updating handles in gui/guide for webcam
Show older comments
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);
Answers (1)
Mischa Kim
on 12 Dec 2016
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 Comments
Christian Buchgeher
on 12 Dec 2016
Mischa Kim
on 12 Dec 2016
Check out the attached app.
Christian Buchgeher
on 12 Dec 2016
Categories
Find more on MATLAB Support Package for USB Webcams in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!