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

AttributeError: 'DXCamera' object has no attribute 'is_capturing' #74

Open
ghost opened this issue Oct 24, 2023 · 2 comments
Open

AttributeError: 'DXCamera' object has no attribute 'is_capturing' #74

ghost opened this issue Oct 24, 2023 · 2 comments

Comments

@ghost
Copy link

ghost commented Oct 24, 2023

So I had working code yesterday. I didn't change a thing. Now suddenly dxcam is throwing this error:

Loading camera...
Traceback (most recent call last):
  File "C:\Users\xxx\PycharmProjects\yolov8\__main__.py", line 96, in <module>
    main()
  File "C:\Users\xxx\PycharmProjects\yolov8\__main__.py", line 84, in main
    camera = load_camera(region)
             ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\xxx\PycharmProjects\yolov8\__main__.py", line 56, in load_camera
    camera = dxcam.create(device_idx=0, region=region)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\xxx\PycharmProjects\yolov8\venv\Lib\site-packages\dxcam\__init__.py", line 112, in create
    return __factory.create(
           ^^^^^^^^^^^^^^^^^
  File "C:\Users\xxx\PycharmProjects\yolov8\venv\Lib\site-packages\dxcam\__init__.py", line 71, in create
    camera = DXCamera(
             ^^^^^^^^^
  File "C:\Users\xxx\PycharmProjects\yolov8\venv\Lib\site-packages\dxcam\dxcam.py", line 33, in __init__
    self._duplicator: Duplicator = Duplicator(
                                   ^^^^^^^^^^^
  File "<string>", line 6, in __init__
  File "C:\Users\xxx\PycharmProjects\yolov8\venv\Lib\site-packages\dxcam\core\duplicator.py", line 19, in __post_init__
    output.output.DuplicateOutput(device.device, ctypes.byref(self.duplicator))
_ctypes.COMError: (-2005270524, 'The specified device interface or feature level is not supported on this system.', (None, None, None, 0, None))
Exception ignored in: <function DXCamera.__del__ at 0x0000022E282677E0>
Traceback (most recent call last):
  File "C:\Users\xxx\PycharmProjects\yolov8\venv\Lib\site-packages\dxcam\dxcam.py", line 243, in __del__
    self.release()
  File "C:\Users\xxx\PycharmProjects\yolov8\venv\Lib\site-packages\dxcam\dxcam.py", line 238, in release
    self.stop()
  File "C:\Users\xxx\PycharmProjects\yolov8\venv\Lib\site-packages\dxcam\dxcam.py", line 138, in stop
    if self.is_capturing:
       ^^^^^^^^^^^^^^^^^
AttributeError: 'DXCamera' object has no attribute 'is_capturing'

I don't understand why this is happening. I don't think it is an issue with my code.

@mmayorga97
Copy link

mmayorga97 commented Oct 24, 2023

hey 0xDEITY,

Per the exception:
'The specified device interface or feature level is not supported on this system.'

When creating the instance keep it simple unless you need to, like setting 2 gpu or 2 monitors. In my case, I noticed NOT setting the "device" or "output" helps, and only to define the "region", as code below
camera = dxcam.create(region=region)
Also you may check if "dxcam.device_info()", "dxcam.output_info()", for more details.

Running this code works if you run it for one or multiple instances in the same scope.


I'm using version 0.0.5 and I'm having the same "is_capturing" issue but with different details related to "available resources", details:
output.output.DuplicateOutput(device.device, ctypes.byref(self.duplicator)) _ctypes.COMError: (-2005270494, 'A resource is not available at the time of the call, but may become available later.', (None, None, None, 0, None))

The way I'm able to reproduce this issue is when using multiple instances in different parallel scopes/threads such as SubProcVecEnv, each instance needs a dxcam on a specific region, so on the 3rd or 4th instance created the 'is_capturing' error is thrown, probably by its duplicator nature and resource handling.

My workaround was to provide specific resource time when creating a dxcam instance to avoid all instances creating the cam simultaneously aka "Delayed Start", and at the end releasing properly the instance with ".release" or "del".

@ChinaVolvocars
Copy link

ChinaVolvocars commented May 31, 2024

I have 2 graphic cards in my computer. I have the same issue with you too.
Here is how I solved this problem
image
image
I changed my graphic preference from Nvidia Geforce RTX 3060 to AMD Radeon(TM) Graphics.
Then the problem solved.
Hope it was helpful to you. Wish you have a nice day~

P.S. Graphics settings -> find python.exe -> Graphic preference -> Power saving

屏幕截图 2024-05-31 222533
屏幕截图 2024-05-31 222612

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants