1

I am trying to install OpenCV on my Ubuntu 14.04. I have Python 2.7 in usr/bin/python2.7. I am trying to compile OpenCV to use my miniconda python 3.6 interpreter, but it always installs on my python 2.7 interpreter. I don't know how to fix this.

Here is the guide I am following. These are the cmake commands I run:

cmake -D CMAKE_BUILD_TYPE=RELEASE \
    -D CMAKE_INSTALL_PREFIX=/usr/local \
    -D INSTALL_C_EXAMPLES=ON \
    -D INSTALL_PYTHON_EXAMPLES=ON \
    -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules \
    -D BUILD_EXAMPLES=ON 
    -D PYTHON_DEFAULT_EXECUTABLE=$(which python3) ..

And this is the relevant output I am getting when I run it:

--   GUI: 
--     QT:                          NO
--     GTK+ 3.x:                    YES (ver 3.10.8)
--     GThread :                    YES (ver 2.40.2)
--     GtkGlExt:                    NO
--     OpenGL support:              NO
--     VTK support:                 NO
-- 
--   Media I/O: 
--     ZLib:                        /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.8)
--     JPEG:                        /usr/lib/x86_64-linux-gnu/libjpeg.so (ver )
--     WEBP:                        build (ver 0.3.1)
--     PNG:                         /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.2.50)
--     TIFF:                        build (ver 42 - 4.0.2)
--     JPEG 2000:                   /usr/lib/x86_64-linux-gnu/libjasper.so (ver 1.900.1)
--     OpenEXR:                     /usr/lib/x86_64-linux-gnu/libImath.so /usr/lib/x86_64-linux-gnu/libIlmImf.so /usr/lib/x86_64-linux-gnu/libIex.so /usr/lib/x86_64-linux-gnu/libHalf.so /usr/lib/x86_64-linux-gnu/libIlmThread.so (ver 1.6.1)
--     GDAL:                        NO
-- 
--   Video I/O:
--     DC1394 1.x:                  NO
--     DC1394 2.x:                  YES (ver 2.2.1)
--     FFMPEG:                      YES
--       codec:                     YES (ver 54.35.1)
--       format:                    YES (ver 54.20.4)
--       util:                      YES (ver 52.3.0)
--       swscale:                   YES (ver 2.1.1)
--       resample:                  YES (ver 1.0.1)
--       gentoo-style:              YES
--     GStreamer:                   
--       base:                      YES (ver 1.2.4)
--       video:                     YES (ver 1.2.4)
--       app:                       YES (ver 1.2.4)
--       riff:                      YES (ver 1.2.4)
--       pbutils:                   YES (ver 1.2.4)
--     OpenNI:                      NO
--     OpenNI PrimeSensor Modules:  NO
--     OpenNI2:                     NO
--     PvAPI:                       NO
--     GigEVisionSDK:               NO
--     UniCap:                      NO
--     UniCap ucil:                 NO
--     V4L/V4L2:                    Using libv4l1 (ver 1.0.1) / libv4l2 (ver 1.0.1)
--     XIMEA:                       NO
--     Xine:                        NO
--     gPhoto2:                     NO
-- 
--   Other third-party libraries:
--     Use IPP:                     8.2.1 [8.2.1]
--          at:                     /home/tex/opencv/3rdparty/ippicv/unpack/ippicv_lnx
--     Use IPP Async:               NO
--     Use Eigen:                   YES (ver 3.2.0)
--     Use TBB:                     YES (ver 4.2 interface 7000)
--     Use OpenMP:                  NO
--     Use GCD                      NO
--     Use Concurrency              NO
--     Use C=:                      NO
--     Use pthreads for parallel for:
--                                  NO
--     Use Cuda:                    NO
--     Use OpenCL:                  YES
-- 
--   OpenCL:
--     Version:                     dynamic
--     Include path:                /home/tex/opencv/3rdparty/include/opencl/1.2
--     Use AMDFFT:                  NO
--     Use AMDBLAS:                 NO
-- 
--   Python 2:
--     Interpreter:                 /usr/bin/python2.7 (ver 2.7.6)
--     Libraries:                   /usr/lib/x86_64-linux-gnu/libpython2.7.so (ver 2.7.6)
--     numpy:                       /usr/local/lib/python2.7/dist-packages/numpy/core/include (ver 1.13.1)
--     packages path:               lib/python2.7/dist-packages
-- 
--   Python 3:
--     Interpreter:                 /home/tex/miniconda3/bin/python (ver 3.6.3)
--     Libraries:                   /home/tex/miniconda3/lib/libpython3.6m.so (ver 3.6.3)
--     numpy:                       /home/tex/miniconda3/lib/python3.6/site-packages/numpy/core/include (ver 1.13.3)
--     packages path:               /home/tex/miniconda3/lib/python3.6/site-packages
-- 
--   Python (for build):            /usr/bin/python2.7
-- 
--   Java:
--     ant:                         NO
--     JNI:                         /usr/lib/jvm/java-8-oracle/include /usr/lib/jvm/java-8-oracle/include/linux /usr/lib/jvm/java-8-oracle/include
--     Java wrappers:               NO
--     Java tests:                  NO
-- 
--   Matlab:
--     mex:                         NO
-- 
--   Documentation:
--     Doxygen:                     NO
--     PlantUML:                    NO
-- 
--   Tests and samples:
--     Tests:                       NO
--     Performance tests:           NO
--     C/C++ Examples:              YES
-- 
--   Install path:                  /usr/local
-- 
--   cvconfig.h is in:              /home/tex/opencv/build
-- -----------------------------------------------------------------

How do I make it build on miniconda?

Edit: not a duplicate because that command conda install opencv-python installs opencv without video support, which I need.

John Lexus
  • 3,576
  • 3
  • 15
  • 33
  • No, sorry, I am installing OpenCV with video support - very important. Installing OpenCV that way does NOT provide video support. – John Lexus Dec 14 '17 at 20:26
  • What about this one : [VideoCapture Does Not Work in Anaconda](https://stackoverflow.com/questions/29249611/videocapture-does-not-work-in-anaconda) ? – Loïc G. Dec 14 '17 at 21:18

1 Answers1

1

Use gedit and run:

gedit ~/opencv/cmake/OpenCVDetectedPython.cmake

Go to the last lines (the if statement that says if(PYTHON2INTERP_FOUND) and change the whole if block to:

if(PYTHON3INTERP_FOUND)
    set(PYTHON_DEFAULT_AVAILABLE "TRUE")
    set(PYTHON_DEFAULT_EXECUTABLE "/home/tex/miniconda3/bin/python")
endif()

Worked for me...

user3026388
  • 300
  • 2
  • 12