Skip to content

Commit

Permalink
added NewMatFromPoint2fVector function
Browse files Browse the repository at this point in the history
  • Loading branch information
diegohce committed Nov 21, 2024
1 parent f737aab commit 0698277
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ Mat Mat_NewWithSizesFromBytes(IntVector sizes, int type, struct ByteArray buf) {
return new cv::Mat(_sizes, type, buf.data);
}

Mat Mat_NewFromPoint2fVector(Point2fVector pfv, bool copy_data) {
return new cv::Mat(*pfv, copy_data);
}

Mat Eye(int rows, int cols, int type) {
cv::Mat* mat = new cv::Mat(rows, cols, type);
*mat = cv::Mat::eye(rows, cols, type);
Expand Down
8 changes: 7 additions & 1 deletion core.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ func NewMatWithSizesWithScalar(sizes []int, mt MatType, s Scalar) Mat {
return newMat(C.Mat_NewWithSizesFromScalar(sizesVector, C.int(mt), sVal))
}

// NewMatWithSizesWithScalar returns a new multidimensional Mat with a specific size, type and preexisting data.
// NewMatWithSizesFromBytes returns a new multidimensional Mat with a specific size, type and preexisting data.
func NewMatWithSizesFromBytes(sizes []int, mt MatType, data []byte) (Mat, error) {
cBytes, err := toByteArray(data)
if err != nil {
Expand Down Expand Up @@ -312,6 +312,12 @@ func NewMatFromBytes(rows int, cols int, mt MatType, data []byte) (Mat, error) {
return mat, nil
}

// NewMatFromPoint2fVector returns a new Mat from a gocv.Point2fVector.
func NewMatFromPoint2fVector(pfv Point2fVector, copyData bool) Mat {
mat := newMat(C.Mat_NewFromPoint2fVector(pfv.p, C.bool(copyData)))
return mat
}

// Returns an identity matrix of the specified size and type.
//
// The method returns a Matlab-style identity matrix initializer, similarly to Mat::zeros. Similarly to Mat::ones.
Expand Down
1 change: 1 addition & 0 deletions core.h
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ Mat Mat_NewWithSizesFromBytes(IntVector sizes, int type, struct ByteArray buf);
Mat Mat_NewFromScalar(const Scalar ar, int type);
Mat Mat_NewWithSizeFromScalar(const Scalar ar, int rows, int cols, int type);
Mat Mat_NewFromBytes(int rows, int cols, int type, struct ByteArray buf);
Mat Mat_NewFromPoint2fVector(Point2fVector pfv, bool copy_data);
Mat Mat_FromPtr(Mat m, int rows, int cols, int type, int prows, int pcols);
void Mat_Close(Mat m);
int Mat_Empty(Mat m);
Expand Down

0 comments on commit 0698277

Please sign in to comment.