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
15 changes: 15 additions & 0 deletions src/OpenCvSharp/Cv2/Cv2_photo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -358,4 +358,19 @@ public static void Stylization(

GC.KeepAlive(src.Source);
}

/// <summary>
/// Applies gamma correction to the input image.
/// </summary>
/// <param name="src">Input image.</param>
/// <param name="dst">Output image.</param>
/// <param name="gamma">Gamma correction greater than zero.</param>
public static void GammaCorrection(InputArray src, OutputArray dst, double gamma)
{
NativeMethods.HandleException(
NativeMethods.photo_ccm_gammaCorrection(src.Proxy, dst.Proxy, gamma));

GC.KeepAlive(src.Source);
GC.KeepAlive(dst.Source);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
using System.Runtime.CompilerServices;
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.Internal;

static partial class NativeMethods
{
[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
internal static partial ExceptionStatus photo_ccm_gammaCorrection(in InputArrayProxy src, in OutputArrayProxy dst, double gamma);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus photo_ccm_ColorCorrectionModel_delete(IntPtr obj);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus photo_ccm_ColorCorrectionModel_new1(out IntPtr returnValue);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
internal static partial ExceptionStatus photo_ccm_ColorCorrectionModel_new2(
in InputArrayProxy src, int constColor, out IntPtr returnValue);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
internal static partial ExceptionStatus photo_ccm_ColorCorrectionModel_new3(
in InputArrayProxy src, in InputArrayProxy colors, int refColorSpace, out IntPtr returnValue);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
internal static partial ExceptionStatus photo_ccm_ColorCorrectionModel_new4(
in InputArrayProxy src, in InputArrayProxy colors, int refColorSpace, in InputArrayProxy coloredPatchesMask, out IntPtr returnValue);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus photo_ccm_ColorCorrectionModel_setColorSpace(OpenCvSafeHandle obj, int cs);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus photo_ccm_ColorCorrectionModel_setCcmType(OpenCvSafeHandle obj, int ccmType);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus photo_ccm_ColorCorrectionModel_setDistance(OpenCvSafeHandle obj, int distance);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus photo_ccm_ColorCorrectionModel_setLinearization(OpenCvSafeHandle obj, int linearizationType);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus photo_ccm_ColorCorrectionModel_setLinearizationGamma(OpenCvSafeHandle obj, double gamma);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus photo_ccm_ColorCorrectionModel_setLinearizationDegree(OpenCvSafeHandle obj, int deg);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus photo_ccm_ColorCorrectionModel_setSaturatedThreshold(OpenCvSafeHandle obj, double lower, double upper);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus photo_ccm_ColorCorrectionModel_setWeightsList(OpenCvSafeHandle obj, IntPtr weightsList);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus photo_ccm_ColorCorrectionModel_setWeightCoeff(OpenCvSafeHandle obj, double weightsCoeff);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus photo_ccm_ColorCorrectionModel_setInitialMethod(OpenCvSafeHandle obj, int initialMethodType);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus photo_ccm_ColorCorrectionModel_setMaxCount(OpenCvSafeHandle obj, int maxCount);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus photo_ccm_ColorCorrectionModel_setEpsilon(OpenCvSafeHandle obj, double epsilon);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus photo_ccm_ColorCorrectionModel_setRGB(OpenCvSafeHandle obj, int rgb);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus photo_ccm_ColorCorrectionModel_compute(OpenCvSafeHandle obj, out IntPtr returnValue);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus photo_ccm_ColorCorrectionModel_getColorCorrectionMatrix(OpenCvSafeHandle obj, out IntPtr returnValue);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus photo_ccm_ColorCorrectionModel_getLoss(OpenCvSafeHandle obj, out double returnValue);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus photo_ccm_ColorCorrectionModel_getSrcLinearRGB(OpenCvSafeHandle obj, out IntPtr returnValue);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus photo_ccm_ColorCorrectionModel_getRefLinearRGB(OpenCvSafeHandle obj, out IntPtr returnValue);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus photo_ccm_ColorCorrectionModel_getMask(OpenCvSafeHandle obj, out IntPtr returnValue);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus photo_ccm_ColorCorrectionModel_getWeights(OpenCvSafeHandle obj, out IntPtr returnValue);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
internal static partial ExceptionStatus photo_ccm_ColorCorrectionModel_correctImage(
OpenCvSafeHandle obj, in InputArrayProxy src, in OutputArrayProxy dst, int islinear);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus photo_ccm_ColorCorrectionModel_write(OpenCvSafeHandle obj, IntPtr fs);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus photo_ccm_ColorCorrectionModel_read(OpenCvSafeHandle obj, IntPtr node);
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,10 @@ public static partial ExceptionStatus saliency_MotionSaliencyBinWangApr2014_getI
[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus saliency_MotionSaliencyBinWangApr2014_setImageHeight(
OpenCvSafeHandle obj, int val);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus saliency_MotionSaliencyBinWangApr2014_write(OpenCvSafeHandle obj, IntPtr fs);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus saliency_MotionSaliencyBinWangApr2014_read(OpenCvSafeHandle obj, IntPtr fn);
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,10 @@ public static partial ExceptionStatus saliency_ObjectnessBING_getW(

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus saliency_ObjectnessBING_setW(OpenCvSafeHandle obj, int val);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus saliency_ObjectnessBING_write(OpenCvSafeHandle obj, IntPtr fs);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus saliency_ObjectnessBING_read(OpenCvSafeHandle obj, IntPtr fn);
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,10 @@ internal static partial ExceptionStatus saliency_StaticSaliencyFineGrained_compu
[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
internal static partial ExceptionStatus saliency_StaticSaliencyFineGrained_computeBinaryMap(
OpenCvSafeHandle obj, in InputArrayProxy saliencyMap, in OutputArrayProxy binaryMap, out int returnValue);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus saliency_StaticSaliencyFineGrained_write(OpenCvSafeHandle obj, IntPtr fs);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus saliency_StaticSaliencyFineGrained_read(OpenCvSafeHandle obj, IntPtr fn);
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,12 @@ public static partial ExceptionStatus saliency_StaticSaliencySpectralResidual_ge
[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus saliency_StaticSaliencySpectralResidual_setImageHeight(
OpenCvSafeHandle obj, int val);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus saliency_StaticSaliencySpectralResidual_write(
OpenCvSafeHandle obj, IntPtr fs);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus saliency_StaticSaliencySpectralResidual_read(
OpenCvSafeHandle obj, IntPtr fn);
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,8 @@ public static partial ExceptionStatus shape_createShapeContextDistanceExtractor(
[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus shape_ShapeContextDistanceExtractor_setCostExtractor(
OpenCvSafeHandle obj, IntPtr comparer);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus shape_ShapeContextDistanceExtractor_getCostExtractor(
OpenCvSafeHandle obj, out IntPtr returnValue);
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,17 @@ public static partial ExceptionStatus shape_Ptr_AffineTransformer_upcast(
[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus shape_Ptr_ShapeTransformer_delete(IntPtr obj);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus shape_Ptr_ShapeTransformer_get(IntPtr ptr, out IntPtr returnValue);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus shape_Ptr_ShapeTransformer_copy(IntPtr src, out IntPtr returnValue);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus shape_ShapeContextDistanceExtractor_setTransformAlgorithm(
OpenCvSafeHandle obj, IntPtr transformer);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus shape_ShapeContextDistanceExtractor_getTransformAlgorithm(
OpenCvSafeHandle obj, out IntPtr returnValue);
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ public static partial ExceptionStatus stereo_StereoMatcher_getDisp12MaxDiff(
public static partial ExceptionStatus stereo_StereoMatcher_setDisp12MaxDiff(
OpenCvSafeHandle obj, int value);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus stereo_Ptr_StereoMatcher_get(
IntPtr obj, out IntPtr returnValue);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus stereo_Ptr_StereoMatcher_delete(
IntPtr obj);

#endregion

#region StereoBM
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ internal static partial ExceptionStatus superres_DenseOpticalFlowExt_calc(
OpenCvSafeHandle obj, in InputArrayProxy frame0, in InputArrayProxy frame1, in OutputArrayProxy flow1, in OutputArrayProxy flow2);
[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus superres_DenseOpticalFlowExt_collectGarbage(OpenCvSafeHandle obj);


[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus superres_Ptr_DenseOpticalFlowExt_get(IntPtr ptr, out IntPtr returnValue);
[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus superres_Ptr_DenseOpticalFlowExt_delete(IntPtr ptr);

#region FarnebackOpticalFlow

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
using System.Runtime.CompilerServices;
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.Internal;

static partial class NativeMethods
{
// ERFilter::Callback

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus text_Ptr_ERFilterCallback_delete(IntPtr obj);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus text_Ptr_ERFilterCallback_get(IntPtr ptr, out IntPtr returnValue);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus text_loadClassifierNM1(
[MarshalAs(UnmanagedType.LPUTF8Str)] string filename, out IntPtr returnValue);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus text_loadClassifierNM2(
[MarshalAs(UnmanagedType.LPUTF8Str)] string filename, out IntPtr returnValue);

// ERFilter

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus text_Ptr_ERFilter_delete(IntPtr obj);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus text_Ptr_ERFilter_get(IntPtr ptr, out IntPtr returnValue);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus text_createERFilterNM1_callback(
IntPtr cb, int thresholdDelta, float minArea, float maxArea,
float minProbability, int nonMaxSuppression, float minProbabilityDiff, out IntPtr returnValue);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus text_createERFilterNM1_file(
[MarshalAs(UnmanagedType.LPUTF8Str)] string filename, int thresholdDelta, float minArea, float maxArea,
float minProbability, int nonMaxSuppression, float minProbabilityDiff, out IntPtr returnValue);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus text_createERFilterNM2_callback(
IntPtr cb, float minProbability, out IntPtr returnValue);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus text_createERFilterNM2_file(
[MarshalAs(UnmanagedType.LPUTF8Str)] string filename, float minProbability, out IntPtr returnValue);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus text_ERFilter_setCallback(OpenCvSafeHandle obj, IntPtr cb);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus text_ERFilter_setThresholdDelta(OpenCvSafeHandle obj, int thresholdDelta);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus text_ERFilter_setMinArea(OpenCvSafeHandle obj, float minArea);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus text_ERFilter_setMaxArea(OpenCvSafeHandle obj, float maxArea);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus text_ERFilter_setMinProbability(OpenCvSafeHandle obj, float minProbability);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus text_ERFilter_setMinProbabilityDiff(OpenCvSafeHandle obj, float minProbabilityDiff);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus text_ERFilter_setNonMaxSuppression(OpenCvSafeHandle obj, int nonMaxSuppression);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ExceptionStatus text_ERFilter_getNumRejected(OpenCvSafeHandle obj, out int returnValue);

// Free functions

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
internal static partial ExceptionStatus text_computeNMChannels(in InputArrayProxy src, IntPtr channels, int mode);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
internal static partial ExceptionStatus text_detectRegions_contours(
in InputArrayProxy image, IntPtr erFilter1, IntPtr erFilter2, IntPtr regions);

[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
internal static partial ExceptionStatus text_detectRegions_rects(
in InputArrayProxy image, IntPtr erFilter1, IntPtr erFilter2, IntPtr groupsRects,
int method, [MarshalAs(UnmanagedType.LPUTF8Str)] string filename, float minProbability);
}
Loading
Loading