imshow with a slider object is blocking my Button Down function
I have developed an app that reads all the frames of the video and allows the user to scroll through all the frames of a video with a line that I want to place at the centre of the frame during startup. Subsequently, it will become a user movable line. I initially created a ButtonDown callback on the Axes but it only works on the first image before I use the slider. After that, it doesn’t respond to any clicks.
I then tried a ButtonDown callback on the figure and it doesn’t work on the first image. It only works after I use the slider object and scroll through the frames. Can anyone figure out what the slider is doing to make my callbacks not work throughout the user interaction?
Also, I can’t seem to get rid of the first line that is created by the app during start up. Both callbacks will create a second line when a click is detected but subsequently that second line will be movable while the first line just stays in place.
The last issue I have is that my app takes ages to load when I click the ‘play’ button. At least 30 seconds-1 minute to show the first frame and all the other UI objects in the function. Is there any way I can make my app more efficient?
Here are my codes:
P.S. I use either the UIFigure ButtonDown call back or the UIAxes ButtonDown callback when I run my app and not at the same time.
function play(app, event)
videoReader = VideoReader(‘C:/Capstone/Data/Patient/Left Diaphragm Expiration.mp4’);
app.AllFrames=zeros(app.h,app.w,app.numFrames);
app.h=videoReader.height;
app.w=videoReader.width;
app.numFrames=videoReader.NumFrames;
app.framerate= videoReader.FrameRate;
app.Slider.Limits=[1,app.numFrames];
app.Slider.MinorTicks=[];
firstframe=read(videoReader,1);
for a=1:app.numFrames
frame=read(videoReader,a);
frame=im2gray(frame);
app.AllFrames(:,:,a)=frame;
end
app.framehandle=imshow(firstframe,’Parent’,app.UIAxes);
set(app.framehandle,’HitTest’,’off’);
set(app.framehandle, ‘PickableParts’,’all’);
hold (app.UIAxes,"on");
app.Mline= xline(app.UIAxes,(app.w/2),’Color’,’red’);
app.Mline.LineWidth=2;
function changingValue(app, event)
value = floor(app.Slider.Value);
app.framehandle=imshow(app.AllFrames(:,:,value),[0,255],’Parent’,app.UIAxes)
set(app.framehandle,’HitTest’,’off’);
set(app.framehandle, ‘PickableParts’,’all’);
hold (app.UIAxes,"on");
% Value changed function: Slider
function valueChanged(app, event)
value = floor(app.Slider.Value);
app.framehandle=imshow(app.AllFrames(:,:,value),[0,255],’Parent’,app.UIAxes)
set(app.framehandle,’HitTest’,’off’);
set(app.framehandle, ‘PickableParts’,’all’);
hold (app.UIAxes,"on");
% Button down function: UIFigure
function UIFigureButtonDown(app, event)
delete(app.Mline)
app.Mline=xline(app.UIAxes,app.UIAxes.CurrentPoint(1),’Color’,’red’);
app.Mline.LineWidth=2;
% Button down function: UIAxes
function UIAxesButtonDown(app, event)
app.Mline=xline(app.UIAxes,app.UIAxes.CurrentPoint(1),’Color’,’red’);
app.Mline.LineWidth=2;I have developed an app that reads all the frames of the video and allows the user to scroll through all the frames of a video with a line that I want to place at the centre of the frame during startup. Subsequently, it will become a user movable line. I initially created a ButtonDown callback on the Axes but it only works on the first image before I use the slider. After that, it doesn’t respond to any clicks.
I then tried a ButtonDown callback on the figure and it doesn’t work on the first image. It only works after I use the slider object and scroll through the frames. Can anyone figure out what the slider is doing to make my callbacks not work throughout the user interaction?
Also, I can’t seem to get rid of the first line that is created by the app during start up. Both callbacks will create a second line when a click is detected but subsequently that second line will be movable while the first line just stays in place.
The last issue I have is that my app takes ages to load when I click the ‘play’ button. At least 30 seconds-1 minute to show the first frame and all the other UI objects in the function. Is there any way I can make my app more efficient?
Here are my codes:
P.S. I use either the UIFigure ButtonDown call back or the UIAxes ButtonDown callback when I run my app and not at the same time.
function play(app, event)
videoReader = VideoReader(‘C:/Capstone/Data/Patient/Left Diaphragm Expiration.mp4’);
app.AllFrames=zeros(app.h,app.w,app.numFrames);
app.h=videoReader.height;
app.w=videoReader.width;
app.numFrames=videoReader.NumFrames;
app.framerate= videoReader.FrameRate;
app.Slider.Limits=[1,app.numFrames];
app.Slider.MinorTicks=[];
firstframe=read(videoReader,1);
for a=1:app.numFrames
frame=read(videoReader,a);
frame=im2gray(frame);
app.AllFrames(:,:,a)=frame;
end
app.framehandle=imshow(firstframe,’Parent’,app.UIAxes);
set(app.framehandle,’HitTest’,’off’);
set(app.framehandle, ‘PickableParts’,’all’);
hold (app.UIAxes,"on");
app.Mline= xline(app.UIAxes,(app.w/2),’Color’,’red’);
app.Mline.LineWidth=2;
function changingValue(app, event)
value = floor(app.Slider.Value);
app.framehandle=imshow(app.AllFrames(:,:,value),[0,255],’Parent’,app.UIAxes)
set(app.framehandle,’HitTest’,’off’);
set(app.framehandle, ‘PickableParts’,’all’);
hold (app.UIAxes,"on");
% Value changed function: Slider
function valueChanged(app, event)
value = floor(app.Slider.Value);
app.framehandle=imshow(app.AllFrames(:,:,value),[0,255],’Parent’,app.UIAxes)
set(app.framehandle,’HitTest’,’off’);
set(app.framehandle, ‘PickableParts’,’all’);
hold (app.UIAxes,"on");
% Button down function: UIFigure
function UIFigureButtonDown(app, event)
delete(app.Mline)
app.Mline=xline(app.UIAxes,app.UIAxes.CurrentPoint(1),’Color’,’red’);
app.Mline.LineWidth=2;
% Button down function: UIAxes
function UIAxesButtonDown(app, event)
app.Mline=xline(app.UIAxes,app.UIAxes.CurrentPoint(1),’Color’,’red’);
app.Mline.LineWidth=2; I have developed an app that reads all the frames of the video and allows the user to scroll through all the frames of a video with a line that I want to place at the centre of the frame during startup. Subsequently, it will become a user movable line. I initially created a ButtonDown callback on the Axes but it only works on the first image before I use the slider. After that, it doesn’t respond to any clicks.
I then tried a ButtonDown callback on the figure and it doesn’t work on the first image. It only works after I use the slider object and scroll through the frames. Can anyone figure out what the slider is doing to make my callbacks not work throughout the user interaction?
Also, I can’t seem to get rid of the first line that is created by the app during start up. Both callbacks will create a second line when a click is detected but subsequently that second line will be movable while the first line just stays in place.
The last issue I have is that my app takes ages to load when I click the ‘play’ button. At least 30 seconds-1 minute to show the first frame and all the other UI objects in the function. Is there any way I can make my app more efficient?
Here are my codes:
P.S. I use either the UIFigure ButtonDown call back or the UIAxes ButtonDown callback when I run my app and not at the same time.
function play(app, event)
videoReader = VideoReader(‘C:/Capstone/Data/Patient/Left Diaphragm Expiration.mp4’);
app.AllFrames=zeros(app.h,app.w,app.numFrames);
app.h=videoReader.height;
app.w=videoReader.width;
app.numFrames=videoReader.NumFrames;
app.framerate= videoReader.FrameRate;
app.Slider.Limits=[1,app.numFrames];
app.Slider.MinorTicks=[];
firstframe=read(videoReader,1);
for a=1:app.numFrames
frame=read(videoReader,a);
frame=im2gray(frame);
app.AllFrames(:,:,a)=frame;
end
app.framehandle=imshow(firstframe,’Parent’,app.UIAxes);
set(app.framehandle,’HitTest’,’off’);
set(app.framehandle, ‘PickableParts’,’all’);
hold (app.UIAxes,"on");
app.Mline= xline(app.UIAxes,(app.w/2),’Color’,’red’);
app.Mline.LineWidth=2;
function changingValue(app, event)
value = floor(app.Slider.Value);
app.framehandle=imshow(app.AllFrames(:,:,value),[0,255],’Parent’,app.UIAxes)
set(app.framehandle,’HitTest’,’off’);
set(app.framehandle, ‘PickableParts’,’all’);
hold (app.UIAxes,"on");
% Value changed function: Slider
function valueChanged(app, event)
value = floor(app.Slider.Value);
app.framehandle=imshow(app.AllFrames(:,:,value),[0,255],’Parent’,app.UIAxes)
set(app.framehandle,’HitTest’,’off’);
set(app.framehandle, ‘PickableParts’,’all’);
hold (app.UIAxes,"on");
% Button down function: UIFigure
function UIFigureButtonDown(app, event)
delete(app.Mline)
app.Mline=xline(app.UIAxes,app.UIAxes.CurrentPoint(1),’Color’,’red’);
app.Mline.LineWidth=2;
% Button down function: UIAxes
function UIAxesButtonDown(app, event)
app.Mline=xline(app.UIAxes,app.UIAxes.CurrentPoint(1),’Color’,’red’);
app.Mline.LineWidth=2; appdesigner, image analysis MATLAB Answers — New Questions