# 为定制模型添加后处理支持

本节将指导您在 Qualcomm IM SDK 插件中添加模型后处理支持，尤其是在当前 Qualcomm IM SDK 插件不支持模型后处理的情况下。

此示例说明了将自定义模型后处理添加到 `qtimlvdetection` 插件的步骤。

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by Microsoft Visio, SVG Export add-post-processing.svg add-post-processing -->
<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="9.9225in" height="0.8704in" viewbox="0 0 714.42 62.6688" xml:space="preserve" color-interpolation-filters="sRGB" class="st7" aria-label="../_images/add-post-processing.svg"><v:documentproperties v:langid="1033" v:viewmarkup="false">	<v:userdefs>		<v:ud v:nameu="msvNoAutoConnect" v:val="VT0(1):26"></v:ud>	</v:userdefs></v:documentproperties>
<style>.svg-1 .st1 { fill: #2a2aea; stroke: none; stroke-linecap: butt; stroke-width: 0.75 }
.svg-1 .st2 { fill: #ffffff; font-family: Microsoft YaHei UI; font-size: 1.00001em; font-weight: bold }
.svg-1 .st3 { font-family: Arial; font-size: 1em }
.svg-1 .st4 { font-size: 1em }
.svg-1 .st5 { marker-end: url("#mrkr4-26"); stroke: #000000; stroke-linecap: butt; stroke-width: 2 }
.svg-1 .st6 { fill: #000000; fill-opacity: 1; stroke: #000000; stroke-opacity: 1; stroke-width: 0.44247787610619 }
.svg-1 .st7 { fill: none; fill-rule: evenodd; font-size: 12px; overflow: visible; stroke-linecap: square; stroke-miterlimit: 3 }</style>
<defs id="Markers">	<g id="lend4">		<path d="M 2 1 L 0 0 L 2 -1 L 2 1 " style="stroke:none"></path>	</g>	<marker id="mrkr4-26" class="st6" v:arrowtype="4" v:arrowsize="2" v:setback="4.52" refx="-4.52" orient="auto" markerunits="strokeWidth" overflow="visible">		<use xlink:href="#lend4" transform="scale(-2.26,-2.26) "></use>	</marker></defs><g v:mid="19" v:index="7" v:groupcontext="foregroundPage">	<title>add-post-processing</title>	<v:pageproperties v:drawingscale="0.0138889" v:pagescale="0.0138889" v:drawingunits="29" v:shadowoffsetx="9" v:shadowoffsety="-9"></v:pageproperties>	<g id="shape1-1" v:mid="1" v:groupcontext="shape" transform="translate(0.587487,0)">		<title>Sheet.1</title>		<desc>确保预处理受支持</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="57.1237" cy="31.3338" width="114.25" height="62.67"></v:textrect>		<path d="M0 58.92 A3.75009 3.75009 -180 0 0 3.75 62.67 L110.5 62.67 A3.75009 3.75009 -180 0 0 114.25 58.92 L114.25 3.75					 A3.75009 3.75009 -180 0 0 110.5 -0 L3.75 -0 A3.75009 3.75009 -180 0 0 0 3.75 L0 58.92 Z" class="st1"></path>		<text x="9.12" y="34.98" class="st2" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>确保预处理受支持</text>		</g>	<g id="shape2-4" v:mid="2" v:groupcontext="shape" transform="translate(450.715,0)">		<title>Sheet.2</title>		<desc>重新编译 SDK 插件</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="57.1237" cy="31.3338" width="114.25" height="62.67"></v:textrect>		<path d="M0 58.92 A3.75009 3.75009 -180 0 0 3.75 62.67 L110.5 62.67 A3.75009 3.75009 -180 0 0 114.25 58.92 L114.25 3.75					 A3.75009 3.75009 -180 0 0 110.5 -0 L3.75 -0 A3.75009 3.75009 -180 0 0 0 3.75 L0 58.92 Z" class="st1"></path>		<text x="33.12" y="27.68" class="st2" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>重新编译<tspan class="st3"> </tspan><tspan x="30.79" dy="1.216em" class="st3">SDK </tspan>插件</text>		</g>	<g id="shape3-9" v:mid="3" v:groupcontext="shape" transform="translate(150.632,0)">		<title>Sheet.3</title>		<desc>添加用于后处理 的新模块</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="57.1237" cy="31.3338" width="114.25" height="62.67"></v:textrect>		<path d="M0 58.92 A3.75009 3.75009 -180 0 0 3.75 62.67 L110.5 62.67 A3.75009 3.75009 -180 0 0 114.25 58.92 L114.25 3.75					 A3.75009 3.75009 -180 0 0 110.5 -0 L3.75 -0 A3.75009 3.75009 -180 0 0 0 3.75 L0 58.92 Z" class="st1"></path>		<text x="15.12" y="27.68" class="st2" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>添加用于后处理<v:lf></v:lf><tspan x="33.12" dy="1.216em" class="st4">的新模块</tspan></text>		</g>	<g id="shape4-13" v:mid="4" v:groupcontext="shape" transform="translate(300.67,0)">		<title>Sheet.4</title>		<desc>使用新模型修改 参考应用程序</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="57.1237" cy="31.3338" width="114.25" height="62.67"></v:textrect>		<path d="M0 58.92 A3.75009 3.75009 -180 0 0 3.75 62.67 L110.5 62.67 A3.75009 3.75009 -180 0 0 114.25 58.92 L114.25 3.75					 A3.75009 3.75009 -180 0 0 110.5 -0 L3.75 -0 A3.75009 3.75009 -180 0 0 0 3.75 L0 58.92 Z" class="st1"></path>		<text x="15.12" y="27.68" class="st2" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>使用新模型修改<v:lf></v:lf><tspan x="21.12" dy="1.216em" class="st4">参考应用程序</tspan></text>		</g>	<g id="shape5-17" v:mid="5" v:groupcontext="shape" transform="translate(600.752,0)">		<title>Sheet.5</title>		<desc>重新编译 参考应用程序</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="57.1237" cy="31.3338" width="114.25" height="62.67"></v:textrect>		<path d="M0 58.92 A3.75009 3.75009 -180 0 0 3.75 62.67 L110.5 62.67 A3.75009 3.75009 -180 0 0 114.25 58.92 L114.25 3.75					 A3.75009 3.75009 -180 0 0 110.5 -0 L3.75 -0 A3.75009 3.75009 -180 0 0 0 3.75 L0 58.92 Z" class="st1"></path>		<text x="33.12" y="27.68" class="st2" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>重新编译<v:lf></v:lf><tspan x="21.12" dy="1.216em" class="st4">参考应用程序</tspan></text>		</g>	<g id="shape116-21" v:mid="116" v:groupcontext="shape" transform="translate(114.835,-28)">		<title>Sheet.116</title>		<path d="M0 62.67 L26.76 62.67" class="st5"></path>	</g>	<g id="shape117-27" v:mid="117" v:groupcontext="shape" transform="translate(264.88,-28)">		<title>Sheet.117</title>		<path d="M0 62.67 L26.75 62.67" class="st5"></path>	</g>	<g id="shape118-32" v:mid="118" v:groupcontext="shape" transform="translate(414.917,-28)">		<title>Sheet.118</title>		<path d="M0 62.67 L26.76 62.67" class="st5"></path>	</g>	<g id="shape119-37" v:mid="119" v:groupcontext="shape" transform="translate(564.962,-28)">		<title>Sheet.119</title>		<path d="M0 62.67 L26.75 62.67" class="st5"></path>	</g></g>
</svg>

前提条件

`qtimlvconverter` 必须支持模型预处理。请参阅 [README](https://git.codelinaro.org/clo/le/platform/vendor/qcom-opensource/gst-plugins-qti-oss/-/blob/imsdk.lnx.2.0.0.r2-rel/gst-plugin-mlvdetection/modules/README?ref_type=heads) 以了解更多信息。

## 为 `qtimlvdetection` 添加 YoloV8 模块支持

1. 在 `qtimlvdetection` 插件中编写一个新模块以启用后处理支持。

    请参阅以下示例代码作为参考：[gst-plugin-mlvdetection/modules/ml-vdetection-yolov8.c imsdk.lnx.2.0.0.r2-rel · CodeLinaro / le / platform / vendor / qcom-opensource / gst-plugins-qti-oss GitLab](https://git.codelinaro.org/clo/le/platform/vendor/qcom-opensource/gst-plugins-qti-oss/-/blob/imsdk.lnx.2.0.0.r2-rel/gst-plugin-mlvdetection/modules/ml-vdetection-yolov8.c)。
2. 为定制模型编写一个新文件。在模型后处理模块中，该 `gst_ml_module_process` 函数负责执行所有后处理操作。

    使用[编译和安装 Qualcomm IM SDK插件](https://docs.qualcomm.com/bundle/publicresource/topics/80-70018-51/compile-install-imsdk-plugins.html)中提供的说明重新编译该插件。
3. 将新文件添加到 `Cmakelists.txt` 中。

    请参阅以下示例作为参考：

    [gst-plugin-mlvdetection/modules/CMakeLists.txt·imsdk.lnx.2.0.0.r2-rel·CodeLinaro/le/platform/vendor/qcom-opensource/gst-plugins-qti-oss GitLab](https://git.codelinaro.org/clo/le/platform/vendor/qcom-opensource/gst-plugins-qti-oss/-/blob/imsdk.lnx.2.0.0.r2-rel/gst-plugin-mlvdetection/modules/CMakeLists.txt)
4. 重新编译并运行参考应用程序。

    有关如何使用 eSDK 编译参考应用程序的说明，请参阅 [Qualcomm Intelligent Multimedia 软件开发包 (IM SDK) 快速入门指南](https://docs.qualcomm.com/bundle/publicresource/topics/80-70018-51/introduction.html)。

    有关如何编写自己的插件的更多详细说明，请参阅 [README](https://git.codelinaro.org/clo/le/platform/vendor/qcom-opensource/gst-plugins-qti-oss/-/blob/imsdk.lnx.2.0.0.r2-rel/gst-plugin-mlvdetection/modules/README)。

Last Published: Oct 23, 2025

[Previous Topic
在应用程序中集成 AI Hub 模型](https://docs.qualcomm.com/bundle/publicresource/80-70018-15BY/topics/integrate-ai-hub-models.md) [Next Topic
开发定制 GStreamer 插件](https://docs.qualcomm.com/bundle/publicresource/80-70018-15BY/topics/general-guidelines-for-developing-gstreamer-plugin.md)