how to use button that controls video?
    조회 수: 7 (최근 30일)
  
       이전 댓글 표시
    
hello~may I help you?
this is my code
obj = mmreader('watch.avi');
vid = read(obj);
for frame = 1 : size(vid,4)
   % bw = im2bw(vid(:,:,:,frame));
    subplot(2,2,1); imshow(vid(:,:,:,frame));
    subplot(2,2,2); imshow(vid(:,:,:,frame));
    subplot(2,2,3); imshow(vid(:,:,:,frame));
    subplot(2,2,4); imshow(vid(:,:,:,frame));
    drawnow;    
end
I want to use button that can "play"and "stop" and"close"
h4 = uicontrol('Style','PushButton','Units','normalized',...
  'String','play','Position',[.05 .05 .1 .1]);
controlling all video.
댓글 수: 0
채택된 답변
  Chandra Kurniawan
      
 2012년 2월 21일
        function vidplayer()
obj = mmreader('rhinos.avi');
v = read(obj);
hstat = uicontrol('unit','pixel','style','checkbox','value',0,'position',...
            [160 10 25 25]);
hplay = uicontrol('unit','pixel','style','pushbutton','string','PLAY',...
            'position',[10 10 50 25],'callback',{@play_callback,v});
hstop = uicontrol('unit','pixel','style','pushbutton','string','STOP',...
            'position',[60 10 50 25],'callback',@stop_callback);
hexit = uicontrol('unit','pixel','style','pushbutton','string','EXIT',...
            'position',[110 10 50 25],'callback',@exit_callback);
function play_callback(hObject,eventdata,vid)
    set(hstat,'value',1);    
    for frame = 1 : size(vid,4)   
        if get(hstat,'value') == 1,
            subplot(2,2,1); imshow(vid(:,:,:,frame));
            subplot(2,2,2); imshow(vid(:,:,:,frame));
            subplot(2,2,3); imshow(vid(:,:,:,frame));
            subplot(2,2,4); imshow(vid(:,:,:,frame));
            drawnow;    
        else, break; end
    end    
end
function stop_callback(hObject,eventdata)
    set(hstat,'value',0);
end
function exit_callback(hObject,eventdata)
    stop_callback;
    close gcf;
end
end
댓글 수: 0
추가 답변 (1개)
참고 항목
카테고리
				Help Center 및 File Exchange에서 Graphics Performance에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

