From 3641d52b57c611f9eb695511ce965ab2c4cd059e Mon Sep 17 00:00:00 2001 From: Matthieu Hog Date: Thu, 16 Nov 2023 11:58:18 +0100 Subject: [PATCH] added unknown image detector/descriptor type --- src/aliceVision/feature/ImageDescriber.cpp | 4 + src/aliceVision/feature/ImageDescriber.hpp | 120 ++++++++++++++++++ .../feature/imageDescriberCommon.hpp | 5 +- src/aliceVision/feature/regionsFactory.hpp | 3 + src/aliceVision/sfm/pipeline/regionsIO.cpp | 4 +- src/aliceVision/voctree/VocabularyTree.hpp | 3 + 6 files changed, 134 insertions(+), 5 deletions(-) diff --git a/src/aliceVision/feature/ImageDescriber.cpp b/src/aliceVision/feature/ImageDescriber.cpp index 883818d9bf..69237314d5 100644 --- a/src/aliceVision/feature/ImageDescriber.cpp +++ b/src/aliceVision/feature/ImageDescriber.cpp @@ -228,6 +228,10 @@ std::unique_ptr createImageDescriber(EImageDescriberType imageDe case EImageDescriberType::AKAZE_LIOP: describerPtr.reset(new ImageDescriber_AKAZE(AKAZEParams(AKAZEOptions(), feature::AKAZE_LIOP))); break; + //Unknown descriptor to be used when the descriptor computed outside of alicevsion + case EImageDescriberType::UNKNOWN: + describerPtr.reset(new UnknownImageDescriber()); + break; #if ALICEVISION_IS_DEFINED(ALICEVISION_HAVE_CCTAG) case EImageDescriberType::CCTAG3: diff --git a/src/aliceVision/feature/ImageDescriber.hpp b/src/aliceVision/feature/ImageDescriber.hpp index 2bb84a3f4f..38703d1bf0 100644 --- a/src/aliceVision/feature/ImageDescriber.hpp +++ b/src/aliceVision/feature/ImageDescriber.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -260,6 +261,125 @@ class ImageDescriber void LoadFeatures(Regions* regions, const std::string& sfileNameFeats) const { regions->LoadFeatures(sfileNameFeats); } }; +/** + * @brief Used to load descripters computed outside of meshroom. + */ +class UnknownImageDescriber : public ImageDescriber +{ + public: + UnknownImageDescriber() = default; + + virtual ~UnknownImageDescriber() = default; + + /** + * @brief Check if the image describer use CUDA + * @return True if the image describer use CUDA + */ + bool useCuda() const override { return false; } + + /** + * @brief Check if the image describer use float image + * @return True if the image describer use float image + */ + bool useFloatImage() const override { return false; } + + /** + * @brief Get the corresponding EImageDescriberType + * @return EImageDescriberType + */ + EImageDescriberType getDescriberType() const override { return EImageDescriberType::UNKNOWN; } + + /** + * @brief Get the total amount of RAM needed for a + * feature extraction of an image of the given dimension. + * @param[in] width The image width + * @param[in] height The image height + * @return total amount of memory needed + */ + std::size_t getMemoryConsumption(std::size_t width, std::size_t height) const override + { + std::cout<<"Bonjour 0"<& image, + std::unique_ptr& regions, + const image::Image* mask = nullptr) override + { + std::cout<<"Bonjour 5"<& image, std::unique_ptr& regions, const image::Image* mask = nullptr) override + { + std::cout<<"Bonjour 6"<& regions) const override + { + std::cout<<"Bonjour 7"< _imageDescriberImpl = nullptr; +}; + /** * @brief Create the desired ImageDescriber method. * Don't use a factory, perform direct allocation. diff --git a/src/aliceVision/feature/imageDescriberCommon.hpp b/src/aliceVision/feature/imageDescriberCommon.hpp index 937a3f28a8..678d81cf02 100644 --- a/src/aliceVision/feature/imageDescriberCommon.hpp +++ b/src/aliceVision/feature/imageDescriberCommon.hpp @@ -23,9 +23,8 @@ enum class EImageDescriberType : unsigned char SIFT = 10, SIFT_FLOAT = 11, SIFT_UPRIGHT = 12, - DSPSIFT = 13 - - , + DSPSIFT = 13, + AKAZE = 20, AKAZE_LIOP = 21, AKAZE_MLDB = 22 diff --git a/src/aliceVision/feature/regionsFactory.hpp b/src/aliceVision/feature/regionsFactory.hpp index 58e98a392c..72a928a1f7 100644 --- a/src/aliceVision/feature/regionsFactory.hpp +++ b/src/aliceVision/feature/regionsFactory.hpp @@ -29,5 +29,8 @@ using AKAZE_Liop_Regions = ScalarRegions; /// Define the AKAZE Keypoint (with a binary descriptor saved in an uchar array) using AKAZE_BinaryRegions = BinaryRegions<64>; +/// Define an unknown feature regions +using UNKNOWN_Regions = ScalarRegions; + } // namespace feature } // namespace aliceVision diff --git a/src/aliceVision/sfm/pipeline/regionsIO.cpp b/src/aliceVision/sfm/pipeline/regionsIO.cpp index 19e5555f5c..9d3c4f227e 100644 --- a/src/aliceVision/sfm/pipeline/regionsIO.cpp +++ b/src/aliceVision/sfm/pipeline/regionsIO.cpp @@ -26,7 +26,7 @@ using namespace sfmData; std::unique_ptr loadRegions(const std::vector& folders, IndexT viewId, const feature::ImageDescriber& imageDescriber) { assert(!folders.empty()); - + const std::string imageDescriberTypeName = feature::EImageDescriberType_enumToString(imageDescriber.getDescriberType()); const std::string basename = std::to_string(viewId); @@ -228,7 +228,7 @@ bool loadRegionsPerView(feature::RegionsPerView& regionsPerView, std::unique_ptr regionsPtr; try { - regionsPtr = loadRegions(featuresFolders, iter->second.get()->getViewId(), *(imageDescribers.at(i))); + regionsPtr = loadRegions(featuresFolders, iter->second.get()->getViewId(), *(imageDescribers.at(i))); } catch (const std::exception& e) { diff --git a/src/aliceVision/voctree/VocabularyTree.hpp b/src/aliceVision/voctree/VocabularyTree.hpp index 96abbc0904..7c973e326d 100644 --- a/src/aliceVision/voctree/VocabularyTree.hpp +++ b/src/aliceVision/voctree/VocabularyTree.hpp @@ -360,6 +360,9 @@ inline std::unique_ptr createVoctreeForDescriberType(feature::E case EImageDescriberType::AKAZE_MLDB: res.reset(new VocabularyTree); break; + case EImageDescriberType::UNKNOWN: + res.reset(new VocabularyTree); + break; #if ALICEVISION_IS_DEFINED(ALICEVISION_HAVE_CCTAG) case EImageDescriberType::CCTAG3: