Recently I use image acquistion toolbox, the image captured is very gloomy

1 vue (au cours des 30 derniers jours)
Recently I use image acquistion toolbox, the image captured is very gloomy, but the image in preview figure is clear bright.
% This is copyed from Image acquistion toolbox
vid = videoinput('winvideo', 1, 'I420_640x480');
src = getselectedsource(vid);
% Set video input object properties for this application.
vid.FrameGrabInterval = 1;
% Set value of a video source object property.
vid_src = getselectedsource(vid);
set(vid_src,'Tag','motion detection setup');
% Create a figure window.
% Start acquiring frames.
% display it.
while(vid.FramesAcquired<=100) % Stop after 100 frames
frame = getsnapshot(vid);
imshow(frame); %%This is used to show the snapshot, very gloomy

Réponse acceptée

David Tarkowski
David Tarkowski le 5 Déc 2012
You're trying to display an image in the YCbCr color space (that's what the I420 in your videoinput line means) with a function that is expecting RGB data.
If you do:
vid = videoinput('winvideo', 1, 'I420_640x480');
vid.ReturnedColorSpace = 'RGB';
then the toolbox will convert the data to RGB data when you call getsnapshot or getdata. If you actually want the YCbCr data you can omit changing the ReturnedColorSpace property and instead convert the data before displaying it:
frame = getsnapshot(vid);

Plus de réponses (0)


En savoir plus sur Image Preview and Device Configuration dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by