unable to display video object detection in GUI..please help here..??
조회 수: 1 (최근 30일)
이전 댓글 표시
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
Walter Roberson
2013년 3월 13일
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()
답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!