Image acquisition, frame rgb2gray conversion
古いコメントを表示
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.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Image Data Acquisition についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!