opencv python debug记录

        本文将持续记录opencv-python使用过程中出现的常见错误和解决方案。

1  window.cpp:1274: error: (-2:Unspecified error) The function is not implemented

        该错误通常表现为连最基本的cv2.imshow都无法使用。报错内容为:window.cpp:1274: error: (-2:Unspecified error) The function is not implemented.

Traceback (most recent call last):
File “/home/data/PJS/test_bed/img_show.py”, line 18, in
cv2.imshow(‘img’, img)
cv2.error: OpenCV(4.5.3) /tmp/pip-req-build-9gwtlx3c/opencv/modules/highgui/src/window.cpp:1274: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function ‘cvShowImage’
        解决方法:

import cv2
print(cv2.__file__)
#删除打印出来的cv2文件夹即可
#如果不行,卸载并重新安装opencv-python就可以了

2 error: (-215:Assertion failed) iDepth == CV_8U || iDepth == CV_8S in function 'cv::connectedComponents_sub1'

        出现这个错误,通常原因是图像矩阵的元素不是整数,所以报的是数据格式相关的错误提示。

image = image.astype(np.uint8)

3 Linux下lib缺失

ImportError: libSM.so.6: cannot open shared object file: No such file or directory
apt-get install libsm6
ImportError: libXrender.so.1: cannot open shared object file: No such file or directory
apt-get install libxrender1
ImportError: libGL.so.1: cannot open shared object file: No such file or directory
apt install libgl1-mesa-glx

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Coding的叶子

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值