Skip to content

Commit

Permalink
Add additional signature for MinMaxLoc.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelarusso committed Oct 5, 2023
1 parent 4f45958 commit 2d28b9a
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
11 changes: 11 additions & 0 deletions core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,17 @@ void Mat_MinMaxLoc(Mat m, double* minVal, double* maxVal, Point* minLoc, Point*
maxLoc->y = cMaxLoc.y;
}

void Mat_MinMaxLocWithMask(Mat m, double* minVal, double* maxVal, Point* minLoc, Point* maxLoc, Mat mask) {
cv::Point cMinLoc;
cv::Point cMaxLoc;
cv::minMaxLoc(*m, minVal, maxVal, &cMinLoc, &cMaxLoc, *mask);

minLoc->x = cMinLoc.x;
minLoc->y = cMinLoc.y;
maxLoc->x = cMaxLoc.x;
maxLoc->y = cMaxLoc.y;
}

void Mat_MixChannels(struct Mats src, struct Mats dst, struct IntVector fromTo) {
std::vector<cv::Mat> srcMats;

Expand Down
19 changes: 19 additions & 0 deletions core.go
Original file line number Diff line number Diff line change
Expand Up @@ -1534,6 +1534,25 @@ func MinMaxLoc(input Mat) (minVal, maxVal float32, minLoc, maxLoc image.Point) {
return float32(cMinVal), float32(cMaxVal), minLoc, maxLoc
}

// MinMaxLocWithMask finds the global minimum and maximum in an array with a mask used to select a sub-array.
//
// For further details, please see:
// https://docs.opencv.org/trunk/d2/de8/group__core__array.html#gab473bf2eb6d14ff97e89b355dac20707
//
func MinMaxLocWithMask(input Mat, mask Mat) (minVal, maxVal float32, minLoc, maxLoc image.Point) {
var cMinVal C.double
var cMaxVal C.double
var cMinLoc C.struct_Point
var cMaxLoc C.struct_Point

C.Mat_MinMaxLocWithMask(input.p, &cMinVal, &cMaxVal, &cMinLoc, &cMaxLoc, mask.p)

minLoc = image.Pt(int(cMinLoc.x), int(cMinLoc.y))
maxLoc = image.Pt(int(cMaxLoc.x), int(cMaxLoc.y))

return float32(cMinVal), float32(cMaxVal), minLoc, maxLoc
}

// Copies specified channels from input arrays to the specified channels of output arrays.
//
// For further details, please see:
Expand Down
1 change: 1 addition & 0 deletions core.h
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ void Mat_Merge(struct Mats mats, Mat dst);
void Mat_Min(Mat src1, Mat src2, Mat dst);
void Mat_MinMaxIdx(Mat m, double* minVal, double* maxVal, int* minIdx, int* maxIdx);
void Mat_MinMaxLoc(Mat m, double* minVal, double* maxVal, Point* minLoc, Point* maxLoc);
void Mat_MinMaxLocWithMask(Mat m, double* minVal, double* maxVal, Point* minLoc, Point* maxLoc, Mat mask);
void Mat_MixChannels(struct Mats src, struct Mats dst, struct IntVector fromTo);
void Mat_MulSpectrums(Mat a, Mat b, Mat c, int flags);
void Mat_Multiply(Mat src1, Mat src2, Mat dst);
Expand Down

0 comments on commit 2d28b9a

Please sign in to comment.