42 bool use_initial_estimate,
size_t level,
size_t num_levels,
float pyramid_scale)
44 configure(
CLKernelLibrary::get().get_compile_context(), old_points, new_points_estimates, old_points_internal, new_points_internal, use_initial_estimate, level, num_levels, pyramid_scale);
49 bool use_initial_estimate,
size_t level,
size_t num_levels,
float pyramid_scale)
56 const float scale = std::pow(pyramid_scale, level);
60 if(level == (num_levels - 1))
62 kernel_name += (use_initial_estimate) ? std::string(
"_max_initial_estimate") : std::string(
"_max");
68 if(level == (num_levels - 1))
70 _kernel.setArg(idx++, old_points->
cl_buffer());
71 if(use_initial_estimate)
73 _kernel.setArg(idx++, new_points_estimates->
cl_buffer());
76 _kernel.setArg(idx++, old_points_internal->
cl_buffer());
77 _kernel.setArg(idx++, new_points_internal->
cl_buffer());
78 _kernel.setArg<cl_float>(idx++,
scale);
84 ICLKernel::configure_internal(window);
110 unsigned int idx = 0;
111 _kernel.setArg(idx++, new_points_internal->
cl_buffer());
112 _kernel.setArg(idx++, new_points->
cl_buffer());
118 ICLKernel::configure_internal(window);
130 : _old_input(nullptr), _old_scharr_gx(nullptr), _old_scharr_gy(nullptr)
137 size_t window_dimension,
size_t level)
139 configure(
CLKernelLibrary::get().get_compile_context(), old_input, old_scharr_gx, old_scharr_gy, old_points_internal, new_points_internal, coeff_table, old_ival, window_dimension, level);
145 size_t window_dimension,
size_t level)
156 _old_input = old_input;
157 _old_scharr_gx = old_scharr_gx;
158 _old_scharr_gy = old_scharr_gy;
172 valid_region.
end(0), valid_region.
end(1)),
174 valid_region.
end(0), valid_region.
end(1)),
176 valid_region.
end(0), valid_region.
end(1)));
178 ICLKernel::configure_internal(window);
181 const int level0 = (level == 0) ? 1 : 0;
182 const int window_size = window_dimension;
183 const int window_size_squared = window_dimension * window_dimension;
184 const int window_size_half = window_dimension / 2;
185 const float eig_const = 1.0f / (2.0f * window_size_squared);
186 const cl_float3 border_limits =
190 static_cast<cl_float
>(valid_region.
end(0) - window_size - 1),
191 static_cast<cl_float>(valid_region.
end(1) - window_size - 1),
192 static_cast<cl_float>(valid_region.
start(0))
197 _kernel =
create_kernel(compile_context,
"lktracker_stage0");
201 _kernel.setArg(idx++, old_points_internal->
cl_buffer());
202 _kernel.setArg(idx++, new_points_internal->
cl_buffer());
203 _kernel.setArg(idx++, coeff_table->
cl_buffer());
204 _kernel.setArg(idx++, old_ival->
cl_buffer());
205 _kernel.setArg<cl_int>(idx++, window_size);
206 _kernel.setArg<cl_int>(idx++, window_size_squared);
207 _kernel.setArg<cl_int>(idx++, window_size_half);
208 _kernel.setArg<cl_float3>(idx++, border_limits);
209 _kernel.setArg<cl_float>(idx++, eig_const);
210 _kernel.setArg<cl_int>(idx++, level0);
219 unsigned int idx = 0;
228 : _new_input(nullptr)
235 configure(
CLKernelLibrary::get().get_compile_context(), new_input, new_points_internal, coeff_table, old_ival, termination, epsilon, num_iterations, window_dimension, level);
248 _new_input = new_input;
259 valid_region.
end(0), valid_region.
end(1)));
261 ICLKernel::configure_internal(window);
264 const int level0 = (level == 0) ? 1 : 0;
265 const int window_size = window_dimension;
266 const int window_size_squared = window_dimension * window_dimension;
267 const int window_size_half = window_dimension / 2;
268 const float eig_const = 1.0f / (2.0f * window_size_squared);
269 const cl_float3 border_limits =
273 static_cast<cl_float
>(valid_region.
end(0) - window_size - 1),
274 static_cast<cl_float>(valid_region.
end(1) - window_size - 1),
275 static_cast<cl_float>(valid_region.
start(0))
280 const size_t max_iterations = 1000;
286 _kernel =
create_kernel(compile_context,
"lktracker_stage1");
290 _kernel.setArg(idx++, new_points_internal->
cl_buffer());
291 _kernel.setArg(idx++, coeff_table->
cl_buffer());
292 _kernel.setArg(idx++, old_ival->
cl_buffer());
293 _kernel.setArg<cl_int>(idx++, window_size);
294 _kernel.setArg<cl_int>(idx++, window_size_squared);
295 _kernel.setArg<cl_int>(idx++, window_size_half);
296 _kernel.setArg<cl_int>(idx++, num_iterations);
297 _kernel.setArg<cl_float>(idx++,
epsilon);
298 _kernel.setArg<cl_float3>(idx++, border_limits);
299 _kernel.setArg<cl_float>(idx++, eig_const);
300 _kernel.setArg<cl_int>(idx++, level0);
301 _kernel.setArg<cl_int>(idx++, term_epsilon);
310 unsigned int idx = 0;
void configure(const ICLTensor *new_input, ICLLKInternalKeypointArray *new_points_internal, ICLCoefficientTableArray *coeff_table, ICLOldValArray *old_ival, Termination termination, float epsilon, size_t num_iterations, size_t window_dimension, size_t level)
Initialise the kernel input and output.
const Window & window() const
The maximum window the kernel can be executed on.
void run(const Window &window, cl::CommandQueue &queue) override
Enqueue the OpenCL kernel to process the given window on the passed OpenCL command queue...
void enqueue(IGCKernel &kernel, const Window &window, const gles::NDRange &lws=gles::NDRange(1U, 1U, 1U))
Add the kernel to the command queue with the given window.
cl::NDRange lws_hint() const
Return the Local-Workgroup-Size hint.
1 channel, 1 U8 per channel
Terminate when within epsilon of a threshold.
#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.
Describe one of the image's dimensions with a start, end and step.
const ValidRegion valid_region
Terminate on whichever of the other conditions occurs first.
Copyright (c) 2017-2021 Arm Limited.
void configure(ICLLKInternalKeypointArray *new_points_internal, ICLKeyPointArray *new_points)
Initialise the kernel input and output.
virtual ValidRegion valid_region() const =0
Valid region of the tensor.
CLLKTrackerStage0Kernel()
Default constructor.
Implementation of a static rectangular access pattern.
void configure(const ICLKeyPointArray *old_points, const ICLKeyPointArray *new_points_estimates, ICLLKInternalKeypointArray *old_points_internal, ICLLKInternalKeypointArray *new_points_internal, bool use_initial_estimate, size_t level, size_t num_levels, float pyramid_scale)
Initialise the kernel input and output.
cl::Kernel create_kernel(const CLCompileContext &ctx, const std::string &kernel_name, const std::set< std::string > &build_opts=std::set< std::string >())
Creates an opencl kernel using a compile context.
Interface for OpenCL Array.
static constexpr size_t DimX
Alias for dimension 0 also known as X dimension.
bool update_window_and_padding(Window &win, Ts &&... patterns)
Update window and padding size for each of the access patterns.
size_t num_values() const
Number of values currently stored in the array.
int start(unsigned int d) const
Return the start of the valid region for the given dimension d.
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
ValidRegion intersect_valid_regions(const Ts &... regions)
Intersect multiple valid regions.
void set(size_t dimension, const Dimension &dim)
Set the values of a given dimension.
static constexpr unsigned int num_arguments_per_2D_tensor()
Returns the number of arguments enqueued per 2D tensor object.
Termination
Termination criteria.
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
1 channel, 1 S16 per channel
void run(const Window &window, cl::CommandQueue &queue) override
Enqueue the OpenCL kernel to process the given window on the passed OpenCL command queue...
#define ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
void configure(const ICLTensor *old_input, const ICLTensor *old_scharr_gx, const ICLTensor *old_scharr_gy, ICLLKInternalKeypointArray *old_points_internal, ICLLKInternalKeypointArray *new_points_internal, ICLCoefficientTableArray *coeff_table, ICLOldValArray *old_ival, size_t window_dimension, size_t level)
Initialise the kernel input and output.
static constexpr size_t DimY
Alias for dimension 1 also known as Y dimension.
void add_2D_tensor_argument(unsigned int &idx, const ICLTensor *tensor, const Window &window)
Add the passed 2D tensor's parameters to the object's kernel's arguments starting from the index idx...
Interface for OpenCL tensor.
int end(unsigned int d) const
Return the end of the valid region for the given dimension d.
Manages all the OpenCL kernels compilation and caching, provides accessors for the OpenCL Context...
void run(const Window &window, cl::CommandQueue &queue) override
Enqueue the OpenCL kernel to process the given window on the passed OpenCL command queue...
Container for valid region of a window.
CLLKTrackerStage1Kernel()
Default constructor.
virtual const cl::Buffer & cl_buffer() const =0
Interface to be implemented by the child class to return a reference to the OpenCL buffer containing ...
void run(const Window &window, cl::CommandQueue &queue) override
Enqueue the OpenCL kernel to process the given window on the passed OpenCL command queue...
Describe a multidimensional execution window.
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)