unable to display video object detection in GUI..please help here..??
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Walter Roberson
el 13 de Mzo. de 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()
Respuestas (0)
Ver también
Categorías
Más información sobre Image Preview and Device Configuration en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!