MJPEGStream on Shuffleboard


#1

Hello, we recently figured out how to switch camera streams with the press of a button (except in C++) using 3 USB Cameras and an MJPEGStream, and we can view the camera stream in a web browser, but we don’t know how to add that camera stream to shuffleboard.

I’ve tried looking into the CameraServer and Shuffleboard code but there doesn’t seem to be any documentation explaining how to get this sort of system working. Has anyone done something like this before or know where I could find some documentation on how to do it?


#2

We don’t do it programmatically, but it’s really easy to add a camera stream from Shuffleboard itself.

Just select the IP Camera Stream (not camera server) from the widget selector (not sure of the actual name) on the left. Drag it onto the layout, and add the URL to the stream.


#3

It isn’t an IP camera stream it’s an MJPEG stream.

We got it working with SmartDashboard but want to use Shuffleboard this year, anyone know of a solution?


#4

You can use this:

shuffleboardContainer.add(SendableCameraWrapper.wrap(cameraServer.getSource());

Also, as a note, in the new update that came out half an hour ago, you can use this:

CameraServer.getInstance().addSwitchedCamera("camera name");

To easily make a switchable camera. I haven’t tested this yet, but it sure looks like it’ll work.


#5

Interesting, any idea how it all works or where I can find some documentation?


#6

Since we just added it, we’ve not updated the documentation yet. But basically follow the third example on This page except replace GetServer() with AddSwitchedCamera().


#7

Cool, I’ll look into it tonight and see if we can figure it out for tomorrow!

Also, do you know the best way to avoid sending an invalid camera stream because we’ve been running into issues with the robot code crashing if SmartDashboard is open and trying to stream the video without it being initialized?


#8

The robot code shouldn’t ever crash. Please provide the backtrace / more information so I can help isolate the issue.