Skip to content

Commit

Permalink
Added CvInvoke.ReduceArgMin & CvInvoke.ReduceArgMax
Browse files Browse the repository at this point in the history
  • Loading branch information
emgucv committed May 21, 2024
1 parent 554c558 commit b5884d8
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Emgu.CV.Extern/core/core_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,16 @@ void cveMinMaxLoc(cv::_InputArray* src, double* minVal, double* maxVal, CvPoint*
maxLoc->x = maxPt.x; maxLoc->y = maxPt.y;
}

void cveReduceArgMin(cv::_InputArray* src, cv::_OutputArray* dst, int axis, bool lastIndex)
{
cv::reduceArgMin(*src, *dst, axis, lastIndex);
}

void cveReduceArgMax(cv::_InputArray* src, cv::_OutputArray* dst, int axis, bool lastIndex)
{
cv::reduceArgMax(*src, *dst, axis, lastIndex);
}

void cveBitwiseAnd(cv::_InputArray* src1, cv::_InputArray* src2, cv::_OutputArray* dst, cv::_InputArray* mask)
{
cv::bitwise_and(*src1, *src2, *dst, mask ? *mask : static_cast<cv::InputArray>(cv::noArray()));
Expand Down
2 changes: 2 additions & 0 deletions Emgu.CV.Extern/core/core_c_extra.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ CVAPI(void) cveScalarRelease(cv::Scalar** scalar);

CVAPI(void) cveMinMaxIdx(cv::_InputArray* src, double* minVal, double* maxVal, int* minIdx, int* maxIdx, cv::_InputArray* mask);
CVAPI(void) cveMinMaxLoc(cv::_InputArray* src, double* minVal, double* maxVal, CvPoint* minLoc, CvPoint* macLoc, cv::_InputArray* mask);
CVAPI(void) cveReduceArgMin(cv::_InputArray* src, cv::_OutputArray* dst, int axis, bool lastIndex);
CVAPI(void) cveReduceArgMax(cv::_InputArray* src, cv::_OutputArray* dst, int axis, bool lastIndex);

CVAPI(void) cveBitwiseAnd(cv::_InputArray* src1, cv::_InputArray* src2, cv::_OutputArray* dst, cv::_InputArray* mask);
CVAPI(void) cveBitwiseNot(cv::_InputArray* src, cv::_OutputArray* dst, cv::_InputArray* mask);
Expand Down
57 changes: 57 additions & 0 deletions Emgu.CV/PInvoke/CvInvokeCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2292,6 +2292,63 @@ public static IntPtr cvCvtSeqToArray(IntPtr seq, IntPtr elements, MCvSlice slice
ref Point maxLoc,
IntPtr mask);

/// <summary>
/// Finds indices of min elements along provided axis.
/// </summary>
/// <param name="src">Input single-channel array.</param>
/// <param name="dst">Output array of type CV_32SC1 with the same dimensionality as src, except for axis being reduced - it should be set to 1.</param>
/// <param name="axis">Axis to reduce along.</param>
/// <param name="lastIndex">Whether to get the index of first or last occurrence of min.</param>
public static void ReduceArgMin(
IInputArray src,
IOutputArray dst,
int axis,
bool lastIndex = false)
{
using (InputArray iaSrc = src.GetInputArray())
using (OutputArray oaDst = dst.GetOutputArray())
{
cveReduceArgMin(iaSrc, oaDst, axis, lastIndex);
}
}

[DllImport(ExternLibrary, CallingConvention = CvInvoke.CvCallingConvention)]
private static extern void cveReduceArgMin(
IntPtr src,
IntPtr dst,
int axis,
[MarshalAs(BoolMarshalType)]
bool lastIndex);


/// <summary>
/// Finds indices of max elements along provided axis.
/// </summary>
/// <param name="src">Input single-channel array.</param>
/// <param name="dst">Output array of type CV_32SC1 with the same dimensionality as src, except for axis being reduced - it should be set to 1.</param>
/// <param name="axis">Axis to reduce along.</param>
/// <param name="lastIndex">Whether to get the index of first or last occurrence of max.</param>
public static void ReduceArgMax(
IInputArray src,
IOutputArray dst,
int axis,
bool lastIndex = false)
{
using (InputArray iaSrc = src.GetInputArray())
using (OutputArray oaDst = dst.GetOutputArray())
{
cveReduceArgMax(iaSrc, oaDst, axis, lastIndex);
}
}

[DllImport(ExternLibrary, CallingConvention = CvInvoke.CvCallingConvention)]
private static extern void cveReduceArgMax(
IntPtr src,
IntPtr dst,
int axis,
[MarshalAs(BoolMarshalType)]
bool lastIndex);

/// <summary>
/// Copies the source 2D array into interior of destination array and makes a border of the specified type around the copied area. The function is useful when one needs to emulate border type that is different from the one embedded into a specific algorithm implementation. For example, morphological functions, as well as most of other filtering functions in OpenCV, internally use replication border type, while the user may need zero border or a border, filled with 1's or 255's
/// </summary>
Expand Down

0 comments on commit b5884d8

Please sign in to comment.