Image acquisition, frame rgb2gray conversion
Afficher commentaires plus anciens
I am using image acquisition toolbox to capture a frame from the video output of my wireless usb camera. I get an error when i perform rgb2gray conversion for the captured frame.
CODE:
clear ;
close all;
vid = videoinput('winvideo', 1, 'YUY2_720x480');
vid.Timeout = 20;
set(vid, 'FrameGrabInterval', 2);
set(vid, 'FramesPerTrigger', 50);
src = getselectedsource(vid);
set(src, 'FrameRate', '30');
vid.ReturnedColorspace = 'rgb';
preview(vid);
start(vid);
pause(2);
%frame = getsnapshot(vid);
frames = getdata(vid);
delete(vid)
clear vid
imshow( frames(:, :, :, 1) );
Scolor = frames;
Sgray = rgb2gray(Scolor);
ERROR: RGB2GRAY only accepts a Mx3 matrix for MAP or a MxNx3 input for RGB.
Please help me to correct the code, also i want to know what is the function used to save the frame in .jpg format, in the current working directory.Thank you.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Image Data Acquisition dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!