How to run webcam on an axis in app designer ?

조회 수: 15 (최근 30일)
Ahmer Shahid
Ahmer Shahid 2018년 11월 1일
댓글: Ahmer Shahid 2018년 12월 4일
function startcamerabutton_Callback(app, event)
% hObject handle to startcamerabutton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
app.camera=videoinput('winvideo',1);
imshow(app.camera,'Parent',app.livedisplay);
end
  댓글 수: 1
Ahmer Shahid
Ahmer Shahid 2018년 11월 1일
This Error showing up there.......
Error using imageDisplayValidateParams Expected input number 1, I, to be one of these types:
numeric, logical
Instead its type was videoinput.
Error in images.internal.imageDisplayValidateParams (line 11) validateattributes(common_args.CData, {'numeric','logical'},...
Error in images.internal.imageDisplayParseInputs (line 78) common_args = images.internal.imageDisplayValidateParams(common_args);
Error in imshow (line 245) images.internal.imageDisplayParseInputs({'Parent','Border','Reduce'},preparsed_varargin{:});

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

채택된 답변

Astarag Chattopadhyay
Astarag Chattopadhyay 2018년 11월 20일
편집: Astarag Chattopadhyay 2018년 11월 23일
Hi Ahmer,
You do not need to use "videoinput" object you can use "webcam" object.
In your app define two properties like this:
properties (Access = private)
webcamObject;
imageObject;
end
You can define the startup function using the following code snippet:
function startupFcn(app)
app.webcamObject = webcam;
app.imageObject = image(app.UIAxes);
axis(app.UIAxes,'ij')
res = split(app.webcamObject.Resolution,'x');
app.UIAxes.XLim = [0,str2double(res{1})];
app.UIAxes.YLim = [0,str2double(res{2})];
app.webcamObject.preview(app.imageObject);
end
This will setup the UIAxis with the resolution of the webcam object and start the preview.
  댓글 수: 4
Astarag Chattopadhyay
Astarag Chattopadhyay 2018년 12월 4일
Which version of MATLAB you are working on?
If you want to take a snapshot you can add a snapshot button to the app and add a callback to the button where you may use the function "snapshot".
Ahmer Shahid
Ahmer Shahid 2018년 12월 4일
I'm using Matlab R2018a, I'm already working on that but when I use snapshot or getsnapshot then it give me error that snapshot is invalid function for webcam.
I can use snapshot function for videoinput but I cannot get the live streaming on axis while using videoinput.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by