Skip to content

cv2.Mat does not exist in opencv cuda build #468

@subbyte

Description

@subbyte

Description:

dvr-scan reports an error when running with MOG2_CUDA.

Command:

dvr-scan -b MOG2_CUDA -i example.mp4

Output:

Traceback (most recent call last):
  File "venv/dvr-scan/bin/dvr-scan", line 5, in <module>
    from dvr_scan.__main__ import main
  File "venv/dvr-scan/lib/python3.13/site-packages/dvr_scan/__init__.py", line 40, in <module>
    from dvr_scan.platform import init_logger
  File "venv/dvr-scan/lib/python3.13/site-packages/dvr_scan/platform.py", line 29, in <module>
    from scenedetect.platform import get_and_create_path, get_ffmpeg_version
  File "venv/dvr-scan/lib/python3.13/site-packages/scenedetect/__init__.py", line 54, in <module>
    from scenedetect.scene_manager import SceneManager, save_images, SceneList, CutList, Interpolation
  File "venv/dvr-scan/lib/python3.13/site-packages/scenedetect/scene_manager.py", line 413, in <module>
    image: cv2.Mat,
           ^^^^^^^
AttributeError: module 'cv2' has no attribute 'Mat'

Environment:

  • Python 3.13
  • dvr-scan 1.6.2
  • scenedetect 0.6.5 (0.6.4 did not have this problem)
  • OpenCV 4.10 compiled with cuda (python-opencv-cuda)

Debug:

I replaced cv2.Mat with cv2.UMat in scene_manager.py and it works now. Basically some compilation of CUDA-enabled OpenCV does not have cv2.Mat but only cv2.UMat, e.g., python-opencv-cuda.

Python 3.13.1 (main, Dec  4 2024, 18:05:56) [GCC 14.2.1 20240910] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.Mat
Traceback (most recent call last):
  File "<python-input-1>", line 1, in <module>
    cv2.Mat
AttributeError: module 'cv2' has no attribute 'Mat'
>>> cv2.UMat
<class 'cv2.UMat'>
>>> 

I suspect this is related to #456 when cv2.Mat was added to scene_manager.py. I didn't have this issue with version 0.6.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions