2016-06-30 3 views
0

나는 U.I에 마우스 비디오를 표시하고 있으며 머리 부분의 좌표가있는 파일이 있습니다. 각 프레임마다 마커를 사용하여 머리의 위치를 ​​표시하고 싶습니다.Matlab 가이드 - 비디오에 대한 추가 정보 표시

% --- Get the current frame, display it and set axes properties 
    setDirectory(handles.video,handles.numFrame); 
    I = handles.video.read();   
    imagesc(I,'Parent',handles.axes1); 
    hold on 
    plot(handles.xHead(handles.numFrame),handles.yHead(handles.numFrame),... 
      'o','MarkerFaceColor','b','MarkerSize',10,'Parent',handles.axes1); 
    colormap(gray); 
    handles.axes1.Visible = 'off'; 
    drawnow 
    hold off 

그리고 문제는 단지 비디오를 표시한다는 것입니다 내가 (콜백 버튼 포함)에이 과정을 일시 중지 할 때 현재 프레임없이 단지 지점을 표시 : 여기

내가 실제로 할 것입니다. ..

나는 주변을 둘러 보았지만 아무 것도 발견하지 못했습니다. 어떤 도움을 주시면 감사하겠습니다 :)

Thank you!

편집 : 여기

는 버튼 pause_callback의 코드입니다 :

% --- Executes on button press in play. 
function play_Callback(hObject, ~, handles) 
% hObject handle to play (see GCBO) 
% eventdata reserved - to be defined in a future version of MATLAB 
% handles structure with handles and user data (see GUIDATA) 

% --- Inverse the value of the button Play/Pause when it is clicked 
if strcmp(hObject.String,'Play') 
    hObject.String = 'Pause'; 
else 
    hObject.String = 'Play'; 
end 

% --- Algorithm to read the video and graphics 
while strcmp(hObject.String,'Pause') 
    % --- Get the way of reading of the video 
    handles.sens = get(handles.listbox3, 'Value'); 
if handles.sens == 1 
    % Go forward 
    handles.defilement = 1; 
elseif handles.sens == 2 
    % Go back 
    handles.defilement = -1; 
end 

% --- Get the speed of the video 
tPause = get(handles.edit2,'String'); 
tPause = str2num(tPause); 
if isempty(tPause) 
    set(handles.edit2,'String','1'); 
    warndlg('Vous devez entrer une valeur num�rique non nulle !'); 
elseif tPause ~= handles.speedBase 
    handles.speedBase = tPause; 
end 

