Skip to content

Commit

Permalink
Merge branch 'enh-improve-here-and-there' into 'master'
Browse files Browse the repository at this point in the history
ENH: add notes and pursue work on SfM.

See merge request oddkiva/sara!456
  • Loading branch information
Odd Kiva committed Apr 24, 2024
2 parents e0af2ee + 190f27c commit 63df504
Show file tree
Hide file tree
Showing 101 changed files with 23,383 additions and 2,305 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
# os: [macos-latest, windows-latest]
include:
- os: ubuntu-latest
container: 'oddkiva/sara-devel:cuda12.1.0-ubuntu22.04-trt8.6-swift5.9.1-halide16.0.0'
container: 'oddkiva/sara-devel:cuda12.1.0-ubuntu22.04-trt8.6-swift5.10-halide17.0.1'
- os: ubuntu-latest
container: 'oddkiva/sara-emsdk-devel:latest'

Expand Down
2 changes: 1 addition & 1 deletion build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ $cmake_toolset = $cmake_vsver[$vsver]

$qt_dir = "C:\local\qt-everywhere-src-6.1.2\qtbase"
$cudnn_dir = "C:\local\C:\local\cudnn-windows-x86_64-8.8.0.121_cuda12-archive"
$halide_dir = "C:\local\Halide-16.0.0-x86-64-windows"
$halide_dir = "C:\local\Halide-17.0.1-x86-64-windows"
$nvidia_codec_sdk_dir = "C:\local\Video_Codec_SDK_12.1.14"
$tensorrt_dir = "C:\local\TensorRT-8.6.0.12.Windows10.x86_64.cuda-12.0"

Expand Down
6 changes: 3 additions & 3 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
UBUNTU_VERSION = "22.04"
CUDA_VERSION = "12.1.0"
TRT_VERSION = "8.6"
SWIFT_VERSION = "5.9.1"
HALIDE_VERSION = "16.0.0"
SWIFT_VERSION = "5.10"
HALIDE_VERSION = "17.0.1"

# Docker
SARA_SOURCE_DIR = pathlib.Path(__file__).parent.resolve()
Expand Down Expand Up @@ -186,7 +186,7 @@ def generate_project(
my_cmake_prefix_paths.append(HALIDE_ROOT_PATH)
elif SYSTEM == "Darwin":
cmake_options.append("-D SARA_USE_HALIDE:BOOL=ON")
llvm_dir = subprocess.check_output(["brew", "--prefix", "llvm@16"])
llvm_dir = subprocess.check_output(["brew", "--prefix", "llvm"])
llvm_dir = llvm_dir.decode(sys.stdout.encoding).strip()
llvm_cmake_dir = pathlib.Path(llvm_dir) / "lib" / "cmake" / "llvm"
cmake_options.append(f"-D LLVM_DIR={llvm_cmake_dir}")
Expand Down
7 changes: 5 additions & 2 deletions cpp/examples/Sara/MultiViewGeometry/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@ target_link_libraries(essential_5_point_example PRIVATE tinyply)
# Visual odometry.
sara_add_example(visual_odometry_example)
target_link_libraries(visual_odometry_example PRIVATE DO::Kalpana::EasyGL #
fmt::fmt
glfw)
fmt::fmt glfw)

sara_add_example(visual_odometry_example_v2)
target_link_libraries(visual_odometry_example_v2 PRIVATE DO::Kalpana::EasyGL #
fmt::fmt glfw)

# Bundle adjustment.
sara_add_example(two_view_bundle_adjustment_example)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
#include <DO/Sara/FeatureDetectors/SIFT.hpp>
#include <DO/Sara/Graphics.hpp>
#include <DO/Sara/ImageIO.hpp>
#include <DO/Sara/MultiViewGeometry/EpipolarGraph.hpp>
#include <DO/Sara/MultiViewGeometry/Graph/EpipolarGraph.hpp>
#include <DO/Sara/MultiViewGeometry/Miscellaneous.hpp>
#include <DO/Sara/RANSAC/RANSAC.hpp>

