Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "Generic" Feature Type #1598

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions src/aliceVision/feature/ImageDescriber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,10 @@ std::unique_ptr<ImageDescriber> createImageDescriber(EImageDescriberType imageDe
case EImageDescriberType::AKAZE_LIOP:
describerPtr.reset(new ImageDescriber_AKAZE(AKAZEParams(AKAZEOptions(), feature::AKAZE_LIOP)));
break;
//Generic descriptor to be used when the descriptor is computed outside of alicevsion
case EImageDescriberType::GENERIC:
describerPtr.reset(new GenericImageDescriber());
break;

#if ALICEVISION_IS_DEFINED(ALICEVISION_HAVE_CCTAG)
case EImageDescriberType::CCTAG3:
Expand Down
110 changes: 110 additions & 0 deletions src/aliceVision/feature/ImageDescriber.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <aliceVision/numeric/numeric.hpp>
#include <aliceVision/feature/imageDescriberCommon.hpp>
#include <aliceVision/feature/Regions.hpp>
#include <aliceVision/feature/regionsFactory.hpp>
#include <aliceVision/image/Image.hpp>
#include <memory>

Expand Down Expand Up @@ -260,6 +261,115 @@ class ImageDescriber
void LoadFeatures(Regions* regions, const std::string& sfileNameFeats) const { regions->LoadFeatures(sfileNameFeats); }
};

/**
* @brief Used to load descripters computed outside of meshroom.
*/
class GenericImageDescriber : public ImageDescriber
{
public:
GenericImageDescriber() = default;

virtual ~GenericImageDescriber() = 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::GENERIC; }

/**
* @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
{
return 0;
}

/**
* @brief Set image describer always upRight
* @param[in] upRight
*/
void setUpRight(bool upRight) override
{}

/**
* @brief Set if yes or no imageDescriber need to use cuda implementation
* @param[in] useCuda
*/
void setUseCuda(bool useCuda) override
{}

/**
* @brief set the CUDA pipe
* @param[in] pipe The CUDA pipe id
*/
void setCudaPipe(int pipe) override
{}

/**
* @brief Use a preset to control the number of detected regions
* @param[in] preset The preset configuration
*/
void setConfigurationPreset(ConfigurationPreset preset) override
{}

/**
* @brief Detect regions on the 8-bit image and compute their attributes (description)
* @param[in] image Image.
* @param[out] regions The detected regions and attributes (the caller must delete the allocated data)
* @param[in] mask 8-bit grayscale image for keypoint filtering (optional)
* Non-zero values depict the region of interest.
* @return True if detection succed.
*/
bool describe(const image::Image<unsigned char>& image,
std::unique_ptr<Regions>& regions,
const image::Image<unsigned char>* mask = nullptr) override
{
return false;
}

/**
* @brief Detect regions on the float image and compute their attributes (description)
* @param[in] image Image.
* @param[out] regions The detected regions and attributes (the caller must delete the allocated data)
* @param[in] mask 8-bit gray image for keypoint filtering (optional).
* Non-zero values depict the region of interest.
* @return True if detection succed.
*/
bool describe(const image::Image<float>& image, std::unique_ptr<Regions>& regions, const image::Image<unsigned char>* mask = nullptr) override
{
return false;
}

/**
* @brief Allocate Regions type depending of the ImageDescriber
* @param[in,out] regions
*/
void allocate(std::unique_ptr<Regions>& regions) const override
{
regions.reset(new GENERIC_Regions);
}

private:
std::unique_ptr<ImageDescriber> _imageDescriberImpl = nullptr;
};

