several small fixes; added overloaded variant of cv::drawChessboardCorners

This commit is contained in:
Vadim Pisarevsky 2010-11-27 23:16:50 +00:00
parent ee3618243d
commit cbe132cabe
7 changed files with 34 additions and 13 deletions

View 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,

View 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 );
}
}

View 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); }

View 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);

View 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;
}
}

View 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>

View File

@ -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;