AliceVision
Photogrammetric Computer Vision Framework
ImageDescriber_SIFT_popSIFT.hpp
1 // This file is part of the AliceVision project.
2 // Copyright (c) 2016 AliceVision contributors.
3 // Copyright (c) 2012 openMVG contributors.
4 // This Source Code Form is subject to the terms of the Mozilla Public License,
5 // v. 2.0. If a copy of the MPL was not distributed with this file,
6 // You can obtain one at https://mozilla.org/MPL/2.0/.
7 
8 #pragma once
9 
10 #include <aliceVision/feature/Descriptor.hpp>
11 #include <aliceVision/feature/ImageDescriber.hpp>
12 #include <aliceVision/feature/regionsFactory.hpp>
13 #include <aliceVision/feature/sift/SIFT.hpp>
14 
15 #include <iostream>
16 #include <numeric>
17 
18 class PopSift;
19 
20 namespace aliceVision {
21 namespace feature {
22 
27 {
28  public:
29  explicit ImageDescriber_SIFT_popSIFT(const SiftParams& params = SiftParams(), bool isOriented = true);
30 
35  bool useCuda() const override { return true; }
36 
41  bool useFloatImage() const override { return true; }
42 
47  EImageDescriberType getDescriberType() const override
48  {
49  if (!_isOriented)
50  return EImageDescriberType::SIFT_UPRIGHT;
51  return EImageDescriberType::SIFT;
52  }
53 
61  std::size_t getMemoryConsumption(std::size_t width, std::size_t height) const override
62  {
63  // GPU only
64  return 4 * width * height * sizeof(float); // only use the input RGBA image
65  }
66 
71  void setUpRight(bool upRight) override { _isOriented = !upRight; }
72 
77  void setConfigurationPreset(ConfigurationPreset preset) override;
78 
87  bool describe(const image::Image<float>& image, std::unique_ptr<Regions>& regions, const image::Image<unsigned char>* mask = nullptr) override;
88 
93  void allocate(std::unique_ptr<Regions>& regions) const override { regions.reset(new SIFT_Regions); }
94 
99 
100  private:
101  void resetConfiguration();
102 
103  SiftParams _params;
104  bool _isOriented = true;
105  static std::unique_ptr<PopSift> _popSift;
106  static std::atomic<int> _instanceCounter;
107 };
108 
109 } // namespace feature
110 } // namespace aliceVision
aliceVision::feature::ImageDescriber_SIFT_popSIFT
Create an ImageDescriber interface for PopSIFT SIFT feature extractor.
Definition: ImageDescriber_SIFT_popSIFT.hpp:26
aliceVision::feature::SiftParams
Definition: SIFT.hpp:35
aliceVision::feature::ImageDescriber_SIFT_popSIFT::setUpRight
void setUpRight(bool upRight) override
Set image describer always upRight.
Definition: ImageDescriber_SIFT_popSIFT.hpp:71
aliceVision::feature::ImageDescriber_SIFT_popSIFT::useCuda
bool useCuda() const override
Check if the image describer use CUDA.
Definition: ImageDescriber_SIFT_popSIFT.hpp:35
aliceVision::feature::ImageDescriber_SIFT_popSIFT::getMemoryConsumption
std::size_t getMemoryConsumption(std::size_t width, std::size_t height) const override
Get the total amount of RAM needed for a feature extraction of an image of the given dimension.
Definition: ImageDescriber_SIFT_popSIFT.hpp:61
aliceVision::feature::ImageDescriber_SIFT_popSIFT::~ImageDescriber_SIFT_popSIFT
~ImageDescriber_SIFT_popSIFT() override
Destructor.
Definition: ImageDescriber_SIFT_popSIFT.cpp:105
aliceVision
Definition: checkerDetector.cpp:32
aliceVision::feature::ImageDescriber
A pure virtual class for image description computation.
Definition: ImageDescriber.hpp:159
aliceVision::feature::ImageDescriber_SIFT_popSIFT::setConfigurationPreset
void setConfigurationPreset(ConfigurationPreset preset) override
Use a preset to control the number of detected regions.
Definition: ImageDescriber_SIFT_popSIFT.cpp:25
aliceVision::feature::ImageDescriber_SIFT_popSIFT::allocate
void allocate(std::unique_ptr< Regions > &regions) const override
Allocate Regions type depending of the ImageDescriber.
Definition: ImageDescriber_SIFT_popSIFT.hpp:93
aliceVision::image::Image< float >
aliceVision::feature::ImageDescriber_SIFT_popSIFT::useFloatImage
bool useFloatImage() const override
Check if the image describer use float image.
Definition: ImageDescriber_SIFT_popSIFT.hpp:41
aliceVision::feature::ImageDescriber_SIFT_popSIFT::getDescriberType
EImageDescriberType getDescriberType() const override
Get the corresponding EImageDescriberType.
Definition: ImageDescriber_SIFT_popSIFT.hpp:47
aliceVision::feature::FeatDescRegions
Definition: Regions.hpp:144
aliceVision::feature::ImageDescriber_SIFT_popSIFT::describe
bool describe(const image::Image< float > &image, std::unique_ptr< Regions > &regions, const image::Image< unsigned char > *mask=nullptr) override
Detect regions on the 8-bit image and compute their attributes (description)
Definition: ImageDescriber_SIFT_popSIFT.cpp:31
aliceVision::feature::ConfigurationPreset
Definition: ImageDescriber.hpp:118