Compute Library
 21.02
NEOpticalFlow.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016-2021 Arm Limited.
3  *
4  * SPDX-License-Identifier: MIT
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to
8  * deal in the Software without restriction, including without limitation the
9  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10  * sell copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all
14  * copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24 #ifndef ARM_COMPUTE_NEOPTICALFLOW_H
25 #define ARM_COMPUTE_NEOPTICALFLOW_H
26 
28 #include "arm_compute/core/Types.h"
29 #include "arm_compute/core/Types.h"
36 
37 #include <cstddef>
38 #include <cstdint>
39 #include <memory>
40 
41 namespace arm_compute
42 {
43 class Pyramid;
44 class NELKTrackerKernel;
45 
46 /** Array of LK Internel Keypoints */
48 /** Basic function to execute optical flow. This function calls the following Neon kernels and functions:
49  *
50  * -# @ref NEScharr3x3
51  * -# @ref NELKTrackerKernel
52  *
53  *
54  * @deprecated This function is deprecated and is intended to be removed in 21.05 release
55  *
56  */
57 class NEOpticalFlow : public IFunction
58 {
59 public:
60  /** Constructor
61  *
62  * @param[in] memory_manager (Optional) Memory manager.
63  */
64  NEOpticalFlow(std::shared_ptr<IMemoryManager> memory_manager = nullptr);
65  /** Prevent instances of this class from being copied (As this class contains pointers) */
66  NEOpticalFlow(const NEOpticalFlow &) = delete;
67  /** Prevent instances of this class from being copied (As this class contains pointers) */
68  NEOpticalFlow &operator=(const NEOpticalFlow &) = delete;
69  /** Default destructor */
71  /** Initialise the function input and output
72  *
73  * @param[in] old_pyramid Pointer to the pyramid for the old tensor. Data type supported U8
74  * @param[in] new_pyramid Pointer to the pyramid for the new tensor. Data type supported U8
75  * @param[in] old_points Pointer to the IKeyPointArray storing old key points
76  * @param[in] new_points_estimates Pointer to the IKeyPointArray storing new estimates key points
77  * @param[out] new_points Pointer to the IKeyPointArray storing new key points
78  * @param[in] termination The criteria to terminate the search of each keypoint.
79  * @param[in] epsilon The error for terminating the algorithm
80  * @param[in] num_iterations The maximum number of iterations before terminate the alogrithm
81  * @param[in] window_dimension The size of the window on which to perform the algorithm
82  * @param[in] use_initial_estimate The flag to indicate whether the initial estimated position should be used
83  * @param[in] border_mode The border mode applied at scharr kernel stage
84  * @param[in] constant_border_value (Optional) Constant value to use for borders if border_mode is set to CONSTANT
85  *
86  */
87  void configure(const Pyramid *old_pyramid, const Pyramid *new_pyramid, const IKeyPointArray *old_points, const IKeyPointArray *new_points_estimates,
88  IKeyPointArray *new_points, Termination termination, float epsilon, unsigned int num_iterations, size_t window_dimension,
89  bool use_initial_estimate, BorderMode border_mode, uint8_t constant_border_value = 0);
90 
91  // Inherited methods overridden:
92  void run() override;
93 
94 private:
95  MemoryGroup _memory_group;
96  std::vector<NEScharr3x3> _func_scharr;
97  std::vector<std::unique_ptr<NELKTrackerKernel>> _kernel_tracker;
98  std::vector<Tensor> _scharr_gx;
99  std::vector<Tensor> _scharr_gy;
100  IKeyPointArray *_new_points;
101  const IKeyPointArray *_new_points_estimates;
102  const IKeyPointArray *_old_points;
103  LKInternalKeypointArray _new_points_internal;
104  LKInternalKeypointArray _old_points_internal;
105  unsigned int _num_levels;
106 };
107 } // namespace arm_compute
108 #endif /*ARM_COMPUTE_NEOPTICALFLOW_H */
BorderMode
Methods available to handle borders.
Definition: Types.h:265
Base class for all functions.
Definition: IFunction.h:30
Array of type T.
Definition: IArray.h:40
NEOpticalFlow & operator=(const NEOpticalFlow &)=delete
Prevent instances of this class from being copied (As this class contains pointers) ...
Copyright (c) 2017-2021 Arm Limited.
Basic implementation of the pyramid interface.
Definition: Pyramid.h:40
Termination
Termination criteria.
Definition: Types.h:414
Basic function to execute optical flow.
Definition: NEOpticalFlow.h:57
NEOpticalFlow(std::shared_ptr< IMemoryManager > memory_manager=nullptr)
Constructor.
void configure(const Pyramid *old_pyramid, const Pyramid *new_pyramid, const IKeyPointArray *old_points, const IKeyPointArray *new_points_estimates, IKeyPointArray *new_points, Termination termination, float epsilon, unsigned int 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.
~NEOpticalFlow()
Default destructor.
void run() override
Run the kernels contained in the function.