Skip to content
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
10 changes: 9 additions & 1 deletion src/OpenCvSharp/Cv2/Cv2_calib.cs
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,14 @@ public static double StereoCalibrate(
throw new ArgumentNullException(nameof(cameraMatrix2));
if (distCoeffs2 is null)
throw new ArgumentNullException(nameof(distCoeffs2));
if (R is null)
throw new ArgumentNullException(nameof(R));
if (T is null)
throw new ArgumentNullException(nameof(T));
if (E is null)
throw new ArgumentNullException(nameof(E));
if (F is null)
throw new ArgumentNullException(nameof(F));
cameraMatrix1.ThrowIfDisposed();
distCoeffs1.ThrowIfDisposed();
cameraMatrix2.ThrowIfDisposed();
Expand All @@ -592,7 +600,7 @@ public static double StereoCalibrate(
ip1Ptrs, ip1Ptrs.Length, ip2Ptrs, ip2Ptrs.Length,
cameraMatrix1.ToInputOutputProxy(), distCoeffs1.ToInputOutputProxy(),
cameraMatrix2.ToInputOutputProxy(), distCoeffs2.ToInputOutputProxy(),
imageSize, R?.ToOutputProxy() ?? default, T?.ToOutputProxy() ?? default, E?.ToOutputProxy() ?? default, F?.ToOutputProxy() ?? default,
imageSize, R.ToOutputProxy(), T.ToOutputProxy(), E.ToOutputProxy(), F.ToOutputProxy(),
(int) flags, criteria0, out var ret));

GC.KeepAlive(cameraMatrix1);
Expand Down
2 changes: 1 addition & 1 deletion src/OpenCvSharp/Cv2/Cv2_features.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static KeyPoint[] AGAST(InputArray image, int threshold, bool nonmaxSuppr

using var vector = new StdVector<KeyPoint>();
NativeMethods.HandleException(
NativeMethods.xfeatures2d_AGAST(image.CvPtr, vector.CvPtr, threshold, nonmaxSuppression ? 1 : 0, (int) type));
NativeMethods.xfeatures2d_AGAST(image.ToInputProxy(), vector.CvPtr, threshold, nonmaxSuppression ? 1 : 0, (int) type));
GC.KeepAlive(image);
return vector.ToArray();
}
Expand Down
4 changes: 2 additions & 2 deletions src/OpenCvSharp/Cv2/Cv2_geometry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public static Mat FindHomography(
var p = (@params ?? new UsacParams()).ToNativeStruct();
NativeMethods.HandleException(
NativeMethods.geometry_findHomography_UsacParams(
srcPoints.ToInputProxy(), dstPoints.ToInputProxy(), mask?.ToOutputProxy() ?? default, ref p,
srcPoints.ToInputProxy(), dstPoints.ToInputProxy(), mask.ToOutputProxy(), ref p,
out var ret));

GC.KeepAlive(srcPoints);
Expand Down Expand Up @@ -1432,7 +1432,7 @@ public static Mat FindFundamentalMat(InputArray points1, InputArray points2, Out
var p = (@params ?? new UsacParams()).ToNativeStruct();
NativeMethods.HandleException(
NativeMethods.geometry_findFundamentalMat_UsacParams(
points1.ToInputProxy(), points2.ToInputProxy(), mask?.ToOutputProxy() ?? default, ref p, out var ret));
points1.ToInputProxy(), points2.ToInputProxy(), mask.ToOutputProxy(), ref p, out var ret));

GC.KeepAlive(points1);
GC.KeepAlive(points2);
Expand Down
6 changes: 3 additions & 3 deletions src/OpenCvSharp/Cv2/Cv2_highgui.cs
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ public static Rect SelectROI(string windowName, InputArray img, bool showCrossha
img.ThrowIfDisposed();

NativeMethods.HandleException(
NativeMethods.highgui_selectROI1(windowName, img.CvPtr, showCrosshair ? 1 : 0, fromCenter ? 1 : 0, out var ret));
NativeMethods.highgui_selectROI1(windowName, img.ToInputProxy(), showCrosshair ? 1 : 0, fromCenter ? 1 : 0, out var ret));

