<commit_before>/* +------------------------------------------------------------------------+
   |                     Mobile Robot Programming Toolkit (MRPT)            |
   |                          https://www.mrpt.org/                         |
   |                                                                        |
   | Copyright (c) 2005-2021, Individual contributors, see AUTHORS file     |
   | See: https://www.mrpt.org/Authors - All rights reserved.               |
   | Released under BSD License. See: https://www.mrpt.org/License          |
   +------------------------------------------------------------------------+ */

#include "vision-precomp.h"	 // Precompiled headers
//
#include <mrpt/3rdparty/do_opencv_includes.h>
#include <mrpt/config/CConfigFileMemory.h>
#include <mrpt/system/filesystem.h>
#include <mrpt/vision/chessboard_camera_calib.h>
#include <mrpt/vision/chessboard_find_corners.h>
#include <mrpt/vision/pinhole.h>

#include <Eigen/Dense>

using namespace mrpt;
using namespace mrpt::vision;
using namespace mrpt::img;
using namespace mrpt::config;
using namespace mrpt::math;
using namespace mrpt::poses;
using namespace std;

/* -------------------------------------------------------
				checkerBoardCameraCalibration
   ------------------------------------------------------- */
bool mrpt::vision::checkerBoardCameraCalibration(
	TCalibrationImageList& images, unsigned int check_size_x,
	unsigned int check_size_y, double check_squares_length_X_meters,
	double check_squares_length_Y_meters, CMatrixDouble33& intrinsicParams,
	std::vector<double>& distortionParams, bool normalize_image,
	double* out_MSE, bool skipDrawDetectedImgs,
	bool useScaramuzzaAlternativeDetector)
{
	// Just a wrapper for the newer version of the function which uses TCamera:
	TCamera cam;
	bool ret = checkerBoardCameraCalibration(
		images, check_size_x, check_size_y, check_squares_length_X_meters,
		check_squares_length_Y_meters, cam, normalize_image, out_MSE,
		skipDrawDetectedImgs, useScaramuzzaAlternativeDetector);

	intrinsicParams = cam.intrinsicParams;
	distortionParams = cam.getDistortionParamsAsVector();
	return ret;
}

#if MRPT_HAS_OPENCV
#include <opencv2/core/eigen.hpp>
#endif

/* -------------------------------------------------------
				checkerBoardCameraCalibration
   ------------------------------------------------------- */
bool mrpt::vision::checkerBoardCameraCalibration(
	TCalibrationImageList& images, unsigned int check_size_x,
	unsigned int check_size_y, double check_squares_length_X_meters,
	double check_squares_length_Y_meters, mrpt::img::TCamera& out_camera_params,
	bool normalize_image, double* out_MSE,
	[[maybe_unused]] bool skipDrawDetectedImgs,
	bool useScaramuzzaAlternativeDetector)
{
#if MRPT_HAS_OPENCV
	try
	{
		ASSERT_(check_size_x > 2);
		ASSERT_(check_size_y > 2);
		ASSERT_(check_squares_length_X_meters > 0);
		ASSERT_(check_squares_length_Y_meters > 0);

		if (images.size() < 1)
		{
			std::cout << "ERROR: No input images." << std::endl;
			return false;
		}<commit_msg>includes must happen before "using"<commit_after>/* +------------------------------------------------------------------------+
   |                     Mobile Robot Programming Toolkit (MRPT)            |
   |                          https://www.mrpt.org/                         |
   |                                                                        |
   | Copyright (c) 2005-2021, Individual contributors, see AUTHORS file     |
   | See: https://www.mrpt.org/Authors - All rights reserved.               |
   | Released under BSD License. See: https://www.mrpt.org/License          |
   +------------------------------------------------------------------------+ */

#include "vision-precomp.h"	 // Precompiled headers
//
#include <mrpt/3rdparty/do_opencv_includes.h>
#include <mrpt/config/CConfigFileMemory.h>
#include <mrpt/system/filesystem.h>
#include <mrpt/vision/chessboard_camera_calib.h>
#include <mrpt/vision/chessboard_find_corners.h>
#include <mrpt/vision/pinhole.h>

#include <Eigen/Dense>

#if MRPT_HAS_OPENCV
#include <opencv2/core/eigen.hpp>
#endif

using namespace mrpt;
using namespace mrpt::vision;
using namespace mrpt::img;
using namespace mrpt::config;
using namespace mrpt::math;
using namespace mrpt::poses;
using namespace std;

/* -------------------------------------------------------
				checkerBoardCameraCalibration
   ------------------------------------------------------- */
bool mrpt::vision::checkerBoardCameraCalibration(
	TCalibrationImageList& images, unsigned int check_size_x,
	unsigned int check_size_y, double check_squares_length_X_meters,
	double check_squares_length_Y_meters, CMatrixDouble33& intrinsicParams,
	std::vector<double>& distortionParams, bool normalize_image,
	double* out_MSE, bool skipDrawDetectedImgs,
	bool useScaramuzzaAlternativeDetector)
{
	// Just a wrapper for the newer version of the function which uses TCamera:
	TCamera cam;
	bool ret = checkerBoardCameraCalibration(
		images, check_size_x, check_size_y, check_squares_length_X_meters,
		check_squares_length_Y_meters, cam, normalize_image, out_MSE,
		skipDrawDetectedImgs, useScaramuzzaAlternativeDetector);

	intrinsicParams = cam.intrinsicParams;
	distortionParams = cam.getDistortionParamsAsVector();
	return ret;
}


/* -------------------------------------------------------
				checkerBoardCameraCalibration
   ------------------------------------------------------- */
bool mrpt::vision::checkerBoardCameraCalibration(
	TCalibrationImageList& images, unsigned int check_size_x,
	unsigned int check_size_y, double check_squares_length_X_meters,
	double check_squares_length_Y_meters, mrpt::img::TCamera& out_camera_params,
	bool normalize_image, double* out_MSE,
	[[maybe_unused]] bool skipDrawDetectedImgs,
	bool useScaramuzzaAlternativeDetector)
{
#if MRPT_HAS_OPENCV
	try
	{
		ASSERT_(check_size_x > 2);
		ASSERT_(check_size_y > 2);
		ASSERT_(check_squares_length_X_meters > 0);
		ASSERT_(check_squares_length_Y_meters > 0);

		if (images.size() < 1)
		{
			std::cout << "ERROR: No input images." << std::endl;
			return false;
		}
{'fraction_non_alphanumeric': 0.20218846970439328, 'fraction_numerical': 0.005552833578311285, 'mean_word_length': 2.346448087431694, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 29, 'https://': 6, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7309108', 'n_tokens_mistral': 1910, 'n_tokens_neox': 1789, 'n_words': 362}