# Image classification and encode with Neural Processing SDK The use cases implement the InceptionV3 image classification model with Qualcomm Neural Processing SDK to classify scenes from a single camera stream and either overlay or compose the classification labels. The streams are then encoded. You can use any publicly available classification model with LiteRT and convert it to `.dlc` format. For instructions, see [TensorFlow Model Conversion](https://docs.qualcomm.com/bundle/publicresource/topics/80-63442-2/model_conv_tensorflow.html). ## Use qtivoverlay plugin to apply classification overlay Run the use case on the target device: gst-launch-1.0 -e filesrc location=/etc/media/video.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=/etc/media/video.mp4 \ split. ! queue ! qtimlvconverter ! queue ! qtimlsnpe delegate=dsp model=/etc/ models/inceptionv3.dlc ! queue ! qtimlpostprocess \ settings="{\"confidence\": 40.0}" results=2 module=mobilenet-softmax labels=/etc/labels/classification.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. Classify scenes from a video stream coming through a file source. 2. Overlay the classification labels using overlaylib. 3. Encode this stream as an H.264 bitstream. 4. Multiplex the stream in an MP4 container and store it as an MP4 file. **Figure : Pipeline for classification overlay and encode** The following table provides the sequential processing stages of the pipeline execution: | Process | Description | | --- | --- | | File source: filesrc |
Captures the video stream using filesrc, followed by qtdemux, which demultiplexes the stream.
Uses tee to split the stream for inferencing.
Receives the video stream on its sink pad.
Color conversion
Scaling down/up
Normalization on the stream data when the model expects the floating point values as input
Converts the video stream to a tensor stream on its source pad.
The classification model uses this tensor stream for inferencing.
Loads the model.
Modifies the graph for the chosen delegate.
Receives the tensor stream on its sinkpad.
Runs the inference and produces a tensor stream with the inference results on its source pad.
Receives the inference tensors from a classification model on its sinkpad.
Converts the tensors into formats such as video or text that the multimedia plugins can process later.
Applies the threshold to the chosen number of results.
Loads the corresponding modules of the classification models.
In this use case, qtimlpostprocess does the following:
Loads the submodule of the model.
Produces results as video frames with classification labels.
Sends them to the sinkpad of qtimetamux.
Receives the video and text streams with the classification results corresponding to the video stream on its sinkpads.
Produces GST buffers with the contents of the video stream on its sink pad.
Adds classification result from the data sinkpad to GST buffer meta (meta muxing) on its source pad.
Receives the multiplexed stream.
Overlays the classification labels on the VideoFrame using CL.
Produces GST buffers with overlays in its source pad.
Applies parameters to each frame of the video stream it's receiving on its sinkpad.
Encodes it into bitstream and sends it over its sourcepad.
Captures the video stream using filesrc, followed by qtdemux, which demultiplexes the stream.
Uses tee to split the stream for inferencing.
Receives the video stream on its sink pad.
Color conversion
Scaling down/up
Normalization on the stream data when the model expects the floating point values as input
Converts the video stream to a tensor stream on its source pad.
The classification model uses this tensor stream for inferencing.
Loads the model.
Modifies the graph for the chosen delegate.
Receives the tensor stream on its sinkpad.
Runs the inference and produces a tensor stream with the inference results on its source pad.
Receives the inference tensors from a classification model on its sinkpad.
Converts the tensors into formats such as video or text that the multimedia plugins can process later.
Applies the threshold to the chosen number of results.
Loads the corresponding modules of the classification models.
In this use case, qtimlpostprocess does the following:
Loads the submodule of the model.
Produces results as video frames with classification labels.
Sends them to the sinkpad of qtivcomposer.
Receives original video stream and video stream with classification results on its sinkpads.
On its sourcepad, produces GST buffers with the contents composed of video streams from its sinkpads.
Applies parameters to each frame of the video stream it's receiving on its sinkpad.
Encodes it into bitstream and sends it over its sourcepad.