Compiles against OpenCV 3.0.0

This commit is contained in:
Simon Vogl 2015-06-11 12:58:50 +02:00
parent 585790f06e
commit 2931440acb
11 changed files with 50 additions and 29 deletions

View File

@ -3,6 +3,8 @@
#include "OpenCV.h" #include "OpenCV.h"
#include <opencv2/calib3d.hpp>
// Implementation of calib3d.hpp functions // Implementation of calib3d.hpp functions
class Calib3D: public node::ObjectWrap { class Calib3D: public node::ObjectWrap {

View File

@ -2,6 +2,7 @@
#include "OpenCV.h" #include "OpenCV.h"
#include "Matrix.h" #include "Matrix.h"
#include <opencv2/video/tracking.hpp>
#define CHANNEL_HUE 0 #define CHANNEL_HUE 0
#define CHANNEL_SATURATION 1 #define CHANNEL_SATURATION 1

View File

@ -4,6 +4,11 @@
#include <nan.h> #include <nan.h>
#include <opencv2/objdetect.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/imgcodecs.hpp>
Persistent<FunctionTemplate> CascadeClassifierWrap::constructor; Persistent<FunctionTemplate> CascadeClassifierWrap::constructor;
void void

View File

@ -1,4 +1,5 @@
#include "OpenCV.h" #include "OpenCV.h"
#include <opencv2/objdetect.hpp>
class CascadeClassifierWrap: public node::ObjectWrap { class CascadeClassifierWrap: public node::ObjectWrap {
public: public:

View File

@ -4,6 +4,8 @@
#include <iostream> #include <iostream>
#include <opencv2/imgproc.hpp>
v8::Persistent<FunctionTemplate> Contour::constructor; v8::Persistent<FunctionTemplate> Contour::constructor;

View File

@ -3,6 +3,11 @@
#include "OpenCV.h" #include "OpenCV.h"
#include <nan.h> #include <nan.h>
#include <opencv2/core.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/ml.hpp>
v8::Persistent<FunctionTemplate> Matrix::constructor; v8::Persistent<FunctionTemplate> Matrix::constructor;
cv::Scalar setColor(Local<Object> objColor); cv::Scalar setColor(Local<Object> objColor);

View File

@ -2,6 +2,10 @@
#include "Matrix.h" #include "Matrix.h"
#include <nan.h> #include <nan.h>
#include <opencv2/core.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/imgcodecs.hpp>
void void
OpenCV::Init(Handle<Object> target) { OpenCV::Init(Handle<Object> target) {
NanScope(); NanScope();

View File

@ -7,7 +7,9 @@
#include <node_version.h> #include <node_version.h>
#include <node_buffer.h> #include <node_buffer.h>
#include <opencv/cv.h> #include <opencv/cv.h>
#include <opencv/highgui.h> #include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/videoio.hpp>
#include <string.h> #include <string.h>
#include <nan.h> #include <nan.h>

View File

@ -1,6 +1,7 @@
#include "Stereo.h" #include "Stereo.h"
#include "Matrix.h" #include "Matrix.h"
#include <opencv2/legacy/legacy.hpp> //#include <opencv2/legacy.hpp>
#include <opencv2/ml.hpp>
// Block matching // Block matching
@ -17,9 +18,9 @@ StereoBM::Init(Handle<Object> target) {
NODE_SET_PROTOTYPE_METHOD(ctor, "compute", Compute); NODE_SET_PROTOTYPE_METHOD(ctor, "compute", Compute);
ctor->Set(NanNew<String>("BASIC_PRESET"), NanNew<Integer>((int)cv::StereoBM::BASIC_PRESET)); ctor->Set(NanNew<String>("BASIC_PRESET"), NanNew<Integer>((int)0));
ctor->Set(NanNew<String>("FISH_EYE_PRESET"), NanNew<Integer>((int)cv::StereoBM::FISH_EYE_PRESET)); ctor->Set(NanNew<String>("FISH_EYE_PRESET"), NanNew<Integer>((int)1));
ctor->Set(NanNew<String>("NARROW_PRESET"), NanNew<Integer>((int)cv::StereoBM::NARROW_PRESET)); ctor->Set(NanNew<String>("NARROW_PRESET"), NanNew<Integer>((int)2));
target->Set(NanNew("StereoBM"), ctor->GetFunction()); target->Set(NanNew("StereoBM"), ctor->GetFunction());
} }
@ -30,7 +31,7 @@ NAN_METHOD(StereoBM::New) {
if (args.This()->InternalFieldCount() == 0) if (args.This()->InternalFieldCount() == 0)
NanThrowTypeError("Cannot instantiate without new"); NanThrowTypeError("Cannot instantiate without new");
StereoBM *stereo; StereoBM *stereo=0;
if (args.Length() == 0) if (args.Length() == 0)
{ {
@ -38,25 +39,21 @@ NAN_METHOD(StereoBM::New) {
} }
else if (args.Length() == 1) else if (args.Length() == 1)
{ {
stereo = new StereoBM(args[0]->IntegerValue()); // preset stereo = new StereoBM(args[0]->IntegerValue()); // disparity search range
} }
else if (args.Length() == 2) else if (args.Length() == 2)
{ {
stereo = new StereoBM(args[0]->IntegerValue(), args[1]->IntegerValue()); // preset, disparity search range stereo = new StereoBM(args[0]->IntegerValue(), args[1]->IntegerValue()); // disparity search range, sum of absolute differences window size
}
else
{
stereo = new StereoBM(args[0]->IntegerValue(), args[1]->IntegerValue(), args[2]->IntegerValue()); // preset, disparity search range, sum of absolute differences window size
} }
stereo->Wrap(args.Holder()); stereo->Wrap(args.Holder());
NanReturnValue(args.Holder()); NanReturnValue(args.Holder());
} }
StereoBM::StereoBM(int preset, int ndisparities, int SADWindowSize) StereoBM::StereoBM( int ndisparities, int SADWindowSize)
: ObjectWrap(), stereo(preset, ndisparities, SADWindowSize) : ObjectWrap()
{ {
stereo = cv::StereoBM::create(ndisparities, SADWindowSize);
} }
// TODO make this async // TODO make this async
@ -83,8 +80,8 @@ NAN_METHOD(StereoBM::Compute)
} }
// Compute stereo using the block matching algorithm // Compute stereo using the block matching algorithm
cv::Mat disparity; cv::Mat disparity(left.size(), type);
self->stereo(left, right, disparity, type); self->stereo->compute(left, right, disparity);
// Wrap the returned disparity map // Wrap the returned disparity map
Local<Object> disparityWrap = NanNew(Matrix::constructor)->GetFunction()->NewInstance(); Local<Object> disparityWrap = NanNew(Matrix::constructor)->GetFunction()->NewInstance();
@ -187,15 +184,15 @@ NAN_METHOD(StereoSGBM::New) {
} }
StereoSGBM::StereoSGBM() StereoSGBM::StereoSGBM()
: ObjectWrap(), stereo() : ObjectWrap()
{ {
stereo = cv::StereoSGBM::create(0,64,11);
} }
StereoSGBM::StereoSGBM(int minDisparity, int ndisparities, int SADWindowSize, int p1, int p2, int disp12MaxDiff, int preFilterCap, int uniquenessRatio, int speckleWindowSize, int speckleRange, bool fullDP) StereoSGBM::StereoSGBM(int minDisparity, int ndisparities, int SADWindowSize, int p1, int p2, int disp12MaxDiff, int preFilterCap, int uniquenessRatio, int speckleWindowSize, int speckleRange, bool fullDP)
: ObjectWrap(), stereo(minDisparity, ndisparities, SADWindowSize, p1, p2, disp12MaxDiff, preFilterCap, uniquenessRatio, speckleWindowSize, speckleRange, fullDP) : ObjectWrap()
{ {
stereo = cv::StereoSGBM::create(minDisparity, ndisparities, SADWindowSize, p1, p2, disp12MaxDiff, preFilterCap, uniquenessRatio, speckleWindowSize, speckleRange, fullDP);
} }
// TODO make this async // TODO make this async
@ -216,7 +213,7 @@ NAN_METHOD(StereoSGBM::Compute)
// Compute stereo using the block matching algorithm // Compute stereo using the block matching algorithm
cv::Mat disparity; cv::Mat disparity;
self->stereo(left, right, disparity); self->stereo->compute(left, right, disparity);
// Wrap the returned disparity map // Wrap the returned disparity map
Local<Object> disparityWrap = NanNew(Matrix::constructor)->GetFunction()->NewInstance(); Local<Object> disparityWrap = NanNew(Matrix::constructor)->GetFunction()->NewInstance();
@ -232,7 +229,7 @@ NAN_METHOD(StereoSGBM::Compute)
} }
}; };
#if 0
// Graph cut // Graph cut
v8::Persistent<FunctionTemplate> StereoGC::constructor; v8::Persistent<FunctionTemplate> StereoGC::constructor;
@ -321,3 +318,4 @@ NAN_METHOD(StereoGC::Compute)
} }
}; };
#endif

