AI Based Object Redaction/Examples/Library Examples: Difference between revisions

From RidgeRun Developer Wiki
Line 3: Line 3:
First, we create the backend object. The backend provides factories to create the redaction algorithm and buffers. It provides the user the ability to select the desired backend for the execution of the algorithm for object redaction. The backend could be CPU or GPU.  
First, we create the backend object. The backend provides factories to create the redaction algorithm and buffers. It provides the user the ability to select the desired backend for the execution of the algorithm for object redaction. The backend could be CPU or GPU.  


<syntaxhighlight lang=C>
<syntaxhighlight lang=Casa>
std::shared_ptr<rd::IBackend> backend = std::make_shared<rd::gpu::Backend>();
std::shared_ptr<rd::IBackend> backend = std::make_shared<rd::gpu::Backend>();
/* HOLA */
/* HOLA */

Revision as of 21:30, 20 December 2023

In this section will be explained an example for face redaction running on GPU.

Backend

First, we create the backend object. The backend provides factories to create the redaction algorithm and buffers. It provides the user the ability to select the desired backend for the execution of the algorithm for object redaction. The backend could be CPU or GPU.

std::shared_ptr<rd::IBackend> backend = std::make_shared<rd::gpu::Backend>();
/* HOLA */

In case the input buffer is not already in GPU memory, we also need to create a CPU backend to allocate the buffer in CPU memory.

std::shared_ptr<rd::IBackend> cpu_backend = std::make_shared<rd::cpu::Backend>();

Get algorithm

The GetAlgorithm method is used to obtain the redaction algorithm to process the input buffer.

std::shared_ptr<rd::IRedaction> algorithm = backend->GetAlgorithm();

Get Model

The getModel method is used to obtain the AI model that will be used for the detection of the desired object. In this case: faces.

std::shared_ptr<rd::IModel> model = backend->getModel(rd::Model::FACE_DETECTION);

Buffers

Buffers are the structure used to manipulate and load the data corresponding to the video frames. A buffer consists of a resolution and a format.

Resolution

Resolution is a structure that consists of two parameters: width and height. The resolution of the input video/image may differ from the resolution accepted by the AI model. We should create both of this resolutions that will b