diff --git a/modules/calib3d/include/opencv2/calib3d/calib3d.hpp b/modules/calib3d/include/opencv2/calib3d/calib3d.hpp index f0ab377fc7..e2de756b03 100644 --- a/modules/calib3d/include/opencv2/calib3d/calib3d.hpp +++ b/modules/calib3d/include/opencv2/calib3d/calib3d.hpp @@ -531,6 +531,10 @@ CV_EXPORTS_W void drawChessboardCorners( Mat& image, Size patternSize, const Mat& corners, bool patternWasFound ); +CV_EXPORTS void drawChessboardCorners( Mat& image, Size patternSize, + const vector& corners, + bool patternWasFound ); + enum { CALIB_USE_INTRINSIC_GUESS = 1, diff --git a/modules/calib3d/src/calibinit.cpp b/modules/calib3d/src/calibinit.cpp index b6083fa2dd..b283a4f850 100644 --- a/modules/calib3d/src/calibinit.cpp +++ b/modules/calib3d/src/calibinit.cpp @@ -1916,10 +1916,21 @@ void drawChessboardCorners( Mat& image, Size patternSize, if( corners.cols == 0 || corners.rows == 0 ) return; CvMat _image = image; - CV_Assert((corners.cols == 1 || corners.rows == 1) && - corners.type() == CV_32FC2 && corners.isContinuous()); + int nelems = corners.checkVector(2, CV_32F, true); + CV_Assert(nelems >= 0); cvDrawChessboardCorners( &_image, patternSize, (CvPoint2D32f*)corners.data, - corners.cols + corners.rows - 1, patternWasFound ); + nelems, patternWasFound ); +} + +void drawChessboardCorners( Mat& image, Size patternSize, + const vector& corners, + bool patternWasFound ) +{ + if( corners.empty() ) + return; + CvMat _image = image; + cvDrawChessboardCorners( &_image, patternSize, (CvPoint2D32f*)&corners[0], + (int)corners.size(), patternWasFound ); } } diff --git a/modules/core/include/opencv2/core/mat.hpp b/modules/core/include/opencv2/core/mat.hpp index b38d95748f..80febfee04 100644 --- a/modules/core/include/opencv2/core/mat.hpp +++ b/modules/core/include/opencv2/core/mat.hpp @@ -408,7 +408,7 @@ inline Mat::operator CvMat() const inline bool Mat::isContinuous() const { return (flags & CONTINUOUS_FLAG) != 0; } inline bool Mat::isSubmatrix() const { return (flags & SUBMATRIX_FLAG) != 0; } -inline size_t Mat::elemSize() const { return step.p[dims-1]; } +inline size_t Mat::elemSize() const { return dims > 0 ? step.p[dims-1] : 0; } inline size_t Mat::elemSize1() const { return CV_ELEM_SIZE1(flags); } inline int Mat::type() const { return CV_MAT_TYPE(flags); } inline int Mat::depth() const { return CV_MAT_DEPTH(flags); } diff --git a/modules/imgproc/src/contours.cpp b/modules/imgproc/src/contours.cpp index 7a3690c5be..0f02f55bcb 100644 --- a/modules/imgproc/src/contours.cpp +++ b/modules/imgproc/src/contours.cpp @@ -1704,8 +1704,9 @@ double cv::matchShapes( const Mat& contour1, void cv::convexHull( const Mat& points, vector& hull, bool clockwise ) { - CV_Assert(points.checkVector(2) >= 0 && (points.depth() == CV_32F || points.depth() == CV_32S)); - hull.resize(points.cols*points.rows*points.channels()/2); + int nelems = points.checkVector(2); + CV_Assert(nelems >= 0 && (points.depth() == CV_32F || points.depth() == CV_32S)); + hull.resize(nelems); CvMat _points = Mat(points), _hull=Mat(hull); cvConvexHull2(&_points, &_hull, clockwise ? CV_CLOCKWISE : CV_COUNTER_CLOCKWISE, 0); hull.resize(_hull.cols + _hull.rows - 1); @@ -1715,8 +1716,9 @@ void cv::convexHull( const Mat& points, vector& hull, bool clockwise ) void cv::convexHull( const Mat& points, vector& hull, bool clockwise ) { - CV_Assert(points.checkVector(2, CV_32S) >= 0); - hull.resize(points.cols*points.rows*points.channels()/2); + int nelems = points.checkVector(2, CV_32S); + CV_Assert(nelems >= 0); + hull.resize(nelems); CvMat _points = Mat(points), _hull=Mat(hull); cvConvexHull2(&_points, &_hull, clockwise ? CV_CLOCKWISE : CV_COUNTER_CLOCKWISE, 1); hull.resize(_hull.cols + _hull.rows - 1); @@ -1726,8 +1728,9 @@ void cv::convexHull( const Mat& points, void cv::convexHull( const Mat& points, vector& hull, bool clockwise ) { - CV_Assert(points.checkVector(2, CV_32F) >= 0); - hull.resize(points.cols*points.rows*points.channels()/2); + int nelems = points.checkVector(2, CV_32S); + CV_Assert(nelems >= 0); + hull.resize(nelems); CvMat _points = Mat(points), _hull=Mat(hull); cvConvexHull2(&_points, &_hull, clockwise ? CV_CLOCKWISE : CV_COUNTER_CLOCKWISE, 1); hull.resize(_hull.cols + _hull.rows - 1); diff --git a/modules/imgproc/src/histogram.cpp b/modules/imgproc/src/histogram.cpp index c68ed94834..837c5e3778 100644 --- a/modules/imgproc/src/histogram.cpp +++ b/modules/imgproc/src/histogram.cpp @@ -174,7 +174,7 @@ static void histPrepareImages( const Mat* images, int nimages, const int* channe uniranges.resize( dims*2 ); for( i = 0; i < dims; i++ ) { - uniranges[i*2] = 1; + uniranges[i*2] = histSize[i]/256.; uniranges[i*2+1] = 0; } } diff --git a/modules/legacy/include/opencv2/legacy/compat.hpp b/modules/legacy/include/opencv2/legacy/compat.hpp index 311fa496e7..7644cbbd23 100644 --- a/modules/legacy/include/opencv2/legacy/compat.hpp +++ b/modules/legacy/include/opencv2/legacy/compat.hpp @@ -50,6 +50,9 @@ #ifndef __OPENCV_COMPAT_HPP__ #define __OPENCV_COMPAT_HPP__ +#include "opencv2/core/core_c.h" +#include "opencv2/imgproc/types_c.h" + #include #include diff --git a/modules/objdetect/src/lsvmparser.cpp b/modules/objdetect/src/lsvmparser.cpp index 99ca7b27e7..83a326dca2 100644 --- a/modules/objdetect/src/lsvmparser.cpp +++ b/modules/objdetect/src/lsvmparser.cpp @@ -181,7 +181,7 @@ void addFilter(CvLSVMFilterObject *** model, int *last, int *max){ void parserRFilter (FILE * xmlf, int p, CvLSVMFilterObject * model, float *b){ int st = 0; - int sizeX, sizeY; + int sizeX=0, sizeY=0; int tag; int tagVal; char ch; @@ -432,7 +432,7 @@ void parserD (FILE * xmlf, int /*p*/, CvLSVMFilterObject * model){ void parserPFilter (FILE * xmlf, int p, int /*N_path*/, CvLSVMFilterObject * model){ int st = 0; - int sizeX, sizeY; + int sizeX=0, sizeY=0; int tag; int tagVal; char ch;