Compute Library
CLGaussianPyramidOrb Class Reference

Basic function to execute gaussian pyramid with ORB scale factor. More...

#include <CLGaussianPyramid.h>

Collaboration diagram for CLGaussianPyramidOrb:

Public Member Functions

 CLGaussianPyramidOrb ()
 Constructor. More...
void configure (ICLTensor *input, CLPyramid *pyramid, BorderMode border_mode, uint8_t constant_border_value) override
 Initialise the function's source, destinations and border mode. More...
void run () override
 Run the kernels contained in the function. More...
- Public Member Functions inherited from CLGaussianPyramid
 CLGaussianPyramid ()
 Constructor. More...
 CLGaussianPyramid (const CLGaussianPyramid &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
CLGaussianPyramidoperator= (const CLGaussianPyramid &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 CLGaussianPyramid (CLGaussianPyramid &&)=default
 Allow instances of this class to be moved. More...
CLGaussianPyramidoperator= (CLGaussianPyramid &&)=default
 Allow instances of this class to be moved. More...
virtual ~CLGaussianPyramid ()=default
 Default destructor. More...
- Public Member Functions inherited from IFunction
virtual ~IFunction ()=default
 Destructor. More...
virtual void prepare ()
 Prepare the function for executing. More...

Detailed Description

Basic function to execute gaussian pyramid with ORB scale factor.

This function calls the following OpenCL kernels and functions:

  1. CLFillBorderKernel (executed if border_mode == CONSTANT or border_mode == REPLICATE)
  2. CLGaussian5x5
  3. CLScaleKernel

Definition at line 104 of file CLGaussianPyramid.h.

Constructor & Destructor Documentation

◆ CLGaussianPyramidOrb()


Definition at line 133 of file CLGaussianPyramid.cpp.

134  : _gauss5x5(),
135  _scale_nearest()
136 {
137 }

Member Function Documentation

◆ configure()

void configure ( ICLTensor input,
CLPyramid pyramid,
BorderMode  border_mode,
uint8_t  constant_border_value 

Initialise the function's source, destinations and border mode.

[in,out]inputSource tensor. Data types supported: U8. (Written to only for border_mode != UNDEFINED)
[out]pyramidDestination pyramid tensors, Data types supported at each level: U8.
[in]border_modeBorder mode to use.
[in]constant_border_value(Optional) Constant value to use for borders if border_mode is set to CONSTANT.

Implements CLGaussianPyramid.

Definition at line 139 of file CLGaussianPyramid.cpp.

140 {
142  ARM_COMPUTE_ERROR_ON(nullptr == pyramid);
143  ARM_COMPUTE_ERROR_ON(input->info()->num_dimensions() != pyramid->get_pyramid_level(0)->info()->num_dimensions());
144  ARM_COMPUTE_ERROR_ON(input->info()->dimension(0) != pyramid->info()->width());
145  ARM_COMPUTE_ERROR_ON(input->info()->dimension(1) != pyramid->info()->height());
148  /* Get number of pyramid levels */
149  const size_t num_levels = pyramid->info()->num_levels();
151  _input = input;
152  _pyramid = pyramid;
154  if(num_levels > 1)
155  {
156  _gauss5x5.resize(num_levels - 1);
157  _scale_nearest.resize(num_levels - 1);
159  PyramidInfo pyramid_info(num_levels - 1, SCALE_PYRAMID_ORB, pyramid->info()->tensor_shape(), Format::U8);
161  _tmp.init(pyramid_info);
163  for(size_t i = 0; i < num_levels - 1; ++i)
164  {
165  /* Configure gaussian 5x5 */
166  _gauss5x5[i].configure(_pyramid->get_pyramid_level(i), _tmp.get_pyramid_level(i), border_mode, constant_border_value);
168  /* Configure scale image kernel */
169  _scale_nearest[i].configure(_tmp.get_pyramid_level(i), _pyramid->get_pyramid_level(i + 1), InterpolationPolicy::NEAREST_NEIGHBOR, border_mode, SamplingPolicy::CENTER);
170  }
172  _tmp.allocate();
173  }
174 }
constexpr float SCALE_PYRAMID_ORB
Constant value used to indicate a ORB scaled pyramid.
Definition: Types.h:111
const TensorShape & tensor_shape() const
Return the TensorShape of the o-th level tensor.
Definition: PyramidInfo.cpp:92
TensorInfo * info() const override
Interface to be implemented by the child class to return the tensor's metadata.
Definition: CLTensor.cpp:41
1 channel, 1 U8 per channel
const PyramidInfo * info() const override
Interface to be implemented by the child class to return the Pyramid's metadata.
Definition: CLPyramid.cpp:118
void init(size_t num_levels, float scale, size_t width, size_t height, Format format)
Initialize pyramid's metadata for 2D tensors.
Definition: PyramidInfo.cpp:50
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466
Output values are defined to match the source pixel whose center is nearest to the sample position.
Samples are taken at pixel center.
size_t num_dimensions() const override
The number of dimensions of the tensor (rank)
Definition: TensorInfo.h:253
float scale() const
Return the scale factor of the pyramid.
Definition: Validate.h:790
Store the Pyramid's metadata.
Definition: PyramidInfo.h:35
CLTensor * get_pyramid_level(size_t index) const override
Retrieves a level of the pyramid as a ITensor pointer.
Definition: CLPyramid.cpp:123
size_t width() const
Return the width of the 0th level tensor.
Definition: PyramidInfo.cpp:82
size_t num_levels() const
Return the number of the pyramid levels.
Definition: PyramidInfo.cpp:77
size_t height() const
Return the height of the 0th level tensor.
Definition: PyramidInfo.cpp:87

References ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN, arm_compute::test::validation::border_mode, arm_compute::CENTER, CLPyramid::get_pyramid_level(), PyramidInfo::height(), CLPyramid::info(), CLTensor::info(), PyramidInfo::init(), arm_compute::test::validation::input, arm_compute::NEAREST_NEIGHBOR, TensorInfo::num_dimensions(), PyramidInfo::num_levels(), PyramidInfo::scale(), arm_compute::SCALE_PYRAMID_ORB, PyramidInfo::tensor_shape(), arm_compute::U8, and PyramidInfo::width().

◆ run()

void run ( )

Run the kernels contained in the function.

For NEON kernels:

  • Multi-threading is used for the kernels which are parallelisable.
  • By default std::thread::hardware_concurrency() threads are used.
CPPScheduler::set_num_threads() can be used to manually set the number of threads

For OpenCL kernels:

  • All the kernels are enqueued on the queue associated with CLScheduler.
  • The queue is then flushed.
The function will not block until the kernels are executed. It is the user's responsibility to wait.
Will call prepare() on first run if hasn't been done

Implements IFunction.

Definition at line 176 of file CLGaussianPyramid.cpp.

177 {
178  ARM_COMPUTE_ERROR_ON_MSG(_pyramid == nullptr, "Unconfigured function");
180  /* Get number of pyramid levels */
181  const size_t num_levels = _pyramid->info()->num_levels();
183  /* The first level of the pyramid has the input image */
184  _pyramid->get_pyramid_level(0)->map(CLScheduler::get().queue(), true /* blocking */);
185  _input->map(CLScheduler::get().queue(), true /* blocking */);
186  _pyramid->get_pyramid_level(0)->copy_from(*_input);
187  _input->unmap(CLScheduler::get().queue());
188  _pyramid->get_pyramid_level(0)->unmap(CLScheduler::get().queue());
190  for(unsigned int i = 0; i < num_levels - 1; ++i)
191  {
192  _gauss5x5[i].run();
193  CLScheduler::get().enqueue(_scale_nearest[i]);
194  }
195 }
static CLScheduler & get()
Access the scheduler singleton.
Definition: CLScheduler.cpp:99
#define ARM_COMPUTE_ERROR_ON_MSG(cond, msg)
Definition: Error.h:456
void enqueue(ICLKernel &kernel, bool flush=true)
Schedule the execution of the passed kernel if possible.

References ARM_COMPUTE_ERROR_ON_MSG, CLScheduler::enqueue(), and CLScheduler::get().

The documentation for this class was generated from the following files: