Skip to content

Commit

Permalink
Merge pull request #393 from oddkiva/maint-move-calibration-code
Browse files Browse the repository at this point in the history
MAINT: move chessboard detection and camera calibration to main source folder.
  • Loading branch information
oddkiva authored Jul 15, 2024
2 parents 3b07642 + be776d0 commit 7d718a3
Show file tree
Hide file tree
Showing 42 changed files with 62 additions and 81 deletions.
2 changes: 0 additions & 2 deletions cpp/drafts/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ if(SARA_BUILD_TESTS)
add_definitions(-DBOOST_ALL_NO_LIB)
endif()

add_subdirectory(ChessboardDetection)
add_subdirectory(Calibration)
add_subdirectory(Compute)
add_subdirectory(MatchPropagation)
add_subdirectory(NuScenes)
Expand Down
1 change: 1 addition & 0 deletions cpp/examples/Sara/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ if (SARA_BUILD_VIDEOIO)
add_subdirectory(VideoIO)
endif ()

add_subdirectory(ChessboardDetection)
add_subdirectory(NeuralNetworks)
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,16 @@

//! @example

#ifdef _OPENMP
#include <omp.h>
#endif

#include <DO/Sara/ChessboardDetection/ChessboardDetector.hpp>
#include <DO/Sara/Graphics.hpp>

#include <DO/Sara/ImageProcessing/FastColorConversion.hpp>

#include <drafts/ChessboardDetection/ChessboardDetector.hpp>

#include "Utilities/ImageOrVideoReader.hpp"

#ifdef _OPENMP
# include <omp.h>
#endif

#include <optional>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@

#include <DO/Sara/Graphics.hpp>

#include <DO/Sara/ChessboardDetection/ChessboardDetector.hpp>
#include <DO/Sara/ImageProcessing/FastColorConversion.hpp>

#include <drafts/ChessboardDetection/ChessboardDetector.hpp>

#include "Utilities/ImageOrVideoReader.hpp"

#include <optional>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,7 @@
//! This partially implements OpenCV ideas used to detect the chessboard to draw
//! some intuitions.

#ifdef _OPENMP
# include <omp.h>
#endif

#include <map>
#include <unordered_map>

#include <DO/Sara/ChessboardDetection/Erode.hpp>
#include <DO/Sara/Core/TicToc.hpp>
#include <DO/Sara/FeatureDetectors.hpp>
#include <DO/Sara/FeatureDetectors/EdgePostProcessing.hpp>
Expand All @@ -32,7 +26,13 @@
#include <DO/Sara/ImageProcessing/FastColorConversion.hpp>
#include <DO/Sara/VideoIO.hpp>

#include <drafts/ChessboardDetection/Erode.hpp>

#ifdef _OPENMP
# include <omp.h>
#endif

#include <map>
#include <unordered_map>


namespace sara = DO::Sara;
Expand Down
6 changes: 3 additions & 3 deletions cpp/examples/Sara/ImageProcessing/find_chessboard_corners.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
#include <DO/Sara/VideoIO.hpp>
#include <DO/Sara/Visualization.hpp>

#include "Chessboard/CircularProfileExtractor.hpp"
#include "Chessboard/JunctionDetection.hpp"
#include "Chessboard/NonMaximumSuppression.hpp"
#include <DO/Sara/Chessboard/CircularProfileExtractor.hpp>
#include <DO/Sara/Chessboard/JunctionDetection.hpp>
#include <DO/Sara/Chessboard/NonMaximumSuppression.hpp>


namespace sara = DO::Sara;
Expand Down
3 changes: 3 additions & 0 deletions cpp/src/DO/Sara/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,7 @@ include(UseDOSaraRANSAC)

include(UseDOSaraVisualization)

add_subdirectory(ChessboardDetection)
add_subdirectory(Calibration)

add_subdirectory(NeuralNetworks)
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,3 @@ add_library(
target_link_libraries(DO_Sara_Calibration PUBLIC DO::Sara::Core
DO::Sara::Graphics)
set_property(TARGET DO_Sara_Calibration PROPERTY FOLDER "Libraries/Sara")

add_subdirectory(tool)
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

//! @file

#include <drafts/Calibration/Chessboard.hpp>
#include <DO/Sara/Calibration/Chessboard.hpp>


namespace DO::Sara {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

#pragma once

#include <drafts/ChessboardDetection/ChessboardDetector.hpp>
#include <DO/Sara/ChessboardDetection/ChessboardDetector.hpp>

#include <optional>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#pragma once

#include <drafts/Calibration/Chessboard.hpp>
#include <DO/Sara/Calibration/Chessboard.hpp>

#include <DO/Sara/Graphics.hpp>
#include <DO/Sara/MultiViewGeometry/Camera/v2/OmnidirectionalCamera.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,3 @@ target_link_libraries(
DO_Sara_ChessboardDetection
PUBLIC DO::Sara::ImageProcessing #
DO::Sara::FeatureDetectors)

add_subdirectory(examples)
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
// you can obtain one at http://mozilla.org/MPL/2.0/.
// ========================================================================== //

#include <drafts/ChessboardDetection/ChessboardDetector.hpp>
#include <drafts/ChessboardDetection/LineReconstruction.hpp>
#include <drafts/ChessboardDetection/NonMaximumSuppression.hpp>
#include <drafts/ChessboardDetection/OrientationHistogram.hpp>
#include <drafts/ChessboardDetection/SquareReconstruction.hpp>
#include <DO/Sara/ChessboardDetection/ChessboardDetector.hpp>
#include <DO/Sara/ChessboardDetection/LineReconstruction.hpp>
#include <DO/Sara/ChessboardDetection/NonMaximumSuppression.hpp>
#include <DO/Sara/ChessboardDetection/OrientationHistogram.hpp>
#include <DO/Sara/ChessboardDetection/SquareReconstruction.hpp>

#include <DO/Sara/FeatureDescriptors/Orientation.hpp>
#include <DO/Sara/FeatureDetectors/EdgePostProcessing.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
#include <DO/Sara/FeatureDetectors/EdgeDetector.hpp>
#include <DO/Sara/ImageProcessing/EdgeShapeStatistics.hpp>

#include <drafts/ChessboardDetection/CircularProfileExtractor.hpp>
#include <drafts/ChessboardDetection/Corner.hpp>
#include <drafts/ChessboardDetection/EdgeStatistics.hpp>
#include <drafts/ChessboardDetection/SquareGraph.hpp>
#include <DO/Sara/ChessboardDetection/CircularProfileExtractor.hpp>
#include <DO/Sara/ChessboardDetection/Corner.hpp>
#include <DO/Sara/ChessboardDetection/EdgeStatistics.hpp>
#include <DO/Sara/ChessboardDetection/SquareGraph.hpp>


namespace DO::Sara {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// you can obtain one at http://mozilla.org/MPL/2.0/.
// ========================================================================== //

#include "CircularProfileExtractor.hpp"
#include <DO/Sara/ChessboardDetection/CircularProfileExtractor.hpp>

#include <DO/Sara/ImageProcessing/Interpolation.hpp>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
// you can obtain one at http://mozilla.org/MPL/2.0/.
// ========================================================================== //

#include "Corner.hpp"
#include "NonMaximumSuppression.hpp"
#include <DO/Sara/ChessboardDetection/Corner.hpp>
#include <DO/Sara/ChessboardDetection/NonMaximumSuppression.hpp>

#include <DO/Sara/ImageProcessing/JunctionRefinement.hpp>

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// you can obtain one at http://mozilla.org/MPL/2.0/.
// ========================================================================== //

#include "EdgeStatistics.hpp"
#include <DO/Sara/ChessboardDetection/EdgeStatistics.hpp>


namespace DO::Sara {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,18 @@
// you can obtain one at http://mozilla.org/MPL/2.0/.
// ========================================================================== //

#include <DO/Sara/ChessboardDetection/JunctionDetection.hpp>

#ifdef _OPENMP
#include <omp.h>
# include <omp.h>
#endif

#include "JunctionDetection.hpp"


namespace DO::Sara {

auto junction_map(const ImageView<float>& image,
const ImageView<Eigen::Vector2f>& gradients,
const float sigma)
-> Image<float>
const float sigma) -> Image<float>
{
auto junction_map = Image<float>{image.sizes()};
junction_map.flat_array().fill(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
// you can obtain one at http://mozilla.org/MPL/2.0/.
// ========================================================================== //

#include "LineReconstruction.hpp"
#include "SquareReconstruction.hpp"
#include <DO/Sara/ChessboardDetection/LineReconstruction.hpp>
#include <DO/Sara/ChessboardDetection/SquareReconstruction.hpp>


namespace DO::Sara {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@

#pragma once

#include <unordered_set>

#include <DO/Sara/ChessboardDetection/SquareReconstruction.hpp>
#include <DO/Sara/ImageProcessing/EdgeShapeStatistics.hpp>

#include "SquareReconstruction.hpp"

#include <unordered_set>

namespace DO::Sara {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#pragma once

#include "ChessboardDetector.hpp"
#include <DO/Sara/ChessboardDetection/ChessboardDetector.hpp>


namespace DO::Sara {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@

#pragma once

#include "Corner.hpp"

#include <DO/Sara/ChessboardDetection/Corner.hpp>
#include <DO/Sara/Graphics.hpp>

#include <cstdint>
Expand Down Expand Up @@ -297,9 +296,7 @@ namespace DO::Sara {
for (auto x = 0; x < cols(cb); ++x)
{
new_row.push_back(ChessboardSquare{
-1,
Eigen::Vector2i{anchor.x() + x, curr_coords.y() - 1},
{} //
-1, Eigen::Vector2i{anchor.x() + x, curr_coords.y() - 1}, {} //
});
}
cb.emplace_front(std::move(new_row));
Expand All @@ -312,9 +309,7 @@ namespace DO::Sara {
for (auto x = 0; x < cols(cb); ++x)
{
new_row.push_back(ChessboardSquare{
-1,
Eigen::Vector2i{anchor.x() + x, curr_coords.y() + 1},
{} //
-1, Eigen::Vector2i{anchor.x() + x, curr_coords.y() + 1}, {} //
});
}

Expand All @@ -327,9 +322,7 @@ namespace DO::Sara {
for (auto y = 0; y < rows(cb); ++y)
{
cb[y].push_front(ChessboardSquare{
-1,
Eigen::Vector2i{curr_coords.x() - 1, anchor.y() + y},
{} //
-1, Eigen::Vector2i{curr_coords.x() - 1, anchor.y() + y}, {} //
});
}
}
Expand All @@ -339,9 +332,7 @@ namespace DO::Sara {
for (auto y = 0; y < rows(cb); ++y)
{
cb[y].push_back(ChessboardSquare{
-1,
Eigen::Vector2i{curr_coords.x() + 1, anchor.y() + y},
{} //
-1, Eigen::Vector2i{curr_coords.x() + 1, anchor.y() + y}, {} //
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// you can obtain one at http://mozilla.org/MPL/2.0/.
// ========================================================================== //

#include "SquareReconstruction.hpp"
#include <DO/Sara/ChessboardDetection/SquareReconstruction.hpp>


namespace DO::Sara {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@

#pragma once

#include <DO/Sara/ChessboardDetection/Corner.hpp>

#include <optional>
#include <unordered_set>

#include "Corner.hpp"


namespace DO::Sara {

Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions cpp/tools/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
add_subdirectory(Calibration)
add_subdirectory(ImageAnnotator)
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@

//! @file

#include <drafts/Calibration/Chessboard.hpp>
#include <drafts/Calibration/Utilities.hpp>

#include <DO/Sara/Calibration/Chessboard.hpp>
#include <DO/Sara/Calibration/Utilities.hpp>
#include <DO/Sara/Core/TicToc.hpp>
#include <DO/Sara/Graphics.hpp>
#include <DO/Sara/VideoIO.hpp>

#include <DO/Sara/ImageProcessing/FastColorConversion.hpp>
#include <DO/Sara/MultiViewGeometry/Calibration/OmnidirectionalCameraReprojectionError.hpp>
#include <DO/Sara/VideoIO.hpp>


namespace sara = DO::Sara;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,15 @@

//! @file

#include <drafts/Calibration/Utilities.hpp>

#include <DO/Sara/Calibration/Utilities.hpp>
#include <DO/Sara/Core/EigenFormatInterop.hpp>
#include <DO/Sara/Core/TicToc.hpp>
#include <DO/Sara/Graphics.hpp>
#include <DO/Sara/VideoIO.hpp>

#include <DO/Sara/ImageProcessing/FastColorConversion.hpp>
#include <DO/Sara/MultiViewGeometry/Calibration/PinholeCameraReprojectionError.hpp>
#include <DO/Sara/MultiViewGeometry/Camera/v2/PinholeCamera.hpp>
#include <DO/Sara/MultiViewGeometry/PnP/LambdaTwist.hpp>
#include <DO/Sara/VideoIO.hpp>


namespace sara = DO::Sara;
Expand All @@ -33,7 +31,8 @@ class ChessboardCalibrationData
static constexpr auto extrinsic_parameter_count =
sara::PinholeCameraReprojectionError::extrinsic_parameter_count;

auto initialize_intrinsics(const sara::v2::PinholeCamera<double>& camera) -> void
auto initialize_intrinsics(const sara::v2::PinholeCamera<double>& camera)
-> void
{
// fx
_intrinsics.fx() = camera.fx();
Expand Down

0 comments on commit 7d718a3

Please sign in to comment.