# Object detection and encode with Neural Processing SDK The use cases implement a `yolox.dlc` object detection model with Qualcomm Neural Processing SDK to identify an object from a camera stream. The use case is to overlay or compose the bounding boxes over the detected objects, and then encode the stream as a H.264 bitstream. Download [YOLOX](https://aihub.qualcomm.com/iot/models/yolox?searchTerm=yolox)) Qualcomm AI runtime w8a8 precision model from AI hub. The YOLOX model uses the YOLOv8 postprocessing module. ## Use qtivoverlay plugin to apply detection overlay Run the use case on the target device: gst-launch-1.0 -e filesrc location=/opt/Animals_000_1080p_180s_30FPS.mp4 ! qtdemux ! h264parse ! v4l2h264dec capture-io-mode=4 output-io-mode=4 ! tee name=split \ split. ! queue ! qtimetamux name=metamux ! queue ! qtivoverlay ! queue ! \ v4l2h264enc capture-io-mode=4 output-io-mode=4 ! h264parse ! mp4mux ! filesink location=/opt/video.mp4 \ split. ! queue ! qtimlvconverter ! queue ! qtimlsnpe delegate=dsp tensors="" model=/etc/models/foot_track_net-person-foot-detection-w8a8.dlc ! queue ! qtimlpostprocess name=stage_01_postproc results=10 module=qpd labels=/etc/labels/foot_track_net.json settings=/etc/labels/foot_track_net_settings.json ! text/x-raw ! queue ! metamux. Copy to clipboard To stop the use case, use **CTRL + C**. The following figure shows the flow of the use case execution: 1. Identify object scenes from a video stream, which is coming through a file source. 2. Overlay bounding boxes over the detected objects using overlaylib. 3. Encode this stream as an H.264 bitstream. 4. Multiplex the stream in an MP4 container and stored as an MP4 file. The following table provides the sequential processing stages of the pipeline execution: | Process | Description | | --- | --- | | File source: filesrc |

  1. Captures the video stream using filesrc, followed by qtdemux, which demultiplexes the stream.


  2. Uses tee to split the stream for inferencing.


