Install openCV using anaconda on ubuntu

I am trying to use the openCV library with anaconda (Python), I can import the cv2 package, but so far nothing has been received .mp4. This is a problem with ffmpeg that I have no idea about. I can’t send the code right now, since I use my phone. But if someone can give me a Linux script or tutorial that can help me work with openCV in python to be able to parse h264 encoded mp4 video, that would be great

+6
source share
4 answers

I believe that I am on the way to a solution, so I am posting this to help others.

Download conda-recipes . Sitting in this directory, run conda build x264 and then conda build ffmpeg .

Since my system is 32-bit, I had to change one line in conda-recipes/x264/build.sh and conda-recipes/ffmpeg/build.sh before I could successfully complete conda build . I changed

 export CFLAGS="-Wall -g -m64 -pipe -O2 -march=x86-64 -fPIC" 

to

 export CFLAGS="-Wall -g -m32 -pipe -O2 -march=x86-64 -fPIC" 

I really don't understand what I'm doing, but I figured it would help, and now both assemblies work without errors.

However, opencv does not seem to use FFmpeg; I still can’t open the video files as I can outside the conda. I will update if I ever get this job.

+4
source

Conda's standard OpenCV package does not support ffmpeg. To solve this problem, I compiled OpenCV for Linux-64 with ffmpeg activated in CMake. I downloaded the package to my binstar channel and you can install it using the following command:

 conda install -c https://conda.binstar.org/jaimeivancervantes opencv 
+1
source

I guess I just managed to create opencv3.1.0 for python 3.5 on LinuxMint17 (mostly Ubuntu 14) using menpo-opencv3 at https://github.com/menpo/conda-opencv3.This menpo package comes with opencv-contrib modules. Amazing ...

First, make sure that source deactivate , because the assembly of the conda package should be done in the main cond.

 conda install conda-build git clone https://github.com/menpo/conda-opencv3 cd conda-opencv3 conda config --add channels menpo conda build conda/ conda install /PATH/TO/OPENCV3/PACKAGE.tar.gz 

As indicated in the instructions, in the default setting, FFMPEG is disabled. So, I had to edit the build.sh file located in conda-opencv3/conda to do -DWITH_FFMPEG=0 to -DWITH_FFMPEG=1 before doing conda build conda/ .

If conda build conda/ , at the end you will see something like this.

If you want to download this package at anaconda.org later, enter:

$ download anaconda / home / username / anaconda 3 / conda-bld / linux-64 / opencv3-3.1.0-py35_0.tar.bz2

This is the path to the conda package we just created (I think).

So, now we can activate conda env, we want to install this package (for example, cv2-env)

source activate cv2-env

then

conda install /home/username/anaconda3/conda-bld/linux-64/opencv3-3.1.0-py35_0.tar.bz2

With the package installed, I could use cv2.VideoCapture to load some AVI file recorded in Windows 7.

(menpo even has opencv v2.4 https://github.com/menpo/conda-opencv , but I have not tried it. And note that 2 and 3 cannot cooperate, exist.)

+1
source
 + curl -L https://raw.githubusercontent.com/Itseez/opencv_3rdparty/81a676001ca8075ada498583e4166079e5744668/ippicv/ippicv_linux_20151201.tgz -o /home/vasu/anaconda2/conda-bld/work/opencv-3.1.0/3rdparty/ippicv/downloads/linux-808b791a6eac9ed78d32a7666804320e/ippicv_linux_20151201.tgz % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- 0:00:05 --:--:-- 0curl: (77) error setting certificate verify locations: CAfile: /etc/pki/tls/certs/ca-bundle.crt CApath: none Command failed: /bin/bash -x -e /home/vasu/anaconda2/conda-bld/work/opencv-3.1.0/conda_build.sh 
0
source

Source: https://habr.com/ru/post/957622/


All Articles