add bindings for isConvex in contours

This commit is contained in:
Jean-Tiare LE BIGOT 2013-01-20 14:20:33 +01:00
parent e3280ddc1e
commit d2e8b1969f
2 changed files with 13 additions and 0 deletions

View File

@ -27,6 +27,7 @@ Contour::Init(Handle<Object> target) {
NODE_SET_PROTOTYPE_METHOD(constructor, "area", Area);
NODE_SET_PROTOTYPE_METHOD(constructor, "arcLength", ArcLength);
NODE_SET_PROTOTYPE_METHOD(constructor, "approxPolyDP", ApproxPolyDP);
NODE_SET_PROTOTYPE_METHOD(constructor, "isConvex", IsConvex);
target->Set(String::NewSymbol("Contours"), m->GetFunction());
};
@ -99,3 +100,14 @@ Contour::ApproxPolyDP(const Arguments &args) {
return scope.Close(v8::Null());
}
Handle<Value>
Contour::IsConvex(const Arguments &args) {
HandleScope scope;
Contour *self = ObjectWrap::Unwrap<Contour>(args.This());
int pos = args[0]->NumberValue();
return scope.Close(Boolean::New(isContourConvex(cv::Mat(self->contours[pos]))));
}

View File

@ -18,5 +18,6 @@ class Contour: public node::ObjectWrap {
static Handle<Value> Area(const v8::Arguments&);
static Handle<Value> ArcLength(const v8::Arguments&);
static Handle<Value> ApproxPolyDP(const v8::Arguments&);
static Handle<Value> IsConvex(const v8::Arguments&);
};