From 3022adcbb7045ba3e8878448088f05d0e4fdc904 Mon Sep 17 00:00:00 2001 From: Jordan Date: Sat, 23 Mar 2024 10:44:50 -0700 Subject: [PATCH] frame tests complete successfully. --- src/CMakeLists.txt | 3 +-- src/extlib/openMVG | 2 +- src/frame.cxx | 11 ++++++++--- src/frame.h | 14 ++++++++++---- src/tests/test_frame.cxx | 6 +++--- 5 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c65a8c0..d587440 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -62,6 +62,7 @@ add_library(${LIBDART_OPENMVG} SHARED "frame.cxx" "streamingview.cxx" "image.cxx" + "util.cpp" ) set(CEREAL_INCLUDE_DIR ${OpenMVG_DIR}/../../../include/openMVG_dependencies/cereal/include/cereal/) @@ -100,13 +101,11 @@ target_link_options(${LIBDART_OPENMVG} PRIVATE "-Wl,-Bdynamic") add_executable( test_image ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_image.cxx - ${CMAKE_CURRENT_SOURCE_DIR}/util.cpp ) add_executable( test_frame ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_frame.cxx - ${CMAKE_CURRENT_SOURCE_DIR}/util.cpp ) target_link_libraries( diff --git a/src/extlib/openMVG b/src/extlib/openMVG index 7fd19fc..aff37dd 160000 --- a/src/extlib/openMVG +++ b/src/extlib/openMVG @@ -1 +1 @@ -Subproject commit 7fd19fc22419a35481d39d2946f77e1dc00df37c +Subproject commit aff37dd005f85b3589aa50caca13b74ca7bd57e4 diff --git a/src/frame.cxx b/src/frame.cxx index cc82a3e..03525c9 100644 --- a/src/frame.cxx +++ b/src/frame.cxx @@ -77,6 +77,11 @@ void clean_frame(Frame *f) { #ifdef __cplusplus +DartOpenMvg::Frame::Frame(const DartOpenMvg::Frame &frame) { + cFrame = frame.cFrame; + mRegions = std::unique_ptr(frame.mRegions.get()); +} + openMVG::image::Image DartOpenMvg::imageFromFrame(const CFrame *frame) { rewind(frame->stream); @@ -112,10 +117,10 @@ void DartOpenMvg::Frames::computeMatches() // Within openMvg::matching_image_collection::Matcher // they matcha gainst *ALL* images. However, since we know the order of the // image sequences (video frames), we'll stick to the sequence order. - for (size_t i = 0; i < this->size() - 1; ++i) + for (size_t i = 0; i < mFrames.size() - 1; ++i) { - const Frame &frame1 = this->at(i); - const Frame &frame2 = this->at(i + 1); + const Frame &frame1 = mFrames[i]; + const Frame &frame2 = mFrames[i+1]; auto *regions1 = frame1.mRegions.get(); auto *regions2 = frame2.mRegions.get(); diff --git a/src/frame.h b/src/frame.h index c878670..1648a64 100644 --- a/src/frame.h +++ b/src/frame.h @@ -80,6 +80,7 @@ namespace DartOpenMvg read_buffer(f->stream, &buffer_data, &len); mStream = std::stringstream(std::string((char *)buffer_data)); } + Frame(const Frame &); openMVG::image::Image getMvgImage(); void calculateFeatures(); }; @@ -87,7 +88,7 @@ namespace DartOpenMvg typedef std::pair FrameMatchKey; typedef std::map, openMVG::matching::IndMatches> FrameFeatureMatch; - class Frames : protected std::vector + class Frames { protected: @@ -95,13 +96,18 @@ namespace DartOpenMvg openMVG::tracks::STLMAPTracks mTracks; openMVG::sfm::SfM_Data mSfmData; openMVG::sfm::Bundle_Adjustment_Ceres mAdjustment; + public: + + // TODO: make private with accessors + std::vector mFrames; + Frames(openMVG::sfm::Bundle_Adjustment_Ceres::BA_Ceres_options &); void computeMatches(); void buildTracks(); - void adjust (); - void resection (); - void resectionAll (); + void adjust(); + void resection(); + void resectionAll(); }; } #endif diff --git a/src/tests/test_frame.cxx b/src/tests/test_frame.cxx index 2c50cca..3874a92 100644 --- a/src/tests/test_frame.cxx +++ b/src/tests/test_frame.cxx @@ -71,11 +71,11 @@ void test_calculate_fetures(void) { void test_compute_matches(void) { Frame *f1 = get_first_frame(); Frame *f2 = get_second_frame(); - DartOpenMvg::Frame frame1(f1), frame2(f2); + const DartOpenMvg::Frame frame1(f1), frame2(f2); openMVG::sfm::Bundle_Adjustment_Ceres::BA_Ceres_options opts; DartOpenMvg::Frames frames(opts); - frames.insert(frame1); - frames.insert(frame2); + frames.mFrames.push_back(frame1); + frames.mFrames.push_back(frame2); } int main()