Jump to content

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

m
no edit summary
No edit summary
mNo edit summary
Line 4: Line 4:


In this section will be explained an example for face redaction running on GPU.  
In this section will be explained an example for face redaction running on GPU.  
=== Backend ===
== 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.  
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.  


Line 16: Line 16:
</source>
</source>


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


Line 23: Line 23:
</source>
</source>


==== Get Model ====
=== 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.  
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.  


Line 30: Line 30:
</source>
</source>


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


==== Resolution ====
=== 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 these resolutions with the AI model resolution as 640x480 in case of ONNX face detector.
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 these resolutions with the AI model resolution as 640x480 in case of ONNX face detector.


Line 43: Line 43:
</syntaxhighlight>
</syntaxhighlight>


==== Format ====
=== Format ===


Format is an enumeration of values for the supported formats, which are: RGBA, RGB, GREY and YUV. The format of the input video/image may differ from the format accepted by the AI model. We should create both of these formats with the AI model format as RGB in case of ONNX face detector.
Format is an enumeration of values for the supported formats, which are: RGBA, RGB, GREY and YUV. The format of the input video/image may differ from the format accepted by the AI model. We should create both of these formats with the AI model format as RGB in case of ONNX face detector.
Line 52: Line 52:
</syntaxhighlight>
</syntaxhighlight>


==== Allocate Buffers ====
=== Allocate Buffers ===


With the resolution and formats defined, the buffer objects can be created.
With the resolution and formats defined, the buffer objects can be created.
Line 77: Line 77:
</syntaxhighlight>
</syntaxhighlight>


=== Redaction Algorithm ===
== Redaction Algorithm ==


The Object Redaction library its compound by the stages: convert, detect, track (optional) and redact. This stages can be perform in a single step using the apply method or in a step-by-step process.
The Object Redaction library its compound by the stages: convert, detect, track (optional) and redact. This stages can be perform in a single step using the apply method or in a step-by-step process.
Line 87: Line 87:
</syntaxhighlight>
</syntaxhighlight>


==== Step-by-step ====
=== Step-by-step ===


* First step is to preprocess the input image to be accepted by the AI model.
* First step is to preprocess the input image to be accepted by the AI model.
Line 107: Line 107:
</syntaxhighlight>
</syntaxhighlight>


==== Apply method ====
=== Apply method ===


To apply the redaction algorithm in a single step use the apply method set by the algorithm. This method  
To apply the redaction algorithm in a single step use the apply method set by the algorithm. This method  
Line 115: Line 115:
</syntaxhighlight>
</syntaxhighlight>


=== Download buffer to CPU memory ===
== Download buffer to CPU memory ==


When using GPU the output buffer must be allocated to CPU memory. To accomplish the allocation use the <code>copyToHost</code> method to download the output buffer to CPU memory.
When using GPU the output buffer must be allocated to CPU memory. To accomplish the allocation use the <code>copyToHost</code> method to download the output buffer to CPU memory.
Line 125: Line 125:
The output final buffer contains the modified image where the detected faces have been redact.
The output final buffer contains the modified image where the detected faces have been redact.


=== Full example ===
== Full example ==


The full example script should look like:
The full example script should look like:
Cookies help us deliver our services. By using our services, you agree to our use of cookies.