Videoinput function and bad quality image

Hi,
I am trying to use a usb microscope camera to take a series of photos of my samples. I use 'videoinput' and 'getsnapshot' to drive the camera and it takes a photo every few minute for a few hours. Some of the images taken by the camera are of good quality (see image 1 below) while some are of bad qualities with regions of over- and under-exposure. The occurance of bad images is around 1 in 3 but the frequency can vary. I want to know (1) if this is a common problem when using usb camera, (2) whether this is a hardware or software issue, (3) if it's possible to reduce its occurance by adjusting certain parameters in the camera setting.
I am attaching sections of my code at the end. Many thanks in advance!
good quality image
bad quality image
bad quality image
clear
close all
clc
info = imaqhwinfo('winvideo')
for n = 1:100
vid = videoinput('winvideo',2,'YUY2_640x480');
set(vid,'ReturnedColorSpace','rgb');% convert from yuy2 to rgb
vid.FrameGrabInterval = 1; % time interval between captured frames
preview(vid)
start(vid)
I=getsnapshot(vid);
figure(1);
clf
newmap = rgb2gray(I);
imshow(newmap)
objects = imaqfind ;
delete(objects) ;
end

Respuestas (0)

Productos

Versión

R2017a

Preguntada:

YZ
el 2 de Sept. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by