I am using a basic USB webcam with OpenCV in python and it works as expected using a simple test script.
import cv2
cap = cv2.VideoCapture(0)
while True:
ret, frame = cap.read() #capture a frame
cv2.imshow('frame', frame) #display the frame
if cv2.waitKey(1) & 0xff == ord('q'): #keep streaming video until the 'q' key is pressed
break
cap.release()
cv2.destroyAllWindows()
I have also tested functionality using YawCam and the camera works as expected. However, I am now trying to use a USB over IP server. In this configuration, I can still stream video using YawCam but OpenCV returns blank frames. Does anyone have any suggestions as to what might cause this, possible solutions, or tests I should try?
Additional details
I am using the SIIG DS0611 USB IP Server. This allows me to connect the camera to my LAN at home instead of connecting the camera directly to the USB port on my computer. This is different from an IP camera in that my computer "thinks" the camera is connected directly to its USB port, so I don't think RTSP will work. I believe this because the "HD USB Camera" device shows up in my Device Manager under "Cameras" just like it does when I connect the camera directly to my computer's USB port. However, OpenCV only returns black or mostly black frames with some gibberish pixels when I run my code. OpenCV is able to connect and does recognize that the camera is opened. I have also tried adding various delays into the code to allow more time to initialize the camera and to read frames. Nothing has helped. YawCam doesn't have any issues so I know the camera/IP server are working well, but I need the camera to work in python.
cap = cv2.VideoCapture(0)
. This works when you have a camera dirrectly plugged in your computer, but if the camera is distant, you'll need to change that0
argument for your ip address or somehting! Look at this link -> answers.opencv.org/question/133/how-do-i-access-an-ip-camera – LoukMouk