Skip to content

Commit

Permalink
imgproc: add CreateHanningWindow()
Browse files Browse the repository at this point in the history
Signed-off-by: deadprogram <[email protected]>
  • Loading branch information
deadprogram committed Oct 19, 2023
1 parent 3a6191e commit 2c0b2b9
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions imgproc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
13 changes: 13 additions & 0 deletions imgproc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
1 change: 1 addition & 0 deletions imgproc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
11 changes: 11 additions & 0 deletions imgproc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 2c0b2b9

Please sign in to comment.