Skip to content

Commit

Permalink
Merge pull request hybridgroup#166 from kylycht/feature/rotate
Browse files Browse the repository at this point in the history
Feature/core
  • Loading branch information
deadprogram authored Apr 12, 2018
2 parents a0b3520 + 342873d commit 3fd1b7f
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 0 deletions.
8 changes: 8 additions & 0 deletions core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,14 @@ void Mat_Hconcat(Mat src1, Mat src2, Mat dst) {
cv::hconcat(*src1, *src2, *dst);
}

void Mat_Vconcat(Mat src1, Mat src2, Mat dst) {
cv::vconcat(*src1, *src2, *dst);
}

void Rotate(Mat src, Mat dst, int rotateCode) {
cv::rotate(*src, *dst, rotateCode);
}

void Mat_Idct(Mat src, Mat dst, int flags) {
cv::idct(*src, *dst, flags);
}
Expand Down
17 changes: 17 additions & 0 deletions core.go
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,23 @@ func Hconcat(src1, src2 Mat, dst *Mat) {
C.Mat_Hconcat(src1.p, src2.p, dst.p)
}

// Vconcat applies vertical concatenation to given matrices.
//
// For further details, please see:
// https://docs.opencv.org/master/d2/de8/group__core__array.html#gaab5ceee39e0580f879df645a872c6bf7
//
func Vconcat(src1, src2 Mat, dst *Mat) {
C.Mat_Vconcat(src1.p, src2.p, dst.p)
}

// Rotate rotates a 2D array in multiples of 90 degrees
//
// For further details, please see:
// https://docs.opencv.org/master/d2/de8/group__core__array.html#ga4ad01c0978b0ce64baa246811deeac24
func Rotate(src Mat, dst *Mat, code int) {
C.Rotate(src.p, dst.p, C.int(code))
}

// IDCT calculates the inverse Discrete Cosine Transform of a 1D or 2D array.
//
// For further details, please see:
Expand Down
2 changes: 2 additions & 0 deletions core.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ void Mat_Flip(Mat src, Mat dst, int flipCode);
void Mat_Gemm(Mat src1, Mat src2, double alpha, Mat src3, double beta, Mat dst, int flags);
int Mat_GetOptimalDFTSize(int vecsize);
void Mat_Hconcat(Mat src1, Mat src2, Mat dst);
void Mat_Vconcat(Mat src1, Mat src2, Mat dst);
void Rotate(Mat src, Mat dst, int rotationCode);
void Mat_Idct(Mat src, Mat dst, int flags);
void Mat_Idft(Mat src, Mat dst, int flags, int nonzeroRows);
void Mat_InRange(Mat src, Mat lowerb, Mat upperb, Mat dst);
Expand Down
29 changes: 29 additions & 0 deletions core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,35 @@ func TestMatHconcat(t *testing.T) {
}
}

func TestMatVconcat(t *testing.T) {
src := NewMatWithSize(10, 10, MatTypeCV32F)
defer src.Close()

dst := NewMat()
defer dst.Close()

Vconcat(src, src, &dst)

if dst.Empty() {
t.Error("TestMatVconcat dst should not be empty.")
}
if dst.Rows() != 2*src.Rows() {
t.Error("TestMatVconcat dst.Cols should be 2 x src.Rows().")
}
}

func TestRotate(t *testing.T) {
src := NewMatWithSize(1, 2, MatTypeCV64F)
defer src.Close()
dst := NewMat()
defer dst.Close()

Rotate(src, &dst, 0)
if dst.Rows() != 2 {
t.Errorf("expected rows: %d got %d", src.Cols(), dst.Rows())
}
}

func TestMatIdct(t *testing.T) {
src := NewMatWithSize(4, 4, MatTypeCV32F)
defer src.Close()
Expand Down

0 comments on commit 3fd1b7f

Please sign in to comment.