I want to detect features of image 16 into rest 15 images..?
Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
Ältere Kommentare anzeigen
clc ; % clearing the command window
n = 15;
intervel = 1;
photosave = 'y';
disp('Please wait...');
outputFolder = fullfile(cd);
if ~exist(outputFolder, 'dir')
mkdir(outputFolder);
end
a = imaqhwinfo;
[camera_name, camera_id, format] = getCameraInfo(a);
obj = videoinput(camera_name, camera_id, format);
set(obj, 'FramesPerTrigger', Inf);
set(obj, 'ReturnedColorspace', 'rgb')
vid.FrameGrabInterval = 5;
start(obj)
%obj = videoinput('winvideo',1);
preview(obj);
for i=1:n
img=getsnapshot(obj);
image(img);
if(photosave == 'y')
outputBaseFileName = sprintf('%d.jpg',i);
outputFullFileName = fullfile(outputFolder, outputBaseFileName);
imwrite(img,outputFullFileName,'jpg');
end
pause(intervel);
d = dir('*.jpg');
n = length(d);
for imageNumber = 1:(n+0)
myFunction(imageNumber)
end
end
closepreview;
stop(obj)
disp('The program successfully taken the photos');
disp('Done.');
function [] = myFunction(imageNumber)
I2 = imread(sprintf('%d.jpg',imageNumber));
I2 = I2(:,:,3);
I1 = imread('16.jpg');
I1 = I1(:,:,3);
points1 = detectHarrisFeatures(I1);
points2 = detectHarrisFeatures(I2);
[features1, valid_points1] = extractFeatures(I1, points1);
[features2, valid_points2] = extractFeatures(I2, points2);
[features1, valid_points1] = extractFeatures(I1, points1);
[features2, valid_points2] = extractFeatures(I2, points2);
indexPairs = matchFeatures(features1,features2)
matched_points1 = valid_points1(indexPairs(:,1),:);
matched_points2 = valid_points2(indexPairs(:,2),:);
figure; showMatchedFeatures(I1, I2, matched_points1, matched_points2);
I have written a code to detect features of image 16 into remaining 15 images.! But i am getting a following error.
Undefined function or variable "indexPairs".
Error in myFunction (line 13)
matched_points1 = valid_points1(indexPairs(:,1),:);
Error in TrialProg (line 32)
myFunction(imageNumber)
I am using Matlab R2013a
How to solve an error..?
Antworten (2)
Image Analyst
am 18 Mär. 2015
0 Stimmen
Well, what values did you think indexPairs would have? You never assigned any values to it before you tried to use it, so it won't have any.
4 Kommentare
Nimisha
am 19 Mär. 2015
Image Analyst
am 19 Mär. 2015
That's not how I use getsnapshot(). I do things like this:
vidobj = videoinput('lumeneraimaqW32', 1, highestResFormat);
% Snap picture from camera.
snappedImage = getsnapshot(vidobj); % This works.
You might want to call tech support.
Nimisha
am 22 Mär. 2015
Image Analyst
am 22 Mär. 2015
I never heard of it.
Dima Lisin
am 18 Mär. 2015
0 Stimmen
Hi Nimisha,
indexPairs should be the output of the matchFeatures function.
2 Kommentare
Nimisha
am 19 Mär. 2015
Dima Lisin
am 19 Mär. 2015
Is it the error about the memory for the incoming frame? Are you running on 32-bit windows? How big is your video frame?
There are several things you can do:
- Use a 64-bit machine
- Make sure that the frame data type is set to uint8
- Set the camera to use lower resolution
Diese Frage ist geschlossen.
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!