Segmentation fault while import cv2 in centos [closed]

asked Apr 17 '16

moresnow gravatar image

I'm installing Opencv3 on Centos 2.6 with Python 2.6. I get the error when I import cv. I get a Segmentation fault error.

I'm installing OpenCV like this:

yum update && \
yum install -y libjpeg-turbo && \
yum install -y libtiff-devel && \
yum install -y libpng-devel && \
yum install -y cmake python-devel numpy gcc gcc-c++ gtk2-devel libdc1394-devel libv41-devel ffmpeg-devel gstreamer-plugins-base-devel && \
yum groupinstall -y "Development Tools"

cmake -D CMAKE_BUILD_TYPE=RELEASE -D \
CMAKE_INSTALL_PREFIX=/usr/local -D \
OPENCV_EXTRA_MODULES_PATH=/opencv_contrib/modules/ .. 

make -j4 
make install 

/usr/local/lib/python2.6/site-packages/cv2.so /usr/lib/python2.6/site-packages/

Importing cv2 gives a segmentation fault error. I get the following output:

[root@localhost ~]# python
Python 2.6.6 (r266:84292, Jul 23 2015, 15:22:56)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Segmentation fault
Preview: (hide)

Closed for the following reason the question is answered, right answer was accepted by moresnow
close date 2016-04-17 06:06:29.208501

Comments

1

it's probably a better idea, to build cv2.pyd statically:

cmake -D BUILD_SHARED_LIBS=OFF ......
berak gravatar imageberak (Apr 17 '16)edit

I'm unaware what the difference is? can you please explain. if I use that flag, will it make the cv2.so that I then move to PYTHON PATH?

moresnow gravatar imagemoresnow (Apr 17 '16)edit

this way, cv2.so will be no more dependant on opencv so's at runtime

(but again, we don't know the reason for the crash, this is just a blunt guess)

berak gravatar imageberak (Apr 17 '16)edit

well, what do you know...that worked. It created a cv2.so as well and after moving it to /usr/lib/python2.6/site-packages/ i was able to import cv2.

moresnow gravatar imagemoresnow (Apr 17 '16)edit

is it resolved, then ? can we close it ?

berak gravatar imageberak (Apr 17 '16)edit