- added nan dependency

- updated binding.gyp
- ported all header files to the nan api
This commit is contained in:
Mark kaosat-dev Moissette 2014-09-10 13:41:09 +02:00
parent 668c21dc44
commit 8db4e0ed2d
12 changed files with 69 additions and 32 deletions

View File

@ -20,7 +20,8 @@
# For windows
,'include_dirs': [
'<!@(pkg-config --cflags opencv)'
'<!@(pkg-config --cflags opencv)',
"<!(node -e \"require('nan')\")"
]
, 'cflags': [
@ -47,4 +48,3 @@
]
}]
}

View File

@ -3,7 +3,8 @@
"description": "Node Bindings to OpenCV",
"author": "Peter Braden <peterbraden@peterbraden.co.uk>",
"dependencies": {
"buffers": "0.1.1"
"buffers": "0.1.1",
"nan": "^1.3.0"
},
"version": "0.5.0",
"devDependencies": {

View File

@ -14,7 +14,8 @@ class TrackedObject: public node::ObjectWrap {
static Persistent<FunctionTemplate> constructor;
static void Init(Handle<Object> target);
static Handle<Value> New(const Arguments &args);
//static Handle<Value> New(const Arguments &args);
static NAN_METHOD(New);
TrackedObject(cv::Mat image, cv::Rect rect, int channel);

View File

@ -6,13 +6,16 @@ class CascadeClassifierWrap: public node::ObjectWrap {
static Persistent<FunctionTemplate> constructor;
static void Init(Handle<Object> target);
static Handle<Value> New(const Arguments &args);
//static Handle<Value> New(const Arguments &args);
static NAN_METHOD(New);
CascadeClassifierWrap(v8::Value* fileName);
//static Handle<Value> LoadHaarClassifierCascade(const v8::Arguments&);
static Handle<Value> DetectMultiScale(const v8::Arguments&);
//static Handle<Value> DetectMultiScale(const v8::Arguments&);
static NAN_METHOD(DetectMultiScale);
static void EIO_DetectMultiScale(uv_work_t *req);
static int EIO_AfterDetectMultiScale(uv_work_t *req);

View File

@ -9,12 +9,24 @@ class Contour: public node::ObjectWrap {
vector<vector<cv::Point> > contours;
static Persistent<FunctionTemplate> constructor;
static void Init(Handle<Object> target);
static Handle<Value> New(const Arguments &args);
//static Handle<Value> New(const Arguments &args);
static NAN_METHOD(New);
Contour();
//JSFUNC(Size)
static Handle<Value> 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<Value> Point(const v8::Arguments&);
static Handle<Value> Size(const v8::Arguments&);
static Handle<Value> CornerCount(const v8::Arguments&);
static Handle<Value> Area(const v8::Arguments&);
@ -24,6 +36,6 @@ class Contour: public node::ObjectWrap {
static Handle<Value> BoundingRect(const v8::Arguments&);
static Handle<Value> MinAreaRect(const v8::Arguments&);
static Handle<Value> IsConvex(const v8::Arguments&);
static Handle<Value> Moments(const v8::Arguments&);
static Handle<Value> Moments(const v8::Arguments&);*/
};

View File

@ -11,7 +11,8 @@ class FaceRecognizerWrap: public node::ObjectWrap {
static Persistent<FunctionTemplate> constructor;
static void Init(Handle<Object> target);
static Handle<Value> New(const Arguments &args);
//static Handle<Value> New(const Arguments &args);
static NAN_METHOD(New);
FaceRecognizerWrap(cv::Ptr<cv::FaceRecognizer> f, int type);

View File

@ -9,7 +9,8 @@ class NamedWindow: public node::ObjectWrap {
static Persistent<FunctionTemplate> constructor;
static void Init(Handle<Object> target);
static Handle<Value> New(const Arguments &args);
//static Handle<Value> New(const Arguments &args);
static NAN_METHOD(New);
NamedWindow(const std::string& winname, int flags);

View File

@ -6,7 +6,8 @@ class Matrix: public node::ObjectWrap {
cv::Mat mat;
static Persistent<FunctionTemplate> constructor;
static void Init(Handle<Object> target);
static Handle<Value> New(const Arguments &args);
//static Handle<Value> New(const Arguments &args);
static NAN_METHOD(New);
Matrix();
Matrix(cv::Mat other, cv::Rect roi);
Matrix(int rows, int cols);

View File

@ -9,6 +9,7 @@
#include <opencv/cv.h>
#include <opencv/highgui.h>
#include <string.h>
#include <nan.h>
using namespace v8;
using namespace node;
@ -25,7 +26,8 @@ using namespace node;
TYP *self = ObjectWrap::Unwrap<TYP>(args.This());
#define JSFUNC(NAME) \
static Handle<Value> NAME(const Arguments& args);
NAN_METHOD(NAME);
//static Handle<Value> 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<Object> target);
static Handle<Value> ReadImage(const v8::Arguments&);
static NAN_METHOD(ReadImage);
//static Handle<Value> ReadImage(const v8::Arguments&);
};
#endif

View File

@ -7,13 +7,18 @@ class Point: public node::ObjectWrap {
CvPoint2D32f point;
static Persistent<FunctionTemplate> constructor;
static void Init(Handle<Object> target);
static Handle<Value> New(const Arguments &args);
//static Handle<Value> New(const Arguments &args);
static NAN_METHOD(New);
Point(double x, double y);
static Handle<Value> GetX(Local<String> prop, const AccessorInfo &info);
static Handle<Value> GetY(Local<String> prop, const AccessorInfo &info);
static void RaiseImmutable(Local<String> property, Local<Value> value, const AccessorInfo& info);
static Handle<Value> Dot(const v8::Arguments&);
//static Handle<Value> GetX(Local<String> prop, const AccessorInfo &info);
static NAN_GETTER(GetX);
//static Handle<Value> GetY(Local<String> prop, const AccessorInfo &info);
static NAN_GETTER(GetY);
//static void RaiseImmutable(Local<String> property, Local<Value> value, const AccessorInfo& info);
static NAN_METHOD(RaiseImmutable);
//static Handle<Value> Dot(const v8::Arguments&);
static NAN_METHOD(Dot);
};

View File

@ -6,27 +6,35 @@ class VideoCaptureWrap: public node::ObjectWrap {
static Persistent<FunctionTemplate> constructor;
static void Init(Handle<Object> target);
static Handle<Value> New(const Arguments &args);
//static Handle<Value> New(const Arguments &args);
static NAN_METHOD(New);
VideoCaptureWrap(const std::string& filename);
VideoCaptureWrap(int device);
static Handle<Value> Read(const v8::Arguments&);
//static Handle<Value> Read(const v8::Arguments&);
static NAN_METHOD(Read);
//(Optional) For setting width and height of the input video stream
static Handle<Value> SetWidth(const v8::Arguments&);
static Handle<Value> SetHeight(const v8::Arguments&);
//static Handle<Value> SetWidth(const v8::Arguments&);
static NAN_METHOD(SetWidth);
//static Handle<Value> SetHeight(const v8::Arguments&);
static NAN_METHOD(SetHeight);
// to set frame position
static Handle<Value> SetPosition(const v8::Arguments&);
//static Handle<Value> SetPosition(const v8::Arguments&);
static NAN_METHOD(SetPosition);
static Handle<Value> GetFrameAt(const v8::Arguments&);
//static Handle<Value> GetFrameAt(const v8::Arguments&);
static NAN_METHOD(GetFrameAt);
//close the stream
static Handle<Value> Close(const v8::Arguments&);
//static Handle<Value> Close(const v8::Arguments&);
static NAN_METHOD(Close);
//experimental
static Handle<Value> ReadSync(const v8::Arguments&);
//static Handle<Value> ReadSync(const v8::Arguments&);
static NAN_METHOD(ReadSync);
};

View File

@ -11,7 +11,8 @@
extern "C" void
init(Handle<Object> target) {
HandleScope scope;
//HandleScope scope;
NanScope();
OpenCV::Init(target);
Point::Init(target);
Matrix::Init(target);