unable to display video object detection in GUI..please help here..??
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
This is my code for object detection in video, but it unable to display in GUI axes, it is displaying outside axes.. plz help..?
vid = videoinput('winvideo',1, 'YUY2_640x480');
set(vid,'ReturnedColorSpace','rgb');
set(vid,'TriggerRepeat',Inf);
vid.FrameGrabInterval =5;
start(vid);
figure;
while(vid.FramesAcquired<=50) % Stop after 50 frames, it depends upon the
frames
data = getdata(vid,2);
differ_image = imabsdiff(data(:,:,:,1),data(:,:,:,2)); %background subtraction
diff = rgb2gray(differ_image);
diff_bw = im2bw(diff,0.2);
bw2 = imfill(diff_bw,'holes');
s = regionprops(differ_image, 'centroid');
cd = s.Centroid;
centroids = cat(1, s.Centroid);
imshow(data(:,:,:,2));
hold(imgca,'on');
plot(imgca,centroids(:,1),centroids(:,2),'m*');
hold on;
rectangle('Position',[cd(:,1) cd(:,2) 20 20],'LineWidth',2,'EdgeColor','c');
hold(imgca,'off');
end
stop(vid)
delete(vid)
close(vid)
handles.output = hObject;
2 commentaires
Walter Roberson
le 13 Mar 2013
What is displaying outside of the axes?
You should have a drawnow() after you have finished the plotting.
Note: you should probably use 'Parent', imgca for the rectangle()
Réponses (0)
Voir également
Catégories
En savoir plus sur Image Preview and Device Configuration dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!