|
Re: Clarity on Smart Dashboard Camera Mechanism
Quote:
Originally Posted by sgk525
I have developed a straight forward vision code on the Raspberry Pi that grabs a frame, applies masking/Canny Edge Detection, and contour fitting that will send a udp string of distance measurements to the roborio. The main issue I am having is sending an image from the pi to the SmartDashboard. I have been reading about mjpeg streaming, and touched on the mjpeg streamer by robotpy, although am a little confused on how the smartdashboard will grab the frames. I tweaked a stream i found on-line for python3, found here:
https://github.com/SachinKonan/Windo.../httpserver.py
I was wondering how it could be changed to interface with the Smart Dashboard.
|
That code as-is should work fine with SmartDashboard, as it appears to be serving up just a standard MJPEG over HTTP stream. For competition you'll want to change the port number from 9090 to one of the ones allowed through the field radio. You'll need to use the mjpg streamer widget rather than the CameraServer widget, and put in the URL manually (e.g. http://10.x.y.z:9090/stream.mjpg), as the CameraServer widget uses information from NetworkTables to find the camera stream URL, and that won't be present in this instance (unless you put it there).
Note this code is inefficient in that it's decompressing and recompressing the image from the camera. The Raspberry Pi likely has enough horsepower to do this, particularly at lower resolutions, but I wanted to note this fact because you'll see more CPU use of this approach versus others for this reason.
__________________
Author of cscore - WPILib CameraServer for 2017+
Author of ntcore - WPILib NetworkTables for 2016+
Creator of RobotPy - Python for FRC
2010 FRC World Champions ( 294, 67, 177)
2007 FTC World Champions (30, 74, 23)
2001 FRC National Champions (71, 294, 125, 365, 279)
Last edited by Peter Johnson : 31-01-2017 at 16:22.
|