41 : _memory_group(
std::move(memory_manager)),
52 _non_maxima_suppression(false),
53 _num_orient_bin_kernel(0),
54 _num_block_norm_kernel(0),
55 _num_hog_detect_kernel(0)
64 configure(
CLKernelLibrary::get().get_compile_context(), input, multi_hog, detection_windows, detection_window_strides, border_mode, constant_border_value, threshold, non_maxima_suppression,
80 const size_t num_models = multi_hog->
num_models();
98 std::vector<size_t> input_orient_bin;
99 std::vector<size_t> input_hog_detect;
100 std::vector<std::pair<size_t, size_t>> input_block_norm;
102 input_orient_bin.push_back(0);
103 input_hog_detect.push_back(0);
104 input_block_norm.emplace_back(0, 0);
106 for(
size_t i = 1; i < num_models; ++i)
113 if((cur_num_bins != prev_num_bins) || (cur_cell_size.
width != prev_cell_size.
width) || (cur_cell_size.
height != prev_cell_size.
height))
115 prev_num_bins = cur_num_bins;
116 prev_cell_size = cur_cell_size;
117 prev_block_size = cur_block_size;
118 prev_block_stride = cur_block_stride;
121 input_orient_bin.push_back(i);
122 input_block_norm.emplace_back(i, input_orient_bin.size() - 1);
124 else if((cur_block_size.
width != prev_block_size.
width) || (cur_block_size.
height != prev_block_size.
height) || (cur_block_stride.
width != prev_block_stride.
width)
125 || (cur_block_stride.
height != prev_block_stride.
height))
127 prev_block_size = cur_block_size;
128 prev_block_stride = cur_block_stride;
131 input_block_norm.emplace_back(i, input_orient_bin.size() - 1);
135 input_hog_detect.push_back(input_block_norm.size() - 1);
138 _detection_windows = detection_windows;
140 _num_orient_bin_kernel = input_orient_bin.size();
141 _num_block_norm_kernel = input_block_norm.size();
142 _num_hog_detect_kernel = input_hog_detect.size();
144 _orient_bin_kernel.reserve(_num_orient_bin_kernel);
145 _block_norm_kernel.reserve(_num_block_norm_kernel);
146 _hog_detect_kernel.resize(_num_hog_detect_kernel);
147 _hog_space.resize(_num_orient_bin_kernel);
148 _hog_norm_space.resize(_num_block_norm_kernel);
158 _memory_group.
manage(&_mag);
159 _memory_group.
manage(&_phase);
162 _gradient_kernel.
configure(compile_context, input, &_mag, &_phase, phase_type, border_mode, constant_border_value);
165 for(
size_t i = 0; i < _num_orient_bin_kernel; ++i)
167 const size_t idx_multi_hog = input_orient_bin[i];
174 const size_t num_cells_x = width / cell.
width;
175 const size_t num_cells_y = height / cell.
height;
184 _hog_space[i].allocator()->init(info_space);
187 _memory_group.
manage(&_hog_space[i]);
190 _orient_bin_kernel.emplace_back(std::make_unique<CLHOGOrientationBinningKernel>());
191 _orient_bin_kernel.back()->configure(compile_context, &_mag, &_phase, &_hog_space[i], multi_hog->
model(idx_multi_hog)->
info());
199 for(
size_t i = 0; i < _num_block_norm_kernel; ++i)
201 const size_t idx_multi_hog = input_block_norm[i].first;
202 const size_t idx_orient_bin = input_block_norm[i].second;
206 _hog_norm_space[i].allocator()->init(tensor_info);
209 _memory_group.
manage(&_hog_norm_space[i]);
212 _block_norm_kernel.emplace_back(std::make_unique<CLHOGBlockNormalizationKernel>());
213 _block_norm_kernel.back()->configure(compile_context, &_hog_space[idx_orient_bin], &_hog_norm_space[i], multi_hog->
model(idx_multi_hog)->
info());
217 for(
size_t i = 0; i < _num_orient_bin_kernel; ++i)
219 _hog_space[i].allocator()->allocate();
225 for(
size_t i = 0; i < _num_hog_detect_kernel; ++i)
227 const size_t idx_block_norm = input_hog_detect[i];
229 _hog_detect_kernel[i].configure(compile_context, &_hog_norm_space[idx_block_norm], multi_hog->
cl_model(i), detection_windows, detection_window_strides->
at(i),
threshold, i);
235 _non_maxima_kernel.
configure(_detection_windows, min_distance);
238 for(
size_t i = 0; i < _num_block_norm_kernel; ++i)
240 _hog_norm_space[i].allocator()->allocate();
251 _detection_windows->
clear();
254 _gradient_kernel.
run();
257 for(
size_t i = 0; i < _num_orient_bin_kernel; ++i)
263 for(
size_t i = 0; i < _num_block_norm_kernel; ++i)
269 for(
size_t i = 0; i < _num_hog_detect_kernel; ++i)
271 _hog_detect_kernel[i].run();
275 if(_non_maxima_suppression)
BorderMode
Methods available to handle borders.
void configure(ICLTensor *input, const ICLMultiHOG *multi_hog, ICLDetectionWindowArray *detection_windows, ICLSize2DArray *detection_window_strides, BorderMode border_mode, uint8_t constant_border_value=0, float threshold=0.0f, bool non_maxima_suppression=false, float min_distance=1.0f)
Initialise the function's source, destination, detection window strides, border mode, threshold and non-maxima suppression.
size_t num_bins() const
The number of histogram bins for each cell.
void clear()
Clear all the points from the array.
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
const Size2D & cell_size() const
The cell size in pixels.
static CLScheduler & get()
Access the scheduler singleton.
PhaseType
Phase calculation type.
void configure(ICLTensor *input, ICLTensor *output_magnitude, ICLTensor *output_phase, PhaseType phase_type, BorderMode border_mode, uint8_t constant_border_value=0)
Initialise the function's source, destinations, phase type and border mode.
1 channel, 1 U8 per channel
1 channel, 1 F32 per channel
void map(cl::CommandQueue &q, bool blocking=true)
Enqueue a map operation of the allocated buffer on the given queue.
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
static CLKernelLibrary & get()
Access the KernelLibrary singleton.
CLHOGMultiDetection(std::shared_ptr< IMemoryManager > memory_manager=nullptr)
Default constructor.
CLTensorAllocator * allocator()
Return a pointer to the tensor's allocator.
PhaseType phase_type() const
The type of PhaseType.
virtual ICLHOG * cl_model(size_t index)=0
Return a pointer to the requested OpenCL HOG model.
const Size2D & block_stride() const
The block stride in pixels.
void init(const TensorInfo &input, size_t alignment=0)
Initialize a tensor based on the passed TensorInfo.
Copyright (c) 2017-2021 Arm Limited.
size_t height
Height of the image region or rectangle.
virtual size_t num_models() const =0
The number of HOG models stored.
void manage(IMemoryManageable *obj) override
Sets a object to be managed by the given memory group.
Interface to enqueue OpenCL kernels and get/set the OpenCL CommandQueue and ICLTuner.
IHOG * model(size_t index) override
Return a pointer to the requested HOG model.
Interface for OpenCL Array.
static constexpr size_t DimX
Alias for dimension 0 also known as X dimension.
#define ARM_COMPUTE_ERROR_ON_INVALID_MULTI_HOG(m)
size_t num_values() const
Number of values currently stored in the array.
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
Interface for storing multiple HOG data-objects.
#define ARM_COMPUTE_ERROR_ON_MSG(cond, msg)
const Size2D & block_size() const
The block size in pixels.
void configure(IDetectionWindowArray *input_output, float min_distance)
Initialise the kernel's input, output and the euclidean minimum distance.
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
1 channel, 1 S16 per channel
void enqueue(ICLKernel &kernel, bool flush=true)
Schedule the execution of the passed kernel if possible.
#define ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
void unmap(cl::CommandQueue &q)
Enqueue an unmap operation of the allocated and mapped buffer on the given queue. ...
void allocate() override
Allocate size specified by TensorInfo of OpenCL memory.
static constexpr size_t DimY
Alias for dimension 1 also known as Y dimension.
Memory group resources scope handling class.
Interface for OpenCL tensor.
virtual void schedule(ICPPKernel *kernel, const Hints &hints)=0
Runs the kernel in the same thread as the caller synchronously.
size_t width
Width of the image region or rectangle.
SimpleTensor< T > non_maxima_suppression(const SimpleTensor< T > &src, BorderMode border_mode, T constant_border_value)
Class for specifying the size of an image or rectangle.
Wrapper to configure the Khronos OpenCL C++ header.
Store the tensor's metadata.
~CLHOGMultiDetection()
Default destructor.
virtual const HOGInfo * info() const =0
Interface to be implemented by the child class to return the HOG's metadata.
void run() override
Run the kernels contained in the function.
SimpleTensor< T > threshold(const SimpleTensor< T > &src, T threshold, T false_value, T true_value, ThresholdType type, T upper)
TensorShape & set(size_t dimension, size_t value, bool apply_dim_correction=true, bool increase_dim_unit=true)
Accessor to set the value of one of the dimensions.
void run() override
Run the kernels contained in the function.
virtual T & at(size_t index) const
Reference to the element of the array located at the given index.
static IScheduler & get()
Access the scheduler singleton.