フィルターのクリア

how to read an imagecaptured by webcam

2 ビュー (過去 30 日間)
venus tyagi
venus tyagi 2019 年 3 月 31 日
コメント済み: Cris LaPierre 2019 年 4 月 1 日
%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?

回答 (1 件)

Cris LaPierre
Cris LaPierre 2019 年 4 月 1 日
編集済み: Cris LaPierre 2019 年 4 月 1 日
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 件のコメント
venus tyagi
venus tyagi 2019 年 4 月 1 日
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 2019 年 4 月 1 日
Please share the entire error message. Would be nice to also include a sample image that produces this error.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMicroscopy についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by