フィルターのクリア

How to run webcam on an axis in app designer ?

17 ビュー (過去 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 Center および File ExchangeDevelop 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