several small fixes; added overloaded variant of cv::drawChessboardCorners
authorVadim Pisarevsky <no@email>
Sat, 27 Nov 2010 23:16:50 +0000 (23:16 +0000)
committerVadim Pisarevsky <no@email>
Sat, 27 Nov 2010 23:16:50 +0000 (23:16 +0000)
modules/calib3d/include/opencv2/calib3d/calib3d.hpp
modules/calib3d/src/calibinit.cpp
modules/core/include/opencv2/core/mat.hpp
modules/imgproc/src/contours.cpp
modules/imgproc/src/histogram.cpp
modules/legacy/include/opencv2/legacy/compat.hpp
modules/objdetect/src/lsvmparser.cpp

index f0ab377..e2de756 100644 (file)
@@ -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<Point2f>& corners,
+                                       bool patternWasFound );    
+    
 enum
 {
     CALIB_USE_INTRINSIC_GUESS = 1,
index b6083fa..b283a4f 100644 (file)
@@ -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<Point2f>& corners,
+                            bool patternWasFound )
+{
+    if( corners.empty() )
+        return;
+    CvMat _image = image;
+    cvDrawChessboardCorners( &_image, patternSize, (CvPoint2D32f*)&corners[0],
+                            (int)corners.size(), patternWasFound );
 }
 
 }
index b38d957..80febfe 100644 (file)
@@ -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); }
index 7a3690c..0f02f55 100644 (file)
@@ -1704,8 +1704,9 @@ double cv::matchShapes( const Mat& contour1,
 
 void cv::convexHull( const Mat& points, vector<int>& 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<int>& hull, bool clockwise )
 void cv::convexHull( const Mat& points,
                      vector<Point>& 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<Point2f>& 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);
index c68ed94..837c5e3 100644 (file)
@@ -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;
         }
     }
index 311fa49..7644cbb 100644 (file)
@@ -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 <math.h>
 #include <string.h>
 
index 99ca7b2..83a326d 100644 (file)
@@ -181,7 +181,7 @@ void addFilter(CvLSVMFilterObject *** model, int *last, int *max){
 \r
 void parserRFilter  (FILE * xmlf, int p, CvLSVMFilterObject * model, float *b){\r
     int st = 0;\r
-    int sizeX, sizeY;\r
+    int sizeX=0, sizeY=0;\r
     int tag;\r
     int tagVal;\r
     char ch;\r
@@ -432,7 +432,7 @@ void parserD  (FILE * xmlf, int /*p*/, CvLSVMFilterObject * model){
 \r
 void parserPFilter  (FILE * xmlf, int p, int /*N_path*/, CvLSVMFilterObject * model){\r
     int st = 0;\r
-    int sizeX, sizeY;\r
+    int sizeX=0, sizeY=0;\r
     int tag;\r
     int tagVal;\r
     char ch;\r