Onboard Serial USB connection with Arduino Mega.

Hi.
Is it possible to establish a connection between the Arduino Mega 2560 and a USB-Webcam? This is supposed to be on-board, meaning no external device to run the webcam, like a computer.

The project is a robot with an arm, with the task to locate a small container, painted with a certain contrast-color to the background color. We’d like the arduino to calculate the distance in 3D-space, so that the arm would be able to reach the container, regardless of the position of both the robot and the container (in a certain amount of space of course - like 30cm x 30cm.)
How would you approach this task?

Thanks in advance - Jeppe.

Not with an arduino. There is not enough horsepower for video processing, much less 3D vision.

The USB part can be handled with the USB host shield like this: https://www.sparkfun.com/products/9947

KeithRB: Not with an arduino. There is not enough horsepower for video processing, much less 3D vision.

The USB part can be handled with the USB host shield like this: https://www.sparkfun.com/products/9947

Thank you for your reply. So this shield contains a processor for that purpose? Do you know if they are sold in Europe as well?

jepperaskdk: So this shield contains a processor for that purpose? Do you know if they are sold in Europe as well?

Just to be clear, the shield can act as a USB host. It doesn't have any extra processing capacity to supplement the abilities of the Mega.

The shields are widely available.

...R

Ok, but the shield would create the connection between the webcam and the arduino?

Lets assume i wanna render a 240x320 px frame. Every pixel can have a given color, in a 8bit-RGB view (meaning 24 bit total). Divide this by 8 bit, (to convert to bytes) that would lead to 230.400 bytes (230,4 kB) and this would be the needed SRAM to load an image? The Mega has 8 kB SRAM. Is this correct?

But I don't really need it to render every single pixel. If i know the container in the image has a certain color-range, i could easily discard unwanted pixels. Also, I could choose a container that would fit the whole height (or most of it) and like in the picture below, just render the pixels in the x-axis. Isn't that also the principle of bar-codes?

If i do the same calculation, but isolate the max amount of the pixels in the y-axis, with an estimated SRAM-demand of 6 kB (assuming that the program would need SRAM as well) - then i could shorten it down to 6,25px.

CAN this be done? All this is probably easier said than done, but what would be needed to do this? Lets assume i wanna render an image of 320px x ~6.25 px, at a speed of 1fps or lower. I have searched around, but only found people using a computer for the image-rendering.. :-/

Given you constraints, you are not totally out of Arduino land, you also have a good handle on things, so go for it.

Actually, communicating through USB is pretty processor intensive, it might be best to have two arduinos, one for USB-Camera interactions and one for image processing.

KeithRB:
Actually, communicating through USB is pretty processor intensive, it might be best to have two arduinos, one for USB-Camera interactions and one for image processing.

‘processor intensive’ - meaning the clockspeed needed to run both the program, USB-connection with the webcam and image rendering is too little? Or that the memory needed would simply exceed the accessible 8kB?

What if i added a memory-shield of 512 kB like this one: http://174.136.57.214/html/quadram.html

This sounds like one of those projects that you might be able to implement on an Arduino after hours of hard work and many many optimizations and simplifications.

And it could be done relatively easily on, say, a Raspberry PI or, perhaps, a Yun.

…R

Robin2:
This sounds like one of those projects that you might be able to implement on an Arduino after hours of hard work and many many optimizations and simplifications.

And it could be done relatively easily on, say, a Raspberry PI or, perhaps, a Yun.

…R

Yes, this does indeed look easier:
http://raspberrypi.rsdelivers.com/product/rs/picamera-2/pi-a-type-a-camera-4gb-sd-os/7902708.aspx

Since i already have the webcam, wouldn’t this be the easiest solution for me? It’s about 40$.
http://dk.farnell.com/raspberry-pi/raspberry-pi-8gb-usd/sbc-raspberry-pi-8gb-sd-bundle/dp/2334982#