Skip to content
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

nuint, change namespace #1144

Merged
merged 4 commits into from
Jan 2, 2021
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
1 change: 1 addition & 0 deletions OpenCvSharp.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=opencv/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Otsu/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=PSNR/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Ptrs/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=RANSAC/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=reproject/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=reprojection/@EntryIndexedValue">True</s:Boolean>
Expand Down
1 change: 1 addition & 0 deletions src/OpenCvSharp/Cv2/Cv2_calib3d.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using OpenCvSharp.Internal.Vectors;

namespace OpenCvSharp
{
Expand Down
2 changes: 2 additions & 0 deletions src/OpenCvSharp/Cv2/Cv2_core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenCvSharp.Internal.Vectors;

// ReSharper disable CommentTypo
// ReSharper disable IdentifierTypo
// ReSharper disable UnusedMember.Global
Expand Down
1 change: 1 addition & 0 deletions src/OpenCvSharp/Cv2/Cv2_features2d.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using OpenCvSharp.Internal.Vectors;
using OpenCvSharp.Util;

// ReSharper disable UnusedMember.Global
Expand Down
2 changes: 2 additions & 0 deletions src/OpenCvSharp/Cv2/Cv2_highgui.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
using OpenCvSharp.Internal.Vectors;

// ReSharper disable UnusedMember.Global

namespace OpenCvSharp
Expand Down
1 change: 1 addition & 0 deletions src/OpenCvSharp/Cv2/Cv2_imgcodecs.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using OpenCvSharp.Internal.Vectors;

namespace OpenCvSharp
{
Expand Down
70 changes: 32 additions & 38 deletions src/OpenCvSharp/Cv2/Cv2_imgproc.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using OpenCvSharp.Internal.Vectors;
using OpenCvSharp.Util;

// ReSharper disable InconsistentNaming
Expand Down Expand Up @@ -2653,7 +2654,7 @@ public static void Demosaicing(InputArray src, OutputArray dst, ColorConversionC
/// <returns></returns>
public static Moments Moments(InputArray array, bool binaryImage = false)
{
return new Moments(array, binaryImage);
return new (array, binaryImage);
}

/// <summary>
Expand All @@ -2665,7 +2666,7 @@ public static Moments Moments(InputArray array, bool binaryImage = false)
/// <returns></returns>
public static Moments Moments(byte[,] array, bool binaryImage = false)
{
return new Moments(array, binaryImage);
return new (array, binaryImage);
}

/// <summary>
Expand All @@ -2677,7 +2678,7 @@ public static Moments Moments(byte[,] array, bool binaryImage = false)
/// <returns></returns>
public static Moments Moments(float[,] array, bool binaryImage = false)
{
return new Moments(array, binaryImage);
return new (array, binaryImage);
}

/// <summary>
Expand All @@ -2689,7 +2690,7 @@ public static Moments Moments(float[,] array, bool binaryImage = false)
/// <returns></returns>
public static Moments Moments(IEnumerable<Point> array, bool binaryImage = false)
{
return new Moments(array, binaryImage);
return new (array, binaryImage);
}

/// <summary>
Expand All @@ -2701,7 +2702,7 @@ public static Moments Moments(IEnumerable<Point> array, bool binaryImage = false
/// <returns></returns>
public static Moments Moments(IEnumerable<Point2f> array, bool binaryImage = false)
{
return new Moments(array, binaryImage);
return new (array, binaryImage);
}

/// <summary>
Expand Down Expand Up @@ -3061,16 +3062,15 @@ public static void FindContours(InputArray image, out Point[][] contours,
image.ThrowIfDisposed();

var offset0 = offset.GetValueOrDefault(new Point());
using var contoursVec = new VectorOfVectorPoint();
using var hierarchyVec = new VectorOfVec4i();
NativeMethods.HandleException(
NativeMethods.imgproc_findContours1_vector(image.CvPtr, out var contoursPtr, out var hierarchyPtr, (int)mode, (int)method, offset0));
NativeMethods.imgproc_findContours1_vector(
image.CvPtr, contoursVec.CvPtr, hierarchyVec.CvPtr, (int) mode, (int) method, offset0));

using (var contoursVec = new VectorOfVectorPoint(contoursPtr))
{
using var hierarchyVec = new VectorOfVec4i(hierarchyPtr);
contours = contoursVec.ToArray();
var hierarchyOrg = hierarchyVec.ToArray();
hierarchy = hierarchyOrg.Select(HierarchyIndex.FromVec4i).ToArray();
}
contours = contoursVec.ToArray();
var hierarchyOrg = hierarchyVec.ToArray();
hierarchy = hierarchyOrg.Select(HierarchyIndex.FromVec4i).ToArray();

GC.KeepAlive(image);
}
Expand Down Expand Up @@ -3118,13 +3118,11 @@ public static void FindContours(InputArray image, out Mat[] contours,
hierarchy.ThrowIfNotReady();

var offset0 = offset.GetValueOrDefault(new Point());
using var contoursVec = new VectorOfMat();
NativeMethods.HandleException(
NativeMethods.imgproc_findContours1_OutputArray(image.CvPtr, out var contoursPtr, hierarchy.CvPtr, (int) mode, (int) method, offset0));
NativeMethods.imgproc_findContours1_OutputArray(image.CvPtr, contoursVec.CvPtr, hierarchy.CvPtr, (int) mode, (int) method, offset0));

using (var contoursVec = new VectorOfMat(contoursPtr))
{
contours = contoursVec.ToArray();
}
contours = contoursVec.ToArray();

hierarchy.Fix();
GC.KeepAlive(image);
Expand Down Expand Up @@ -3162,11 +3160,11 @@ public static Point[][] FindContoursAsArray(InputArray image,
image.ThrowIfDisposed();

var offset0 = offset.GetValueOrDefault(new Point());
using var contoursVec = new VectorOfVectorPoint();
NativeMethods.HandleException(
NativeMethods.imgproc_findContours2_vector(image.CvPtr, out var contoursPtr, (int) mode, (int) method, offset0));
NativeMethods.imgproc_findContours2_vector(image.CvPtr, contoursVec.CvPtr, (int) mode, (int) method, offset0));
GC.KeepAlive(image);

using var contoursVec = new VectorOfVectorPoint(contoursPtr);
return contoursVec.ToArray();
}

Expand Down Expand Up @@ -3201,11 +3199,11 @@ public static Mat<Point>[] FindContoursAsMat(InputArray image,
image.ThrowIfDisposed();

var offset0 = offset.GetValueOrDefault(new Point());
using var contoursVec = new VectorOfMat();
NativeMethods.HandleException(
NativeMethods.imgproc_findContours2_OutputArray(image.CvPtr, out var contoursPtr, (int)mode, (int)method, offset0));
NativeMethods.imgproc_findContours2_OutputArray(image.CvPtr, contoursVec.CvPtr, (int)mode, (int)method, offset0));
GC.KeepAlive(image);

using var contoursVec = new VectorOfMat(contoursPtr);
return contoursVec.ToArray<Mat<Point>>();
}

Expand Down Expand Up @@ -3251,11 +3249,11 @@ public static Point[] ApproxPolyDP(IEnumerable<Point> curve, double epsilon, boo
{
if(curve == null)
throw new ArgumentNullException(nameof(curve));
var curveArray = curve.ToArray();
var curveArray = curve as Point[] ?? curve.ToArray();
using var approxCurveVec = new VectorOfPoint();
NativeMethods.HandleException(
NativeMethods.imgproc_approxPolyDP_Point(
curveArray, curveArray.Length, out var approxCurvePtr, epsilon, closed ? 1 : 0));
using var approxCurveVec = new VectorOfPoint(approxCurvePtr);
curveArray, curveArray.Length, approxCurveVec.CvPtr, epsilon, closed ? 1 : 0));
return approxCurveVec.ToArray();
}

Expand All @@ -3273,11 +3271,11 @@ public static Point2f[] ApproxPolyDP(IEnumerable<Point2f> curve, double epsilon,
{
if (curve == null)
throw new ArgumentNullException(nameof(curve));
var curveArray = curve.ToArray();
var curveArray = curve as Point2f[] ?? curve.ToArray();
using var approxCurveVec = new VectorOfPoint2f();
NativeMethods.HandleException(
NativeMethods.imgproc_approxPolyDP_Point2f(
curveArray, curveArray.Length, out var approxCurvePtr, epsilon, closed ? 1 : 0));
using var approxCurveVec = new VectorOfPoint2f(approxCurvePtr);
curveArray, curveArray.Length, approxCurveVec.CvPtr, epsilon, closed ? 1 : 0));
return approxCurveVec.ToArray();
}

Expand Down Expand Up @@ -4009,14 +4007,12 @@ public static float IntersectConvexConvex(IEnumerable<Point> p1, IEnumerable<Poi
var p1Array = p1.ToArray();
var p2Array = p2.ToArray();

using var p12Vec = new VectorOfPoint();
NativeMethods.HandleException(
NativeMethods.imgproc_intersectConvexConvex_Point(
p1Array, p1Array.Length, p2Array, p2Array.Length, out var p12Ptr, handleNested ? 1 : 0, out var ret));
p1Array, p1Array.Length, p2Array, p2Array.Length, p12Vec.CvPtr, handleNested ? 1 : 0, out var ret));

