AliceVision
Photogrammetric Computer Vision Framework
ImageDescriber_SIFT_OCV.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/imageDescriberCommon.hpp>
11 #include <aliceVision/feature/ImageDescriber.hpp>
12 #include <aliceVision/feature/regionsFactory.hpp>
13 
14 namespace aliceVision {
15 
16 namespace image {
17 
18 template<typename T>
19 class Image;
20 
21 } // namespace image
22 
23 namespace feature {
24 
26 {
27  public:
34 
36  std::size_t gridSize = 4;
37  std::size_t maxTotalKeypoints = 1000;
38  int nOctaveLayers = 6; //< default opencv value is 3
39  double contrastThreshold = 0.04; //< default opencv value is 0.04
40  double edgeThreshold = 10;
41  double sigma = 1.6;
42  // bool rootSift = true;
43 };
44 
50 {
51  public:
56  bool useCuda() const override { return false; }
57 
62  bool useFloatImage() const override { return false; }
63 
68  EImageDescriberType getDescriberType() const override { return EImageDescriberType::SIFT_OCV; }
69 
77  std::size_t getMemoryConsumption(std::size_t width, std::size_t height) const override
78  {
79  return 3 * width * height * sizeof(unsigned char) + (_params.maxTotalKeypoints * 128 * sizeof(unsigned char));
80  }
81 
87  void setConfigurationPreset(ConfigurationPreset preset) override { _params.setConfigurationPreset(preset); }
88 
97  bool describe(const image::Image<unsigned char>& image,
98  std::unique_ptr<Regions>& regions,
99  const image::Image<unsigned char>* mask = NULL) override;
100 
105  void allocate(std::unique_ptr<Regions>& regions) const override { regions.reset(new SIFT_Regions); }
106 
107  private:
108  SIFT_openCV_Params _params;
109 };
110 
111 } // namespace feature
112 } // namespace aliceVision
aliceVision::feature::ImageDescriber_SIFT_openCV::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_OCV.hpp:77
aliceVision::feature::ImageDescriber_SIFT_openCV
Create an ImageDescriber interface for OpenCV SIFT feature extractor Regions is the same as classic S...
Definition: ImageDescriber_SIFT_OCV.hpp:49
aliceVision::feature::ImageDescriber_SIFT_openCV::useCuda
bool useCuda() const override
Check if the image describer use CUDA.
Definition: ImageDescriber_SIFT_OCV.hpp:56
aliceVision
Definition: checkerDetector.cpp:32
aliceVision::feature::ImageDescriber
A pure virtual class for image description computation.
Definition: ImageDescriber.hpp:159
aliceVision::feature::ImageDescriber_SIFT_openCV::setConfigurationPreset
void setConfigurationPreset(ConfigurationPreset preset) override
Use a preset to control the number of detected regions.
Definition: ImageDescriber_SIFT_OCV.hpp:87
aliceVision::image::Image< unsigned char >
aliceVision::feature::SIFT_openCV_Params::setConfigurationPreset
void setConfigurationPreset(ConfigurationPreset preset)
Use a preset to control the number of detected regions.
Definition: ImageDescriber_SIFT_OCV.cpp:21
aliceVision::feature::SIFT_openCV_Params::gridSize
std::size_t gridSize
Parameters.
Definition: ImageDescriber_SIFT_OCV.hpp:36
aliceVision::feature::FeatDescRegions
Definition: Regions.hpp:144
aliceVision::feature::ImageDescriber_SIFT_openCV::getDescriberType
EImageDescriberType getDescriberType() const override
Get the corresponding EImageDescriberType.
Definition: ImageDescriber_SIFT_OCV.hpp:68
aliceVision::feature::ImageDescriber_SIFT_openCV::useFloatImage
bool useFloatImage() const override
Check if the image describer use float image.
Definition: ImageDescriber_SIFT_OCV.hpp:62
aliceVision::feature::ImageDescriber_SIFT_openCV::describe
bool describe(const image::Image< unsigned char > &image, std::unique_ptr< Regions > &regions, const image::Image< unsigned char > *mask=NULL) override
Detect regions on the 8-bit image and compute their attributes (description)
Definition: ImageDescriber_SIFT_OCV.cpp:53
aliceVision::feature::ConfigurationPreset
Definition: ImageDescriber.hpp:118
aliceVision::feature::SIFT_openCV_Params
Definition: ImageDescriber_SIFT_OCV.hpp:25
aliceVision::feature::ImageDescriber_SIFT_openCV::allocate
void allocate(std::unique_ptr< Regions > &regions) const override
Allocate Regions type depending of the ImageDescriber.
Definition: ImageDescriber_SIFT_OCV.hpp:105