Go to Post You can design and theorize all you want, but the sooner you get to testing your ideas and seeing how things actually work, the better off you will be. - Andy Baker [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 03-12-2015, 10:37 PM
taichichuan's Avatar
taichichuan taichichuan is offline
Software Mentor
AKA: Mike Anderson
FRC #0116 (Epsilon Delta)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2010
Location: Herndon, VA
Posts: 334
taichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud of
Send a message via AIM to taichichuan
mjpg-streamer running on roboRIO

Here at the Orlando Regionals while waiting in the pits for our robot to start working, I ported mjpg-streamer to the roboRIO. It was pretty funky since the source doesn't lend itself to cross-compilation. So, the answer? Compile it on a Beaglebone Black running Angstrom and copy the files over.

Result? A working camera feed that takes only 1% of the CPU. And, with a little Javascript magic, you can have multiple cameras running at the same time. There was only one little problem in that the libjpeg code isn't available on the roboRIO. So, simply copy the libraries from the BBB and place them in /usr/lib. Open source is a wonderful thing.

Then, untar the mjpg-streamer code and run it ala the instructions.

Enjoy,

Mike
Attached Files
File Type: tgz mjpg-streamer-built.tgz (1.47 MB, 200 views)
File Type: tgz jpeg.tgz (197.4 KB, 125 views)
  #2   Spotlight this post!  
Unread 03-12-2015, 11:38 PM
AlexanderTheOK AlexanderTheOK is offline
Guy
no team
 
Join Date: Jan 2014
Rookie Year: 2012
Location: Los Angeles
Posts: 170
AlexanderTheOK is a name known to allAlexanderTheOK is a name known to allAlexanderTheOK is a name known to allAlexanderTheOK is a name known to allAlexanderTheOK is a name known to allAlexanderTheOK is a name known to all
Re: mjpg-streamer running on roboRIO

Multiple cameras? Last I tried to use mjpg-streamer for anything productive I found that only a select few models didn't hog the entire USB bandwidth on their own (causing a second camera to fail because there "isn't enough bandwidth" . Most cameras that are "uvc compatible" just aren't because of the underdevelopment by the companies that make them. What cameras are you using?
  #3   Spotlight this post!  
Unread 03-13-2015, 05:36 AM
taichichuan's Avatar
taichichuan taichichuan is offline
Software Mentor
AKA: Mike Anderson
FRC #0116 (Epsilon Delta)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2010
Location: Herndon, VA
Posts: 334
taichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud of
Send a message via AIM to taichichuan
Re: mjpg-streamer running on roboRIO

Quote:
Originally Posted by AlexanderTheOK View Post
Multiple cameras? Last I tried to use mjpg-streamer for anything productive I found that only a select few models didn't hog the entire USB bandwidth on their own (causing a second camera to fail because there "isn't enough bandwidth" . Most cameras that are "uvc compatible" just aren't because of the underdevelopment by the companies that make them. What cameras are you using?
The Logitech C920 does hardware H.264 encoding. Mjpeg-streamer understands that and doesn't repeat the process. This significant;y lowers CPU utilization.

HTH,

Mike
  #4   Spotlight this post!  
Unread 03-13-2015, 10:21 AM
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,219
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Re: mjpg-streamer running on roboRIO

This sounds great. I've been contemplating finding something like this and compiling for the roborio (though I was considering ffmpeg et al), now I don't have to!

I've been nervous about running the streaming stuff in the same process as our robot code (particularly since we're in python and there are GIL contention issues), so having a standalone executable sounds great.
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python), pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript), and lots more...

2017 Season: Teams #1973, #4796, #6367
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
  #5   Spotlight this post!  
Unread 03-14-2015, 05:01 PM
cbf cbf is offline
Registered User
FRC #2877
 
Join Date: Feb 2012
Location: Newton, MA
Posts: 77
cbf is just really nicecbf is just really nicecbf is just really nicecbf is just really nicecbf is just really nice
Re: mjpg-streamer running on roboRIO

Have you guys run this during a competition yet? I would be concerned about the bandwidth taken by two simultaneous video streams. In the past, we've accidentally saturated the feed between our laptop and the robot with a single 640 x 480 stream.
  #6   Spotlight this post!  
Unread 03-14-2015, 08:19 PM
EmileH's Avatar
EmileH EmileH is offline
Remove The Dividers
AKA: Emile Hamwey
FRC #1058 (The PVC Pirates) & The Blue Alliance (Contributor)
Team Role: Student
 
