Matrix: add mtx.addref() and mtx.getrefCount()

This commit is contained in:
Simon Hailes 2017-11-12 16:03:17 +00:00
parent f7d6b6cdee
commit 96d0eb8824
2 changed files with 40 additions and 0 deletions

View File

@ -117,7 +117,9 @@ void Matrix::Init(Local<Object> target) {
Nan::SetPrototypeMethod(ctor, "mean", Mean);
Nan::SetPrototypeMethod(ctor, "shift", Shift);
Nan::SetPrototypeMethod(ctor, "reshape", Reshape);
Nan::SetPrototypeMethod(ctor, "addref", Addref);
Nan::SetPrototypeMethod(ctor, "release", Release);
Nan::SetPrototypeMethod(ctor, "getrefCount", GetrefCount);
Nan::SetPrototypeMethod(ctor, "subtract", Subtract);
Nan::SetPrototypeMethod(ctor, "compare", Compare);
Nan::SetPrototypeMethod(ctor, "mul", Mul);
@ -3025,6 +3027,41 @@ NAN_METHOD(Matrix::Release) {
return;
}
NAN_METHOD(Matrix::Addref) {
Nan::HandleScope scope;
Matrix *self = Nan::ObjectWrap::Unwrap<Matrix>(info.This());
self->mat.addref();
return;
}
NAN_METHOD(Matrix::GetrefCount) {
Nan::HandleScope scope;
Matrix *self = Nan::ObjectWrap::Unwrap<Matrix>(info.This());
int refcount = -1;
#if CV_MAJOR_VERSION >= 3
if (self->mat.u){
refcount = self->mat.u->refcount;
} else {
refcount = -1;
}
#else
if (self->mat.refcount){
refcount = *self->mat.refcount);
} else {
refcount = -1;
}
#endif
info.GetReturnValue().Set(Nan::New<Number>(refcount));
return;
}
NAN_METHOD(Matrix::Subtract) {
SETUP_FUNCTION(Matrix)

View File

@ -134,7 +134,10 @@ public:
JSFUNC(Shift)
JSFUNC(Reshape)
JSFUNC(Addref)
JSFUNC(Release)
JSFUNC(GetrefCount)
JSFUNC(Subtract)
JSFUNC(Compare)