Next up, confirm where your current OpenCV version is installed. The following command produces the following output: Cellars and SymlinksĬheck that you’re using a Homebrew Python install by confirming that Here I’ll refer to Python 2.7, although you could of course do this for other versions by addingįlags to the homebrew installation of OpenCV. It should work for homebrew users like myself. It’s not pretty, it’s not necessarily advisable, but it works. With version 2.4.12 so that I can choose which one to use from Python. Here’s how I solved the problem, installing OpenCV 3.1.0 side-by-side on my system Meanwhile he was feeling terrifically trendy Like a lot of people, I’ve got a system-wide install of 2.4.X, That my friend and I were actually working from different versions of OpenCV, and as a result the simpleĪpplication wrapper written in Python-OpenCV was crashing even though everything Caffe Recently I’ve been working on a project that’s written in Python/OpenCV/Caffe.Īfter spending a while installing Caffe on OS X, I was pretty disappointed to find out > (0, 'usr/local/lib/python2.7/site-packages/opencv3') If you want to import the 3.x.x version, add the following line at the top of your script to temporarily add the new site-packages subdirectory to the PYTHONPATH:.usr/local/lib/python2.7/site-packages/opencv3/cv2.so $ ln -s /usr/local/Cellar/opencv3/3.x.x/lib/python2.7/site-packages/cv2.so \ Create another subdirectory inside site-packages, for example, /opencv3 and put a symlink to the 3.x.x cv2.so file in there:.usr/local/lib/python2.7/site-packages/cv2.so Homebrew Python imports that module via a symlink at:.Both the above libraries contain a Python module cv2.so, stored at a path similar (but not necessarily identical) to:.brew install opencv3 creates /usr/local/Cellar/opencv3/. brew install opencv creates /usr/local/Cellar/opencv/.Homebrew installs libraries to /usr/local/Cellar/.If these commands import OpenCV and print the correct version without complaining, then the Python bindings are properly installed.Ĭongrats, you just built and installed OpenCV. If the sample runs, then the C libraries are properly installed. If no errors were produced, run a any sample, e.g./cpp/cpp-example-edge We first build the C examples: cd ~/src/opencv/samples Pkg-config -libs opencv # get the libraries path (-L) and the libraries (-l) You can use the following lines to know where OpenCV was installed and which libraries were installed: pkg-config -cflags opencv # get the include path (-I) Now OpenCV should be available to your system. If no errors were produced, we can carry on with installing OpenCV to the system: sudo make install If CMake didn't report any errors or missing libraries, continue with the build. Also feel free to set other flags and customise your build as you see fit. We include the examples in the build, but feel free to leave them out. Issue the following command to get the OpenCV source code and prepare the build: mkdir ~/src Libpng-devlibtiff-dev libjasper-dev libdc1394-22-dev The following packages are optional: sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev \ Libavcodec-dev libavformat-dev libswscale-dev Sudo apt-get install cmake git libgtk2.0-dev pkg-config \ Issue the following commands in your terminal to install the required packages: sudo apt-get update However, these libraries are often out of date. Note: If you don't feel like wasting time building stuff or dislike the terminal, you can most likely install OpenCV from the Synaptic package manager GUI. The steps should stay the same for other distros, just replace the relevant package manager commands when installing packages for the build. This is a step-by-step guide to installing OpenCV 3 on a Debian-based Linux system from source.
0 Comments
Leave a Reply. |