diff --git a/binding.gyp b/binding.gyp index 72df9f3..f8b73fa 100755 --- a/binding.gyp +++ b/binding.gyp @@ -20,7 +20,8 @@ # For windows ,'include_dirs': [ - '", "dependencies": { - "buffers": "0.1.1" + "buffers": "0.1.1", + "nan": "^1.3.0" }, "version": "0.5.0", "devDependencies": { diff --git a/src/CamShift.h b/src/CamShift.h index 649a65f..c79b090 100644 --- a/src/CamShift.h +++ b/src/CamShift.h @@ -14,7 +14,8 @@ class TrackedObject: public node::ObjectWrap { static Persistent constructor; static void Init(Handle target); - static Handle New(const Arguments &args); + //static Handle New(const Arguments &args); + static NAN_METHOD(New); TrackedObject(cv::Mat image, cv::Rect rect, int channel); diff --git a/src/CascadeClassifierWrap.h b/src/CascadeClassifierWrap.h index fa42309..fb3c033 100755 --- a/src/CascadeClassifierWrap.h +++ b/src/CascadeClassifierWrap.h @@ -6,13 +6,16 @@ class CascadeClassifierWrap: public node::ObjectWrap { static Persistent constructor; static void Init(Handle target); - static Handle New(const Arguments &args); + //static Handle New(const Arguments &args); + static NAN_METHOD(New); CascadeClassifierWrap(v8::Value* fileName); //static Handle LoadHaarClassifierCascade(const v8::Arguments&); - static Handle DetectMultiScale(const v8::Arguments&); + //static Handle DetectMultiScale(const v8::Arguments&); + static NAN_METHOD(DetectMultiScale); + static void EIO_DetectMultiScale(uv_work_t *req); static int EIO_AfterDetectMultiScale(uv_work_t *req); diff --git a/src/Contours.h b/src/Contours.h index e84c005..e67c37b 100755 --- a/src/Contours.h +++ b/src/Contours.h @@ -9,12 +9,24 @@ class Contour: public node::ObjectWrap { vector > contours; static Persistent constructor; static void Init(Handle target); - static Handle New(const Arguments &args); + //static Handle New(const Arguments &args); + static NAN_METHOD(New); Contour(); - //JSFUNC(Size) - static Handle Point(const v8::Arguments&); + JSFUNC(Point) + JSFUNC(Size) + JSFUNC(CornerCount) + JSFUNC(Area) + JSFUNC(ArcLength) + JSFUNC(ApproxPolyDP) + JSFUNC(ConvexHull) + JSFUNC(BoundingRect) + JSFUNC(MinAreaRect) + JSFUNC(IsConvex) + JSFUNC(Moments) + + /*static Handle Point(const v8::Arguments&); static Handle Size(const v8::Arguments&); static Handle CornerCount(const v8::Arguments&); static Handle Area(const v8::Arguments&); @@ -24,6 +36,6 @@ class Contour: public node::ObjectWrap { static Handle BoundingRect(const v8::Arguments&); static Handle MinAreaRect(const v8::Arguments&); static Handle IsConvex(const v8::Arguments&); - static Handle Moments(const v8::Arguments&); + static Handle Moments(const v8::Arguments&);*/ }; diff --git a/src/FaceRecognizer.h b/src/FaceRecognizer.h index 55404b7..274d691 100644 --- a/src/FaceRecognizer.h +++ b/src/FaceRecognizer.h @@ -11,7 +11,8 @@ class FaceRecognizerWrap: public node::ObjectWrap { static Persistent constructor; static void Init(Handle target); - static Handle New(const Arguments &args); + //static Handle New(const Arguments &args); + static NAN_METHOD(New); FaceRecognizerWrap(cv::Ptr f, int type); diff --git a/src/HighGUI.h b/src/HighGUI.h index 61b5033..faf4ab0 100644 --- a/src/HighGUI.h +++ b/src/HighGUI.h @@ -9,7 +9,8 @@ class NamedWindow: public node::ObjectWrap { static Persistent constructor; static void Init(Handle target); - static Handle New(const Arguments &args); + //static Handle New(const Arguments &args); + static NAN_METHOD(New); NamedWindow(const std::string& winname, int flags); diff --git a/src/Matrix.h b/src/Matrix.h index 3331e44..4ccde47 100755 --- a/src/Matrix.h +++ b/src/Matrix.h @@ -6,7 +6,8 @@ class Matrix: public node::ObjectWrap { cv::Mat mat; static Persistent constructor; static void Init(Handle target); - static Handle New(const Arguments &args); + //static Handle New(const Arguments &args); + static NAN_METHOD(New); Matrix(); Matrix(cv::Mat other, cv::Rect roi); Matrix(int rows, int cols); diff --git a/src/OpenCV.h b/src/OpenCV.h index 83a3cc7..b6d3e33 100755 --- a/src/OpenCV.h +++ b/src/OpenCV.h @@ -9,6 +9,7 @@ #include #include #include +#include using namespace v8; using namespace node; @@ -25,7 +26,8 @@ using namespace node; TYP *self = ObjectWrap::Unwrap(args.This()); #define JSFUNC(NAME) \ - static Handle NAME(const Arguments& args); + NAN_METHOD(NAME); + //static Handle NAME(const Arguments& args); #define JSTHROW_TYPE(ERR) \ return v8::ThrowException(v8::Exception::TypeError(v8::String::New(ERR))); @@ -48,10 +50,11 @@ class OpenCV: public node::ObjectWrap{ public: static void Init(Handle target); - static Handle ReadImage(const v8::Arguments&); - + static NAN_METHOD(ReadImage); + //static Handle ReadImage(const v8::Arguments&); }; + #endif diff --git a/src/Point.h b/src/Point.h index 988c66f..fd5bc84 100755 --- a/src/Point.h +++ b/src/Point.h @@ -7,13 +7,18 @@ class Point: public node::ObjectWrap { CvPoint2D32f point; static Persistent constructor; static void Init(Handle target); - static Handle New(const Arguments &args); + //static Handle New(const Arguments &args); + static NAN_METHOD(New); Point(double x, double y); - - static Handle GetX(Local prop, const AccessorInfo &info); - static Handle GetY(Local prop, const AccessorInfo &info); - static void RaiseImmutable(Local property, Local value, const AccessorInfo& info); - static Handle Dot(const v8::Arguments&); + + //static Handle GetX(Local prop, const AccessorInfo &info); + static NAN_GETTER(GetX); + //static Handle GetY(Local prop, const AccessorInfo &info); + static NAN_GETTER(GetY); + //static void RaiseImmutable(Local property, Local value, const AccessorInfo& info); + static NAN_METHOD(RaiseImmutable); + //static Handle Dot(const v8::Arguments&); + static NAN_METHOD(Dot); }; diff --git a/src/VideoCaptureWrap.h b/src/VideoCaptureWrap.h index 7955406..1118cec 100755 --- a/src/VideoCaptureWrap.h +++ b/src/VideoCaptureWrap.h @@ -6,27 +6,35 @@ class VideoCaptureWrap: public node::ObjectWrap { static Persistent constructor; static void Init(Handle target); - static Handle New(const Arguments &args); + //static Handle New(const Arguments &args); + static NAN_METHOD(New); VideoCaptureWrap(const std::string& filename); VideoCaptureWrap(int device); - static Handle Read(const v8::Arguments&); + //static Handle Read(const v8::Arguments&); + static NAN_METHOD(Read); //(Optional) For setting width and height of the input video stream - static Handle SetWidth(const v8::Arguments&); - static Handle SetHeight(const v8::Arguments&); + //static Handle SetWidth(const v8::Arguments&); + static NAN_METHOD(SetWidth); + + //static Handle SetHeight(const v8::Arguments&); + static NAN_METHOD(SetHeight); // to set frame position - static Handle SetPosition(const v8::Arguments&); + //static Handle SetPosition(const v8::Arguments&); + static NAN_METHOD(SetPosition); - - static Handle GetFrameAt(const v8::Arguments&); + //static Handle GetFrameAt(const v8::Arguments&); + static NAN_METHOD(GetFrameAt); //close the stream - static Handle Close(const v8::Arguments&); + //static Handle Close(const v8::Arguments&); + static NAN_METHOD(Close); //experimental - static Handle ReadSync(const v8::Arguments&); + //static Handle ReadSync(const v8::Arguments&); + static NAN_METHOD(ReadSync); }; diff --git a/src/init.cc b/src/init.cc index 1610800..08df48f 100755 --- a/src/init.cc +++ b/src/init.cc @@ -11,7 +11,8 @@ extern "C" void init(Handle target) { - HandleScope scope; + //HandleScope scope; + NanScope(); OpenCV::Init(target); Point::Init(target); Matrix::Init(target);