Skip to content

Commit 905fa46

Browse files
authored
feat: add Copy method to Mat (#1346)
* feat: add Copy method to Mat * fix: cpp
1 parent d902275 commit 905fa46

3 files changed

Lines changed: 16 additions & 0 deletions

File tree

core.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@ Mat Mat_Row(Mat m, int r) {
168168
return new cv::Mat(m->row(r));
169169
}
170170

171+
Mat Mat_Copy(Mat m) {
172+
return new cv::Mat(*m);
173+
}
174+
171175
// Mat_Clone returns a clone of this Mat
172176
Mat Mat_Clone(Mat m) {
173177
return new cv::Mat(m->clone());

core.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,17 @@ func (m *Mat) Row(row int) Mat {
437437
return newMat(C.Mat_Row(m.p, C.int(row)))
438438
}
439439

440+
// Copy returns a shallow copy of the Mat. No data is copied.
441+
//
442+
// For further details, please see:
443+
// https://docs.opencv.org/4.x/d3/d63/classcv_1_1Mat.html#a294eaf8a95d2f9c7be19ff594d06278e
444+
func (m *Mat) Copy() Mat {
445+
return Mat{
446+
p: C.Mat_Copy(m.p),
447+
d: m.d,
448+
}
449+
}
450+
440451
// Clone returns a cloned full copy of the Mat.
441452
func (m *Mat) Clone() Mat {
442453
return newMat(C.Mat_Clone(m.p))

core.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ bool Mat_IsContinuous(Mat m);
343343
void Mat_Inv(Mat m);
344344
Mat Mat_Col(Mat m, int c);
345345
Mat Mat_Row(Mat m, int r);
346+
Mat Mat_Copy(Mat m);
346347
Mat Mat_Clone(Mat m);
347348
OpenCVResult Mat_CopyTo(Mat m, Mat dst);
348349
int Mat_Total(Mat m);

0 commit comments

Comments
 (0)