Ich zeige ein Video einer Maus in einer U.I und ich habe eine Datei mit den Koordinaten des Kopfes durch die Zeit. Ich möchte für jeden Rahmen die Position des Kopfes beispielsweise mit einem Marker anzeigen. HierMatlab Guide - Anzeige zusätzlicher Informationen auf einem Video
ist, was ich eigentlich tun:
% --- 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
Und das Problem ist, dass es nur um das Video anzuzeigen, und wenn ich die Processus Pause (mit einer Rückruftaste) zeigt es nur den Punkt, ohne den aktuellen Rahmen. ..
Ich sah mich um, fand aber nichts. Jede Hilfe wäre zu schätzen :)
Vielen Dank!
edit:
hier ist der Code der Taste 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);
ich Ihnen für die schlechte Vertiefung bitte um Vergebung, aber ich weiß nicht, wie es in Stack-Überlauf schnell zu lösen.
Können Sie Ihren Pause-Rückruf anzeigen? – Suever
Ich habe meinen Beitrag bearbeitet! –