code for template matching

4 次查看(过去 30 天)
amarnath
amarnath 2014-3-13
all I needed is the same template matching code for Center of Gravity of moving target in a surveillance .......and I need to connect dynamic template matching output to stepper motor . . . .can you plz help me
object detection code . . by frame differencing we used the following code...
vid = videoinput('winvideo',1);
set(vid,'ReturnedColorSpace','rgb');
% Note that example uses both SET method and dot notation method.
set(vid,'TriggerRepeat',Inf);
vid.FrameGrabInterval = 5;
vid_src = getselectedsource(vid);
set(vid_src,'Tag','Intellicam setup');
figure;
start(vid)
while(vid.FramesAcquired<=1000) % Stop after 1000 frames
data = getdata(vid,2);
diff_im = imabsdiff(data(:,:,:,1),data(:,:,:,2));
diff = rgb2gray(diff_im);
%diff_range = rangefilt(diff); %you can use the range filter for better analysis
diff_bw = im2bw(diff,0.2);
noi_red = medfilt2(diff_bw,[3 3]);
%if more noise then use median filter or weiner filt to remove salt n
pepper noise
%ulta = imadjust(diff_bw,[0;1],[1;0]);
bw2 = imfill(diff_bw,'holes');%you can specify any other location
s = regionprops(bw2, 'centroid');
cd = s.Centroid
centroids = cat(1, s.Centroid);
imshow(data(:,:,:,2));
%imshow(diff_bw)
hold(imgca,'on');
plot(imgca,centroids(:,1),centroids(:,2),'g*');
imshow(diff_bw);
%hold on;
rectangle('Position',[cd 60 33],'LineWidth',1,'EdgeColor','b');%this is for
edges
hold(imgca,'off');
end
stop(vid)
plz plz plz help me with code.......
  2 个评论
Image Analyst
Image Analyst 2014-3-14
You're making us work blind? I can't see anything!
amarnath
amarnath 2014-3-15
sorry I didn't get you . . . .
actually our project is to track the moving object in a live video surveillance. . . . the above code I submitted has been using frame differencing method to obtain the centre of gravity of the moving object . . .we were facing the problem of loosing the track of first detected object if any other moving object is been through the video ......hope I briefly made you understand my problem .....

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 C4ISR 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by