#include <DO/Sara/SfM/BuildingBlocks/EssentialMatrixEstimation.hpp>
#include <DO/Sara/SfM/BuildingBlocks/FundamentalMatrixEstimation.hpp>
#include <DO/Sara/SfM/BuildingBlocks/KeypointMatching.hpp>
#include <DO/Sara/SfM/BuildingBlocks/Triangulation.hpp>
#include <DO/Sara/SfM/Helpers/EssentialMatrixEstimation.hpp>
#include <DO/Sara/SfM/Helpers/FundamentalMatrixEstimation.hpp>
#include <DO/Sara/SfM/Helpers/KeypointMatching.hpp>
#include <DO/Sara/SfM/Helpers/Triangulation.hpp>

#include <filesystem>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <DO/Sara/RANSAC/RANSAC.hpp>
#include <DO/Sara/Visualization.hpp>

#include <DO/Sara/SfM/BuildingBlocks/KeypointMatching.hpp>
#include <DO/Sara/SfM/Helpers/KeypointMatching.hpp>


using namespace std;
Expand Down Expand Up @@ -89,7 +89,8 @@ auto estimate_fundamental_matrix(const KeypointList<OERegion, float>& keys1,
const auto data_normalizer =
std::make_optional(Normalizer<FundamentalMatrix>{X});

auto inlier_predicate = InlierPredicate<SymmetricEpipolarGeometricSquaredDistance>{};
auto inlier_predicate =
InlierPredicate<SymmetricEpipolarGeometricSquaredDistance>{};
inlier_predicate.err_threshold = f_err_thres;

const auto [F, inliers, sample_best] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ int sara_graphics_main(int argc, char** argv)
tic();
const Eigen::MatrixXf lines_as_matrix = lines.matrix().transpose();
auto plane_list = PointList<float, 2>{};
auto& plane_tensor = plane_list._data;
auto& plane_tensor = plane_list.data;
plane_tensor.resize(static_cast<int>(line_segments.size()), 4);
plane_tensor.colmajor_view().matrix() = (Pt * lines_as_matrix) //
.colwise() //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@
#include <DO/Sara/FeatureDetectors/SIFT.hpp>
#include <DO/Sara/Graphics.hpp>
#include <DO/Sara/ImageIO.hpp>
#include <DO/Sara/MultiViewGeometry/EpipolarGraph.hpp>
#include <DO/Sara/MultiViewGeometry/Graph/EpipolarGraph.hpp>
#include <DO/Sara/MultiViewGeometry/MinimalSolvers/InlierPredicates.hpp>
#include <DO/Sara/MultiViewGeometry/MinimalSolvers/RelativePoseSolver.hpp>
#include <DO/Sara/MultiViewGeometry/Miscellaneous.hpp>
#include <DO/Sara/RANSAC/RANSAC.hpp>

#include <DO/Sara/SfM/BuildingBlocks/EssentialMatrixEstimation.hpp>
#include <DO/Sara/SfM/BuildingBlocks/FundamentalMatrixEstimation.hpp>
#include <DO/Sara/SfM/BuildingBlocks/KeypointMatching.hpp>
#include <DO/Sara/SfM/BuildingBlocks/Triangulation.hpp>
#include <DO/Sara/SfM/Helpers/EssentialMatrixEstimation.hpp>
#include <DO/Sara/SfM/Helpers/FundamentalMatrixEstimation.hpp>
#include <DO/Sara/SfM/Helpers/KeypointMatching.hpp>
#include <DO/Sara/SfM/Helpers/Triangulation.hpp>


using namespace std::string_literals;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@
#include <DO/Sara/Graphics.hpp>
#include <DO/Sara/ImageIO.hpp>
#include <DO/Sara/MultiViewGeometry/BundleAdjustmentProblem.hpp>
#include <DO/Sara/MultiViewGeometry/EpipolarGraph.hpp>
#include <DO/Sara/MultiViewGeometry/FeatureGraph.hpp>
#include <DO/Sara/MultiViewGeometry/Graph/EpipolarGraph.hpp>
#include <DO/Sara/MultiViewGeometry/Graph/FeatureGraph.hpp>
#include <DO/Sara/MultiViewGeometry/Miscellaneous.hpp>
#include <DO/Sara/RANSAC/RANSAC.hpp>

#include <DO/Sara/SfM/BuildingBlocks/EssentialMatrixEstimation.hpp>
#include <DO/Sara/SfM/BuildingBlocks/FundamentalMatrixEstimation.hpp>
#include <DO/Sara/SfM/BuildingBlocks/KeypointMatching.hpp>
#include <DO/Sara/SfM/BuildingBlocks/Triangulation.hpp>
#include <DO/Sara/SfM/Helpers/EssentialMatrixEstimation.hpp>
#include <DO/Sara/SfM/Helpers/FundamentalMatrixEstimation.hpp>
#include <DO/Sara/SfM/Helpers/KeypointMatching.hpp>
#include <DO/Sara/SfM/Helpers/Triangulation.hpp>

#if defined(_WIN32)
# pragma warning(push, 0)
Expand Down
58 changes: 35 additions & 23 deletions cpp/examples/Sara/MultiViewGeometry/visual_odometry_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,18 @@ class SingleWindowApp
glfwSetWindowSizeCallback(_window, window_size_callback);
}

