diff --git a/ROADMAP.md b/ROADMAP.md index f686506c..b8ec91d0 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -83,8 +83,8 @@ Your pull requests will be greatly appreciated! - [ ] [rotatedRectangleIntersection](https://docs.opencv.org/master/d3/dc0/group__imgproc__shape.html#ga8740e7645628c59d238b0b22c2abe2d4) - [ ] **Motion Analysis and Object Tracking - WORK STARTED** The following functions still need implementation: - - [ ] [createHanningWindow](https://docs.opencv.org/master/d7/df3/group__imgproc__motion.html#ga80e5c3de52f6bab3a7c1e60e89308e1b) - - [ ] [phaseCorrelate](https://docs.opencv.org/master/d7/df3/group__imgproc__motion.html#ga552420a2ace9ef3fb053cd630fdb4952) + - [X] [createHanningWindow](https://docs.opencv.org/master/d7/df3/group__imgproc__motion.html#ga80e5c3de52f6bab3a7c1e60e89308e1b) + - [X] [phaseCorrelate](https://docs.opencv.org/master/d7/df3/group__imgproc__motion.html#ga552420a2ace9ef3fb053cd630fdb4952) - [ ] **Feature Detection - WORK STARTED** The following functions still need implementation: - [ ] [cornerEigenValsAndVecs](https://docs.opencv.org/master/dd/d1a/group__imgproc__feature.html#ga4055896d9ef77dd3cacf2c5f60e13f1c) diff --git a/imgproc.cpp b/imgproc.cpp index dd65eac1..f2da39a0 100644 --- a/imgproc.cpp +++ b/imgproc.cpp @@ -643,6 +643,11 @@ Point2f PhaseCorrelate(Mat src1, Mat src2, Mat window, double* response) { return result2f; } +void CreateHanningWindow(Mat dst, Size size, int typ) { + cv::Size sz(size.width, size.height); + cv::createHanningWindow(*dst, sz, typ); +} + void Mat_Accumulate(Mat src, Mat dst) { cv::accumulate(*src, *dst); } diff --git a/imgproc.go b/imgproc.go index 80fb091a..07d1e9cd 100644 --- a/imgproc.go +++ b/imgproc.go @@ -1921,6 +1921,19 @@ func PhaseCorrelate(src1, src2, window Mat) (phaseShift Point2f, response float6 }, float64(responseDouble) } +// CreateHanningWindow computes a Hanning window coefficients in two dimensions. +// +// For further details, please see: +// https://docs.opencv.org/4.x/d7/df3/group__imgproc__motion.html#ga80e5c3de52f6bab3a7c1e60e89308e1b +func CreateHanningWindow(img *Mat, size image.Point, typ MatType) { + sz := C.struct_Size{ + width: C.int(size.X), + height: C.int(size.Y), + } + + C.CreateHanningWindow(img.p, sz, C.int(typ)) +} + // ToImage converts a Mat to a image.Image. func (m *Mat) ToImage() (image.Image, error) { switch m.Type() { diff --git a/imgproc.h b/imgproc.h index ec862bd3..9d67517e 100644 --- a/imgproc.h +++ b/imgproc.h @@ -132,6 +132,7 @@ void CLAHE_Close(CLAHE c); void CLAHE_Apply(CLAHE c, Mat src, Mat dst); void InvertAffineTransform(Mat src, Mat dst); Point2f PhaseCorrelate(Mat src1, Mat src2, Mat window, double* response); +void CreateHanningWindow(Mat dst, Size size, int typ); void Mat_Accumulate(Mat src, Mat dst); void Mat_AccumulateWithMask(Mat src, Mat dst, Mat mask); void Mat_AccumulateSquare(Mat src, Mat dst); diff --git a/imgproc_test.go b/imgproc_test.go index 9b975f18..d85bcefb 100644 --- a/imgproc_test.go +++ b/imgproc_test.go @@ -2464,6 +2464,17 @@ func TestPhaseCorrelate(t *testing.T) { } } +func TestCreateHanningWindow(t *testing.T) { + dst := NewMat() + defer dst.Close() + + CreateHanningWindow(&dst, image.Pt(100, 100), MatTypeCV32F) + + if dst.Empty() { + t.Error("Invalid CreateHanningWindow test") + } +} + func TestMatToImage(t *testing.T) { mat1 := NewMatWithSize(101, 102, MatTypeCV8UC3) defer mat1.Close()