Home > Blockchain >  cannot import name '_registerMatType' from 'cv2.cv2'
cannot import name '_registerMatType' from 'cv2.cv2'

Time:01-01

I got below error message when I run model_main_tf2.py on Object Detection API. " Traceback (most recent call last): File "/content/models/research/object_detection/model_main_tf2.py", line 32, in from object_detection import model_lib_v2 File "/usr/local/lib/python3.7/dist-packages/object_detection/model_lib_v2.py", line 29, in from object_detection import eval_util File "/usr/local/lib/python3.7/dist-packages/object_detection/eval_util.py", line 36, in from object_detection.metrics import lvis_evaluation File "/usr/local/lib/python3.7/dist-packages/object_detection/metrics/lvis_evaluation.py", line 23, in from lvis import results as lvis_results File "/usr/local/lib/python3.7/dist-packages/lvis/init.py", line 5, in from lvis.vis import LVISVis File "/usr/local/lib/python3.7/dist-packages/lvis/vis.py", line 1, in import cv2 File "/usr/local/lib/python3.7/dist-packages/cv2/init.py", line 9, in from .cv2 import _registerMatType ImportError: cannot import name '_registerMatType' from 'cv2.cv2' (/usr/local/lib/python3.7/dist-packages/cv2/cv2.cpython-37m-x86_64-linux-gnu.so) "

The weird thing is I run the same code before, it worked well but now it give me an error.

CodePudding user response:

The same thing occurred to me yesterday when I used Colab. A possible reason may be that the version of opencv-python(4.1.2.30) does not match opencv-python-headless(4.5.5.62). Or the latest version 4.5.5 may have something wrong...

I uninstalled opencv-python-headless==4.5.5.62 and installed 4.1.2.30 and it fixed.

CodePudding user response:

Thanks Dharman. Yes, I have solved this issue by the similar way of yours. This is my solution. !pip uninstall opencv_python_headless !pip install opencv-python-headless==4.5.4.60

CodePudding user response:

I was also facing same issue. version 4.1.2.30 worked for me.

  • Related