A. Attia
A. Attia

Reputation: 1720

OpenCV Segmentation fault for VideoCapture

I am using OpenCV2 with Python for a while and I don't why for a couple days it doesn't work for Video Capturing.
For example, this code works:

>>> import cv2
>>> a = cv2.imread('./pic_video0_145.jpg')
>>> a.shape
(416, 576, 3)

But it doesn't to capture video and exit from Python (or dead kernel in Jupyter Notebook):

>>> import cv2
>>> cap = cv2.VideoCapture('./video6.avi')
Segmentation fault: 11 

It used to work and I don't remember to have changed something regarding OpenCV (perhaps an update of MacPorts).

More information:
I am working on Mac OS X 10.12
Version : 3.2.0
Installed with MacPorts : opencv @3.2.0_1+contrib+debug+python35+qt4+tbb (active)

Thanks very much for any help.

Upvotes: 0

Views: 2172

Answers (1)

A. Attia
A. Attia

Reputation: 1720

Finally, I uninstalled and reinstalled OpenCV2 with MacPorts (proper installation).

sudo uninstall opencv
sudo port install opencv +debug +python35 +qt4 +tbb +contrib 

# To use openCV in a virtual env
cp /opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/cv2.cpython-35m-darwin.so VIRTUALENV_PATH/lib/python3.5/site-packages/

I needed to update numpy too (pip install numpy -U) and it worked.

Upvotes: 1

Related Questions