/**
* @brief Create the desired ImageDescriber method.
* Don't use a factory, perform direct allocation.
Expand Down
5 changes: 5 additions & 0 deletions src/aliceVision/feature/imageDescriberCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ std::string EImageDescriberType_enumToString(EImageDescriberType imageDescriberT
return "akaze_liop";
case EImageDescriberType::AKAZE_MLDB:
return "akaze_mldb";
case EImageDescriberType::GENERIC:
return "generic";

#if ALICEVISION_IS_DEFINED(ALICEVISION_HAVE_CCTAG)
case EImageDescriberType::CCTAG3:
Expand Down Expand Up @@ -113,6 +115,9 @@ EImageDescriberType EImageDescriberType_stringToEnum(const std::string& imageDes
if (type == "akaze_mldb")
return EImageDescriberType::AKAZE_MLDB;

if (type == "generic")
return EImageDescriberType::GENERIC;

#if ALICEVISION_IS_DEFINED(ALICEVISION_HAVE_CCTAG)
if (type == "cctag3")
return EImageDescriberType::CCTAG3;
Expand Down
23 changes: 10 additions & 13 deletions src/aliceVision/feature/imageDescriberCommon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,29 @@ 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

#if ALICEVISION_IS_DEFINED(ALICEVISION_HAVE_CCTAG)
,
CCTAG3 = 30,
CCTAG4 = 31
, CCTAG3 = 30
, CCTAG4 = 31
#endif

#if ALICEVISION_IS_DEFINED(ALICEVISION_HAVE_OPENCV)
#if ALICEVISION_IS_DEFINED(ALICEVISION_HAVE_OCVSIFT)
,
SIFT_OCV = 40
, SIFT_OCV = 40
#endif
,
AKAZE_OCV = 41
, AKAZE_OCV = 41
#endif

#if ALICEVISION_IS_DEFINED(ALICEVISION_HAVE_APRILTAG)
,
APRILTAG16H5 = 50
, APRILTAG16H5 = 50
#endif

, GENERIC = 100
};

/**
Expand Down Expand Up @@ -111,8 +108,8 @@ inline float getStrongSupportCoeff(EImageDescriberType imageDescriberType)
case EImageDescriberType::AKAZE:
case EImageDescriberType::AKAZE_LIOP:
case EImageDescriberType::AKAZE_MLDB:
case EImageDescriberType::GENERIC:
return 0.14f;

#if ALICEVISION_IS_DEFINED(ALICEVISION_HAVE_CCTAG)
case EImageDescriberType::CCTAG3:
case EImageDescriberType::CCTAG4:
Expand Down
3 changes: 3 additions & 0 deletions src/aliceVision/feature/regionsFactory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,8 @@ using AKAZE_Liop_Regions = ScalarRegions<unsigned char, 144>;
/// Define the AKAZE Keypoint (with a binary descriptor saved in an uchar array)
using AKAZE_BinaryRegions = BinaryRegions<64>;

/// Define an unknown feature regions
using GENERIC_Regions = ScalarRegions<float, 128>;

} // namespace feature
} // namespace aliceVision
4 changes: 4 additions & 0 deletions src/aliceVision/matching/svgVisualization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ std::string describerTypeColor(feature::EImageDescriberType descType)
return "purple";
case feature::EImageDescriberType::AKAZE_MLDB:
return "purple";

case feature::EImageDescriberType::GENERIC:
return "black";

#if ALICEVISION_IS_DEFINED(ALICEVISION_HAVE_CCTAG)
case feature::EImageDescriberType::CCTAG3:
return "blue";
Expand Down
3 changes: 3 additions & 0 deletions src/aliceVision/voctree/VocabularyTree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,9 @@ inline std::unique_ptr<IVocabularyTree> createVoctreeForDescriberType(feature::E
case EImageDescriberType::AKAZE_MLDB:
res.reset(new VocabularyTree<AKAZE_BinaryRegions::DescriptorT>);
break;
case EImageDescriberType::GENERIC:
res.reset(new VocabularyTree<GENERIC_Regions::DescriptorT>);
break;

#if ALICEVISION_IS_DEFINED(ALICEVISION_HAVE_CCTAG)
case EImageDescriberType::CCTAG3:
Expand Down
Loading