0
votes

When following the below tutorial:

brew install python3 pip3 install numpy brew install cmake git clone --depth=1 https://github.com/Itseez/opencv.git cd opencv mkdir build cd build

note: in the next line, adjust paths to point to the correct python version cmake -DBUILD_opencv_python3=YES -DBUILD_opencv_python2=NO

-DINSTALL_PYTHON_EXAMPLES=YES -DPYTHON3_EXECUTABLE=/usr/local/bin/python3 -DPYTHON3_INCLUDE_DIR=/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/include/python3.5m/ -DPYTHON3_LIBRARY=/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/libpython3.5.dylib -DPYTHON3_NUMPY_INCLUDE_DIRS=/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/numpy/core/include/ -DPYTHON3_PACKAGES_PATH=/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/ .. make -j8 make install python3 -c "import cv2; print(cv2.version)"

I get this error for line 10 $ make -j8:

[ 39%] Built target opencv_shape
In file included from /Users/mona/Downloads/opencv/modules/videoio/src/cap_ffmpeg.cpp:47:
In file included from /Users/mona/Downloads/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:65:
/Users/mona/Downloads/opencv/modules/videoio/src/ffmpeg_codecs.hpp:77:12: fatal error: 
      'libavformat/avformat.h' file not found
  #include <libavformat/avformat.h>
           ^
1 error generated.
make[2]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_ffmpeg.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
[ 40%] Linking CXX shared library ../../lib/libopencv_photo.dylib
[ 40%] Built target opencv_photo
make[1]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/all] Error 2
make: *** [all] Error 2
Monas-MacBook-Pro:build mona$ 

Why is this tutorial not passing on my OSX?

1
Have you followed the note: in the next line, adjust paths to point to the correct python version?usr1234567
That include is from FFmpeg. Do you have that package installed, or otherwise accessible? If you don't, and don't want to install it, you can add -DWITH_FFMPEG:BOOL=FALSE to your configure.StAlphonzo
I believe ffmpeg is necessary for opencv that is why it is looking for it! @StAlphonzoMona Jalal
No, you can build OpenCV with out it, I do all the time. But, if you are concerned then just make sure it's installed and on your path somewhere for OpenCV to find. I was only posing the simpler of the 2 options. You have to do one or the other though.StAlphonzo

1 Answers

0
votes

So this is how I solved the problem. Please let me know if you might have further questions:

 ~  c   master ⭑  Face_Recognition  ls                                                                                                  10:03:38 PM
3.1.0.zip            3.1.0.zip.1          opencv-3.1.0         opencv_contrib-3.1.0 papers
-------------------------------------------------------  

In opencv-3.1.0/modules/viz/src/vtk/vtkCocoaInteractorFix.mm
#if VTK_MAJOR_VERSION >= 6 && VTK_MINOR_VERSION >=2

If we use VTK 7.0.0, although it is a newer version, the minor version is less than two, so the vtkCocoaInteractorFix.mm will handle this as older VTK versions and that causes the problem.

So to fix this we just need to add the version number 7 to the line.

#if VTK_MAJOR_VERSION >= 6 && VTK_MINOR_VERSION >=2 || VTK_MAJOR_VERSION >=7
---------------------------------------------------------------------------
cmake -D CMAKE_BUILD_TYPE=RELEASE \
      -D CMAKE_INSTALL_PREFIX=/usr/local \
      -D BUILD_opencv_java=OFF \
      -D WITH_IPP=OFF -D WITH_1394=OFF \
      -D WITH_FFMPEG=OFF\
      -D BUILD_EXAMPLES=ON \
      -D BUILD_TESTS=ON \
      -D BUILD_PERF_TESTS=OFF \
      -D BUILD_DOCS=ON \
      -D BUILD_opencv_python3=ON \
      -D BUILD_opencv_video=ON \
      -D BUILD_opencv_videoio=ON \
      -D BUILD_opencv_videostab=ON \
      -D PYTHON_EXECUTABLE=$(which python) \
      -D OPENCV_EXTRA_MODULES_PATH=/Users/mona/computer_vision/Face_Recognition/opencv_contrib-3.1.0/modules ..


-------------------------------------------------------     
make -j4


-------------------------------------------------------   
sudo make install

Main points are -D WITH_FFMPEG=OFF and also giving the absolute path to opencv modules in -D OPENCV_EXTRA_MODULES_PATH=/Users/mona/computer_vision/Face_Recognition/opencv_contrib-3.1.0/modules ..