mirror of
https://github.com/peterbraden/node-opencv.git
synced 2025-12-08 19:45:55 +00:00
comment out Addref - too dangerous to leave in. Modify test example.
This commit is contained in:
parent
2c1732f0c4
commit
bc8095534b
@ -4,27 +4,19 @@ cv.readImage('./files/mona.png', function(err, im) {
|
||||
if (err) throw err;
|
||||
if (im.width() < 1 || im.height() < 1) throw new Error('Image has no size');
|
||||
|
||||
|
||||
// getrefCount will give the refcount. if > 0, then a reference ptr is present, and the value returned.
|
||||
// if -1, no reference pointer was present (i.e. the mat does not know about any data).
|
||||
var refcount = im.getrefCount();
|
||||
console.log('initial refcount '+refcount);
|
||||
if (refcount !== 1)
|
||||
throw "refcountmismatch - initial should be 1";
|
||||
|
||||
im.addref();
|
||||
var refcount2 = im.getrefCount();
|
||||
console.log('refcount after addref '+refcount2);
|
||||
if (refcount2 !== (refcount + 1))
|
||||
throw "refcountmismatch";
|
||||
|
||||
im.addref();
|
||||
refcount2 = im.getrefCount();
|
||||
console.log('refcount after addref 2 '+refcount2);
|
||||
if (refcount2 !== (refcount + 2))
|
||||
throw "refcountmismatch";
|
||||
|
||||
|
||||
im.release();
|
||||
var refcount3 = im.getrefCount();
|
||||
console.log('refcount after release (seems should be -1) '+refcount3);
|
||||
if (refcount3 !== -1)
|
||||
throw "refcountmismatch";
|
||||
throw "refcountmismatch - after release should be -1";
|
||||
|
||||
// data is now still there somewhere, but lost to us - this is NOT a good situation.
|
||||
|
||||
|
||||
@ -117,7 +117,8 @@ 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);
|
||||
// leave this out - can't see a way it could be useful to us, as release() always completely forgets the data
|
||||
// Nan::SetPrototypeMethod(ctor, "addref", Addref);
|
||||
Nan::SetPrototypeMethod(ctor, "release", Release);
|
||||
Nan::SetPrototypeMethod(ctor, "getrefCount", GetrefCount);
|
||||
Nan::SetPrototypeMethod(ctor, "subtract", Subtract);
|
||||
@ -3027,14 +3028,15 @@ NAN_METHOD(Matrix::Release) {
|
||||
return;
|
||||
}
|
||||
|
||||
NAN_METHOD(Matrix::Addref) {
|
||||
Nan::HandleScope scope;
|
||||
|
||||
Matrix *self = Nan::ObjectWrap::Unwrap<Matrix>(info.This());
|
||||
self->mat.addref();
|
||||
|
||||
return;
|
||||
}
|
||||
// leave this out - can't see a way it could be useful to us, as release() always completely forgets the data
|
||||
//NAN_METHOD(Matrix::Addref) {
|
||||
// Nan::HandleScope scope;
|
||||
//
|
||||
// Matrix *self = Nan::ObjectWrap::Unwrap<Matrix>(info.This());
|
||||
// self->mat.addref();
|
||||
//
|
||||
// return;
|
||||
//}
|
||||
|
||||
|
||||
NAN_METHOD(Matrix::GetrefCount) {
|
||||
@ -3047,13 +3049,13 @@ NAN_METHOD(Matrix::GetrefCount) {
|
||||
if (self->mat.u){
|
||||
refcount = self->mat.u->refcount;
|
||||
} else {
|
||||
refcount = -1;
|
||||
refcount = -1; // indicates no reference ptr
|
||||
}
|
||||
#else
|
||||
if (self->mat.refcount){
|
||||
refcount = *(self->mat.refcount);
|
||||
} else {
|
||||
refcount = -1;
|
||||
refcount = -1; // indicates no reference ptr
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user