I'm not sure what is happening but like when I set my device_idx = 1 ( as my gpu is 1 ) it gives the error:
Traceback (most recent call last):
File "C:\Users\phuoc\OneDrive\Desktop\All-in-One\Coding\Aimbot\test\capture.py", line 5, in
camera = dxcam.create(device_idx= 1, output_color="BGR")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\phuoc\AppData\Local\Programs\Python\Python311\Lib\site-packages\dxcam__init.py", line 112, in create
return factory.create(
^^^^^^^^^^^^^^^^^
File "C:\Users\phuoc\AppData\Local\Programs\Python\Python311\Lib\site-packages\dxcam__init__.py", line 45, in create
device = self.devices[device_idx]
IndexError: list index out of range
but when I set it to 0 ( is my cpu ) it work fine
below is my code:
import dxcam
import cv2
import time
camera = dxcam.create(device_idx= 1, output_color="BGR")
print(dxcam.device_info())
# Initialize loop_time before the loop
loop_time = time.time()
print("running")
while True:
capture = camera.grab()
if capture is None:
continue
hsv_capture = cv2.cvtColor(capture, cv2.COLOR_BGR2HSV)
print('FPS {}'.format(1 / (time.time() - loop_time)))
loop_time = time.time()
cv2.imshow("capture", hsv_capture)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
print("done")
time.sleep(3)
cv2.destroyAllWindows()
I think your computer may be laptop,not desktop computer. Beacuse I also had this problem when I wanted to use my Nvida. But, I found it's normal if I chose Interl, which is a more slow device.
I'm not sure what is happening but like when I set my device_idx = 1 ( as my gpu is 1 ) it gives the error: Traceback (most recent call last): File "C:\Users\phuoc\OneDrive\Desktop\All-in-One\Coding\Aimbot\test\capture.py", line 5, in
camera = dxcam.create(device_idx= 1, output_color="BGR")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\phuoc\AppData\Local\Programs\Python\Python311\Lib\site-packages\dxcam__init.py", line 112, in create
return factory.create(
^^^^^^^^^^^^^^^^^
File "C:\Users\phuoc\AppData\Local\Programs\Python\Python311\Lib\site-packages\dxcam__init__.py", line 45, in create
device = self.devices[device_idx]