mirror of
https://github.com/peterbraden/node-opencv.git
synced 2025-12-08 19:45:55 +00:00
Add ConvexHull binding for Contours class
This commit is contained in:
parent
4f7968e567
commit
84e5f255df
@ -29,6 +29,7 @@ Contour::Init(Handle<Object> target) {
|
|||||||
NODE_SET_PROTOTYPE_METHOD(constructor, "area", Area);
|
NODE_SET_PROTOTYPE_METHOD(constructor, "area", Area);
|
||||||
NODE_SET_PROTOTYPE_METHOD(constructor, "arcLength", ArcLength);
|
NODE_SET_PROTOTYPE_METHOD(constructor, "arcLength", ArcLength);
|
||||||
NODE_SET_PROTOTYPE_METHOD(constructor, "approxPolyDP", ApproxPolyDP);
|
NODE_SET_PROTOTYPE_METHOD(constructor, "approxPolyDP", ApproxPolyDP);
|
||||||
|
NODE_SET_PROTOTYPE_METHOD(constructor, "convexHull", ConvexHull);
|
||||||
NODE_SET_PROTOTYPE_METHOD(constructor, "boundingRect", BoundingRect);
|
NODE_SET_PROTOTYPE_METHOD(constructor, "boundingRect", BoundingRect);
|
||||||
NODE_SET_PROTOTYPE_METHOD(constructor, "minAreaRect", BoundingRect);
|
NODE_SET_PROTOTYPE_METHOD(constructor, "minAreaRect", BoundingRect);
|
||||||
NODE_SET_PROTOTYPE_METHOD(constructor, "isConvex", IsConvex);
|
NODE_SET_PROTOTYPE_METHOD(constructor, "isConvex", IsConvex);
|
||||||
@ -135,6 +136,23 @@ Contour::ApproxPolyDP(const Arguments &args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Handle<Value>
|
||||||
|
Contour::ConvexHull(const Arguments &args) {
|
||||||
|
HandleScope scope;
|
||||||
|
|
||||||
|
Contour *self = ObjectWrap::Unwrap<Contour>(args.This());
|
||||||
|
|
||||||
|
int pos = args[0]->NumberValue();
|
||||||
|
bool clockwise = args[1]->BooleanValue();
|
||||||
|
|
||||||
|
cv::Mat hull;
|
||||||
|
cv::convexHull(cv::Mat(self->contours[pos]), hull, clockwise);
|
||||||
|
hull.copyTo(self->contours[pos]);
|
||||||
|
|
||||||
|
return scope.Close(v8::Null());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Handle<Value>
|
Handle<Value>
|
||||||
Contour::BoundingRect(const Arguments &args) {
|
Contour::BoundingRect(const Arguments &args) {
|
||||||
HandleScope scope;
|
HandleScope scope;
|
||||||
|
|||||||
@ -20,6 +20,7 @@ class Contour: public node::ObjectWrap {
|
|||||||
static Handle<Value> Area(const v8::Arguments&);
|
static Handle<Value> Area(const v8::Arguments&);
|
||||||
static Handle<Value> ArcLength(const v8::Arguments&);
|
static Handle<Value> ArcLength(const v8::Arguments&);
|
||||||
static Handle<Value> ApproxPolyDP(const v8::Arguments&);
|
static Handle<Value> ApproxPolyDP(const v8::Arguments&);
|
||||||
|
static Handle<Value> ConvexHull(const v8::Arguments&);
|
||||||
static Handle<Value> BoundingRect(const v8::Arguments&);
|
static Handle<Value> BoundingRect(const v8::Arguments&);
|
||||||
static Handle<Value> MinAreaRect(const v8::Arguments&);
|
static Handle<Value> MinAreaRect(const v8::Arguments&);
|
||||||
static Handle<Value> IsConvex(const v8::Arguments&);
|
static Handle<Value> IsConvex(const v8::Arguments&);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user