Re: Interfacing Camera to Matlab
- From: Dave Tarkowski <dtarkows@xxxxxxxxxxxxx>
- Date: Mon, 25 Aug 2008 09:33:24 -0400
Kushagra Garg wrote:
I tried to interface Gemini usb 2.0 webcam to matlab using following commands--
cam=videoinput('winvideo')
It gives the following output.
Summary of Video Input Object Using 'USB2.0 Web Camera'.
Acquisition Source(s): input1 is available.
Acquisition Parameters: 'input1' is the current selected source.
10 frames per trigger using the selected source.
'RGB24_640x480' video data to be logged upon START.
Grabbing first of every 1 frame(s).
Log data to 'memory' on trigger.
Trigger Parameters: 1 'immediate' trigger(s) on START.
Status: Waiting for START.
0 frames acquired since starting.
0 frames available for GETDATA.
start(cam);
preview(cam);
Till this point it works fine.
frame=getsnapshot(cam);
imshow(frame);
The image shown is completely black.The array frame has all RGB values 0.
Is the preview window open when you call getsnapshot?
Some cameras, notably web cams, start out with black frames. It takes the automatic gain control a couple frames to adjust and give you a proper image. This is most likely happening when you start the video preview, but since it only last a few frames, you don't really notice it.
If the preview window is closed when you call getsnapshot, the camera is not acquiring data therefore the automatic gain control isn't working. Since it takes a few frames to get good images back, you'll always get black images that way. However, there a few workarounds. One, you can leave the preview window open while calling getsnapshot. This leaves the camera active, and you should get valid images back.
If you don't want to have the preview window open, you can use the manual triggering mode of the toolbox. Try this:
>> triggerconfig(cam, 'manual');
>> start(cam);
>> pause(.5); % Wait for the camera to adjust the AGC
>> frame = getsnapshot(cam);
>> stop(cam);
You can see http://www.mathworks.com/products/imaq/demos.html?file=/products/demos/shipping/imaq/demoimaq_Getsnapshot.html for more information on using manual triggering and getsnapshot.
-Dave
.
- References:
- Interfacing Camera to Matlab
- From: Kushagra Garg
- Interfacing Camera to Matlab
- Prev by Date: Re: Simulink Problem
- Next by Date: Re: problem with phase of complex number
- Previous by thread: Interfacing Camera to Matlab
- Next by thread: Re: Interfacing Camera to Matlab
- Index(es):
Relevant Pages
|