mirror of
https://github.com/peterbraden/node-opencv.git
synced 2025-12-08 19:45:55 +00:00
add countNonZero to Matrix operations
This commit is contained in:
parent
363b950f1e
commit
d60e3d11d5
@ -61,6 +61,7 @@ Matrix::Init(Handle<Object> target) {
|
|||||||
NODE_SET_PROTOTYPE_METHOD(constructor, "absDiff", AbsDiff);
|
NODE_SET_PROTOTYPE_METHOD(constructor, "absDiff", AbsDiff);
|
||||||
NODE_SET_PROTOTYPE_METHOD(constructor, "addWeighted", AddWeighted);
|
NODE_SET_PROTOTYPE_METHOD(constructor, "addWeighted", AddWeighted);
|
||||||
NODE_SET_PROTOTYPE_METHOD(constructor, "bitwiseXor", BitwiseXor);
|
NODE_SET_PROTOTYPE_METHOD(constructor, "bitwiseXor", BitwiseXor);
|
||||||
|
NODE_SET_PROTOTYPE_METHOD(constructor, "countNonZero", CountNonZero);
|
||||||
NODE_SET_PROTOTYPE_METHOD(constructor, "split", Split);
|
NODE_SET_PROTOTYPE_METHOD(constructor, "split", Split);
|
||||||
NODE_SET_PROTOTYPE_METHOD(constructor, "canny", Canny);
|
NODE_SET_PROTOTYPE_METHOD(constructor, "canny", Canny);
|
||||||
NODE_SET_PROTOTYPE_METHOD(constructor, "dilate", Dilate);
|
NODE_SET_PROTOTYPE_METHOD(constructor, "dilate", Dilate);
|
||||||
@ -816,6 +817,16 @@ Matrix::BitwiseXor(const v8::Arguments& args) {
|
|||||||
return scope.Close(v8::Null());
|
return scope.Close(v8::Null());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Handle<Value>
|
||||||
|
Matrix::CountNonZero(const v8::Arguments& args) {
|
||||||
|
HandleScope scope;
|
||||||
|
|
||||||
|
Matrix *self = ObjectWrap::Unwrap<Matrix>(args.This());
|
||||||
|
|
||||||
|
double count = (double)cv::countNonZero(self->mat);
|
||||||
|
return scope.Close(v8::Number::New(count));
|
||||||
|
}
|
||||||
|
|
||||||
Handle<Value>
|
Handle<Value>
|
||||||
Matrix::Split(const v8::Arguments& args) {
|
Matrix::Split(const v8::Arguments& args) {
|
||||||
HandleScope scope;
|
HandleScope scope;
|
||||||
|
|||||||
@ -56,6 +56,7 @@ class Matrix: public node::ObjectWrap {
|
|||||||
JSFUNC(AbsDiff)
|
JSFUNC(AbsDiff)
|
||||||
JSFUNC(AddWeighted)
|
JSFUNC(AddWeighted)
|
||||||
JSFUNC(BitwiseXor)
|
JSFUNC(BitwiseXor)
|
||||||
|
JSFUNC(CountNonZero)
|
||||||
JSFUNC(Split)
|
JSFUNC(Split)
|
||||||
JSFUNC(Canny)
|
JSFUNC(Canny)
|
||||||
JSFUNC(Dilate)
|
JSFUNC(Dilate)
|
||||||
|
|||||||
@ -216,6 +216,15 @@ vows.describe('Smoke Tests OpenCV').addBatch({
|
|||||||
assert.equal(xored.get(0,0), 0);
|
assert.equal(xored.get(0,0), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
, ".countNonZero": function(cv) {
|
||||||
|
cv.readImage("./examples/mona.png", function(err, im) {
|
||||||
|
assert.ok(im);
|
||||||
|
|
||||||
|
im.convertGrayscale();
|
||||||
|
assert.equal(im.countNonZero(), 378000);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user