Commit 909d6fcf authored by Andrey Kamaev's avatar Andrey Kamaev

Move legacy part of opencv_contrib to separate header

parent 3b364330
...@@ -51,11 +51,12 @@ ...@@ -51,11 +51,12 @@
#include "opencv2/photo/photo_c.h" #include "opencv2/photo/photo_c.h"
#include "opencv2/video/tracking_c.h" #include "opencv2/video/tracking_c.h"
#include "opencv2/objdetect/objdetect_c.h" #include "opencv2/objdetect/objdetect_c.h"
#include "opencv2/contrib/compat.hpp"
#include "opencv2/legacy.hpp" #include "opencv2/legacy.hpp"
#include "opencv2/legacy/compat.hpp" #include "opencv2/legacy/compat.hpp"
#include "opencv2/legacy/blobtrack.hpp" #include "opencv2/legacy/blobtrack.hpp"
#include "opencv2/contrib.hpp"
#endif #endif
......
...@@ -48,931 +48,592 @@ ...@@ -48,931 +48,592 @@
#include "opencv2/features2d.hpp" #include "opencv2/features2d.hpp"
#include "opencv2/objdetect.hpp" #include "opencv2/objdetect.hpp"
#include "opencv2/core/core_c.h" namespace cv
{
#include <ostream> class CV_EXPORTS Octree
#ifdef __cplusplus
/****************************************************************************************\
* Adaptive Skin Detector *
\****************************************************************************************/
class CV_EXPORTS CvAdaptiveSkinDetector
{ {
private:
enum {
GSD_HUE_LT = 3,
GSD_HUE_UT = 33,
GSD_INTENSITY_LT = 15,
GSD_INTENSITY_UT = 250
};
class CV_EXPORTS Histogram
{
private:
enum {
HistogramSize = (GSD_HUE_UT - GSD_HUE_LT + 1)
};
protected:
int findCoverageIndex(double surfaceToCover, int defaultValue = 0);
public:
CvHistogram *fHistogram;
Histogram();
virtual ~Histogram();
void findCurveThresholds(int &x1, int &x2, double percent = 0.05);
void mergeWith(Histogram *source, double weight);
};
int nStartCounter, nFrameCount, nSkinHueLowerBound, nSkinHueUpperBound, nMorphingMethod, nSamplingDivider;
double fHistogramMergeFactor, fHuePercentCovered;
Histogram histogramHueMotion, skinHueHistogram;
IplImage *imgHueFrame, *imgSaturationFrame, *imgLastGrayFrame, *imgMotionFrame, *imgFilteredFrame;
IplImage *imgShrinked, *imgTemp, *imgGrayFrame, *imgHSVFrame;
protected:
void initData(IplImage *src, int widthDivider, int heightDivider);
void adaptiveFilter();
public: public:
struct Node
enum { {
MORPHING_METHOD_NONE = 0, Node() {}
MORPHING_METHOD_ERODE = 1, int begin, end;
MORPHING_METHOD_ERODE_ERODE = 2, float x_min, x_max, y_min, y_max, z_min, z_max;
MORPHING_METHOD_ERODE_DILATE = 3 int maxLevels;
bool isLeaf;
int children[8];
}; };
CvAdaptiveSkinDetector(int samplingDivider = 1, int morphingMethod = MORPHING_METHOD_NONE); Octree();
virtual ~CvAdaptiveSkinDetector(); Octree( const std::vector<Point3f>& points, int maxLevels = 10, int minPoints = 20 );
virtual ~Octree();
virtual void process(IplImage *inputBGRImage, IplImage *outputHueMask);
};
/****************************************************************************************\
* Fuzzy MeanShift Tracker *
\****************************************************************************************/
class CV_EXPORTS CvFuzzyPoint {
public:
double x, y, value;
CvFuzzyPoint(double _x, double _y);
};
class CV_EXPORTS CvFuzzyCurve { virtual void buildTree( const std::vector<Point3f>& points, int maxLevels = 10, int minPoints = 20 );
virtual void getPointsWithinSphere( const Point3f& center, float radius,
std::vector<Point3f>& points ) const;
const std::vector<Node>& getNodes() const { return nodes; }
private: private:
std::vector<CvFuzzyPoint> points; int minPoints;
double value, centre; std::vector<Point3f> points;
std::vector<Node> nodes;
bool between(double x, double x1, double x2); virtual void buildNext(size_t node_ind);
public:
CvFuzzyCurve();
~CvFuzzyCurve();
void setCentre(double _centre);
double getCentre();
void clear();
void addPoint(double x, double y);
double calcValue(double param);
double getValue();
void setValue(double _value);
}; };
class CV_EXPORTS CvFuzzyFunction {
public:
std::vector<CvFuzzyCurve> curves;
CvFuzzyFunction();
~CvFuzzyFunction();
void addCurve(CvFuzzyCurve *curve, double value = 0);
void resetValues();
double calcValue();
CvFuzzyCurve *newCurve();
};
class CV_EXPORTS CvFuzzyRule { class CV_EXPORTS Mesh3D
private:
CvFuzzyCurve *fuzzyInput1, *fuzzyInput2;
CvFuzzyCurve *fuzzyOutput;
public:
CvFuzzyRule();
~CvFuzzyRule();
void setRule(CvFuzzyCurve *c1, CvFuzzyCurve *c2, CvFuzzyCurve *o1);
double calcValue(double param1, double param2);
CvFuzzyCurve *getOutputCurve();
};
class CV_EXPORTS CvFuzzyController {
private:
std::vector<CvFuzzyRule*> rules;
public:
CvFuzzyController();
~CvFuzzyController();
void addRule(CvFuzzyCurve *c1, CvFuzzyCurve *c2, CvFuzzyCurve *o1);
double calcOutput(double param1, double param2);
};
class CV_EXPORTS CvFuzzyMeanShiftTracker
{ {
private:
class FuzzyResizer
{
private:
CvFuzzyFunction iInput, iOutput;
CvFuzzyController fuzzyController;
public:
FuzzyResizer();
int calcOutput(double edgeDensity, double density);
};
class SearchWindow
{
public:
FuzzyResizer *fuzzyResizer;
int x, y;
int width, height, maxWidth, maxHeight, ellipseHeight, ellipseWidth;
int ldx, ldy, ldw, ldh, numShifts, numIters;
int xGc, yGc;
long m00, m01, m10, m11, m02, m20;
double ellipseAngle;
double density;
unsigned int depthLow, depthHigh;
int verticalEdgeLeft, verticalEdgeRight, horizontalEdgeTop, horizontalEdgeBottom;
SearchWindow();
~SearchWindow();
void setSize(int _x, int _y, int _width, int _height);
void initDepthValues(IplImage *maskImage, IplImage *depthMap);
bool shift();
void extractInfo(IplImage *maskImage, IplImage *depthMap, bool initDepth);
void getResizeAttribsEdgeDensityLinear(int &resizeDx, int &resizeDy, int &resizeDw, int &resizeDh);
void getResizeAttribsInnerDensity(int &resizeDx, int &resizeDy, int &resizeDw, int &resizeDh);
void getResizeAttribsEdgeDensityFuzzy(int &resizeDx, int &resizeDy, int &resizeDw, int &resizeDh);
bool meanShift(IplImage *maskImage, IplImage *depthMap, int maxIteration, bool initDepth);
};
public: public:
enum TrackingState struct EmptyMeshException {};
{
tsNone = 0,
tsSearching = 1,
tsTracking = 2,
tsSetWindow = 3,
tsDisabled = 10
};
enum ResizeMethod { Mesh3D();
rmEdgeDensityLinear = 0, Mesh3D(const std::vector<Point3f>& vtx);
rmEdgeDensityFuzzy = 1, ~Mesh3D();
rmInnerDensity = 2
};
enum {
MinKernelMass = 1000
};
SearchWindow kernel; void buildOctree();
int searchMode; void clearOctree();
float estimateResolution(float tryRatio = 0.1f);
void computeNormals(float normalRadius, int minNeighbors = 20);
void computeNormals(const std::vector<int>& subset, float normalRadius, int minNeighbors = 20);
private: void writeAsVrml(const String& file, const std::vector<Scalar>& colors = std::vector<Scalar>()) const;
enum
{
MaxMeanShiftIteration = 5,
MaxSetSizeIteration = 5
};
void findOptimumSearchWindow(SearchWindow &searchWindow, IplImage *maskImage, IplImage *depthMap, int maxIteration, int resizeMethod, bool initDepth); std::vector<Point3f> vtx;
std::vector<Point3f> normals;
float resolution;
Octree octree;
public: const static Point3f allzero;
CvFuzzyMeanShiftTracker();
~CvFuzzyMeanShiftTracker();
void track(IplImage *maskImage, IplImage *depthMap, int resizeMethod, bool resetSearch, int minKernelMass = MinKernelMass);
}; };
class CV_EXPORTS SpinImageModel
namespace cv
{ {
public:
class CV_EXPORTS Octree /* model parameters, leave unset for default or auto estimate */
{ float normalRadius;
public: int minNeighbors;
struct Node
{
Node() {}
int begin, end;
float x_min, x_max, y_min, y_max, z_min, z_max;
int maxLevels;
bool isLeaf;
int children[8];
};
Octree();
Octree( const std::vector<Point3f>& points, int maxLevels = 10, int minPoints = 20 );
virtual ~Octree();
virtual void buildTree( const std::vector<Point3f>& points, int maxLevels = 10, int minPoints = 20 );
virtual void getPointsWithinSphere( const Point3f& center, float radius,
std::vector<Point3f>& points ) const;
const std::vector<Node>& getNodes() const { return nodes; }
private:
int minPoints;
std::vector<Point3f> points;
std::vector<Node> nodes;
virtual void buildNext(size_t node_ind);
};
class CV_EXPORTS Mesh3D
{
public:
struct EmptyMeshException {};
Mesh3D();
Mesh3D(const std::vector<Point3f>& vtx);
~Mesh3D();
void buildOctree();
void clearOctree();
float estimateResolution(float tryRatio = 0.1f);
void computeNormals(float normalRadius, int minNeighbors = 20);
void computeNormals(const std::vector<int>& subset, float normalRadius, int minNeighbors = 20);
void writeAsVrml(const String& file, const std::vector<Scalar>& colors = std::vector<Scalar>()) const;
std::vector<Point3f> vtx;
std::vector<Point3f> normals;
float resolution;
Octree octree;
const static Point3f allzero;
};
class CV_EXPORTS SpinImageModel
{
public:
/* model parameters, leave unset for default or auto estimate */
float normalRadius;
int minNeighbors;
float binSize;
int imageWidth;
float lambda; float binSize;
float gamma; int imageWidth;
float T_GeometriccConsistency; float lambda;
float T_GroupingCorespondances; float gamma;
/* public interface */ float T_GeometriccConsistency;
SpinImageModel(); float T_GroupingCorespondances;
explicit SpinImageModel(const Mesh3D& mesh);
~SpinImageModel();
void setLogger(std::ostream* log); /* public interface */
void selectRandomSubset(float ratio); SpinImageModel();
void setSubset(const std::vector<int>& subset); explicit SpinImageModel(const Mesh3D& mesh);
void compute(); ~SpinImageModel();
void match(const SpinImageModel& scene, std::vector< std::vector<Vec2i> >& result); void selectRandomSubset(float ratio);
void setSubset(const std::vector<int>& subset);
void compute();
Mat packRandomScaledSpins(bool separateScale = false, size_t xCount = 10, size_t yCount = 10) const; void match(const SpinImageModel& scene, std::vector< std::vector<Vec2i> >& result);
size_t getSpinCount() const { return spinImages.rows; } Mat packRandomScaledSpins(bool separateScale = false, size_t xCount = 10, size_t yCount = 10) const;
Mat getSpinImage(size_t index) const { return spinImages.row((int)index); }
const Point3f& getSpinVertex(size_t index) const { return mesh.vtx[subset[index]]; }
const Point3f& getSpinNormal(size_t index) const { return mesh.normals[subset[index]]; }
const Mesh3D& getMesh() const { return mesh; } size_t getSpinCount() const { return spinImages.rows; }
Mesh3D& getMesh() { return mesh; } Mat getSpinImage(size_t index) const { return spinImages.row((int)index); }
const Point3f& getSpinVertex(size_t index) const { return mesh.vtx[subset[index]]; }
const Point3f& getSpinNormal(size_t index) const { return mesh.normals[subset[index]]; }
/* static utility functions */ const Mesh3D& getMesh() const { return mesh; }
static bool spinCorrelation(const Mat& spin1, const Mat& spin2, float lambda, float& result); Mesh3D& getMesh() { return mesh; }
static Point2f calcSpinMapCoo(const Point3f& point, const Point3f& vertex, const Point3f& normal); /* static utility functions */
static bool spinCorrelation(const Mat& spin1, const Mat& spin2, float lambda, float& result);
static float geometricConsistency(const Point3f& pointScene1, const Point3f& normalScene1, static Point2f calcSpinMapCoo(const Point3f& point, const Point3f& vertex, const Point3f& normal);
const Point3f& pointModel1, const Point3f& normalModel1,
const Point3f& pointScene2, const Point3f& normalScene2,
const Point3f& pointModel2, const Point3f& normalModel2);
static float groupingCreteria(const Point3f& pointScene1, const Point3f& normalScene1, static float geometricConsistency(const Point3f& pointScene1, const Point3f& normalScene1,
const Point3f& pointModel1, const Point3f& normalModel1, const Point3f& pointModel1, const Point3f& normalModel1,
const Point3f& pointScene2, const Point3f& normalScene2, const Point3f& pointScene2, const Point3f& normalScene2,
const Point3f& pointModel2, const Point3f& normalModel2, const Point3f& pointModel2, const Point3f& normalModel2);
float gamma);
protected:
void defaultParams();
void matchSpinToModel(const Mat& spin, std::vector<int>& indeces, static float groupingCreteria(const Point3f& pointScene1, const Point3f& normalScene1,
std::vector<float>& corrCoeffs, bool useExtremeOutliers = true) const; const Point3f& pointModel1, const Point3f& normalModel1,
const Point3f& pointScene2, const Point3f& normalScene2,
const Point3f& pointModel2, const Point3f& normalModel2,
float gamma);
protected:
void defaultParams();
void repackSpinImages(const std::vector<uchar>& mask, Mat& spinImages, bool reAlloc = true) const; void matchSpinToModel(const Mat& spin, std::vector<int>& indeces,
std::vector<float>& corrCoeffs, bool useExtremeOutliers = true) const;
std::vector<int> subset; void repackSpinImages(const std::vector<uchar>& mask, Mat& spinImages, bool reAlloc = true) const;
Mesh3D mesh;
Mat spinImages;
std::ostream* out;
};
class CV_EXPORTS TickMeter std::vector<int> subset;
{ Mesh3D mesh;
public: Mat spinImages;
TickMeter(); };
void start();
void stop();
int64 getTimeTicks() const;
double getTimeMicro() const;
double getTimeMilli() const;
double getTimeSec() const;
int64 getCounter() const;
void reset();
private:
int64 counter;
int64 sumTime;
int64 startTime;
};
CV_EXPORTS std::ostream& operator<<(std::ostream& out, const TickMeter& tm);
class CV_EXPORTS SelfSimDescriptor class CV_EXPORTS TickMeter
{ {
public: public:
SelfSimDescriptor(); TickMeter();
SelfSimDescriptor(int _ssize, int _lsize, void start();
int _startDistanceBucket=DEFAULT_START_DISTANCE_BUCKET, void stop();
int _numberOfDistanceBuckets=DEFAULT_NUM_DISTANCE_BUCKETS,
int _nangles=DEFAULT_NUM_ANGLES);
SelfSimDescriptor(const SelfSimDescriptor& ss);
virtual ~SelfSimDescriptor();
SelfSimDescriptor& operator = (const SelfSimDescriptor& ss);
size_t getDescriptorSize() const;
Size getGridSize( Size imgsize, Size winStride ) const;
virtual void compute(const Mat& img, std::vector<float>& descriptors, Size winStride=Size(),
const std::vector<Point>& locations=std::vector<Point>()) const;
virtual void computeLogPolarMapping(Mat& mappingMask) const;
virtual void SSD(const Mat& img, Point pt, Mat& ssd) const;
int smallSize;
int largeSize;
int startDistanceBucket;
int numberOfDistanceBuckets;
int numberOfAngles;
enum { DEFAULT_SMALL_SIZE = 5, DEFAULT_LARGE_SIZE = 41,
DEFAULT_NUM_ANGLES = 20, DEFAULT_START_DISTANCE_BUCKET = 3,
DEFAULT_NUM_DISTANCE_BUCKETS = 7 };
};
int64 getTimeTicks() const;
double getTimeMicro() const;
double getTimeMilli() const;
double getTimeSec() const;
int64 getCounter() const;
typedef bool (*BundleAdjustCallback)(int iteration, double norm_error, void* user_data); void reset();
private:
int64 counter;
int64 sumTime;
int64 startTime;
};
class CV_EXPORTS LevMarqSparse { //CV_EXPORTS std::ostream& operator<<(std::ostream& out, const TickMeter& tm);
public:
LevMarqSparse();
LevMarqSparse(int npoints, // number of points
int ncameras, // number of cameras
int nPointParams, // number of params per one point (3 in case of 3D points)
int nCameraParams, // number of parameters per one camera
int nErrParams, // number of parameters in measurement vector
// for 1 point at one camera (2 in case of 2D projections)
Mat& visibility, // visibility matrix. rows correspond to points, columns correspond to cameras
// 1 - point is visible for the camera, 0 - invisible
Mat& P0, // starting vector of parameters, first cameras then points
Mat& X, // measurements, in order of visibility. non visible cases are skipped
TermCriteria criteria, // termination criteria
// callback for estimation of Jacobian matrices
void (CV_CDECL * fjac)(int i, int j, Mat& point_params,
Mat& cam_params, Mat& A, Mat& B, void* data),
// callback for estimation of backprojection errors
void (CV_CDECL * func)(int i, int j, Mat& point_params,
Mat& cam_params, Mat& estim, void* data),
void* data, // user-specific data passed to the callbacks
BundleAdjustCallback cb, void* user_data
);
virtual ~LevMarqSparse();
virtual void run( int npoints, // number of points
int ncameras, // number of cameras
int nPointParams, // number of params per one point (3 in case of 3D points)
int nCameraParams, // number of parameters per one camera
int nErrParams, // number of parameters in measurement vector
// for 1 point at one camera (2 in case of 2D projections)
Mat& visibility, // visibility matrix. rows correspond to points, columns correspond to cameras
// 1 - point is visible for the camera, 0 - invisible
Mat& P0, // starting vector of parameters, first cameras then points
Mat& X, // measurements, in order of visibility. non visible cases are skipped
TermCriteria criteria, // termination criteria
// callback for estimation of Jacobian matrices
void (CV_CDECL * fjac)(int i, int j, Mat& point_params,
Mat& cam_params, Mat& A, Mat& B, void* data),
// callback for estimation of backprojection errors
void (CV_CDECL * func)(int i, int j, Mat& point_params,
Mat& cam_params, Mat& estim, void* data),
void* data // user-specific data passed to the callbacks
);
virtual void clear();
// useful function to do simple bundle adjustment tasks
static void bundleAdjust(std::vector<Point3d>& points, // positions of points in global coordinate system (input and output)
const std::vector<std::vector<Point2d> >& imagePoints, // projections of 3d points for every camera
const std::vector<std::vector<int> >& visibility, // visibility of 3d points for every camera
std::vector<Mat>& cameraMatrix, // intrinsic matrices of all cameras (input and output)
std::vector<Mat>& R, // rotation matrices of all cameras (input and output)
std::vector<Mat>& T, // translation vector of all cameras (input and output)
std::vector<Mat>& distCoeffs, // distortion coefficients of all cameras (input and output)
const TermCriteria& criteria=
TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, DBL_EPSILON),
BundleAdjustCallback cb = 0, void* user_data = 0);
public: class CV_EXPORTS SelfSimDescriptor
virtual void optimize(CvMat &_vis); //main function that runs minimization {
public:
SelfSimDescriptor();
SelfSimDescriptor(int _ssize, int _lsize,
int _startDistanceBucket=DEFAULT_START_DISTANCE_BUCKET,
int _numberOfDistanceBuckets=DEFAULT_NUM_DISTANCE_BUCKETS,
int _nangles=DEFAULT_NUM_ANGLES);
SelfSimDescriptor(const SelfSimDescriptor& ss);
virtual ~SelfSimDescriptor();
SelfSimDescriptor& operator = (const SelfSimDescriptor& ss);
size_t getDescriptorSize() const;
Size getGridSize( Size imgsize, Size winStride ) const;
virtual void compute(const Mat& img, std::vector<float>& descriptors, Size winStride=Size(),
const std::vector<Point>& locations=std::vector<Point>()) const;
virtual void computeLogPolarMapping(Mat& mappingMask) const;
virtual void SSD(const Mat& img, Point pt, Mat& ssd) const;
int smallSize;
int largeSize;
int startDistanceBucket;
int numberOfDistanceBuckets;
int numberOfAngles;
enum { DEFAULT_SMALL_SIZE = 5, DEFAULT_LARGE_SIZE = 41,
DEFAULT_NUM_ANGLES = 20, DEFAULT_START_DISTANCE_BUCKET = 3,
DEFAULT_NUM_DISTANCE_BUCKETS = 7 };
};
//iteratively asks for measurement for visible camera-point pairs
void ask_for_proj(CvMat &_vis,bool once=false);
//iteratively asks for Jacobians for every camera_point pair
void ask_for_projac(CvMat &_vis);
CvMat* err; //error X-hX CV_EXPORTS_W int chamerMatching( Mat& img, Mat& templ,
double prevErrNorm, errNorm; CV_OUT std::vector<std::vector<Point> >& results, CV_OUT std::vector<float>& cost,
double lambda; double templScale=1, int maxMatches = 20,
CvTermCriteria criteria; double minMatchDistance = 1.0, int padX = 3,
int iters; int padY = 3, int scales = 5, double minScale = 0.6, double maxScale = 1.6,
double orientationWeight = 0.5, double truncate = 20);
CvMat** U; //size of array is equal to number of cameras
CvMat** V; //size of array is equal to number of points
CvMat** inv_V_star; //inverse of V*
CvMat** A; class CV_EXPORTS_W StereoVar
CvMat** B; {
CvMat** W; public:
// Flags
enum {USE_INITIAL_DISPARITY = 1, USE_EQUALIZE_HIST = 2, USE_SMART_ID = 4, USE_AUTO_PARAMS = 8, USE_MEDIAN_FILTERING = 16};
enum {CYCLE_O, CYCLE_V};
enum {PENALIZATION_TICHONOV, PENALIZATION_CHARBONNIER, PENALIZATION_PERONA_MALIK};
//! the default constructor
CV_WRAP StereoVar();
//! the full constructor taking all the necessary algorithm parameters
CV_WRAP StereoVar(int levels, double pyrScale, int nIt, int minDisp, int maxDisp, int poly_n, double poly_sigma, float fi, float lambda, int penalization, int cycle, int flags);
//! the destructor
virtual ~StereoVar();
//! the stereo correspondence operator that computes disparity map for the specified rectified stereo pair
CV_WRAP_AS(compute) virtual void operator()(const Mat& left, const Mat& right, CV_OUT Mat& disp);
CV_PROP_RW int levels;
CV_PROP_RW double pyrScale;
CV_PROP_RW int nIt;
CV_PROP_RW int minDisp;
CV_PROP_RW int maxDisp;
CV_PROP_RW int poly_n;
CV_PROP_RW double poly_sigma;
CV_PROP_RW float fi;
CV_PROP_RW float lambda;
CV_PROP_RW int penalization;
CV_PROP_RW int cycle;
CV_PROP_RW int flags;
CvMat* X; //measurement private:
CvMat* hX; //current measurement extimation given new parameter vector void autoParams();
void FMG(Mat &I1, Mat &I2, Mat &I2x, Mat &u, int level);
void VCycle_MyFAS(Mat &I1_h, Mat &I2_h, Mat &I2x_h, Mat &u_h, int level);
void VariationalSolver(Mat &I1_h, Mat &I2_h, Mat &I2x_h, Mat &u_h, int level);
};
CvMat* prevP; //current already accepted parameter. CV_EXPORTS void polyfit(const Mat& srcx, const Mat& srcy, Mat& dst, int order);
CvMat* P; // parameters used to evaluate function with new params
// this parameters may be rejected
CvMat* deltaP; //computed increase of parameters (result of normal system solution ) class CV_EXPORTS Directory
{
public:
static std::vector<String> GetListFiles ( const String& path, const String & exten = "*", bool addPath = true );
static std::vector<String> GetListFilesR ( const String& path, const String & exten = "*", bool addPath = true );
static std::vector<String> GetListFolders( const String& path, const String & exten = "*", bool addPath = true );
};
CvMat** ea; // sum_i AijT * e_ij , used as right part of normal equation /*
// length of array is j = number of cameras * Generation of a set of different colors by the following way:
CvMat** eb; // sum_j BijT * e_ij , used as right part of normal equation * 1) generate more then need colors (in "factor" times) in RGB,
// length of array is i = number of points * 2) convert them to Lab,
* 3) choose the needed count of colors from the set that are more different from
* each other,
* 4) convert the colors back to RGB
*/
CV_EXPORTS void generateColors( std::vector<Scalar>& colors, size_t count, size_t factor=100 );
/*
* Estimate the rigid body motion from frame0 to frame1. The method is based on the paper
* "Real-Time Visual Odometry from Dense RGB-D Images", F. Steinbucker, J. Strum, D. Cremers, ICCV, 2011.
*/
enum { ROTATION = 1,
TRANSLATION = 2,
RIGID_BODY_MOTION = 4
};
CV_EXPORTS bool RGBDOdometry( Mat& Rt, const Mat& initRt,
const Mat& image0, const Mat& depth0, const Mat& mask0,
const Mat& image1, const Mat& depth1, const Mat& mask1,
const Mat& cameraMatrix, float minDepth=0.f, float maxDepth=4.f, float maxDepthDiff=0.07f,
const std::vector<int>& iterCounts=std::vector<int>(),
const std::vector<float>& minGradientMagnitudes=std::vector<float>(),
int transformType=RIGID_BODY_MOTION );
/**
*Bilinear interpolation technique.
*
*The value of a desired cortical pixel is obtained through a bilinear interpolation of the values
*of the four nearest neighbouring Cartesian pixels to the center of the RF.
*The same principle is applied to the inverse transformation.
*
*More details can be found in http://dx.doi.org/10.1007/978-3-642-23968-7_5
*/
class CV_EXPORTS LogPolar_Interp
{
public:
CvMat** Yj; //length of array is i = num_points LogPolar_Interp() {}
CvMat* S; //big matrix of block Sjk , each block has size num_cam_params x num_cam_params /**
*Constructor
*\param w the width of the input image
*\param h the height of the input image
*\param center the transformation center: where the output precision is maximal
*\param R the number of rings of the cortical image (default value 70 pixel)
*\param ro0 the radius of the blind spot (default value 3 pixel)
*\param full \a 1 (default value) means that the retinal image (the inverse transform) is computed within the circumscribing circle.
* \a 0 means that the retinal image is computed within the inscribed circle.
*\param S the number of sectors of the cortical image (default value 70 pixel).
* Its value is usually internally computed to obtain a pixel aspect ratio equals to 1.
*\param sp \a 1 (default value) means that the parameter \a S is internally computed.
* \a 0 means that the parameter \a S is provided by the user.
*/
LogPolar_Interp(int w, int h, Point2i center, int R=70, double ro0=3.0,
int interp=INTER_LINEAR, int full=1, int S=117, int sp=1);
/**
*Transformation from Cartesian image to cortical (log-polar) image.
*\param source the Cartesian image
*\return the transformed image (cortical image)
*/
const Mat to_cortical(const Mat &source);
/**
*Transformation from cortical image to retinal (inverse log-polar) image.
*\param source the cortical image
*\return the transformed image (retinal image)
*/
const Mat to_cartesian(const Mat &source);
/**
*Destructor
*/
~LogPolar_Interp();
CvMat* JtJ_diag; //diagonal of JtJ, used to backup diagonal elements before augmentation protected:
CvMat* Vis_index; // matrix which element is index of measurement for point i and camera j Mat Rsri;
Mat Csri;
int num_cams; int S, R, M, N;
int num_points; int top, bottom,left,right;
int num_err_param; double ro0, romax, a, q;
int num_cam_param; int interp;
int num_point_param;
//target function and jacobian pointers, which needs to be initialized Mat ETAyx;
void (*fjac)(int i, int j, Mat& point_params, Mat& cam_params, Mat& A, Mat& B, void* data); Mat CSIyx;
void (*func)(int i, int j, Mat& point_params, Mat& cam_params, Mat& estim, void* data);
void* data; void create_map(int M, int N, int R, int S, double ro0);
};
BundleAdjustCallback cb; /**
void* user_data; *Overlapping circular receptive fields technique
}; *
*The Cartesian plane is divided in two regions: the fovea and the periphery.
*The fovea (oversampling) is handled by using the bilinear interpolation technique described above, whereas in
*the periphery we use the overlapping Gaussian circular RFs.
*
*More details can be found in http://dx.doi.org/10.1007/978-3-642-23968-7_5
*/
class CV_EXPORTS LogPolar_Overlapping
{
public:
LogPolar_Overlapping() {}
CV_EXPORTS_W int chamerMatching( Mat& img, Mat& templ, /**
CV_OUT std::vector<std::vector<Point> >& results, CV_OUT std::vector<float>& cost, *Constructor
double templScale=1, int maxMatches = 20, *\param w the width of the input image
double minMatchDistance = 1.0, int padX = 3, *\param h the height of the input image
int padY = 3, int scales = 5, double minScale = 0.6, double maxScale = 1.6, *\param center the transformation center: where the output precision is maximal
double orientationWeight = 0.5, double truncate = 20); *\param R the number of rings of the cortical image (default value 70 pixel)
*\param ro0 the radius of the blind spot (default value 3 pixel)
*\param full \a 1 (default value) means that the retinal image (the inverse transform) is computed within the circumscribing circle.
* \a 0 means that the retinal image is computed within the inscribed circle.
*\param S the number of sectors of the cortical image (default value 70 pixel).
* Its value is usually internally computed to obtain a pixel aspect ratio equals to 1.
*\param sp \a 1 (default value) means that the parameter \a S is internally computed.
* \a 0 means that the parameter \a S is provided by the user.
*/
LogPolar_Overlapping(int w, int h, Point2i center, int R=70,
double ro0=3.0, int full=1, int S=117, int sp=1);
/**
*Transformation from Cartesian image to cortical (log-polar) image.
*\param source the Cartesian image
*\return the transformed image (cortical image)
*/
const Mat to_cortical(const Mat &source);
/**
*Transformation from cortical image to retinal (inverse log-polar) image.
*\param source the cortical image
*\return the transformed image (retinal image)
*/
const Mat to_cartesian(const Mat &source);
/**
*Destructor
*/
~LogPolar_Overlapping();
protected:
class CV_EXPORTS_W StereoVar Mat Rsri;
{ Mat Csri;
public: std::vector<int> Rsr;
// Flags std::vector<int> Csr;
enum {USE_INITIAL_DISPARITY = 1, USE_EQUALIZE_HIST = 2, USE_SMART_ID = 4, USE_AUTO_PARAMS = 8, USE_MEDIAN_FILTERING = 16}; std::vector<double> Wsr;
enum {CYCLE_O, CYCLE_V};
enum {PENALIZATION_TICHONOV, PENALIZATION_CHARBONNIER, PENALIZATION_PERONA_MALIK};
//! the default constructor
CV_WRAP StereoVar();
//! the full constructor taking all the necessary algorithm parameters
CV_WRAP StereoVar(int levels, double pyrScale, int nIt, int minDisp, int maxDisp, int poly_n, double poly_sigma, float fi, float lambda, int penalization, int cycle, int flags);
//! the destructor
virtual ~StereoVar();
//! the stereo correspondence operator that computes disparity map for the specified rectified stereo pair
CV_WRAP_AS(compute) virtual void operator()(const Mat& left, const Mat& right, CV_OUT Mat& disp);
CV_PROP_RW int levels;
CV_PROP_RW double pyrScale;
CV_PROP_RW int nIt;
CV_PROP_RW int minDisp;
CV_PROP_RW int maxDisp;
CV_PROP_RW int poly_n;
CV_PROP_RW double poly_sigma;
CV_PROP_RW float fi;
CV_PROP_RW float lambda;
CV_PROP_RW int penalization;
CV_PROP_RW int cycle;
CV_PROP_RW int flags;
private:
void autoParams();
void FMG(Mat &I1, Mat &I2, Mat &I2x, Mat &u, int level);
void VCycle_MyFAS(Mat &I1_h, Mat &I2_h, Mat &I2x_h, Mat &u_h, int level);
void VariationalSolver(Mat &I1_h, Mat &I2_h, Mat &I2x_h, Mat &u_h, int level);
};
CV_EXPORTS void polyfit(const Mat& srcx, const Mat& srcy, Mat& dst, int order); int S, R, M, N, ind1;
int top, bottom,left,right;
double ro0, romax, a, q;
class CV_EXPORTS Directory struct kernel
{ {
public: kernel() { w = 0; }
static std::vector<String> GetListFiles ( const String& path, const String & exten = "*", bool addPath = true ); std::vector<double> weights;
static std::vector<String> GetListFilesR ( const String& path, const String & exten = "*", bool addPath = true ); int w;
static std::vector<String> GetListFolders( const String& path, const String & exten = "*", bool addPath = true );
}; };
/* Mat ETAyx;
* Generation of a set of different colors by the following way: Mat CSIyx;
* 1) generate more then need colors (in "factor" times) in RGB, std::vector<kernel> w_ker_2D;
* 2) convert them to Lab,
* 3) choose the needed count of colors from the set that are more different from
* each other,
* 4) convert the colors back to RGB
*/
CV_EXPORTS void generateColors( std::vector<Scalar>& colors, size_t count, size_t factor=100 );
void create_map(int M, int N, int R, int S, double ro0);
};
/* /**
* Estimate the rigid body motion from frame0 to frame1. The method is based on the paper * Adjacent receptive fields technique
* "Real-Time Visual Odometry from Dense RGB-D Images", F. Steinbucker, J. Strum, D. Cremers, ICCV, 2011. *
*/ *All the Cartesian pixels, whose coordinates in the cortical domain share the same integer part, are assigned to the same RF.
enum { ROTATION = 1, *The precision of the boundaries of the RF can be improved by breaking each pixel into subpixels and assigning each of them to the correct RF.
TRANSLATION = 2, *This technique is implemented from: Traver, V., Pla, F.: Log-polar mapping template design: From task-level requirements
RIGID_BODY_MOTION = 4 *to geometry parameters. Image Vision Comput. 26(10) (2008) 1354-1370
}; *
CV_EXPORTS bool RGBDOdometry( Mat& Rt, const Mat& initRt, *More details can be found in http://dx.doi.org/10.1007/978-3-642-23968-7_5
const Mat& image0, const Mat& depth0, const Mat& mask0, */
const Mat& image1, const Mat& depth1, const Mat& mask1, class CV_EXPORTS LogPolar_Adjacent
const Mat& cameraMatrix, float minDepth=0.f, float maxDepth=4.f, float maxDepthDiff=0.07f, {
const std::vector<int>& iterCounts=std::vector<int>(), public:
const std::vector<float>& minGradientMagnitudes=std::vector<float>(), LogPolar_Adjacent() {}
int transformType=RIGID_BODY_MOTION );
/** /**
*Bilinear interpolation technique. *Constructor
* *\param w the width of the input image
*The value of a desired cortical pixel is obtained through a bilinear interpolation of the values *\param h the height of the input image
*of the four nearest neighbouring Cartesian pixels to the center of the RF. *\param center the transformation center: where the output precision is maximal
*The same principle is applied to the inverse transformation. *\param R the number of rings of the cortical image (default value 70 pixel)
* *\param ro0 the radius of the blind spot (default value 3 pixel)
*More details can be found in http://dx.doi.org/10.1007/978-3-642-23968-7_5 *\param smin the size of the subpixel (default value 0.25 pixel)
*/ *\param full \a 1 (default value) means that the retinal image (the inverse transform) is computed within the circumscribing circle.
class CV_EXPORTS LogPolar_Interp * \a 0 means that the retinal image is computed within the inscribed circle.
{ *\param S the number of sectors of the cortical image (default value 70 pixel).
public: * Its value is usually internally computed to obtain a pixel aspect ratio equals to 1.
*\param sp \a 1 (default value) means that the parameter \a S is internally computed.
LogPolar_Interp() {} * \a 0 means that the parameter \a S is provided by the user.
*/
/** LogPolar_Adjacent(int w, int h, Point2i center, int R=70, double ro0=3.0, double smin=0.25, int full=1, int S=117, int sp=1);
*Constructor
*\param w the width of the input image
*\param h the height of the input image
*\param center the transformation center: where the output precision is maximal
*\param R the number of rings of the cortical image (default value 70 pixel)
*\param ro0 the radius of the blind spot (default value 3 pixel)
*\param full \a 1 (default value) means that the retinal image (the inverse transform) is computed within the circumscribing circle.
* \a 0 means that the retinal image is computed within the inscribed circle.
*\param S the number of sectors of the cortical image (default value 70 pixel).
* Its value is usually internally computed to obtain a pixel aspect ratio equals to 1.
*\param sp \a 1 (default value) means that the parameter \a S is internally computed.
* \a 0 means that the parameter \a S is provided by the user.
*/
LogPolar_Interp(int w, int h, Point2i center, int R=70, double ro0=3.0,
int interp=INTER_LINEAR, int full=1, int S=117, int sp=1);
/**
*Transformation from Cartesian image to cortical (log-polar) image.
*\param source the Cartesian image
*\return the transformed image (cortical image)
*/
const Mat to_cortical(const Mat &source);
/**
*Transformation from cortical image to retinal (inverse log-polar) image.
*\param source the cortical image
*\return the transformed image (retinal image)
*/
const Mat to_cartesian(const Mat &source);
/**
*Destructor
*/
~LogPolar_Interp();
protected:
Mat Rsri;
Mat Csri;
int S, R, M, N;
int top, bottom,left,right;
double ro0, romax, a, q;
int interp;
Mat ETAyx;
Mat CSIyx;
void create_map(int M, int N, int R, int S, double ro0);
};
/** /**
*Overlapping circular receptive fields technique *Transformation from Cartesian image to cortical (log-polar) image.
* *\param source the Cartesian image
*The Cartesian plane is divided in two regions: the fovea and the periphery. *\return the transformed image (cortical image)
*The fovea (oversampling) is handled by using the bilinear interpolation technique described above, whereas in */
*the periphery we use the overlapping Gaussian circular RFs. const Mat to_cortical(const Mat &source);
*
*More details can be found in http://dx.doi.org/10.1007/978-3-642-23968-7_5
*/
class CV_EXPORTS LogPolar_Overlapping
{
public:
LogPolar_Overlapping() {}
/**
*Constructor
*\param w the width of the input image
*\param h the height of the input image
*\param center the transformation center: where the output precision is maximal
*\param R the number of rings of the cortical image (default value 70 pixel)
*\param ro0 the radius of the blind spot (default value 3 pixel)
*\param full \a 1 (default value) means that the retinal image (the inverse transform) is computed within the circumscribing circle.
* \a 0 means that the retinal image is computed within the inscribed circle.
*\param S the number of sectors of the cortical image (default value 70 pixel).
* Its value is usually internally computed to obtain a pixel aspect ratio equals to 1.
*\param sp \a 1 (default value) means that the parameter \a S is internally computed.
* \a 0 means that the parameter \a S is provided by the user.
*/
LogPolar_Overlapping(int w, int h, Point2i center, int R=70,
double ro0=3.0, int full=1, int S=117, int sp=1);
/**
*Transformation from Cartesian image to cortical (log-polar) image.
*\param source the Cartesian image
*\return the transformed image (cortical image)
*/
const Mat to_cortical(const Mat &source);
/**
*Transformation from cortical image to retinal (inverse log-polar) image.
*\param source the cortical image
*\return the transformed image (retinal image)
*/
const Mat to_cartesian(const Mat &source);
/**
*Destructor
*/
~LogPolar_Overlapping();
protected:
Mat Rsri;
Mat Csri;
std::vector<int> Rsr;
std::vector<int> Csr;
std::vector<double> Wsr;
int S, R, M, N, ind1;
int top, bottom,left,right;
double ro0, romax, a, q;
struct kernel
{
kernel() { w = 0; }
std::vector<double> weights;
int w;
};
Mat ETAyx;
Mat CSIyx;
std::vector<kernel> w_ker_2D;
void create_map(int M, int N, int R, int S, double ro0);
};
/** /**
* Adjacent receptive fields technique *Transformation from cortical image to retinal (inverse log-polar) image.
* *\param source the cortical image
*All the Cartesian pixels, whose coordinates in the cortical domain share the same integer part, are assigned to the same RF. *\return the transformed image (retinal image)
*The precision of the boundaries of the RF can be improved by breaking each pixel into subpixels and assigning each of them to the correct RF. */
*This technique is implemented from: Traver, V., Pla, F.: Log-polar mapping template design: From task-level requirements const Mat to_cartesian(const Mat &source);
*to geometry parameters. Image Vision Comput. 26(10) (2008) 1354-1370 /**
* *Destructor
*More details can be found in http://dx.doi.org/10.1007/978-3-642-23968-7_5 */
*/ ~LogPolar_Adjacent();
class CV_EXPORTS LogPolar_Adjacent
protected:
struct pixel
{ {
public: pixel() { u = v = 0; a = 0.; }
LogPolar_Adjacent() {} int u;
int v;
/** double a;
*Constructor
*\param w the width of the input image
*\param h the height of the input image
*\param center the transformation center: where the output precision is maximal
*\param R the number of rings of the cortical image (default value 70 pixel)
*\param ro0 the radius of the blind spot (default value 3 pixel)
*\param smin the size of the subpixel (default value 0.25 pixel)
*\param full \a 1 (default value) means that the retinal image (the inverse transform) is computed within the circumscribing circle.
* \a 0 means that the retinal image is computed within the inscribed circle.
*\param S the number of sectors of the cortical image (default value 70 pixel).
* Its value is usually internally computed to obtain a pixel aspect ratio equals to 1.
*\param sp \a 1 (default value) means that the parameter \a S is internally computed.
* \a 0 means that the parameter \a S is provided by the user.
*/
LogPolar_Adjacent(int w, int h, Point2i center, int R=70, double ro0=3.0, double smin=0.25, int full=1, int S=117, int sp=1);
/**
*Transformation from Cartesian image to cortical (log-polar) image.
*\param source the Cartesian image
*\return the transformed image (cortical image)
*/
const Mat to_cortical(const Mat &source);
/**
*Transformation from cortical image to retinal (inverse log-polar) image.
*\param source the cortical image
*\return the transformed image (retinal image)
*/
const Mat to_cartesian(const Mat &source);
/**
*Destructor
*/
~LogPolar_Adjacent();
protected:
struct pixel
{
pixel() { u = v = 0; a = 0.; }
int u;
int v;
double a;
};
int S, R, M, N;
int top, bottom,left,right;
double ro0, romax, a, q;
std::vector<std::vector<pixel> > L;
std::vector<double> A;
void subdivide_recursively(double x, double y, int i, int j, double length, double smin);
bool get_uv(double x, double y, int&u, int&v);
void create_map(int M, int N, int R, int S, double ro0, double smin);
}; };
int S, R, M, N;
int top, bottom,left,right;
double ro0, romax, a, q;
std::vector<std::vector<pixel> > L;
std::vector<double> A;
void subdivide_recursively(double x, double y, int i, int j, double length, double smin);
bool get_uv(double x, double y, int&u, int&v);
void create_map(int M, int N, int R, int S, double ro0, double smin);
};
CV_EXPORTS Mat subspaceProject(InputArray W, InputArray mean, InputArray src); CV_EXPORTS Mat subspaceProject(InputArray W, InputArray mean, InputArray src);
CV_EXPORTS Mat subspaceReconstruct(InputArray W, InputArray mean, InputArray src); CV_EXPORTS Mat subspaceReconstruct(InputArray W, InputArray mean, InputArray src);
class CV_EXPORTS LDA class CV_EXPORTS LDA
{
public:
// Initializes a LDA with num_components (default 0) and specifies how
// samples are aligned (default dataAsRow=true).
LDA(int num_components = 0) :
_num_components(num_components) {};
// Initializes and performs a Discriminant Analysis with Fisher's
// Optimization Criterion on given data in src and corresponding labels
// in labels. If 0 (or less) number of components are given, they are
// automatically determined for given data in computation.
LDA(InputArrayOfArrays src, InputArray labels,
int num_components = 0) :
_num_components(num_components)
{ {
public: this->compute(src, labels); //! compute eigenvectors and eigenvalues
// Initializes a LDA with num_components (default 0) and specifies how }
// samples are aligned (default dataAsRow=true).
LDA(int num_components = 0) :
_num_components(num_components) {};
// Initializes and performs a Discriminant Analysis with Fisher's // Serializes this object to a given filename.
// Optimization Criterion on given data in src and corresponding labels void save(const String& filename) const;
// in labels. If 0 (or less) number of components are given, they are
// automatically determined for given data in computation.
LDA(InputArrayOfArrays src, InputArray labels,
int num_components = 0) :
_num_components(num_components)
{
this->compute(src, labels); //! compute eigenvectors and eigenvalues
}
// Serializes this object to a given filename. // Deserializes this object from a given filename.
void save(const String& filename) const; void load(const String& filename);
// Deserializes this object from a given filename. // Serializes this object to a given cv::FileStorage.
void load(const String& filename); void save(FileStorage& fs) const;
// Serializes this object to a given cv::FileStorage. // Deserializes this object from a given cv::FileStorage.
void save(FileStorage& fs) const; void load(const FileStorage& node);
// Deserializes this object from a given cv::FileStorage.
void load(const FileStorage& node);
// Destructor. // Destructor.
~LDA() {} ~LDA() {}
//! Compute the discriminants for data in src and labels. //! Compute the discriminants for data in src and labels.
void compute(InputArrayOfArrays src, InputArray labels); void compute(InputArrayOfArrays src, InputArray labels);
// Projects samples into the LDA subspace. // Projects samples into the LDA subspace.
Mat project(InputArray src); Mat project(InputArray src);
// Reconstructs projections from the LDA subspace. // Reconstructs projections from the LDA subspace.
Mat reconstruct(InputArray src); Mat reconstruct(InputArray src);
// Returns the eigenvectors of this LDA. // Returns the eigenvectors of this LDA.
Mat eigenvectors() const { return _eigenvectors; }; Mat eigenvectors() const { return _eigenvectors; };
// Returns the eigenvalues of this LDA. // Returns the eigenvalues of this LDA.
Mat eigenvalues() const { return _eigenvalues; } Mat eigenvalues() const { return _eigenvalues; }
protected: protected:
bool _dataAsRow; bool _dataAsRow;
int _num_components; int _num_components;
Mat _eigenvectors; Mat _eigenvectors;
Mat _eigenvalues; Mat _eigenvalues;
void lda(InputArrayOfArrays src, InputArray labels); void lda(InputArrayOfArrays src, InputArray labels);
}; };
class CV_EXPORTS_W FaceRecognizer : public Algorithm class CV_EXPORTS_W FaceRecognizer : public Algorithm
{ {
public: public:
//! virtual destructor //! virtual destructor
virtual ~FaceRecognizer() {} virtual ~FaceRecognizer() {}
// Trains a FaceRecognizer. // Trains a FaceRecognizer.
CV_WRAP virtual void train(InputArrayOfArrays src, InputArray labels) = 0; CV_WRAP virtual void train(InputArrayOfArrays src, InputArray labels) = 0;
// Updates a FaceRecognizer. // Updates a FaceRecognizer.
CV_WRAP virtual void update(InputArrayOfArrays src, InputArray labels); CV_WRAP virtual void update(InputArrayOfArrays src, InputArray labels);
// Gets a prediction from a FaceRecognizer. // Gets a prediction from a FaceRecognizer.
virtual int predict(InputArray src) const = 0; virtual int predict(InputArray src) const = 0;
// Predicts the label and confidence for a given sample. // Predicts the label and confidence for a given sample.
CV_WRAP virtual void predict(InputArray src, CV_OUT int &label, CV_OUT double &confidence) const = 0; CV_WRAP virtual void predict(InputArray src, CV_OUT int &label, CV_OUT double &confidence) const = 0;
// Serializes this object to a given filename. // Serializes this object to a given filename.
CV_WRAP virtual void save(const String& filename) const; CV_WRAP virtual void save(const String& filename) const;
// Deserializes this object from a given filename. // Deserializes this object from a given filename.
CV_WRAP virtual void load(const String& filename); CV_WRAP virtual void load(const String& filename);
// Serializes this object to a given cv::FileStorage. // Serializes this object to a given cv::FileStorage.
virtual void save(FileStorage& fs) const = 0; virtual void save(FileStorage& fs) const = 0;
// Deserializes this object from a given cv::FileStorage. // Deserializes this object from a given cv::FileStorage.
virtual void load(const FileStorage& fs) = 0; virtual void load(const FileStorage& fs) = 0;
}; };
CV_EXPORTS_W Ptr<FaceRecognizer> createEigenFaceRecognizer(int num_components = 0, double threshold = DBL_MAX); CV_EXPORTS_W Ptr<FaceRecognizer> createEigenFaceRecognizer(int num_components = 0, double threshold = DBL_MAX);
CV_EXPORTS_W Ptr<FaceRecognizer> createFisherFaceRecognizer(int num_components = 0, double threshold = DBL_MAX); CV_EXPORTS_W Ptr<FaceRecognizer> createFisherFaceRecognizer(int num_components = 0, double threshold = DBL_MAX);
CV_EXPORTS_W Ptr<FaceRecognizer> createLBPHFaceRecognizer(int radius=1, int neighbors=8, CV_EXPORTS_W Ptr<FaceRecognizer> createLBPHFaceRecognizer(int radius=1, int neighbors=8,
int grid_x=8, int grid_y=8, double threshold = DBL_MAX); int grid_x=8, int grid_y=8, double threshold = DBL_MAX);
enum enum
{ {
COLORMAP_AUTUMN = 0, COLORMAP_AUTUMN = 0,
COLORMAP_BONE = 1, COLORMAP_BONE = 1,
COLORMAP_JET = 2, COLORMAP_JET = 2,
COLORMAP_WINTER = 3, COLORMAP_WINTER = 3,
COLORMAP_RAINBOW = 4, COLORMAP_RAINBOW = 4,
COLORMAP_OCEAN = 5, COLORMAP_OCEAN = 5,
COLORMAP_SUMMER = 6, COLORMAP_SUMMER = 6,
COLORMAP_SPRING = 7, COLORMAP_SPRING = 7,
COLORMAP_COOL = 8, COLORMAP_COOL = 8,
COLORMAP_HSV = 9, COLORMAP_HSV = 9,
COLORMAP_PINK = 10, COLORMAP_PINK = 10,
COLORMAP_HOT = 11 COLORMAP_HOT = 11
}; };
CV_EXPORTS_W void applyColorMap(InputArray src, OutputArray dst, int colormap); CV_EXPORTS_W void applyColorMap(InputArray src, OutputArray dst, int colormap);
CV_EXPORTS bool initModule_contrib(); CV_EXPORTS bool initModule_contrib();
} }
#include "opencv2/contrib/retina.hpp" #include "opencv2/contrib/retina.hpp"
#include "opencv2/contrib/openfabmap.hpp" #include "opencv2/contrib/openfabmap.hpp"
#endif #endif
#endif
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009-2011, Willow Garage Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#ifndef __OPENCV_CONTRIB_COMPAT_HPP__
#define __OPENCV_CONTRIB_COMPAT_HPP__
#include "opencv2/core/core_c.h"
#ifdef __cplusplus
/****************************************************************************************\
* Adaptive Skin Detector *
\****************************************************************************************/
class CV_EXPORTS CvAdaptiveSkinDetector
{
private:
enum {
GSD_HUE_LT = 3,
GSD_HUE_UT = 33,
GSD_INTENSITY_LT = 15,
GSD_INTENSITY_UT = 250
};
class CV_EXPORTS Histogram
{
private:
enum {
HistogramSize = (GSD_HUE_UT - GSD_HUE_LT + 1)
};
protected:
int findCoverageIndex(double surfaceToCover, int defaultValue = 0);
public:
CvHistogram *fHistogram;
Histogram();
virtual ~Histogram();
void findCurveThresholds(int &x1, int &x2, double percent = 0.05);
void mergeWith(Histogram *source, double weight);
};
int nStartCounter, nFrameCount, nSkinHueLowerBound, nSkinHueUpperBound, nMorphingMethod, nSamplingDivider;
double fHistogramMergeFactor, fHuePercentCovered;
Histogram histogramHueMotion, skinHueHistogram;
IplImage *imgHueFrame, *imgSaturationFrame, *imgLastGrayFrame, *imgMotionFrame, *imgFilteredFrame;
IplImage *imgShrinked, *imgTemp, *imgGrayFrame, *imgHSVFrame;
protected:
void initData(IplImage *src, int widthDivider, int heightDivider);
void adaptiveFilter();
public:
enum {
MORPHING_METHOD_NONE = 0,
MORPHING_METHOD_ERODE = 1,
MORPHING_METHOD_ERODE_ERODE = 2,
MORPHING_METHOD_ERODE_DILATE = 3
};
CvAdaptiveSkinDetector(int samplingDivider = 1, int morphingMethod = MORPHING_METHOD_NONE);
virtual ~CvAdaptiveSkinDetector();
virtual void process(IplImage *inputBGRImage, IplImage *outputHueMask);
};
/****************************************************************************************\
* Fuzzy MeanShift Tracker *
\****************************************************************************************/
class CV_EXPORTS CvFuzzyPoint {
public:
double x, y, value;
CvFuzzyPoint(double _x, double _y);
};
class CV_EXPORTS CvFuzzyCurve {
private:
std::vector<CvFuzzyPoint> points;
double value, centre;
bool between(double x, double x1, double x2);
public:
CvFuzzyCurve();
~CvFuzzyCurve();
void setCentre(double _centre);
double getCentre();
void clear();
void addPoint(double x, double y);
double calcValue(double param);
double getValue();
void setValue(double _value);
};
class CV_EXPORTS CvFuzzyFunction {
public:
std::vector<CvFuzzyCurve> curves;
CvFuzzyFunction();
~CvFuzzyFunction();
void addCurve(CvFuzzyCurve *curve, double value = 0);
void resetValues();
double calcValue();
CvFuzzyCurve *newCurve();
};
class CV_EXPORTS CvFuzzyRule {
private:
CvFuzzyCurve *fuzzyInput1, *fuzzyInput2;
CvFuzzyCurve *fuzzyOutput;
public:
CvFuzzyRule();
~CvFuzzyRule();
void setRule(CvFuzzyCurve *c1, CvFuzzyCurve *c2, CvFuzzyCurve *o1);
double calcValue(double param1, double param2);
CvFuzzyCurve *getOutputCurve();
};
class CV_EXPORTS CvFuzzyController {
private:
std::vector<CvFuzzyRule*> rules;
public:
CvFuzzyController();
~CvFuzzyController();
void addRule(CvFuzzyCurve *c1, CvFuzzyCurve *c2, CvFuzzyCurve *o1);
double calcOutput(double param1, double param2);
};
class CV_EXPORTS CvFuzzyMeanShiftTracker
{
private:
class FuzzyResizer
{
private:
CvFuzzyFunction iInput, iOutput;
CvFuzzyController fuzzyController;
public:
FuzzyResizer();
int calcOutput(double edgeDensity, double density);
};
class SearchWindow
{
public:
FuzzyResizer *fuzzyResizer;
int x, y;
int width, height, maxWidth, maxHeight, ellipseHeight, ellipseWidth;
int ldx, ldy, ldw, ldh, numShifts, numIters;
int xGc, yGc;
long m00, m01, m10, m11, m02, m20;
double ellipseAngle;
double density;
unsigned int depthLow, depthHigh;
int verticalEdgeLeft, verticalEdgeRight, horizontalEdgeTop, horizontalEdgeBottom;
SearchWindow();
~SearchWindow();
void setSize(int _x, int _y, int _width, int _height);
void initDepthValues(IplImage *maskImage, IplImage *depthMap);
bool shift();
void extractInfo(IplImage *maskImage, IplImage *depthMap, bool initDepth);
void getResizeAttribsEdgeDensityLinear(int &resizeDx, int &resizeDy, int &resizeDw, int &resizeDh);
void getResizeAttribsInnerDensity(int &resizeDx, int &resizeDy, int &resizeDw, int &resizeDh);
void getResizeAttribsEdgeDensityFuzzy(int &resizeDx, int &resizeDy, int &resizeDw, int &resizeDh);
bool meanShift(IplImage *maskImage, IplImage *depthMap, int maxIteration, bool initDepth);
};
public:
enum TrackingState
{
tsNone = 0,
tsSearching = 1,
tsTracking = 2,
tsSetWindow = 3,
tsDisabled = 10
};
enum ResizeMethod {
rmEdgeDensityLinear = 0,
rmEdgeDensityFuzzy = 1,
rmInnerDensity = 2
};
enum {
MinKernelMass = 1000
};
SearchWindow kernel;
int searchMode;
private:
enum
{
MaxMeanShiftIteration = 5,
MaxSetSizeIteration = 5
};
void findOptimumSearchWindow(SearchWindow &searchWindow, IplImage *maskImage, IplImage *depthMap, int maxIteration, int resizeMethod, bool initDepth);
public:
CvFuzzyMeanShiftTracker();
~CvFuzzyMeanShiftTracker();
void track(IplImage *maskImage, IplImage *depthMap, int resizeMethod, bool resetSearch, int minKernelMass = MinKernelMass);
};
namespace cv
{
typedef bool (*BundleAdjustCallback)(int iteration, double norm_error, void* user_data);
class CV_EXPORTS LevMarqSparse {
public:
LevMarqSparse();
LevMarqSparse(int npoints, // number of points
int ncameras, // number of cameras
int nPointParams, // number of params per one point (3 in case of 3D points)
int nCameraParams, // number of parameters per one camera
int nErrParams, // number of parameters in measurement vector
// for 1 point at one camera (2 in case of 2D projections)
Mat& visibility, // visibility matrix. rows correspond to points, columns correspond to cameras
// 1 - point is visible for the camera, 0 - invisible
Mat& P0, // starting vector of parameters, first cameras then points
Mat& X, // measurements, in order of visibility. non visible cases are skipped
TermCriteria criteria, // termination criteria
// callback for estimation of Jacobian matrices
void (*fjac)(int i, int j, Mat& point_params,
Mat& cam_params, Mat& A, Mat& B, void* data),
// callback for estimation of backprojection errors
void (*func)(int i, int j, Mat& point_params,
Mat& cam_params, Mat& estim, void* data),
void* data, // user-specific data passed to the callbacks
BundleAdjustCallback cb, void* user_data
);
virtual ~LevMarqSparse();
virtual void run( int npoints, // number of points
int ncameras, // number of cameras
int nPointParams, // number of params per one point (3 in case of 3D points)
int nCameraParams, // number of parameters per one camera
int nErrParams, // number of parameters in measurement vector
// for 1 point at one camera (2 in case of 2D projections)
Mat& visibility, // visibility matrix. rows correspond to points, columns correspond to cameras
// 1 - point is visible for the camera, 0 - invisible
Mat& P0, // starting vector of parameters, first cameras then points
Mat& X, // measurements, in order of visibility. non visible cases are skipped
TermCriteria criteria, // termination criteria
// callback for estimation of Jacobian matrices
void (CV_CDECL * fjac)(int i, int j, Mat& point_params,
Mat& cam_params, Mat& A, Mat& B, void* data),
// callback for estimation of backprojection errors
void (CV_CDECL * func)(int i, int j, Mat& point_params,
Mat& cam_params, Mat& estim, void* data),
void* data // user-specific data passed to the callbacks
);
virtual void clear();
// useful function to do simple bundle adjustment tasks
static void bundleAdjust(std::vector<Point3d>& points, // positions of points in global coordinate system (input and output)
const std::vector<std::vector<Point2d> >& imagePoints, // projections of 3d points for every camera
const std::vector<std::vector<int> >& visibility, // visibility of 3d points for every camera
std::vector<Mat>& cameraMatrix, // intrinsic matrices of all cameras (input and output)
std::vector<Mat>& R, // rotation matrices of all cameras (input and output)
std::vector<Mat>& T, // translation vector of all cameras (input and output)
std::vector<Mat>& distCoeffs, // distortion coefficients of all cameras (input and output)
const TermCriteria& criteria=
TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, DBL_EPSILON),
BundleAdjustCallback cb = 0, void* user_data = 0);
public:
virtual void optimize(CvMat &_vis); //main function that runs minimization
//iteratively asks for measurement for visible camera-point pairs
void ask_for_proj(CvMat &_vis,bool once=false);
//iteratively asks for Jacobians for every camera_point pair
void ask_for_projac(CvMat &_vis);
CvMat* err; //error X-hX
double prevErrNorm, errNorm;
double lambda;
CvTermCriteria criteria;
int iters;
CvMat** U; //size of array is equal to number of cameras
CvMat** V; //size of array is equal to number of points
CvMat** inv_V_star; //inverse of V*
CvMat** A;
CvMat** B;
CvMat** W;
CvMat* X; //measurement
CvMat* hX; //current measurement extimation given new parameter vector
CvMat* prevP; //current already accepted parameter.
CvMat* P; // parameters used to evaluate function with new params
// this parameters may be rejected
CvMat* deltaP; //computed increase of parameters (result of normal system solution )
CvMat** ea; // sum_i AijT * e_ij , used as right part of normal equation
// length of array is j = number of cameras
CvMat** eb; // sum_j BijT * e_ij , used as right part of normal equation
// length of array is i = number of points
CvMat** Yj; //length of array is i = num_points
CvMat* S; //big matrix of block Sjk , each block has size num_cam_params x num_cam_params
CvMat* JtJ_diag; //diagonal of JtJ, used to backup diagonal elements before augmentation
CvMat* Vis_index; // matrix which element is index of measurement for point i and camera j
int num_cams;
int num_points;
int num_err_param;
int num_cam_param;
int num_point_param;
//target function and jacobian pointers, which needs to be initialized
void (*fjac)(int i, int j, Mat& point_params, Mat& cam_params, Mat& A, Mat& B, void* data);
void (*func)(int i, int j, Mat& point_params, Mat& cam_params, Mat& estim, void* data);
void* data;
BundleAdjustCallback cb;
void* user_data;
};
} // cv
#endif /* __cplusplus */
#endif /* __OPENCV_CONTRIB_COMPAT_HPP__ */
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include "precomp.hpp" #include "precomp.hpp"
#include "opencv2/imgproc/imgproc_c.h" #include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/contrib/compat.hpp"
#define ASD_INTENSITY_SET_PIXEL(pointer, qq) {(*pointer) = (unsigned char)qq;} #define ASD_INTENSITY_SET_PIXEL(pointer, qq) {(*pointer) = (unsigned char)qq;}
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include "precomp.hpp" #include "precomp.hpp"
#include "opencv2/calib3d.hpp" #include "opencv2/calib3d.hpp"
#include "opencv2/contrib/compat.hpp"
#include "opencv2/calib3d/calib3d_c.h" #include "opencv2/calib3d/calib3d_c.h"
#include <iostream> #include <iostream>
......
...@@ -142,7 +142,7 @@ private: ...@@ -142,7 +142,7 @@ private:
LocationScaleImageRange(const std::vector<Point>& locations, const std::vector<float>& _scales) : LocationScaleImageRange(const std::vector<Point>& locations, const std::vector<float>& _scales) :
locations_(locations), scales_(_scales) locations_(locations), scales_(_scales)
{ {
assert(locations.size()==_scales.size()); CV_Assert(locations.size()==_scales.size());
} }
ImageIterator* iterator() const ImageIterator* iterator() const
...@@ -393,7 +393,7 @@ private: ...@@ -393,7 +393,7 @@ private:
LocationScaleImageIterator(const std::vector<Point>& locations, const std::vector<float>& _scales) : LocationScaleImageIterator(const std::vector<Point>& locations, const std::vector<float>& _scales) :
locations_(locations), scales_(_scales) locations_(locations), scales_(_scales)
{ {
assert(locations.size()==_scales.size()); CV_Assert(locations.size()==_scales.size());
reset(); reset();
} }
...@@ -622,7 +622,7 @@ void ChamferMatcher::Matching::followContour(Mat& templ_img, template_coords_t& ...@@ -622,7 +622,7 @@ void ChamferMatcher::Matching::followContour(Mat& templ_img, template_coords_t&
coordinate_t next; coordinate_t next;
unsigned char ptr; unsigned char ptr;
assert (direction==-1 || !coords.empty()); CV_Assert (direction==-1 || !coords.empty());
coordinate_t crt = coords.back(); coordinate_t crt = coords.back();
...@@ -903,18 +903,18 @@ void ChamferMatcher::Template::show() const ...@@ -903,18 +903,18 @@ void ChamferMatcher::Template::show() const
p2.x = x + pad*(int)(sin(orientations[i])*100)/100; p2.x = x + pad*(int)(sin(orientations[i])*100)/100;
p2.y = y + pad*(int)(cos(orientations[i])*100)/100; p2.y = y + pad*(int)(cos(orientations[i])*100)/100;
line(templ_color, p1,p2, CV_RGB(255,0,0)); line(templ_color, p1,p2, Scalar(255,0,0));
} }
} }
circle(templ_color,Point(center.x + pad, center.y + pad),1,CV_RGB(0,255,0)); circle(templ_color,Point(center.x + pad, center.y + pad),1,Scalar(0,255,0));
#ifdef HAVE_OPENCV_HIGHGUI #ifdef HAVE_OPENCV_HIGHGUI
namedWindow("templ",1); namedWindow("templ",1);
imshow("templ",templ_color); imshow("templ",templ_color);
waitKey(); waitKey();
#else #else
CV_Error(CV_StsNotImplemented, "OpenCV has been compiled without GUI support"); CV_Error(Error::StsNotImplemented, "OpenCV has been compiled without GUI support");
#endif #endif
templ_color.release(); templ_color.release();
...@@ -1059,7 +1059,7 @@ void ChamferMatcher::Matching::fillNonContourOrientations(Mat& annotated_img, Ma ...@@ -1059,7 +1059,7 @@ void ChamferMatcher::Matching::fillNonContourOrientations(Mat& annotated_img, Ma
int cols = annotated_img.cols; int cols = annotated_img.cols;
int rows = annotated_img.rows; int rows = annotated_img.rows;
assert(orientation_img.cols==cols && orientation_img.rows==rows); CV_Assert(orientation_img.cols==cols && orientation_img.rows==rows);
for (int y=0;y<rows;++y) { for (int y=0;y<rows;++y) {
for (int x=0;x<cols;++x) { for (int x=0;x<cols;++x) {
...@@ -1279,7 +1279,7 @@ void ChamferMatcher::showMatch(Mat& img, int index) ...@@ -1279,7 +1279,7 @@ void ChamferMatcher::showMatch(Mat& img, int index)
std::cout << "Index too big.\n" << std::endl; std::cout << "Index too big.\n" << std::endl;
} }
assert(img.channels()==3); CV_Assert(img.channels()==3);
Match match = matches[index]; Match match = matches[index];
...@@ -1298,7 +1298,7 @@ void ChamferMatcher::showMatch(Mat& img, int index) ...@@ -1298,7 +1298,7 @@ void ChamferMatcher::showMatch(Mat& img, int index)
void ChamferMatcher::showMatch(Mat& img, Match match) void ChamferMatcher::showMatch(Mat& img, Match match)
{ {
assert(img.channels()==3); CV_Assert(img.channels()==3);
const template_coords_t& templ_coords = match.tpl->coords; const template_coords_t& templ_coords = match.tpl->coords;
for (size_t i=0;i<templ_coords.size();++i) { for (size_t i=0;i<templ_coords.size();++i) {
......
...@@ -40,7 +40,7 @@ static Mat linspace(float x0, float x1, int n) ...@@ -40,7 +40,7 @@ static Mat linspace(float x0, float x1, int n)
static void sortMatrixRowsByIndices(InputArray _src, InputArray _indices, OutputArray _dst) static void sortMatrixRowsByIndices(InputArray _src, InputArray _indices, OutputArray _dst)
{ {
if(_indices.getMat().type() != CV_32SC1) if(_indices.getMat().type() != CV_32SC1)
CV_Error(CV_StsUnsupportedFormat, "cv::sortRowsByIndices only works on integer indices!"); CV_Error(Error::StsUnsupportedFormat, "cv::sortRowsByIndices only works on integer indices!");
Mat src = _src.getMat(); Mat src = _src.getMat();
std::vector<int> indices = _indices.getMat(); std::vector<int> indices = _indices.getMat();
_dst.create(src.rows, src.cols, src.type()); _dst.create(src.rows, src.cols, src.type());
...@@ -64,8 +64,8 @@ static Mat argsort(InputArray _src, bool ascending=true) ...@@ -64,8 +64,8 @@ static Mat argsort(InputArray _src, bool ascending=true)
{ {
Mat src = _src.getMat(); Mat src = _src.getMat();
if (src.rows != 1 && src.cols != 1) if (src.rows != 1 && src.cols != 1)
CV_Error(CV_StsBadArg, "cv::argsort only sorts 1D matrices."); CV_Error(Error::StsBadArg, "cv::argsort only sorts 1D matrices.");
int flags = CV_SORT_EVERY_ROW+(ascending ? CV_SORT_ASCENDING : CV_SORT_DESCENDING); int flags = SORT_EVERY_ROW | (ascending ? SORT_ASCENDING : SORT_DESCENDING);
Mat sorted_indices; Mat sorted_indices;
sortIdx(src.reshape(1,1),sorted_indices,flags); sortIdx(src.reshape(1,1),sorted_indices,flags);
return sorted_indices; return sorted_indices;
...@@ -116,8 +116,8 @@ static Mat interp1(InputArray _x, InputArray _Y, InputArray _xi) ...@@ -116,8 +116,8 @@ static Mat interp1(InputArray _x, InputArray _Y, InputArray _xi)
Mat Y = _Y.getMat(); Mat Y = _Y.getMat();
Mat xi = _xi.getMat(); Mat xi = _xi.getMat();
// check types & alignment // check types & alignment
assert((x.type() == Y.type()) && (Y.type() == xi.type())); CV_Assert((x.type() == Y.type()) && (Y.type() == xi.type()));
assert((x.cols == 1) && (x.rows == Y.rows) && (x.cols == Y.cols)); CV_Assert((x.cols == 1) && (x.rows == Y.rows) && (x.cols == Y.cols));
// call templated interp1 // call templated interp1
switch(x.type()) { switch(x.type()) {
case CV_8SC1: return interp1_<char>(x,Y,xi); break; case CV_8SC1: return interp1_<char>(x,Y,xi); break;
...@@ -127,7 +127,7 @@ static Mat interp1(InputArray _x, InputArray _Y, InputArray _xi) ...@@ -127,7 +127,7 @@ static Mat interp1(InputArray _x, InputArray _Y, InputArray _xi)
case CV_32SC1: return interp1_<int>(x,Y,xi); break; case CV_32SC1: return interp1_<int>(x,Y,xi); break;
case CV_32FC1: return interp1_<float>(x,Y,xi); break; case CV_32FC1: return interp1_<float>(x,Y,xi); break;
case CV_64FC1: return interp1_<double>(x,Y,xi); break; case CV_64FC1: return interp1_<double>(x,Y,xi); break;
default: CV_Error(CV_StsUnsupportedFormat, ""); break; default: CV_Error(Error::StsUnsupportedFormat, ""); break;
} }
return Mat(); return Mat();
} }
...@@ -473,7 +473,7 @@ namespace colormap ...@@ -473,7 +473,7 @@ namespace colormap
void ColorMap::operator()(InputArray _src, OutputArray _dst) const void ColorMap::operator()(InputArray _src, OutputArray _dst) const
{ {
if(_lut.total() != 256) if(_lut.total() != 256)
CV_Error(CV_StsAssert, "cv::LUT only supports tables of size 256."); CV_Error(Error::StsAssert, "cv::LUT only supports tables of size 256.");
Mat src = _src.getMat(); Mat src = _src.getMat();
// Return original matrix if wrong type is given (is fail loud better here?) // Return original matrix if wrong type is given (is fail loud better here?)
if(src.type() != CV_8UC1 && src.type() != CV_8UC3) if(src.type() != CV_8UC1 && src.type() != CV_8UC3)
...@@ -521,7 +521,7 @@ namespace colormap ...@@ -521,7 +521,7 @@ namespace colormap
colormap == COLORMAP_WINTER ? (colormap::ColorMap*)(new colormap::Winter) : 0; colormap == COLORMAP_WINTER ? (colormap::ColorMap*)(new colormap::Winter) : 0;
if( !cm ) if( !cm )
CV_Error( CV_StsBadArg, "Unknown colormap id; use one of COLORMAP_*"); CV_Error( Error::StsBadArg, "Unknown colormap id; use one of COLORMAP_*");
(*cm)(src, dst); (*cm)(src, dst);
......
...@@ -51,7 +51,7 @@ static Mat asRowMatrix(InputArrayOfArrays src, int rtype, double alpha=1, double ...@@ -51,7 +51,7 @@ static Mat asRowMatrix(InputArrayOfArrays src, int rtype, double alpha=1, double
// make sure the input data is a vector of matrices or vector of vector // make sure the input data is a vector of matrices or vector of vector
if(src.kind() != _InputArray::STD_VECTOR_MAT && src.kind() != _InputArray::STD_VECTOR_VECTOR) { if(src.kind() != _InputArray::STD_VECTOR_MAT && src.kind() != _InputArray::STD_VECTOR_VECTOR) {
String error_message = "The data is expected as InputArray::STD_VECTOR_MAT (a std::vector<Mat>) or _InputArray::STD_VECTOR_VECTOR (a std::vector< std::vector<...> >)."; String error_message = "The data is expected as InputArray::STD_VECTOR_MAT (a std::vector<Mat>) or _InputArray::STD_VECTOR_VECTOR (a std::vector< std::vector<...> >).";
CV_Error(CV_StsBadArg, error_message); CV_Error(Error::StsBadArg, error_message);
} }
// number of samples // number of samples
size_t n = src.total(); size_t n = src.total();
...@@ -67,7 +67,7 @@ static Mat asRowMatrix(InputArrayOfArrays src, int rtype, double alpha=1, double ...@@ -67,7 +67,7 @@ static Mat asRowMatrix(InputArrayOfArrays src, int rtype, double alpha=1, double
// make sure data can be reshaped, throw exception if not! // make sure data can be reshaped, throw exception if not!
if(src.getMat(i).total() != d) { if(src.getMat(i).total() != d) {
String error_message = format("Wrong number of elements in matrix #%d! Expected %d was %d.", i, d, src.getMat(i).total()); String error_message = format("Wrong number of elements in matrix #%d! Expected %d was %d.", i, d, src.getMat(i).total());
CV_Error(CV_StsBadArg, error_message); CV_Error(Error::StsBadArg, error_message);
} }
// get a hold of the current row // get a hold of the current row
Mat xi = data.row(i); Mat xi = data.row(i);
...@@ -306,13 +306,13 @@ void FaceRecognizer::update(InputArrayOfArrays src, InputArray labels ) { ...@@ -306,13 +306,13 @@ void FaceRecognizer::update(InputArrayOfArrays src, InputArray labels ) {
} }
String error_msg = format("This FaceRecognizer (%s) does not support updating, you have to use FaceRecognizer::train to update it.", this->name().c_str()); String error_msg = format("This FaceRecognizer (%s) does not support updating, you have to use FaceRecognizer::train to update it.", this->name().c_str());
CV_Error(CV_StsNotImplemented, error_msg); CV_Error(Error::StsNotImplemented, error_msg);
} }
void FaceRecognizer::save(const String& filename) const { void FaceRecognizer::save(const String& filename) const {
FileStorage fs(filename, FileStorage::WRITE); FileStorage fs(filename, FileStorage::WRITE);
if (!fs.isOpened()) if (!fs.isOpened())
CV_Error(CV_StsError, "File can't be opened for writing!"); CV_Error(Error::StsError, "File can't be opened for writing!");
this->save(fs); this->save(fs);
fs.release(); fs.release();
} }
...@@ -320,7 +320,7 @@ void FaceRecognizer::save(const String& filename) const { ...@@ -320,7 +320,7 @@ void FaceRecognizer::save(const String& filename) const {
void FaceRecognizer::load(const String& filename) { void FaceRecognizer::load(const String& filename) {
FileStorage fs(filename, FileStorage::READ); FileStorage fs(filename, FileStorage::READ);
if (!fs.isOpened()) if (!fs.isOpened())
CV_Error(CV_StsError, "File can't be opened for writing!"); CV_Error(Error::StsError, "File can't be opened for writing!");
this->load(fs); this->load(fs);
fs.release(); fs.release();
} }
...@@ -331,17 +331,17 @@ void FaceRecognizer::load(const String& filename) { ...@@ -331,17 +331,17 @@ void FaceRecognizer::load(const String& filename) {
void Eigenfaces::train(InputArrayOfArrays _src, InputArray _local_labels) { void Eigenfaces::train(InputArrayOfArrays _src, InputArray _local_labels) {
if(_src.total() == 0) { if(_src.total() == 0) {
String error_message = format("Empty training data was given. You'll need more than one sample to learn a model."); String error_message = format("Empty training data was given. You'll need more than one sample to learn a model.");
CV_Error(CV_StsBadArg, error_message); CV_Error(Error::StsBadArg, error_message);
} else if(_local_labels.getMat().type() != CV_32SC1) { } else if(_local_labels.getMat().type() != CV_32SC1) {
String error_message = format("Labels must be given as integer (CV_32SC1). Expected %d, but was %d.", CV_32SC1, _local_labels.type()); String error_message = format("Labels must be given as integer (CV_32SC1). Expected %d, but was %d.", CV_32SC1, _local_labels.type());
CV_Error(CV_StsBadArg, error_message); CV_Error(Error::StsBadArg, error_message);
} }
// make sure data has correct size // make sure data has correct size
if(_src.total() > 1) { if(_src.total() > 1) {
for(int i = 1; i < static_cast<int>(_src.total()); i++) { for(int i = 1; i < static_cast<int>(_src.total()); i++) {
if(_src.getMat(i-1).total() != _src.getMat(i).total()) { if(_src.getMat(i-1).total() != _src.getMat(i).total()) {
String error_message = format("In the Eigenfaces method all input samples (training images) must be of equal size! Expected %d pixels, but was %d pixels.", _src.getMat(i-1).total(), _src.getMat(i).total()); String error_message = format("In the Eigenfaces method all input samples (training images) must be of equal size! Expected %d pixels, but was %d pixels.", _src.getMat(i-1).total(), _src.getMat(i).total());
CV_Error(CV_StsUnsupportedFormat, error_message); CV_Error(Error::StsUnsupportedFormat, error_message);
} }
} }
} }
...@@ -355,7 +355,7 @@ void Eigenfaces::train(InputArrayOfArrays _src, InputArray _local_labels) { ...@@ -355,7 +355,7 @@ void Eigenfaces::train(InputArrayOfArrays _src, InputArray _local_labels) {
// assert there are as much samples as labels // assert there are as much samples as labels
if(static_cast<int>(labels.total()) != n) { if(static_cast<int>(labels.total()) != n) {
String error_message = format("The number of samples (src) must equal the number of labels (labels)! len(src)=%d, len(labels)=%d.", n, labels.total()); String error_message = format("The number of samples (src) must equal the number of labels (labels)! len(src)=%d, len(labels)=%d.", n, labels.total());
CV_Error(CV_StsBadArg, error_message); CV_Error(Error::StsBadArg, error_message);
} }
// clear existing model data // clear existing model data
_labels.release(); _labels.release();
...@@ -365,7 +365,7 @@ void Eigenfaces::train(InputArrayOfArrays _src, InputArray _local_labels) { ...@@ -365,7 +365,7 @@ void Eigenfaces::train(InputArrayOfArrays _src, InputArray _local_labels) {
_num_components = n; _num_components = n;
// perform the PCA // perform the PCA
PCA pca(data, Mat(), CV_PCA_DATA_AS_ROW, _num_components); PCA pca(data, Mat(), PCA::DATA_AS_ROW, _num_components);
// copy the PCA results // copy the PCA results
_mean = pca.mean.reshape(1,1); // store the mean vector _mean = pca.mean.reshape(1,1); // store the mean vector
_eigenvalues = pca.eigenvalues.clone(); // eigenvalues by row _eigenvalues = pca.eigenvalues.clone(); // eigenvalues by row
...@@ -386,11 +386,11 @@ void Eigenfaces::predict(InputArray _src, int &minClass, double &minDist) const ...@@ -386,11 +386,11 @@ void Eigenfaces::predict(InputArray _src, int &minClass, double &minDist) const
if(_projections.empty()) { if(_projections.empty()) {
// throw error if no data (or simply return -1?) // throw error if no data (or simply return -1?)
String error_message = "This Eigenfaces model is not computed yet. Did you call Eigenfaces::train?"; String error_message = "This Eigenfaces model is not computed yet. Did you call Eigenfaces::train?";
CV_Error(CV_StsError, error_message); CV_Error(Error::StsError, error_message);
} else if(_eigenvectors.rows != static_cast<int>(src.total())) { } else if(_eigenvectors.rows != static_cast<int>(src.total())) {
// check data alignment just for clearer exception messages // check data alignment just for clearer exception messages
String error_message = format("Wrong input image size. Reason: Training and Test images must be of equal size! Expected an image with %d elements, but got %d.", _eigenvectors.rows, src.total()); String error_message = format("Wrong input image size. Reason: Training and Test images must be of equal size! Expected an image with %d elements, but got %d.", _eigenvectors.rows, src.total());
CV_Error(CV_StsBadArg, error_message); CV_Error(Error::StsBadArg, error_message);
} }
// project into PCA subspace // project into PCA subspace
Mat q = subspaceProject(_eigenvectors, _mean, src.reshape(1,1)); Mat q = subspaceProject(_eigenvectors, _mean, src.reshape(1,1));
...@@ -440,17 +440,17 @@ void Eigenfaces::save(FileStorage& fs) const { ...@@ -440,17 +440,17 @@ void Eigenfaces::save(FileStorage& fs) const {
void Fisherfaces::train(InputArrayOfArrays src, InputArray _lbls) { void Fisherfaces::train(InputArrayOfArrays src, InputArray _lbls) {
if(src.total() == 0) { if(src.total() == 0) {
String error_message = format("Empty training data was given. You'll need more than one sample to learn a model."); String error_message = format("Empty training data was given. You'll need more than one sample to learn a model.");
CV_Error(CV_StsBadArg, error_message); CV_Error(Error::StsBadArg, error_message);
} else if(_lbls.getMat().type() != CV_32SC1) { } else if(_lbls.getMat().type() != CV_32SC1) {
String error_message = format("Labels must be given as integer (CV_32SC1). Expected %d, but was %d.", CV_32SC1, _lbls.type()); String error_message = format("Labels must be given as integer (CV_32SC1). Expected %d, but was %d.", CV_32SC1, _lbls.type());
CV_Error(CV_StsBadArg, error_message); CV_Error(Error::StsBadArg, error_message);
} }
// make sure data has correct size // make sure data has correct size
if(src.total() > 1) { if(src.total() > 1) {
for(int i = 1; i < static_cast<int>(src.total()); i++) { for(int i = 1; i < static_cast<int>(src.total()); i++) {
if(src.getMat(i-1).total() != src.getMat(i).total()) { if(src.getMat(i-1).total() != src.getMat(i).total()) {
String error_message = format("In the Fisherfaces method all input samples (training images) must be of equal size! Expected %d pixels, but was %d pixels.", src.getMat(i-1).total(), src.getMat(i).total()); String error_message = format("In the Fisherfaces method all input samples (training images) must be of equal size! Expected %d pixels, but was %d pixels.", src.getMat(i-1).total(), src.getMat(i).total());
CV_Error(CV_StsUnsupportedFormat, error_message); CV_Error(Error::StsUnsupportedFormat, error_message);
} }
} }
} }
...@@ -462,10 +462,10 @@ void Fisherfaces::train(InputArrayOfArrays src, InputArray _lbls) { ...@@ -462,10 +462,10 @@ void Fisherfaces::train(InputArrayOfArrays src, InputArray _lbls) {
// make sure labels are passed in correct shape // make sure labels are passed in correct shape
if(labels.total() != (size_t) N) { if(labels.total() != (size_t) N) {
String error_message = format("The number of samples (src) must equal the number of labels (labels)! len(src)=%d, len(labels)=%d.", N, labels.total()); String error_message = format("The number of samples (src) must equal the number of labels (labels)! len(src)=%d, len(labels)=%d.", N, labels.total());
CV_Error(CV_StsBadArg, error_message); CV_Error(Error::StsBadArg, error_message);
} else if(labels.rows != 1 && labels.cols != 1) { } else if(labels.rows != 1 && labels.cols != 1) {
String error_message = format("Expected the labels in a matrix with one row or column! Given dimensions are rows=%s, cols=%d.", labels.rows, labels.cols); String error_message = format("Expected the labels in a matrix with one row or column! Given dimensions are rows=%s, cols=%d.", labels.rows, labels.cols);
CV_Error(CV_StsBadArg, error_message); CV_Error(Error::StsBadArg, error_message);
} }
// clear existing model data // clear existing model data
_labels.release(); _labels.release();
...@@ -481,7 +481,7 @@ void Fisherfaces::train(InputArrayOfArrays src, InputArray _lbls) { ...@@ -481,7 +481,7 @@ void Fisherfaces::train(InputArrayOfArrays src, InputArray _lbls) {
if((_num_components <= 0) || (_num_components > (C-1))) if((_num_components <= 0) || (_num_components > (C-1)))
_num_components = (C-1); _num_components = (C-1);
// perform a PCA and keep (N-C) components // perform a PCA and keep (N-C) components
PCA pca(data, Mat(), CV_PCA_DATA_AS_ROW, (N-C)); PCA pca(data, Mat(), PCA::DATA_AS_ROW, (N-C));
// project the data and perform a LDA on it // project the data and perform a LDA on it
LDA lda(pca.project(data),labels, _num_components); LDA lda(pca.project(data),labels, _num_components);
// store the total mean vector // store the total mean vector
...@@ -506,10 +506,10 @@ void Fisherfaces::predict(InputArray _src, int &minClass, double &minDist) const ...@@ -506,10 +506,10 @@ void Fisherfaces::predict(InputArray _src, int &minClass, double &minDist) const
if(_projections.empty()) { if(_projections.empty()) {
// throw error if no data (or simply return -1?) // throw error if no data (or simply return -1?)
String error_message = "This Fisherfaces model is not computed yet. Did you call Fisherfaces::train?"; String error_message = "This Fisherfaces model is not computed yet. Did you call Fisherfaces::train?";
CV_Error(CV_StsBadArg, error_message); CV_Error(Error::StsBadArg, error_message);
} else if(src.total() != (size_t) _eigenvectors.rows) { } else if(src.total() != (size_t) _eigenvectors.rows) {
String error_message = format("Wrong input image size. Reason: Training and Test images must be of equal size! Expected an image with %d elements, but got %d.", _eigenvectors.rows, src.total()); String error_message = format("Wrong input image size. Reason: Training and Test images must be of equal size! Expected an image with %d elements, but got %d.", _eigenvectors.rows, src.total());
CV_Error(CV_StsBadArg, error_message); CV_Error(Error::StsBadArg, error_message);
} }
// project into LDA subspace // project into LDA subspace
Mat q = subspaceProject(_eigenvectors, _mean, src.reshape(1,1)); Mat q = subspaceProject(_eigenvectors, _mean, src.reshape(1,1));
...@@ -641,7 +641,7 @@ static void elbp(InputArray src, OutputArray dst, int radius, int neighbors) ...@@ -641,7 +641,7 @@ static void elbp(InputArray src, OutputArray dst, int radius, int neighbors)
case CV_64FC1: elbp_<double>(src,dst, radius, neighbors); break; case CV_64FC1: elbp_<double>(src,dst, radius, neighbors); break;
default: default:
String error_msg = format("Using Original Local Binary Patterns for feature extraction only works on single-channel images (given %d). Please pass the image data as a grayscale image!", type); String error_msg = format("Using Original Local Binary Patterns for feature extraction only works on single-channel images (given %d). Please pass the image data as a grayscale image!", type);
CV_Error(CV_StsNotImplemented, error_msg); CV_Error(Error::StsNotImplemented, error_msg);
break; break;
} }
} }
...@@ -687,7 +687,7 @@ static Mat histc(InputArray _src, int minVal, int maxVal, bool normed) ...@@ -687,7 +687,7 @@ static Mat histc(InputArray _src, int minVal, int maxVal, bool normed)
return histc_(src, minVal, maxVal, normed); return histc_(src, minVal, maxVal, normed);
break; break;
default: default:
CV_Error(CV_StsUnmatchedFormats, "This type is not implemented yet."); break; CV_Error(Error::StsUnmatchedFormats, "This type is not implemented yet."); break;
} }
return Mat(); return Mat();
} }
...@@ -769,14 +769,14 @@ void LBPH::update(InputArrayOfArrays _in_src, InputArray _in_labels) { ...@@ -769,14 +769,14 @@ void LBPH::update(InputArrayOfArrays _in_src, InputArray _in_labels) {
void LBPH::train(InputArrayOfArrays _in_src, InputArray _in_labels, bool preserveData) { void LBPH::train(InputArrayOfArrays _in_src, InputArray _in_labels, bool preserveData) {
if(_in_src.kind() != _InputArray::STD_VECTOR_MAT && _in_src.kind() != _InputArray::STD_VECTOR_VECTOR) { if(_in_src.kind() != _InputArray::STD_VECTOR_MAT && _in_src.kind() != _InputArray::STD_VECTOR_VECTOR) {
String error_message = "The images are expected as InputArray::STD_VECTOR_MAT (a std::vector<Mat>) or _InputArray::STD_VECTOR_VECTOR (a std::vector< std::vector<...> >)."; String error_message = "The images are expected as InputArray::STD_VECTOR_MAT (a std::vector<Mat>) or _InputArray::STD_VECTOR_VECTOR (a std::vector< std::vector<...> >).";
CV_Error(CV_StsBadArg, error_message); CV_Error(Error::StsBadArg, error_message);
} }
if(_in_src.total() == 0) { if(_in_src.total() == 0) {
String error_message = format("Empty training data was given. You'll need more than one sample to learn a model."); String error_message = format("Empty training data was given. You'll need more than one sample to learn a model.");
CV_Error(CV_StsUnsupportedFormat, error_message); CV_Error(Error::StsUnsupportedFormat, error_message);
} else if(_in_labels.getMat().type() != CV_32SC1) { } else if(_in_labels.getMat().type() != CV_32SC1) {
String error_message = format("Labels must be given as integer (CV_32SC1). Expected %d, but was %d.", CV_32SC1, _in_labels.type()); String error_message = format("Labels must be given as integer (CV_32SC1). Expected %d, but was %d.", CV_32SC1, _in_labels.type());
CV_Error(CV_StsUnsupportedFormat, error_message); CV_Error(Error::StsUnsupportedFormat, error_message);
} }
// get the vector of matrices // get the vector of matrices
std::vector<Mat> src; std::vector<Mat> src;
...@@ -786,7 +786,7 @@ void LBPH::train(InputArrayOfArrays _in_src, InputArray _in_labels, bool preserv ...@@ -786,7 +786,7 @@ void LBPH::train(InputArrayOfArrays _in_src, InputArray _in_labels, bool preserv
// check if data is well- aligned // check if data is well- aligned
if(labels.total() != src.size()) { if(labels.total() != src.size()) {
String error_message = format("The number of samples (src) must equal the number of labels (labels). Was len(samples)=%d, len(labels)=%d.", src.size(), _labels.total()); String error_message = format("The number of samples (src) must equal the number of labels (labels). Was len(samples)=%d, len(labels)=%d.", src.size(), _labels.total());
CV_Error(CV_StsBadArg, error_message); CV_Error(Error::StsBadArg, error_message);
} }
// if this model should be trained without preserving old data, delete old model data // if this model should be trained without preserving old data, delete old model data
if(!preserveData) { if(!preserveData) {
...@@ -817,7 +817,7 @@ void LBPH::predict(InputArray _src, int &minClass, double &minDist) const { ...@@ -817,7 +817,7 @@ void LBPH::predict(InputArray _src, int &minClass, double &minDist) const {
if(_histograms.empty()) { if(_histograms.empty()) {
// throw error if no data (or simply return -1?) // throw error if no data (or simply return -1?)
String error_message = "This LBPH model is not computed yet. Did you call the train method?"; String error_message = "This LBPH model is not computed yet. Did you call the train method?";
CV_Error(CV_StsBadArg, error_message); CV_Error(Error::StsBadArg, error_message);
} }
Mat src = _src.getMat(); Mat src = _src.getMat();
// get the spatial histogram from input image // get the spatial histogram from input image
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
//M*/ //M*/
#include "precomp.hpp" #include "precomp.hpp"
#include "opencv2/contrib/compat.hpp"
CvFuzzyPoint::CvFuzzyPoint(double _x, double _y) CvFuzzyPoint::CvFuzzyPoint(double _x, double _y)
{ {
......
...@@ -85,7 +85,7 @@ static void downsamplePoints( const Mat& src, Mat& dst, size_t count ) ...@@ -85,7 +85,7 @@ static void downsamplePoints( const Mat& src, Mat& dst, size_t count )
candidatePointsMask.at<uchar>(0, maxLoc.x) = 0; candidatePointsMask.at<uchar>(0, maxLoc.x) = 0;
Mat minDists; Mat minDists;
reduce( activedDists, minDists, 0, CV_REDUCE_MIN ); reduce( activedDists, minDists, 0, REDUCE_MIN );
minMaxLoc( minDists, 0, &maxVal, 0, &maxLoc, candidatePointsMask ); minMaxLoc( minDists, 0, &maxVal, 0, &maxLoc, candidatePointsMask );
dst.at<Point3_<uchar> >((int)i) = src.at<Point3_<uchar> >(maxLoc.x); dst.at<Point3_<uchar> >((int)i) = src.at<Point3_<uchar> >(maxLoc.x);
} }
......
...@@ -43,9 +43,9 @@ static Mat argsort(InputArray _src, bool ascending=true) ...@@ -43,9 +43,9 @@ static Mat argsort(InputArray _src, bool ascending=true)
Mat src = _src.getMat(); Mat src = _src.getMat();
if (src.rows != 1 && src.cols != 1) { if (src.rows != 1 && src.cols != 1) {
String error_message = "Wrong shape of input matrix! Expected a matrix with one row or column."; String error_message = "Wrong shape of input matrix! Expected a matrix with one row or column.";
CV_Error(CV_StsBadArg, error_message); CV_Error(Error::StsBadArg, error_message);
} }
int flags = CV_SORT_EVERY_ROW+(ascending ? CV_SORT_ASCENDING : CV_SORT_DESCENDING); int flags = SORT_EVERY_ROW | (ascending ? SORT_ASCENDING : SORT_DESCENDING);
Mat sorted_indices; Mat sorted_indices;
sortIdx(src.reshape(1,1),sorted_indices,flags); sortIdx(src.reshape(1,1),sorted_indices,flags);
return sorted_indices; return sorted_indices;
...@@ -55,7 +55,7 @@ static Mat asRowMatrix(InputArrayOfArrays src, int rtype, double alpha=1, double ...@@ -55,7 +55,7 @@ static Mat asRowMatrix(InputArrayOfArrays src, int rtype, double alpha=1, double
// make sure the input data is a vector of matrices or vector of vector // make sure the input data is a vector of matrices or vector of vector
if(src.kind() != _InputArray::STD_VECTOR_MAT && src.kind() != _InputArray::STD_VECTOR_VECTOR) { if(src.kind() != _InputArray::STD_VECTOR_MAT && src.kind() != _InputArray::STD_VECTOR_VECTOR) {
String error_message = "The data is expected as InputArray::STD_VECTOR_MAT (a std::vector<Mat>) or _InputArray::STD_VECTOR_VECTOR (a std::vector< std::vector<...> >)."; String error_message = "The data is expected as InputArray::STD_VECTOR_MAT (a std::vector<Mat>) or _InputArray::STD_VECTOR_VECTOR (a std::vector< std::vector<...> >).";
CV_Error(CV_StsBadArg, error_message); CV_Error(Error::StsBadArg, error_message);
} }
// number of samples // number of samples
size_t n = src.total(); size_t n = src.total();
...@@ -71,7 +71,7 @@ static Mat asRowMatrix(InputArrayOfArrays src, int rtype, double alpha=1, double ...@@ -71,7 +71,7 @@ static Mat asRowMatrix(InputArrayOfArrays src, int rtype, double alpha=1, double
// make sure data can be reshaped, throw exception if not! // make sure data can be reshaped, throw exception if not!
if(src.getMat(i).total() != d) { if(src.getMat(i).total() != d) {
String error_message = format("Wrong number of elements in matrix #%d! Expected %d was %d.", i, (int)d, (int)src.getMat(i).total()); String error_message = format("Wrong number of elements in matrix #%d! Expected %d was %d.", i, (int)d, (int)src.getMat(i).total());
CV_Error(CV_StsBadArg, error_message); CV_Error(Error::StsBadArg, error_message);
} }
// get a hold of the current row // get a hold of the current row
Mat xi = data.row(i); Mat xi = data.row(i);
...@@ -87,7 +87,7 @@ static Mat asRowMatrix(InputArrayOfArrays src, int rtype, double alpha=1, double ...@@ -87,7 +87,7 @@ static Mat asRowMatrix(InputArrayOfArrays src, int rtype, double alpha=1, double
static void sortMatrixColumnsByIndices(InputArray _src, InputArray _indices, OutputArray _dst) { static void sortMatrixColumnsByIndices(InputArray _src, InputArray _indices, OutputArray _dst) {
if(_indices.getMat().type() != CV_32SC1) { if(_indices.getMat().type() != CV_32SC1) {
CV_Error(CV_StsUnsupportedFormat, "cv::sortColumnsByIndices only works on integer indices!"); CV_Error(Error::StsUnsupportedFormat, "cv::sortColumnsByIndices only works on integer indices!");
} }
Mat src = _src.getMat(); Mat src = _src.getMat();
std::vector<int> indices = _indices.getMat(); std::vector<int> indices = _indices.getMat();
...@@ -179,12 +179,12 @@ Mat subspaceProject(InputArray _W, InputArray _mean, InputArray _src) { ...@@ -179,12 +179,12 @@ Mat subspaceProject(InputArray _W, InputArray _mean, InputArray _src) {
// make sure the data has the correct shape // make sure the data has the correct shape
if(W.rows != d) { if(W.rows != d) {
String error_message = format("Wrong shapes for given matrices. Was size(src) = (%d,%d), size(W) = (%d,%d).", src.rows, src.cols, W.rows, W.cols); String error_message = format("Wrong shapes for given matrices. Was size(src) = (%d,%d), size(W) = (%d,%d).", src.rows, src.cols, W.rows, W.cols);
CV_Error(CV_StsBadArg, error_message); CV_Error(Error::StsBadArg, error_message);
} }
// make sure mean is correct if not empty // make sure mean is correct if not empty
if(!mean.empty() && (mean.total() != (size_t) d)) { if(!mean.empty() && (mean.total() != (size_t) d)) {
String error_message = format("Wrong mean shape for the given data matrix. Expected %d, but was %d.", d, mean.total()); String error_message = format("Wrong mean shape for the given data matrix. Expected %d, but was %d.", d, mean.total());
CV_Error(CV_StsBadArg, error_message); CV_Error(Error::StsBadArg, error_message);
} }
// create temporary matrices // create temporary matrices
Mat X, Y; Mat X, Y;
...@@ -217,12 +217,12 @@ Mat subspaceReconstruct(InputArray _W, InputArray _mean, InputArray _src) ...@@ -217,12 +217,12 @@ Mat subspaceReconstruct(InputArray _W, InputArray _mean, InputArray _src)
// make sure the data has the correct shape // make sure the data has the correct shape
if(W.cols != d) { if(W.cols != d) {
String error_message = format("Wrong shapes for given matrices. Was size(src) = (%d,%d), size(W) = (%d,%d).", src.rows, src.cols, W.rows, W.cols); String error_message = format("Wrong shapes for given matrices. Was size(src) = (%d,%d), size(W) = (%d,%d).", src.rows, src.cols, W.rows, W.cols);
CV_Error(CV_StsBadArg, error_message); CV_Error(Error::StsBadArg, error_message);
} }
// make sure mean is correct if not empty // make sure mean is correct if not empty
if(!mean.empty() && (mean.total() != (size_t) W.rows)) { if(!mean.empty() && (mean.total() != (size_t) W.rows)) {
String error_message = format("Wrong mean shape for the given eigenvector matrix. Expected %d, but was %d.", W.cols, mean.total()); String error_message = format("Wrong mean shape for the given eigenvector matrix. Expected %d, but was %d.", W.cols, mean.total());
CV_Error(CV_StsBadArg, error_message); CV_Error(Error::StsBadArg, error_message);
} }
// initalize temporary matrices // initalize temporary matrices
Mat X, Y; Mat X, Y;
...@@ -939,7 +939,7 @@ public: ...@@ -939,7 +939,7 @@ public:
void LDA::save(const String& filename) const { void LDA::save(const String& filename) const {
FileStorage fs(filename, FileStorage::WRITE); FileStorage fs(filename, FileStorage::WRITE);
if (!fs.isOpened()) { if (!fs.isOpened()) {
CV_Error(CV_StsError, "File can't be opened for writing!"); CV_Error(Error::StsError, "File can't be opened for writing!");
} }
this->save(fs); this->save(fs);
fs.release(); fs.release();
...@@ -949,7 +949,7 @@ void LDA::save(const String& filename) const { ...@@ -949,7 +949,7 @@ void LDA::save(const String& filename) const {
void LDA::load(const String& filename) { void LDA::load(const String& filename) {
FileStorage fs(filename, FileStorage::READ); FileStorage fs(filename, FileStorage::READ);
if (!fs.isOpened()) if (!fs.isOpened())
CV_Error(CV_StsError, "File can't be opened for writing!"); CV_Error(Error::StsError, "File can't be opened for writing!");
this->load(fs); this->load(fs);
fs.release(); fs.release();
} }
...@@ -1002,12 +1002,12 @@ void LDA::lda(InputArrayOfArrays _src, InputArray _lbls) { ...@@ -1002,12 +1002,12 @@ void LDA::lda(InputArrayOfArrays _src, InputArray _lbls) {
// want to separate from each other then? // want to separate from each other then?
if(C == 1) { if(C == 1) {
String error_message = "At least two classes are needed to perform a LDA. Reason: Only one class was given!"; String error_message = "At least two classes are needed to perform a LDA. Reason: Only one class was given!";
CV_Error(CV_StsBadArg, error_message); CV_Error(Error::StsBadArg, error_message);
} }
// throw error if less labels, than samples // throw error if less labels, than samples
if (labels.size() != static_cast<size_t>(N)) { if (labels.size() != static_cast<size_t>(N)) {
String error_message = format("The number of samples must equal the number of labels. Given %d labels, %d samples. ", labels.size(), N); String error_message = format("The number of samples must equal the number of labels. Given %d labels, %d samples. ", labels.size(), N);
CV_Error(CV_StsBadArg, error_message); CV_Error(Error::StsBadArg, error_message);
} }
// warn if within-classes scatter matrix becomes singular // warn if within-classes scatter matrix becomes singular
if (N < D) { if (N < D) {
...@@ -1090,7 +1090,7 @@ void LDA::compute(InputArrayOfArrays _src, InputArray _lbls) { ...@@ -1090,7 +1090,7 @@ void LDA::compute(InputArrayOfArrays _src, InputArray _lbls) {
break; break;
default: default:
String error_message= format("InputArray Datatype %d is not supported.", _src.kind()); String error_message= format("InputArray Datatype %d is not supported.", _src.kind());
CV_Error(CV_StsBadArg, error_message); CV_Error(Error::StsBadArg, error_message);
break; break;
} }
} }
......
...@@ -258,7 +258,7 @@ namespace cv ...@@ -258,7 +258,7 @@ namespace cv
void Octree::buildTree(const std::vector<Point3f>& points3d, int maxLevels, int _minPoints) void Octree::buildTree(const std::vector<Point3f>& points3d, int maxLevels, int _minPoints)
{ {
assert((size_t)maxLevels * 8 < MAX_STACK_SIZE); CV_Assert((size_t)maxLevels * 8 < MAX_STACK_SIZE);
points.resize(points3d.size()); points.resize(points3d.size());
std::copy(points3d.begin(), points3d.end(), points.begin()); std::copy(points3d.begin(), points3d.end(), points.begin());
minPoints = _minPoints; minPoints = _minPoints;
......
...@@ -450,7 +450,7 @@ bool Retina::_convertCvMat2ValarrayBuffer(const cv::Mat inputMatToConvert, std:: ...@@ -450,7 +450,7 @@ bool Retina::_convertCvMat2ValarrayBuffer(const cv::Mat inputMatToConvert, std::
inputMatToConvert.convertTo(dst, dsttype); inputMatToConvert.convertTo(dst, dsttype);
} }
else else
CV_Error(CV_StsUnsupportedFormat, "input image must be single channel (gray levels), bgr format (color) or bgra (color with transparency which won't be considered"); CV_Error(Error::StsUnsupportedFormat, "input image must be single channel (gray levels), bgr format (color) or bgra (color with transparency which won't be considered");
return imageNumberOfChannels>1; // return bool : false for gray level image processing, true for color mode return imageNumberOfChannels>1; // return bool : false for gray level image processing, true for color mode
} }
......
...@@ -422,7 +422,7 @@ bool computeKsi( int transformType, ...@@ -422,7 +422,7 @@ bool computeKsi( int transformType,
computeCFuncPtr = computeC_Translation; computeCFuncPtr = computeC_Translation;
} }
else else
CV_Error( CV_StsBadFlag, "Unsupported value of transformation type flag."); CV_Error(Error::StsBadFlag, "Unsupported value of transformation type flag.");
Mat C( correspsCount, Cwidth, CV_64FC1 ); Mat C( correspsCount, Cwidth, CV_64FC1 );
Mat dI_dt( correspsCount, 1, CV_64FC1 ); Mat dI_dt( correspsCount, 1, CV_64FC1 );
......
...@@ -56,24 +56,24 @@ namespace ...@@ -56,24 +56,24 @@ namespace
{ {
const static Scalar colors[] = const static Scalar colors[] =
{ {
CV_RGB(255, 0, 0), Scalar(255, 0, 0),
CV_RGB( 0, 255, 0), Scalar( 0, 255, 0),
CV_RGB( 0, 0, 255), Scalar( 0, 0, 255),
CV_RGB(255, 255, 0), Scalar(255, 255, 0),
CV_RGB(255, 0, 255), Scalar(255, 0, 255),
CV_RGB( 0, 255, 255), Scalar( 0, 255, 255),
CV_RGB(255, 127, 127), Scalar(255, 127, 127),
CV_RGB(127, 127, 255), Scalar(127, 127, 255),
CV_RGB(127, 255, 127), Scalar(127, 255, 127),
CV_RGB(255, 255, 127), Scalar(255, 255, 127),
CV_RGB(127, 255, 255), Scalar(127, 255, 255),
CV_RGB(255, 127, 255), Scalar(255, 127, 255),
CV_RGB(127, 0, 0), Scalar(127, 0, 0),
CV_RGB( 0, 127, 0), Scalar( 0, 127, 0),
CV_RGB( 0, 0, 127), Scalar( 0, 0, 127),
CV_RGB(127, 127, 0), Scalar(127, 127, 0),
CV_RGB(127, 0, 127), Scalar(127, 0, 127),
CV_RGB( 0, 127, 127) Scalar( 0, 127, 127)
}; };
size_t colors_mum = sizeof(colors)/sizeof(colors[0]); size_t colors_mum = sizeof(colors)/sizeof(colors[0]);
...@@ -199,7 +199,7 @@ void convertTransformMatrix(const float* matrix, float* sseMatrix) ...@@ -199,7 +199,7 @@ void convertTransformMatrix(const float* matrix, float* sseMatrix)
inline __m128 transformSSE(const __m128* matrix, const __m128& in) inline __m128 transformSSE(const __m128* matrix, const __m128& in)
{ {
assert(((size_t)matrix & 15) == 0); CV_DbgAssert(((size_t)matrix & 15) == 0);
__m128 a0 = _mm_mul_ps(_mm_load_ps((float*)(matrix+0)), _mm_shuffle_ps(in,in,_MM_SHUFFLE(0,0,0,0))); __m128 a0 = _mm_mul_ps(_mm_load_ps((float*)(matrix+0)), _mm_shuffle_ps(in,in,_MM_SHUFFLE(0,0,0,0)));
__m128 a1 = _mm_mul_ps(_mm_load_ps((float*)(matrix+1)), _mm_shuffle_ps(in,in,_MM_SHUFFLE(1,1,1,1))); __m128 a1 = _mm_mul_ps(_mm_load_ps((float*)(matrix+1)), _mm_shuffle_ps(in,in,_MM_SHUFFLE(1,1,1,1)));
__m128 a2 = _mm_mul_ps(_mm_load_ps((float*)(matrix+2)), _mm_shuffle_ps(in,in,_MM_SHUFFLE(2,2,2,2))); __m128 a2 = _mm_mul_ps(_mm_load_ps((float*)(matrix+2)), _mm_shuffle_ps(in,in,_MM_SHUFFLE(2,2,2,2)));
...@@ -221,8 +221,8 @@ void computeSpinImages( const Octree& Octree, const std::vector<Point3f>& points ...@@ -221,8 +221,8 @@ void computeSpinImages( const Octree& Octree, const std::vector<Point3f>& points
float pixelsPerMeter = 1.f / binSize; float pixelsPerMeter = 1.f / binSize;
float support = imageWidth * binSize; float support = imageWidth * binSize;
assert(normals.size() == points.size()); CV_Assert(normals.size() == points.size());
assert(mask.size() == points.size()); CV_Assert(mask.size() == points.size());
size_t points_size = points.size(); size_t points_size = points.size();
mask.resize(points_size); mask.resize(points_size);
...@@ -250,7 +250,7 @@ void computeSpinImages( const Octree& Octree, const std::vector<Point3f>& points ...@@ -250,7 +250,7 @@ void computeSpinImages( const Octree& Octree, const std::vector<Point3f>& points
if (mask[i] == 0) if (mask[i] == 0)
continue; continue;
int t = cvGetThreadNum(); int t = getThreadNum();
std::vector<Point3f>& pointsInSphere = pointsInSpherePool[t]; std::vector<Point3f>& pointsInSphere = pointsInSpherePool[t];
const Point3f& center = points[i]; const Point3f& center = points[i];
...@@ -289,7 +289,7 @@ void computeSpinImages( const Octree& Octree, const std::vector<Point3f>& points ...@@ -289,7 +289,7 @@ void computeSpinImages( const Octree& Octree, const std::vector<Point3f>& points
__m128 ppm4 = _mm_set1_ps(pixelsPerMeter); __m128 ppm4 = _mm_set1_ps(pixelsPerMeter);
__m128i height4m1 = _mm_set1_epi32(spinImage.rows-1); __m128i height4m1 = _mm_set1_epi32(spinImage.rows-1);
__m128i width4m1 = _mm_set1_epi32(spinImage.cols-1); __m128i width4m1 = _mm_set1_epi32(spinImage.cols-1);
assert( spinImage.step <= 0xffff ); CV_Assert( spinImage.step <= 0xffff );
__m128i step4 = _mm_set1_epi16((short)step); __m128i step4 = _mm_set1_epi16((short)step);
__m128i zero4 = _mm_setzero_si128(); __m128i zero4 = _mm_setzero_si128();
__m128i one4i = _mm_set1_epi32(1); __m128i one4i = _mm_set1_epi32(1);
...@@ -472,7 +472,7 @@ float cv::Mesh3D::estimateResolution(float /*tryRatio*/) ...@@ -472,7 +472,7 @@ float cv::Mesh3D::estimateResolution(float /*tryRatio*/)
return resolution = (float)dist[ dist.size() / 2 ]; return resolution = (float)dist[ dist.size() / 2 ];
#else #else
CV_Error(CV_StsNotImplemented, ""); CV_Error(Error::StsNotImplemented, "");
return 1.f; return 1.f;
#endif #endif
} }
...@@ -686,16 +686,15 @@ inline float cv::SpinImageModel::groupingCreteria(const Point3f& pointScene1, co ...@@ -686,16 +686,15 @@ inline float cv::SpinImageModel::groupingCreteria(const Point3f& pointScene1, co
} }
cv::SpinImageModel::SpinImageModel(const Mesh3D& _mesh) : mesh(_mesh) , out(0) cv::SpinImageModel::SpinImageModel(const Mesh3D& _mesh) : mesh(_mesh)
{ {
if (mesh.vtx.empty()) if (mesh.vtx.empty())
throw Mesh3D::EmptyMeshException(); throw Mesh3D::EmptyMeshException();
defaultParams(); defaultParams();
} }
cv::SpinImageModel::SpinImageModel() : out(0) { defaultParams(); }
cv::SpinImageModel::~SpinImageModel() {}
void cv::SpinImageModel::setLogger(std::ostream* log) { out = log; } cv::SpinImageModel::SpinImageModel() { defaultParams(); }
cv::SpinImageModel::~SpinImageModel() {}
void cv::SpinImageModel::defaultParams() void cv::SpinImageModel::defaultParams()
{ {
...@@ -756,7 +755,7 @@ Mat cv::SpinImageModel::packRandomScaledSpins(bool separateScale, size_t xCount, ...@@ -756,7 +755,7 @@ Mat cv::SpinImageModel::packRandomScaledSpins(bool separateScale, size_t xCount,
int sz = spins.front().cols; int sz = spins.front().cols;
Mat result((int)(yCount * sz + (yCount - 1)), (int)(xCount * sz + (xCount - 1)), CV_8UC3); Mat result((int)(yCount * sz + (yCount - 1)), (int)(xCount * sz + (xCount - 1)), CV_8UC3);
result = colors[(static_cast<int64>(cvGetTickCount()/cvGetTickFrequency())/1000) % colors_mum]; result = colors[(static_cast<int64>(getTickCount()/getTickFrequency())/1000) % colors_mum];
int pos = 0; int pos = 0;
for(int y = 0; y < (int)yCount; ++y) for(int y = 0; y < (int)yCount; ++y)
...@@ -1030,12 +1029,8 @@ private: ...@@ -1030,12 +1029,8 @@ private:
matchSpinToModel(scene.spinImages.row(i), indeces, coeffs); matchSpinToModel(scene.spinImages.row(i), indeces, coeffs);
for(size_t t = 0; t < indeces.size(); ++t) for(size_t t = 0; t < indeces.size(); ++t)
allMatches.push_back(Match(i, indeces[t], coeffs[t])); allMatches.push_back(Match(i, indeces[t], coeffs[t]));
if (out) if (i % 100 == 0) *out << "Comparing scene spinimage " << i << " of " << scene.spinImages.rows << std::endl;
} }
corr_timer.stop(); corr_timer.stop();
if (out) *out << "Spin correlation time = " << corr_timer << std::endl;
if (out) *out << "Matches number = " << allMatches.size() << std::endl;
if(allMatches.empty()) if(allMatches.empty())
return; return;
...@@ -1046,7 +1041,6 @@ private: ...@@ -1046,7 +1041,6 @@ private:
allMatches.erase( allMatches.erase(
remove_if(allMatches.begin(), allMatches.end(), bind2nd(std::less<float>(), maxMeasure * fraction)), remove_if(allMatches.begin(), allMatches.end(), bind2nd(std::less<float>(), maxMeasure * fraction)),
allMatches.end()); allMatches.end());
if (out) *out << "Matches number [filtered by similarity measure] = " << allMatches.size() << std::endl;
int matchesSize = (int)allMatches.size(); int matchesSize = (int)allMatches.size();
if(matchesSize == 0) if(matchesSize == 0)
...@@ -1095,15 +1089,12 @@ private: ...@@ -1095,15 +1089,12 @@ private:
allMatches.erase( allMatches.erase(
std::remove_if(allMatches.begin(), allMatches.end(), std::bind2nd(std::equal_to<float>(), infinity)), std::remove_if(allMatches.begin(), allMatches.end(), std::bind2nd(std::equal_to<float>(), infinity)),
allMatches.end()); allMatches.end());
if (out) *out << "Matches number [filtered by geometric consistency] = " << allMatches.size() << std::endl;
matchesSize = (int)allMatches.size(); matchesSize = (int)allMatches.size();
if(matchesSize == 0) if(matchesSize == 0)
return; return;
if (out) *out << "grouping ..." << std::endl;
Mat groupingMat((int)matchesSize, (int)matchesSize, CV_32F); Mat groupingMat((int)matchesSize, (int)matchesSize, CV_32F);
groupingMat = Scalar(0); groupingMat = Scalar(0);
...@@ -1151,8 +1142,6 @@ private: ...@@ -1151,8 +1142,6 @@ private:
for(int g = 0; g < matchesSize; ++g) for(int g = 0; g < matchesSize; ++g)
{ {
if (out) if (g % 100 == 0) *out << "G = " << g << std::endl;
group_t left = allMatchesInds; group_t left = allMatchesInds;
group_t group; group_t group;
...@@ -1201,16 +1190,16 @@ private: ...@@ -1201,16 +1190,16 @@ private:
cv::TickMeter::TickMeter() { reset(); } cv::TickMeter::TickMeter() { reset(); }
int64 cv::TickMeter::getTimeTicks() const { return sumTime; } int64 cv::TickMeter::getTimeTicks() const { return sumTime; }
double cv::TickMeter::getTimeMicro() const { return (double)getTimeTicks()/cvGetTickFrequency(); } double cv::TickMeter::getTimeMicro() const { return (double)getTimeTicks()/getTickFrequency(); }
double cv::TickMeter::getTimeMilli() const { return getTimeMicro()*1e-3; } double cv::TickMeter::getTimeMilli() const { return getTimeMicro()*1e-3; }
double cv::TickMeter::getTimeSec() const { return getTimeMilli()*1e-3; } double cv::TickMeter::getTimeSec() const { return getTimeMilli()*1e-3; }
int64 cv::TickMeter::getCounter() const { return counter; } int64 cv::TickMeter::getCounter() const { return counter; }
void cv::TickMeter::reset() {startTime = 0; sumTime = 0; counter = 0; } void cv::TickMeter::reset() {startTime = 0; sumTime = 0; counter = 0; }
void cv::TickMeter::start(){ startTime = cvGetTickCount(); } void cv::TickMeter::start(){ startTime = getTickCount(); }
void cv::TickMeter::stop() void cv::TickMeter::stop()
{ {
int64 time = cvGetTickCount(); int64 time = getTickCount();
if ( startTime == 0 ) if ( startTime == 0 )
return; return;
...@@ -1220,4 +1209,4 @@ void cv::TickMeter::stop() ...@@ -1220,4 +1209,4 @@ void cv::TickMeter::stop()
startTime = 0; startTime = 0;
} }
std::ostream& cv::operator<<(std::ostream& out, const TickMeter& tm){ return out << tm.getTimeSec() << "sec"; } //std::ostream& cv::operator<<(std::ostream& out, const TickMeter& tm){ return out << tm.getTimeSec() << "sec"; }
...@@ -239,8 +239,8 @@ void StereoVar::VariationalSolver(Mat &I1, Mat &I2, Mat &I2x, Mat &u, int level) ...@@ -239,8 +239,8 @@ void StereoVar::VariationalSolver(Mat &I1, Mat &I2, Mat &I2x, Mat &u, int level)
void StereoVar::VCycle_MyFAS(Mat &I1, Mat &I2, Mat &I2x, Mat &_u, int level) void StereoVar::VCycle_MyFAS(Mat &I1, Mat &I2, Mat &I2x, Mat &_u, int level)
{ {
CvSize imgSize = _u.size(); Size imgSize = _u.size();
CvSize frmSize = cvSize((int) (imgSize.width * pyrScale + 0.5), (int) (imgSize.height * pyrScale + 0.5)); Size frmSize = Size((int) (imgSize.width * pyrScale + 0.5), (int) (imgSize.height * pyrScale + 0.5));
Mat I1_h, I2_h, I2x_h, u_h, U, U_h; Mat I1_h, I2_h, I2x_h, u_h, U, U_h;
//PRE relaxation //PRE relaxation
...@@ -285,7 +285,7 @@ void StereoVar::VCycle_MyFAS(Mat &I1, Mat &I2, Mat &I2x, Mat &_u, int level) ...@@ -285,7 +285,7 @@ void StereoVar::VCycle_MyFAS(Mat &I1, Mat &I2, Mat &I2x, Mat &_u, int level)
void StereoVar::FMG(Mat &I1, Mat &I2, Mat &I2x, Mat &u, int level) void StereoVar::FMG(Mat &I1, Mat &I2, Mat &I2x, Mat &u, int level)
{ {
double scale = std::pow(pyrScale, (double) level); double scale = std::pow(pyrScale, (double) level);
CvSize frmSize = cvSize((int) (u.cols * scale + 0.5), (int) (u.rows * scale + 0.5)); Size frmSize = Size((int) (u.cols * scale + 0.5), (int) (u.rows * scale + 0.5));
Mat I1_h, I2_h, I2x_h, u_h; Mat I1_h, I2_h, I2x_h, u_h;
//scaling DOWN //scaling DOWN
...@@ -350,7 +350,7 @@ void StereoVar::autoParams() ...@@ -350,7 +350,7 @@ void StereoVar::autoParams()
void StereoVar::operator ()( const Mat& left, const Mat& right, Mat& disp ) void StereoVar::operator ()( const Mat& left, const Mat& right, Mat& disp )
{ {
CV_Assert(left.size() == right.size() && left.type() == right.type()); CV_Assert(left.size() == right.size() && left.type() == right.type());
CvSize imgSize = left.size(); Size imgSize = left.size();
int MaxD = MAX(labs(minDisp), labs(maxDisp)); int MaxD = MAX(labs(minDisp), labs(maxDisp));
int SignD = 1; if (MIN(minDisp, maxDisp) < 0) SignD = -1; int SignD = 1; if (MIN(minDisp, maxDisp) < 0) SignD = -1;
if (minDisp >= maxDisp) {MaxD = 256; SignD = 1;} if (minDisp >= maxDisp) {MaxD = 256; SignD = 1;}
...@@ -378,8 +378,8 @@ void StereoVar::operator ()( const Mat& left, const Mat& right, Mat& disp ) ...@@ -378,8 +378,8 @@ void StereoVar::operator ()( const Mat& left, const Mat& right, Mat& disp )
equalizeHist(rightgray, rightgray); equalizeHist(rightgray, rightgray);
} }
if (poly_sigma > 0.0001) { if (poly_sigma > 0.0001) {
GaussianBlur(leftgray, leftgray, cvSize(poly_n, poly_n), poly_sigma); GaussianBlur(leftgray, leftgray, Size(poly_n, poly_n), poly_sigma);
GaussianBlur(rightgray, rightgray, cvSize(poly_n, poly_n), poly_sigma); GaussianBlur(rightgray, rightgray, Size(poly_n, poly_n), poly_sigma);
} }
if (flags & USE_AUTO_PARAMS) { if (flags & USE_AUTO_PARAMS) {
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
#include <cstdio> #include <cstdio>
#include <cstring> #include <cstring>
#include <ctime> #include <ctime>
#include "opencv2/contrib/contrib.hpp" #include "opencv2/contrib/compat.hpp"
#include "opencv2/highgui/highgui_c.h" #include "opencv2/highgui/highgui_c.h"
static void help(char **argv) static void help(char **argv)
......
...@@ -32,7 +32,7 @@ static Mat toGrayscale(InputArray _src) { ...@@ -32,7 +32,7 @@ static Mat toGrayscale(InputArray _src) {
Mat src = _src.getMat(); Mat src = _src.getMat();
// only allow one channel // only allow one channel
if(src.channels() != 1) { if(src.channels() != 1) {
CV_Error(CV_StsBadArg, "Only Matrices with one channel are supported"); CV_Error(Error::StsBadArg, "Only Matrices with one channel are supported");
} }
// create and return normalized image // create and return normalized image
Mat dst; Mat dst;
...@@ -44,7 +44,7 @@ static void read_csv(const string& filename, vector<Mat>& images, vector<int>& l ...@@ -44,7 +44,7 @@ static void read_csv(const string& filename, vector<Mat>& images, vector<int>& l
std::ifstream file(filename.c_str(), ifstream::in); std::ifstream file(filename.c_str(), ifstream::in);
if (!file) { if (!file) {
string error_message = "No valid input file was given, please check the given filename."; string error_message = "No valid input file was given, please check the given filename.";
CV_Error(CV_StsBadArg, error_message); CV_Error(Error::StsBadArg, error_message);
} }
string line, path, classlabel; string line, path, classlabel;
while (getline(file, line)) { while (getline(file, line)) {
...@@ -82,7 +82,7 @@ int main(int argc, const char *argv[]) { ...@@ -82,7 +82,7 @@ int main(int argc, const char *argv[]) {
// Quit if there are not enough images for this demo. // Quit if there are not enough images for this demo.
if(images.size() <= 1) { if(images.size() <= 1) {
string error_message = "This demo needs at least 2 images to work. Please add more images to your data set!"; string error_message = "This demo needs at least 2 images to work. Please add more images to your data set!";
CV_Error(CV_StsError, error_message); CV_Error(Error::StsError, error_message);
} }
// Get the height from the first image. We'll need this // Get the height from the first image. We'll need this
// later in code to reshape the images to their original // later in code to reshape the images to their original
......
...@@ -178,7 +178,7 @@ int main(int argc, char** argv) ...@@ -178,7 +178,7 @@ int main(int argc, char** argv)
if( intrinsic_filename ) if( intrinsic_filename )
{ {
// reading intrinsic parameters // reading intrinsic parameters
FileStorage fs(intrinsic_filename, CV_STORAGE_READ); FileStorage fs(intrinsic_filename, FileStorage::READ);
if(!fs.isOpened()) if(!fs.isOpened())
{ {
printf("Failed to open file %s\n", intrinsic_filename); printf("Failed to open file %s\n", intrinsic_filename);
...@@ -194,7 +194,7 @@ int main(int argc, char** argv) ...@@ -194,7 +194,7 @@ int main(int argc, char** argv)
M1 *= scale; M1 *= scale;
M2 *= scale; M2 *= scale;
fs.open(extrinsic_filename, CV_STORAGE_READ); fs.open(extrinsic_filename, FileStorage::READ);
if(!fs.isOpened()) if(!fs.isOpened())
{ {
printf("Failed to open file %s\n", extrinsic_filename); printf("Failed to open file %s\n", extrinsic_filename);
......
...@@ -59,15 +59,15 @@ static void matPrint(Mat &img, int lineOffsY, Scalar fontColor, const string &ss ...@@ -59,15 +59,15 @@ static void matPrint(Mat &img, int lineOffsY, Scalar fontColor, const string &ss
Point org; Point org;
org.x = 1; org.x = 1;
org.y = 3 * fontSize.height * (lineOffsY + 1) / 2; org.y = 3 * fontSize.height * (lineOffsY + 1) / 2;
putText(img, ss, org, fontFace, fontScale, CV_RGB(0,0,0), 5*fontThickness/2, 16); putText(img, ss, org, fontFace, fontScale, Scalar(0,0,0), 5*fontThickness/2, 16);
putText(img, ss, org, fontFace, fontScale, fontColor, fontThickness, 16); putText(img, ss, org, fontFace, fontScale, fontColor, fontThickness, 16);
} }
static void displayState(Mat &canvas, bool bHelp, bool bGpu, bool bLargestFace, bool bFilter, double fps) static void displayState(Mat &canvas, bool bHelp, bool bGpu, bool bLargestFace, bool bFilter, double fps)
{ {
Scalar fontColorRed = CV_RGB(255,0,0); Scalar fontColorRed = Scalar(255,0,0);
Scalar fontColorNV = CV_RGB(118,185,0); Scalar fontColorNV = Scalar(118,185,0);
ostringstream ss; ostringstream ss;
ss << "FPS = " << setprecision(1) << fixed << fps; ss << "FPS = " << setprecision(1) << fixed << fps;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment