show the bounding box in the sequence images?

1 view (last 30 days)
I want to detect an object in the sequence images and track it..
i have develop an program in malab to do it.
i track it with SAD template matchng.
here is the code :
for t=1:NumImages %to read the seq images
meas=80000;
for r=(lminr-10):(lminr+10)
for c=(lminc-10):(lminc+10)
temp=abs(im2double(cropped_img)-ImSeq(r:r+(lmaxr-lminr),c:c+(lmaxc-lminc),t));
if norm(temp,1)<= meas
meas=norm(temp,1);
new_r=r;
new_c=c;
else
new_r=r+15;
new_c=c+10;
end
end
end
final_rect=[new_c, new_r,(lmaxc-lminc),(lmaxr-lminr)];
figure(1);imshow(ImSeq(:,:,t),[])
hold on
title(t)
rectangle('Position',final_rect,'EdgeColor',[1 0 0]);
hold off
end
because i do template matching (SAD) between the cropped object with the seq images, the variable lminr, lminr, lminc, lminc is the coordinates of the cropped images(x,y,w,h).
to simplify the program, i do matching between the cropped object with the seq images in the position not far from the first object locate (first detected).By add 10 pixel to extend the location of the object in the next frames.
But the bounding box is not follow the object when i run the se imagess.. I think the problem is in the var new_r,new_c and the final_rect.
How to solve it??
pleasee

Answers (0)

Community Treasure Hunt

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

Start Hunting!