forked from abhn/marvel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDMatch
More file actions
59 lines (51 loc) · 1.87 KB
/
DMatch
File metadata and controls
59 lines (51 loc) · 1.87 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
public class DMatch {
// Member variables
private int queryIdx; // Query descriptor index
private int trainIdx; // Train descriptor index
private int imgIdx; // Train image index
private float distance; // Distance between descriptors
// Default constructor initializing to default values
public DMatch() {
this.queryIdx = -1;
this.trainIdx = -1;
this.imgIdx = -1;
this.distance = Float.MAX_VALUE;
}
// Constructor with query and train indices and distance
public DMatch(int queryIdx, int trainIdx, float distance) {
this.queryIdx = queryIdx;
this.trainIdx = trainIdx;
this.imgIdx = -1;
this.distance = distance;
}
// Constructor with query and train indices, image index, and distance
public DMatch(int queryIdx, int trainIdx, int imgIdx, float distance) {
this.queryIdx = queryIdx;
this.trainIdx = trainIdx;
this.imgIdx = imgIdx;
this.distance = distance;
}
// Method to compare this DMatch with another DMatch
public boolean isLessThan(DMatch other) {
return this.distance < other.distance;
}
// Method to print the DMatch details
public void print() {
System.out.println("DMatch [queryIdx=" + queryIdx
+ ", trainIdx=" + trainIdx
+ ", imgIdx=" + imgIdx
+ ", distance=" + distance + "]");
}
public static void main(String[] args) {
// Example usage of DMatch
DMatch match1 = new DMatch(0, 1, 0.5f);
DMatch match2 = new DMatch(1, 2, 0.3f);
match1.print();
match2.print();
if (match1.isLessThan(match2)) {
System.out.println("Match1 is closer than Match2.");
} else {
System.out.println("Match2 is closer than Match1.");
}
}
}