GC.KeepAlive(img);
return ret;
Expand All @@ -335,7 +335,7 @@ public static Rect SelectROI(InputArray img, bool showCrosshair = true, bool fro
img.ThrowIfDisposed();

NativeMethods.HandleException(
NativeMethods.highgui_selectROI2(img.CvPtr, showCrosshair ? 1 : 0, fromCenter ? 1 : 0, out var ret));
NativeMethods.highgui_selectROI2(img.ToInputProxy(), showCrosshair ? 1 : 0, fromCenter ? 1 : 0, out var ret));

GC.KeepAlive(img);
return ret;
Expand Down Expand Up @@ -364,7 +364,7 @@ public static Rect[] SelectROIs(string windowName, InputArray img, bool showCro

using var boundingBoxesVec = new StdVector<Rect>();
NativeMethods.HandleException(
NativeMethods.highgui_selectROIs(windowName, img.CvPtr, boundingBoxesVec.CvPtr, showCrosshair ? 1 : 0, fromCenter ? 1 : 0));
NativeMethods.highgui_selectROIs(windowName, img.ToInputProxy(), boundingBoxesVec.CvPtr, showCrosshair ? 1 : 0, fromCenter ? 1 : 0));

GC.KeepAlive(img);
return boundingBoxesVec.ToArray();
Expand Down
4 changes: 2 additions & 2 deletions src/OpenCvSharp/Cv2/Cv2_imgcodecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public static Mat ImDecode(InputArray buf, ImreadModes flags)
buf.ThrowIfDisposed();

