Skip to content

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

Closed

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

Activity

  1. subbyte commented on Dec 23, 2024

    @subbyte
    Author
  2. changed the title [-]cv2.Mat does not exist in opencv cuda build[/-] [+]cv2.Mat does not exist in some opencv cuda build[/+] on Dec 23, 2024
  3. changed the title [-]cv2.Mat does not exist in some opencv cuda build[/-] [+]cv2.Mat does not exist in opencv cuda build[/+] on Dec 23, 2024
  4. added this to the 0.6.6 milestone on Dec 23, 2024
  5. Breakthrough commented on Dec 23, 2024

    @Breakthrough
    Owner

    Thanks for letting me know, I'll make sure this prioritized for resolution in the next release. We should probably audit the use of cv2.Mat and replace most usages with numpy.ndarray.

  6. Breakthrough commented on Dec 23, 2024

    @Breakthrough
    Owner

    @subbyte I've just pushed a new version (0.6.5.2) that should fix this issue. Let me know if you run into any other issues, thanks for the report!

  7. removed this from the 0.6.6 milestone on Dec 23, 2024
  8. pinned this issue on Dec 23, 2024
  9. subbyte commented on Dec 24, 2024

    @subbyte
    Author

    Fix confirmed. Thank you!

  10. unpinned this issue on Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions