|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Clarity on Smart Dashboard Camera Mechanism
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. |
|
#2
|
|||
|
|||
|
Re: Clarity on Smart Dashboard Camera Mechanism
Quote:
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. Last edited by Peter Johnson : 31-01-2017 at 16:22. |
|
#3
|
|||
|
|||
|
Re: Clarity on Smart Dashboard Camera Mechanism
Thanks, so what will basically happen is I will start an MPEG server on my raspberry pi that is updating frames and sending to the the url you specified, the roborio's background CameraServer class will grab these frames according to the url (http://10.x.y.z:9090/stream.mjpg), and will then send the images to the smartdashboard on the computer?
Also, what might be a faster way of uploading these frames to byte format, because even on my desktop, I am noticing significant lag. |
|
#4
|
||||
|
||||
|
Re: Clarity on Smart Dashboard Camera Mechanism
Quote:
|
|
#5
|
|||
|
|||
|
Re: Clarity on Smart Dashboard Camera Mechanism
Quote:
OpenCV does not provide a way to avoid the decompress+recompress. If you aren't actually editing the images being sent to the dashboard, you can use the cscore library that we use on the roboRio to both send the original camera JPEG via HTTP in the lowest overhead way possible and make it available for OpenCV processing. There's a Java tutorial for this here: http://wpilib.screenstepslive.com/s/...essing-in-java. The RobotPy folks are working on a cscore wrapper that should make this possible to do in Python, but there's not an existing tutorial that I know of. |
|
#6
|
|||
|
|||
|
Re: Clarity on Smart Dashboard Camera Mechanism
I think I understand now. So I will replace line 34 of my server code with:
self.wfile.write('<img src="http://10.x.y.z:9090/stream.mjpg" height="240px" width="320px"/>') and thread the server_serve_forever() statement, so that the pi can simultaneously process and set the images in a global variable, perhaps a queue. So just for clarification, there isn't much I will have to do on my end other than set up a mjpeg stream with an appropriate send port and ip address. The smart dashboard will do the rest by finding the url and grabbing the images. |
|
#7
|
|||
|
|||
|
Re: Clarity on Smart Dashboard Camera Mechanism
Quote:
|
|
#8
|
|||
|
|||
|
Re: Clarity on Smart Dashboard Camera Mechanism
So I have been looking at the smartdashboard camera viewer properties and it asks for the "camera's ip address or mdns name". Here I can feed the URL: "http://10.x.y.z:9090/stream.mjpg" and should it successfully make a connection to the Dash? Should the x, y, and z have integer values? Is it possible to set a mdns name for the http web server?
Also the the ports that are allowed for team use ranges from "5800-5810" |
|
#9
|
||||||
|
||||||
|
Re: Clarity on Smart Dashboard Camera Mechanism
Quote:
|
|
#10
|
|||
|
|||
|
Re: Clarity on Smart Dashboard Camera Mechanism
Quote:
The ports allowed for team use are listed in R56. Ports 5800-5810 are one option; another is port 80. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|