Monday, September 24, 2012

mexopencv compile error in MacOSX 10.8

I had the following error message, at the end of this post, when I installed the mexopencv on my MacOSX 10.8 with Xcode 4.5, opencv installed from macports, and config_pkg properly installed.

First of all, I grab the patch from the following link to connect Matlab mex with Xcode,

https://www.mathworks.com/support/solutions/en/data/1-FR6LXJ/

Second, I modify the MACOSX_DEPLOYMENT_TARGET=10.5 into 10.6 or higher.

After these steps, you should be able to compile and enjoy the mexopencv. 

PS: website of mexopencv, (many thanks to kota)
http://www.cs.sunysb.edu/~kyamagu/mexopencv/

/Applications/MATLAB_R2012a.app/bin/mex -c -cxx -largeArrayDims -Iinclude -I/opt/local/include/opencv -I/opt/local/include   src/MxArray.cpp -outdir lib
/opt/local/include/opencv2/flann/params.h: In instantiation of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]':
/opt/local/include/opencv2/flann/params.h:87:   instantiated from here
/opt/local/include/opencv2/flann/params.h:87: error: explicit instantiation of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]' but no definition available
/opt/local/include/opencv2/flann/params.h: In instantiation of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]':
/opt/local/include/opencv2/flann/params.h:87:   instantiated from here
/opt/local/include/opencv2/flann/params.h:87: error: explicit instantiation of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]' but no definition available
/opt/local/include/opencv2/flann/params.h: In instantiation of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]':
/opt/local/include/opencv2/flann/params.h:87:   instantiated from here
/opt/local/include/opencv2/flann/params.h:87: error: explicit instantiation of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]' but no definition available
/opt/local/include/opencv2/flann/params.h: In instantiation of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]':
/opt/local/include/opencv2/flann/params.h:87:   instantiated from here
/opt/local/include/opencv2/flann/params.h:87: error: explicit instantiation of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]' but no definition available
/opt/local/include/opencv2/flann/params.h: In instantiation of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]':
/opt/local/include/opencv2/flann/params.h:87:   instantiated from here
/opt/local/include/opencv2/flann/params.h:87: error: explicit instantiation of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]' but no definition available

   mex: compile of ' "src/MxArray.cpp"' failed.

make: *** [lib/libMxArray.a] Error 1

std::cout undefined issue in MacOSX

In Mac, sometimes, especially in terminal with Makefile, you would meet the error message, such as

"error: explicit instantiation of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]' but no definition available",

even with a simple code as following:

#include <iostream>
int main(){
    std::cout << "hello world" << std::endl;
    return 0;
}

The main reason might be, the compiled being used is gcc instead of g++, in g++, not like gcc, the         -lstdc++ will be automatically added. This will link the STL library with your compiler.

Sunday, September 23, 2012

I'm sorry my baby girl

Today you were not happy to drink milk from bottles. I am very worried about that. Since your Mom may not be able to produce enough milk for you in the future, and if you couldn't drink bottle or formula milk anymore, which means we will be in a big trouble.

Hopefully, you will be better and happier tomorrow.

Upload two images, which you Mom took today. Look how happy you are. :)



Saturday, September 15, 2012

How to compile 3d party mex file in MacOSX 8 (mount lion)

Once you downloaded some .cpp files from 3rd party group, the urgency of testing on new code makes you attempt to compile them asap. However, you may meet the following error message:


/Applications/MATLAB_R2012a.app/bin/mex: line 305: gcc-4.2: command not found
/Applications/MATLAB_R2012a.app/bin/mex: line 1326: g++-4.2: command not found

This is because your matlab haven't been able to co-work with XCode installed on your machine. 

I founding the following solutions from Mathworks.com, it should be official and, it does work, at least on my machine. 

Cheers, and wish you guys good luck. :) 


http://www.mathworks.com/support/solutions/en/data/1-FR6LXJ/

Wednesday, September 12, 2012

Git: How to commit only one file from another branch

Problem claimed as title: How to commit only one file from another branch, (instead of the whole branch)

git checkout <branch-name> <path-to-file>

example: (here, we want to only merge the .gitignore file from desired-branch into current HEAD branch.)

git checkout desired-branch .gitignore


This answer is referred to the following url:
http://jasonrudolph.com/blog/2009/02/25/git-tip-how-to-merge-specific-files-from-another-branch/

Monday, September 10, 2012

resize Image in OpenCV

This is simple. Just in case people may need it sometimes.
Here, we resize the image into 1 quarter of the original image, with half height and width comparing to original image.


#include <iostream>
#include <opencv2/opencv.hpp>

int main(int argc, const char * argv[])
{
    // Read original image into varialbe img
    cv::Mat img = cv::imread("/Users/herbert19lee/Desktop/lena1.jpg");
    // Declare variable img_resize as container for resized image
    cv::Mat img_resize;

    // resize the original img, as half size of original cols and rows
    // cv::Size2i(img.cols/2, img.rows/2) is where you specify the desired dimension for resized image
    cv::resize(img, img_resize, cv::Size2i(img.cols/2, img.rows/2));
  
    // Visualize the original and resized image in window: lena and lena_resize respectively. 
    cv::namedWindow("lena");
    cv::namedWindow("lena_resize");
    cv::imshow("lean", img);
    cv::imshow("lena_resize", img_resize);
    
    cv::waitKey();
    return 0;
}

Saturday, September 8, 2012

How to create bootable Windows 7 disk on Mac OSX


1. Double click the .iso file to mount the disk
2. One the menu bar at the top, click "Images" -> "Convert"
3. Make sure the "Image Format:" is set to "DVD/CD master"
4. Save the IMage where you want to locate, it will prompt to ask to save as ".cdr" file
5. Navigate to the Image you just created and change the extension from ".cdr" to ".iso"
6. Burn it using Disk Utility and this CD should be bootable.


This information is learnt from the following link:

http://kyliente.wordpress.com/2010/04/02/making-windows-bootable-cddvd-with-mac-disk-utility/

Monday, September 3, 2012

org-mac-link-grabber with Aquamacs

Org mode is a powerful plus for emacs, if you want to organize you daily life to be more productive.

When you note you everyday work, especially communicating with co-workers, such as you advisor, boss, students. You may want to add a reference to you work todo list, note or working log, such an email, url or even a contact. This is where org-mac-link-grabber shining.

You could install this mode easily follow the link below:

http://orgmode.org/worg/org-contrib/org-mac-link-grabber.html

However, unfortunately, this is not enough, after you follow the link above, you will find emacs can not find function omlg-grab-link,this is because you haven't let the emacs link where org-mac-link-grabber.el is.

You may need to follow the link below:

http://irreal.org/blog/?p=732

Especially this two lines:


(add-to-list 'load-path (expand-file-name "~/.xemacs/org-mode/contrib/lisp")) ; where your org-mac-link-grabber.el lives
(require 'org-mac-link-grabber)

After all this, enjoy! You will be more productive tmw, hopefully. :)


Sunday, September 2, 2012

Installing Qt on Mac MountLion

Don't install qt though Macports till now "2 Sep 2012" It just doesn't work yet.

Install the QtSDK, which includes Qt Creator, save you some trouble.

After Installation, when you run an application, you may incur an error in the following link,

http://qt-project.org/forums/viewthread/19106/P15

Follow the instruction.

If you don't know where the g++-macx.conf is, just search this file name within "This Mac"
(in my system it lies in: QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/common/g++-macx.conf)

If you still have problems, pls make sure you are using Qt Version: Desktop Qt 4.8.1 for GCC (Qt SDK) in  QT projects setting.


prettify