- Edited
Hi, I have managed to get Oak camera recognized as a webcam but I cannot use it inside another script when I try to access it by cv2. Initially what worked for me was following the Using UVC for webcam. Please help thank you!
Hi, I have managed to get Oak camera recognized as a webcam but I cannot use it inside another script when I try to access it by cv2. Initially what worked for me was following the Using UVC for webcam. Please help thank you!
jakaskerl Hi could you please tell me how I can show that? I was separately running the webcam as mentioned here https://docs.luxonis.com/en/latest/pages/oak_webcam/ using the UVC option. Thank you for your help!
Hi SadiaC
Did you try any of the workarounds? https://docs.luxonis.com/en/latest/pages/oak_webcam/#webcam-workarounds
Also make sure your depthai and depthai_sdk are up to date.
Another workaround: https://discuss.luxonis.com/d/2282-jetson-nano-and-virtual-camera-need-some-help
Thanks,
Jaka
Hi SadiaC
Could you paste your code?
I can confirm that it works for me with this code:
import cv2
# Initialize the VideoCapture object to use the default camera (camera index 1 since 0 is my webcam)
cap = cv2.VideoCapture(1)
# Check if the camera opened successfully
if not cap.isOpened():
print("Error: Could not open camera.")
exit()
# Loop to continuously get frames from the camera
while True:
# Capture frame-by-frame
ret, frame = cap.read()
# Check if the frame was captured successfully
if not ret:
print("Error: Could not read frame.")
break
# Display the resulting frame
cv2.imshow('Video Feed', frame)
# Break the loop if 'q' is pressed
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# Release the VideoCapture object and close display window
cap.release()
cv2.destroyAllWindows()
Thanks,
Jaka