After importing opencv-python , the corresponding functions don't work

148 Views Asked by At

I'm new to learning on opencv-python. So I started by creating a new python project named OpenCV and then imported opencv-python package and then started typing in my code in a new Python file. But once I try running the file I keep getting error.

Code And Error img

It seems as if imread() and imshow() - none are accepted. I tried importing imread() separately by using cmd and my terminal but nothing seems to works. It further shows legacy error.

import cv2
img = cv2.imread('lena.jpg', 1)
print(img)
cv2.imshow('image', img)
cv2.waitKey(10000)


cv2.destroyAllWindows()

My error: Traceback (most recent call last): File "/Users/mac/myprojects/opencv/read_and_display_image.py", line 1, in import cv2

File "/Users/mac/myprojects/opencv/openenv/lib/python3.9/site-packages/cv2/init.py", line 181, in bootstrap()

File "/Users/mac/myprojects/opencv/openenv/lib/python3.9/site-packages/cv2/init.py", line 153, in bootstrap native_module = importlib.import_module("cv2")

File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level)

ImportError: dlopen(/Users/mac/myprojects/opencv/openenv/lib/python3.9/site-packages/cv2/cv2.abi3.so, 2): Symbol not found: _VTRegisterSupplementalVideoDecoderIfAvailable

Referenced from: /Users/mac/myprojects/opencv/openenv/lib/python3.9/site-packages/cv2/.dylibs/libavcodec.59.37.100.dylib

Expected in: /System/Library/Frameworks/VideoToolbox.framework/Versions/A/VideoToolbox in /Users/mac/myprojects/opencv/openenv/lib/python3.9/site-packages/cv2/.dylibs/libavcodec.59.37.100.dylib

0

There are 0 best solutions below