# External Postprocessing

You can add custom processing to the inference pipeline by connecting an external application. The application receives data from the Nx AI Manager, can modify it, and returns a response.

Example implementations are provided in C and Python, but you can use any language that can communicate over a Unix socket.

A high-level overview of the inference pipeline is as follows:

<figure><img src="/files/CVoUQ65NjNOFXPJgCjKd" alt=""><figcaption><p>A high-level overview of the inference pipeline</p></figcaption></figure>

The postprocessor receives inference results, can modify them, and returns the altered data. The Nx AI Manager then sends the result to the Network Optix platform to generate bounding boxes or trigger events.

Configure the startup settings to tell the Nx AI Manager how to launch your application. The Nx AI Manager starts and stops it automatically as needed.

### External Postprocessor

The postprocessor receives a MessagePack-encoded buffer of inference results, using the same structure that would be sent to the output. Modify the message and return it; the Nx AI Manager forwards your response to the Network Optix platform. The returned message must preserve the original structure, otherwise the platform cannot parse it. The examples show how to read, modify, and write this structure.

<figure><img src="/files/JuPRpoLYtZ4ibKPIXDSG" alt=""><figcaption><p>External Postprocessor data flow</p></figcaption></figure>

### External Tensor Postprocessor

Enable the tensor postprocessor setting to give your postprocessor access to the raw input tensor from which the inference results were generated. This is useful for inspecting pixel data inside detected bounding boxes or for cropping sub-images.

When enabled, the Nx AI Manager writes the input tensor to shared memory and sends your postprocessor an additional message with the shared memory location.

The Nx AI Manager sends two messages in sequence: the inference results first, then the image header. Your postprocessor must read both before sending its response. Both messages are MessagePack encoded.

<figure><img src="/files/GoDAuMKnrv8RXBP441vc" alt=""><figcaption><p>Tensor Postprocessor data flow</p></figcaption></figure>

The postprocessor can do additional analysis on the tensor data.

### Custom external processing

If this behavior is not the desired behavior, is possible to create your own preprocessor to create a mask or postprocessor to exclude results from an area that you designate.

For more information on custom preprocessors and postprocessors you can checkout the examples in our GitHub repository

{% embed url="<https://github.com/scailable/sclbl-integration-sdk>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://nx.docs.scailable.net/nx-ai-manager-v6.1.2/nx-ai-manager-plugin/advanced-configuration/external-postprocessing.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
