capture a image using matlab
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
i am trying to capture image in matlab using following commands:
cam=videoinput('winvideo',2,'USB2.0 PC CAM')
preview(cam)
start(cam)
frame=getsnapshot(cam);
imshow(frame);
But it shows error: ??? Error using ==> videoinput.videoinput at 329 Device files are not supported by this device. See IMAQHWINFO.
Error in ==> webcam at 2
cam=videoinput('winvideo',2,'USB2.0 PC CAM')
---- using command imaqhinfo('winvideo',2) returns:
ans =
DefaultFormat: 'YUY2_1280x1024'
DeviceFileSupported: 0
DeviceName: 'USB2.0 PC CAMERA'
DeviceID: 2
ObjectConstructor: 'videoinput('winvideo', 2)'
SupportedFormats: {1x7 cell}
which confirms the device name and deviceID ---
then i tried a different set of codes:
if(~isdeployed)
cd(fileparts(which(mfilename)));
end
clc;
clear;
close all;
imtool close all;
workspace;
fontSize = 36;
vid = videoinput('winvideo',2,'USB2.0 PC CAMERA');
vid.FramesPerTrigger = 1;
preview(vid);
start(vid);
rgbImage = getdata(vid);
subplot(1,2, 1);
imshow(rgbImage);
title('Initial Image', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'Position', get(0,'Screensize'));
% Save this image to disk.
fullImageFileName = fullfile(pwd, 'myfirstimage.jpg');
imwrite(rgbImage,fullImageFileName);
% Read it back in to check it.
recalledImage = imread(fullImageFileName);
subplot(1,2, 2);
imshow(recalledImage);
title('Recalled Image', 'FontSize', fontSize);
But again, there is same error message ----
please help me to solve the issue
thanks in advance
1 Kommentar
Kamal Abuqaaud
am 7 Sep. 2017
Try removing this part from your code "2,'USB2.0 PC CAM'" for videoinput command.
Antworten (1)
Image Analyst
am 7 Okt. 2013
I think the "device format" should be 'YUY2_1280x1024'. The problem is probably that you put in the "Device Name" instead of the "Device Format" for the third argument to videoinput().
vid = videoinput('winvideo', 2, 'YUY2_1280x1024');
If that doesn't work, then can you operate the camera from within imaqtool? If so, what does the session log say? You should be able to copy and paste the session log into your m-file to do the same thing.
0 Kommentare
Siehe auch
Kategorien
Mehr zu National Instruments Frame Grabbers finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!