Using rectangle function in gui, not getting displayed?
2 次查看(过去 30 天)
显示 更早的评论
I have created a gui to insert video stream from webcam based on the code from
I have previously used rectangle function in normal figures with imshow and hold on, to put bounding boxes to track human. Now I want to use the rectangle function in gui. I tried displaying in a small while loop for testing. But Im not getting it.
Code:
function myCameraGUI_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
handles.video = videoinput('winvideo', 2);
set(handles.video,'TimerPeriod', 0.05, ...
'TimerFcn',['if(~isempty(gco)),'...
'handles=guidata(gcf);'... % Update handles
'image(getsnapshot(handles.video));'... % Get picture using GETSNAPSHOT and put it into axes using IMAGE
'set(handles.cameraAxes,''ytick'',[],''xtick'',[]),'... % Remove tickmarks and labels that are inserted when using IMAGE
'else '...
'delete(imaqfind);'... % Clean up - delete any image acquisition objects
'end']);
triggerconfig(handles.video,'manual');
handles.video.FramesPerTrigger = Inf; % Capture frames until we manually stop it
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes mycameragui wait for user response (see UIRESUME)
uiwait(handles.myCameraGUI);
%------
%Callback Fn for startCamera Button
function startStopCamera_Callback(hObject, eventdata, handles)
if strcmp(get(handles.startStopCamera,'String'),'Start Camera')
% Camera is off. Change button string and start camera.
set(handles.startStopCamera,'String','Stop Camera')
start(handles.video)
i=1;
x3=500;
y3=300;
while(i<20)
rectangle('Position',[x3,y3,10,10],'EdgeColor','r','LineWidth',1);
i=i+1
end
else
% Camera is on. Stop camera and change button string.
set(handles.startStopCamera,'String','Start Camera')
stop(handles.video)
end
0 个评论
采纳的回答
Walter Roberson
2016-3-7
Where is your drawnow() ?
Why are you drawing 20 rectangles in the same position on the same frame?
Which figure or axes are you drawing the rectangles in?
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 MATLAB Support Package for IP Cameras 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!