ON THIS PAGE

  • Post-Processing
  • Output Interpretation and Conversion
  • Predefined Models
  • Object Detection
  • Custom Models
  • Practical Applications Showcase

Post-Processing

Post-processing is a critical phase in the inference process. It involves refining the raw outputs of the models to derive meaningful insights and actionable data.

Output Interpretation and Conversion

In the DepthAI library, we support a range of predefined models as well as custom ones. This section will guide you through interpreting and parsing outputs from both types of models.

Predefined Models

Object Detection

We provide decoding support for some predefined models with outputs that can be easily parsed using the Python API. These models provide a set of data for each detected object. This includes the following:
  • Bounding Box Coordinates (xmin, ymin, xmax, ymax): These define the rectangular area in which the detected object is located within the image. The coordinates are normalized, meaning they are expressed as values between 0 and 1 relative to the dimensions of the image.
  • Confidence Scores: Represent the model's certainty about the detection. A higher score indicates greater confidence in the accuracy of the detection.
  • Class Labels: Indicate the category of the detected object, as learned by the model during training.
Supported predefined models include:
  • MobileNet: can be used through the MobileNetDetectionNetwork node.
  • Yolo: can be used through the YoloDetectionNetwork node. Available for export via Luxonis Tools. We support several versions of Yolo models, each tailored for different detection needs:
    • YoloV5
    • YoloV6 (R1, R2, R3, R4)
    • YoloV7
    • YoloV8
    • GoldYolo
For a more detailed understanding of model outputs and predifined model nodes, refer to the ImgDetections documentation. An example of parsing the data is as follows:
Python
1import depthai as dai
2
3# Assuming the pipeline and model setup are already done
4# For details on pipeline creation, refer to DepthAI documentation
5
6# Connect to the device and start the pipeline
7with dai.Device(pipeline) as device:
8
9    # Retrieve detections from the output queue
10    qDet = device.getOutputQueue(name="network_node_name", maxSize=4, blocking=False)
11    detections = qDet.get().detections
12
13    # Parse each detection
14    for detection in detections:
15        xmin, ymin, xmax, ymax = detection.bbox
16        confidence = detection.confidence
17        class_id = detection.label
18        # Further processing or utilizing...

Custom Models

For custom models, outputs can still be retrieved using methods like getLayerFp16(layer_name) or getLayerInt8(layer_name), where you need to provide the name of the specific layer. Given that these methods return a flattened output from the selected layer, it's necessary to reshape the output for subsequent use. You can find an example in
the EfficientDet experiment. The following code snippet briefly illustrates the process:
Python
1import depthai as dai
2import numpy as np
3
4# Assuming the pipeline and model setup are already done
5# For details on pipeline creation, refer to DepthAI documentation
6output_shape=(1,1000) # replace with your own shape
7
8# Connect to the device and start the pipeline
9with dai.Device(pipeline) as device:
10
11    # Define the queue
12    qDet = device.getOutputQueue(name="network_node_name", maxSize=4, blocking=False)
13
14    # Retrieve the list of outputs and reshape it to the desired dimensions
15    outputs = in_nn.getLayerFp16('network_output_name')
16    outputs = np.array(outputs).reshape(output_shape)
17
18    # Further parsing, processing or utilizing...

Practical Applications Showcase

Once the model's outputs are parsed, the resulting data can be employed in various meaningful ways:
  • Visual Feedback: Use the bounding box coordinates to draw rectangles around detected objects in real-time video streams. You can find the example in our YOLO experiment.
  • Data Analytics: The people tracking experiment illustrates the application of data for tracking, analyzing movement trends, and counting people. It can be useful in environments like retail spaces, public venues, or transport hubs, where understanding foot traffic patterns and density is essential for operational efficiency, safety, and customer experience optimization.
  • Anomaly Detection: This experiment showcases real-time anomaly detection capabilities. This is particularly useful in scenarios like quality control in manufacturing, where detecting deviations from the norm in products or processes is crucial.