-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFeatureVector.m
More file actions
146 lines (114 loc) · 4.92 KB
/
Copy pathFeatureVector.m
File metadata and controls
146 lines (114 loc) · 4.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
%% Importing files
%clear all;
%% Glob file function
imageFile = dir( 'data/image/*.txt') ;
storageDir = 'results/';
noOfFiles = size(imageFile,1);
worldpoints = load('WorldPoints3D.txt');
%%
%% Setting values
nbrPoints = 7; % How many neighbours to consider
gain = 100; % How much gain to be given to distances
% Matching theshold for 2 values
maxMatchingThreshold = ( gain * 0.10 ); % 5% of the gain
% Voting required to select a match
fvSize = (nbrPoints*(nbrPoints - 1));
%maxVote = round( fvSize * 0.80 ); % 80% of the max possible feature vector size
% Voting scheme 2
maxVote = round( ( (fvSize/2) * 0.80 ) ); % 80% of the max possible feature vector size
%% Begin
disp(' New Experiment');
disp(' Neighbour Points Selected');disp(nbrPoints);
disp(' gain = '); disp(gain);
disp(' Matching Threshold ='); disp(maxMatchingThreshold);
disp(' fvSize = ');disp(fvSize);
disp(' Max Initial voting = %d ');disp(maxVote);
%%
%% Creating feature vectors for world points
disp('No of world points'); disp(size(worldpoints,1));
[fvecWorld indexMappingWorld] = createFeatureVec(worldpoints,nbrPoints);
writeToFile('results\fvecWorld.txt',fvecWorld,gain);
writeMappingToFile ( 'results\MappingIndicesWorld.txt ', indexMappingWorld);
%%
%% Operation
for fileIter = 1 : noOfFiles
% Get the file names iteratively
fileName = imageFile(fileIter).name;
% load file from the right path
image = load(strcat('data/image/',fileName) );
[fvecImage indexMappingImage] = createFeatureVec(image,nbrPoints);
matchedPair = findMatch(fvecWorld,fvecImage,gain,maxMatchingThreshold,maxVote,nbrPoints);
fvecFile = strcat(storageDir,'fvec',fileName);
mappingFile = strcat(storageDir,'MappingIndices',fileName);
matchPairFile = strcat(storageDir,'MatchPair',fileName);
writeToFile(fvecFile,fvecImage,gain);
writeMappingToFile ( mappingFile, indexMappingImage);
writeMatchingHypothesisToFile(matchPairFile,matchedPair);
disp(fileName); disp(size(image,1));
disp('No of possible match'); disp(size(matchedPair,1));
goodPair = successCheck(matchedPair)
end
%
%
%
% %%
%
% %% Creating feature vectors for Image points
%
% %%Data for image 1
% disp('No of Image 1 points'); disp(size(image1,1));
% [fvecImage1 indexMappingImage1] = createFeatureVec(image1,nbrPoints);
% matchedPair1 = findMatch(fvecWorld,fvecImage1,gain,maxMatchingThreshold,maxVote,nbrPoints);
% disp('No of possible match'); disp(size(matchedPair1,1));
%
% writeToFile('results\fvecImg1.txt',fvecImage1,gain);
% writeMappingToFile ( 'results\MappingIndicesImage1.txt ', indexMappingImage1);
% writeMatchingHypothesisToFile('results\matchedPair1.txt',matchedPair1);
% %%
%
% %% Data for image 12
% disp('No of Image 12 points'); disp(size(image12,1));
% [fvecImage12 indexMappingImage12]= createFeatureVec(image12,nbrPoints);
% matchedPair12 = findMatch(fvecWorld,fvecImage12,gain,maxMatchingThreshold,maxVote,nbrPoints);
% disp('No of possible match'); disp(size(matchedPair12,1));
%
% writeToFile('results\fvecImg12.txt',fvecImage12,gain);
% writeMappingToFile ( 'results\MappingIndicesImage12.txt ', indexMappingImage12);
% writeMatchingHypothesisToFile('results\matchedPair12.txt',matchedPair12);
% %%
%
%
% %% Data for image 8
% disp('No of Image 8 points'); disp(size(image8,1));
% [fvecImage8 indexMappingImage8]= createFeatureVec(image8,nbrPoints);
% matchedPair8 = findMatch(fvecWorld,fvecImage8,gain,maxMatchingThreshold,maxVote,nbrPoints);
% disp('No of possible match'); disp(size(matchedPair8,1));
%
% writeToFile('results\fvecImg8.txt',fvecImage8,gain);
% writeMappingToFile ( 'results\MappingIndicesImage8.txt ', indexMappingImage8);
% writeMatchingHypothesisToFile('results\matchedPair8.txt',matchedPair8);
% %%
%
% %% Data for image 4
% disp('No of Image 4 points'); disp(size(image4,1));
% [fvecImage4 indexMappingImage4]= createFeatureVec(image4,nbrPoints);
% matchedPair4 = findMatch(fvecWorld,fvecImage4,gain,maxMatchingThreshold,maxVote,nbrPoints);
% disp('No of possible match'); disp(size(matchedPair4,1));
%
% writeToFile('results\fvecImg4.txt',fvecImage4,gain);
% writeMappingToFile ( 'results\MappingIndicesImage4.txt ', indexMappingImage4);
% writeMatchingHypothesisToFile('results\matchedPair4.txt',matchedPair4);
% %%
%
% trueMatch1 = successCheck(matchedPair1)
% trueMatch12 = successCheck(matchedPair12)
% trueMatch8 = successCheck(matchedPair8)
% trueMatch4 = successCheck(matchedPair4)
%% Image based matching
% matchedImagePair1n12 = findMatch(fvecImage1,fvecImage12,gain,maxMatchingThreshold,maxVote,nbrPoints);
% matchedImagePair1n8 = findMatch(fvecImage1,fvecImage8,gain,maxMatchingThreshold,maxVote,nbrPoints);
% matchedImagePair12n8 = findMatch(fvecImage12,fvecImage8,gain,maxMatchingThreshold,maxVote,nbrPoints);
% trueImgPairMatch1n12 = successCheck(matchedImagePair1n12)
% trueImgPairMatch1n8 = successCheck(matchedImagePair1n8)
% trueImgPairMatch12n8 = successCheck(matchedImagePair12n8)
%%