% --- Check if there is still a frame in the video 
if handles.numFrame > 0 && handles.numFrame < (handles.nbrFrames + 1) 

    % --- Get the current frame, display it and set axes properties 
    setDirectory(handles.video,handles.numFrame); 
    I = handles.video.read();   
    imagesc(I,'Parent',handles.axes1); 
    colormap(gray); 
    handles.axes1.Visible = 'off'; 
    pause(0.001); 

    % --- Assign the new position of the marker 
    handles.xMV = handles.numFrame; 
    handles.yMV = handles.yGV(handles.xMV); 

    handles.xMR = handles.numFrame; 
    handles.yMR = handles.yGR(handles.xMR); 

    handles.xMRat = handles.numFrame; 
    handles.yMRat = handles.yGRat(handles.xMRat); 

    if handles.angle.Value==1 
     handles.xMAng = handles.numFrame; 
     handles.yMAng = handles.yGAng(handles.xMAng); 
    end 

    % --- Assign the new scale for Y 
    if mod(handles.numFrame,(handles.ecart/10)) == 0 && handles.autoscale.Value == 1 
     [handles.YminV, handles.YmaxV] = autoscale(handles.yGVsmooth,handles.ecart,handles.numFrame,handles.nbrFrames); 
     handles.yminV.String = handles.YminV; 
     handles.ymaxV.String = handles.YmaxV; 

     [handles.YminR, handles.YmaxR] = autoscale(handles.yGRsmooth,handles.ecart,handles.numFrame,handles.nbrFrames); 
     handles.yminR.String = handles.YminR; 
     handles.ymaxR.String = handles.YmaxR; 

     [handles.YminRat, handles.YmaxRat] = autoscale(handles.yGRat,handles.ecart,handles.numFrame,handles.nbrFrames); 
     handles.yminRat.String = handles.YminRat; 
     handles.ymaxRat.String = handles.YmaxRat; 

     if handles.angle.Value==1 
      [handles.YminAng, handles.YmaxAng] = autoscale(handles.yGAng,handles.ecart,handles.numFrame,handles.nbrFrames); 
      handles.yminAng.String = handles.YminAng; 
      handles.ymaxAng.String = handles.YmaxAng; 
      disp(handles.YminAng); 
      disp(handles.YmaxAng); 
     end 
    end 

    % --- Refresh graphics 
    if handles.numFrame < handles.ecart 
     % --- Display the graphics 
     % Graph of red fluorescence 
     plot(handles.xGV(1:(handles.ecart*2)),handles.yGV(1:(handles.ecart*2)),... 
      handles.xMV,handles.yMV,'o','MarkerFaceColor','r','MarkerSize',3, ... 
      'Color','g','Parent',handles.axes2); 
     % Graph of green fluorescence 
     plot(handles.xGR(1:(handles.ecart*2)),handles.yGR(1:(handles.ecart*2)),... 
      handles.xMR,handles.yMR,'o','MarkerFaceColor','g','MarkerSize',3, ... 
      'Color','r','Parent',handles.axes3); 
     % Graph of ratio 
     plot(handles.xGRat(1:(handles.ecart*2)),handles.yGRat(1:(handles.ecart*2)),... 
      handles.xMRat,handles.yMRat,'o','MarkerFaceColor','g','MarkerSize',3, ... 
      'Color','b','Parent',handles.axes4); 
     % Graph of the angle 
     if handles.angle.Value==1 
      plot(handles.xGAng(1:(handles.ecart*2)),handles.yGAng(1:(handles.ecart*2)),... 
       handles.xMAng,handles.yMAng,'o','MarkerFaceColor','g','MarkerSize',3, ... 
       'Color','y','Parent',handles.axes6); 
      set(handles.axes6,'xLim',[1 (handles.ecart*2)],'yLim',[handles.YminAng handles.YmaxAng]); 
      set(handles.axes6.Title,'String','Angle'); 
     end 
     % --- Set the properties of the axis 
     % Graph of red fluorescence 
     set(handles.axes2,'xLim',[1 (handles.ecart*2)],'yLim',[handles.YminV handles.YmaxV]); 
     set(handles.axes2.Title,'String','Fluorescence Verte'); 
     % Graph of green fluorescence 
     set(handles.axes3,'xLim',[1 (handles.ecart*2)],'yLim',[handles.YminR handles.YmaxR]); 
     set(handles.axes3.Title,'String','Fluorescence Rouge'); 
     % Graph of ratio 
     set(handles.axes4,'xLim',[1 (handles.ecart*2)],'yLim',[handles.YminRat handles.YmaxRat]); 
     set(handles.axes4.Title,'String','Ratio'); 

    elseif handles.numFrame > handles.ecart && handles.numFrame < (handles.nbrFrames - handles.ecart-1) 
     % --- Display the graph and the marker and make the graph dynamic 
     % Graph of red fluorescence 
     plot(handles.xGV((handles.numFrame-handles.ecart):(handles.numFrame+handles.ecart)), ... 
      handles.yGV((handles.numFrame-handles.ecart):(handles.numFrame+handles.ecart)),... 
      handles.xMV,handles.yMV,'o','MarkerFaceColor','r','MarkerSize',3, ... 
      'Color','g','Parent',handles.axes2); 
     % Graph of green fluorescence 
     plot(handles.xGR((handles.numFrame-handles.ecart):(handles.numFrame+handles.ecart)), ... 
      handles.yGR((handles.numFrame-handles.ecart):(handles.numFrame+handles.ecart)),... 
      handles.xMR,handles.yMR,'o','MarkerFaceColor','g','MarkerSize',3, ... 
      'Color','r','Parent',handles.axes3); 
     % Graph of ratio 
     plot(handles.xGRat((handles.numFrame-handles.ecart):(handles.numFrame+handles.ecart)), ... 
      handles.yGRat((handles.numFrame-handles.ecart):(handles.numFrame+handles.ecart)),... 
      handles.xMRat,handles.yMRat,'o','MarkerFaceColor','g','MarkerSize',3, ... 
      'Color','b','Parent',handles.axes4); 
     if handles.angle.Value==1 
      plot(handles.xGAng((handles.numFrame-handles.ecart):(handles.numFrame+handles.ecart)), ... 
       handles.yGAng((handles.numFrame-handles.ecart):(handles.numFrame+handles.ecart)),... 
       handles.xMAng,handles.yMAng,'o','MarkerFaceColor','g','MarkerSize',3, ... 
       'Color','b','Parent',handles.axes6); 
      set(handles.axes6,'xLim',[(handles.numFrame-handles.ecart) (handles.numFrame+handles.ecart-1)],... 
       'yLim',[handles.YminAng handles.YmaxAng]); 
      set(handles.axes6.Title,'String','Angle'); 
     end 
     % --- Set the properties of the axis 
     % Graph of red fluorescence 
     set(handles.axes2,'xLim',[(handles.numFrame-handles.ecart) (handles.numFrame+handles.ecart-1)],... 
      'yLim',[handles.YminV handles.YmaxV]); 
     set(handles.axes2.Title,'String','Fluorescence Verte'); 
     % Graph of green fluorescence 
     set(handles.axes3,'xLim',[(handles.numFrame-handles.ecart) (handles.numFrame+handles.ecart-1)],... 
      'yLim',[handles.YminR handles.YmaxR]); 
     set(handles.axes3.Title,'String','Fluorescence Rouge'); 
     % Graph of ratio 
     set(handles.axes4,'xLim',[(handles.numFrame-handles.ecart) (handles.numFrame+handles.ecart-1)],... 
      'yLim',[handles.YminRat handles.YmaxRat]); 
     set(handles.axes4.Title,'String','Ratio'); 
    elseif handles.numFrame > (handles.nbrFrames - handles.ecart) 
     % --- Display the graph and the marker 
     % Graph of red fluorescence 
     plot(handles.xGV((handles.nbrFrames-(handles.ecart*2)):handles.nbrFrames-1), ... 
      handles.yGV((handles.nbrFrames-(handles.ecart*2)):handles.nbrFrames-1),... 
      handles.xMV,handles.yMV,'o','MarkerFaceColor','r','MarkerSize',3, ... 
      'Color','g','Parent',handles.axes2); 
     % Graph of green fluorescence 
     plot(handles.xGR((handles.nbrFrames-(handles.ecart*2)):handles.nbrFrames-1), ... 
      handles.yGR((handles.nbrFrames-(handles.ecart*2)):handles.nbrFrames-1),... 
      handles.xMR,handles.yMR,'o','MarkerFaceColor','g','MarkerSize',3, ... 
      'Color','r','Parent',handles.axes3); 
     % Graph of ratio 
     plot(handles.xGRat((handles.nbrFrames-(handles.ecart*2)):handles.nbrFrames-1), ... 
      handles.yGRat((handles.nbrFrames-(handles.ecart*2)):handles.nbrFrames-1),... 
      handles.xMRat,handles.yMRat,'o','MarkerFaceColor','g','MarkerSize',3, ... 
      'Color','b','Parent',handles.axes4); 
     if handles.angle.Value==1 
      plot(handles.xGAng((handles.nbrFrames-(handles.ecart*2)):handles.nbrFrames-1), ... 
       handles.yGAng((handles.nbrFrames-(handles.ecart*2)):handles.nbrFrames-1),... 
       handles.xMAng,handles.yMAng,'o','MarkerFaceColor','g','MarkerSize',3, ... 
       'Color','b','Parent',handles.axes6); 
      set(handles.axes6,'xLim',[((handles.nbrFrames-1)-(handles.ecart*2)) handles.nbrFrames],... 
       'yLim',[handles.YminAng handles.YmaxAng]); 
      set(handles.axes6.Title,'String','Angle'); 
     end 
     % --- Set the properties of the axis 
     % Graph of red fluorescence 
     set(handles.axes2,'xLim',[((handles.nbrFrames-1)-(handles.ecart*2)) handles.nbrFrames],... 
      'yLim',[handles.YminV handles.YmaxV]); 
     set(handles.axes2.Title,'String','Fluorescence Verte'); 
     % Graph of green fluoresence 
     set(handles.axes3,'xLim',[((handles.nbrFrames-1)-(handles.ecart*2)) handles.nbrFrames],... 
      'yLim',[handles.YminR handles.YmaxR]); 
     set(handles.axes3.Title,'String','Fluorescence Rouge'); 
     % Graph of ratio 
     set(handles.axes4,'xLim',[((handles.nbrFrames-1)-(handles.ecart*2)) handles.nbrFrames],... 
      'yLim',[handles.YminRat handles.YmaxRat]); 
     set(handles.axes4.Title,'String','Ratio'); 
    end 

    % --- Manage the speed of the video 
    pause(tPause); 

    % --- Conditions whiwh prevent to assign a wrong value to 
    % --- handles.numFrame 
    if handles.numFrame == 1 && handles.sens == 1 
     handles.numFrame = handles.numFrame + handles.defilement; 
    elseif handles.numFrame > 1 && handles.numFrame < handles.nbrFrames 
     handles.numFrame = handles.numFrame + handles.defilement; 
    elseif handles.numFrame == handles.nbrFrames && handles.sens == 2 
     handles.numFrame = handles.numFrame + handles.defilement; 
    end 
