silverscorpion
silverscorpion
Branch Unspecified
08 Feb 2010

Video processing in matlab

Hi guys,
There's a robotics contest coming up in our univ. For that i've to build a robot that "sees" another robot in the arena and chases and catches it. Let's call mine as the cop and the other as thief. The arena will be video captured aerially and the video fed to the computer to which the robot is interfaced. The bot is autonomous. While designing the bot in itself is a big challenge, processing the video feed to identify where the thief is located currently is an even bigger problem. Does anyone know matlab? I know only the basics like plotting, func. generation, aliasing etc... Or is there some other software available to process the video? Can any one help me out on processing the video feed?
Thanks......
silverscorpion

silverscorpion

Branch Unspecified
11 years ago
Hey guys,
Nobody knows matlab here? help meeee.....
xheavenlyx

xheavenlyx

Electronics and Communication
11 years ago
Hi there Scorpion,

A few Q you will have to answer before I can help.

1. Do you have complete MATLAB? Do you have Image Processing, Signal Processing etc etc toolboxes??

2. What markers will be used to identify the robots? All cannot be the same color or shape or something. Give me more to help you here.

3. As you say you know MATLAB a bit, it would be nice if you can give me more details for your competition, rules, computer, camera (hardware) you will be using. Cuz, MATLAB has to detect the hardware first to get the images.

4. I know a bit of video processing in MATLAB and simulink, but again you need the toolboxes and blocksets. Before asking what these are I would have to tell you to read up.(I think you already know 😀 )

5. I am hoping you have a good team because building a robot itself is a challenge, having video processing is another story. Its not that tough, but you need a LOT of time if doing it alone...
silverscorpion

silverscorpion

Branch Unspecified
11 years ago
Hi xheavenlyx,
Thanx for ur support and here is my update to the problem.

I. Ya, i do think I have the complete matlab. In particular, I have the image processing and signal processing toolbox, as you mentioned will be necessary.

II. These are the rules regarding the competition...
Arena specifications
1. TOTAL SIZE : 160 X 120 cms
2. Size of each cell is 32 X 24 cms . Arena comprises of 5 X 5 cells.
3. The arena base will be covered with black chart paper (rough side).
4. A white outline of width 5 cm will be provided to the arena. The robot should not go out of the arena at any point
5. The web cam will be mounted at a height such that, the arena fits exactly into the 640 X 480
resolution.
6. The arena will be painted in white color whereas the grid lines and the restricted zones are in black.
[FONT=Verdana, Arial, Helvetica, sans-serif] 7. The cop bot is however allowed to cross the grid lines but not the restricted zones.[/FONT]
8. The restricted zone will be 2 cm higher than the arena surface.
As you see, the camera used is a standard web cam.

And this is the sample arena.
TOP VIEW OF THE SAMPLE ARENA
III These are the constraints of my bot...
THE COP:
1. The cop’s dimensions should not exceed 15 cm X15 cm X 15 cm (L x B x H) at any point of
the competition.
2. The power supply can either be on-board or external . The maximum power supply is 12V (ie)
potential measured across any two points on the robot should not exceed 12V at any point of time. A 12V
adaptor will be provided .
3.The robot can communicate with the computer either remotely or through wires.
4. Readymade chassis and gear boxes are permitted. The use of lego or other such kits, however is NOT
allowed.
5.Misinterpretation of the arena due to the participant’s wires must be tackled by the participant.
6.In the case of wired control, the wires connected to the robot must be slack at all times.
IV This is about the camera...
Model : Logitech Quickcam Messenger
Video Capture: upto 640x480
Still image Capture:upto 640x480
Frame rate : upto 30 frames per second
Also, there'll be only two bot in the arena at any time, mine and the other. ie, participants won't be pitted against each other...

That's it for now. Hope this will suffice... Expecting ur reply eagerly...
Bye.
xheavenlyx

xheavenlyx

Electronics and Communication
11 years ago
Dude, this one is a very interesting problem but you should know before hand, I nor anyone else can do the whole thing for you, since its very involving.

You gave a really good reply, but the last answer? Do you have a good team to make the bot? Ok, whatever it is, I will reply with the algorithm within a day or two.
xheavenlyx

xheavenlyx

Electronics and Communication
11 years ago
so firstly, you gotta divide the resolution in 5x5 with the same ratio of square as the field.

 So 32/160 = x/640      (32/160=0.2 which means 20% of hight)
     x = 128

and
     24/120 = x/480     (24/120=0.2 which means 20% of width. coincident?)
     x = 96
you should be knowing how to start a video object and import each frame in MATLAB. If not check some tutorials online or something, even MATLAb help is awesome! But I will give the code anyway (learn from it to suite ur neeeds, thats why I am giving this to you)

%% Block to aquire image from webcam.
% Create video input object. 
vid = videoinput('winvideo',1,'YUY2_320x240') %Check help for this before you start!! different frmats are possible.

% Set video input object properties for this application.
% Note that example uses both SET method and dot notation method.
set(vid,'TriggerRepeat',Inf);
set(vid,'ReturnedColorSpace','rgb');
%vid.FrameGrabInterval = -1;

%% Processing block
% Start acquiring frames.
start(vid);

while(vid.FramesAcquired<=100) % Stop after 100 frames
    imgrgb = getdata(vid);          %Store RGB image in imgrgb
    imshow(imgrgb);
end

stop(vid);
Next step will be to convert it to a grayscale image:

%I = .2989*imgrgb(:,:,1)+.5870*imgrgb(:,:,2)+.1140*imgrgb(:,:,3);
          %imshow(I);
Then you threshold the image. (Search for thresholding in MATLAB)

First do all this, get familiar.
silverscorpion

silverscorpion

Branch Unspecified
11 years ago
Hello xHx,
Very sorry for the long break. I'm glad that I'm back to video processing. I've built a team of four people who are very eager to do this robot. Now these are the things we've planned to do:

1. We've almost designed the chassis for the robot.
2. We're gonna use stepper motors which are to be driven by ULN2308 IC.
3. We're gonna interface the bot with the parallel port of the computer.
4. We've got ourselves more familiar with matlab and have learnt some basic image processing skills like filters, image type conversions, correlation etc.

Now the harder part: What to do next?

Well, matlab should take the video feed, determine where the thief is currently, and tell the current co-ordinates to the bot via parallel port. So, how to do it? How is shape recognition done in matlab? Lots of help required. Please help. Waiting for your reply...

(Thanx)
xheavenlyx

xheavenlyx

Electronics and Communication
11 years ago
Dude, oh my god!!! Sorry for the lateeee reply. I was busy with my project and on top of that last week i was in bombay for medical reasons!!

As I have mentioned before check the help files for many many examples, write down your objectives and look for the code in help files one by one, and everyone does it in their own way. It would take a lot of time if I did the whole thing.

Check and tell me.
sanih

sanih

Branch Unspecified
10 years ago
hi,
how can i save image of video fram by fram into the certain file?
please help me it's very important for me.
it's better for me if you ask me with matlab simulink!
sherlyram

sherlyram

Branch Unspecified
9 years ago
hi all
i wan't to know about how we will get GOP from mpeg video also is any command is there to identify I frames in a video file?

help me please

Share this content on your social channels -

Only logged in users can reply.