| | h264parse | Parses the H.264 video. | | [v4l2h264dec](https://docs.qualcomm.com/doc/80-80021-50/topic/v4l2h264dec.html) | Decodes the video. | | **Preprocessing** | **Preprocessing** | | [qtimlvconverter](https://docs.qualcomm.com/doc/80-80021-50/topic/qtimlvconverter.html) |

  1. Receives the video stream on its sink pad.


  2. Performs preprocessing:


    • Color conversion


    • Scaling down/up


    • Normalization on the stream data when the model expects the floating point values as input




  3. Converts the video stream to a tensor stream on its source pad.


    The object detection model uses this tensor stream for inferencing.



| | **Inferencing** | **Inferencing** | | [qtimlsnpe](https://docs.qualcomm.com/doc/80-80021-50/topic/qtimlsnpe.html) |

  1. Loads the object detection model.


  2. Modifies the graph for the chosen delegate.


  3. Receives the tensor stream on its sinkpad.


  4. Runs the inference and produces a tensor stream with the object detection results on its source pad.


| | **Postprocessing** | **Postprocessing** | | qtimlpostprocess |

  1. Receives the inference tensors from the object detection model.


  2. Converts the inference tensors on its sinkpad into formats like video or text that the multimedia plugins can process later.


  3. Applies the threshold to the chosen number of results.


  4. Loads the corresponding modules for detection models.


    In this use case, qtimlpostprocess does the following:


    1. Loads the YOLOv8 submodule.


    2. Produces results as structures of text.


    3. Sends them to the sinkpad of qtimetamux.




| | [qtimetamux](https://docs.qualcomm.com/doc/80-80021-50/topic/qtimetamux.html) |

  1. Receives video stream and text stream with the bounding box results corresponding to the video stream on its sinkpads.


  2. Produces GST buffers with the contents of the video stream from its sink pad.


  3. Adds the bounding boxes as GstVideoRegionOfInterest from data sinkpad to GST buffers meta (meta muxing) on its source pad.


| | [qtivoverlay](https://docs.qualcomm.com/doc/80-80021-50/topic/qtioverlay.html) |

  1. Receives the multiplexed stream.


  2. Overlays the bounding boxes on the VideoFrame using CL.


  3. Produces GST buffers with overlays in its source pad.


| | [v4l2h264enc](https://docs.qualcomm.com/doc/80-80021-50/topic/v4l2h264enc.html) |

  1. Applies parameters to each frame of the video stream it's receiving on its sinkpad.


  2. Encodes it into bitstream and sends it over its sourcepad.


| | h264parse | Adds more information about the bitstream to the GStreamer buffer meta. | | mp4mux | Receives these buffers and creates containers with format specification buffers. | | **Output** | **Output** | | Filesink | Stores the resulting stream in a */etc/media/video.mp4* file. | | Playback | Pull *video.mp4* from the host computer and play it on a media player: `scp root@\:/etc/media/video.mp4 ` | ## Use qtivcomposer to mix original frame with detection mask Run the use case on the target device: gst-launch-1.0 -e --gst-debug=2 \ filesrc location=/opt/Animals_000_1080p_180s_30FPS.mp4 ! qtdemux ! h264parse ! v4l2h264dec capture-io-mode=4 output-io-mode=4 ! queue ! tee name=split \ split. ! queue ! qtivcomposer name=mixer sink_1::position="<30, 30>" sink_1::dimensions="<320, 180>" ! queue ! \ v4l2h264enc capture-io-mode=4 output-io-mode=5 ! h264parse ! queue ! mp4mux ! queue ! filesink location=/opt/video.mp4 \ split. ! queue ! qtimlvconverter ! queue ! qtimlsnpe delegate=dsp tensors="" model=/etc/models/foot_track_net-person-foot-detection-w8a8.dlc ! queue ! qtimlpostprocess name=stage_01_postproc results=10 module=qpd labels=/etc/labels/foot_track_net.json settings=/etc/labels/foot_track_net_settings.json ! video/x-raw,format=BGRA,width=960,height=540 ! queue ! mixer. Copy to clipboard To stop the use case, use **CTRL + C**. The following figure shows the flow of the use case execution: 1. Identify object scenes from a video stream, which is coming through a file source. 2. Compose bounding boxes over objects detected and original video stream using qtivcomposer. 3. Encode this stream as an H.264 bitstream. 4. Multiplex the stream in an MP4 container and stored as an MP4 file. Qualcomm Open source tee qtimlvconverter qtivcomposer v4l2h264enc h264parse mp4mux filesink qtimlsnpe qtimlpostprocess filesrc qtdemux h264parse v4l2h264dec **Figure : Pipeline for bounding box mask and encode with qtivcomposer** The following table provides the sequential processing stages of the pipeline execution: | Process | Description | | --- | --- | | File source: filesrc |

  1. Captures the video stream using filesrc, followed by qtdemux, which demultiplexes the stream.


  2. Uses tee to split the stream for inferencing.


| | h264parse | Parses the H.264 video. | | [v4l2h264dec](https://docs.qualcomm.com/doc/80-80021-50/topic/v4l2h264dec.html) | Decodes the video. | | **Preprocessing** | **Preprocessing** | | [qtimlvconverter](https://docs.qualcomm.com/doc/80-80021-50/topic/qtimlvconverter.html) |

  1. Receives the video stream on its sink pad.


  2. Performs preprocessing:


    • Color conversion


    • Scaling down/up


    • Normalization on the stream data when the model expects the floating point values as input




  3. Converts the video stream to a tensor stream on its source pad.


    The object detection model uses this tensor stream for inferencing.



| | **Inferencing** | **Inferencing** | | [qtimlsnpe](https://docs.qualcomm.com/doc/80-80021-50/topic/qtimlsnpe.html) |

  1. Loads the object detection model.


  2. Modifies the graph for the chosen delegate.


  3. Receives the tensor stream on its sinkpad.


  4. Runs the inference and produces tensor stream with the object detection results on its source pad.


| | **Postprocessing** | **Postprocessing** | | qtimlpostprocess |

  1. Receives the inference tensors from the object detection model.


  2. Converts the inference tensors on its sinkpad into formats like video or text that the multimedia plugins can process later.


  3. Applies the threshold to the chosen number of results.


  4. Loads the corresponding modules for detection models.


    In this use case, qtimlpostprocess does the following:


    1. Loads the YOLOv8 submodule.


    2. Produces video frames with only bounding boxes that can be overlaid on objects.


    3. Sends them to sinkpad of qtivcomposer.




| | [qtivcomposer](https://docs.qualcomm.com/doc/80-80021-50/topic/qtivcomposer.html) |

  1. Receives the original video stream and video stream with bounding boxes on its sinkpads


  2. On its sourcepads, produces content that's composed of the video streams processed from its sinkpads.


| | [v4l2h264enc](https://docs.qualcomm.com/doc/80-80021-50/topic/v4l2h264enc.html) |

  1. Applies parameters to each frame of the video stream its receiving on its sinkpad.


  2. Encodes it into bitstream and sends it over its sourcepad.


| | h264parse | Adds more information about the bitstream to the GStreamer buffer meta. | | mp4mux | Receives these buffers and creates containers with format specification buffers. | | **Output** | **Output** | | Filesink | Stores the resulting stream in a */etc/media/video.mp4* file. | | Playback | Pull *video.mp4* from the host computer and play it on a media player: `scp root@\:/etc/media/video.mp4 ` | Last Published: Mar 26, 2026 [Previous Topic Object detection and display with Neural Processing SDK](https://docs.qualcomm.com/bundle/publicresource/80-80021-50/topics/single-camera-stream-with-object-detection-and-display-with-mobilenet-v2-ssd.md) [Next Topic Image segmentation and display with Neural Processing SDK](https://docs.qualcomm.com/bundle/publicresource/80-80021-50/topics/single-camera-stream-with-image-segmentation-and-display-with-deeplabv3-quantized.md) Source: [https://docs.qualcomm.com/doc/80-80021-50/topic/single-camera-stream-with-object-detection-and-encode-with-mobilenet-v2-ssd.html](https://docs.qualcomm.com/doc/80-80021-50/topic/single-camera-stream-with-object-detection-and-encode-with-mobilenet-v2-ssd.html)