using (var p12Vec = new VectorOfPoint(p12Ptr))
{
p12 = p12Vec.ToArray();
}
p12 = p12Vec.ToArray();

return ret;
}
Expand All @@ -4039,15 +4035,13 @@ public static float IntersectConvexConvex(IEnumerable<Point2f> p1, IEnumerable<P
var p1Array = p1.ToArray();
var p2Array = p2.ToArray();

using var p12Vec = new VectorOfPoint2f();
NativeMethods.HandleException(
NativeMethods.imgproc_intersectConvexConvex_Point2f(
p1Array, p1Array.Length, p2Array, p2Array.Length,
out var p12Ptr, handleNested ? 1 : 0, out var ret));
p12Vec.CvPtr, handleNested ? 1 : 0, out var ret));

using (var p12Vec = new VectorOfPoint2f(p12Ptr))
{
p12 = p12Vec.ToArray();
}
p12 = p12Vec.ToArray();

return ret;
}
Expand Down
1 change: 1 addition & 0 deletions src/OpenCvSharp/Cv2/Cv2_objdetect.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using OpenCvSharp.Internal.Vectors;

namespace OpenCvSharp
{
Expand Down
1 change: 1 addition & 0 deletions src/OpenCvSharp/Cv2/Cv2_video.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using OpenCvSharp.Internal.Vectors;

namespace OpenCvSharp
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System;
using System.Diagnostics.Contracts;
using System.Runtime.InteropServices;

#pragma warning disable 1591
#pragma warning disable CA1401 // P/Invokes should not be visible
#pragma warning disable IDE1006 // Naming style

namespace OpenCvSharp
{
static partial class NativeMethods
{
[Pure, DllImport(DllExtern, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern ExceptionStatus line_descriptor_LSDDetector_new1(
out IntPtr returnValue);

[Pure, DllImport(DllExtern, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern ExceptionStatus line_descriptor_LSDDetector_new2(
double scale,
double sigmaScale,
double quant,
double angTh,
double logEps,
double densityTh,
int nBins,
out IntPtr returnValue);

[Pure, DllImport(DllExtern, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern ExceptionStatus line_descriptor_LSDDetector_delete(IntPtr obj);

[Pure, DllImport(DllExtern, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern ExceptionStatus line_descriptor_LSDDetector_detect1(
IntPtr obj, IntPtr image, IntPtr keypoints, int scale, int numOctaves, IntPtr mask);

[Pure, DllImport(DllExtern, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern ExceptionStatus line_descriptor_LSDDetector_detect2(
IntPtr obj,
IntPtr[] images, int imagesSize,
IntPtr keyLines, int scale, int numOctaves,
IntPtr[] masks, int masksSize);
}
}
Loading