Permalink
Browse files

Added videocapture working (libuv), some examples, more methods to Ma…

…trix and implement of libuv for detectobjects
  • Loading branch information...
1 parent bc91847 commit b73174c00fbce67bd801d6707590d42c7cec9535 @raichuk raichuk committed Jun 18, 2012
View
0 .gitignore 100644 → 100755
No changes.
View
0 .travis.yml 100644 → 100755
No changes.
View
0 README.md 100644 → 100755
No changes.
View
2 TODO 100644 → 100755
@@ -42,4 +42,4 @@ cv.loadImage('test.jpg', function(err, im){
http://www.athile.net/library/wiki/index.php?title=Library/V8/Tutorial#Wrapping_a_Javascript_function_as_a_std::function.3C.3E
-https://www.cloudkick.com/blog/2010/aug/23/writing-nodejs-native-extensions/
+https://www.cloudkick.com/blog/2010/aug/23/writing-nodejs-native-extensions/
View
0 examples/face-proxy.js 100644 → 100755
No changes.
View
No changes.
View
Deleted file not rendered
View
0 index.html 100644 → 100755
No changes.
View
0 lib/bindings.js 100644 → 100755
No changes.
View
2 lib/opencv.js 100644 → 100755
@@ -1,5 +1,5 @@
var Stream = require('stream').Stream
- , Buffers = require('buffers')
+ , Buffers = require('buffer')
, util = require('util');
var bindings = require('./bindings')
View
0 package.json 100644 → 100755
No changes.
View
@@ -14,4 +14,4 @@ var cv = require('./lib/opencv')
im.save('./out.jpg');
});
-})
+})
View
39 src/CascadeClassifierWrap.cc 100644 → 100755
@@ -3,6 +3,8 @@
#include "Matrix.h"
+void AsyncDetectMultiScale(uv_work_t *req);
+void AfterAsyncDetectMultiScale(uv_work_t *req);
Persistent<FunctionTemplate> CascadeClassifierWrap::constructor;
@@ -61,6 +63,8 @@ struct classifier_baton_t {
int minh;
int sleep_for;
std::vector<cv::Rect> res;
+
+ uv_work_t request;
};
@@ -102,42 +106,47 @@ CascadeClassifierWrap::DetectMultiScale(const v8::Arguments& args){
baton->minw = minw;
baton->minh = minh;
baton->sleep_for = 1;
- self->Ref();
+ baton->request.data = baton;
+// self->Ref();
+
+// eio_custom(EIO_DetectMultiScale, EIO_PRI_DEFAULT, EIO_AfterDetectMultiScale, baton);
+// ev_ref(EV_DEFAULT_UC);
- eio_custom(EIO_DetectMultiScale, EIO_PRI_DEFAULT, EIO_AfterDetectMultiScale, baton);
- ev_ref(EV_DEFAULT_UC);
+ uv_queue_work(uv_default_loop(), &baton->request, AsyncDetectMultiScale, AfterAsyncDetectMultiScale);
return Undefined();
}
-
-void
-CascadeClassifierWrap::EIO_DetectMultiScale(eio_req *req){
- classifier_baton_t *baton = static_cast<classifier_baton_t *>(req->data);
- sleep(baton->sleep_for);
+void AsyncDetectMultiScale(uv_work_t *req) {
+ classifier_baton_t *baton = static_cast<classifier_baton_t *>(req->data);
+// sleep(baton->sleep_for);
std::vector<cv::Rect> objects;
cv::Mat gray;
- cvtColor( baton->im->mat, gray, CV_BGR2GRAY );
- equalizeHist( gray, gray);
+ if(baton->im->mat.channels() != 1)
+ cvtColor(baton->im->mat, gray, CV_BGR2GRAY);
+
+ equalizeHist( gray, gray);
baton->cc->cc.detectMultiScale(gray, objects, baton->scale, baton->neighbors, 0, cv::Size(baton->minw, baton->minh));
baton->res = objects;
+
+
}
-int
-CascadeClassifierWrap::EIO_AfterDetectMultiScale(eio_req *req){
+void AfterAsyncDetectMultiScale(uv_work_t *req) {
+
HandleScope scope;
classifier_baton_t *baton = static_cast<classifier_baton_t *>(req->data);
- ev_unref(EV_DEFAULT_UC);
- baton->cc->Unref();
+// ev_unref(EV_DEFAULT_UC);
+// baton->cc->Unref();
Local<Value> argv[2];
@@ -169,6 +178,6 @@ CascadeClassifierWrap::EIO_AfterDetectMultiScale(eio_req *req){
delete baton;
- return 0;
+// return 0;
}
View
2 src/CascadeClassifierWrap.h 100644 → 100755
@@ -16,4 +16,4 @@ class CascadeClassifierWrap: public node::ObjectWrap {
static void EIO_DetectMultiScale(eio_req *req);
static int EIO_AfterDetectMultiScale(eio_req *req);
-};
+};
Oops, something went wrong.

0 comments on commit b73174c

Please sign in to comment.