NativeMethods.HandleException(
NativeMethods.imgcodecs_imdecode_InputArray(buf.CvPtr, (int) flags, out var ret));
NativeMethods.imgcodecs_imdecode_InputArray(buf.ToInputProxy(), (int) flags, out var ret));
GC.KeepAlive(buf);
return new Mat(ret);
}
Expand Down Expand Up @@ -222,7 +222,7 @@ public static bool ImEncode(string ext, InputArray img, out byte[] buf, int[]? p

using var bufVec = new StdVector<byte>();
NativeMethods.HandleException(
NativeMethods.imgcodecs_imencode_vector(ext, img.CvPtr, bufVec.CvPtr, prms, prms.Length, out var ret));
NativeMethods.imgcodecs_imencode_vector(ext, img.ToInputProxy(), bufVec.CvPtr, prms, prms.Length, out var ret));
GC.KeepAlive(img);
buf = bufVec.ToArray();
return ret != 0;
Expand Down
19 changes: 13 additions & 6 deletions src/OpenCvSharp/Cv2/Cv2_imgproc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ public static void MedianBlur(InputArray src, OutputArray dst, int ksize)
/// respectively (see getGaussianKernel() for details); to fully control the result
/// regardless of possible future modifications of all this semantics, it is recommended to specify all of ksize, sigmaX, and sigmaY.</param>
/// <param name="borderType">pixel extrapolation method</param>
/// <param name="hint">Hint that selects between alternative algorithm implementations (OpenCV 5).</param>
public static void GaussianBlur(InputArray src, OutputArray dst, Size ksize, double sigmaX,
double sigmaY = 0, BorderTypes borderType = BorderTypes.Default, AlgorithmHint hint = AlgorithmHint.Default)
{
Expand Down Expand Up @@ -1051,6 +1052,7 @@ public static void Resize(InputArray src, OutputArray dst, Size dsize,
/// it means that the pixels in the destination image corresponding to the "outliers"
/// in the source image are not modified by the function.</param>
/// <param name="borderValue">value used in case of a constant border; by default, it is 0.</param>
/// <param name="hint">Hint that selects between alternative algorithm implementations (OpenCV 5).</param>
public static void WarpAffine(
InputArray src, OutputArray dst, InputArray m, Size dsize,
InterpolationFlags flags = InterpolationFlags.Linear,
Expand Down Expand Up @@ -1088,6 +1090,7 @@ public static void WarpAffine(
/// and the optional flag WARP_INVERSE_MAP, that sets M as the inverse transformation (dst -> src).</param>
/// <param name="borderMode">pixel extrapolation method (BORDER_CONSTANT or BORDER_REPLICATE).</param>
/// <param name="borderValue">value used in case of a constant border; by default, it equals 0.</param>
/// <param name="hint">Hint that selects between alternative algorithm implementations (OpenCV 5).</param>
public static void WarpPerspective(
InputArray src, OutputArray dst, InputArray m, Size dsize,
InterpolationFlags flags = InterpolationFlags.Linear,
Expand Down Expand Up @@ -1127,6 +1130,7 @@ public static void WarpPerspective(
/// and the optional flag WARP_INVERSE_MAP, that sets M as the inverse transformation (dst -> src).</param>
/// <param name="borderMode">pixel extrapolation method (BORDER_CONSTANT or BORDER_REPLICATE).</param>
/// <param name="borderValue">value used in case of a constant border; by default, it equals 0.</param>
/// <param name="hint">Hint that selects between alternative algorithm implementations (OpenCV 5).</param>
public static void WarpPerspective(
InputArray src, OutputArray dst, float[,] m, Size dsize,
InterpolationFlags flags = InterpolationFlags.Linear,
Expand Down Expand Up @@ -1168,6 +1172,7 @@ public static void WarpPerspective(
/// it means that the pixels in the destination image that corresponds to the "outliers" in
/// the source image are not modified by the function.</param>
/// <param name="borderValue">Value used in case of a constant border. By default, it is 0.</param>
/// <param name="hint">Hint that selects between alternative algorithm implementations (OpenCV 5).</param>
public static void Remap(
InputArray src, OutputArray dst, InputArray map1, InputArray map2,
InterpolationFlags interpolation = InterpolationFlags.Linear,
Expand Down Expand Up @@ -2430,6 +2435,7 @@ public static void BlendLinear(InputArray src1, InputArray src2, InputArray weig
/// <param name="dst">The destination image; will have the same size and the same depth as src</param>
/// <param name="code">The color space conversion code</param>
/// <param name="dstCn">The number of channels in the destination image; if the parameter is 0, the number of the channels will be derived automatically from src and the code</param>
/// <param name="hint">Hint that selects between alternative algorithm implementations (OpenCV 5).</param>
public static void CvtColor(InputArray src, OutputArray dst, ColorConversionCodes code, int dstCn = 0,
AlgorithmHint hint = AlgorithmHint.Default)
{
Expand Down Expand Up @@ -2464,6 +2470,7 @@ public static void CvtColor(InputArray src, OutputArray dst, ColorConversionCode
/// - #COLOR_YUV2RGB_NV21
/// - #COLOR_YUV2BGRA_NV21
/// - #COLOR_YUV2RGBA_NV21</param>
/// <param name="hint">Hint that selects between alternative algorithm implementations (OpenCV 5).</param>
public static void CvtColorTwoPlane(InputArray src1, InputArray src2, OutputArray dst, ColorConversionCodes code,
AlgorithmHint hint = AlgorithmHint.Default)
{
Expand Down Expand Up @@ -5221,7 +5228,7 @@ public static void DrawFrameAxes(

NativeMethods.HandleException(
NativeMethods.imgproc_drawFrameAxes(
image.CvPtr, cameraMatrix.CvPtr, distCoeffs.CvPtr, rvec.CvPtr, tvec.CvPtr, length, thickness));
image.ToInputOutputProxy(), cameraMatrix.ToInputProxy(), distCoeffs.ToInputProxy(), rvec.ToInputProxy(), tvec.ToInputProxy(), length, thickness));

GC.KeepAlive(image);
GC.KeepAlive(cameraMatrix);
Expand Down Expand Up @@ -5257,8 +5264,8 @@ public static void Undistort(InputArray src, OutputArray dst,
cameraMatrix.ThrowIfDisposed();

NativeMethods.HandleException(
NativeMethods.imgproc_undistort(src.CvPtr, dst.CvPtr, cameraMatrix.CvPtr,
ToPtr(distCoeffs), ToPtr(newCameraMatrix)));
NativeMethods.imgproc_undistort(src.ToInputProxy(), dst.ToOutputProxy(), cameraMatrix.ToInputProxy(),
distCoeffs?.ToInputProxy() ?? default, newCameraMatrix?.ToInputProxy() ?? default));

GC.KeepAlive(src);
GC.KeepAlive(dst);
Expand Down Expand Up @@ -5305,7 +5312,7 @@ public static void InitUndistortRectifyMap(

NativeMethods.HandleException(
NativeMethods.imgproc_initUndistortRectifyMap(
cameraMatrix.CvPtr, distCoeffs.CvPtr, r.CvPtr, newCameraMatrix.CvPtr, size, m1Type, map1.CvPtr, map2.CvPtr));
cameraMatrix.ToInputProxy(), distCoeffs.ToInputProxy(), r.ToInputProxy(), newCameraMatrix.ToInputProxy(), size, m1Type, map1.ToOutputProxy(), map2.ToOutputProxy()));

GC.KeepAlive(cameraMatrix);
GC.KeepAlive(distCoeffs);
Expand Down Expand Up @@ -5351,8 +5358,8 @@ public static float InitWideAngleProjMap(

NativeMethods.HandleException(
NativeMethods.imgproc_initWideAngleProjMap(
cameraMatrix.CvPtr, distCoeffs.CvPtr, imageSize,
destImageWidth, m1Type, map1.CvPtr, map2.CvPtr, (int) projType, alpha, out var ret));
cameraMatrix.ToInputProxy(), distCoeffs.ToInputProxy(), imageSize,
destImageWidth, m1Type, map1.ToOutputProxy(), map2.ToOutputProxy(), (int) projType, alpha, out var ret));

GC.KeepAlive(cameraMatrix);
GC.KeepAlive(distCoeffs);
Expand Down
14 changes: 7 additions & 7 deletions src/OpenCvSharp/Cv2/Cv2_objdetect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public static bool CheckChessboard(InputArray img, Size size)
img.ThrowIfDisposed();

NativeMethods.HandleException(
NativeMethods.objdetect_checkChessboard(img.CvPtr, size, out var ret));
NativeMethods.objdetect_checkChessboard(img.ToInputProxy(), size, out var ret));
GC.KeepAlive(img);
return ret != 0;
}
Expand All @@ -176,7 +176,7 @@ public static bool FindChessboardCornersSB(

NativeMethods.HandleException(
NativeMethods.objdetect_findChessboardCornersSB_OutputArray(
image.CvPtr, patternSize, corners.CvPtr, (int) flags, out var ret));
image.ToInputProxy(), patternSize, corners.ToOutputProxy(), (int) flags, out var ret));

GC.KeepAlive(image);
GC.KeepAlive(corners);
Expand All @@ -202,7 +202,7 @@ public static bool FindChessboardCornersSB(
using var cornersVec = new StdVector<Point2f>();
NativeMethods.HandleException(
NativeMethods.objdetect_findChessboardCornersSB_vector(
image.CvPtr, patternSize, cornersVec.CvPtr, (int) flags, out var ret));
image.ToInputProxy(), patternSize, cornersVec.CvPtr, (int) flags, out var ret));

corners = cornersVec.ToArray();
GC.KeepAlive(image);
Expand All @@ -227,7 +227,7 @@ public static bool Find4QuadCornerSubpix(InputArray img, InputOutputArray corner

NativeMethods.HandleException(
NativeMethods.objdetect_find4QuadCornerSubpix_InputArray(
img.CvPtr, corners.CvPtr, regionSize, out var ret));
img.ToInputProxy(), corners.ToInputOutputProxy(), regionSize, out var ret));
GC.KeepAlive(img);
corners.Fix();
return ret != 0;
Expand All @@ -250,7 +250,7 @@ public static bool Find4QuadCornerSubpix(InputArray img, Point2f[] corners, Size
using var cornersVec = new StdVector<Point2f>(corners);
NativeMethods.HandleException(
NativeMethods.objdetect_find4QuadCornerSubpix_vector(
img.CvPtr, cornersVec.CvPtr, regionSize, out var ret));
img.ToInputProxy(), cornersVec.CvPtr, regionSize, out var ret));
GC.KeepAlive(img);

var newCorners = cornersVec.ToArray();
Expand Down Expand Up @@ -281,7 +281,7 @@ public static void DrawChessboardCorners(InputOutputArray image, Size patternSiz

NativeMethods.HandleException(
NativeMethods.objdetect_drawChessboardCorners_InputArray(
image.CvPtr, patternSize, corners.CvPtr, patternWasFound ? 1 : 0));
image.ToInputOutputProxy(), patternSize, corners.ToInputProxy(), patternWasFound ? 1 : 0));
GC.KeepAlive(corners);
image.Fix();
}
Expand All @@ -306,7 +306,7 @@ public static void DrawChessboardCorners(InputOutputArray image, Size patternSiz
var cornersArray = corners as Point2f[] ?? corners.ToArray();
NativeMethods.HandleException(
NativeMethods.objdetect_drawChessboardCorners_array(
image.CvPtr, patternSize, cornersArray, cornersArray.Length,
image.ToInputOutputProxy(), patternSize, cornersArray, cornersArray.Length,
patternWasFound ? 1 : 0));
image.Fix();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,18 @@ double thresh
public static partial ExceptionStatus barcode_BarcodeDetector_delete(IntPtr obj);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus barcode_BarcodeDetector_decodeWithType(
internal static partial ExceptionStatus barcode_BarcodeDetector_decodeWithType(
OpenCvSafeHandle obj,
IntPtr inputImage,
in InputArrayProxy inputImage,
IntPtr points,
IntPtr infos,
IntPtr types
);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus barcode_BarcodeDetector_detectAndDecodeWithType(
internal static partial ExceptionStatus barcode_BarcodeDetector_detectAndDecodeWithType(
OpenCvSafeHandle obj,
IntPtr inputImage,
in InputArrayProxy inputImage,
IntPtr points,
IntPtr infos,
IntPtr types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ public static partial ExceptionStatus bgsegm_createBackgroundSubtractorMOG(
public static partial ExceptionStatus bgsegm_BackgroundSubtractorMOG_setNoiseSigma(OpenCvSafeHandle ptr, double value);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus bgsegm_BackgroundSubtractorMOG_apply(OpenCvSafeHandle ptr, IntPtr image, IntPtr fgmask, double learningRate);
internal static partial ExceptionStatus bgsegm_BackgroundSubtractorMOG_apply(OpenCvSafeHandle ptr, in InputArrayProxy image, in OutputArrayProxy fgmask, double learningRate);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus bgsegm_BackgroundSubtractorMOG_getBackgroundImage(OpenCvSafeHandle ptr, IntPtr backgroundImage);
internal static partial ExceptionStatus bgsegm_BackgroundSubtractorMOG_getBackgroundImage(OpenCvSafeHandle ptr, in OutputArrayProxy backgroundImage);

#endregion

Expand Down Expand Up @@ -126,10 +126,10 @@ public static partial ExceptionStatus bgsegm_createBackgroundSubtractorGMG(
public static partial ExceptionStatus bgsegm_BackgroundSubtractorGMG_setMaxVal(OpenCvSafeHandle ptr, double value);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus bgsegm_BackgroundSubtractorGMG_apply(OpenCvSafeHandle ptr, IntPtr image, IntPtr fgmask, double learningRate);
internal static partial ExceptionStatus bgsegm_BackgroundSubtractorGMG_apply(OpenCvSafeHandle ptr, in InputArrayProxy image, in OutputArrayProxy fgmask, double learningRate);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus bgsegm_BackgroundSubtractorGMG_getBackgroundImage(OpenCvSafeHandle ptr, IntPtr backgroundImage);
internal static partial ExceptionStatus bgsegm_BackgroundSubtractorGMG_getBackgroundImage(OpenCvSafeHandle ptr, in OutputArrayProxy backgroundImage);

#endregion
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ static partial class NativeMethods
#region Index

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus flann_Index_new(IntPtr features, IntPtr @params, int distType, out IntPtr returnValue);
internal static partial ExceptionStatus flann_Index_new(in InputArrayProxy features, IntPtr @params, int distType, out IntPtr returnValue);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus flann_Index_delete(IntPtr obj);
Expand Down
Loading
Loading