Image acquisition, frame rgb2gray conversion
Show older comments
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.
Accepted Answer
More Answers (0)
Categories
Find more on Image Data Acquisition in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!