Live video preview in app designer

조회 수: 9 (최근 30일)
Ghaith Hatamleh
Ghaith Hatamleh 2020년 11월 28일
댓글: Ghaith Hatamleh 2020년 12월 10일
I am trying to get a live video input to be shown in a place of an image I added to my application.
I followed some steps provided by our professor, however, I keep getting the error provided in the image!
Those are all of the objects I have
properties (Access = public)
UIFigure matlab.ui.Figure
AppsNameLabel matlab.ui.control.Label
InstructionsButton matlab.ui.control.Button
CameraSwitchLabel matlab.ui.control.Label
CameraSwitch matlab.ui.control.Switch
Lamp matlab.ui.control.Lamp
ExitButton matlab.ui.control.Button
Image matlab.ui.control.Image
end
This is the function that is supposed to view the live video in the place of the image.
function startupFcn(app)
vid = videoinput('winvideo');
hImage = image(app.Image,zeros(720 ,1280, 3));
pause(2)
app.Image.XLim = [0,1280];
app.Image.YLim = [0, 720];
app.Image.XTick = [];
app.Image.YTick = [];
pbaspect(app.Image,[1280,720,1])
preview(vid,hImage)
end
And lastly, this is the error I'm getting
Error using image
Image cannot be a child of Image.
Error in HandGApp (line 121)
runStartupFcn(app, @startupFcn)

답변 (1개)

Raunak Gupta
Raunak Gupta 2020년 12월 5일
Hi,
I found a similar question which talks about plotting a Line on a live Image Preview. In your case you want to add image only, I suggest creating an axes first and then plot the image to that axes. This image can then be previewed on the video. Currently app.Image looks like an Image already on which another Image object cannot be plotted, thus you may need to create an axes first. Code in the similar question can help you to resolve the error.
  댓글 수: 1
Ghaith Hatamleh
Ghaith Hatamleh 2020년 12월 10일
Thank you for your relpy, Everything works fine now that I replaced the image with an axes

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by