'cv2' has no attribute '_registerMatType 问题解决

简介: 'cv2' has no attribute '_registerMatType 问题解决

1.报错信息


/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/cv2/mat_wrapper/__init__.py in <module> 31 Mat.__module__ = cv.__name__ 32 cv.Mat = Mat ---> 33 cv._registerMatType(Mat) AttributeError: module 'cv2' has no attribute '_registerMatType'

今天使用opencv碰到的,感觉有点怪怪的,后来就github搜索,其实这个问题在2021年就已经有人说了。


2.信息确认


错了当然第一时间github查了,会特别准确,不建议百度。

github.com/opencv/open…


3.降级解决


There is mess with versions:
-   `_registerMatType` is a part of OpenCV 4.5.4
-   but you mention 4.5.1
Please ensure that you have installed one version of OpenCV only.


4.headless解决


I solved this error on Google Colab by downloading the headless open-cv and of a version below 4.3 because [backward compatibility](https://github.com/opencv/opencv-python#backward-compatibility) was dropped since 4.3.0. Try the following command in Google Colab:
`!pip install "opencv-python-headless<4.3"`
Here's a thread from [stack overflow](https://stackoverflow.com/questions/64650877/install-of-opencv-python-headless-takes-a-long-time) on the same issue.

看来大家在codelab上也遇到了。

opencv-python-headless<4.3


5.全部升级法


My problem was related to diferent versions of opencv modules. You can check it with:\
`pip list | grep opencv`
upgrading all modules to the same version solved my error:
pip install --upgrade opencv-python
pip install --upgrade opencv-contrib-python
pip install --upgrade opencv-python-headless


6.总结


建议那就都用最新版本吧,免得这错那错。



目录
相关文章
|
5天前
|
算法 光互联 计算机视觉
Locally Adaptive Color Correction for Underwater Image Dehazing and Matching
该文提出了一种新颖的水下图像处理方法,结合颜色转移和局部调整来校正颜色,以应对水下光照和散射造成的图像退化。传统颜色转移方法基于全局参数,不适应水下场景中颜色变化的局部性质。文章中,作者通过融合策略,利用光衰减水平估计来实现局部颜色校正。首先,通过暗通道先验恢复彩色补偿图像,然后估计光衰减图。接着,创建一个合成图像,该图像的统计特性代表高衰减区域,用于颜色转移。最后,通过加权融合初始图像和颜色转移图像,生成最终的颜色校正图像。这种方法旨在提高水下图像的对比度和颜色准确性,特别关注高衰减区域。
25 1
|
3月前
|
机器学习/深度学习
RuntimeError mat1 and mat2 shapes cannot be multiplied
RuntimeError mat1 and mat2 shapes cannot be multiplied
120 0
|
4月前
|
JavaScript
image-conversion
image-conversion
58 0
|
9月前
|
计算机视觉
图像拼接遇到module ‘cv2.cv2‘ has no attribute ‘xfeatures2d‘
图像拼接遇到module ‘cv2.cv2‘ has no attribute ‘xfeatures2d‘
83 0
|
11月前
|
算法 计算机视觉 Python
【完美解决方案】module ‘cv2.cv2‘ has no attribute ‘xfeatures2d‘
【完美解决方案】module ‘cv2.cv2‘ has no attribute ‘xfeatures2d‘
434 0
|
11月前
|
计算机视觉
cv2.error: OpenCV(4.5.2) : -1 : error: (-5:Bad argument) in function ‘rectangle‘
cv2.error: OpenCV(4.5.2) : -1 : error: (-5:Bad argument) in function ‘rectangle‘
194 0
|
算法 计算机视觉 C++
积分图像(Integral image)
积分图算法由Crow在1984年首次提出,是为了在多尺度透视投影中提高渲染速度。积分图算法是一种快速计算图像区域和以及图像区域平方和的算法。它的核心思想就是对每一个图像建立起自己的积分图查找表,在图像处理的阶段就可以根据预先建立积分图查找表直接查找从而实现对均值卷积的线性时间计算。做到了卷积执行的时间与窗口大小无关。之前介绍的NL-means算法就可以采用积分图算法进行优化加速。
118 0
积分图像(Integral image)
|
Python
完美解决 TypeError: Invalid shape (3, 224, 224) for image data
完美解决 TypeError: Invalid shape (3, 224, 224) for image data
607 0
|
计算机视觉
AttributeError: module 'cv2' has no attribute 'xfeatures2d'问题解决
AttributeError: module 'cv2' has no attribute 'xfeatures2d'问题解决
3170 0
成功解决AttributeError: module &#39;cv2.cv2&#39; has no attribute &#39;CV_CAP_PROP_FPS&#39;和 &#39;CV_CAP_PROP_FRAME_WIDTH&#39;
成功解决AttributeError: module &#39;cv2.cv2&#39; has no attribute &#39;CV_CAP_PROP_FPS&#39;和 &#39;CV_CAP_PROP_FRAME_WIDTH&#39;