- overall cleanup :

* removed obsolete code , comments
This commit is contained in:
Mark Moissette 2014-09-30 21:49:24 +02:00
parent a5a4b59ff3
commit a42033ac96
14 changed files with 10 additions and 74 deletions

View File

@ -26,7 +26,6 @@ TrackedObject::Init(Handle<Object> target) {
NODE_SET_PROTOTYPE_METHOD(ctor, "track", Track);
//target->Set(String::NewSymbol("TrackedObject"), constructor->GetFunction());
target->Set(NanNew("TrackedObject"), ctor->GetFunction());
};

View File

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

View File

@ -69,7 +69,6 @@ class AsyncDetectMultiScale : public NanAsyncWorker {
void HandleOKCallback () {
NanScope();
// ev_unref(EV_DEFAULT_UC);
// this->matrix->Unref();
v8::Local<v8::Array> arr = NanNew<v8::Array>(this->res.size());
@ -107,17 +106,6 @@ class AsyncDetectMultiScale : public NanAsyncWorker {
int sleep_for;
std::vector<cv::Rect> res;
/* baton->cc = self;
baton->cb = Persistent<Function>::New(cb);
baton->im = im;
baton->scale = scale;
baton->neighbors = neighbors;
baton->minw = minw;
baton->minh = minh;
baton->sleep_for = 1;
baton->request.data = baton;
};*/
};
@ -150,13 +138,6 @@ NAN_METHOD(CascadeClassifierWrap::DetectMultiScale){
minh = args[5]->IntegerValue();
}
//FIXME: convert async
/* classifier_baton_t *baton = new classifier_baton_t();
// eio_custom(EIO_DetectMultiScale, EIO_PRI_DEFAULT, EIO_AfterDetectMultiScale, baton);
// ev_ref(EV_DEFAULT_UC);
uv_queue_work(uv_default_loop(), &baton->request, AsyncDetectMultiScale, (uv_after_work_cb)AfterAsyncDetectMultiScale);*/
NanCallback *callback = new NanCallback(cb.As<Function>());

View File

@ -6,14 +6,12 @@ class CascadeClassifierWrap: public node::ObjectWrap {
static Persistent<FunctionTemplate> constructor;
static void Init(Handle<Object> target);
//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> LoadHaarClassifierCascade(const v8::Arguments&);
//static Handle<Value> DetectMultiScale(const v8::Arguments&);
static NAN_METHOD(DetectMultiScale);
static void EIO_DetectMultiScale(uv_work_t *req);

View File

@ -12,7 +12,6 @@ Contour::Init(Handle<Object> target) {
NanScope();
//Class/contructor
Local<FunctionTemplate> ctor = NanNew<FunctionTemplate>(Contour::New);
NanAssignPersistent(constructor, ctor);
ctor->InstanceTemplate()->SetInternalFieldCount(1);
@ -21,8 +20,6 @@ Contour::Init(Handle<Object> target) {
// Prototype
//Local<ObjectTemplate> proto = constructor->PrototypeTemplate();
NODE_SET_PROTOTYPE_METHOD(ctor, "point", Point);
NODE_SET_PROTOTYPE_METHOD(ctor, "size", Size);
NODE_SET_PROTOTYPE_METHOD(ctor, "cornerCount", CornerCount);

View File

@ -9,7 +9,6 @@ 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 NAN_METHOD(New);
Contour();

View File

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

View File

@ -16,8 +16,6 @@ NamedWindow::Init(Handle<Object> target) {
ctor->SetClassName(NanNew("NamedWindow"));
// Prototype
//Local<ObjectTemplate> proto = constructor->PrototypeTemplate();
NODE_SET_PROTOTYPE_METHOD(ctor, "show", Show);
NODE_SET_PROTOTYPE_METHOD(ctor, "destroy", Destroy);
NODE_SET_PROTOTYPE_METHOD(ctor, "blockingWaitKey", BlockingWaitKey);

View File

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

View File

@ -22,7 +22,6 @@ Matrix::Init(Handle<Object> target) {
ctor->SetClassName(NanNew("Matrix"));
// Prototype
NODE_SET_PROTOTYPE_METHOD(ctor, "row", Row);
NODE_SET_PROTOTYPE_METHOD(ctor, "col", Col);
@ -279,7 +278,6 @@ NAN_METHOD(Matrix::Size){
NAN_METHOD(Matrix::Clone){
SETUP_FUNCTION(Matrix)
//Local<FunctionTemplate> constructorHandle = NanNew(Matrix::constructor);
Local<Object> im_h = NanNew(Matrix::constructor)->GetFunction()->NewInstance();
Matrix *m = ObjectWrap::Unwrap<Matrix>(im_h);
@ -418,15 +416,12 @@ NAN_METHOD(Matrix::ToBuffer){
std::vector<uchar> vec(0);
// We use operator * before the "ext" variable, because it converts String to char *
cv::imencode(ext, self->mat, vec, params);
//Local<Object> buf = NanNewBufferHandle((char*)closure->data, closure->len);
//memcpy(Buffer::Data(buf), closure->data, closure->len);
cv::imencode(ext, self->mat, vec, params);
Local<Object> buf = NanNewBufferHandle(vec.size());
uchar* data = (uchar*) Buffer::Data(buf);
memcpy(data, &vec[0], vec.size());//dest, source, size
memcpy(data, &vec[0], vec.size());
v8::Local<v8::Object> globalObj = NanGetCurrentContext()->Global();
v8::Local<v8::Function> bufferConstructor = v8::Local<v8::Function>::Cast(globalObj->Get(NanNew<String>("Buffer")));
@ -454,15 +449,12 @@ class AsyncToBufferWorker : public NanAsyncWorker {
res = vec;
}
// Executed when the async work is complete
// this function will be run inside the main event loop
// so it is safe to use V8 again
void HandleOKCallback () {
NanScope();
Local<Object> buf = NanNewBufferHandle(res.size());
uchar* data = (uchar*) Buffer::Data(buf);
memcpy(data, &res[0], res.size());//dest, source, size
memcpy(data, &res[0], res.size());
v8::Local<v8::Object> globalObj = NanGetCurrentContext()->Global();
v8::Local<v8::Function> bufferConstructor = v8::Local<v8::Function>::Cast(globalObj->Get(NanNew<String>("Buffer")));
@ -485,7 +477,6 @@ class AsyncToBufferWorker : public NanAsyncWorker {
private:
Matrix* matrix;
//char* filename;
std::string ext;
std::vector<int> params;
std::vector<uchar> res;

View File

@ -6,7 +6,6 @@ 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 NAN_METHOD(New);
Matrix();
Matrix(cv::Mat other, cv::Rect roi);

View File

@ -9,23 +9,15 @@ Point::Init(Handle<Object> target) {
NanScope();
// Constructor
/*constructor = Persistent<FunctionTemplate>::New(FunctionTemplate::New(Point::New));
constructor->InstanceTemplate()->SetInternalFieldCount(1);
constructor->SetClassName(String::NewSymbol("Point"));
// Prototype
Local<ObjectTemplate> proto = constructor->PrototypeTemplate();
proto->SetAccessor(String::NewSymbol("x"), GetX, RaiseImmutable);
proto->SetAccessor(String::NewSymbol("y"), GetY, RaiseImmutable);*/
Local<FunctionTemplate> ctor = NanNew<FunctionTemplate>(Point::New);
NanAssignPersistent(constructor, ctor);
ctor->InstanceTemplate()->SetInternalFieldCount(1);
ctor->SetClassName(NanNew("Point"));
// Prototype
Local<ObjectTemplate> proto = ctor->PrototypeTemplate();
proto->SetAccessor(NanNew("x"), GetX, RaiseImmutable);//, RaiseImmutable);
proto->SetAccessor(NanNew("y"), GetY, RaiseImmutable);//, RaiseImmutable);
proto->SetAccessor(NanNew("x"), GetX, RaiseImmutable);
proto->SetAccessor(NanNew("y"), GetY, RaiseImmutable);
NODE_SET_PROTOTYPE_METHOD(ctor, "dot", Dot);
@ -47,13 +39,13 @@ NAN_METHOD(Point::New) {
NanReturnValue(args.This());
}
NAN_GETTER(Point::GetX){ //(Local<String> prop, const AccessorInfo &info) {
NAN_GETTER(Point::GetX){
NanScope();
Point *pt = ObjectWrap::Unwrap<Point>(args.This());
NanReturnValue(NanNew<Number>(pt->point.x));
}
NAN_GETTER(Point::GetY){//(Local<String> prop, const AccessorInfo &info) {
NAN_GETTER(Point::GetY){
NanScope();
Point *pt = ObjectWrap::Unwrap<Point>(args.This());
NanReturnValue(NanNew<Number>(pt->point.y));

View File

@ -6,9 +6,6 @@
using namespace std;
void AsyncRead(uv_work_t *req);
void AfterAsyncRead(uv_work_t *req);
v8::Persistent<FunctionTemplate> VideoCaptureWrap::constructor;
struct videocapture_baton {

View File

@ -6,35 +6,24 @@ class VideoCaptureWrap: public node::ObjectWrap {
static Persistent<FunctionTemplate> constructor;
static void Init(Handle<Object> target);
//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 NAN_METHOD(Read);
static NAN_METHOD(ReadSync);
//(Optional) For setting width and height of the input video stream
//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 NAN_METHOD(SetPosition);
//static Handle<Value> GetFrameAt(const v8::Arguments&);
static NAN_METHOD(GetFrameAt);
//close the stream
//static Handle<Value> Close(const v8::Arguments&);
static NAN_METHOD(Close);
//experimental
//static Handle<Value> ReadSync(const v8::Arguments&);
static NAN_METHOD(ReadSync);
};