IP Camera Object with Raspberry Pi as MJPEG Server

I have a machine on which there are some hard-to-access bits that could benefit from a camera to verify the placement of material and tools. IP cameras these days are almost all aimed at the security market, so they have long focal lengths and fisheye lenses, and real machine vision cameras from Cognex or Matrox are more expensive than we can justify for this application.

USB webcams would be ideal, but the machine is too far from any of our computers for USB or USB extenders to reach, and the USB/Ethernet extenders we have tried need a separate Cat6 homerun and have had spotty success.

Enter my Christmas present: a Raspberry Pi Model B, which is the one with an Ethernet port.

With a little open-source software installed, the Raspberry Pi will plug into a USB webcam, and provide the webcam image as a MJPEG stream over an IP network. At high frame rates (I’ve run it at 60 fps) it takes most of the Pi’s processing power, but we’re not asking it to do anything else. I’m not even running XWindows; I set up the Pi to boot to console only and there’s no monitor or keyboard installed.

The Video For Linux (V4L2) libraries support quite a lot of webcams out of the box these days. The two that we happened to buy were sold as borescopes, and arrived from Hong Kong for under $30 each.

ebay.com/itm/USB-Endoscope-B … 3f2dff1e4f

The Raspberry Pi has a camera module, but it mounts right to the computer. I need a camera that I can sneak inside a machine where even the tiny Raspberry Pi won’t fit.

Just plugging in the camera allowed me to use the “lsusb” command to see the camera’s USB ID. The camera is available to the OS as “video0”.

I installed the mpeg-streamer software project more or less as described by this blog post:

wolfpaulus.com/jounal/embedded/r … pi_webcam/

I had to switch the camera into YUVC mode to get it to work.

The actual command line that starts the streaming server is:

/usr/local/bin/mjpg_streamer -i “/usr/local/lib/input_uvc.so -y YUVC -n” -o “/usr/local/lib/output_http.so -w /usr/local/www”

Once I had it tested and working, I put that command line as a shell script into the init.d directory, so that it runs when I power up the Raspberry Pi.

I have very little Linux experience, but this took me about a day of tinkering. Total cash outlay was under $100.

You put the streaming URL into the IP Camera object in Ignition, and ta-daa… live video.

Kakkerlak

I like that!

good job,

wouldn’t it be useful if you could take a snapshot on an alarm event?

chris