Effacer les filtres
Effacer les filtres

how to read an imagecaptured by webcam

2 vues (au cours des 30 derniers jours)
venus tyagi
venus tyagi le 31 Mar 2019
Commenté : Cris LaPierre le 1 Avr 2019
%webcamlist
cam = webcam('Integrated Webcam');
preview(cam);
closePreview(cam)
img = snapshot(cam);
imshow(img)
%image(img)
clear('cam');
I = imread(img);
srcFiles1 = dir('C:\b\*.bmp');
for j = 1 : length(srcFiles1)
filename1 = strcat('C:\b\',srcFiles1(j).name);
I2 = imread(filename1);
points = detectSURFFeatures(I);
length(points)
points2 = detectSURFFeatures(I2);
length(points2)
[features1, validPoints1] = extractFeatures(I, points);
[features2, validPoints2] = extractFeatures(I2, points2);
indexPairs = matchFeatures(features1, features2);
matchedPoints1 = validPoints1(indexPairs(:, 1), :);
matchedPoints2 = validPoints2(indexPairs(:, 2), :);
showMatchedFeatures(I, I2, matchedPoints1, matchedPoints2, 'montage');
figure;
end
%end
output:
Error using imread>parse_inputs (line 450)
The file name or URL argument must be a character vector.
Error in imread (line 322)
[filename, fmt_s, extraArgs, was_cached_fmt_used] = parse_inputs(cached_fmt, varargin{:});
Error in acquire (line 13)
[X, map] = imread(img);
Error using imread>parse_inputs (line 450)
The file name or URL argument must be a character vector.
Error in imread (line 322)
[filename, fmt_s, extraArgs, was_cached_fmt_used] = parse_inputs(cached_fmt, varargin{:});
Error in acquire (line 13)
[X, map] = imread(img);
i have captured an image using webcam and then am trying to compare this image with the images in the database.why is matlab unable to read image file?

Réponses (1)

Cris LaPierre
Cris LaPierre le 1 Avr 2019
Modifié(e) : Cris LaPierre le 1 Avr 2019
I think the issue here is that img is not a file, but a matrix of pixel values already. You therefore don't need to use imread to read it. It's already been 'read' in.
Try just using I=img;
  2 commentaires
venus tyagi
venus tyagi le 1 Avr 2019
It is working now.But the images have to be converted to gray format.the following error is coming when the acquired and the compared image are converted to gray.
Error in acquire (line 20)
I2 = rgb2gray(imread(filename1));
Cris LaPierre
Cris LaPierre le 1 Avr 2019
Please share the entire error message. Would be nice to also include a sample image that produces this error.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Microscopy dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by