Skip to content

Commit

Permalink
add bindings for cornerCount (size in OpenCV) in contours + fix bool …
Browse files Browse the repository at this point in the history
…instead of double in approxPolyDP
  • Loading branch information
Jean-Tiare LE BIGOT committed Jan 20, 2013
1 parent d2e8b19 commit abf5e99
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/Contours.cc
Expand Up @@ -24,6 +24,7 @@ Contour::Init(Handle<Object> target) {


NODE_SET_PROTOTYPE_METHOD(constructor, "size", Size);
NODE_SET_PROTOTYPE_METHOD(constructor, "cornerCount", CornerCount);
NODE_SET_PROTOTYPE_METHOD(constructor, "area", Area);
NODE_SET_PROTOTYPE_METHOD(constructor, "arcLength", ArcLength);
NODE_SET_PROTOTYPE_METHOD(constructor, "approxPolyDP", ApproxPolyDP);
Expand Down Expand Up @@ -51,6 +52,9 @@ Contour::Contour(): ObjectWrap() {
}


// FIXME: this sould better be called "Length" as ``Contours`` is an Array like structure
// also, this would allow to use ``Size`` for the function returning the number of corners
// in the contour for better consistency with OpenCV.
Handle<Value>
Contour::Size(const Arguments &args) {
HandleScope scope;
Expand All @@ -60,6 +64,15 @@ Contour::Size(const Arguments &args) {
return scope.Close(Number::New(self->contours.size()));
}

Handle<Value>
Contour::CornerCount(const Arguments &args) {
HandleScope scope;

Contour *self = ObjectWrap::Unwrap<Contour>(args.This());
int pos = args[0]->NumberValue();

return scope.Close(Number::New(self->contours[pos].size()));
}

Handle<Value>
Contour::Area(const Arguments &args) {
Expand Down Expand Up @@ -91,7 +104,7 @@ Contour::ApproxPolyDP(const Arguments &args) {

Contour *self = ObjectWrap::Unwrap<Contour>(args.This());
int pos = args[0]->NumberValue();
bool epsilon = args[1]->NumberValue();
double epsilon = args[1]->NumberValue();
bool isClosed = args[2]->BooleanValue();

cv::Mat approxed;
Expand Down
1 change: 1 addition & 0 deletions src/Contours.h
Expand Up @@ -15,6 +15,7 @@ class Contour: public node::ObjectWrap {

//JSFUNC(Size)
static Handle<Value> Size(const v8::Arguments&);
static Handle<Value> CornerCount(const v8::Arguments&);
static Handle<Value> Area(const v8::Arguments&);
static Handle<Value> ArcLength(const v8::Arguments&);
static Handle<Value> ApproxPolyDP(const v8::Arguments&);
Expand Down

0 comments on commit abf5e99

Please sign in to comment.