Compute Library
 21.02
NEFastCorners Class Reference

Basic function to execute fast corners. More...

#include <NEFastCorners.h>

Collaboration diagram for NEFastCorners:
[legend]

Public Member Functions

 NEFastCorners (std::shared_ptr< IMemoryManager > memory_manager=nullptr)
 Constructor. More...
 
 NEFastCorners (const NEFastCorners &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
NEFastCornersoperator= (const NEFastCorners &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 NEFastCorners (NEFastCorners &&)=delete
 Prevent instances of this class from being moved (As this class contains non movable objects) More...
 
NEFastCornersoperator= (NEFastCorners &&)=delete
 Prevent instances of this class from being moved (As this class contains non movable objects) More...
 
 ~NEFastCorners ()
 Default destructor. More...
 
void configure (IImage *input, float threshold, bool nonmax_suppression, KeyPointArray *corners, BorderMode border_mode, uint8_t constant_border_value=0)
 Initialize the function's source, destination, conv and border_mode. More...
 
void run () override
 Run the kernels contained in the function. 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 fast corners.

This function call the following Neon kernels:

  1. NEFastCornersKernel
  2. NENonMaximaSuppression3x3Kernel (executed if nonmax_suppression == true)
  3. NEFillArrayKernel
Deprecated:
This function is deprecated and is intended to be removed in 21.05 release

Definition at line 55 of file NEFastCorners.h.

Constructor & Destructor Documentation

◆ NEFastCorners() [1/3]

NEFastCorners ( std::shared_ptr< IMemoryManager memory_manager = nullptr)

Constructor.

Definition at line 43 of file NEFastCorners.cpp.

44  : _memory_group(std::move(memory_manager)),
45  _fast_corners_kernel(),
46  _border_handler(),
47  _nonmax_kernel(),
48  _fill_kernel(),
49  _output(),
50  _suppressed(),
51  _non_max(false)
52 {
53 }

◆ NEFastCorners() [2/3]

NEFastCorners ( const NEFastCorners )
delete

Prevent instances of this class from being copied (As this class contains pointers)

◆ NEFastCorners() [3/3]

NEFastCorners ( NEFastCorners &&  )
delete

Prevent instances of this class from being moved (As this class contains non movable objects)

◆ ~NEFastCorners()

~NEFastCorners ( )
default

Default destructor.

Member Function Documentation

◆ configure()

void configure ( IImage input,
float  threshold,
bool  nonmax_suppression,
KeyPointArray corners,
BorderMode  border_mode,
uint8_t  constant_border_value = 0 
)

Initialize the function's source, destination, conv and border_mode.

Parameters
[in,out]inputSource image. Data type supported: U8. (Written to only for border_mode != UNDEFINED)
[in]thresholdThreshold on difference between intensity of the central pixel and pixels on Bresenham's circle of radius 3.
[in]nonmax_suppressionIf true, non-maximum suppression is applied to detected corners before being placed in the array.
[out]cornersArray of keypoints to store the results.
[in]border_modeStrategy to use for borders.
[in]constant_border_value(Optional) Constant value to use for borders if border_mode is set to CONSTANT.

Definition at line 55 of file NEFastCorners.cpp.

References TensorAllocator::allocate(), Tensor::allocator(), ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN, ARM_COMPUTE_ERROR_ON_TENSOR_NOT_2D, ITensor::info(), TensorAllocator::init(), MemoryGroup::manage(), ITensorInfo::tensor_shape(), arm_compute::U8, and arm_compute::UNDEFINED.

57 {
61  ARM_COMPUTE_ERROR_ON(nullptr == corners);
62  ARM_COMPUTE_ERROR_ON(threshold < 1 && threshold > 255);
63 
64  _non_max = nonmax_suppression;
65 
66  TensorInfo tensor_info(input->info()->tensor_shape(), Format::U8);
67  _output.allocator()->init(tensor_info);
68  _memory_group.manage(&_output);
69 
70  _fast_corners_kernel = std::make_unique<NEFastCornersKernel>();
71  _border_handler = std::make_unique<NEFillBorderKernel>();
72  _fill_kernel = std::make_unique<NEFillArrayKernel>();
73  // If border is UNDEFINED _fast_corners_kernel will operate in xwindow (3,
74  // width - 3) and ywindow (3, height -3) so the output image will leave the
75  // pixels on the borders unchanged. This is reflected in the valid region
76  // of the output. The non maxima suppression is only run on the valid
77  // pixels.
78  _fast_corners_kernel->configure(input, &_output, threshold, nonmax_suppression, BorderMode::UNDEFINED == border_mode);
79  _border_handler->configure(input, _fast_corners_kernel->border_size(), border_mode, constant_border_value);
80 
81  if(!_non_max)
82  {
83  _fill_kernel->configure(&_output, 1 /* we keep all texels >0 */, corners);
84  }
85  else
86  {
87  _suppressed.allocator()->init(tensor_info);
88  _memory_group.manage(&_suppressed);
89  _nonmax_kernel = std::make_unique<NENonMaximaSuppression3x3Kernel>();
90  _nonmax_kernel->configure(&_output, &_suppressed, BorderMode::UNDEFINED == border_mode);
91  _fill_kernel->configure(&_suppressed, 1 /* we keep all texels >0 */, corners);
92 
93  // Allocate intermediate tensors
94  _suppressed.allocator()->allocate();
95  }
96 
97  // Allocate intermediate tensors
98  _output.allocator()->allocate();
99 }
void init(const TensorAllocator &allocator, const Coordinates &coords, TensorInfo &sub_info)
Shares the same backing memory with another tensor allocator, while the tensor info might be differen...
#define ARM_COMPUTE_ERROR_ON_TENSOR_NOT_2D(t)
Definition: Validate.h:856
1 channel, 1 U8 per channel
#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
TensorAllocator * allocator()
Return a pointer to the tensor&#39;s allocator.
Definition: Tensor.cpp:48
void manage(IMemoryManageable *obj) override
Sets a object to be managed by the given memory group.
Definition: MemoryGroup.h:79
void allocate() override
Allocate size specified by TensorInfo of CPU memory.
#define ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
Definition: Validate.h:790
Borders are left undefined.
SimpleTensor< T > threshold(const SimpleTensor< T > &src, T threshold, T false_value, T true_value, ThresholdType type, T upper)
Definition: Threshold.cpp:35

◆ operator=() [1/2]

NEFastCorners& operator= ( const NEFastCorners )
delete

Prevent instances of this class from being copied (As this class contains pointers)

◆ operator=() [2/2]

NEFastCorners& operator= ( NEFastCorners &&  )
delete

Prevent instances of this class from being moved (As this class contains non movable objects)

◆ run()

void run ( )
overridevirtual

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.
Note
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.
Note
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 101 of file NEFastCorners.cpp.

References Window::DimY, Window::DimZ, Scheduler::get(), and IScheduler::schedule().

102 {
103  NEScheduler::get().schedule(_border_handler.get(), Window::DimZ);
104 
105  MemoryGroupResourceScope scope_mg(_memory_group);
106 
107  NEScheduler::get().schedule(_fast_corners_kernel.get(), Window::DimY);
108 
109  if(_non_max)
110  {
111  NEScheduler::get().schedule(_nonmax_kernel.get(), Window::DimY);
112  }
113 
114  NEScheduler::get().schedule(_fill_kernel.get(), Window::DimY);
115 }
static constexpr size_t DimY
Alias for dimension 1 also known as Y dimension.
Definition: Window.h:45
virtual void schedule(ICPPKernel *kernel, const Hints &hints)=0
Runs the kernel in the same thread as the caller synchronously.
static constexpr size_t DimZ
Alias for dimension 2 also known as Z dimension.
Definition: Window.h:47
static IScheduler & get()
Access the scheduler singleton.
Definition: Scheduler.cpp:94

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