Last year I posted about using an iPhone with an Arduino to create a remote controlled car. There are a few issues that make it less than ideal:
First, is obviously that it ties up my iPhone whilst using the car. Also, the connection between the iPhone and the Arduino was using the Redpark Serial Cable - connecting to the iPhone using the 30 pin dock connector; less than ideal as Apple is rapidly moving away from this connector.
Secondly, because at the time, the library for streaming video from the phone to the ipad didn‘t support Peer-to-Peer streaming (I think it does now, but haven’t had a chance to test this out), the video went via a web server and therefore introduced a good 2-3 second lag; not ideal when trying to control a remote vehicle.
One option for solving both of these problems would be to replace the iPhone on the car with a Raspberry Pi and a web cam. I had been intending to buy a cheap webcam for this purpose, but then realised I already have a USB camera in the form of the PS3 EyeToy camera.
I initially used Chris Barnes' tutorial Using a PS3 EyeToy with the Raspberry Pi to get it working with ‘Motion’ but found it very slow; nearly as much lag as sending the video up to the web server and down again, and with a worse framerate. Also, because it‘s designed for capturing video and stills when it sees motion, it quickly filled up the RPi’s SD card.
With that in mind, I tried Mjpeg Streamer (although, iirc, I just used apt-get to install it). Initially no luck; the built in server worked, but no images / video were sent. On a whim, I tried forcing YUYV format - bingo! It seems that the EyeToy doesn‘t support the mjpeg format, which is annoying because it means that the RPi’s CPU needs to do a lot of processing for mpeg-streamer to get the YUYV format into mjpeg. For my purposes though, I could knock the frame size down to 160x120px, thus making the CPU load around 25%, and allowing me to get around 10 fps.
I used the following arguments to start mjpeg streamer:
- . - - - - - . - -
As it is streamed over the network, this is just as easily viewed on iOS as on the Mac, although the “Javascript” option seems to work best with iOS.
Next test will be to get myself a cheapo webcam that supports mjpeg and see how that performs.
Continue →
2a>