Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/aliceVision/calibration/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@ set(calibration_files_headers
patternDetect.hpp
exportData.hpp
distortionEstimation.hpp
distortionEstimationLine.hpp
distortionEstimationPoint.hpp
distortionEstimationGeometry.hpp
checkerDetector.hpp
checkerDetector_io.hpp
)

# Sources
set(calibration_files_sources
distortionEstimation.cpp
distortionEstimationLine.cpp
distortionEstimationPoint.cpp
distortionEstimationGeometry.cpp
checkerDetector.cpp
checkerDetector_io.cpp
)
Expand Down
40 changes: 38 additions & 2 deletions src/aliceVision/calibration/checkerDetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1446,6 +1446,43 @@ bool CheckerDetector::removeInvalidCheckerboards()

const Vec2i delta = horizontal ? Vec2i{1, 0} : Vec2i{0, 1};

/**
* Check squares for not too important angles
*/
for (int i = 0; i < board.rows() - 1; ++i)
{
for (int j = 0; j < board.cols() - 1; j++)
{
const IndexT c00 = board(i, j);
const IndexT c01 = board(i, j + 1);
const IndexT c10 = board(i + 1, j);
const IndexT c11 = board(i + 1, j + 1);

if (c00 == UndefinedIndexT || c01 == UndefinedIndexT || c10 == UndefinedIndexT || c11 == UndefinedIndexT)
{
continue;
}

Vec2 dir1 = (_corners[c01].center - _corners[c00].center).normalized();
Vec2 dir2 = (_corners[c10].center - _corners[c00].center).normalized();
Vec2 dir3 = (_corners[c10].center - _corners[c11].center).normalized();
Vec2 dir4 = (_corners[c01].center - _corners[c11].center).normalized();

double a1 = std::acos(dir1.dot(dir2));
double a2 = std::acos(dir1.dot(dir2));

if (a1 < M_PI_4 || a1 > 3.0 * M_PI_4)
{
return true;
}

if (a2 < M_PI_4 || a2 > 3.0 * M_PI_4)
{
return true;
}
}
}

for (int i = 0; i < board.rows() - delta.y(); ++i)
{
Vec2 sum{0, 0};
Expand Down Expand Up @@ -1610,9 +1647,8 @@ void CheckerDetector::filterNestedCheckerBoards(const size_t& height, const size
}

double mean_area = mean_squares / count_squares;

// Check that square size function is increasing
if (mean_area < previous_area * 0.8)
if (mean_area < previous_area * 0.5)
continue;

previous_area = mean_area;
Expand Down
67 changes: 1 addition & 66 deletions src/aliceVision/calibration/distortionEstimation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,12 @@
#include <aliceVision/numeric/numeric.hpp>
#include <aliceVision/camera/Pinhole.hpp>
#include <aliceVision/camera/Undistortion.hpp>

#include <vector>
#include <memory>

namespace aliceVision {
namespace calibration {

/**
* @brief Set of 2D points that belong to the same line.
*
* The 2D points correspond to real-world points that are aligned and evenly spaced
* observed with a camera which applies some distortion on them.
*
* Therefore these 2D points may not actually be aligned and evenly spaced,
* and this difference with the ideal line model is used to estimate distortion.
*/
struct LineWithPoints
{
double angle;
double dist;
std::vector<Vec2> points;
};

/**
* @brief a pair of points coordinates
*
* One vector for the distorted coordinates
* One vector from the undistorted coordinates
*/
struct PointPair
{
Vec2 distortedPoint;
Vec2 undistortedPoint;
};

/**
* @brief Statistics on distortion parameters estimation error.
*/
Expand All @@ -52,45 +23,9 @@ struct Statistics
double mean;
double stddev;
double median;
double lastDecile;
double max;
};

/**
* @brief Estimate the undistortion parameters of a camera using a set of line aligned points.
*
* This algorithms minimizes a distance between points and lines using distortion.
*
* @param[out] undistortionToEstimate Undistortion object with the parameters to estimate.
* @param[out] statistics Statistics on the estimation error.
* @param[in] lines Set of line aligned points used to estimate distortion.
* @param[in] lockCenter Lock the distortion offset during optimization.
* @param[in] lockDistortions Distortion parameters to lock during optimization.
* @return False if the estimation failed, otherwise true.
*/
bool estimate(std::shared_ptr<camera::Undistortion> undistortionToEstimate,
Statistics& statistics,
std::vector<LineWithPoints>& lines,
bool lockCenter,
const std::vector<bool>& lockDistortions);


/**
* @brief Estimate the undistortion parameters of a camera using a set of pair of undistorted/distorted points.
*
* This algorithms minimizes a distance between points and points using distortion.
*
* @param[out] undistortionToEstimate Undistortion object with the parameters to estimate.
* @param[out] statistics Statistics on the estimation error.
* @param[in] pointpairs Set of pair of points used to estimate distortion.
* @param[in] lockCenter Lock the distortion offset during optimization.
* @param[in] lockDistortions Distortion parameters to lock during optimization.
* @return False if the estimation failed, otherwise true.
*/
bool estimate(std::shared_ptr<camera::Undistortion> undistortionToEstimate,
Statistics& statistics,
const std::vector<PointPair>& pointpairs,
bool lockCenter,
const std::vector<bool>& lockDistortions);

} // namespace calibration
} // namespace aliceVision
Loading