mirror of
https://github.com/peterbraden/node-opencv.git
synced 2025-12-08 19:45:55 +00:00
Merge pull request #568 from peterbraden/available-modules
Available modules
This commit is contained in:
commit
cc8b4804c5
34
examples/async-resize.js
Normal file
34
examples/async-resize.js
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
var cv = require('../lib/opencv');
|
||||||
|
|
||||||
|
cv.readImage("./files/mona.png", function(err, im) {
|
||||||
|
if (err) throw err;
|
||||||
|
|
||||||
|
var width = im.width();
|
||||||
|
var height = im.height();
|
||||||
|
if (width < 1 || height < 1) throw new Error('Image has no size');
|
||||||
|
|
||||||
|
console.log('Image loaded from ./files/mona.png at '+im.width()+'x'+im.height());
|
||||||
|
|
||||||
|
var AfterResize = function(err, img){
|
||||||
|
if (err){
|
||||||
|
console.log('Error in resize:' + err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
img.save("./tmp/resize-async-image.png");
|
||||||
|
console.log('Image saved to ./tmp/resize-async-image.png at '+img.width()+'x'+img.height());
|
||||||
|
};
|
||||||
|
|
||||||
|
var newwidth = width*0.95;
|
||||||
|
var newheight = height*0.95;
|
||||||
|
|
||||||
|
var Async = true;
|
||||||
|
if (Async){
|
||||||
|
// note - generates a new image
|
||||||
|
im.resize(newwidth, newheight, AfterResize);
|
||||||
|
} else {
|
||||||
|
// sync - note - modifies the input image
|
||||||
|
im.resize(newwidth, newheight);
|
||||||
|
AfterResize(null, im);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
@ -11,7 +11,7 @@
|
|||||||
*/
|
*/
|
||||||
#ifndef NODE_OPENCV_MATRIX_H
|
#ifndef NODE_OPENCV_MATRIX_H
|
||||||
#define NODE_OPENCV_MATRIX_H
|
#define NODE_OPENCV_MATRIX_H
|
||||||
#include <opencv/cv.h>
|
#include <opencv2/opencv.hpp>
|
||||||
#include <node_object_wrap.h>
|
#include <node_object_wrap.h>
|
||||||
|
|
||||||
namespace node_opencv {
|
namespace node_opencv {
|
||||||
|
|||||||
141
lib/opencv.js
141
lib/opencv.js
@ -7,30 +7,34 @@ var Stream = require('stream').Stream
|
|||||||
var cv = module.exports = require('./bindings');
|
var cv = module.exports = require('./bindings');
|
||||||
|
|
||||||
var Matrix = cv.Matrix
|
var Matrix = cv.Matrix
|
||||||
, VideoCapture = cv.VideoCapture
|
|
||||||
, VideoWriter = cv.VideoWriter
|
|
||||||
, ImageStream
|
, ImageStream
|
||||||
, ImageDataStream
|
, ImageDataStream
|
||||||
, ObjectDetectionStream
|
, ObjectDetectionStream
|
||||||
, VideoStream;
|
, VideoStream;
|
||||||
|
|
||||||
|
|
||||||
Matrix.prototype.detectObject = function(classifier, opts, cb){
|
if (cv.CascadeClassifier) {
|
||||||
var face_cascade;
|
Matrix.prototype.detectObject = function(classifier, opts, cb){
|
||||||
opts = opts || {};
|
var face_cascade;
|
||||||
cv._detectObjectClassifiers = cv._detectObjectClassifiers || {};
|
opts = opts || {};
|
||||||
|
cv._detectObjectClassifiers = cv._detectObjectClassifiers || {};
|
||||||
|
|
||||||
if (!(face_cascade = cv._detectObjectClassifiers[classifier])){
|
if (!(face_cascade = cv._detectObjectClassifiers[classifier])){
|
||||||
face_cascade = new cv.CascadeClassifier(classifier);
|
face_cascade = new cv.CascadeClassifier(classifier);
|
||||||
cv._detectObjectClassifiers[classifier] = face_cascade;
|
cv._detectObjectClassifiers[classifier] = face_cascade;
|
||||||
|
}
|
||||||
|
|
||||||
|
face_cascade.detectMultiScale(this, cb, opts.scale, opts.neighbors
|
||||||
|
, opts.min && opts.min[0], opts.min && opts.min[1]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
cv.Matrix.prototype.detectObject = function() {
|
||||||
|
throw new Error("You need to install OpenCV with OBJDETECT module");
|
||||||
}
|
}
|
||||||
|
|
||||||
face_cascade.detectMultiScale(this, cb, opts.scale, opts.neighbors
|
|
||||||
, opts.min && opts.min[0], opts.min && opts.min[1]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Matrix.prototype.inspect = function(){
|
cv.Matrix.prototype.inspect = function(){
|
||||||
var size = (this.size()||[]).join('x');
|
var size = (this.size()||[]).join('x');
|
||||||
return "[ Matrix " + size + " ]";
|
return "[ Matrix " + size + " ]";
|
||||||
}
|
}
|
||||||
@ -189,69 +193,70 @@ ImageDataStream.prototype.end = function(b){
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cv.CascadeClassifier) {
|
||||||
ObjectDetectionStream = cv.ObjectDetectionStream = function(cascade, opts){
|
ObjectDetectionStream = cv.ObjectDetectionStream = function(cascade, opts){
|
||||||
this.classifier = new cv.CascadeClassifier(cascade);
|
this.classifier = new cv.CascadeClassifier(cascade);
|
||||||
this.opts = opts || {};
|
this.opts = opts || {};
|
||||||
this.readable = true;
|
this.readable = true;
|
||||||
this.writable = true;
|
this.writable = true;
|
||||||
}
|
|
||||||
util.inherits(ObjectDetectionStream, Stream);
|
|
||||||
|
|
||||||
|
|
||||||
ObjectDetectionStream.prototype.write = function(m){
|
|
||||||
var self = this;
|
|
||||||
this.classifier.detectMultiScale(m, function(err, objs){
|
|
||||||
if (err) return self.emit('error', err);
|
|
||||||
self.emit('data', objs, m);
|
|
||||||
}
|
}
|
||||||
, this.opts.scale
|
util.inherits(ObjectDetectionStream, Stream);
|
||||||
, this.opts.neighbors
|
|
||||||
, this.opts.min && this.opts.min[0]
|
|
||||||
, this.opts.min && this.opts.min[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
ObjectDetectionStream.prototype.write = function(m){
|
||||||
VideoStream = cv.VideoStream = function(src){
|
var self = this;
|
||||||
if (!(src instanceof VideoCapture)) src = new VideoCapture(src);
|
this.classifier.detectMultiScale(m, function(err, objs){
|
||||||
this.video = src;
|
|
||||||
this.readable = true;
|
|
||||||
this.paused = false;
|
|
||||||
}
|
|
||||||
util.inherits(VideoStream, Stream);
|
|
||||||
|
|
||||||
|
|
||||||
VideoStream.prototype.read = function(){
|
|
||||||
var self = this;
|
|
||||||
var frame = function(){
|
|
||||||
self.video.read(function(err, mat){
|
|
||||||
if (err) return self.emit('error', err);
|
if (err) return self.emit('error', err);
|
||||||
self.emit('data', mat);
|
self.emit('data', objs, m);
|
||||||
if (!self.paused) process.nextTick(frame);
|
}
|
||||||
})
|
, this.opts.scale
|
||||||
|
, this.opts.neighbors
|
||||||
|
, this.opts.min && this.opts.min[0]
|
||||||
|
, this.opts.min && this.opts.min[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (cv.VideoCapture) {
|
||||||
|
var VideoCapture = cv.VideoCapture
|
||||||
|
|
||||||
|
VideoStream = cv.VideoStream = function(src){
|
||||||
|
if (!(src instanceof VideoCapture)) src = new VideoCapture(src);
|
||||||
|
this.video = src;
|
||||||
|
this.readable = true;
|
||||||
|
this.paused = false;
|
||||||
|
}
|
||||||
|
util.inherits(VideoStream, Stream);
|
||||||
|
|
||||||
|
|
||||||
|
VideoStream.prototype.read = function(){
|
||||||
|
var self = this;
|
||||||
|
var frame = function(){
|
||||||
|
self.video.read(function(err, mat){
|
||||||
|
if (err) return self.emit('error', err);
|
||||||
|
self.emit('data', mat);
|
||||||
|
if (!self.paused) process.nextTick(frame);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
frame();
|
||||||
}
|
}
|
||||||
|
|
||||||
frame();
|
VideoStream.prototype.pause = function(){
|
||||||
|
this.paused = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
VideoStream.prototype.resume = function(){
|
||||||
|
this.paused = false;
|
||||||
|
this.read();
|
||||||
|
}
|
||||||
|
|
||||||
|
VideoCapture.prototype.toStream = function(){
|
||||||
|
return new VideoStream(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VideoStream.prototype.pause = function(){
|
|
||||||
this.paused = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
VideoStream.prototype.resume = function(){
|
|
||||||
this.paused = false;
|
|
||||||
this.read();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
VideoCapture.prototype.toStream = function(){
|
|
||||||
return new VideoStream(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Provide cascade data for faces etc.
|
// Provide cascade data for faces etc.
|
||||||
var CASCADES = {
|
var CASCADES = {
|
||||||
FACE_CASCADE: 'haarcascade_frontalface_alt.xml'
|
FACE_CASCADE: 'haarcascade_frontalface_alt.xml'
|
||||||
|
|||||||
@ -3,6 +3,8 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <nan.h>
|
#include <nan.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_OPENCV_VIDEO
|
||||||
|
|
||||||
#if CV_MAJOR_VERSION >= 3
|
#if CV_MAJOR_VERSION >= 3
|
||||||
#warning TODO: port me to OpenCV 3
|
#warning TODO: port me to OpenCV 3
|
||||||
#endif
|
#endif
|
||||||
@ -129,3 +131,4 @@ BackgroundSubtractorWrap::BackgroundSubtractorWrap(
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
#include "OpenCV.h"
|
#include "OpenCV.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_OPENCV_VIDEO
|
||||||
|
|
||||||
#if ((CV_MAJOR_VERSION == 2) && (CV_MINOR_VERSION >=4))
|
#if ((CV_MAJOR_VERSION == 2) && (CV_MINOR_VERSION >=4))
|
||||||
|
|
||||||
#include <opencv2/video/background_segm.hpp>
|
#include <opencv2/video/background_segm.hpp>
|
||||||
@ -19,3 +21,5 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
#include "Calib3D.h"
|
#include "Calib3D.h"
|
||||||
#include "Matrix.h"
|
#include "Matrix.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_OPENCV_CALIB3D
|
||||||
|
|
||||||
inline Local<Object> matrixFromMat(cv::Mat &input) {
|
inline Local<Object> matrixFromMat(cv::Mat &input) {
|
||||||
Local<Object> matrixWrap =
|
Local<Object> matrixWrap =
|
||||||
Nan::NewInstance(Nan::GetFunction(Nan::New(Matrix::constructor)).ToLocalChecked()).ToLocalChecked();
|
Nan::NewInstance(Nan::GetFunction(Nan::New(Matrix::constructor)).ToLocalChecked()).ToLocalChecked();
|
||||||
@ -564,3 +566,5 @@ NAN_METHOD(Calib3D::ReprojectImageTo3D) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
#include "OpenCV.h"
|
#include "OpenCV.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_OPENCV_CALIB3D
|
||||||
|
|
||||||
#if CV_MAJOR_VERSION >= 3
|
#if CV_MAJOR_VERSION >= 3
|
||||||
#include <opencv2/calib3d.hpp>
|
#include <opencv2/calib3d.hpp>
|
||||||
#endif
|
#endif
|
||||||
@ -25,3 +27,4 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|||||||
@ -2,6 +2,8 @@
|
|||||||
#include "OpenCV.h"
|
#include "OpenCV.h"
|
||||||
#include "Matrix.h"
|
#include "Matrix.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_OPENCV_VIDEO
|
||||||
|
|
||||||
#if CV_MAJOR_VERSION >= 3
|
#if CV_MAJOR_VERSION >= 3
|
||||||
#include <opencv2/video/tracking.hpp>
|
#include <opencv2/video/tracking.hpp>
|
||||||
#endif
|
#endif
|
||||||
@ -176,3 +178,5 @@ NAN_METHOD(TrackedObject::Track) {
|
|||||||
|
|
||||||
info.GetReturnValue().Set(arr);
|
info.GetReturnValue().Set(arr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
#include "OpenCV.h"
|
#include "OpenCV.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_OPENCV_VIDEO
|
||||||
|
|
||||||
class TrackedObject: public Nan::ObjectWrap {
|
class TrackedObject: public Nan::ObjectWrap {
|
||||||
public:
|
public:
|
||||||
@ -20,3 +21,5 @@ public:
|
|||||||
|
|
||||||
JSFUNC(Track);
|
JSFUNC(Track);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@ -3,6 +3,8 @@
|
|||||||
#include "Matrix.h"
|
#include "Matrix.h"
|
||||||
#include <nan.h>
|
#include <nan.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_OPENCV_OBJDETECT
|
||||||
|
|
||||||
Nan::Persistent<FunctionTemplate> CascadeClassifierWrap::constructor;
|
Nan::Persistent<FunctionTemplate> CascadeClassifierWrap::constructor;
|
||||||
|
|
||||||
void CascadeClassifierWrap::Init(Local<Object> target) {
|
void CascadeClassifierWrap::Init(Local<Object> target) {
|
||||||
@ -54,7 +56,7 @@ public:
|
|||||||
minw(minw),
|
minw(minw),
|
||||||
minh(minh) {
|
minh(minh) {
|
||||||
}
|
}
|
||||||
|
|
||||||
~AsyncDetectMultiScale() {
|
~AsyncDetectMultiScale() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,3 +151,5 @@ NAN_METHOD(CascadeClassifierWrap::DetectMultiScale) {
|
|||||||
neighbors, minw, minh));
|
neighbors, minw, minh));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@ -1,6 +1,9 @@
|
|||||||
#include "OpenCV.h"
|
#include "OpenCV.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_OPENCV_OBJDETECT
|
||||||
|
|
||||||
#if CV_MAJOR_VERSION >= 3
|
#if CV_MAJOR_VERSION >= 3
|
||||||
#include <opencv2/objdetect.hpp>
|
#include <opencv2/objdetect.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class CascadeClassifierWrap: public Nan::ObjectWrap {
|
class CascadeClassifierWrap: public Nan::ObjectWrap {
|
||||||
@ -20,3 +23,5 @@ public:
|
|||||||
static void EIO_DetectMultiScale(uv_work_t *req);
|
static void EIO_DetectMultiScale(uv_work_t *req);
|
||||||
static int EIO_AfterDetectMultiScale(uv_work_t *req);
|
static int EIO_AfterDetectMultiScale(uv_work_t *req);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@ -8,9 +8,9 @@
|
|||||||
#if CV_MAJOR_VERSION >= 3
|
#if CV_MAJOR_VERSION >= 3
|
||||||
namespace cv {
|
namespace cv {
|
||||||
using std::vector;
|
using std::vector;
|
||||||
using cv::face::createEigenFaceRecognizer;
|
using cv::face::EigenFaceRecognizer;
|
||||||
using cv::face::createFisherFaceRecognizer;
|
using cv::face::FisherFaceRecognizer;
|
||||||
using cv::face::createLBPHFaceRecognizer;
|
using cv::face::LBPHFaceRecognizer;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ NAN_METHOD(FaceRecognizerWrap::New) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// By default initialize LBPH
|
// By default initialize LBPH
|
||||||
cv::Ptr<cv::FaceRecognizer> f = cv::createLBPHFaceRecognizer(1, 8, 8, 8, 80.0);
|
cv::Ptr<cv::FaceRecognizer> f = cv::LBPHFaceRecognizer::create(1, 8, 8, 8, 80.0);
|
||||||
FaceRecognizerWrap *pt = new FaceRecognizerWrap(f, LBPH);
|
FaceRecognizerWrap *pt = new FaceRecognizerWrap(f, LBPH);
|
||||||
|
|
||||||
pt->Wrap(info.This());
|
pt->Wrap(info.This());
|
||||||
@ -91,7 +91,7 @@ NAN_METHOD(FaceRecognizerWrap::CreateLBPH) {
|
|||||||
DOUBLE_FROM_ARGS(threshold, 4)
|
DOUBLE_FROM_ARGS(threshold, 4)
|
||||||
|
|
||||||
Local<Object> n = Nan::NewInstance(Nan::GetFunction(Nan::New(FaceRecognizerWrap::constructor)).ToLocalChecked()).ToLocalChecked();
|
Local<Object> n = Nan::NewInstance(Nan::GetFunction(Nan::New(FaceRecognizerWrap::constructor)).ToLocalChecked()).ToLocalChecked();
|
||||||
cv::Ptr<cv::FaceRecognizer> f = cv::createLBPHFaceRecognizer(radius,
|
cv::Ptr<cv::FaceRecognizer> f = cv::LBPHFaceRecognizer::create(radius,
|
||||||
neighbors, grid_x, grid_y, threshold);
|
neighbors, grid_x, grid_y, threshold);
|
||||||
FaceRecognizerWrap *pt = new FaceRecognizerWrap(f, LBPH);
|
FaceRecognizerWrap *pt = new FaceRecognizerWrap(f, LBPH);
|
||||||
pt->Wrap(n);
|
pt->Wrap(n);
|
||||||
@ -109,7 +109,7 @@ NAN_METHOD(FaceRecognizerWrap::CreateEigen) {
|
|||||||
DOUBLE_FROM_ARGS(threshold, 1)
|
DOUBLE_FROM_ARGS(threshold, 1)
|
||||||
|
|
||||||
Local<Object> n = Nan::NewInstance(Nan::GetFunction(Nan::New(FaceRecognizerWrap::constructor)).ToLocalChecked()).ToLocalChecked();
|
Local<Object> n = Nan::NewInstance(Nan::GetFunction(Nan::New(FaceRecognizerWrap::constructor)).ToLocalChecked()).ToLocalChecked();
|
||||||
cv::Ptr<cv::FaceRecognizer> f = cv::createEigenFaceRecognizer(components,
|
cv::Ptr<cv::FaceRecognizer> f = cv::EigenFaceRecognizer::create(components,
|
||||||
threshold);
|
threshold);
|
||||||
FaceRecognizerWrap *pt = new FaceRecognizerWrap(f, EIGEN);
|
FaceRecognizerWrap *pt = new FaceRecognizerWrap(f, EIGEN);
|
||||||
pt->Wrap(n);
|
pt->Wrap(n);
|
||||||
@ -128,7 +128,7 @@ NAN_METHOD(FaceRecognizerWrap::CreateFisher) {
|
|||||||
|
|
||||||
Local<Object> n = Nan::NewInstance(Nan::GetFunction(Nan::New(FaceRecognizerWrap::constructor)).ToLocalChecked()).ToLocalChecked();
|
Local<Object> n = Nan::NewInstance(Nan::GetFunction(Nan::New(FaceRecognizerWrap::constructor)).ToLocalChecked()).ToLocalChecked();
|
||||||
|
|
||||||
cv::Ptr<cv::FaceRecognizer> f = cv::createFisherFaceRecognizer(components,
|
cv::Ptr<cv::FaceRecognizer> f = cv::FisherFaceRecognizer::create(components,
|
||||||
threshold);
|
threshold);
|
||||||
FaceRecognizerWrap *pt = new FaceRecognizerWrap(f, FISHER);
|
FaceRecognizerWrap *pt = new FaceRecognizerWrap(f, FISHER);
|
||||||
pt->Wrap(n);
|
pt->Wrap(n);
|
||||||
@ -378,7 +378,7 @@ NAN_METHOD(FaceRecognizerWrap::SaveSync) {
|
|||||||
JSTHROW("Save takes a filename")
|
JSTHROW("Save takes a filename")
|
||||||
}
|
}
|
||||||
std::string filename = std::string(*Nan::Utf8String(info[0]->ToString()));
|
std::string filename = std::string(*Nan::Utf8String(info[0]->ToString()));
|
||||||
self->rec->save(filename);
|
self->rec->write(filename);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -388,7 +388,7 @@ NAN_METHOD(FaceRecognizerWrap::LoadSync) {
|
|||||||
JSTHROW("Load takes a filename")
|
JSTHROW("Load takes a filename")
|
||||||
}
|
}
|
||||||
std::string filename = std::string(*Nan::Utf8String(info[0]->ToString()));
|
std::string filename = std::string(*Nan::Utf8String(info[0]->ToString()));
|
||||||
self->rec->load(filename);
|
self->rec->read(filename);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,6 +6,8 @@
|
|||||||
#include <nan.h>
|
#include <nan.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_OPENCV_FEATURES2D
|
||||||
|
|
||||||
void Features::Init(Local<Object> target) {
|
void Features::Init(Local<Object> target) {
|
||||||
Nan::HandleScope scope;
|
Nan::HandleScope scope;
|
||||||
|
|
||||||
@ -112,3 +114,4 @@ NAN_METHOD(Features::Similarity) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|||||||
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
#if ((CV_MAJOR_VERSION == 2) && (CV_MINOR_VERSION >=4))
|
#if ((CV_MAJOR_VERSION == 2) && (CV_MINOR_VERSION >=4))
|
||||||
|
|
||||||
|
#ifdef HAVE_OPENCV_FEATURES2D
|
||||||
|
|
||||||
#include <opencv2/core/core.hpp>
|
#include <opencv2/core/core.hpp>
|
||||||
#include <opencv2/features2d/features2d.hpp>
|
#include <opencv2/features2d/features2d.hpp>
|
||||||
|
|
||||||
@ -14,3 +16,5 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@ -2,6 +2,8 @@
|
|||||||
#include "OpenCV.h"
|
#include "OpenCV.h"
|
||||||
#include "Matrix.h"
|
#include "Matrix.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_OPENCV_HIGHGUI
|
||||||
|
|
||||||
Nan::Persistent<FunctionTemplate> NamedWindow::constructor;
|
Nan::Persistent<FunctionTemplate> NamedWindow::constructor;
|
||||||
|
|
||||||
void NamedWindow::Init(Local<Object> target) {
|
void NamedWindow::Init(Local<Object> target) {
|
||||||
@ -82,3 +84,5 @@ NAN_METHOD(NamedWindow::BlockingWaitKey) {
|
|||||||
|
|
||||||
info.GetReturnValue().Set(Nan::New<Number>(res));
|
info.GetReturnValue().Set(Nan::New<Number>(res));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
#include "OpenCV.h"
|
#include "OpenCV.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_OPENCV_HIGHGUI
|
||||||
|
|
||||||
class NamedWindow: public Nan::ObjectWrap {
|
class NamedWindow: public Nan::ObjectWrap {
|
||||||
public:
|
public:
|
||||||
std::string winname;
|
std::string winname;
|
||||||
@ -17,3 +19,5 @@ public:
|
|||||||
;
|
;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
#include "ImgProc.h"
|
#include "ImgProc.h"
|
||||||
#include "Matrix.h"
|
#include "Matrix.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_OPENCV_IMGPROC
|
||||||
|
|
||||||
void ImgProc::Init(Local<Object> target) {
|
void ImgProc::Init(Local<Object> target) {
|
||||||
Nan::Persistent<Object> inner;
|
Nan::Persistent<Object> inner;
|
||||||
Local<Object> obj = Nan::New<Object>();
|
Local<Object> obj = Nan::New<Object>();
|
||||||
@ -233,3 +235,5 @@ NAN_METHOD(ImgProc::GetStructuringElement) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
#include "OpenCV.h"
|
#include "OpenCV.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_OPENCV_IMGPROC
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of imgproc.hpp functions
|
* Implementation of imgproc.hpp functions
|
||||||
*/
|
*/
|
||||||
@ -17,3 +19,5 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
154
src/Matrix.cc
154
src/Matrix.cc
@ -83,7 +83,9 @@ void Matrix::Init(Local<Object> target) {
|
|||||||
Nan::SetPrototypeMethod(ctor, "drawContour", DrawContour);
|
Nan::SetPrototypeMethod(ctor, "drawContour", DrawContour);
|
||||||
Nan::SetPrototypeMethod(ctor, "drawAllContours", DrawAllContours);
|
Nan::SetPrototypeMethod(ctor, "drawAllContours", DrawAllContours);
|
||||||
Nan::SetPrototypeMethod(ctor, "goodFeaturesToTrack", GoodFeaturesToTrack);
|
Nan::SetPrototypeMethod(ctor, "goodFeaturesToTrack", GoodFeaturesToTrack);
|
||||||
|
#ifdef HAVE_OPENCV_VIDEO
|
||||||
Nan::SetPrototypeMethod(ctor, "calcOpticalFlowPyrLK", CalcOpticalFlowPyrLK);
|
Nan::SetPrototypeMethod(ctor, "calcOpticalFlowPyrLK", CalcOpticalFlowPyrLK);
|
||||||
|
#endif
|
||||||
Nan::SetPrototypeMethod(ctor, "houghLinesP", HoughLinesP);
|
Nan::SetPrototypeMethod(ctor, "houghLinesP", HoughLinesP);
|
||||||
Nan::SetPrototypeMethod(ctor, "houghCircles", HoughCircles);
|
Nan::SetPrototypeMethod(ctor, "houghCircles", HoughCircles);
|
||||||
Nan::SetPrototypeMethod(ctor, "inRange", inRange);
|
Nan::SetPrototypeMethod(ctor, "inRange", inRange);
|
||||||
@ -651,7 +653,7 @@ NAN_METHOD(Matrix::PixelCol) {
|
|||||||
int height = self->mat.size().height;
|
int height = self->mat.size().height;
|
||||||
int x = info[0]->IntegerValue();
|
int x = info[0]->IntegerValue();
|
||||||
v8::Local < v8::Array > arr;
|
v8::Local < v8::Array > arr;
|
||||||
|
|
||||||
if (self->mat.channels() == 4) {
|
if (self->mat.channels() == 4) {
|
||||||
arr = Nan::New<Array>(height * 4);
|
arr = Nan::New<Array>(height * 4);
|
||||||
for (int y = 0; y < height; y++) {
|
for (int y = 0; y < height; y++) {
|
||||||
@ -1697,6 +1699,7 @@ NAN_METHOD(Matrix::GoodFeaturesToTrack) {
|
|||||||
info.GetReturnValue().Set(arr);
|
info.GetReturnValue().Set(arr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_OPENCV_VIDEO
|
||||||
NAN_METHOD(Matrix::CalcOpticalFlowPyrLK) {
|
NAN_METHOD(Matrix::CalcOpticalFlowPyrLK) {
|
||||||
Nan::HandleScope scope;
|
Nan::HandleScope scope;
|
||||||
|
|
||||||
@ -1773,6 +1776,7 @@ NAN_METHOD(Matrix::CalcOpticalFlowPyrLK) {
|
|||||||
|
|
||||||
info.GetReturnValue().Set(data);
|
info.GetReturnValue().Set(data);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
NAN_METHOD(Matrix::HoughLinesP) {
|
NAN_METHOD(Matrix::HoughLinesP) {
|
||||||
Nan::HandleScope scope;
|
Nan::HandleScope scope;
|
||||||
@ -1885,27 +1889,145 @@ cv::Rect* setRect(Local<Object> objRect, cv::Rect &result) {
|
|||||||
return &result;
|
return &result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class ResizeASyncWorker: public Nan::AsyncWorker {
|
||||||
|
public:
|
||||||
|
ResizeASyncWorker(Nan::Callback *callback, Matrix *image, cv::Size size, double fx, double fy, int interpolation) :
|
||||||
|
Nan::AsyncWorker(callback),
|
||||||
|
image(image),
|
||||||
|
size(size),
|
||||||
|
fx(fx),
|
||||||
|
fy(fy),
|
||||||
|
interpolation(interpolation),
|
||||||
|
success(0){
|
||||||
|
}
|
||||||
|
|
||||||
|
~ResizeASyncWorker() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void Execute() {
|
||||||
|
try {
|
||||||
|
dest = new Matrix();
|
||||||
|
cv::resize(image->mat, dest->mat, size, fx, fy, interpolation);
|
||||||
|
success = 1;
|
||||||
|
} catch(...){
|
||||||
|
success = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HandleOKCallback() {
|
||||||
|
Nan::HandleScope scope;
|
||||||
|
|
||||||
|
if (success){
|
||||||
|
Local<Object> im_to_return= Nan::NewInstance(Nan::GetFunction(Nan::New(Matrix::constructor)).ToLocalChecked()).ToLocalChecked();
|
||||||
|
Matrix *img = Nan::ObjectWrap::Unwrap<Matrix>(im_to_return);
|
||||||
|
img->mat = dest->mat;
|
||||||
|
delete dest;
|
||||||
|
|
||||||
|
//delete dest;
|
||||||
|
|
||||||
|
Local<Value> argv[] = {
|
||||||
|
Nan::Null(), // err
|
||||||
|
im_to_return //result
|
||||||
|
};
|
||||||
|
|
||||||
|
Nan::TryCatch try_catch;
|
||||||
|
callback->Call(2, argv);
|
||||||
|
if (try_catch.HasCaught()) {
|
||||||
|
Nan::FatalException(try_catch);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
delete dest;
|
||||||
|
|
||||||
|
Local<Value> argv[] = {
|
||||||
|
Nan::New("C++ exception").ToLocalChecked(), // err
|
||||||
|
Nan::Null() //result
|
||||||
|
};
|
||||||
|
|
||||||
|
Nan::TryCatch try_catch;
|
||||||
|
callback->Call(2, argv);
|
||||||
|
if (try_catch.HasCaught()) {
|
||||||
|
Nan::FatalException(try_catch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
Matrix *image;
|
||||||
|
Matrix *dest;
|
||||||
|
cv::Size size;
|
||||||
|
double fx;
|
||||||
|
double fy;
|
||||||
|
int interpolation;
|
||||||
|
int success;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
NAN_METHOD(Matrix::Resize) {
|
NAN_METHOD(Matrix::Resize) {
|
||||||
Nan::HandleScope scope;
|
SETUP_FUNCTION(Matrix)
|
||||||
|
|
||||||
|
if (info.Length() < 2) {
|
||||||
|
return Nan::ThrowError("Matrix.resize requires at least 2 argument2");
|
||||||
|
}
|
||||||
|
|
||||||
|
//im.resize( width, height );
|
||||||
|
//im.resize( width, height, fx, fy );
|
||||||
|
//im.resize( width, height, interpolation );
|
||||||
|
//im.resize( width, height, fx, fy, interpolation );
|
||||||
|
// if fn is added on the end, makes it Async
|
||||||
|
|
||||||
|
int numargs = info.Length();
|
||||||
|
int isAsync = 0;
|
||||||
|
|
||||||
|
if (info[numargs-1]->IsFunction()){
|
||||||
|
isAsync = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (info.Length() < 2+isAsync) {
|
||||||
|
return Nan::ThrowError("Matrix.resize requires at least x and y size argument2");
|
||||||
|
}
|
||||||
|
|
||||||
int x = info[0]->Uint32Value();
|
int x = info[0]->Uint32Value();
|
||||||
int y = info[1]->Uint32Value();
|
int y = info[1]->Uint32Value();
|
||||||
/*
|
|
||||||
CV_INTER_NN =0,
|
|
||||||
CV_INTER_LINEAR =1,
|
|
||||||
CV_INTER_CUBIC =2,
|
|
||||||
CV_INTER_AREA =3,
|
|
||||||
CV_INTER_LANCZOS4 =4
|
|
||||||
*/
|
|
||||||
int interpolation = (info.Length() < 3) ? (int)cv::INTER_LINEAR : info[2]->Uint32Value();
|
|
||||||
|
|
||||||
Matrix *self = Nan::ObjectWrap::Unwrap<Matrix>(info.This());
|
cv::Size size(x, y);
|
||||||
cv::Mat res = cv::Mat(x, y, CV_32FC3);
|
|
||||||
cv::resize(self->mat, res, cv::Size(x, y), 0, 0, interpolation);
|
if (size.area() == 0) {
|
||||||
~self->mat;
|
return Nan::ThrowError("Area of size must be > 0");
|
||||||
self->mat = res;
|
}
|
||||||
|
|
||||||
return;
|
double fx = 0;
|
||||||
|
double fy = 0;
|
||||||
|
int interpolation = cv::INTER_LINEAR;
|
||||||
|
|
||||||
|
// if 4 or more args, then expect fx, fy next
|
||||||
|
if (numargs >= 4+isAsync) {
|
||||||
|
DOUBLE_FROM_ARGS(fx, 2)
|
||||||
|
DOUBLE_FROM_ARGS(fy, 3)
|
||||||
|
if (numargs == 5+isAsync) {
|
||||||
|
INT_FROM_ARGS(interpolation, 5)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// if 3 args after possible function, expect interpolation
|
||||||
|
if (numargs == 3+isAsync) {
|
||||||
|
INT_FROM_ARGS(interpolation, 3)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if async
|
||||||
|
if (isAsync){
|
||||||
|
REQ_FUN_ARG(numargs-1, cb);
|
||||||
|
Nan::Callback *callback = new Nan::Callback(cb.As<Function>());
|
||||||
|
Nan::AsyncQueueWorker(new ResizeASyncWorker(callback, self, size, fx, fy, interpolation));
|
||||||
|
info.GetReturnValue().Set(Nan::Null());
|
||||||
|
} else {
|
||||||
|
Matrix *self = Nan::ObjectWrap::Unwrap<Matrix>(info.This());
|
||||||
|
cv::Mat res = cv::Mat(x, y, CV_32FC3);
|
||||||
|
cv::resize(self->mat, res, cv::Size(x, y), 0, 0, interpolation);
|
||||||
|
~self->mat;
|
||||||
|
self->mat = res;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NAN_METHOD(Matrix::Rotate) {
|
NAN_METHOD(Matrix::Rotate) {
|
||||||
|
|||||||
@ -90,7 +90,9 @@ public:
|
|||||||
|
|
||||||
// Feature Detection
|
// Feature Detection
|
||||||
JSFUNC(GoodFeaturesToTrack)
|
JSFUNC(GoodFeaturesToTrack)
|
||||||
|
#ifdef HAVE_OPENCV_VIDEO
|
||||||
JSFUNC(CalcOpticalFlowPyrLK)
|
JSFUNC(CalcOpticalFlowPyrLK)
|
||||||
|
#endif
|
||||||
JSFUNC(HoughLinesP)
|
JSFUNC(HoughLinesP)
|
||||||
JSFUNC(HoughCircles)
|
JSFUNC(HoughCircles)
|
||||||
|
|
||||||
|
|||||||
35
src/OpenCV.h
35
src/OpenCV.h
@ -10,22 +10,41 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#include <opencv2/core/version.hpp>
|
||||||
|
#if !((((CV_MAJOR_VERSION <= 2) && (CV_MINOR_VERSION <= 4)) && (CV_MINOR_VERSION < 13)) || ((CV_MAJOR_VERSION >= 3) && (CV_MINOR_VERSION < 1)))
|
||||||
|
#define INCLUDE_AVAILABLE_MODULES_ONLY
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <v8.h>
|
#include <v8.h>
|
||||||
#include <node.h>
|
#include <node.h>
|
||||||
#include <node_object_wrap.h>
|
#include <node_object_wrap.h>
|
||||||
#include <node_version.h>
|
#include <node_version.h>
|
||||||
#include <node_buffer.h>
|
#include <node_buffer.h>
|
||||||
#include <opencv/cv.h>
|
#include <opencv2/opencv.hpp>
|
||||||
|
|
||||||
|
#if ((CV_MAJOR_VERSION <= 2) && (CV_MINOR_VERSION <= 4) && (CV_MINOR_VERSION < 10))
|
||||||
#include <opencv/highgui.h>
|
#include <opencv/highgui.h>
|
||||||
#if CV_MAJOR_VERSION >= 3
|
#else
|
||||||
#include <opencv2/highgui.hpp>
|
#include <opencv2/imgcodecs/imgcodecs_c.h>
|
||||||
#include <opencv2/imgproc.hpp>
|
|
||||||
#include <opencv2/videoio.hpp>
|
|
||||||
#include <opencv2/opencv_modules.hpp>
|
|
||||||
#endif
|
#endif
|
||||||
#if ((CV_MAJOR_VERSION == 2) && (CV_MINOR_VERSION >=4) && (CV_SUBMINOR_VERSION>=4))
|
|
||||||
#define HAVE_OPENCV_FACE
|
#ifndef INCLUDE_AVAILABLE_MODULES_ONLY
|
||||||
|
#define HAVE_OPENCV_CALIB3D
|
||||||
|
#define HAVE_OPENCV_FEATURES2D
|
||||||
|
#define HAVE_OPENCV_FLANN
|
||||||
|
#define HAVE_OPENCV_HIGHGUI
|
||||||
|
// #define HAVE_OPENCV_IMGCODECS
|
||||||
|
#define HAVE_OPENCV_IMGPROC
|
||||||
|
#define HAVE_OPENCV_ML
|
||||||
|
#define HAVE_OPENCV_OBJDETECT
|
||||||
|
#define HAVE_OPENCV_PHOTO
|
||||||
|
#define HAVE_OPENCV_SHAPE
|
||||||
|
#define HAVE_OPENCV_STITCHING
|
||||||
|
#define HAVE_OPENCV_SUPERRES
|
||||||
|
#define HAVE_OPENCV_VIDEO
|
||||||
|
#define HAVE_OPENCV_VIDEOIO
|
||||||
|
#define HAVE_OPENCV_VIDEOSTAB
|
||||||
|
#define HAVE_OPENCV_VIZ
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|||||||
@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#ifdef HAVE_OPENCV_VIDEOIO
|
||||||
|
|
||||||
Nan::Persistent<FunctionTemplate> VideoCaptureWrap::constructor;
|
Nan::Persistent<FunctionTemplate> VideoCaptureWrap::constructor;
|
||||||
|
|
||||||
struct videocapture_baton {
|
struct videocapture_baton {
|
||||||
@ -36,6 +38,7 @@ void VideoCaptureWrap::Init(Local<Object> target) {
|
|||||||
Nan::SetPrototypeMethod(ctor, "getFrameAt", GetFrameAt);
|
Nan::SetPrototypeMethod(ctor, "getFrameAt", GetFrameAt);
|
||||||
Nan::SetPrototypeMethod(ctor, "getFrameCount", GetFrameCount);
|
Nan::SetPrototypeMethod(ctor, "getFrameCount", GetFrameCount);
|
||||||
Nan::SetPrototypeMethod(ctor, "getFPS", GetFPS);
|
Nan::SetPrototypeMethod(ctor, "getFPS", GetFPS);
|
||||||
|
Nan::SetPrototypeMethod(ctor, "setFPS", SetFPS);
|
||||||
Nan::SetPrototypeMethod(ctor, "release", Release);
|
Nan::SetPrototypeMethod(ctor, "release", Release);
|
||||||
Nan::SetPrototypeMethod(ctor, "ReadSync", ReadSync);
|
Nan::SetPrototypeMethod(ctor, "ReadSync", ReadSync);
|
||||||
Nan::SetPrototypeMethod(ctor, "grab", Grab);
|
Nan::SetPrototypeMethod(ctor, "grab", Grab);
|
||||||
@ -125,6 +128,21 @@ NAN_METHOD(VideoCaptureWrap::GetFPS) {
|
|||||||
info.GetReturnValue().Set(Nan::New<Number>(fps));
|
info.GetReturnValue().Set(Nan::New<Number>(fps));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NAN_METHOD(VideoCaptureWrap::SetFPS) {
|
||||||
|
Nan::HandleScope scope;
|
||||||
|
VideoCaptureWrap *v = Nan::ObjectWrap::Unwrap<VideoCaptureWrap>(info.This());
|
||||||
|
|
||||||
|
if (info.Length() > 0) {
|
||||||
|
if (info[0]->IsNumber()) {
|
||||||
|
int fps = info[0]->IntegerValue();
|
||||||
|
v->cap.set(CV_CAP_PROP_FPS, fps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int fps = int(v->cap.get(CV_CAP_PROP_FPS));
|
||||||
|
|
||||||
|
info.GetReturnValue().Set(Nan::New<Number>(fps));
|
||||||
|
}
|
||||||
|
|
||||||
NAN_METHOD(VideoCaptureWrap::GetHeight) {
|
NAN_METHOD(VideoCaptureWrap::GetHeight) {
|
||||||
Nan::HandleScope scope;
|
Nan::HandleScope scope;
|
||||||
@ -311,3 +329,5 @@ NAN_METHOD(VideoCaptureWrap::Retrieve) {
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
#include "OpenCV.h"
|
#include "OpenCV.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_OPENCV_VIDEOIO
|
||||||
|
|
||||||
class VideoCaptureWrap: public Nan::ObjectWrap {
|
class VideoCaptureWrap: public Nan::ObjectWrap {
|
||||||
public:
|
public:
|
||||||
cv::VideoCapture cap;
|
cv::VideoCapture cap;
|
||||||
@ -30,9 +32,12 @@ public:
|
|||||||
static NAN_METHOD(GetFrameCount);
|
static NAN_METHOD(GetFrameCount);
|
||||||
|
|
||||||
static NAN_METHOD(GetFPS);
|
static NAN_METHOD(GetFPS);
|
||||||
|
static NAN_METHOD(SetFPS);
|
||||||
|
|
||||||
static NAN_METHOD(GetFrameAt);
|
static NAN_METHOD(GetFrameAt);
|
||||||
|
|
||||||
// release the stream
|
// release the stream
|
||||||
static NAN_METHOD(Release);
|
static NAN_METHOD(Release);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#ifdef HAVE_OPENCV_VIDEOIO
|
||||||
|
|
||||||
Nan::Persistent<FunctionTemplate> VideoWriterWrap::constructor;
|
Nan::Persistent<FunctionTemplate> VideoWriterWrap::constructor;
|
||||||
|
|
||||||
struct videowriter_baton {
|
struct videowriter_baton {
|
||||||
@ -150,3 +152,4 @@ NAN_METHOD(VideoWriterWrap::WriteSync) {
|
|||||||
info.GetReturnValue().Set(Nan::Null());
|
info.GetReturnValue().Set(Nan::Null());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
#include "OpenCV.h"
|
#include "OpenCV.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_OPENCV_VIDEOIO
|
||||||
|
|
||||||
class VideoWriterWrap: public Nan::ObjectWrap {
|
class VideoWriterWrap: public Nan::ObjectWrap {
|
||||||
public:
|
public:
|
||||||
cv::VideoWriter writer;
|
cv::VideoWriter writer;
|
||||||
@ -16,3 +18,5 @@ public:
|
|||||||
// release the stream
|
// release the stream
|
||||||
static NAN_METHOD(Release);
|
static NAN_METHOD(Release);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
20
src/init.cc
20
src/init.cc
@ -24,23 +24,39 @@ extern "C" void init(Local<Object> target) {
|
|||||||
|
|
||||||
Point::Init(target);
|
Point::Init(target);
|
||||||
Matrix::Init(target);
|
Matrix::Init(target);
|
||||||
|
#ifdef HAVE_OPENCV_OBJDETECT
|
||||||
CascadeClassifierWrap::Init(target);
|
CascadeClassifierWrap::Init(target);
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_OPENCV_VIDEOIO
|
||||||
VideoCaptureWrap::Init(target);
|
VideoCaptureWrap::Init(target);
|
||||||
VideoWriterWrap::Init(target);
|
VideoWriterWrap::Init(target);
|
||||||
|
#endif
|
||||||
Contour::Init(target);
|
Contour::Init(target);
|
||||||
|
#ifdef HAVE_OPENCV_VIDEO
|
||||||
TrackedObject::Init(target);
|
TrackedObject::Init(target);
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_OPENCV_HIGHGUI
|
||||||
NamedWindow::Init(target);
|
NamedWindow::Init(target);
|
||||||
|
#endif
|
||||||
Constants::Init(target);
|
Constants::Init(target);
|
||||||
|
#ifdef HAVE_OPENCV_CALIB3D
|
||||||
Calib3D::Init(target);
|
Calib3D::Init(target);
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_OPENCV_IMGPROC
|
||||||
ImgProc::Init(target);
|
ImgProc::Init(target);
|
||||||
Histogram::Init(target);
|
Histogram::Init(target);
|
||||||
|
#endif
|
||||||
#if CV_MAJOR_VERSION < 3
|
#if CV_MAJOR_VERSION < 3
|
||||||
StereoBM::Init(target);
|
StereoBM::Init(target);
|
||||||
StereoSGBM::Init(target);
|
StereoSGBM::Init(target);
|
||||||
StereoGC::Init(target);
|
StereoGC::Init(target);
|
||||||
#if CV_MAJOR_VERSION == 2 && CV_MINOR_VERSION >=4
|
#if CV_MAJOR_VERSION == 2 && CV_MINOR_VERSION >=4
|
||||||
BackgroundSubtractorWrap::Init(target);
|
#ifdef HAVE_OPENCV_VIDEO
|
||||||
Features::Init(target);
|
BackgroundSubtractorWrap::Init(target);
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_OPENCV_FEATURES2D
|
||||||
|
Features::Init(target);
|
||||||
|
#endif
|
||||||
LDAWrap::Init(target);
|
LDAWrap::Init(target);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user