23 #include <mrpt/examples_config.h> 25 MRPT_EXAMPLES_BASE_DIRECTORY +
string(
"vision_multiple_checkerboards/");
31 const std::string& img_filename,
const unsigned int checkerboard_size_x,
32 const unsigned int checkerboard_size_y)
38 if (!
img.loadFromFile(img_filename))
39 throw std::runtime_error(
"Can't load image!");
42 vector<vector<TPixelCoordf>> listCornerCoords;
44 timlog.
enter(
"findMultipleChessboardsCorners");
47 img, listCornerCoords, checkerboard_size_x, checkerboard_size_y);
49 timlog.
leave(
"findMultipleChessboardsCorners");
51 cout <<
"Number of checkerboards detected: " << listCornerCoords.size()
57 for (
size_t i = 0; i < listCornerCoords.size(); i++)
59 listCornerCoords[i], checkerboard_size_x, checkerboard_size_y);
63 win1.showImage(img_detect);
75 int main(
int argc,
char** argv)
80 unsigned int checkerboard_size_x = 5;
81 unsigned int checkerboard_size_y = 4;
86 checkerboard_size_x = atoi(argv[2]);
87 checkerboard_size_y = atoi(argv[3]);
91 std::cerr <<
"Usage: " << argv[0] <<
" [IMAGE_FILE NX NY]\n";
96 sFile, checkerboard_size_x, checkerboard_size_y);
99 catch (std::exception& e)
101 std::cout <<
"MRPT exception caught: " << e.what() << std::endl;
106 printf(
"Untyped exception!!");
void findMultipleChessboardsCorners(const mrpt::img::CImage &img, std::vector< std::vector< mrpt::img::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.
bool drawChessboardCorners(std::vector< TPixelCoordf > &cornerCoords, unsigned int check_size_x, unsigned int check_size_y, unsigned int lines_width=1, unsigned int circles_radius=4)
Draw onto this image the detected corners of a chessboard.
void clear(bool deep_clear=false)
Resets all stats.
void dumpAllStats(const size_t column_width=80) const
Dump all stats through the COutputLogger interface.
This class creates a window as a graphical user interface (GUI) for displaying images to the user...
Classes for computer vision, detectors, features, etc.
double leave(const char *func_name)
End of a named section.
GLsizei const GLchar ** string
void colorImage(CImage &ret) const
Returns a RGB version of the grayscale image, or itself if it is already a RGB image.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
A versatile "profiler" that logs the time spent within each pair of calls to enter(X)-leave(X), among other stats.
Classes for creating GUI windows for 2D and 3D visualization.
void TestMultipleCheckerboard(const std::string &img_filename, const unsigned int checkerboard_size_x, const unsigned int checkerboard_size_y)
void enter(const char *func_name)
Start of a named section.
A class for storing images as grayscale or RGB bitmaps.