Go Down

Topic: Robot control using top camera image analysis? (Read 2358 times) previous topic - next topic

Kiduino

Hi all,  :)
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 :)

i void warrenties

47Mike47

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

Kiduino

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.
i void warrenties

47Mike47

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

Kiduino

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

Stealth0113

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!
Watch my stealth-bot @ let's make robots

47Mike47

Take a look at this http://docs.opencv.org/doc/tutorials/imgproc/imgtrans/hough_lines/hough_lines.html
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

Kiduino

Quote
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
i void warrenties

Kiduino

Quote
Take a look at this http://docs.opencv.org/doc/tutorials/imgproc/imgtrans/hough_lines/hough_lines.html
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? :smiley-roll:
i void warrenties

47Mike47


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? :smiley-roll:


the output will be a colored line drawn over the line it detected (see the bottom of the page)
Code: [Select]
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

Go Up