# 使用 Neural Processing SDK 进行图像分类和编码

Source: [https://docs.qualcomm.com/doc/80-70022-50SC/topic/single-camera-stream-with-image-classification-and-encode-with-mobilenet-v1.html](https://docs.qualcomm.com/doc/80-70022-50SC/topic/single-camera-stream-with-image-classification-and-encode-with-mobilenet-v1.html)

这些用例使用了 Qualcomm Neural Processing SDK 的 InceptionV3 图像分类模型，对单个摄像头流执行场景分类，并叠加或合成分类标签。然后对流进行编码。

您可以将任何公开可用的分类模型与 LiteRT 结合使用，并将其转换为 `.dlc`格式。相关说明，可参见 [TensorFlow 模型转换](https://docs.qualcomm.com/bundle/publicresource/topics/80-63442-2/model_conv_tensorflow.html)。

Note: 对于 Ubuntu Server，需要 `sudo` 访问权限才能将编码流写入 `/etc/media` 文件夹。

## 使用 qtivoverlay 插件来应用分类叠加

在目标设备上运行用例：

    gst-launch-1.0 -e \
    qtiqmmfsrc name=camsrc ! video/x-raw,format=NV12_Q08C,width=1280,height=720,framerate=30/1 ! queue ! tee name=split \
    split. ! queue ! qtimetamux name=metamux ! queue ! qtivoverlay ! queue ! video/x-raw,format=NV12_Q08C,width=1280,height=720,interlace-mode=progressive,colorimetry=bt601 ! \
    v4l2h264enc capture-io-mode=4 output-io-mode=5 ! h264parse ! queue ! mp4mux ! queue ! 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

要停止用例，请使用 CTRL + C。

下图显示了用例执行的流程：

1. 对从摄像头源传来的视频流中的场景进行分类。
2. 使用 overlaylib 叠加分类标签。
3. 将此流编码为 H.264 码流。
4. 多路复用 MP4 容器中的数据流并将其存储为 MP4 文件。

Figure : 分类叠加和编码的 pipeline
                
                <!--?xml version="1.0" encoding="UTF-8" standalone="no"?-->

<!-- Generated by Microsoft Visio, SVG Export pipeline_classification_and_encode_neural.svg pipeline_classification_and_enc -->
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:v="http://schemas.microsoft.com/visio/2003/SVGExtensions/" width="12.2841in" height="3.72433in" viewbox="0 0 884.454 268.152" xml:space="preserve" color-interpolation-filters="sRGB" class="st12"><v:documentproperties v:langid="1033" v:viewmarkup="false"></v:documentproperties>
<style>.svg-1 .st1 { fill: #fafafa; stroke: none; stroke-linecap: butt; stroke-width: 0.75 }
.svg-1 .st2 { fill: #d2d7e1; stroke: none; stroke-linecap: butt; stroke-width: 0.75 }
.svg-1 .st3 { fill: #007884; stroke: none; stroke-linecap: butt; stroke-width: 0.75 }
.svg-1 .st4 { fill: #ffffff; font-family: Roboto; font-size: 1.00001em }
.svg-1 .st5 { fill: #2a2aea; stroke: none; stroke-linecap: butt; stroke-width: 0.75 }
.svg-1 .st6 { stroke: #000000; stroke-linecap: butt; stroke-width: 0.75 }
.svg-1 .st7 { fill: #000000; stroke: none; stroke-linecap: butt; stroke-width: 0.75 }
.svg-1 .st8 { fill: none }
.svg-1 .st9 { fill: none; stroke: none; stroke-linecap: butt; stroke-width: 0.75 }
.svg-1 .st10 { fill: #000000; font-family: Roboto; font-size: 0.874992em }
.svg-1 .st11 { fill: #000000; font-family: SimHei; font-size: 0.874992em }
.svg-1 .st12 { fill: none; fill-rule: evenodd; font-size: 12px; overflow: visible; stroke-linecap: square; stroke-miterlimit: 3 }</style>
<g v:mid="0" v:index="1" v:groupcontext="foregroundPage">	<title>pipeline_classification_and_enc</title>	<v:pageproperties v:drawingscale="1" v:pagescale="1" v:drawingunits="19" v:shadowoffsetx="9" v:shadowoffsety="-9"></v:pageproperties>	<g id="shape3-1" v:mid="3" v:groupcontext="shape" transform="translate(0.374943,-0.375366)">		<title>Sheet.3</title>		<path d="M0 262.53 A5.62513 5.62513 -180 0 0 5.62 268.15 L878.08 268.15 A5.62513 5.62513 -180 0 0 883.7 262.53 L883.7					 6.38 A5.62513 5.62513 -180 0 0 878.08 0.75 L5.62 0.75 A5.62513 5.62513 -180 0 0 0 6.38 L0 262.53 Z" class="st1"></path>	</g>	<g id="shape4-3" v:mid="4" v:groupcontext="shape">		<title>Sheet.4</title>		<path d="M878.45 0.75 C881.35 0.75 883.7 3.11 883.7 6 L883.7 262.15 C883.7 265.05 881.35 267.4 878.45 267.4 L6 267.4					 C3.11 267.4 0.75 265.05 0.75 262.15 L0.75 6 C0.75 3.11 3.11 0.75 6 0.75 L878.45 0.75 ZM878.45 0 L6 0 C2.69					 0 0 2.69 0 6 L0 262.15 C0 265.47 2.69 268.15 6 268.15 L878.45 268.15 C881.77 268.15 884.45 265.47 884.45					 262.15 L884.45 6 C884.45 2.69 881.77 0 878.45 0 Z" class="st2"></path>	</g>	<g id="shape14-5" v:mid="14" v:groupcontext="shape" transform="translate(15,-215.652)">		<title>Sheet.14</title>		<desc>camsrc</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="45" cy="249.402" width="90" height="37.5"></v:textrect>		<path d="M0 265.15 A3.00007 3.00007 -180 0 0 3 268.15 L87 268.15 A3.00007 3.00007 -180 0 0 90 265.15 L90 233.65 A3.00007					 3.00007 -180 0 0 87 230.65 L3 230.65 A3.00007 3.00007 -180 0 0 -0 233.65 L0 265.15 Z" class="st3"></path>		<text x="25.07" y="253" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>camsrc</text>		</g>	<g id="shape17-8" v:mid="17" v:groupcontext="shape" transform="translate(124.551,-215.652)">		<title>Sheet.17</title>		<desc>tee</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="45" cy="249.402" width="90" height="37.5"></v:textrect>		<path d="M0 265.15 A3.00007 3.00007 -180 0 0 3 268.15 L87 268.15 A3.00007 3.00007 -180 0 0 90 265.15 L90 233.65 A3.00007					 3.00007 -180 0 0 87 230.65 L3 230.65 A3.00007 3.00007 -180 0 0 -0 233.65 L0 265.15 Z" class="st3"></path>		<text x="36.68" y="253" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>tee</text>		</g>	<g id="shape20-11" v:mid="20" v:groupcontext="shape" transform="translate(109.551,-158.021)">		<title>Sheet.20</title>		<desc>qtimlvconverter</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="60" cy="249.402" width="120" height="37.5"></v:textrect>		<path d="M-0 265.15 A3.00007 3.00007 -180 0 0 3 268.15 L117 268.15 A3.00007 3.00007 -180 0 0 120 265.15 L120 233.65 A3.00007					 3.00007 -180 0 0 117 230.65 L3 230.65 A3.00007 3.00007 -180 0 0 0 233.65 L0 265.15 Z" class="st5"></path>		<text x="18.39" y="253" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>qtimlvconverter</text>		</g>	<g id="shape23-14" v:mid="23" v:groupcontext="shape" transform="translate(105.401,-234.402)">		<title>Sheet.23</title>		<path d="M0 268.15 L14.98 268.15" class="st6"></path>	</g>	<g id="shape24-17" v:mid="24" v:groupcontext="shape" transform="translate(119.617,-231.784)">		<title>Sheet.24</title>		<path d="M0 268.15 L4.53 265.53 L0 262.92 L0 268.15 Z" class="st7"></path>	</g>	<g id="shape26-19" v:mid="26" v:groupcontext="shape" transform="translate(233.702,-215.652)">		<title>Sheet.26</title>		<desc>qtimetamux</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="45" cy="249.402" width="90.01" height="37.5"></v:textrect>		<path d="M0 265.15 A3.00007 3.00007 -180 0 0 3 268.15 L87 268.15 A3.00007 3.00007 -180 0 0 90 265.15 L90 233.65 A3.00007					 3.00007 -180 0 0 87 230.65 L3 230.65 A3.00007 3.00007 -180 0 0 -0 233.65 L0 265.15 Z" class="st5"></path>		<text x="12.97" y="253" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>qtimetamux</text>		</g>	<g id="shape29-22" v:mid="29" v:groupcontext="shape" transform="translate(214.551,-234.402)">		<title>Sheet.29</title>		<path d="M0 268.15 L14.98 268.15" class="st6"></path>	</g>	<g id="shape30-25" v:mid="30" v:groupcontext="shape" transform="translate(228.768,-231.784)">		<title>Sheet.30</title>		<path d="M0 268.15 L4.53 265.53 L0 262.92 L0 268.15 Z" class="st7"></path>	</g>	<g id="shape32-27" v:mid="32" v:groupcontext="shape" transform="translate(342.852,-215.652)">		<title>Sheet.32</title>		<desc>qtioverlay</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="45" cy="249.402" width="90.01" height="37.5"></v:textrect>		<path d="M0 265.15 A3.00007 3.00007 -180 0 0 3 268.15 L87 268.15 A3.00007 3.00007 -180 0 0 90 265.15 L90 233.65 A3.00007					 3.00007 -180 0 0 87 230.65 L3 230.65 A3.00007 3.00007 -180 0 0 -0 233.65 L0 265.15 Z" class="st5"></path>		<text x="19.08" y="253" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>qtioverlay</text>		</g>	<g id="shape35-30" v:mid="35" v:groupcontext="shape" transform="translate(323.702,-234.402)">		<title>Sheet.35</title>		<path d="M0 268.15 L14.98 268.15" class="st6"></path>	</g>	<g id="shape36-33" v:mid="36" v:groupcontext="shape" transform="translate(337.918,-231.784)">		<title>Sheet.36</title>		<path d="M0 268.15 L4.53 265.53 L0 262.92 L0 268.15 Z" class="st7"></path>	</g>	<g id="shape38-35" v:mid="38" v:groupcontext="shape" transform="translate(452.003,-215.652)">		<title>Sheet.38</title>		<desc>v4l2h264enc</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="45" cy="249.402" width="90" height="37.5"></v:textrect>		<path d="M0 265.15 A3.00007 3.00007 -180 0 0 3 268.15 L87 268.15 A3.00007 3.00007 -180 0 0 90 265.15 L90 233.65 A3.00007					 3.00007 -180 0 0 87 230.65 L3 230.65 A3.00007 3.00007 -180 0 0 -0 233.65 L0 265.15 Z" class="st3"></path>		<text x="10.86" y="253" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>v4l2h264enc</text>		</g>	<g id="shape41-38" v:mid="41" v:groupcontext="shape" transform="translate(432.852,-234.402)">		<title>Sheet.41</title>		<path d="M0 268.15 L14.98 268.15" class="st6"></path>	</g>	<g id="shape42-41" v:mid="42" v:groupcontext="shape" transform="translate(447.069,-231.784)">		<title>Sheet.42</title>		<path d="M0 268.15 L4.53 265.53 L0 262.92 L0 268.15 Z" class="st7"></path>	</g>	<g id="shape44-43" v:mid="44" v:groupcontext="shape" transform="translate(561.153,-215.652)">		<title>Sheet.44</title>		<desc>h264parse</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="45" cy="249.402" width="90.01" height="37.5"></v:textrect>		<path d="M0 265.15 A3.00007 3.00007 -180 0 0 3 268.15 L87 268.15 A3.00007 3.00007 -180 0 0 90 265.15 L90 233.65 A3.00007					 3.00007 -180 0 0 87 230.65 L3 230.65 A3.00007 3.00007 -180 0 0 -0 233.65 L0 265.15 Z" class="st3"></path>		<text x="16.65" y="253" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>h264parse</text>		</g>	<g id="shape47-46" v:mid="47" v:groupcontext="shape" transform="translate(542.003,-234.402)">		<title>Sheet.47</title>		<path d="M0 268.15 L14.98 268.15" class="st6"></path>	</g>	<g id="shape48-49" v:mid="48" v:groupcontext="shape" transform="translate(556.219,-231.784)">		<title>Sheet.48</title>		<path d="M0 268.15 L4.53 265.53 L0 262.92 L0 268.15 Z" class="st7"></path>	</g>	<g id="shape50-51" v:mid="50" v:groupcontext="shape" transform="translate(670.304,-215.652)">		<title>Sheet.50</title>		<desc>mp4mux</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="45" cy="249.402" width="90" height="37.5"></v:textrect>		<path d="M0 265.15 A3.00007 3.00007 -180 0 0 3 268.15 L87 268.15 A3.00007 3.00007 -180 0 0 90 265.15 L90 233.65 A3.00007					 3.00007 -180 0 0 87 230.65 L3 230.65 A3.00007 3.00007 -180 0 0 -0 233.65 L0 265.15 Z" class="st3"></path>		<text x="21.47" y="253" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>mp4mux</text>		</g>	<g id="shape53-54" v:mid="53" v:groupcontext="shape" transform="translate(651.153,-234.402)">		<title>Sheet.53</title>		<path d="M0 268.15 L14.98 268.15" class="st6"></path>	</g>	<g id="shape54-57" v:mid="54" v:groupcontext="shape" transform="translate(665.37,-231.784)">		<title>Sheet.54</title>		<path d="M0 268.15 L4.53 265.53 L0 262.92 L0 268.15 Z" class="st7"></path>	</g>	<g id="shape56-59" v:mid="56" v:groupcontext="shape" transform="translate(779.454,-215.652)">		<title>Sheet.56</title>		<desc>filesink</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="45" cy="249.402" width="90.01" height="37.5"></v:textrect>		<path d="M0 265.15 A3.00007 3.00007 -180 0 0 3 268.15 L87 268.15 A3.00007 3.00007 -180 0 0 90 265.15 L90 233.65 A3.00007					 3.00007 -180 0 0 87 230.65 L3 230.65 A3.00007 3.00007 -180 0 0 -0 233.65 L0 265.15 Z" class="st3"></path>		<text x="25.92" y="253" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>filesink</text>		</g>	<g id="shape59-62" v:mid="59" v:groupcontext="shape" transform="translate(760.304,-234.402)">		<title>Sheet.59</title>		<path d="M0 268.15 L14.98 268.15" class="st6"></path>	</g>	<g id="shape60-65" v:mid="60" v:groupcontext="shape" transform="translate(774.52,-231.784)">		<title>Sheet.60</title>		<path d="M0 268.15 L4.53 265.53 L0 262.92 L0 268.15 Z" class="st7"></path>	</g>	<g id="shape62-67" v:mid="62" v:groupcontext="shape" transform="translate(437.703,52.8462) rotate(90)">		<title>Sheet.62</title>		<path d="M0 268.15 L14.98 268.15" class="st6"></path>	</g>	<g id="shape63-70" v:mid="63" v:groupcontext="shape" transform="translate(166.933,-196.556)">		<title>Sheet.63</title>		<path d="M0 263.62 L2.62 268.15 L5.24 263.62 L0 263.62 Z" class="st7"></path>	</g>	<g id="shape65-72" v:mid="65" v:groupcontext="shape" transform="translate(109.551,-100.319)">		<title>Sheet.65</title>		<desc>qtimlsnpe</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="60" cy="249.402" width="120" height="37.5"></v:textrect>		<path d="M0 265.15 A3.00007 3.00007 -180 0 0 3 268.15 L117 268.15 A3.00007 3.00007 -180 0 0 120 265.15 L120 233.65 A3.00007					 3.00007 -180 0 0 117 230.65 L3 230.65 A3.00007 3.00007 -180 0 0 0 233.65 L0 265.15 Z" class="st5"></path>		<text x="33.51" y="253" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>qtimlsnpe</text>		</g>	<g id="shape68-75" v:mid="68" v:groupcontext="shape" transform="translate(437.703,110.548) rotate(90)">		<title>Sheet.68</title>		<path d="M0 268.15 L14.98 268.15" class="st6"></path>	</g>	<g id="shape69-78" v:mid="69" v:groupcontext="shape" transform="translate(166.933,-138.854)">		<title>Sheet.69</title>		<path d="M0 263.62 L2.62 268.15 L5.24 263.62 L0 263.62 Z" class="st7"></path>	</g>	<g id="shape71-80" v:mid="71" v:groupcontext="shape" transform="translate(109.551,-42)">		<title>Sheet.71</title>		<desc>qtimlpostprocess</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="60" cy="249.402" width="120.01" height="37.5"></v:textrect>		<path d="M0 265.15 A3.00007 3.00007 -180 0 0 3 268.15 L117 268.15 A3.00007 3.00007 -180 0 0 120 265.15 L120 233.65 A3.00007					 3.00007 -180 0 0 117 230.65 L3 230.65 A3.00007 3.00007 -180 0 0 0 233.65 L0 265.15 Z" class="st5"></path>		<text x="13.29" y="253" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>qtimlpostprocess</text>		</g>	<g id="shape74-83" v:mid="74" v:groupcontext="shape" transform="translate(437.703,168.867) rotate(90)">		<title>Sheet.74</title>		<path d="M0 268.15 L14.98 268.15" class="st6"></path>	</g>	<g id="shape75-86" v:mid="75" v:groupcontext="shape" transform="translate(166.933,-80.5347)">		<title>Sheet.75</title>		<path d="M0 263.62 L2.62 268.15 L5.24 263.62 L0 263.62 Z" class="st7"></path>	</g>	<g id="shape77-88" v:mid="77" v:groupcontext="shape" transform="translate(229.551,-60.75)">		<title>Sheet.77</title>		<path d="M0 268.15 L49.15 268.15 L49.15 117.36 L0 268.15 Z" class="st8"></path>		<path d="M0 268.15 L49.15 268.15 L49.15 117.36" class="st6"></path>	</g>	<g id="shape78-91" v:mid="78" v:groupcontext="shape" transform="translate(276.084,-210.772)">		<title>Sheet.78</title>		<path d="M5.24 268.15 L2.62 263.62 L0 268.15 L5.24 268.15 Z" class="st7"></path>	</g>	<g id="group79-93" transform="translate(759.33,-14.7814)" v:mid="79" v:groupcontext="group">		<title>Sheet.79</title>		<g id="shape7-94" v:mid="7" v:groupcontext="shape" transform="translate(15.1883,0)">			<title>Sheet.7</title>			<desc>Qualcomm</desc>			<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>			<v:textrect cx="29.0831" cy="261.852" width="58.17" height="12.6"></v:textrect>			<rect x="0" y="255.552" width="58.1663" height="12.6" class="st9"></rect>			<text x="0" y="265" class="st10" v:langid="1033"><v:paragraph></v:paragraph><v:tablist></v:tablist>Qualcomm  </text>			</g>		<g id="shape8-97" v:mid="8" v:groupcontext="shape" transform="translate(1.26898E-13,-0.218619)">			<title>Sheet.8</title>			<path d="M0 266.65 A1.50003 1.50003 -180 0 0 1.5 268.15 L10.5 268.15 A1.50003 1.50003 -180 0 0 12 266.65 L12 257.65						 A1.50003 1.50003 -180 0 0 10.5 256.15 L1.5 256.15 A1.50003 1.50003 -180 0 0 0 257.65 L0 266.65 Z" class="st5"></path>		</g>		<g id="shape10-99" v:mid="10" v:groupcontext="shape" transform="translate(89.1246,0)">			<title>Sheet.10</title>			<desc>开源</desc>			<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>			<v:textrect cx="10.5" cy="261.852" width="21.01" height="12.6"></v:textrect>			<rect x="0" y="255.552" width="21" height="12.6" class="st9"></rect>			<text x="0" y="265.35" class="st11" v:langid="1033"><v:paragraph></v:paragraph><v:tablist></v:tablist>开源</text>			</g>		<g id="shape11-102" v:mid="11" v:groupcontext="shape" transform="translate(73.9363,-0.218619)">			<title>Sheet.11</title>			<path d="M0 266.65 A1.50003 1.50003 -180 0 0 1.5 268.15 L10.5 268.15 A1.50003 1.50003 -180 0 0 12 266.65 L12 257.65						 A1.50003 1.50003 -180 0 0 10.5 256.15 L1.5 256.15 A1.50003 1.50003 -180 0 0 0 257.65 L0 266.65 Z" class="st3"></path>		</g>	</g></g>
</svg>

下表列出了 pipeline 执行的顺序处理阶段：

| 处理过程 | 说明 |
| --- | --- |
| Source | <ol class="ol" id="single-camera-stream-with-image-classification-and-encode-with-mobilenet-v1__ol_g41_cf5_vbc"><br>                                    <li class="li">视频流从摄像头源插件收集，并创建两个副本：<ul class="ul" id="single-camera-stream-with-image-classification-and-encode-with-mobilenet-v1__ol_kh3_dyv_r1c"><br>                                            <li class="li">一个视频流被发送至 qtimetamux 插件，以保留视频流。</li><br><br>                                            <li class="li">另一个视频流被发送到 ML 推理 pipeline。</li><br><br>                                        </ul><br></li><br><br>                                </ol> |
| **预处理** | **预处理** |
| [qtimlvconverter](https://docs.qualcomm.com/doc/80-70022-50SC/topic/qtimlvconverter.html) | <ol class="ol" id="single-camera-stream-with-image-classification-and-encode-with-mobilenet-v1__ol_xsf_q5l_vbc"><br>                                    <li class="li">在其接收端口上接收视频流。</li><br><br>                                    <li class="li">执行预处理：<ul class="ul" id="single-camera-stream-with-image-classification-and-encode-with-mobilenet-v1__ul_ff2_twl_vbc"><br>                                            <li class="li">颜色转换</li><br><br>                                            <li class="li">缩小/放大</li><br><br>                                            <li class="li">在模型需要浮点值作为输入时，对流数据进行归一化</li><br><br>                                        </ul><br></li><br><br>                                    <li class="li">在其发送端口上将视频流转换为张量数据。<p class="p">分类模型使用此张量数据进行推理。</p><br></li><br><br>                                </ol> |
| **推理** | **推理** |
| [qtimlsnpe](https://docs.qualcomm.com/doc/80-70022-50SC/topic/qtimlsnpe.html) | <ol class="ol" id="single-camera-stream-with-image-classification-and-encode-with-mobilenet-v1__ol_bwn_s5l_vbc"><br>                                    <li class="li">加载模型。</li><br><br>                                    <li class="li">为选择的 delegate 修改图。</li><br><br>                                    <li class="li">在其接收端口上接收张量数据。</li><br><br>                                    <li class="li">执行推理并在其发送端口上生成包含推理结果的张量数据。</li><br><br>                                </ol> |
| **后处理** | **后处理** |
| qtimlpostprocess | <ol class="ol" id="single-camera-stream-with-image-classification-and-encode-with-mobilenet-v1__ol_gr1_w5l_vbc"><br>                                    <li class="li">从其接收端口上的分类模型接收推理张量。</li><br><br>                                    <li class="li">将张量转换为多媒体插件稍后可以处理的视频或文本等格式。 </li><br><br>                                    <li class="li">将阈值应用于所选的结果数。</li><br><br>                                    <li class="li">加载分类模型的相应模块。 <p class="p">在此用例中，qtimlpostprocess 执行以下操作：</p><ol class="ol" type="a" id="single-camera-stream-with-image-classification-and-encode-with-mobilenet-v1__ol_rrb_1xl_vbc"><br>                                            <li class="li">加载模型的子模块。</li><br><br>                                            <li class="li">将结果生成为带有分类标签的视频帧。</li><br><br>                                            <li class="li">接着发送到 qtimetamux 的接收端口。</li><br><br>                                        </ol><br></li><br><br>                                </ol> |
| [qtimetamux](https://docs.qualcomm.com/doc/80-70022-50SC/topic/qtimetamux.html) | <ol class="ol" id="single-camera-stream-with-image-classification-and-encode-with-mobilenet-v1__ol_ll3_x5l_vbc"><br>                                    <li class="li">在接收端口上接收视频流和文本流，以及与视频流相对应的分类结果。</li><br><br>                                    <li class="li">使用接收端口中的视频流内容生成 GST 缓存。</li><br><br>                                    <li class="li">将数据接收端口上的分类结果添加到其发送端口上的 GST 缓存元数据（元数据复用）。</li><br><br>                                </ol> |
| [qtivoverlay](https://docs.qualcomm.com/doc/80-70022-50SC/topic/qtioverlay.html) | <ol class="ol" id="single-camera-stream-with-image-classification-and-encode-with-mobilenet-v1__ol_wst_y5l_vbc"><br>                                    <li class="li">接收多路复用流。</li><br><br>                                    <li class="li">使用 CL 将分类标签叠加在 VideoFrame 上。</li><br><br>                                    <li class="li">在其发送端口上生成带有叠加层的 GST 缓存。</li><br><br>                                </ol> |
| [v4l2h264enc](https://docs.qualcomm.com/doc/80-70022-50SC/topic/v4l2h264enc.html) | <ol class="ol" id="single-camera-stream-with-image-classification-and-encode-with-mobilenet-v1__ol_h41_cf5_vbc"><br>                                    <li class="li">将参数应用于在接收端口上接收到的视频流的每一帧。</li><br><br>                                    <li class="li">将其编码为码流，并通过其发送端口发送。</li><br><br>                                </ol> |
| h264parse | 向 GStreamer 缓存元数据添加更多码流信息。 |
| mp4mux | 接收这些缓存并创建具有格式规范缓存的容器。 |
| **输出** | **输出** |
| Filesink | 将生成的数据流存储在 /etc/media/video.mp4文件中。 |
| Playback | 从主机拉取 video.mp4并在媒体播放器上播放：<br>`scp root@<IP address of<br>                                        target device>:/etc/media/video.mp4 <destination<br>                                        directory>` |

## 使用 qtivcomposer 混合原始帧与分类遮罩

在目标设备上运行用例：

    gst-launch-1.0 -e --gst-debug=2 \
    qtiqmmfsrc name=camsrc ! video/x-raw,format=NV12_Q08C,width=1280,height=720,framerate=30/1 ! queue ! tee name=split \
    split. ! queue ! qtivcomposer name=mixer sink_1::position="<30, 30>" sink_1::dimensions="<320, 180>" ! queue ! video/x-raw,format=NV12,width=1920,height=1080,interlace-mode=progressive,colorimetry=bt601 ! \
    v4l2h264enc capture-io-mode=4 output-io-mode=5 ! h264parse ! queue ! mp4mux ! queue ! 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 ! video/x-raw,format=BGRA,width=640,height=360 ! queue ! mixer.Copy to clipboard

要停止用例，请使用 CTRL + C。

下图显示了用例执行的流程：
- 对从摄像头源传来的视频流中的场景进行分类。
- 使用 qtivcomposer 合成分类标签和视频流。
- 将此流编码为 H.264 码流。
- 多路复用 MP4 容器中的数据流并将其存储为 MP4 文件。

Figure : 使用 qtivcomposer 进行分类和编码的 pipeline
                
                <!--?xml version="1.0" encoding="UTF-8" standalone="no"?-->

<!-- Generated by Microsoft Visio, SVG Export pipeline_classification_encode_qtivcomposer_neural.svg pipeline_classification_encode_ -->
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:v="http://schemas.microsoft.com/visio/2003/SVGExtensions/" width="10.9785in" height="3.72433in" viewbox="0 0 790.451 268.152" xml:space="preserve" color-interpolation-filters="sRGB" class="st12"><v:documentproperties v:langid="1033" v:viewmarkup="false"></v:documentproperties>
<style>.svg-2 .st1 { fill: #fafafa; stroke: none; stroke-linecap: butt; stroke-width: 0.75 }
.svg-2 .st2 { fill: #d2d7e1; stroke: none; stroke-linecap: butt; stroke-width: 0.75 }
.svg-2 .st3 { fill: #007884; stroke: none; stroke-linecap: butt; stroke-width: 0.75 }
.svg-2 .st4 { fill: #ffffff; font-family: Roboto; font-size: 1.00001em }
.svg-2 .st5 { fill: #2a2aea; stroke: none; stroke-linecap: butt; stroke-width: 0.75 }
.svg-2 .st6 { stroke: #000000; stroke-linecap: butt; stroke-width: 0.75 }
.svg-2 .st7 { fill: #000000; stroke: none; stroke-linecap: butt; stroke-width: 0.75 }
.svg-2 .st8 { fill: none }
.svg-2 .st9 { fill: none; stroke: none; stroke-linecap: butt; stroke-width: 0.75 }
.svg-2 .st10 { fill: #000000; font-family: Roboto; font-size: 0.874992em }
.svg-2 .st11 { fill: #000000; font-family: SimHei; font-size: 0.874992em }
.svg-2 .st12 { fill: none; fill-rule: evenodd; font-size: 12px; overflow: visible; stroke-linecap: square; stroke-miterlimit: 3 }</style>
<g v:mid="0" v:index="1" v:groupcontext="foregroundPage">	<title>pipeline_classification_encode_</title>	<v:pageproperties v:drawingscale="1" v:pagescale="1" v:drawingunits="19" v:shadowoffsetx="9" v:shadowoffsety="-9"></v:pageproperties>	<g id="shape3-1" v:mid="3" v:groupcontext="shape" transform="translate(0.3752,-0.375275)">		<title>Sheet.3</title>		<path d="M0 262.53 A5.62513 5.62513 -180 0 0 5.62 268.15 L784.08 268.15 A5.62513 5.62513 -180 0 0 789.7 262.53 L789.7					 6.38 A5.62513 5.62513 -180 0 0 784.08 0.75 L5.62 0.75 A5.62513 5.62513 -180 0 0 0 6.38 L0 262.53 Z" class="st1"></path>	</g>	<g id="shape4-3" v:mid="4" v:groupcontext="shape">		<title>Sheet.4</title>		<path d="M784.45 0.75 C787.35 0.75 789.7 3.11 789.7 6 L789.7 262.15 C789.7 265.05 787.35 267.4 784.45 267.4 L6 267.4					 C3.11 267.4 0.75 265.05 0.75 262.15 L0.75 6 C0.75 3.11 3.11 0.75 6 0.75 L784.45 0.75 ZM784.45 0 L6 0 C2.69					 0 0 2.69 0 6 L0 262.15 C0 265.47 2.69 268.15 6 268.15 L784.45 268.15 C787.76 268.15 790.45 265.47 790.45					 262.15 L790.45 6 C790.45 2.69 787.76 0 784.45 0 Z" class="st2"></path>	</g>	<g id="shape14-5" v:mid="14" v:groupcontext="shape" transform="translate(15,-215.652)">		<title>Sheet.14</title>		<desc>camsrc</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="45" cy="249.402" width="90" height="37.5"></v:textrect>		<path d="M0 265.15 A3.00007 3.00007 -180 0 0 3 268.15 L87 268.15 A3.00007 3.00007 -180 0 0 90 265.15 L90 233.65 A3.00007					 3.00007 -180 0 0 87 230.65 L3 230.65 A3.00007 3.00007 -180 0 0 -0 233.65 L0 265.15 Z" class="st3"></path>		<text x="25.07" y="253" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>camsrc</text>		</g>	<g id="shape17-8" v:mid="17" v:groupcontext="shape" transform="translate(124.551,-215.652)">		<title>Sheet.17</title>		<desc>tee</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="45" cy="249.402" width="90" height="37.5"></v:textrect>		<path d="M0 265.15 A3.00007 3.00007 -180 0 0 3 268.15 L87 268.15 A3.00007 3.00007 -180 0 0 90 265.15 L90 233.65 A3.00007					 3.00007 -180 0 0 87 230.65 L3 230.65 A3.00007 3.00007 -180 0 0 -0 233.65 L0 265.15 Z" class="st3"></path>		<text x="36.68" y="253" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>tee</text>		</g>	<g id="shape20-11" v:mid="20" v:groupcontext="shape" transform="translate(109.551,-158.021)">		<title>Sheet.20</title>		<desc>qtimlvconverter</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="60" cy="249.402" width="120" height="37.5"></v:textrect>		<path d="M-0 265.15 A3.00007 3.00007 -180 0 0 3 268.15 L117 268.15 A3.00007 3.00007 -180 0 0 120 265.15 L120 233.65 A3.00007					 3.00007 -180 0 0 117 230.65 L3 230.65 A3.00007 3.00007 -180 0 0 0 233.65 L0 265.15 Z" class="st5"></path>		<text x="18.39" y="253" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>qtimlvconverter</text>		</g>	<g id="shape23-14" v:mid="23" v:groupcontext="shape" transform="translate(105.401,-234.402)">		<title>Sheet.23</title>		<path d="M0 268.15 L14.98 268.15" class="st6"></path>	</g>	<g id="shape24-17" v:mid="24" v:groupcontext="shape" transform="translate(119.617,-231.784)">		<title>Sheet.24</title>		<path d="M0 268.15 L4.53 265.53 L0 262.92 L0 268.15 Z" class="st7"></path>	</g>	<g id="shape26-19" v:mid="26" v:groupcontext="shape" transform="translate(234.049,-215.652)">		<title>Sheet.26</title>		<desc>qtivcomposer</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="52.5" cy="249.402" width="105" height="37.5"></v:textrect>		<path d="M-0 265.15 A3.00007 3.00007 -180 0 0 3 268.15 L102 268.15 A3.00007 3.00007 -180 0 0 105 265.15 L105 233.65 A3.00007					 3.00007 -180 0 0 102 230.65 L3 230.65 A3.00007 3.00007 -180 0 0 -0 233.65 L0 265.15 Z" class="st5"></path>		<text x="15.85" y="253" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>qtivcomposer</text>		</g>	<g id="shape29-22" v:mid="29" v:groupcontext="shape" transform="translate(214.551,-234.402)">		<title>Sheet.29</title>		<path d="M0 268.15 L14.98 268.15" class="st6"></path>	</g>	<g id="shape30-25" v:mid="30" v:groupcontext="shape" transform="translate(228.768,-231.784)">		<title>Sheet.30</title>		<path d="M0 268.15 L4.53 265.53 L0 262.92 L0 268.15 Z" class="st7"></path>	</g>	<g id="shape32-27" v:mid="32" v:groupcontext="shape" transform="translate(339.049,-234.402)">		<title>Sheet.32</title>		<path d="M0 268.15 L14.98 268.15" class="st6"></path>	</g>	<g id="shape33-30" v:mid="33" v:groupcontext="shape" transform="translate(353.265,-231.784)">		<title>Sheet.33</title>		<path d="M0 268.15 L4.53 265.53 L0 262.92 L0 268.15 Z" class="st7"></path>	</g>	<g id="shape35-32" v:mid="35" v:groupcontext="shape" transform="translate(357.999,-215.652)">		<title>Sheet.35</title>		<desc>v4l2h264enc</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="45" cy="249.402" width="90" height="37.5"></v:textrect>		<path d="M0 265.15 A3.00007 3.00007 -180 0 0 3 268.15 L87 268.15 A3.00007 3.00007 -180 0 0 90 265.15 L90 233.65 A3.00007					 3.00007 -180 0 0 87 230.65 L3 230.65 A3.00007 3.00007 -180 0 0 -0 233.65 L0 265.15 Z" class="st3"></path>		<text x="10.86" y="253" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>v4l2h264enc</text>		</g>	<g id="shape38-35" v:mid="38" v:groupcontext="shape" transform="translate(467.15,-215.652)">		<title>Sheet.38</title>		<desc>h264parse</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="45" cy="249.402" width="90.01" height="37.5"></v:textrect>		<path d="M0 265.15 A3.00007 3.00007 -180 0 0 3 268.15 L87 268.15 A3.00007 3.00007 -180 0 0 90 265.15 L90 233.65 A3.00007					 3.00007 -180 0 0 87 230.65 L3 230.65 A3.00007 3.00007 -180 0 0 -0 233.65 L0 265.15 Z" class="st3"></path>		<text x="16.65" y="253" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>h264parse</text>		</g>	<g id="shape41-38" v:mid="41" v:groupcontext="shape" transform="translate(447.999,-234.402)">		<title>Sheet.41</title>		<path d="M0 268.15 L14.98 268.15" class="st6"></path>	</g>	<g id="shape42-41" v:mid="42" v:groupcontext="shape" transform="translate(462.215,-231.784)">		<title>Sheet.42</title>		<path d="M0 268.15 L4.53 265.53 L0 262.92 L0 268.15 Z" class="st7"></path>	</g>	<g id="shape44-43" v:mid="44" v:groupcontext="shape" transform="translate(576.3,-215.652)">		<title>Sheet.44</title>		<desc>mp4mux</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="45" cy="249.402" width="90" height="37.5"></v:textrect>		<path d="M0 265.15 A3.00007 3.00007 -180 0 0 3 268.15 L87 268.15 A3.00007 3.00007 -180 0 0 90 265.15 L90 233.65 A3.00007					 3.00007 -180 0 0 87 230.65 L3 230.65 A3.00007 3.00007 -180 0 0 -0 233.65 L0 265.15 Z" class="st3"></path>		<text x="21.47" y="253" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>mp4mux</text>		</g>	<g id="shape47-46" v:mid="47" v:groupcontext="shape" transform="translate(557.149,-234.402)">		<title>Sheet.47</title>		<path d="M0 268.15 L14.98 268.15" class="st6"></path>	</g>	<g id="shape48-49" v:mid="48" v:groupcontext="shape" transform="translate(571.366,-231.784)">		<title>Sheet.48</title>		<path d="M0 268.15 L4.53 265.53 L0 262.92 L0 268.15 Z" class="st7"></path>	</g>	<g id="shape50-51" v:mid="50" v:groupcontext="shape" transform="translate(685.451,-215.652)">		<title>Sheet.50</title>		<desc>filesink</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="45" cy="249.402" width="90.01" height="37.5"></v:textrect>		<path d="M-0 265.15 A3.00007 3.00007 -180 0 0 3 268.15 L87 268.15 A3.00007 3.00007 -180 0 0 90 265.15 L90 233.65 A3.00007					 3.00007 -180 0 0 87 230.65 L3 230.65 A3.00007 3.00007 -180 0 0 -0 233.65 L0 265.15 Z" class="st3"></path>		<text x="25.92" y="253" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>filesink</text>		</g>	<g id="shape53-54" v:mid="53" v:groupcontext="shape" transform="translate(666.3,-234.402)">		<title>Sheet.53</title>		<path d="M0 268.15 L14.98 268.15" class="st6"></path>	</g>	<g id="shape54-57" v:mid="54" v:groupcontext="shape" transform="translate(680.517,-231.784)">		<title>Sheet.54</title>		<path d="M0 268.15 L4.53 265.53 L0 262.92 L0 268.15 Z" class="st7"></path>	</g>	<g id="shape56-59" v:mid="56" v:groupcontext="shape" transform="translate(437.703,52.8461) rotate(90)">		<title>Sheet.56</title>		<path d="M0 268.15 L14.98 268.15" class="st6"></path>	</g>	<g id="shape57-62" v:mid="57" v:groupcontext="shape" transform="translate(166.933,-196.555)">		<title>Sheet.57</title>		<path d="M0 263.62 L2.62 268.15 L5.24 263.62 L0 263.62 Z" class="st7"></path>	</g>	<g id="shape59-64" v:mid="59" v:groupcontext="shape" transform="translate(109.551,-100.319)">		<title>Sheet.59</title>		<desc>qtimlsnpe</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="60" cy="249.402" width="120.01" height="37.5"></v:textrect>		<path d="M0 265.15 A3.00007 3.00007 -180 0 0 3 268.15 L117 268.15 A3.00007 3.00007 -180 0 0 120 265.15 L120 233.65 A3.00007					 3.00007 -180 0 0 117 230.65 L3 230.65 A3.00007 3.00007 -180 0 0 0 233.65 L0 265.15 Z" class="st5"></path>		<text x="33.51" y="253" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>qtimlsnpe</text>		</g>	<g id="shape62-67" v:mid="62" v:groupcontext="shape" transform="translate(437.703,110.548) rotate(90)">		<title>Sheet.62</title>		<path d="M0 268.15 L14.98 268.15" class="st6"></path>	</g>	<g id="shape63-70" v:mid="63" v:groupcontext="shape" transform="translate(166.933,-138.854)">		<title>Sheet.63</title>		<path d="M0 263.62 L2.62 268.15 L5.24 263.62 L0 263.62 Z" class="st7"></path>	</g>	<g id="shape65-72" v:mid="65" v:groupcontext="shape" transform="translate(109.551,-42)">		<title>Sheet.65</title>		<desc>qtimlpostprocess</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="60" cy="249.402" width="120.01" height="37.5"></v:textrect>		<path d="M0 265.15 A3.00007 3.00007 -180 0 0 3 268.15 L117 268.15 A3.00007 3.00007 -180 0 0 120 265.15 L120 233.65 A3.00007					 3.00007 -180 0 0 117 230.65 L3 230.65 A3.00007 3.00007 -180 0 0 0 233.65 L0 265.15 Z" class="st5"></path>		<text x="13.29" y="253" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>qtimlpostprocess</text>		</g>	<g id="shape68-75" v:mid="68" v:groupcontext="shape" transform="translate(437.703,168.867) rotate(90)">		<title>Sheet.68</title>		<path d="M0 268.15 L14.98 268.15" class="st6"></path>	</g>	<g id="shape69-78" v:mid="69" v:groupcontext="shape" transform="translate(166.933,-80.5346)">		<title>Sheet.69</title>		<path d="M0 263.62 L2.62 268.15 L5.24 263.62 L0 263.62 Z" class="st7"></path>	</g>	<g id="shape71-80" v:mid="71" v:groupcontext="shape" transform="translate(229.551,-60.75)">		<title>Sheet.71</title>		<path d="M0 268.15 L49.15 268.15 L49.15 117.36 L0 268.15 Z" class="st8"></path>		<path d="M0 268.15 L49.15 268.15 L49.15 117.36" class="st6"></path>	</g>	<g id="shape72-83" v:mid="72" v:groupcontext="shape" transform="translate(276.084,-210.772)">		<title>Sheet.72</title>		<path d="M5.24 268.15 L2.62 263.62 L0 268.15 L5.24 268.15 Z" class="st7"></path>	</g>	<g id="group73-85" transform="translate(665.326,-14.7814)" v:mid="73" v:groupcontext="group">		<title>Sheet.73</title>		<g id="shape7-86" v:mid="7" v:groupcontext="shape" transform="translate(15.1883,0)">			<title>Sheet.7</title>			<desc>Qualcomm</desc>			<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>			<v:textrect cx="27.1848" cy="261.852" width="54.37" height="12.6"></v:textrect>			<rect x="0" y="255.552" width="54.3696" height="12.6" class="st9"></rect>			<text x="-0" y="265" class="st10" v:langid="1033"><v:paragraph></v:paragraph><v:tablist></v:tablist>Qualcomm  </text>			</g>		<g id="shape8-89" v:mid="8" v:groupcontext="shape" transform="translate(6.29496E-14,-0.218619)">			<title>Sheet.8</title>			<path d="M0 266.65 A1.50003 1.50003 -180 0 0 1.5 268.15 L10.5 268.15 A1.50003 1.50003 -180 0 0 12 266.65 L12 257.65						 A1.50003 1.50003 -180 0 0 10.5 256.15 L1.5 256.15 A1.50003 1.50003 -180 0 0 0 257.65 L0 266.65 Z" class="st5"></path>		</g>		<g id="shape10-91" v:mid="10" v:groupcontext="shape" transform="translate(89.1246,0)">			<title>Sheet.10</title>			<desc>开源</desc>			<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>			<v:textrect cx="10.5" cy="261.852" width="21.01" height="12.6"></v:textrect>			<rect x="0" y="255.552" width="21" height="12.6" class="st9"></rect>			<text x="-0" y="265.35" class="st11" v:langid="1033"><v:paragraph></v:paragraph><v:tablist></v:tablist>开源</text>			</g>		<g id="shape11-94" v:mid="11" v:groupcontext="shape" transform="translate(73.9363,-0.218619)">			<title>Sheet.11</title>			<path d="M0 266.65 A1.50003 1.50003 -180 0 0 1.5 268.15 L10.5 268.15 A1.50003 1.50003 -180 0 0 12 266.65 L12 257.65						 A1.50003 1.50003 -180 0 0 10.5 256.15 L1.5 256.15 A1.50003 1.50003 -180 0 0 0 257.65 L0 266.65 Z" class="st3"></path>		</g>	</g></g>
</svg>

下表列出了 pipeline 执行的顺序处理阶段：

| 处理过程 | 说明 |
| --- | --- |
| Source | <ol class="ol" id="single-camera-stream-with-image-classification-and-encode-with-mobilenet-v1__ol_acs_jk5_vbc"><br>                                    <li class="li">视频流从摄像头源插件收集，并创建两个副本：<ul class="ul" id="single-camera-stream-with-image-classification-and-encode-with-mobilenet-v1__ul_bcs_jk5_vbc"><br>                                            <li class="li">一个视频流被发送到 qtivcomposer 插件以保留视频流。</li><br><br>                                            <li class="li">另一个视频流被发送到 ML 推理 pipeline。</li><br><br>                                        </ul><br></li><br><br>                                </ol> |
| **预处理** | **预处理** |
| [qtimlvconverter](https://docs.qualcomm.com/doc/80-70022-50SC/topic/qtimlvconverter.html) | <ol class="ol" id="single-camera-stream-with-image-classification-and-encode-with-mobilenet-v1__ol_ccs_jk5_vbc"><br>                                    <li class="li">在其接收端口上接收视频流。</li><br><br>                                    <li class="li">执行预处理：<ul class="ul" id="single-camera-stream-with-image-classification-and-encode-with-mobilenet-v1__ul_dcs_jk5_vbc"><br>                                            <li class="li">颜色转换</li><br><br>                                            <li class="li">缩小/放大</li><br><br>                                            <li class="li">在模型需要浮点值作为输入时，对流数据进行归一化</li><br><br>                                        </ul><br></li><br><br>                                    <li class="li">在其发送端口上将视频流转换为张量数据。<p class="p">分类模型使用此张量数据进行推理。</p><br></li><br><br>                                </ol> |
| **推理** | **推理** |
| [qtimlsnpe](https://docs.qualcomm.com/doc/80-70022-50SC/topic/qtimlsnpe.html) | <ol class="ol" id="single-camera-stream-with-image-classification-and-encode-with-mobilenet-v1__ol_ecs_jk5_vbc"><br>                                    <li class="li">加载模型。</li><br><br>                                    <li class="li">为选择的 delegate 修改图。</li><br><br>                                    <li class="li">在其接收端口上接收张量数据。</li><br><br>                                    <li class="li">执行推理并在其发送端口上生成包含推理结果的张量数据。</li><br><br>                                </ol> |
| **后处理** | **后处理** |
| qtimlpostprocess | <ol class="ol" id="single-camera-stream-with-image-classification-and-encode-with-mobilenet-v1__ol_fcs_jk5_vbc"><br>                                    <li class="li">从其接收端口上的分类模型接收推理张量。</li><br><br>                                    <li class="li">将张量转换为多媒体插件稍后可以处理的视频或文本等格式。 </li><br><br>                                    <li class="li">将阈值应用于所选的结果数。</li><br><br>                                    <li class="li">加载分类模型的相应模块。 <p class="p">在此用例中，qtimlpostprocess 执行以下操作：</p><ol class="ol" type="a" id="single-camera-stream-with-image-classification-and-encode-with-mobilenet-v1__ol_gcs_jk5_vbc"><br>                                            <li class="li">加载模型的子模块。</li><br><br>                                            <li class="li">将结果生成为带有分类标签的视频帧。</li><br><br>                                            <li class="li">将它们发送至 qtivcomposer 的接收端口。</li><br><br>                                        </ol><br></li><br><br>                                </ol> |
| [qtivcomposer](https://docs.qualcomm.com/doc/80-70022-50SC/topic/qtivcomposer.html) | <ol class="ol" id="single-camera-stream-with-image-classification-and-encode-with-mobilenet-v1__ol_gv1_wjk_5bc"><br>                                    <li class="li">在其接收端口上接收原始视频流和带有分类结果的视频流。 </li><br><br>                                    <li class="li">在其发送端口上生成 GST 缓存，其内容由来自其接收端的视频流组成。</li><br><br>                                </ol> |
| [v4l2h264enc](https://docs.qualcomm.com/doc/80-70022-50SC/topic/v4l2h264enc.html) | <ol class="ol" id="single-camera-stream-with-image-classification-and-encode-with-mobilenet-v1__ol_jcs_jk5_vbc"><br>                                    <li class="li">将参数应用于在接收端口上接收到的视频流的每一帧。</li><br><br>                                    <li class="li">将其编码为码流，并通过其发送端口发送。</li><br><br>                                </ol> |
| h264parse | 向 GStreamer 缓存元数据添加更多码流信息。 |
| mp4mux | 接收这些缓存并创建具有格式规范缓存的容器。 |
| **输出** | **输出** |
| Filesink | 将生成的数据流存储在 /etc/media/video.mp4文件中。 |
| Playback | 从主机拉取 video.mp4并在媒体播放器上播放：<br>`scp root@<IP address of<br>                                        target device>:/etc/media/video.mp4 <destination<br>                                        directory>` |

**Parent Topic:** [Qualcomm Neural Processing SDK 用例](https://docs.qualcomm.com/doc/80-70022-50SC/topic/qualcomm-neural-processing-sdk-use-cases.html)

Last Published: Nov 05, 2025

[Previous Topic
使用 Neural Processing SDK 进行图像分类和显示](https://docs.qualcomm.com/bundle/publicresource/80-70022-50SC/topics/single-camera-stream-with-image-classification-and-display-with-mobilenet-v1.md) [Next Topic
使用 Neural Processing SDK 进行目标检测和显示](https://docs.qualcomm.com/bundle/publicresource/80-70022-50SC/topics/single-camera-stream-with-object-detection-and-display-with-mobilenet-v2-ssd.md)