Compute Library
 19.08
CLHOGDetector Class Reference

Basic function to execute HOG detector based on linear SVM. More...

#include <CLHOGDetector.h>

Collaboration diagram for CLHOGDetector:
[legend]

Public Member Functions

 CLHOGDetector ()
 Default constructor. More...
 
 CLHOGDetector (const CLHOGDetector &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
CLHOGDetectoroperator= (const CLHOGDetector &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 CLHOGDetector (CLHOGDetector &&)=default
 Allow instances of this class to be moved. More...
 
CLHOGDetectoroperator= (CLHOGDetector &&)=default
 Allow instances of this class to be moved. More...
 
 ~CLHOGDetector ()=default
 Default destructor. More...
 
void configure (const ICLTensor *input, const ICLHOG *hog, ICLDetectionWindowArray *detection_windows, const Size2D &detection_window_stride, float threshold=0.0f, size_t idx_class=0)
 Initialise the kernel's input, output, HOG data object, detection window stride, threshold and index class. 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 HOG detector based on linear SVM.

This function calls the following OpenCL kernel:

  1. CLHOGDetectorKernel

Definition at line 39 of file CLHOGDetector.h.

Constructor & Destructor Documentation

◆ CLHOGDetector() [1/3]

Default constructor.

Definition at line 34 of file CLHOGDetector.cpp.

35  : _hog_detector_kernel(), _detection_windows(nullptr), _num_detection_windows()
36 {
37 }

◆ CLHOGDetector() [2/3]

CLHOGDetector ( const CLHOGDetector )
delete

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

◆ CLHOGDetector() [3/3]

CLHOGDetector ( CLHOGDetector &&  )
default

Allow instances of this class to be moved.

◆ ~CLHOGDetector()

~CLHOGDetector ( )
default

Default destructor.

Member Function Documentation

◆ configure()

void configure ( const ICLTensor input,
const ICLHOG hog,
ICLDetectionWindowArray detection_windows,
const Size2D detection_window_stride,
float  threshold = 0.0f,
size_t  idx_class = 0 
)

Initialise the kernel's input, output, HOG data object, detection window stride, threshold and index class.

Attention
The function does not reset the number of values in IDetectionWindowArray so it is caller's responsibility to clear it.
Parameters
[in]inputInput tensor. It is the output of CLHOGDescriptor. Data type supported: F32
[in]hogHOG data-object that describes the HOG descriptor
[out]detection_windowsArray of DetectionWindow used to store the detected objects
[in]detection_window_strideDistance in pixels between 2 consecutive detection windows in x and y directions. It must be multiple of the block stride stored in hog
[in]threshold(Optional) Threshold for the distance between features and SVM classifying plane
[in]idx_class(Optional) Index of the class used for evaluating which class the detection window belongs to

Definition at line 39 of file CLHOGDetector.cpp.

40 {
41  _detection_windows = detection_windows;
42 
43  // Allocate buffer for storing the number of detected objects
44  _num_detection_windows = cl::Buffer(CLScheduler::get().context(), CL_MEM_ALLOC_HOST_PTR | CL_MEM_READ_WRITE, sizeof(unsigned int));
45 
46  // Configure HOGDetectorKernel
47  _hog_detector_kernel.configure(input, hog, detection_windows, &_num_detection_windows, detection_window_stride, threshold, idx_class);
48 }
static CLScheduler & get()
Access the scheduler singleton.
Definition: CLScheduler.cpp:41
void configure(const ICLTensor *input, const ICLHOG *hog, ICLDetectionWindowArray *detection_windows, cl::Buffer *num_detection_windows, const Size2D &detection_window_stride, float threshold=0.0f, uint16_t idx_class=0)
Initialise the kernel's input, HOG data-object, detection window, the stride of the detection window,...
SimpleTensor< T > threshold(const SimpleTensor< T > &src, T threshold, T false_value, T true_value, ThresholdType type, T upper)
Definition: Threshold.cpp:35

References CLHOGDetectorKernel::configure(), CLScheduler::get(), and arm_compute::test::validation::reference::threshold().

◆ operator=() [1/2]

CLHOGDetector& operator= ( const CLHOGDetector )
delete

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

◆ operator=() [2/2]

CLHOGDetector& operator= ( CLHOGDetector &&  )
default

Allow instances of this class to be moved.

◆ 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 50 of file CLHOGDetector.cpp.

51 {
52  cl::CommandQueue q = CLScheduler::get().queue();
53 
54  // Reset number of detections
55  const unsigned int init_num_detection_windows = _detection_windows->num_values();
56  q.enqueueWriteBuffer(_num_detection_windows, CL_FALSE, 0, sizeof(unsigned int), &init_num_detection_windows);
57 
58  // Run CLHOGDetectorKernel
59  CLScheduler::get().enqueue(_hog_detector_kernel);
60 
61  // Read number of detections
62  unsigned int num_detection_windows = 0;
63  q.enqueueReadBuffer(_num_detection_windows, CL_TRUE, 0, sizeof(unsigned int), &num_detection_windows);
64 
65  // Update the number of values stored in _detection_windows
66  _detection_windows->resize(static_cast<size_t>(num_detection_windows));
67 
68  q.flush();
69 }
static CLScheduler & get()
Access the scheduler singleton.
Definition: CLScheduler.cpp:41
void resize(size_t num)
Resizes the array to contain "num" elements.
Definition: IArray.h:128
size_t num_values() const
Number of values currently stored in the array.
Definition: IArray.h:68
void enqueue(ICLKernel &kernel, bool flush=true)
Schedule the execution of the passed kernel if possible.
Definition: CLScheduler.cpp:95
cl::CommandQueue & queue()
Accessor for the associated CL command queue.
Definition: CLScheduler.h:102

References CLScheduler::enqueue(), CLScheduler::get(), IArray< T >::num_values(), CLScheduler::queue(), and IArray< T >::resize().


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