Open cv is a powerful tool for image processing!
I’ll guided you to install open cv for python in Linux platform.
0. Anaconda
If you installed Anaconda
in you computer, you may install opencv
by this command:
conda install opencv
But this may not work, since in Linux, a lot of differences existed.
You may meet this mistakes:
Thefunction is not implemented. Rebuild the library with Windows, GTK+ 2.x orCarbon support. If you are on Ubuntu or Debian, install libgtk2.0‑dev and pkg‑config, then re‑runcmake or configure script
If so, you should use conda uninstall opencv
and then go to the following steps.
1. Follow the official guidance
https://docs.opencv.org/trunk/d2/de6/tutorial_py_setup_in_ubuntu.html
2. Refer to website
https://jingyan.baidu.com/article/14bd256e466474bb6d2612db.html
3. Mistakes I meet
3.1 ‘NppiGraphcutState’
When I reached 95, I got ‘NppiGraphcutState’ has not been declared
as the follow website
https://devtalk.nvidia.com/default/topic/986950/opencv-installation-problem-nppigraphcutinitalloc-not-declared/
This is caused by the Incompatible between cuda8.0
and opencv2
(or opencv3
).
To solve this:
Modify opencv-3.0.0/modules/cudalegacy/src/graphcuts.cpp
file.
In detail:
change
#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER)
to
#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER) || (CUDART_VERSION >= 8000)
Then, re-make. I passed.
3.1 import error
Even I finished make process and I also did
sudo /bin/bash -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'
sudo ldconfig
But I still can’t import cv2
in python.
To solve this, I used
cd /home/xx/anaconda2/lib/python2.7/site-packages/
ln -s /usr/local/lib/python2.7/site-packages/cv2.so cv2.so
Thing done!