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!