Color detection problem.

조회 수: 2 (최근 30일)
i Venky
i Venky 2012년 1월 14일
I am trying to move my bot to the corresponding color in the image. I tried some algorithms but it didn't work out. I would be really happy if you could help me with this thing. I would be much obliged if you could provide me some kind of sample code or something. If you have this code please share the code with me.
I am trying to move my bot to the black rectangle corresponding to the red.
Thanks in advance.
  댓글 수: 3
Image Analyst
Image Analyst 2012년 1월 14일
What does "the black rectangle corresponding to the red" mean? Since you've been around here a while I would have thought you've already seen this: http://www.mathworks.com/matlabcentral/answers/6200-tutorial-how-to-ask-a-question-on-answers-and-get-a-fast-answer
Image Analyst
Image Analyst 2012년 1월 14일
What is a bot? You mean a robot? Like you're somehow communicating with a robot to move the robot to locations on the floor that are covered with colored paint or stickers?

댓글을 달려면 로그인하십시오.

답변 (5개)

i Venky
i Venky 2012년 1월 14일
Sorry guys. I uploaded it but I don't know why it didn't show up. Anyway I am uploading it once again.
The robot is in the black circle at the bottom. I need to move the robot to the left. I don't have problem with the serial communication. The problem is with the image processing part code. I would be really happy if you could help me.
Thanks in advance
  댓글 수: 1
Image Analyst
Image Analyst 2012년 1월 14일
I don't understand. Your image looks like you're doing a simulation yet you say you have a robot that is taking orders from your computer, perhaps via the Instrument Control Toolbox or something similar. So if you send out a signal through your serial communications line to move your robot to some real world location in a real room, on a calibrated playing field where distances are measured in meters, then how does that relate to your computer graphics simulation where things are measured in pixels?

댓글을 달려면 로그인하십시오.


Walter Roberson
Walter Roberson 2012년 1월 14일

i Venky
i Venky 2012년 1월 15일
Actually I would draw these figures on the ground later. The robot is in the position denoted by the black circle. What I need is some what like this-
I need the robot to move to the position of the black square near the red one. For that I want to first detect where the red square is. After that using left,right,up and down direction commands (i.e. serial data corresponding to left, right, up and down) the robot has to go to that position.
Assume that
left- 00,
right- 01,
up- 10,
down-11
I know how to do the serial communication using Matlab.
So there's no need of the code for serial communication. Let's assume that out(a) will send the value contained in 'a' serially (a has the value for direction - 00 or 01 or 10 or 11).
All I need is the algorithm
Thanks in advance
  댓글 수: 4
i Venky
i Venky 2012년 1월 15일
I would be really happy if you could give me some kind of sample code.
Thanks in advance.
Image Analyst
Image Analyst 2012년 1월 15일
Yes, I believe you would. But that's asking way too much to have us give you code to control movement of a robot around a room while showing a simulation of it on the screen, particularly when you haven't been forthcoming in answering questions directly. You already have code for communicating with your robot over a serial line, and my File Exchange has several methods for finding colored patches in an image. You now have all the tools you need. I think the rest of your project is for you to adapt and integrate those concepts into your project.

댓글을 달려면 로그인하십시오.


i Venky
i Venky 2012년 1월 15일
Assume that I have colored my robot in a different color (say purple).

Walter Roberson
Walter Roberson 2012년 1월 16일
As you already have the other parts, all you need is
left = [0 0];
right = [0 1];
up = [1 0];
down = [1 1];
%calculate number of times need to go Left, Right, Up, Down. Then
for K = 1 : NLeft; out(left); end
for K = 1 : NRight; out(right); end
for K = 1 : NUp; out(up); end
for K = 1 : NDown; out(down); end
I would not have thought that would be a conceptual difficulty ?

카테고리

Help CenterFile Exchange에서 Robotics에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by