mirror of
https://github.com/peterbraden/node-opencv.git
synced 2025-12-08 19:45:55 +00:00
add bindings for arcLength in contours
This commit is contained in:
parent
7be98efacf
commit
a94bc32d5f
@ -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)));
|
||||
}
|
||||
|
||||
@ -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&);
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user