I am using matlab for capturing image using a webcam(company-Labtec) whenever i get a snapshot the image appears Red.How should i overcome this problem?
Also how can I increase the shuter exposore time of the webcam?
OS-Windows XP

3 件のコメント

manali jangam
manali jangam 2016 年 12 月 5 日
when the snapshot of images is recorded...its not showing its file format..how should we get that..????
Mohan Kant
Mohan Kant 2017 年 3 月 12 日
the same problem with me please solve that problem
Chaitanya Panse
Chaitanya Panse 2018 年 5 月 27 日
編集済み: Chaitanya Panse 2018 年 5 月 27 日
The problem with my GUI is that whenever i connect an external webcam and run in GUI the axis becomes very small that it is hardly seen. How do i overcome this problem? Please help.

サインインしてコメントする。

 採用された回答

David Tarkowski
David Tarkowski 2011 年 4 月 20 日

2 投票

I'm going to guess that the problem is the color space that your camera returns data in is not RGB. This is common for a lot of 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)

9 件のコメント

Prateek
Prateek 2011 年 5 月 4 日
Thanks Boss.your solution did work.
prateek chaturvedi
prateek chaturvedi 2012 年 3 月 19 日
i even tried it out didnot work
antriksh saxena
antriksh saxena 2014 年 3 月 4 日
thank you this solution work
Image Analyst
Image Analyst 2014 年 7 月 7 日
編集済み: Image Analyst 2014 年 7 月 7 日
Alternatively, without using the Image Acquisition Toolbox, you might get by with the webcam tool : http://www.mathworks.com/support/2014a/matlab/8.3/demos/webcam-support.html
mark
mark 2014 年 11 月 2 日
thankyou :) it is working
Mohan Kant
Mohan Kant 2017 年 4 月 12 日
Thank you its working
kunal m
kunal m 2017 年 8 月 1 日
its is not working error occur it show A timeout occurred during GETSNAPSHOT can u please help me in fixing that error
Image Analyst
Image Analyst 2017 年 8 月 1 日
Try this:
>> ver
>> which getsnapshot
What does it say? You probably don't have the Image Acquisition Toolbox installed.
Ritika
Ritika 2018 年 2 月 3 日
How to save the snapshots during recording...can u Please help me for this

サインインしてコメントする。

その他の回答 (5 件)

Mark Jones
Mark Jones 2011 年 4 月 25 日
編集済み: John Kelly 2013 年 11 月 13 日

0 投票

Alternatively, it may be that your camera needs to warm up. To allow for this, try using manual triggering and GETSNAPSHOT.
Ian
Ian 2014 年 7 月 7 日

0 投票

I got this to work, but is there a way to then read that image? Like to call it back so matlab can analyze it?

6 件のコメント

Image Analyst
Image Analyst 2014 年 7 月 7 日
What did you do? Did you call getsnapshot()? Did you call imwrite() or imread()? How can we discover what you did to say that it both worked but you don't have the image yet? Show your code.
Ian
Ian 2014 年 7 月 7 日
camlist=webcamlist; cam = webcam(1); preview(cam); img=snapshot(cam); orignalimage=imread(img);
and then this error comes up:
Error using imread>parse_inputs (line 457) The filename or url argument must be a string.
Error in imread (line 316) [filename, fmt_s, extraArgs] = parse_inputs(varargin{:});
Ian
Ian 2014 年 7 月 7 日
I get the image, but now I want to use that image to get other data, but I can't seem to read the image
Anchit Dhar
Anchit Dhar 2014 年 7 月 9 日
The SNAPSHOT command returns the RGB image. The "img" variable is your image. A call to IMREAD is not required.
Ian
Ian 2014 年 7 月 10 日
Ahhh thank you very much! I have gotten the code to work now.
Antonio Meza
Antonio Meza 2015 年 11 月 5 日
Thank you!! it works. Finally, i can finish my project. Greetengs from Mexico

サインインしてコメントする。

finalyear project
finalyear project 2016 年 10 月 21 日

0 投票

Tried to take an image using webcam by following code
vid = videoinput('winvideo', 3);
set(vid, 'ReturnedColorSpace', 'RGB');
img = getsnapshot(vid);
imshow(img)
but still got black image.Can anybody please suggest something?

1 件のコメント

Syed Aameer
Syed Aameer 2017 年 2 月 1 日
attach this code above to to your code axes(handles.axes1);
hImage=image(zeros(80,120,3),'Parent',handles.axes1); preview(vid,hImage);

サインインしてコメントする。

mohamed hushan
mohamed hushan 2017 年 10 月 5 日
編集済み: Walter Roberson 2020 年 5 月 16 日

0 投票

vid = videoinput('winvideo', 1);
set(vid, 'ReturnedColorSpace', 'RGB');
img = getsnapshot(vid); imshow(img)
after that how to save the snap images into folder?
Shrey Garg
Shrey Garg 2020 年 5 月 16 日

0 投票

webcam not working in matlab
it opensup logitech webcam nut it doesnot works and displays message that application already opened

質問済み:

2011 年 4 月 16 日

編集済み:

2020 年 5 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by