Rookie team IP camera woes + Python RPi questions

So our team is using a D-Link IP camera (DCS-933L) because of the nice integrated IR LEDs which give us really nice contours in our GRIP pipeline. We have it wired up to a network switch which runs off of the second ethernet port on the OM5P radio (other port on the radio goes directly to RIO). The switch is also wired up to a Rasberry Pi 3. We are using the code in the response to this question to process the MJPG stream on the Pi in order to put frames through the GRIP pipeline. At this point we have successfully ran the camera and processed the frames in the GRIP pipeline using Python, but have not yet uploaded the contour data to Network Tables for the RIO.

Now that I have explained the setup… on to the questions!

  1. What would be the easiest way to get the video feed to show up in the driver station? I see an option in the Java Smart Dashboard for an MJPG streamer but have no idea how to give it an IP to access.
  2. Is the way we are capturing the MJPG stream considered an “acceptable technique?” Is there an easier/more streamlined way to do it?
  3. How would we go about accessing the X/Y data for the contours? Does it have something to do with the byte array output from convex_hulls_output? (The last item in our GRIP pipeline)
  4. We haven’t set up Network Tables yet, but would the switch change anything with how we would go about using them?

Thanks in advance. Our programming team consists of 3-4 programmers used to web development and this is our first year, so the help is… well needed.

For the first question - on the top of the smartdashboard window (I believe it is under view, hit editable), now when you add an mjpeg stream you can right click on it and edit, then there is a box to input the url.

Where are you running GRIP on? The pi or driver’s station?

http://wpilib.screenstepslive.com/s/4485/m/24194/l/687863-off-board-vision-processing-in-java

This provides an option for using an http camera. I am also a beginner with all this though, so I have no idea how one might integrate it with GRIP. However, there is an option to have GRIP generate code which you can use in those screensteps.

1 - On Axis IP cameras, I will go to their config website (just enter the ip address of the camera into a web browser). Then, I can right-click and hit “Copy image address” - this will copy the mjpg stream address into my clipboard, and you can paste it into smart dashboard, or a web browser to test. I am not sure if an equivilant method exists for the D-Link, though.

2 - I’ve seen that method used often (in fact, einstein-champs 2481 did exactly that last year: https://github.com/Frc2481/paul-bunyan/blob/master/Camera/main.py#L34).

4 - I don’t think so.

ooh, thanks, this is super helpful. I’ll try this out

We are running GRIP on the driver station, and exporting the code to run on the Pi.

I saw this but am not sure about compatibility. It says you can add in your own vision code but mentions that it is in Java. Would we have to reinstall a different version of OpenCV?

Yeah, we have the MJPG stream URL, I just wasn’t sure where to put it in the Smart Dashboard but ryan.mitchell described where to put it.

Wow, that example is helpful. Thanks for linking

Yeah I would go with that instead of trying to translate the project I linked into Python. I’m having troubles with network tables also (not entirely sure what should be client mode or not/what ips I should set or not). But I believe that the code you put on the robot needs to set network tables as client mode and set the ip to the ip your radio uses (10.TE.AM.2) then on the pi you just get table I think?

Yeah… I’m not sure. I’ll try it when I get out of class :\

pynetworktables documentation may be useful: http://robotpy.readthedocs.io/en/stable/guide/nt.html

The python code you linked to for reading the HTTP stream will work, but is highly inefficient (though, chances are the inefficiency doesn’t matter so much).

Obviously if you have something that works, then go with that, but in the future I’d highly recommend using cscore. It has builtin support for cameras and all that streaming stuff, and can stream your modified images to smartdashboard.

Python example of that: https://github.com/robotpy/robotpy-cscore/blob/master/examples/httpcvstream.py

This is super helpful… thank you so much for the links. The example you linked even sets up an MJPG streaming server I can use for the driver station…

Guess where we started for doing vision processing this year :smiley:

Wow that python documentation is super helpful! Is it just me or is the python documentation better than the java documentation?

So I’m trying to use cscore now… followed instructions here
and Python still isn’t seeing the module on the Pi… any ideas?

Oh wait you are using the pi camera itself? In that case there are some steps you have to go through to enable it.

Yes, it is better.

So I’m trying to use cscore now… followed instructions here
and Python still isn’t seeing the module on the Pi… any ideas?

Hard to say without more details. Unfortunately, the cscore documentation isn’t quite as good as the rest… yet.

Have you enabled the raspberry pi camera? Are you using the camera that came with the pi?..i cant tell if you are referring to a usb cam on the pi or the picam itself

Got it working… just had to rebuild OpenCV for Python 3+. Sort of annoying cscore is incompatible with 2.x builds, but w/e. Sorry for the lack of context

We’re using an IP camera, but I just couldn’t get the cscore module to install correctly. Our OpenCV install was for Python 2.7.9 but cscore is only compatible with 3+. It’s fixed now

Maintaining Python 2.x/3.x compatibility is fairly annoying, particularly when it comes to maintaining C extensions. I’ll add something to setup.py to cause it to fail immediately on Python 2, instead of letting you think it works.

Glad to hear you got it installed! Suggestions on improving the install instructions are welcomed. :slight_smile:

Actually that’s a lie… still not seeing the module. I was too certain that Python 3 was the issue I was having. I have no idea why Python3 isn’t seeing cscore :confused: :confused:

ahahahaha never mind… I lied again. sudo fixes all problems

I’m starting to lose my sanity… now Python3 isn’t seeing cv2. I want Java back…