Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Segmentation fault" during "import cv" on Mac OS

Trying to compile opencv on my Mac from source.

I have following CMakeCache.txt: http://pastebin.com/KqPHjBx0

I make ccmake .., press c, then g. Than I make sudo make -j8: http://pastebin.com/cJyr1cEd

Than I make sudo make install: http://pastebin.com/W77syYBj

And than I make import cv in python and get "Segmentation faul" with this stacktrace: http://pastebin.com/gegYAK1u

I don't know what could be useful to help me, pls. ask, I'll get it.

like image 475
Aleksandr Motsjonov Avatar asked Mar 09 '11 06:03

Aleksandr Motsjonov


2 Answers

I had a same situation and resolved the following steps.

In ccmake(ccmake -G "Unix Makefiles" .), toggle to the advanced mode pressing t.

change PYTHON_LIBRARY value to /opt/local/lib/libpython2.6.dylib and PYTHON_INCLUDE_DIR to /opt/local/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6.

Note that the specific path depends, of course, what version of Python you are using (2.6 or 2.7 etc.). Also, if you are using the system Python, instead of MacPorts (which is in /opt), then you probably want PYTHON_LIBRARY to be /usr/lib/libpython2.6.dylib

like image 194
masa Avatar answered Oct 05 '22 14:10

masa


From your logs, you seem to use MacPorts and python 2.6.

opencv will compile fine on this framework:

sudo port install  opencv +python26

be sure to have py26-numpy installed to have support for basic functions such as cv.fromarray :

sudo port install py26-numpy

means that your problem has been solved by the MacPorts community. is it a problem of the latest source? the version you compile is the one (opencv 2.2.0) used by macports.

Your question is about compiling from source. Looking at the portfile linked to that you'll be able to locate your problem. to find the Portfile, do:

port file opencv

or directly

sudo port edit  opencv

this will list all configuration flags necessary for a working openCV.

like image 31
meduz Avatar answered Oct 05 '22 15:10

meduz