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
......
This diff is collapsed.
This diff is collapsed.
...@@ -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);
......
This diff is collapsed.
...@@ -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