View File

@ -2,23 +2,24 @@
#define __NODE_STEREO_H #define __NODE_STEREO_H
#include "OpenCV.h" #include "OpenCV.h"
#include <opencv2/calib3d.hpp>
class StereoBM: public node::ObjectWrap { class StereoBM: public node::ObjectWrap {
public: public:
cv::StereoBM stereo; cv::Ptr<cv::StereoBM> stereo;
static Persistent<FunctionTemplate> constructor; static Persistent<FunctionTemplate> constructor;
static void Init(Handle<Object> target); static void Init(Handle<Object> target);
static NAN_METHOD(New); static NAN_METHOD(New);
StereoBM(int preset = cv::StereoBM::BASIC_PRESET, int ndisparities = 0, int SADWindowSize=21); StereoBM( int ndisparities = 0, int blockSize=21);
JSFUNC(Compute); JSFUNC(Compute);
}; };
class StereoSGBM: public node::ObjectWrap { class StereoSGBM: public node::ObjectWrap {
public: public:
cv::StereoSGBM stereo; cv::Ptr<cv::StereoSGBM> stereo;
static Persistent<FunctionTemplate> constructor; static Persistent<FunctionTemplate> constructor;
static void Init(Handle<Object> target); static void Init(Handle<Object> target);
@ -39,7 +40,7 @@ public:
JSFUNC(Compute); JSFUNC(Compute);
}; };
#if 0
struct CvStereoGCState; struct CvStereoGCState;
class StereoGC: public node::ObjectWrap { class StereoGC: public node::ObjectWrap {
@ -54,5 +55,5 @@ public:
JSFUNC(Compute); JSFUNC(Compute);
}; };
#endif
#endif #endif

View File

@ -31,7 +31,7 @@ init(Handle<Object> target) {
ImgProc::Init(target); ImgProc::Init(target);
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