Author Options:

how to connect arduino to a webcam? Answered

i made a robot that moves using arduino controlled using Xbee(zigbee) connected to my PC and i put on the car a robotic arm to grape any object i like , but after that i wanted to make it much more harder to make the robot find that object using a webcam but i dont know which program to use and how to make an interface between arduino and the used program



How is your project going now? I have drawn up a similar plan with arduino and its ethernet shield. I have referred to related articles on website and gotten a result that it is hard for arduino to process or stream visual data on (near-)real time.

I have thought two alternatives: (i) using Rasberry Pi instead of arduino, (ii) using IP-camera on the market in addition to arduino.  Limited in number of output pins on these boards, I have chosen the latter. 

About pin mapping, my project aims at 3 goals below. So 6 output pins on arduino are engaged in (1), 2 are in (2) and 4 are in (3). No pin remains available.
(1) IP-camera patrols from room to room getting over level differences between rooms,
(2) IP-camera looks down at desktop or tabletopu,
(3) IP-camera is operated from a remote place where is a different LAN.

The movie below summarizes my project.

Do you mean some sort of visual detection program for the robot so it can choose what to pick-up itself, without your input? If that is the case and you succeed then you better guard your results closely until you get a patent because that is a major hurdle currently standing in the way of truly autonomous robots. (See that DARPA sponsored race where autonomous cars try to navigate through the desert. Most of them end up lost or crashing because there "vision" systems are still buggy.)

If you simply want to transmit the video to your computer for you to see I would suggest bypassing the Arduino and buying a wireless webcam or wireless adapter for a webcam.

thnx for u reply and ur time , i have already bought what u mentioned in your comment , and u exactly got my question , but what program to do this ? and how to connect with arduino

Do you mean what program to view the webcam feed? The transmitter for the webcam should probably come with some software that streams the video feed.
I was saying that if you transmit the video feed directly from the camera to the PC you don't need to interface with Arduino.

Do you want the Arduino analyze the video? If that's what you want then you are going to need something much, much, much more powerful, and big, and expensive, and complicated than an Arduino.

no not to view the image of the webcam ,,, i need the program to take the image of the webcam and analyse it and make a grid in it that divide the image into 4 parts up , down , left and right ,, and determine the object in which part and by this determining the car will move automatically ex: if the object in the right part therefore the car moves right and so on ,, so i need a program to do this

Ok, so that's the stuff I was talking about that some of the most brilliant robotics scientists are trying to solve right now.

First things first. As has been pointed out several times an Arduino can not do this. It can react to the results of this but it can not do it itself.
Once you have a system in place capable of analyzing each frame of a streaming video, deciding what to do, and sending a command to the robot you need to write a program that analyzes all the pixels of each frame, or you can skip a few if a delay is acceptable, of the video and try to match a pattern of pixels in the video that represent the object to a pattern of pixels in a picture of the object that it has stored. Once it finds the object then it can determine its position and command the robot to move and pick it up. Once you're done with that you should patent it and sell it so we can have self driving cars and better navigating robots.
The point of that last paragraph is that it can't be done with limited resources and money.
There are ways to select the right object out of a group using a robot but the objects it's picking from must be in the same areas every time and the object should be exactly the same every time. You are not going to be able to have a robot drive around a room full of different objects on it's own and have it pick out just certain objects by sight alone.

i appreciate your help very much ,, you mean that @ my level i cant do it ? ok what about learning another controller different than Arduino is it still hard ? another question is there anyway to get to my goal .. i saw other videos having a robotic arm having a camera moves when moving a colored object ? if is there anyway ?? thanks :D

The first video is using a Rasberry Pi which is a very small linux based computer. The software its using tracks colors only. It doesn't care what shape or size the colored object is as long as most of it is the color it's programmed to look for.

The second video is from a college research lab and that arm has a bank of computers doing all the video processing for it.

If you want to start very simple then get a Lego Mindstorms kit with the color sensor. Then you can build a robot that can track a colored object and build from there. The systems that do the best tracking of objects not only do video tracking but also incorporate other sensors like range finders. You'll notice in the first video the sonar range finder attached to the top of the wireless web cam. Check out the profile page from the first video. They have many videos covering this kind of thing and you should be able to find a link to there site where you can get more info about the software they used with the Rasberry Pi to build the robot.

It was kind of you to reply ,,, okay i will try to read more about rasberry pi and try to biuld another robot ,,, thanks ?

I don't think they (arduino) can handle that kind of data-rate, and you'd need an interface of sorts.


like what ? i dont know a specific one .. i need variety of programs to choose a specific one and learn it and do my program :D