Skip to content

a sift match should contain distance parameter to determine quality #185

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/sift/source/app.d
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void main()
immutable AColor[8] colors = [aRed,aGreen,aBlue,aWhite,aBlack,aYellow,aCyan,aMagenta];

size_t colorInd;
foreach (kp1i, kp2i; matches) {
foreach (kp1i, kp2i, _distQuality; matches) {
auto startPoint = keypoints1[kp1i]; // a keypoint from image1
auto endPoint = keypoints2[kp2i]; // Corresponding keypoint from image2

Expand Down
9 changes: 6 additions & 3 deletions source/dcv/features/sift.d
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,21 @@ Array!SIFTKeypoint find_sift_keypoints_and_descriptors(InputSlice)(auto ref Inpu
}
return kps.move;
}

alias SIFTmatch = Tuple!(int, "index1", int, "index2", float, "distance");

/++
Returns an Array containing matched indices of the given SIFTKeypoints.
+/
Array!(Tuple!(int, int))
Array!SIFTmatch
find_sift_keypoint_matches(const ref Array!SIFTKeypoint a,
const ref Array!SIFTKeypoint b,
float thresh_relative = THRESH_RELATIVE,
float thresh_absolute = THRESH_ABSOLUTE)
{
assert(a.length >= 2 && b.length >= 2);

Array!(Tuple!(int, int)) matches;
Array!SIFTmatch matches;

for (int i = 0; i < a.length; i++)
{
Expand All @@ -128,7 +131,7 @@ find_sift_keypoint_matches(const ref Array!SIFTKeypoint a,
}
if (nn1_dist < thresh_relative * nn2_dist && nn1_dist < thresh_absolute)
{
matches ~= tuple(i, nn1_idx);
matches ~= SIFTmatch(i, nn1_idx, nn1_dist);
}
}
return matches.move;
Expand Down