16 #include <mrpt/otherlibs/do_opencv_includes.h> 37 std::vector<TPixelCoordf> &cornerCoords,
38 unsigned int check_size_x,
39 unsigned int check_size_y,
41 bool useScaramuzzaMethod)
46 ASSERT_(check_size_y>0 && check_size_x>0)
53 bool corners_found=
false;
55 const CvSize check_size = cvSize(check_size_x, check_size_y);
57 const int CORNERS_COUNT = check_size_x * check_size_y;
59 vector<CvPoint2D32f> corners_list;
60 corners_count = CORNERS_COUNT;
61 corners_list.resize( CORNERS_COUNT );
65 int find_chess_flags = cv::CALIB_CB_ADAPTIVE_THRESH;
67 find_chess_flags |= cv::CALIB_CB_NORMALIZE_IMAGE;
69 if (!useScaramuzzaMethod)
71 cv::Mat cvImg = cv::cvarrToMat(
img.getAs<IplImage>());
73 vector<cv::Point2f> pointbuf;
82 corners_list.resize(pointbuf.size());
83 for (
size_t i=0;i<pointbuf.size();i++) {
84 corners_list[i].x = pointbuf[i].x;
85 corners_list[i].y = pointbuf[i].y;
99 if (corners_found && corners_count!=CORNERS_COUNT)
106 img.getAs<IplImage>(),
111 cvTermCriteria( CV_TERMCRIT_ITER|CV_TERMCRIT_EPS, 10, 0.01f ));
116 for(
y = 0, k = 0;
y < check_size.height;
y++ )
117 for(
int x = 0;
x < check_size.width;
x++, k++ )
118 cornerCoords.push_back(
TPixelCoordf( corners_list[k].
x, corners_list[k].
y ) );
122 return corners_found;
146 std::vector<std::vector<TPixelCoordf> > &cornerCoords,
147 unsigned int check_size_x,
148 unsigned int check_size_y )
154 std::vector<std::vector<CvPoint2D32f> > corners_list;
159 cvSize(check_size_x,check_size_y),
162 if( corners_found && !corners_list.empty() )
165 cornerCoords.resize( corners_list.size() );
168 for (
size_t i=0;i<corners_list.size();i++)
170 ASSERT_(corners_list[i].
size()==check_size_x*check_size_y)
173 img.getAs<IplImage>(),
175 check_size_x*check_size_y,
178 cvTermCriteria( CV_TERMCRIT_ITER|CV_TERMCRIT_EPS, 10, 0.01f ));
181 for(
unsigned int y = 0, k = 0;
y < check_size_y;
y++ )
182 for(
unsigned int x = 0;
x < check_size_x;
x++, k++ )
191 pt_0 = cornerCoords[i][0],
192 pt_x1 = cornerCoords[i][1],
193 pt_y1 = cornerCoords[i][check_size_x];
200 for(
unsigned int y = 0;
y < check_size_y;
y++ )
201 std::reverse( cornerCoords[i].
begin()+
y*check_size_x, cornerCoords[i].
begin()+(
y+1)*check_size_x );
207 cornerCoords.clear();
int cvFindChessboardCorners3(const mrpt::utils::CImage &img_, CvSize pattern_size, std::vector< CvPoint2D32f > &out_corners)
A pair (x,y) of pixel coordinates (subpixel resolution).
bool find_chessboard_corners_multiple(const mrpt::utils::CImage &img_, CvSize pattern_size, std::vector< std::vector< CvPoint2D32f > > &out_corners)
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
A class for storing images as grayscale or RGB bitmaps.
bool VISION_IMPEXP findChessboardCorners(const mrpt::utils::CImage &img, std::vector< mrpt::utils::TPixelCoordf > &cornerCoords, unsigned int check_size_x, unsigned int check_size_y, bool normalize_image=true, bool useScaramuzzaMethod=false)
Look for the corners of a chessboard in the image using one of two different methods.
EIGEN_STRONG_INLINE iterator begin()
EIGEN_STRONG_INLINE void push_back(Scalar val)
Insert an element at the end of the container (for 1D vectors/arrays)
void crossProduct3D(const T &v0, const U &v1, V &vOut)
Computes the cross product of two 3D vectors, returning a vector normal to both.
This base provides a set of functions for maths stuff.
Classes for computer vision, detectors, features, etc.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
void VISION_IMPEXP findMultipleChessboardsCorners(const mrpt::utils::CImage &img, std::vector< std::vector< mrpt::utils::TPixelCoordf > > &cornerCoords, unsigned int check_size_x, unsigned int check_size_y)
Look for the corners of one or more chessboard/checkerboards in the image.