# 使用 LiteRT 进行图像分类和显示

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

这些用例使用 Inceptionv3 LiteRT 模型对单个摄像头流中的场景进行分类，并叠加或合成分类标签。

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

在目标设备上运行此用例：

    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 ! qtimetamux name=metamux ! queue ! qtivoverlay ! queue ! waylandsink fullscreen=true \
    split. ! queue ! qtimlvconverter ! queue ! qtimltflite delegate=external external-delegate-path=libQnnTFLiteDelegate.so \
    external-delegate-options="QNNExternalDelegate,backend_type=htp;" model=/etc/models/inception_v3_quantized.tflite ! 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. 显示结果。

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

<!-- Generated by Microsoft Visio, SVG Export pipeline_classification_overlay.svg pipeline_classification_overlay -->
<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="7.86458in" height="3.64557in" viewbox="0 0 566.25 262.481" 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 { stroke: #000000; stroke-linecap: butt; stroke-width: 0.75 }
.svg-1 .st6 { fill: #000000; stroke: none; stroke-linecap: butt; stroke-width: 0.75 }
.svg-1 .st7 { fill: #2a2aea; 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_overlay</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.375,-0.37516)">		<title>Sheet.3</title>		<path d="M0 256.86 A5.62513 5.62513 -180 0 0 5.62 262.48 L559.87 262.48 A5.62513 5.62513 -180 0 0 565.5 256.86 L565.5					 6.37 A5.62513 5.62513 -180 0 0 559.87 0.75 L5.62 0.75 A5.62513 5.62513 -180 0 0 -0 6.37 L0 256.86 Z" class="st1"></path>	</g>	<g id="shape4-3" v:mid="4" v:groupcontext="shape">		<title>Sheet.4</title>		<path d="M560.25 0.75 C563.14 0.75 565.5 3.11 565.5 6 L565.5 256.48 C565.5 259.38 563.14 261.73 560.25 261.73 L6 261.73					 C3.11 261.73 0.75 259.38 0.75 256.48 L0.75 6 C0.75 3.11 3.11 0.75 6 0.75 L560.25 0.75 ZM560.25 0 L6 0 C2.69					 0 0 2.69 0 6 L0 256.48 C0 259.79 2.69 262.48 6 262.48 L560.25 262.48 C563.56 262.48 566.25 259.79 566.25					 256.48 L566.25 6 C566.25 2.69 563.56 0 560.25 0 Z" class="st2"></path>	</g>	<g id="shape15-5" v:mid="15" v:groupcontext="shape" transform="translate(15,-209.981)">		<title>Sheet.15</title>		<desc>camsrc</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="60" cy="243.731" width="120" height="37.5"></v:textrect>		<path d="M0 259.48 A3.00007 3.00007 -180 0 0 3 262.48 L117 262.48 A3.00007 3.00007 -180 0 0 120 259.48 L120 227.98 A3.00007					 3.00007 -180 0 0 117 224.98 L3 224.98 A3.00007 3.00007 -180 0 0 -0 227.98 L0 259.48 Z" class="st3"></path>		<text x="40.07" y="247.33" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>camsrc</text>		</g>	<g id="shape18-8" v:mid="18" v:groupcontext="shape" transform="translate(135,-228.731)">		<title>Sheet.18</title>		<path d="M0 262.48 L14.98 262.48" class="st5"></path>	</g>	<g id="shape19-11" v:mid="19" v:groupcontext="shape" transform="translate(149.217,-226.113)">		<title>Sheet.19</title>		<path d="M0 262.48 L4.53 259.86 L0 257.25 L0 262.48 Z" class="st6"></path>	</g>	<g id="shape21-13" v:mid="21" v:groupcontext="shape" transform="translate(476.231,51.7309) rotate(90)">		<title>Sheet.21</title>		<path d="M0 262.48 L14.98 262.48" class="st5"></path>	</g>	<g id="shape22-16" v:mid="22" v:groupcontext="shape" transform="translate(211.132,-192)">		<title>Sheet.22</title>		<path d="M0 257.95 L2.62 262.48 L5.24 257.95 L0 257.95 Z" class="st6"></path>	</g>	<g id="shape24-18" v:mid="24" v:groupcontext="shape" transform="translate(153.75,-209.981)">		<title>Sheet.24</title>		<desc>tee</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="60" cy="243.731" width="120" height="37.5"></v:textrect>		<path d="M0 259.48 A3.00007 3.00007 -180 0 0 3 262.48 L117 262.48 A3.00007 3.00007 -180 0 0 120 259.48 L120 227.98 A3.00007					 3.00007 -180 0 0 117 224.98 L3 224.98 A3.00007 3.00007 -180 0 0 -0 227.98 L0 259.48 Z" class="st3"></path>		<text x="51.68" y="247.33" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>tee</text>		</g>	<g id="shape27-21" v:mid="27" v:groupcontext="shape" transform="translate(153.75,-154.5)">		<title>Sheet.27</title>		<desc>qtimlvconverter</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="60" cy="243.731" width="120.01" height="37.5"></v:textrect>		<path d="M-0 259.48 A3.00007 3.00007 -180 0 0 3 262.48 L117 262.48 A3.00007 3.00007 -180 0 0 120 259.48 L120 227.98 A3.00007					 3.00007 -180 0 0 117 224.98 L3 224.98 A3.00007 3.00007 -180 0 0 0 227.98 L0 259.48 Z" class="st7"></path>		<text x="18.39" y="247.33" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>qtimlvconverter</text>		</g>	<g id="shape30-24" v:mid="30" v:groupcontext="shape" transform="translate(476.231,107.981) rotate(90)">		<title>Sheet.30</title>		<path d="M0 262.48 L14.98 262.48" class="st5"></path>	</g>	<g id="shape31-27" v:mid="31" v:groupcontext="shape" transform="translate(211.132,-135.75)">		<title>Sheet.31</title>		<path d="M0 257.95 L2.62 262.48 L5.24 257.95 L0 257.95 Z" class="st6"></path>	</g>	<g id="shape33-29" v:mid="33" v:groupcontext="shape" transform="translate(153.75,-98.25)">		<title>Sheet.33</title>		<desc>qtimltflite</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="60" cy="243.731" width="120.01" height="37.5"></v:textrect>		<path d="M0 259.48 A3.00007 3.00007 -180 0 0 3 262.48 L117 262.48 A3.00007 3.00007 -180 0 0 120 259.48 L120 227.98 A3.00007					 3.00007 -180 0 0 117 224.98 L3 224.98 A3.00007 3.00007 -180 0 0 -0 227.98 L0 259.48 Z" class="st7"></path>		<text x="34.36" y="247.33" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>qtimltflite</text>		</g>	<g id="shape36-32" v:mid="36" v:groupcontext="shape" transform="translate(476.231,164.231) rotate(90)">		<title>Sheet.36</title>		<path d="M0 262.48 L14.98 262.48" class="st5"></path>	</g>	<g id="shape37-35" v:mid="37" v:groupcontext="shape" transform="translate(211.132,-79.5)">		<title>Sheet.37</title>		<path d="M0 257.95 L2.62 262.48 L5.24 257.95 L0 257.95 Z" class="st6"></path>	</g>	<g id="shape39-37" v:mid="39" v:groupcontext="shape" transform="translate(153.75,-42)">		<title>Sheet.39</title>		<desc>qtimlpostprocess</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="60" cy="243.731" width="120.01" height="37.5"></v:textrect>		<path d="M0 259.48 A3.00007 3.00007 -180 0 0 3 262.48 L117 262.48 A3.00007 3.00007 -180 0 0 120 259.48 L120 227.98 A3.00007					 3.00007 -180 0 0 117 224.98 L3 224.98 A3.00007 3.00007 -180 0 0 -0 227.98 L0 259.48 Z" class="st7"></path>		<text x="13.29" y="247.33" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>qtimlpostprocess</text>		</g>	<g id="shape42-40" v:mid="42" v:groupcontext="shape" transform="translate(273.75,-228.731)">		<title>Sheet.42</title>		<path d="M0 262.48 L14.98 262.48" class="st5"></path>	</g>	<g id="shape43-43" v:mid="43" v:groupcontext="shape" transform="translate(287.966,-226.113)">		<title>Sheet.43</title>		<path d="M0 262.48 L4.53 259.86 L0 257.25 L0 262.48 Z" class="st6"></path>	</g>	<g id="shape45-45" v:mid="45" v:groupcontext="shape" transform="translate(292.5,-209.981)">		<title>Sheet.45</title>		<desc>qtivcomposer</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="60" cy="243.731" width="120.01" height="37.5"></v:textrect>		<path d="M0 259.48 A3.00007 3.00007 -180 0 0 3 262.48 L117 262.48 A3.00007 3.00007 -180 0 0 120 259.48 L120 227.98 A3.00007					 3.00007 -180 0 0 117 224.98 L3 224.98 A3.00007 3.00007 -180 0 0 0 227.98 L0 259.48 Z" class="st7"></path>		<text x="23.36" y="247.33" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>qtivcomposer</text>		</g>	<g id="shape48-48" v:mid="48" v:groupcontext="shape" transform="translate(412.5,-228.731)">		<title>Sheet.48</title>		<path d="M0 262.48 L14.98 262.48" class="st5"></path>	</g>	<g id="shape49-51" v:mid="49" v:groupcontext="shape" transform="translate(426.716,-226.113)">		<title>Sheet.49</title>		<path d="M0 262.48 L4.53 259.86 L0 257.25 L0 262.48 Z" class="st6"></path>	</g>	<g id="shape51-53" v:mid="51" v:groupcontext="shape" transform="translate(431.25,-209.981)">		<title>Sheet.51</title>		<desc>Waylandsink</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="60" cy="243.731" width="120.01" height="37.5"></v:textrect>		<path d="M0 259.48 A3.00007 3.00007 -180 0 0 3 262.48 L117 262.48 A3.00007 3.00007 -180 0 0 120 259.48 L120 227.98 A3.00007					 3.00007 -180 0 0 117 224.98 L3 224.98 A3.00007 3.00007 -180 0 0 -0 227.98 L0 259.48 Z" class="st3"></path>		<text x="26.26" y="247.33" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>Waylandsink</text>		</g>	<g id="shape54-56" v:mid="54" v:groupcontext="shape" transform="translate(273.75,-58.9772)">		<title>Sheet.54</title>		<path d="M0 262.48 L78.75 262.48 L78.75 115.17 L0 262.48 Z" class="st8"></path>		<path d="M0 262.48 L78.75 262.48 L78.75 115.17" class="st5"></path>	</g>	<g id="shape55-59" v:mid="55" v:groupcontext="shape" transform="translate(349.882,-205.523)">		<title>Sheet.55</title>		<path d="M5.24 262.48 L2.62 257.95 L0 262.48 L5.24 262.48 Z" class="st6"></path>	</g>	<g id="group56-61" transform="translate(441.125,-14.7814)" v:mid="56" v:groupcontext="group">		<title>Sheet.56</title>		<g id="shape7-62" 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="26.4401" cy="256.181" width="52.89" height="12.6"></v:textrect>			<rect x="0" y="249.881" width="52.8803" height="12.6" class="st9"></rect>			<text x="0" y="259.33" class="st10" v:langid="1033"><v:paragraph></v:paragraph><v:tablist></v:tablist>Qualcomm  </text>			</g>		<g id="shape8-65" v:mid="8" v:groupcontext="shape" transform="translate(3.09752E-14,-0.218607)">			<title>Sheet.8</title>			<path d="M0 260.98 A1.50003 1.50003 -180 0 0 1.5 262.48 L10.5 262.48 A1.50003 1.50003 -180 0 0 12 260.98 L12 251.98						 A1.50003 1.50003 -180 0 0 10.5 250.48 L1.5 250.48 A1.50003 1.50003 -180 0 0 -0 251.98 L0 260.98 Z" class="st7"></path>		</g>		<g id="shape10-67" 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="256.181" width="21" height="12.6"></v:textrect>			<rect x="0" y="249.881" width="21" height="12.6" class="st9"></rect>			<text x="0" y="259.68" class="st11" v:langid="1033"><v:paragraph></v:paragraph><v:tablist></v:tablist>开源</text>			</g>		<g id="shape11-70" v:mid="11" v:groupcontext="shape" transform="translate(73.9363,-0.218607)">			<title>Sheet.11</title>			<path d="M0 260.98 A1.50003 1.50003 -180 0 0 1.5 262.48 L10.5 262.48 A1.50003 1.50003 -180 0 0 12 260.98 L12 251.98						 A1.50003 1.50003 -180 0 0 10.5 250.48 L1.5 250.48 A1.50003 1.50003 -180 0 0 -0 251.98 L0 260.98 Z" class="st3"></path>		</g>	</g></g>
</svg>

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

| 处理过程 | 说明 |
| --- | --- |
| [qtiqmmfsrc](https://docs.qualcomm.com/doc/80-70022-50SC/topic/qtiqmmfsrc.html) | <ol class="ol" id="single-camera-stream-with-image-classification-and-display__ol_l2f_zgm_vbc"><br>                                        <li class="li">采集视频流（源）并创建源的两个副本：<ul class="ul" id="single-camera-stream-with-image-classification-and-display__ol_m2f_zgm_vbc"><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-display__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-display__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> |
| **推理** | **推理** |
| [qtimltflite](https://docs.qualcomm.com/doc/80-70022-50SC/topic/qtimltflite.html) | <ol class="ol" id="single-camera-stream-with-image-classification-and-display__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-display__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-display__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-display__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-display__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> |
| **输出** | **输出** |
| [Waylandsink](https://docs.qualcomm.com/doc/80-70022-50SC/topic/waylandsink.html) | <ol class="ol" id="single-camera-stream-with-image-classification-and-display__ol_wx3_3lh_tfc"><br>                                        <li class="li">在其接收端口上接收视频流。</li><br><br>                                        <li class="li">将视频流提交到 Weston。 </li><br><br>                                        <li class="li">Weston 在本地显示设备上渲染视频流和为该场景生成的可能分类。</li><br><br>                                    </ol> |

## 使用 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="<480, 480>" ! queue ! waylandsink fullscreen=true \
    split. ! queue ! qtimlvconverter ! queue ! qtimltflite delegate=external external-delegate-path=libQnnTFLiteDelegate.so \
    external-delegate-options="QNNExternalDelegate,backend_type=htp;" model=/etc/models/inception_v3_quantized.tflite ! queue ! \
    qtimlpostprocess settings="{\"confidence\": 40.0}" results=2 module=mobilenet-softmax labels=/etc/labels/classification.json ! \
    video/x-raw,format=BGRA,width=640,height=480 ! queue ! mixer.Copy to clipboard

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

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

1. 对从摄像头源传来的视频流中的场景进行分类。
2. 使用 qtivcomposer 合成分类标签和视频流。
3. 显示结果。

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

<!-- Generated by Microsoft Visio, SVG Export pipeline_classification_with_qtivecomposer.svg pipeline_classification_with_qt -->
<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="7.86458in" height="3.64557in" viewbox="0 0 566.25 262.481" 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 { stroke: #000000; stroke-linecap: butt; stroke-width: 0.75 }
.svg-2 .st6 { fill: #000000; stroke: none; stroke-linecap: butt; stroke-width: 0.75 }
.svg-2 .st7 { fill: #2a2aea; 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_with_qt</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.375,-0.375137)">		<title>Sheet.3</title>		<path d="M0 256.86 A5.62513 5.62513 -180 0 0 5.62 262.48 L559.87 262.48 A5.62513 5.62513 -180 0 0 565.5 256.86 L565.5					 6.37 A5.62513 5.62513 -180 0 0 559.87 0.75 L5.62 0.75 A5.62513 5.62513 -180 0 0 -0 6.37 L0 256.86 Z" class="st1"></path>	</g>	<g id="shape4-3" v:mid="4" v:groupcontext="shape">		<title>Sheet.4</title>		<path d="M560.25 0.75 C563.14 0.75 565.5 3.11 565.5 6 L565.5 256.48 C565.5 259.38 563.14 261.73 560.25 261.73 L6 261.73					 C3.11 261.73 0.75 259.38 0.75 256.48 L0.75 6 C0.75 3.11 3.11 0.75 6 0.75 L560.25 0.75 ZM560.25 0 L6 0 C2.69					 0 0 2.69 0 6 L0 256.48 C0 259.79 2.69 262.48 6 262.48 L560.25 262.48 C563.56 262.48 566.25 259.79 566.25					 256.48 L566.25 6 C566.25 2.69 563.56 0 560.25 0 Z" class="st2"></path>	</g>	<g id="shape15-5" v:mid="15" v:groupcontext="shape" transform="translate(15,-209.981)">		<title>Sheet.15</title>		<desc>camsrc</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="60" cy="243.731" width="120" height="37.5"></v:textrect>		<path d="M-0 259.48 A3.00007 3.00007 -180 0 0 3 262.48 L117 262.48 A3.00007 3.00007 -180 0 0 120 259.48 L120 227.98 A3.00007					 3.00007 -180 0 0 117 224.98 L3 224.98 A3.00007 3.00007 -180 0 0 0 227.98 L0 259.48 Z" class="st3"></path>		<text x="40.07" y="247.33" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>camsrc</text>		</g>	<g id="shape18-8" v:mid="18" v:groupcontext="shape" transform="translate(135,-228.731)">		<title>Sheet.18</title>		<path d="M0 262.48 L14.98 262.48" class="st5"></path>	</g>	<g id="shape19-11" v:mid="19" v:groupcontext="shape" transform="translate(149.217,-226.113)">		<title>Sheet.19</title>		<path d="M0 262.48 L4.53 259.86 L0 257.25 L0 262.48 Z" class="st6"></path>	</g>	<g id="shape21-13" v:mid="21" v:groupcontext="shape" transform="translate(476.231,51.7309) rotate(90)">		<title>Sheet.21</title>		<path d="M0 262.48 L14.98 262.48" class="st5"></path>	</g>	<g id="shape22-16" v:mid="22" v:groupcontext="shape" transform="translate(211.132,-192)">		<title>Sheet.22</title>		<path d="M0 257.95 L2.62 262.48 L5.24 257.95 L0 257.95 Z" class="st6"></path>	</g>	<g id="shape24-18" v:mid="24" v:groupcontext="shape" transform="translate(153.75,-209.981)">		<title>Sheet.24</title>		<desc>tee</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="60" cy="243.731" width="120" height="37.5"></v:textrect>		<path d="M-0 259.48 A3.00007 3.00007 -180 0 0 3 262.48 L117 262.48 A3.00007 3.00007 -180 0 0 120 259.48 L120 227.98 A3.00007					 3.00007 -180 0 0 117 224.98 L3 224.98 A3.00007 3.00007 -180 0 0 0 227.98 L0 259.48 Z" class="st3"></path>		<text x="51.68" y="247.33" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>tee</text>		</g>	<g id="shape27-21" v:mid="27" v:groupcontext="shape" transform="translate(153.75,-154.5)">		<title>Sheet.27</title>		<desc>qtimlvconverter</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="60" cy="243.731" width="120.01" height="37.5"></v:textrect>		<path d="M-0 259.48 A3.00007 3.00007 -180 0 0 3 262.48 L117 262.48 A3.00007 3.00007 -180 0 0 120 259.48 L120 227.98 A3.00007					 3.00007 -180 0 0 117 224.98 L3 224.98 A3.00007 3.00007 -180 0 0 0 227.98 L0 259.48 Z" class="st7"></path>		<text x="18.39" y="247.33" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>qtimlvconverter</text>		</g>	<g id="shape30-24" v:mid="30" v:groupcontext="shape" transform="translate(476.231,107.981) rotate(90)">		<title>Sheet.30</title>		<path d="M0 262.48 L14.98 262.48" class="st5"></path>	</g>	<g id="shape31-27" v:mid="31" v:groupcontext="shape" transform="translate(211.132,-135.75)">		<title>Sheet.31</title>		<path d="M0 257.95 L2.62 262.48 L5.24 257.95 L0 257.95 Z" class="st6"></path>	</g>	<g id="shape33-29" v:mid="33" v:groupcontext="shape" transform="translate(153.75,-98.25)">		<title>Sheet.33</title>		<desc>qtimltflite</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="60" cy="243.731" width="120.01" height="37.5"></v:textrect>		<path d="M0 259.48 A3.00007 3.00007 -180 0 0 3 262.48 L117 262.48 A3.00007 3.00007 -180 0 0 120 259.48 L120 227.98 A3.00007					 3.00007 -180 0 0 117 224.98 L3 224.98 A3.00007 3.00007 -180 0 0 0 227.98 L0 259.48 Z" class="st7"></path>		<text x="34.36" y="247.33" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>qtimltflite</text>		</g>	<g id="shape36-32" v:mid="36" v:groupcontext="shape" transform="translate(476.231,164.231) rotate(90)">		<title>Sheet.36</title>		<path d="M0 262.48 L14.98 262.48" class="st5"></path>	</g>	<g id="shape37-35" v:mid="37" v:groupcontext="shape" transform="translate(211.132,-79.5)">		<title>Sheet.37</title>		<path d="M0 257.95 L2.62 262.48 L5.24 257.95 L0 257.95 Z" class="st6"></path>	</g>	<g id="shape39-37" v:mid="39" v:groupcontext="shape" transform="translate(153.75,-42)">		<title>Sheet.39</title>		<desc>qtimlpostprocess</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="60" cy="243.731" width="120.01" height="37.5"></v:textrect>		<path d="M0 259.48 A3.00007 3.00007 -180 0 0 3 262.48 L117 262.48 A3.00007 3.00007 -180 0 0 120 259.48 L120 227.98 A3.00007					 3.00007 -180 0 0 117 224.98 L3 224.98 A3.00007 3.00007 -180 0 0 -0 227.98 L0 259.48 Z" class="st7"></path>		<text x="13.29" y="247.33" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>qtimlpostprocess</text>		</g>	<g id="shape42-40" v:mid="42" v:groupcontext="shape" transform="translate(273.75,-228.731)">		<title>Sheet.42</title>		<path d="M0 262.48 L14.98 262.48" class="st5"></path>	</g>	<g id="shape43-43" v:mid="43" v:groupcontext="shape" transform="translate(287.966,-226.113)">		<title>Sheet.43</title>		<path d="M0 262.48 L4.53 259.86 L0 257.25 L0 262.48 Z" class="st6"></path>	</g>	<g id="shape45-45" v:mid="45" v:groupcontext="shape" transform="translate(292.5,-209.981)">		<title>Sheet.45</title>		<desc>qtivcomposer</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="60" cy="243.731" width="120.01" height="37.5"></v:textrect>		<path d="M0 259.48 A3.00007 3.00007 -180 0 0 3 262.48 L117 262.48 A3.00007 3.00007 -180 0 0 120 259.48 L120 227.98 A3.00007					 3.00007 -180 0 0 117 224.98 L3 224.98 A3.00007 3.00007 -180 0 0 0 227.98 L0 259.48 Z" class="st7"></path>		<text x="23.36" y="247.33" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>qtivcomposer</text>		</g>	<g id="shape48-48" v:mid="48" v:groupcontext="shape" transform="translate(412.5,-228.731)">		<title>Sheet.48</title>		<path d="M0 262.48 L14.98 262.48" class="st5"></path>	</g>	<g id="shape49-51" v:mid="49" v:groupcontext="shape" transform="translate(426.716,-226.113)">		<title>Sheet.49</title>		<path d="M0 262.48 L4.53 259.86 L0 257.25 L0 262.48 Z" class="st6"></path>	</g>	<g id="shape51-53" v:mid="51" v:groupcontext="shape" transform="translate(431.25,-209.981)">		<title>Sheet.51</title>		<desc>Waylandsink</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="60" cy="243.731" width="120.01" height="37.5"></v:textrect>		<path d="M-0 259.48 A3.00007 3.00007 -180 0 0 3 262.48 L117 262.48 A3.00007 3.00007 -180 0 0 120 259.48 L120 227.98 A3.00007					 3.00007 -180 0 0 117 224.98 L3 224.98 A3.00007 3.00007 -180 0 0 0 227.98 L0 259.48 Z" class="st3"></path>		<text x="26.26" y="247.33" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>Waylandsink</text>		</g>	<g id="shape54-56" v:mid="54" v:groupcontext="shape" transform="translate(273.75,-60.75)">		<title>Sheet.54</title>		<path d="M0 262.48 L78.75 262.48 L78.75 117.64 L0 262.48 Z" class="st8"></path>		<path d="M0 262.48 L78.75 262.48 L78.75 117.64" class="st5"></path>	</g>	<g id="shape55-59" v:mid="55" v:groupcontext="shape" transform="translate(349.882,-204.829)">		<title>Sheet.55</title>		<path d="M5.24 262.48 L2.62 257.95 L0 262.48 L5.24 262.48 Z" class="st6"></path>	</g>	<g id="group63-61" transform="translate(441.125,-14.7814)" v:mid="63" v:groupcontext="group">		<title>Sheet.63</title>		<g id="shape7-62" 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="26.4404" cy="256.181" width="52.89" height="12.6"></v:textrect>			<rect x="0" y="249.881" width="52.8808" height="12.6" class="st9"></rect>			<text x="-0" y="259.33" class="st10" v:langid="1033"><v:paragraph></v:paragraph><v:tablist></v:tablist>Qualcomm  </text>			</g>		<g id="shape8-65" v:mid="8" v:groupcontext="shape" transform="translate(3.09752E-14,-0.21863)">			<title>Sheet.8</title>			<path d="M0 260.98 A1.50003 1.50003 -180 0 0 1.5 262.48 L10.5 262.48 A1.50003 1.50003 -180 0 0 12 260.98 L12 251.98						 A1.50003 1.50003 -180 0 0 10.5 250.48 L1.5 250.48 A1.50003 1.50003 -180 0 0 -0 251.98 L0 260.98 Z" class="st7"></path>		</g>		<g id="shape10-67" 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="256.181" width="21" height="12.6"></v:textrect>			<rect x="0" y="249.881" width="21" height="12.6" class="st9"></rect>			<text x="0" y="259.68" class="st11" v:langid="1033"><v:paragraph></v:paragraph><v:tablist></v:tablist>开源</text>			</g>		<g id="shape11-70" v:mid="11" v:groupcontext="shape" transform="translate(73.9363,-0.21863)">			<title>Sheet.11</title>			<path d="M0 260.98 A1.50003 1.50003 -180 0 0 1.5 262.48 L10.5 262.48 A1.50003 1.50003 -180 0 0 12 260.98 L12 251.98						 A1.50003 1.50003 -180 0 0 10.5 250.48 L1.5 250.48 A1.50003 1.50003 -180 0 0 -0 251.98 L0 260.98 Z" class="st3"></path>		</g>	</g></g>
</svg>

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

| 处理过程 | 说明 |
| --- | --- |
| [qtiqmmfsrc](https://docs.qualcomm.com/doc/80-70022-50SC/topic/qtiqmmfsrc.html) | <ol class="ol" id="single-camera-stream-with-image-classification-and-display__ol_i4m_xlh_tfc"><br>                                    <li class="li">采集视频流（源）并创建源的两个副本：<ul class="ul" id="single-camera-stream-with-image-classification-and-display__ul_n44_nwl_vbc"><br>                                            <li class="li">一个视频流被发送到 qtivcomposer 插件以保留视频流。</li><br><br>                                            <li class="li">另一个流被发送至 pipeline 中的 ML 推理分支。</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-display__ol_i5w_4wl_vbc"><br>                                    <li class="li">在其接收端口上接收视频流。</li><br><br>                                    <li class="li">执行预处理：<ul class="ul" id="single-camera-stream-with-image-classification-and-display__ol_zdw_qwl_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> |
| **推理** | **推理** |
| [qtimltflite](https://docs.qualcomm.com/doc/80-70022-50SC/topic/qtimltflite.html) | <ol class="ol" id="single-camera-stream-with-image-classification-and-display__ol_u1l_cxl_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-display__ol_o3v_2xl_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-display__ol_p3v_2xl_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-display__ol_nmc_lxl_vbc"><br>                                    <li class="li">在接收端口上接收原始视频流和分类结果。 </li><br><br>                                    <li class="li">在其发送端口上生成 GST 缓存，其内容由来自其接收端的视频流组成。</li><br><br>                                </ol> |
| **输出** | **输出** |
| [Waylandsink](https://docs.qualcomm.com/doc/80-70022-50SC/topic/waylandsink.html) | <ol class="ol" id="single-camera-stream-with-image-classification-and-display__ol_cgt_mwl_vbc"><br>                                    <li class="li">在其接收端口上接收视频</li><br><br>                                    <li class="li">将视频流提交到 Weston。 </li><br><br>                                    <li class="li">Weston 在本地显示设备上渲染视频流和为该场景生成的可能分类。</li><br><br>                                </ol> |

**Parent Topic:** [LiteRT 用例](https://docs.qualcomm.com/doc/80-70022-50SC/topic/tensorflow-lite-use-cases.html)

Last Published: Nov 05, 2025

[Previous Topic
LiteRT 用例](https://docs.qualcomm.com/bundle/publicresource/80-70022-50SC/topics/tensorflow-lite-use-cases.md) [Next Topic
使用 LiteRT 进行图像分类和编码](https://docs.qualcomm.com/bundle/publicresource/80-70022-50SC/topics/single-camera-stream-with-image-classification-and-encode.md)