updating handles in gui/guide for webcam

조회 수: 1 (최근 30일)
Christian Buchgeher
Christian Buchgeher 2016년 12월 12일
댓글: Christian Buchgeher 2016년 12월 12일
hi
I am trying to create a GUI where a user can select between the different webcams attached to the pc. Using the preview function u can see the live data form the webcam.
My problem is switching between webcams. I stored the webcam in handles.cam and I don't know how to update it to the new webcaminformation. usesing delete doesn't work(since it makes handles.cam invalid).
closePreview(handles.cam);
selectedcamera=cellstr(get(hObject,'String'));
selectedcamera=selectedcamera{get(hObject,'Value')};
selectedcamera = strtrim(selectedcamera);
selectedcamera=char(selectedcamera);
handles.cam=webcam(selectedcamera);
Preview_Open(handles);

답변 (1개)

Mischa Kim
Mischa Kim 2016년 12월 12일
Christian, I solved a similar problem by removing the associated field of the handles object.
So essentially (and following your approach), you would close the preview and remove the webcam object. After that you can pick another webcam and create the object.
closePreview(handles.wc);
handles = rmfield(handles,'wc');
...
handles.wc = webcam;
  댓글 수: 3
Mischa Kim
Mischa Kim 2016년 12월 12일
Check out the attached app.
Christian Buchgeher
Christian Buchgeher 2016년 12월 12일
It does close the handles.cam but somehow the webcam still stays active. and it does open the new webcam for a glimpse of a second.
I have the preview window in an axces field .
and different sliders to change the properties of the webcam.
i also attached my code files.

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

카테고리

Help CenterFile Exchange에서 App Building에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by