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 <opencv2/calib3d.hpp>
// Implementation of calib3d.hpp functions
class Calib3D: public node::ObjectWrap {

View File

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

View File

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

View File

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

View File

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

View File

@ -3,6 +3,11 @@
#include "OpenCV.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;
cv::Scalar setColor(Local<Object> objColor);

View File

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

View File

@ -7,7 +7,9 @@
#include <node_version.h>
#include <node_buffer.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 <nan.h>

View File

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

View File

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

View File

@ -31,7 +31,7 @@ init(Handle<Object> target) {
ImgProc::Init(target);
StereoBM::Init(target);
StereoSGBM::Init(target);
StereoGC::Init(target);
//StereoGC::Init(target);
#if CV_MAJOR_VERSION >= 2 && CV_MINOR_VERSION >=4