Tuesday, April 26, 2011

Color detecting

I got several requests to share the color detecting Matlab code.
To run this demo, you may need a webcam.
This code is based on YUY2 type of webcam.
So if you are using RGB type webcam, just remove "tmp = YUY2toRGB(tmp)" in the code.
Enjoy! :)

===================================================================

clear all;
close all;
frame=1;
images = [];

ImageBlur = 0.04 * ones(5,5);
H = fspecial('gaussian',[5 5],1.5);


%try
%% imaqreset;
if ~exist('vid')
vid = videoinput('winvideo', 1, 'YUY2_320x240');
preview(vid);
disp 'preview';
end
figure(1);
set(gcf, 'BackingStore', 'off');
figure(2);
set(gcf, 'toolbar', 'none');
set(gcf, 'MenuBar', 'none');
set(gcf, 'BackingStore', 'off');

while(1)
tmp=getsnapshot(vid);
tmp=YUY2toRGB(tmp);
images(:,:,:) = tmp;
if (size(images,3) >= 2)
set(0,'CurrentFigure',2)
imshow(tmp);
hold on;

temp_x=0;
temp_y=0;
n=0;
rad=0;
rad2=0;
for x = 1 :320;
for y = 1 : 240;
if (images(y,x,1)<20 && images(y,x,2)<20 && images(y,x,3)<20)
n=n+1;
temp_x=temp_x+x;
temp_y=temp_y+y;
rad=rad+1;
end;
end;
if(rad>rad2)
rad2=rad;
end;
rad=0;
end;
center_x=round(temp_x/n);
center_y=round(temp_y/n);
r=rad2/2;
t = 0:0.1:2*pi+0.2;
rx = center_x + r * cos(t); ry = center_y + r * sin(t); % circle drawing
line([center_x-10 center_x+10], [center_y center_y],'Color','c' ,'LineWidth',[2]);
line([center_x center_x], [center_y-10 center_y+10],'Color','c' ,'LineWidth',[2]);
line([160-10 160+10],[120 120],'Color','y' ,'LineWidth',[2]);
line([160 160],[120-10 120+10],'Color','y' ,'LineWidth',[2]);
plot(rx,ry,'c');
hold off;
drawnow;
end

%catch exception
% exception.getReport
%end
end

if exist('vid')
delete(vid);
clear vid;
end

Friday, April 22, 2011

Blob Detecting

Blob Detection
In the area of computer vision, blob detection refers to visual modules that are aimed at detecting points and/or regions in the image that are either brighter or darker than the surrounding.




Wednesday, April 20, 2011

Discussion

Here is RRT model and DH table of the model.
Find the transformation matrix.

Diagram
DH table





# Solution




Tuesday, April 19, 2011

Project Title:

Color Based Object Tracking System

Member Names:

Baek, Seunghun(baeksh@umich.edu)

Project Description

Tracking objects based on color is one of the quickest and easiest methods for tracking an object from one image frame to the next. The speed of this technique makes it very attractive for near-real time applications but due to its simplicity many issues exist that can cause the tracking to fail.

In most cases, a camera is fixed in a certain coordinate for the purpose of easy algorithm. In this project, however, actuators are to be installed perpendicular each other in a camera’s axis in order to move the camera orientation freely so that the camera follows an object, focusing on it.

Table1. Feature

Specification

The image is focused on the lens of a camera. The distance of an object(x, y) from the center of the lens frame can be calculated in real time.

Fig1. Schematic of System

Fig2. Schematic of Device

Model

Now, we can simply consider that the system is comprised of two revolution joint and one prismatic joint robot arm, but we are not controlling the prismatic joint.

Fig3. Three link spherical manipulator

Once we know the distance information (x, y) of an object, we can center the camera to the object adjusting the servomotor position.

Table2. DH Table

Fig4. Jacobian

Block Diagram

I tried two different approaches.

1. Without using the desired velocity.

Fig5. Block diagram of non-desired velocity control

2. Using the desired velocity.

Fig6. Block diagram of desired velocity control

Pictures

The picture of the device

Fig7. Picture of Device


Movies

In the movies, you might be able to check the difference between the control with desired velocity and without desired velocity control. With desired velocity control, the servomotor reduces it's speed when the camera comes close to the object. Without desired velocity control, on the other hand, the device keeps moving the motor in same speed. It shows not much difference in fixed object. However, indeed, the object is moving target. Often, in the case of non-desired velocity control, the system overshoot the target bear by the object.


Movie 1. Without desired velocity control

Movie 2. With desired velocity control

Results

The graph shows the efficiency of desired velocity control.

With desired velocity control, the device can catch the object faster and more reliable than the other method.


Fig8. Graph of desired & non-desired velocity control



Movie 3. Desired velocity control and camera view

Tuesday, April 12, 2011

Project Title:
Member Names (with emails):

Brief Project Description:

Objectives:

Picture:

Model, including Jacobian:

Block Diagram:

Control Design:

Implementation Notes:

Results:
(MATLAB plots)

Discussion: