Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
subbyte opened this issue Dec 23, 2024 · 4 comments
Closed

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

subbyte opened this issue Dec 23, 2024 · 4 comments
Labels

Comments

@subbyte
Copy link

subbyte commented Dec 23, 2024

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

@subbyte
Copy link
Author

subbyte commented Dec 23, 2024

Seems like someone else also encountered this: https://discuss.streamlit.io/t/attributeerror-module-cv2-has-no-attribute-mat/86727

@subbyte subbyte changed the title cv2.Mat does not exist in opencv cuda build cv2.Mat does not exist in some opencv cuda build Dec 23, 2024
@subbyte subbyte changed the title cv2.Mat does not exist in some opencv cuda build cv2.Mat does not exist in opencv cuda build Dec 23, 2024
@Breakthrough Breakthrough added this to the 0.6.6 milestone Dec 23, 2024
@Breakthrough
Copy link
Owner

Breakthrough commented Dec 23, 2024

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.

@Breakthrough
Copy link
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!

@subbyte
Copy link
Author

subbyte commented Dec 24, 2024

Fix confirmed. Thank you!

@Breakthrough Breakthrough unpinned this issue Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants