Skip to content

Commit 7be10c9

Browse files
authored
Merge pull request #1989 from shimat/feature/inputarray-migration-cleanup-5x
Migration: InputArray/OutputArray/InputOutputArray to allocation-free ref structs (issue #1976 step 4 & 5)
2 parents 7f5409a + 51a3786 commit 7be10c9

170 files changed

Lines changed: 2898 additions & 11636 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/OpenCvSharp/Cv2/Cv2_calib.FishEye.cs

Lines changed: 79 additions & 247 deletions
Large diffs are not rendered by default.

src/OpenCvSharp/Cv2/Cv2_calib.cs

Lines changed: 44 additions & 171 deletions
Large diffs are not rendered by default.

src/OpenCvSharp/Cv2/Cv2_core.cs

Lines changed: 460 additions & 1339 deletions
Large diffs are not rendered by default.

src/OpenCvSharp/Cv2/Cv2_experimental.cs

Lines changed: 0 additions & 46 deletions
This file was deleted.

src/OpenCvSharp/Cv2/Cv2_features.cs

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,10 @@ static partial class Cv2
2121
/// <returns>keypoints detected on the image.</returns>
2222
public static KeyPoint[] FAST(InputArray image, int threshold, bool nonmaxSupression = true)
2323
{
24-
if (image is null)
25-
throw new ArgumentNullException(nameof(image));
26-
image.ThrowIfDisposed();
27-
2824
using var kp = new StdVector<KeyPoint>();
2925
NativeMethods.HandleException(
30-
NativeMethods.features_FAST1(image.ToInputProxy(), kp.CvPtr, threshold, nonmaxSupression ? 1 : 0));
31-
GC.KeepAlive(image);
26+
NativeMethods.features_FAST1(image.Proxy, kp.CvPtr, threshold, nonmaxSupression ? 1 : 0));
27+
GC.KeepAlive(image.Source);
3228
return kp.ToArray();
3329
}
3430

@@ -44,14 +40,10 @@ public static KeyPoint[] FAST(InputArray image, int threshold, bool nonmaxSupres
4440
/// <returns>keypoints detected on the image.</returns>
4541
public static KeyPoint[] FAST(InputArray image, int threshold, bool nonmaxSupression, FASTType type)
4642
{
47-
if (image is null)
48-
throw new ArgumentNullException(nameof(image));
49-
image.ThrowIfDisposed();
50-
5143
using var kp = new StdVector<KeyPoint>();
5244
NativeMethods.HandleException(
53-
NativeMethods.features_FAST2(image.ToInputProxy(), kp.CvPtr, threshold, nonmaxSupression ? 1 : 0, (int)type));
54-
GC.KeepAlive(image);
45+
NativeMethods.features_FAST2(image.Proxy, kp.CvPtr, threshold, nonmaxSupression ? 1 : 0, (int)type));
46+
GC.KeepAlive(image.Source);
5547
return kp.ToArray();
5648
}
5749

@@ -67,14 +59,10 @@ public static KeyPoint[] FAST(InputArray image, int threshold, bool nonmaxSupres
6759
/// <returns>keypoints detected on the image.</returns>
6860
public static KeyPoint[] AGAST(InputArray image, int threshold, bool nonmaxSuppression, AgastFeatureDetector.DetectorType type)
6961
{
70-
if (image is null)
71-
throw new ArgumentNullException(nameof(image));
72-
image.ThrowIfDisposed();
73-
7462
using var vector = new StdVector<KeyPoint>();
7563
NativeMethods.HandleException(
76-
NativeMethods.xfeatures2d_AGAST(image.ToInputProxy(), vector.CvPtr, threshold, nonmaxSuppression ? 1 : 0, (int) type));
77-
GC.KeepAlive(image);
64+
NativeMethods.xfeatures2d_AGAST(image.Proxy, vector.CvPtr, threshold, nonmaxSuppression ? 1 : 0, (int) type));
65+
GC.KeepAlive(image.Source);
7866
return vector.ToArray();
7967
}
8068

@@ -93,22 +81,16 @@ public static void DrawKeypoints(
9381
Scalar? color = null,
9482
DrawMatchesFlags flags = DrawMatchesFlags.Default)
9583
{
96-
if (image is null)
97-
throw new ArgumentNullException(nameof(image));
98-
if (outImage is null)
99-
throw new ArgumentNullException(nameof(outImage));
10084
if (keypoints is null)
10185
throw new ArgumentNullException(nameof(keypoints));
102-
image.ThrowIfDisposed();
103-
outImage.ThrowIfDisposed();
10486

10587
var keypointsArray = keypoints.CastOrToArray();
10688
var color0 = color.GetValueOrDefault(Scalar.All(-1));
10789
NativeMethods.HandleException(
108-
NativeMethods.features_drawKeypoints(image.ToInputProxy(), keypointsArray, keypointsArray.Length, outImage.ToInputOutputProxy(), color0, (int)flags));
90+
NativeMethods.features_drawKeypoints(image.Proxy, keypointsArray, keypointsArray.Length, outImage.Proxy, color0, (int)flags));
10991

110-
GC.KeepAlive(image);
111-
GC.KeepAlive(outImage);
92+
GC.KeepAlive(image.Source);
93+
GC.KeepAlive(outImage.Source);
11294
}
11395

11496
/// <summary>

0 commit comments

Comments
 (0)