Skip to content

Commit e249162

Browse files
authored
Merge pull request #340 from nicholasc/reduce
Implemented Mat reduce
2 parents a7d96ae + 6b1423a commit e249162

File tree

7 files changed

+607
-523
lines changed

7 files changed

+607
-523
lines changed

cc/core/Mat.cc

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ NAN_MODULE_INIT(Mat::Init) {
9191
Nan::SetPrototypeMethod(ctor, "meanStdDevAsync", MeanStdDevAsync);
9292
Nan::SetPrototypeMethod(ctor, "copyMakeBorder", CopyMakeBorder);
9393
Nan::SetPrototypeMethod(ctor, "copyMakeBorderAsync", CopyMakeBorderAsync);
94+
Nan::SetPrototypeMethod(ctor, "reduce", Reduce);
95+
Nan::SetPrototypeMethod(ctor, "reduceAsync", ReduceAsync);
9496
#if CV_VERSION_MINOR > 1
9597
Nan::SetPrototypeMethod(ctor, "rotate", Rotate);
9698
Nan::SetPrototypeMethod(ctor, "rotateAsync", RotateAsync);
@@ -191,7 +193,7 @@ NAN_METHOD(Mat::New) {
191193
self->setNativeProps(mat);
192194
}
193195
self->Wrap(info.Holder());
194-
196+
195197
// if ExternalMemTracking is disabled, the following instruction will be a no op
196198
// notes: I *think* New should be called in JS thread where cv::mat has been created async,
197199
// so a good place to rationalise memory
@@ -823,6 +825,22 @@ NAN_METHOD(Mat::CopyMakeBorderAsync) {
823825
);
824826
}
825827

828+
NAN_METHOD(Mat::Reduce) {
829+
FF::SyncBinding(
830+
std::make_shared<MatBindings::ReduceWorker>(Mat::Converter::unwrap(info.This())),
831+
"Mat::Reduce",
832+
info
833+
);
834+
}
835+
836+
NAN_METHOD(Mat::ReduceAsync) {
837+
FF::AsyncBinding(
838+
std::make_shared<MatBindings::ReduceWorker>(Mat::Converter::unwrap(info.This())),
839+
"Mat::ReduceAsync",
840+
info
841+
);
842+
}
843+
826844
#if CV_VERSION_MINOR > 1
827845
NAN_METHOD(Mat::Rotate) {
828846
FF::SyncBinding(
@@ -839,4 +857,4 @@ NAN_METHOD(Mat::RotateAsync) {
839857
info
840858
);
841859
}
842-
#endif
860+
#endif

cc/core/Mat.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,13 @@ class Mat : public Nan::ObjectWrap {
122122
static NAN_METHOD(MeanStdDevAsync);
123123
static NAN_METHOD(CopyMakeBorder);
124124
static NAN_METHOD(CopyMakeBorderAsync);
125+
static NAN_METHOD(Reduce);
126+
static NAN_METHOD(ReduceAsync);
125127
#if CV_VERSION_MINOR > 1
126128
static NAN_METHOD(Rotate);
127129
static NAN_METHOD(RotateAsync);
128130
#endif
129131

130132
};
131133

132-
#endif
134+
#endif

0 commit comments

Comments
 (0)