MATLAB: Do some of the images appear dark or distorted when I use the Image Acquisition Toolbox

Image Acquisition Toolbox

My image appears dark or completely black when I use the GETSNAPSHOT function. Sometimes, the first couple of images are distorted when I acquire data using the Image Acquisition Toolbox.

Best Answer

This is likely a limitation of your hardware. The first few frames that some hardware devices provide (especially for consumer level devices like webcams and video cards) may be of low image quality.
This hardware device behavior may cause the first couple of image frames to appear as:
- a noisy image,
- a very dark / black image; or
- an image with distorted colors
This artifact can be a result of the imaging sensor not having warmed up yet, or the device having just been started.
To work around this, you have the following options:
1. If you wish to use GETSNAPSHOT, keep the preview window running. This avoids having to start up the device and maintains an active image stream.
2. Use the TriggerFrameDelay property before initiating an acquisition with START. TriggerFrameDelay indicates the number of frames to skip after the device is triggered. For example:
% Number of image frames to acquire.
N = 10;
% Access the device.
vid = videoinput('winvideo');
% Skip the first few frames after the
% device is triggered.
set(vid, 'TriggerFrameDelay', 3);
% Configure the number of frames to acquire.
set(vid, 'FramesPerTrigger', N);
% Start the acquisition and have it trigger
% immediately. Then access the data.
triggerconfig(vid, 'Immediate');
start(vid)
data = getdata(vid);