AttributeError: module 'cv2' has no attribute 'Mat'

Hi! I’m trying to deploy the app that uses the cv2 and some other libraries that also use cv2 as the independence. Right now, I have these on the requirements.txt

opencv-python-headless
ffmpeg
scenedetect[opencv-headless]
ultralytics
deepface
SpeechRecognition
pyav
imutils
moviepy

and these are on my packages.txt

freeglut3-dev
libgtk2.0-dev
libgl1-mesa-glx
cv2

However, I have an error that I have never seen before on

AttributeError: module 'cv2' has no attribute 'Mat'
Traceback:
File "/home/vscode/.local/lib/python3.11/site-packages/streamlit/runtime/scriptrunner/exec_code.py", line 88, in exec_func_with_error_handling
    result = func()
             ^^^^^^
File "/home/vscode/.local/lib/python3.11/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 579, in code_to_exec
    exec(code, module.__dict__)
File "/workspaces/YT-video-summarizer/summarizer.py", line 3, in <module>
    from cis5810_final_project import video_summarization
File "/workspaces/YT-video-summarizer/cis5810_final_project.py", line 5, in <module>
    from scenedetect import detect, AdaptiveDetector, split_video_ffmpeg
File "/home/vscode/.local/lib/python3.11/site-packages/scenedetect/__init__.py", line 54, in <module>
    from scenedetect.scene_manager import SceneManager, save_images, SceneList, CutList, Interpolation
File "/home/vscode/.local/lib/python3.11/site-packages/scenedetect/scene_manager.py", line 413, in <module>
    image: cv2.Mat,
           ^^^^^^^

Can someone guide me on this?

In latest version of OpenCV, images are typically represented by numpy arrays, not cv2.Mat objects (which was used in older versions or in other languages like C++).

1 Like