end 
    % --- Refresh the UI 
    set(handles.text14,'String',handles.numFrame); 

% --- Manage the case we went back to the beginning 
if handles.numFrame == 1 && handles.sens == 2 
    if strcmp(hObject.String,'Pause') 
     % reset status of the button 
     hObject.String = 'Play'; 
    end 
    break 
end 

% --- Manage the case we arrived to the end of the video 
if handles.numFrame == handles.nbrFrames 
    if strcmp(hObject.String,'Pause') 
     % reset status of the button 
     hObject.String = 'Play'; 
    end 
    break 
end 
end 

% Update handles structure 
guidata(hObject,handles); 

난 당신이 나쁜 들여 쓰기 용서 구걸하지만 난 스택 오버 플로우에서 신속하게 해결하는 방법을 모르겠어요.

+0

일시 중지 콜백을 표시 할 수 있습니까? – Suever

+0

내 게시물을 편집했습니다. –

답변

0

이 문제는 matlab에서 이벤트 대기열을 사용하는 방법과 drawnow가 이러한 대기열에 미치는 영향과 관련이 있습니다. 나는

이 즉시 업데이트하기 전에 처리 할 이벤트 큐에 이미 다른 콜백을 허용하지 않고 그래픽을 업데이트해야합니다

노출 drawnow 시도 할 것입니다.

+0

그것은 작동하지 않습니다 ... 만약 내가 drawow 노출 그것은 단지 위치의 지점과 더 이상 이미지를 표시! 도와 주셔서 감사합니다. –

관련 문제