Displaying video in a App Designer's tab

I want to display a live video preview in app made by App Designer, using preview(), but I don't want it to create seperate window, just display the image in one of the tabs. Is it even possible using App Designer. Do I have to create any objects to make it possible?

4 Comments

I guess yes.
In your callback function of play button:
for i=1:1:length(yourimage)
imshow(yourimage(i),'Parent',app.UIAxes');
drawnow
pause(0.01) % might not necessary if your gui updating speed is nice to you
end
You may stream your webcam as well. features like play,rewind,forward,pause , you may refer to the link below:
Thank you for response. Why I asked about using preview() to display image is the fact, that it does not affect framerate. Drawing a figure drops it significantly. Also the loop is probably not set correctly, because it seemed that the figure displays only one streched pixel in greyscale. I've developed code that allows us to draw figures based on the video input:
vid = videoinput(adaptorname,deviceID,format);
for i=1:(no of frames you want to display)
img = getsnapshot(vid);
imshow(img,'Parent',app.UIAxes');
drawnow
pause(0.01) % might not necessary if your gui updating speed is nice to you
end
I wonder if you know any way to make displaying more prompt.
it does not affect framerate
You are right, it make me headache sometimes on the inconsistent updating frame rate. I use tic(),toc() and pause().
for loop
tic()
time=toc()
let say you wannt maintain it 0.1 updating rate
pause(0.1-time)
end
However it must ensure 0.1-time is not negative value.
How to make your updating rate faster?
In my memory, i use cla(axes,'reset') in the loop, clear some unused variables, and make the code in the loop more simple and straight forward.
Or,
sacrifice some of your frame to make your display look like faster in playing.
Or,
I heard system object may help, but i haven tried it.
Michael Wieczorek,
If you want your video running faster, you may consider programmatically GUI instead of app designer.

Sign in to comment.

Answers (1)

I am using the above code but this very slowly works I want to run it fastly as a live camera. Thanks in advance.

3 Comments

Are you using App Designer? Put your question/comment below the original question instead of putting it in answer box.
Yes I am using App Designer and I want to preview camera on an axis.
I'm not sure with other's opinion. But if you use programmatically GUI, it will be much more faster without the lag in app designer.

Sign in to comment.

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Asked:

on 22 Oct 2018

Commented:

on 9 Nov 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!