How can I use the same webcam for displaying video on a gui and a function that is run with the gui. I get a error saying winvideo: The device associated with device ID 1 is already in use. A new videoinput object cannot be created ....while in use
2 ビュー (過去 30 日間)
古いコメントを表示
I am making a GUI and I want to display a live video on my GUI with the same webcam i use for collecting data for a function that i run with the GUI. My function uses the webcam to take a snap shot and than calculates a value that is used later in the function. I think i know whats going on but i don't know how to fix it or even if i can. I need to make something global right...but what and where. THANKS IN ADVANCE and here is the error i get.
winvideo: The device associated with device ID 1 is already in use. A new videoinput object cannot be created for this device while it is in use.
0 件のコメント
回答 (2 件)
David Sanchez
2014 年 6 月 26 日
Before you create the video object using videoinput function:
obj = videoinput('winvideo',1); % or something similar, I guess
declare it as global:
global obj
obj = videoinput('winvideo',1); % or something similar, I guess
Then, declare the global variable within your function, and then, use the variable, for example, taking an image.
function your_fun(inputvars)
global obj
frame = getsnapshot(obj);
I never did it, but I think it could work
Chaitra
2014 年 6 月 26 日
As you have indicated in your code:
videoinput('winvideo', 1, 'YUY2_640x480');
A new video input object is being created on the same device. This object is already created as you are accessing it via GUI. I would suggest you to use the same object handle to perform further operations.
Instead of using custom GUI, you can use Imaqtool GUI that is shipped with MATLAB.
>>imaqtool
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!