Re: Interfacing Camera to Matlab



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

.



Relevant Pages

  • Re: Let me ask my question a different way...
    ... you will be losing frames or mixing data from ... The expensive webcams compress the images for you. ... I assume that you want a computer controlled digital camera, ...
    (comp.arch.embedded)
  • Re: Tablet/phone cameras
    ... Wide focus is used in cheap forward-facing lenses (for capturing your ... you would be looking in the same direction that the camera ... the main LCD at several frames per second. ... capture the images required. ...
    (comp.arch.embedded)
  • Need help: Amber Galileo IR camera (radience HS)
    ... I am working with a fairly nice IR camera. ... I need to configure it to acquire images in sync with an external ... the trigger. ... that I don't have any software or documentation for such a command. ...
    (sci.image.processing)
  • Panasonic internet cameraBL-C131 "Image Buffer Frequency" - what does that mean?
    ... camera you can trigger the camera to take pics before and after the ... Enable Pre-trigger Image Buffer ... Every N seconds, buffer B images, Total T images. ...
    (alt.internet.wireless)
  • Mars Exploration Rovers Update - August 4, 2006
    ... SPIRIT UPDATE: Spirit Completes Camera Check-Up, ... pairs of images, each pair taken during a different exposure time. ... calibrating variations in the field of light in the McMurdo panorama. ...
    (sci.space.news)