unable to display video object detection in GUI..please help here..??
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Walter Roberson
am 13 Mär. 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()
Antworten (0)
Siehe auch
Kategorien
Mehr zu Image Preview and Device Configuration finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!