Install OpenCv for python in Linux

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 Anacondain you computer, you may install opencvby 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.cppfile.
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 cv2in 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!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值