unable to display video object detection in GUI..please help here..??

1 view (last 30 days)
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 Comments
Walter Roberson
Walter Roberson on 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()
Rajesh
Rajesh on 13 Mar 2013
outside of the axes figure window is displaying with complete output without any error but I need to display in axes command GUI not outside axes, it is inside axes...?
Here I'm using IMSHOW(), so this is problem arising, it is always display outside of axes GUI axis, so I need to rectify this problem.
So, how can I display output with out using IMSHOW() command.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!