필터 지우기
필터 지우기

how to read an imagecaptured by webcam

조회 수: 4 (최근 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 CenterFile Exchange에서 Microscopy에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by