//! @brief Note: RAII does not work on OpenGL applications.
//!
//! So the destructor gets a default implementation and we neeed to explicitly
//! call the terminate method.
~SingleWindowApp() = default;
~SingleWindowApp()
{
// Destroy GL objects.
deinit_gl_resources();

// Destroy GLFW.
if (_window != nullptr)
glfwDestroyWindow(_window);

if (_glfw_initialized)
glfwTerminate();
}

auto set_config(const fs::path& video_path,
const sara::v2::BrownConradyDistortionModel<double>& camera)
Expand Down Expand Up @@ -125,17 +132,6 @@ class SingleWindowApp
}
}

auto terminate() -> void
{
// Destroy GL objects.
deinit_gl_resources();

// Destroy GLFW.
if (_window != nullptr)
glfwDestroyWindow(_window);
glfwTerminate();
}

private:
auto init_opengl() -> void
{
Expand Down Expand Up @@ -264,8 +260,13 @@ class SingleWindowApp
private:
static auto init_glfw() -> void
{
if (_glfw_initialized)
throw std::runtime_error{
"Error: cannot instantiate more than one GLFW application!"};

// Initialize the windows manager.
if (!glfwInit())
_glfw_initialized = glfwInit();
if (!_glfw_initialized)
throw std::runtime_error{"Error: failed to initialize GLFW!"};

glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
Expand All @@ -292,6 +293,8 @@ class SingleWindowApp
}

private:
static bool _glfw_initialized;

GLFWwindow* _window = nullptr;
//! @brief Framebuffer sizes
//! We want to use this and not the window sizes because of MacOS retina
Expand Down Expand Up @@ -327,6 +330,8 @@ class SingleWindowApp
float _point_size = 5.f;
};

bool SingleWindowApp::_glfw_initialized = false;


auto main(int const argc, char** const argv) -> int
{
Expand All @@ -340,7 +345,7 @@ auto main(int const argc, char** const argv) -> int
{
std::cout << fmt::format("Usage: {} VIDEO_PATH\n",
std::string_view{argv[0]});
return 1;
return EXIT_FAILURE;
}

const auto video_path = fs::path{argv[1]};
Expand All @@ -360,10 +365,17 @@ auto main(int const argc, char** const argv) -> int
camera.p() << -0.0003137658969742134, 0.00021943576376532096;
}

auto app = SingleWindowApp{{800, 600}, "Odometry: " + video_path.string()};
app.set_config(video_path, camera);
app.run();
app.terminate();
try
{
auto app = SingleWindowApp{{800, 600}, "Odometry: " + video_path.string()};
app.set_config(video_path, camera);
app.run();
}
catch (std::exception& e)
{
std::cerr << e.what() << std::endl;
return EXIT_FAILURE;
}

return 0;
return EXIT_SUCCESS;
}
Loading

0 comments on commit 63df504

Please sign in to comment.