Skip to content

Commit 758e022

Browse files
committed
Fix FeaturesMatcher collection keypoints
1 parent 44adfed commit 758e022

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

src/OpenCvSharp/Modules/stitching/FeaturesMatcher.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public virtual MatchesInfo[] Apply(
102102
throw new ArgumentException("features contain null descriptor mat", nameof(features));
103103
featuresArray[i].Descriptors.ThrowIfDisposed();
104104

105-
keypointVecs[i] = new StdVector<KeyPoint>();
105+
keypointVecs[i] = new StdVector<KeyPoint>(featuresArray[i].Keypoints);
106106
wImageFeatures[i] = new WImageFeatures
107107
{
108108
ImgIdx = featuresArray[i].ImgIdx,

test/OpenCvSharp.Tests/stitching/FeaturesMatcherTest.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,8 @@ public void ApplyMultipleImageFeatures()
4646
using var source = LoadImage("lenna.png", ImreadModes.Grayscale);
4747
var images = new[]
4848
{
49-
source[new Rect(0, 0, 200, 200)].Clone(),
50-
source[new Rect(100, 100, 200, 200)].Clone(),
51-
source[new Rect(200, 0, 200, 200)].Clone(),
49+
source.Clone(),
50+
source.Clone(),
5251
};
5352
try
5453
{
@@ -71,6 +70,12 @@ source[new Rect(200, 0, 200, 200)].Clone(),
7170
Assert.InRange(m.DstImgIdx, -1, images.Length - 1);
7271
}
7372

73+
var forwardMatch = Assert.Single(
74+
matches, m => m.SrcImgIdx == 0 && m.DstImgIdx == 1);
75+
Assert.NotEmpty(forwardMatch.Matches);
76+
Assert.True(forwardMatch.NumInliers > 0);
77+
Assert.False(forwardMatch.H.Empty());
78+
7479
foreach (var m in matches)
7580
m.Dispose();
7681
}

0 commit comments

Comments
 (0)