41 : _memory_group(
std::move(memory_manager)),
42 _tracker_init_kernel(),
43 _tracker_stage0_kernel(),
44 _tracker_stage1_kernel(),
50 _new_points_estimates(nullptr),
52 _old_points_internal(),
53 _new_points_internal(),
64 Termination termination,
float epsilon,
size_t num_iterations,
size_t window_dimension,
bool use_initial_estimate,
65 BorderMode border_mode, uint8_t constant_border_value)
67 configure(
CLKernelLibrary::get().get_compile_context(), old_pyramid, new_pyramid, old_points, new_points_estimates, new_points, termination, epsilon, num_iterations, window_dimension,
68 use_initial_estimate, border_mode, constant_border_value);
73 Termination termination,
float epsilon,
size_t num_iterations,
size_t window_dimension,
bool use_initial_estimate,
74 BorderMode border_mode, uint8_t constant_border_value)
88 _old_points = old_points;
89 _new_points_estimates = new_points_estimates;
90 _new_points = new_points;
93 const float pyr_scale = old_pyramid->
info()->
scale();
94 const int list_length = old_points->
num_values();
95 const int old_values_list_length = list_length * window_dimension * window_dimension;
98 _tracker_init_kernel.reserve(_num_levels);
99 _tracker_stage0_kernel.reserve(_num_levels);
100 _tracker_stage1_kernel.reserve(_num_levels);
101 _func_scharr.resize(_num_levels);
102 _scharr_gx.resize(_num_levels);
103 _scharr_gy.resize(_num_levels);
106 _old_points_internal = std::make_unique<CLLKInternalKeypointArray>(list_length);
107 _old_points_internal->resize(list_length);
108 _new_points_internal = std::make_unique<CLLKInternalKeypointArray>(list_length);
109 _new_points_internal->resize(list_length);
110 _coefficient_table = std::make_unique<CLCoefficientTableArray>(list_length);
111 _coefficient_table->resize(list_length);
112 _old_values = std::make_unique<CLOldValueArray>(old_values_list_length);
113 _old_values->resize(old_values_list_length);
114 _new_points->
resize(list_length);
116 for(
size_t i = 0; i < _num_levels; ++i)
123 const unsigned int width_ith = old_ith_input->
info()->
dimension(0);
124 const unsigned int height_ith = new_ith_input->
info()->
dimension(1);
128 _scharr_gx[i].allocator()->init(tensor_info);
129 _scharr_gy[i].allocator()->init(tensor_info);
132 _memory_group.
manage(&_scharr_gx[i]);
133 _memory_group.
manage(&_scharr_gy[i]);
136 _func_scharr[i].configure(compile_context, old_ith_input, &_scharr_gx[i], &_scharr_gy[i], border_mode, constant_border_value);
139 _tracker_init_kernel.emplace_back(std::make_unique<CLLKTrackerInitKernel>());
140 _tracker_init_kernel.back()->configure(compile_context, old_points, new_points_estimates, _old_points_internal.get(), _new_points_internal.get(), use_initial_estimate, i, _num_levels, pyr_scale);
143 _tracker_stage0_kernel.emplace_back(std::make_unique<CLLKTrackerStage0Kernel>());
144 _tracker_stage0_kernel.back()->configure(compile_context, old_ith_input, &_scharr_gx[i], &_scharr_gy[i],
145 _old_points_internal.get(), _new_points_internal.get(), _coefficient_table.get(), _old_values.get(),
146 window_dimension, i);
149 _tracker_stage1_kernel.emplace_back(std::make_unique<CLLKTrackerStage1Kernel>());
150 _tracker_stage1_kernel.back()->configure(compile_context, new_ith_input, _new_points_internal.get(), _coefficient_table.get(), _old_values.get(),
151 termination,
epsilon, num_iterations, window_dimension, i);
154 _scharr_gx[i].allocator()->allocate();
155 _scharr_gy[i].allocator()->allocate();
159 _tracker_finalize_kernel->configure(compile_context, _new_points_internal.get(), new_points);
171 _func_scharr[
level - 1].run();
BorderMode
Methods available to handle borders.
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
static CLScheduler & get()
Access the scheduler singleton.
const PyramidInfo * info() const override
Interface to be implemented by the child class to return the Pyramid's metadata.
void resize(size_t num)
Resizes the array to contain "num" elements.
#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.
Copyright (c) 2017-2021 Arm Limited.
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.
void run() override
Run the kernels contained in the function.
Interface for OpenCL Array.
size_t num_values() const
Number of values currently stored in the array.
Basic implementation of the OpenCL pyramid interface.
#define ARM_COMPUTE_ERROR_ON_MSG(cond, msg)
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
float scale() const
Return the scale factor of the pyramid.
~CLOpticalFlow()
Default destructor.
Termination
Termination criteria.
1 channel, 1 S16 per channel
void enqueue(ICLKernel &kernel, bool flush=true)
Schedule the execution of the passed kernel if possible.
Memory group resources scope handling class.
Interface for OpenCL tensor.
void configure(const CLPyramid *old_pyramid, const CLPyramid *new_pyramid, const ICLKeyPointArray *old_points, const ICLKeyPointArray *new_points_estimates, ICLKeyPointArray *new_points, Termination termination, float epsilon, size_t num_iterations, size_t window_dimension, bool use_initial_estimate, BorderMode border_mode, uint8_t constant_border_value=0)
Initialise the function input and output.
CLOpticalFlow(std::shared_ptr< IMemoryManager > memory_manager=nullptr)
Default constructor.
CLTensor * get_pyramid_level(size_t index) const override
Retrieves a level of the pyramid as a ITensor pointer.
Interface to run the finalize step of LKTracker, where it truncates the coordinates stored in new_poi...
Store the tensor's metadata.
size_t width() const
Return the width of the 0th level tensor.
size_t num_levels() const
Return the number of the pyramid levels.
size_t height() const
Return the height of the 0th level tensor.