필터 지우기
필터 지우기

Warning: Unable to set the selected source. Perhaps the device is in use.

조회 수: 1 (최근 30일)
Hi,
I am trying to display an image captured from my webcam. I am using matlab version 8.1.0.604 (R2013a) on Ubuntu 12.04.
Here is my very simple code:
imaqhwinfo
cam1=imaqhwinfo('linuxvideo',1);
vid1=videoinput('linuxvideo',1);
% cam1.SupportedFormats
preview(vid1);
which produces this error:
InstalledAdaptors: {'dcam' 'gentl' 'gige' 'linuxvideo'}
MATLABVersion: '8.1 (R2013a)'
ToolboxName: 'Image Acquisition Toolbox'
ToolboxVersion: '4.5 (R2013a)'
Warning: Unable to set the selected source. Perhaps the device is
in use.
Error using imaqdevice/preview (line 177)
Could not connect to the image acquisition device. Device may be
in use.
Error in main (line 58)
preview(vid1);
My webcam is a Logitech C270, which works fine with other applications eg. Skype.
Any help in understanding the cause of this error would be greatly appreciated!
Thanks,
Mark

채택된 답변

Mark
Mark 2013년 7월 30일
I'm afraid the solution was quite simple, I changed the camera to a different USB socket and I can now capture images fine. Thanks for reading and thanks Ravi for trying.
Mark

추가 답변 (1개)

Ravi
Ravi 2013년 7월 29일
Color space that your camera returns data in is not RGB i think so. This is a common issue for many webcams. The commands commonly used to display images such as image or imshow expect RGB data. If you pass in YCbCr (or YUV) data, the result is an image that looks vaguely correct but has a pink and green hue to it.
There are a number of ways to work around this, but in your case, I suspect that the easiest will be to change the ReturnedColorSpace property of the videoinput object:
vid = videoinput('winvideo', 1); set(vid, 'ReturnedColorSpace', 'RGB'); img = getsnapshot(vid); imshow(img)
  댓글 수: 1
Walter Roberson
Walter Roberson 2013년 7월 29일
Colorspace is a good point, but unfortunately Mark is not able to connect to the camera to get any data back at all.

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

Community Treasure Hunt

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

Start Hunting!

Translated by