Join Date: Dec 2014
Rookie Year: 2011
Location: New Hampshire
Posts: 671
EmileH has a reputation beyond reputeEmileH has a reputation beyond reputeEmileH has a reputation beyond reputeEmileH has a reputation beyond reputeEmileH has a reputation beyond reputeEmileH has a reputation beyond reputeEmileH has a reputation beyond reputeEmileH has a reputation beyond reputeEmileH has a reputation beyond reputeEmileH has a reputation beyond reputeEmileH has a reputation beyond repute
Re: mjpg-streamer running on roboRIO

How do you display it on the PC, thru smartdashboard or VLC? And does the FMS allow for communications over the ports used?
__________________
FRC 1058 - 2016-present
FRC 3467 - 2013-2015


Thanks to all our alliance partners this season!
125 | 238 | 5687 | 4908 | 58 | 3930 | 6328 | 177 | 67 | 2137 | 1640
  #7   Spotlight this post!  
Unread 03-14-2015, 09:23 PM
taichichuan's Avatar
taichichuan taichichuan is offline
Software Mentor
AKA: Mike Anderson
FRC #0116 (Epsilon Delta)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2010
Location: Herndon, VA
Posts: 334
taichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud of
Send a message via AIM to taichichuan
Re: mjpg-streamer running on roboRIO

Quote:
Originally Posted by cbf View Post
Have you guys run this during a competition yet? I would be concerned about the bandwidth taken by two simultaneous video streams. In the past, we've accidentally saturated the feed between our laptop and the robot with a single 640 x 480 stream.
Actually, you drop a Javascript page onto the ./www directory that has a button that allows you to switch between the streams. So, you're not getting both streams simultaneously unless you want them.

HTH,

Mike
  #8   Spotlight this post!  
Unread 03-14-2015, 09:27 PM
taichichuan's Avatar
taichichuan taichichuan is offline
Software Mentor
AKA: Mike Anderson
FRC #0116 (Epsilon Delta)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2010
Location: Herndon, VA
Posts: 334
taichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud of
Send a message via AIM to taichichuan
Re: mjpg-streamer running on roboRIO

Quote:
Originally Posted by emileh3467 View Post
How do you display it on the PC, thru smartdashboard or VLC? And does the FMS allow for communications over the ports used?
Actually, a simple web browser will do the display just fine. You can compile mjpg-streamer for vlc, udp, rtsp or one of several other options. However, we've just been using the output_http.so plugin and Chrome, Firefox or IE to display it on the DS. You can even make it start automatically just like the dashboard normally would if you want to.

HTH,

Mike
  #9   Spotlight this post!  
Unread 03-14-2015, 11:41 PM
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,219
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Re: mjpg-streamer running on roboRIO

We're actually doing our DS in HTML/JS, with a python interface to forward networktables to/from the HTML page, so the mjpg-streamer is exactly what we're looking for. We played with it a little bit today and it's pretty sweet, but haven't wired it into our interface yet.

I'm curious, what javascript magic do you need to do to switch streams? Is there a delay? We setup two servers, and were able to stream two cameras that way. Didn't try the JS magic yet.
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python), pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript), and lots more...

2017 Season: Teams #1973, #4796, #6367
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
  #10   Spotlight this post!  
Unread 03-14-2015, 11:43 PM
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,219
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Re: mjpg-streamer running on roboRIO

Quote:
Originally Posted by AlexanderTheOK View Post
Multiple cameras? Last I tried to use mjpg-streamer for anything productive I found that only a select few models didn't hog the entire USB bandwidth on their own (causing a second camera to fail because there "isn't enough bandwidth" . Most cameras that are "uvc compatible" just aren't because of the underdevelopment by the companies that make them. What cameras are you using?
We tested two Lifecam 3000 cameras this afternoon running two servers, and at 160x120 were at about 5% CPU usage. 320x160 was roughly the same. Haven't tried measuring the network bandwidth yet.
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python), pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript), and lots more...

2017 Season: Teams #1973, #4796, #6367
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
  #11   Spotlight this post!  
Unread 03-22-2015, 12:54 PM
cbf cbf is offline
Registered User
FRC #2877
 
Join Date: Feb 2012
Location: Newton, MA
Posts: 77
cbf is just really nicecbf is just really nicecbf is just really nicecbf is just really nicecbf is just really nice
Re: mjpg-streamer running on roboRIO

