Image acquisition, frame rgb2gray conversion
Mostrar comentarios más antiguos
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.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Image Data Acquisition en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!