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