We are using Chameleon Vision running on Raspberry Pi 4 B to capture video and track the vision target. The resulting video stream is available in Shuffleboard via the CameraServer and is also directly accessible in a browser without any problems.
Question: how do we get hold of this video stream and modify it with OpenCV calls?
We can find plenty of Java examples that open a local USB camera (USB stream shows just fine in Shuffleboard):
UsbCamera camera = CameraServer.getInstance().startAutomaticCapture();
camera.setResolution(640, 480);
CvSink cvSink = CameraServer.getInstance().getVideo();
CvSource outputStream = CameraServer.getInstance().putVideo("Modified", 640, 480);
Mat source = new Mat();
while(!Thread.interrupted()) {
cvSink.grabFrame(source);
Imgproc.circle(source, new Point(100,100), 10, new Scalar(255,255,0));
outputStream.putFrame(source);
}
What we need is to open an HTTP stream instead. You would think this will do the trick, but … no sign of the feed in Shuffleboard CameraServer:
HttpCamera chameleonFeed = new HttpCamera("chameleon",
"http://raspberrypi.local:1181/?action=stream,mjpg:http://10.0.0.225", HttpCameraKind.kMJPGStreamer);
MjpegServer camera = CameraServer.getInstance().startAutomaticCapture(chameleonFeed);
That URL does not look correct. It should end after the “action=stream” part; the part beginning with “,mjpg:” is another URL. You might also try using CameraServer.addAxisCamera with just the IP address (the Axis camera uses the same URL scheme).
Also, where is this code running? On the Rio? On a desktop application? It seems non-ideal to have the Rio do this extra processing work (decompress image, do OpenCV, recompress image) when you have a Pi.
Thanks for the quick reply. This is running on a desktop as a part of our targeting system during testing (it’s useful to see where the ball is in the frame). But, good point about Rio–we would not want to run it this way during the game.
You are also right about the URL. But correcting it did not do the trick. Neither did using Axis camera …
If you use AxisCamera you shouldn’t pass a URL, just the IP address or hostname (eg “raspberrypi.local”). AxisCamera internally builds the correct URL.
Oh, right, AxisCamera is port 80. Sorry, forgot about that detail. Using HttpCamera with a url that consists of just "http://raspberrypi.local:1181/?action=stream" should work.