I'm trying to set this to test. Where did you guys install the ./www pages on the roboRIO?

Easiest thing that I can see is just to put everything under /var/local/natinst/www, since that would avoid having to edit the web config file (which seems to be at /etc/natinst/NISystemWebServer.conf).

The other alternative would be to add a second document root, but while that NISystemWebServer.conf bears resemblances to Apache .conf files (perhaps version 1.X?), it pretty clearly has proprietary NI directives in it, and I'm hesitate to make changes without real documentation (which I suppose I could hunt for on NI's site).

Also, did anyone notice the mjpeg-stream stuff at /usr/camera_server/mjpg-streamer-r63? It appears that's where the NI-IMAQdx routines get their USB webcam support from. It seems to be an older(?) version of the same MJPEG streaming libraries you guys are playing with.
  #12   Spotlight this post!  
Unread 03-22-2015, 01:38 PM
cbf cbf is offline
Registered User
FRC #2877
 
Join Date: Feb 2012
Location: Newton, MA
Posts: 77
cbf is just really nicecbf is just really nicecbf is just really nicecbf is just really nicecbf is just really nice
Re: mjpg-streamer running on roboRIO

When I try to run this, I'm getting an error opening the /dev/video0 device. I have a Logitech P930e plugged in, which should certainly support the requested mode.

Code:
admin@roboRIO-2877:/var/local/natinst/www/mjpg# source start.sh
MJPG Streamer Version: svn rev:
 i: Using V4L2 device.: /dev/video0
 i: Desired Resolution: 640 x 480
 i: Frames Per Second.: 5
 i: Format............: MJPEG
Unable to set format: 1196444237 res: 640x480
 Init v4L2 failed !! exit fatal
 i: init_VideoIn failed

admin@roboRIO-2877:/var/local/natinst/www/mjpg# ls -l /dev/video0
crw-rw-rw-    1 admin    ni         81,   0 Dec 31  1969 /dev/video0
  #13   Spotlight this post!  
Unread 03-22-2015, 07:06 PM
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,219
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Re: mjpg-streamer running on roboRIO

What you want to execute is something like this:

Code:
LD_LIBRARY_PATH=`pwd` ./mjpg_streamer -i  "./input_uvc.so --device /dev/video0 -f 10 -r 160x120" -o "./output_http.so --port 5800 -w www"
Of course, you're going to want to write scripts and such to make it easy to run, and more importantly start on robot boot. I did all of this already, so I put install instructions + the scripts I created into a gist, you can access it at https://gist.github.com/virtuald/c8835244759e53314211

Feedback/comments welcome!
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python), pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript), and lots more...

2017 Season: Teams #1973, #4796, #6367
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
  #14   Spotlight this post!  
Unread 03-22-2015, 08:36 PM
cbf cbf is offline
Registered User
FRC #2877
 
Join Date: Feb 2012
Location: Newton, MA
Posts: 77
cbf is just really nicecbf is just really nicecbf is just really nicecbf is just really nicecbf is just really nice
Re: mjpg-streamer running on roboRIO

Actually, it turns out the default shell script was working for me. I had forgotten to shut down FRCProgram, which also opened the camera!

But your scripts for starting, etc. will be helpful if we decide to go this route.
Right now at 640 x 480, a stream from my Logitech P930e is taking 2.8Mbps, which is higher than the stream from our robot program, which uses the NI MAXQdx libraries to send a 640 x 360 stream at 24fps and onlyh takes 2.0 mbps. I'm still leery of how this will perform through the FMS.

But you said something about doing an entire Dashboard in JavaScript. That really intrigues me. And a Python implementation of NetworkTables. Is that running server side or client side?
  #15   Spotlight this post!  
Unread 03-22-2015, 08:39 PM
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,219
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Re: mjpg-streamer running on roboRIO

Quote:
Originally Posted by cbf View Post
But you said something about doing an entire Dashboard in JavaScript. That really intrigues me. And a Python implementation of NetworkTables. Is that running server side or client side?
Check out the latest RobotPy project, pynetworktables2js. It forwards networktables traffic to/from an HTML page via a websocket. It hasn't really had a proper release announcement, but we'll be using it in our dashboard at our comp next week.

We run it on the driver station.
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python), pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript), and lots more...

2017 Season: Teams #1973, #4796, #6367
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 09:40 AM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi