image becomes dark wen capturing using webcam

3 views (last 30 days)
FIR
FIR on 21 Mar 2014
Edited: FIR on 21 Mar 2014
I have following code to take photo from a external cam
vid1 = videoinput('winvideo',1,'YUY2_320x240')
% vid2 = videoinput('winvideo',2,'YUY2_320x240')
% Set video input object properties for this application.
set(vid1,'TriggerRepeat',Inf);
% set(vid2,'TriggerRepeat',Inf);
vid1.FrameGrabInterval = 1;
% vid2.FrameGrabInterval = 1;
set(vid1,'ReturnedColorSpace','rgb');
% set(vid2,'ReturnedColorSpace','rgb');
set(vid1,'FramesPerTrigger', 1000);
% set(vid2,'FramesPerTrigger', 1000);
temp1=zeros(240,320,3);
temp2=zeros(240,320,3);
% Create a figure window.
h1=imshow(uint8(temp1));
h2=imshow(uint8(temp2));
pause(0.01)
hold on;
'---------'
% Start acquiring frames.
start(vid1)
% start(vid2)
% while(vid1.FramesAcquired<=10) % Stop after 100 frames
tic
data1 = getdata(vid1,1);
imshow(data1)
% data2 = getdata(vid2,1);
% set(h1,'Cdata',data1);
% set(h2,'Cdata',data2);
flushdata(vid1);
% flushdata(vid2);
toc
% end
stop(vid1)
% stop(vid2)
delete(vid1)
wen i capture the image becomes dark in colour like black ,but wen i use preview(vid),the image is clear but wen captured it becomes very dark like black in colour,kindly help

Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by