add bindings for approxPolyDP in contours

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

View File

@ -26,6 +26,7 @@ Contour::Init(Handle<Object> target) {
NODE_SET_PROTOTYPE_METHOD(constructor, "size", Size);
NODE_SET_PROTOTYPE_METHOD(constructor, "area", Area);
NODE_SET_PROTOTYPE_METHOD(constructor, "arcLength", ArcLength);
NODE_SET_PROTOTYPE_METHOD(constructor, "approxPolyDP", ApproxPolyDP);
target->Set(String::NewSymbol("Contours"), m->GetFunction());
};
@ -81,3 +82,20 @@ Contour::ArcLength(const Arguments &args) {
return scope.Close(Number::New(arcLength(cv::Mat(self->contours[pos]), isClosed)));
}
Handle<Value>
Contour::ApproxPolyDP(const Arguments &args) {
HandleScope scope;
Contour *self = ObjectWrap::Unwrap<Contour>(args.This());
int pos = args[0]->NumberValue();
bool epsilon = args[1]->NumberValue();
bool isClosed = args[2]->BooleanValue();
cv::Mat approxed;
approxPolyDP(cv::Mat(self->contours[pos]), approxed, epsilon, isClosed);
approxed.copyTo(self->contours[pos]);
return scope.Close(v8::Null());
}

View File

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