Robot control using top camera image analysis?

Hi all, :slight_smile:
I'm New to Arduino and Arduino community.
Yesterday they delivered my very first Arduino (Leonardo x 2).
I'm into a project where a top camera image is to be analyzed and my Leonardo based robot is to be navigated as per the analyzed image,
using MATLAB, C++ and OpenCV,
does anyone have an idea how it can be done?
i have a RN-42 bluetooth module from sparkfun to interface Arduino with MATLAB running on PC,
thank you :slight_smile:

Hi, i'm working on a similar project to this. Is your problem analyzing the image? For my robot, i'm using visual C# and EmguCV to locate red pixels and track a red ball. I used a cheap little webcam from amazon to get the video. I sent the X and Y values to the arduino via serial which i then used to control the motors. If your wondering, EmguCV is the same as OpenCV but can be used in a form application where OpenCV cant. There are very good C# and emguCV tutorial on a youtube channel called 18F4550videos. I originally thought about using Matlab, but i was more content with C#.

Good luck

Mike

thank you! but I'm restricted to use only MATLAB/C++/OpenCV.

i can't really help myself to get to a point,
how to move the robot forward(just sayin.) ?
my approach is as below.,.

  1. keep a red/green colored arrow on the top of the robot (prob. a sticker)
  2. Use MATLAB/OpenCV/C++ (Development Environment doesn't matter ) to track the position of the arrow.
  3. Compare the arrow's position with the predefined arrow image and the track.
  4. Rotate the respective motors and check the position of the arrow till it come straight with respect to the path.
  5. if everything comes straight, move the robot forward.

does anyone have any ideas or suggestions?
thanks again.

If there's going to be a track then instead of tracking the position of the arrow and matching it to the track, why not just track the track?

Mike

thats really great
would you gimme an idea how to track the track and navigate the robot?

What kind of track is it? Is it an open area or a sort of maze? Because you're idea is not that easy to realize. If it's a maze or something like that, then its easier to use a ultrasonic sensor or a line-follower.

I really have no skills in programming MATLAB, C++ and OpenCV so i cant help you with that. But i follow you're project because it's sounds interesting!

Good Luck!

Take a look at this Hough Line Transform — OpenCV 2.4.13.7 documentation
This code should work for you, but you'll have to read a webcam image instead of an image file. Then you'll have to send the line info, via serial, to the arduino and write a program to turn the motors based on the data.

Mike

What kind of track is it? Is it an open area or a sort of maze? Because you're idea is not that easy to realize. If it's a maze or something like that, then its easier to use a ultrasonic sensor or a line-follower.

The track is a sort of zebra line, i guess it can't be done using a line follower cuz the lines are perpendicular to the robot's path

Take a look at this Hough Line Transform — OpenCV 2.4.13.7 documentation
This code should work for you, but you'll have to read a webcam image instead of an image file. Then you'll have to send the line info, via serial, to the arduino and write a program to turn the motors based on the data.

thanks for the tutorial.
but as I'm a starter in OpenCV, Let me know what's gonna be the output (of the processed image?)
can i assign it on a variable to work with the further programming? :roll_eyes:

Kiduino:
but as I'm a starter in OpenCV, Let me know what's gonna be the output (of the processed image?)
can i assign it on a variable to work with the further programming? :roll_eyes:

the output will be a colored line drawn over the line it detected (see the bottom of the page)

for( size_t i = 0; i < lines.size(); i++ )
{
  float rho = lines[i][0], theta = lines[i][1];
  Point pt1, pt2;
  double a = cos(theta), b = sin(theta);
  double x0 = a*rho, y0 = b*rho;
  pt1.x = cvRound(x0 + 1000*(-b));
  pt1.y = cvRound(y0 + 1000*(a));
  pt2.x = cvRound(x0 - 1000*(-b));
  pt2.y = cvRound(y0 - 1000*(a));
  line( cdst, pt1, pt2, Scalar(0,0,255), 3, CV_AA);
}

this is where the lines are drawn, so you can use those values to send to the arduino.

Mike