add bindings for arcLength in contours

This commit is contained in:
Jean-Tiare LE BIGOT 2013-01-20 14:02:48 +01:00
parent 7be98efacf
commit a94bc32d5f
2 changed files with 15 additions and 4 deletions

View File

@ -25,6 +25,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);
target->Set(String::NewSymbol("Contours"), m->GetFunction());
};
@ -55,7 +56,6 @@ Contour::Size(const Arguments &args) {
Contour *self = ObjectWrap::Unwrap<Contour>(args.This());
return scope.Close(Number::New(self->contours.size()));
}
@ -68,6 +68,16 @@ Contour::Area(const Arguments &args) {
//return scope.Close(Number::New(contourArea(self->contours)));
return scope.Close(Number::New(contourArea(cv::Mat(self->contours[pos]))));
}
Handle<Value>
Contour::ArcLength(const Arguments &args) {
HandleScope scope;
Contour *self = ObjectWrap::Unwrap<Contour>(args.This());
int pos = args[0]->NumberValue();
bool isClosed = args[1]->BooleanValue();
return scope.Close(Number::New(arcLength(cv::Mat(self->contours[pos]), isClosed)));
}

View File

@ -11,10 +11,11 @@ class Contour: public node::ObjectWrap {
static void Init(Handle<Object> target);
static Handle<Value> New(const Arguments &args);
Contour();
Contour();
//JSFUNC(Size)
static Handle<Value> Size(const v8::Arguments&);
static Handle<Value> Area(const v8::Arguments&);
static Handle<Value> ArcLength(const v8::Arguments&);
};