主要内容

Simulink中的GPU代码生成用于车道检测万博1manbetx

This example shows how to generate CUDA® code for a Simulink® model that can detect and output lane marker boundaries on an image. This example takes RGB image as an input and uses the精加工,,,,rgb2gray,,,,ORDFILT2(图像处理工具箱),,,,伙计(图像处理工具箱),,,,Houghpeaks(图像处理工具箱),Houghlines(图像处理工具箱)是图像处理工具箱™的一部分的功能,可检测车道标记。这个示例密切关注通过使用Houghlines功能,在GPU上检测车道

此示例说明了以下概念:

  • 通过使用图像处理功能,在Simulink中模拟了车道检测应用程序。万博1manbetx

  • 为GPU代码生成配置模型。

  • 为Simulink模型生成CUDA可执行文件。万博1manbetx

第三方先决条件

Required

此示例生成CUDA MEX,并具有以下第三方要求。

  • 启用CUDA的NVIDIA®GPU和兼容驱动程序。

可选的

对于非MEX构建,例如静态,动态库或可执行文件,此示例具有以下其他要求。

验证GPU环境

要验证正确设置此示例所需的编译器和库是否正确设置coder.checkGpuInstall功能。

envcfg = coder.gpuenvconfig('host');envcfg.basiccodegen = 1;envcfg.quiet = 1;coder.checkgpuinstall(envcfg);

使用车道检测Houghlines万博1manbetxSimulink模型

显示了用万博1manbetx于车道检测的模型。

open_system('Lane_detection');

车道检测子系统包含aMATLAB功能block that takes an intensity image as input and provides detected lanes as output. This function is based on the lane detection algorithm implementation usingHoughlines如所述通过使用Houghlines功能,在GPU上检测车道例子。当模型运行时可视化块显示了泳道检测到的输出图像。

运行模拟

打开配置参数对话框。

Simulation Target窗格,选择GPU加速度

以正常模式运行模拟。

set_param('Lane_detection',,,,'simulationmode',,,,'普通的');SIM('Lane_detection');

生成并构建Simulink模型万博1manbetx

代码生成窗格,选择作为C ++并启用生成GPU代码

打开Simulation Target窗格。在里面高级参数,,,,enableMATLAB功能中的动态内存分配阈值。有关更多信息,请参阅MATLAB功能中的动态内存分配(万博1manbetxSimulink)

打开代码生成> GPU Code窗格。在子类别中,,,,enable库公共,,,,Cusolverand袖口

通过使用The Host GPU生成并构建Si万博1manbetxmulink模型Slbuild命令。代码生成器将文件放在构建文件夹,一个子文件夹lane_detection_ert_rtw在您当前的工作文件夹下。

status = evalc(“ slbuild('lane_detection')”);

清理

关闭Simulink万博1manbetx模型。

CLOSS_SYSTEM('Lane_detection');

也可以看看

功能

Related Topics