Issues with viewing a USB Camera

We lost our Lifecam, and are waiting for a new one to come in. In the mean time, I am trying to get a cheap USB webcam from eBay to stream through the roboRIO. But when I call startAutomaticCapture() in robotInit(), and then select “USB Camera 0” in the default dashboard, the roboRIO logs the following message repeatedly:

WARNING: USB Camera 0: invalid JPEG image received from camera (UsbCameraImpl.cpp:419)

Is there anything I can do to troubleshoot this and at least be able to see a stream?

Does it work in a normal computer? Can you use it in another Java specific application (like GRIP)?

@NewtonCrosby, thanks for replying,

I tried it on my Arch Linux laptop and it worked with cheese. I haven’t tested it with a Java specific application, though.

Just after looking at the docs a bit, maybe this method could be useful: VideoSource#setPixelFormat().

After thinking about this for a little bit though, I’m beginning to think that this isn’t exactly what you need. I suspect that this method is more specific to CameraServer, and not a configuration option specific to the camera. The docs aren’t too helpful on this subject, though.
There’s still a chance that this or some other method like it may help.

To be more clear what could be going on: Some webcams by default don’t do MJPG streams at all, and some require authentication to access the MJPG stream.

Your camera could be one of those cases where it would either need to be configured, or you’ll need to find out what the actual stream could be.

For example, if your webcam is streaming YUYV but your CameraServer is looking for MJPG you will not get a proper stream image on the Roborio…but it would be a camera stream that more robust image capture software would see just fine as if there were no issues.

1 Like

I have the camera with me right now, I might try getting information on it from my computer after I finish my math homework.

It took some digging through incomplete help pages, but I think I got the information I need. It looks like the camera I have is only capable of streaming YUYV. Is there anything I can do then?
`➜ ~ v4l2-ctl -d 6 --list-formats-ext
Type: Video Capture

[0]: 'YUYV' (YUYV 4:2:2)
	Size: Discrete 640x480
		Interval: Discrete 0.033s (30.000 fps)
	Size: Discrete 352x288
		Interval: Discrete 0.033s (30.000 fps)
	Size: Discrete 320x240
		Interval: Discrete 0.033s (30.000 fps)
	Size: Discrete 176x144
		Interval: Discrete 0.033s (30.000 fps)
	Size: Discrete 160x120
		Interval: Discrete 0.033s (30.000 fps)`

Yes, use setVideoMode() with format kYUYV and one of the supported camera resolutions/fps. The legal modes will also be listed on the CameraServer webpage for the camera (port 1181 for the first camera).

1 Like

Thank you! I’ll try it with the roboRIO tomorrow and let you know if it works.

Huzzah! It works! Thank you so much!