Halcon 路标牌识别

news2024/9/25 9:28:38

文章目录

  • gray_closing_shape 使用选定的掩码执行灰度值关闭
  • create_planar_uncalib_deformable_model 为未校准的透视匹配创建一个可变形的模型
  • get_deformable_model_params 返回可变形模型的参数
  • find_planar_uncalib_deformable_model 在图像中寻找平面投影不变变形模型的最佳匹配
  • get_deformable_model_contours 返回可变形模型的轮廓表示形式。
  • projective_trans_contour_xld 对XLD轮廓应用投影变换
  • clear_deformable_model 清除模板
  • get_region_runs 访问区域的运行长度编码
  • 示例

gray_closing_shape 使用选定的掩码执行灰度值关闭

gray_closing_shape(Image : ImageClosing : MaskHeight, MaskWidth, MaskShape : )
    Image (input_object): 需要计算最小灰度值的图像。
    ImageClosing (output_object): 包含最小灰度值的图像。
    MaskHeight (input_control): 滤波器掩模的高度。
        默认值: 11
        建议值: 3, 5, 7, 9, 11, 13, 15
        典型取值范围: 1.0 ≤ MaskHeight ≤ 511.0
    MaskWidth (input_control): 滤波器掩模的宽度。
        默认值: 11
        建议值: 3, 5, 7, 9, 11, 13, 15
        典型取值范围: 1.0 ≤ MaskWidth ≤ 511.0
    MaskShape (input_control): 控制滤波器掩模形状的参数。
        默认值: 'octagon'
        可选值: 'octagon', 'rectangle', 'rhombus'

create_planar_uncalib_deformable_model 为未校准的透视匹配创建一个可变形的模型

create_planar_uncalib_deformable_model(Template : : NumLevels, AngleStart, AngleExtent, AngleStep, ScaleRMin, ScaleRMax, ScaleRStep, ScaleCMin, ScaleCMax, ScaleCStep, Optimization, Metric, Contrast, MinContrast, GenParamName, GenParamValue : ModelID)
Image (input_object): 输入图像,模型应在其中查找目标。
ModelID (input_control): 模型的标识符。
AngleStart (input_control): 模型的最小旋转角度。
AngleExtent (input_control): 旋转角度的范围。
ScaleRMin/ScaleRMax/ScaleCMin/ScaleCMax (input_control): 模型在行和列方向上的最小和最大比例。
MinScore (input_control): 实例的最低得分阈值。
NumMatches (input_control): 要找到的模型实例数量。
MaxOverlap (input_control): 实例之间的最大重叠度量。
NumLevels (input_control): 在匹配中使用的金字塔级别数。
Greediness (input_control): 搜索启发式算法的“贪婪度”。
    GenParamName/GenParamValue (input_control): 一般参数名称和值。
HomMat2D (output_control): 模型实例与找到的实例之间的变换矩阵。
Score (output_control): 找到的模型实例的得分。

get_deformable_model_params 返回可变形模型的参数

get_deformable_model_params( : : ModelID, GenParamName : GenParamValue)
这段参数描述了一个可变形模型(deformable model)的相关控制参数:

    ModelID (input_control): 模型的标识符。
    GenParamName (input_control): 要查询可变形模型的通用参数的名称列表。
        默认值: 'angle_start'
        可选值: 'angle_extent', 'angle_start', 'angle_step', 'cam_param', 'cam_param_rect', 'created_from_xld', 'get_deformable_model_contours_coord_system', 'metric', 'min_contrast', 'min_size', 'model_col', 'model_pose', 'model_row', 'model_type', 'num_levels', 'optimization', 'reference_pose', 'scale_c_max', 'scale_c_min', 'scale_c_step', 'scale_r_max', 'scale_r_min', 'scale_r_step'
    GenParamValue (output_control): 通用参数的值。

find_planar_uncalib_deformable_model 在图像中寻找平面投影不变变形模型的最佳匹配

find_planar_uncalib_deformable_model(Image : : ModelID, AngleStart, AngleExtent, ScaleRMin, ScaleRMax, ScaleCMin, ScaleCMax, MinScore, NumMatches, MaxOverlap, NumLevels, Greediness, GenParamName, GenParamValue : HomMat2D, Score)
    Image:输入图像,模型应该在其中被找到。
    ModelID:模型的标识符。
    AngleStart:模型的最小旋转角度。
    AngleExtent:旋转角度的范围。
    ScaleRMin:模型在行方向上的最小比例。
    ScaleRMax:模型在行方向上的最大比例。
    ScaleCMin:模型在列方向上的最小比例。
    ScaleCMax:模型在列方向上的最大比例。
    MinScore:要找到的模型实例的最小分数。
    NumMatches:要找到的模型实例的数量(或者为所有匹配项设置为0)。
    MaxOverlap:要找到的模型实例的最大重叠。
    NumLevels:在匹配中使用的金字塔级别数。
    Greediness:搜索启发式算法的“贪婪度”。
    GenParamName:通用参数名称。
    GenParamValue:通用参数值。
    HomMat2D:模型和找到的实例之间的Homographies。
    Score:找到的模型实例的分数。

get_deformable_model_contours 返回可变形模型的轮廓表示形式。

get_deformable_model_contours( : ModelContours : ModelID, Level : )
ModelContours:可变形模型的轮廓表示。
ModelID:模型的标识符。
Level:应返回轮廓表示的金字塔级别。默认为1,建议值为110之间的整数,且必须大于等于1

projective_trans_contour_xld 对XLD轮廓应用投影变换

projective_trans_contour_xld(Contours : ContoursProjTrans : HomMat2D : )
Contours:输入的轮廓。
ContoursProjTrans:输出的轮廓。
HomMat2D:齐次投影变换矩阵。

clear_deformable_model 清除模板

clear_deformable_model( : : ModelID : )
ModelID :模板句柄

get_region_runs 访问区域的运行长度编码

get_region_runs(Region : : : Row, ColumnBegin, ColumnEnd)
Region:输入的区域。
Row:弦线的行号。
ColumnBegin:弦线起点的列号。
ColumnEnd:弦线终点的列号

示例

determine_area_of_interest (Image, Rectangle, AreaOfInterest) 函数

* 裁剪不重要的部分
reduce_domain (Image, Rectangle, ImageReduced)
*分成RGB三个图片
decompose3 (ImageReduced, ImageR, ImageG, ImageB)
*将图片转换为HSV
trans_from_rgb (ImageR, ImageG, ImageB, ImageH, ImageS, ImageV, 'hsv')
* 阈值处理
threshold (ImageS, HighSat, 130, 255)
* 膨胀
dilation_circle (HighSat, HighSatD, 2.0)
* 将图片填充
fill_up (HighSatD, HighSatD)
*填充后的图片裁剪
reduce_domain (ImageH, HighSatD, HighHue)
* 阈值处理
threshold (HighHue, ColoredAreaOfInterest, [230,145], [255,162])
* 填充图片
fill_up (ColoredAreaOfInterest, ImageFilled)
* 膨胀
dilation_circle (ImageFilled, ImageDilated, 3.0)
* 将图片联合
union1 (ImageDilated, AreaOfInterest)
return ()
* This example shows an application case from the automobile
* industry. A monitoring system in a car  checks the sidewalk
* for roadsigns to support the driver in case of any inattention.
* To show the imaging process we focus on two road signs,
* the attention and the dead end road sign. First the models
* of both signs are generated and then detected in a street
* sequence.
* 
* 读取图片
dev_close_window ()
* Read in model images.
* While the attention sign is from a synthetic source,
* the model for the dead end sign is from another sequence.
* 读取路标图片
read_image (ImageAttentionSign, 'road_signs/attention_road_sign')
* 读取街道图片
read_image (ImageInit, 'road_signs/street_01')
dev_open_window_fit_image (ImageInit, 0, 0, -1, -1, WindowHandle)
dev_update_off ()
dev_set_line_width (2)
dev_set_color ('green')
dev_set_draw ('margin')
set_display_font (WindowHandle, 14, 'mono', 'true', 'false')
* 
* Some values for the later matching process are initialized
* The Attention sign has a significant red part, the
* dead end sign a blue one. Hence, we can extract the respective
* channels from the color images.
Channel := [3,1]
* In this example, we have significant scalings of the road signs.
ScaleRMin := [0.5,0.4]
ScaleRMax := [0.8,2.0]
* One could add an anisotropic scaling for the exhaustive search.
* However, this makes the detection slower and is not required here.
ScaleCMin := [1.0,1.0]
ScaleCMax := [1.0,1.0]
* Add names to the signs.
RoadSign := ['Attention','Dead end']
HFac := [47.0,50.0]
* 
* Prepare the attention sign picture for the model
* creation process.
* 创建通道
access_channel (ImageAttentionSign, Image, Channel[0])
* 放大图片
zoom_image_factor (Image, ImageZoomed, 0.1, 0.1, 'weighted')
* 将放大后的图片插入到轮廓识别算法中
inspect_shape_model (ImageZoomed, ModelImages, ModelRegions, 3, 20)
* 创建一个可变形的模板
create_planar_uncalib_deformable_model (ImageZoomed, 3, [], [], 0.1, ScaleRMin[0], [], 0.05, ScaleCMin[0], [], 0.5, 'none', 'use_polarity', 'auto', 'auto', [], [], ModelID)
Models := ModelID
* 
* 
* 
*读取路标图片
read_image (ImageDeadEnd, 'road_signs/dead_end_road_sign')
* 获取通道1
access_channel (ImageDeadEnd, Image, Channel[1])
* 使用选定的掩码执行灰度值关闭
gray_closing_shape (Image, ImageClosing, 5, 5, 'octagon')
* 图片放大
zoom_image_factor (ImageClosing, ImageZoomed, 0.4, 0.4, 'weighted')
gen_rectangle1 (Rectangle1, 28, 71, 69, 97)
* 裁剪
reduce_domain (ImageZoomed, Rectangle1, ImageReduced)
* 将裁剪的标识创建一个可变形的模板
create_planar_uncalib_deformable_model (ImageReduced, 3, [], [], 0.1, ScaleRMin[1], [], 0.05, ScaleRMin[1], [], 0.1, 'none', 'use_polarity', 'auto', 'auto', [], [], ModelID)
* 
* The following three lines theoretically show how to
* query specific parameters of a model.
* Practically, the derived information is not needed
* within the program.
* 获取模板参数
get_deformable_model_params (ModelID, 'angle_step', AngleStep)
get_deformable_model_params (ModelID, 'scale_r_step', ScaleRStep)
Models := [Models,ModelID]
* 
* Generate ROI in which the road signs are expected.
* We can discard not significant parts of the image, in which
* no road sign can be located.
*丢弃图像中不重要的部分
gen_rectangle1 (Rectangle, 115, 0, 360, 640)
* 
* Search in image sequence
for Index := 1 to 16 by 1
    OutputString := []
    TotalTime := 0
    * 读取街道图片
    read_image (Image, 'road_signs/street_' + Index$'.02')
    * We are using color images, hence the ROI of the search image
    * can significantly be reduced based on the color.
    determine_area_of_interest (Image, Rectangle, AreaOfInterest)
    reduce_domain (Image, AreaOfInterest, ImageReduced)
    dev_display (Image)
    * 
    for Index2 := 0 to |Models| - 1 by 1
        * 
        * Depending on the street sign to be found, we use different color
        * channels of the image and the operator find_planar_uncalib_deformable_model
        * with different parameters because of the varying dimensions of the models.
        access_channel (ImageReduced, ImageChannel, Channel[Index2])
        count_seconds (Time1)
        * 查找匹配模板
        find_planar_uncalib_deformable_model (ImageChannel, Models[Index2], 0, 0, ScaleRMin[Index2], ScaleRMax[Index2], ScaleCMin[Index2], ScaleCMax[Index2], 0.85, 1, 0, 2, 0.4, [], [], HomMat2D, Score)
        count_seconds (Time2)
        Time := Time2 - Time1
        TotalTime := TotalTime + Time
        * 
        * Display found models.
        if (|HomMat2D|)
            *发现轮廓
            get_deformable_model_contours (ModelContours, Models[Index2], 1)
            *将轮廓进行投影
            projective_trans_contour_xld (ModelContours, ContoursProjTrans, HomMat2D)
            * 产生亚像素轮廓
            gen_region_contour_xld (ContoursProjTrans, Region, 'filled')
            * 合并
            union1 (Region, RegionU)
            *获取中心点面积
            area_center (RegionU, Area, R, C)
            * 访问区域的长度
            get_region_runs (RegionU, Row, ColumnBegin, ColumnEnd)
            H := max(Row) - min(Row)
            Fac := H / HFac[Index2]
            gen_circle (Circle, R, C, 45 * Fac)
            dev_display (Circle)
            gen_circle (Circle, R, C, 50 * Fac)
            dev_display (Circle)
            dev_display (ContoursProjTrans)
            if (Index2 == 0)
                OutputString := 'Attention sign found in : ' + (Time * 1000)$'.2f' + ' ms \n'
            else
                OutputString := 'Dead end sign found in  : ' + (Time * 1000)$'.2f' + ' ms \n'
            endif
        endif
    endfor
    if (|OutputString| == 0)
        OutputString := 'No sign found in        : ' + (Time * 1000)$'.2f' + ' ms \n'
    endif
    OutputString := ['Search for all models in: ' + (TotalTime * 1000)$'.2f' + ' ms',OutputString]
    disp_message (WindowHandle, OutputString, 'window', 10, 10, 'black', 'true')
    disp_continue_message (WindowHandle, 'black', 'true')
    stop ()
endfor
dev_display (Image)
disp_message (WindowHandle, 'Program finished.\nPress \'Run\' to clear all deformable models.', 'window', 10, 10, 'black', 'true')
stop ()
* Clean the memory of the models.
for Index1 := 0 to 1 by 1
    clear_deformable_model (Models[Index1])
endfor

在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1533894.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

气压传感器BMP180的简单应用

文章目录 一、BMP1801.介绍2.主要特点:3. 典型应用:4. 原理图5. 典型应用电路6. 测量流程7. 工作模式 二、软件1.初始化2.获取原始温度3.获取真实温度4.获取原始气压5.获取真实气压6.海拔高度的换算 三、总结 一、BMP180 1.介绍 BMP180是一款高精度、小…

【考研数学】全年复习懒人包+资料分享

题主要真是能把这两样做透了,别说90,120都不是问题呀!那么我们就先来说说你如何能把这1800做透吧。这可是人称考研数学路上最厚的一本习题册了。经常有人是做到一半就被劝退的!假设你是挑题出来做,那也行,不…

ThreaTrace复现记录

1. 环境配置 服务器环境 需要10.2的cuda版本 conda环境 包的版本: python 3.6.13 pytorch 1.9.1 torch-cluster 1.5.9 torch-scatter 2.0.9 torch-sparse 0.6.12 torch-spline-conv 1.2.1 torch-geometric 1.4.3 环境bug 这里环境搭建好以后,就可以正…

ssm基于Vue.js的在线购物系统的设计与实现论文

摘 要 随着科学技术的飞速发展,各行各业都在努力与现代先进技术接轨,通过科技手段提高自身的优势;对于在线购物系统当然也不能排除在外,随着网络技术的不断成熟,带动了在线购物系统,它彻底改变了过去传统的…

【数据结构】——线性表(顺序表加链表),万字解读(加链表oj详解)

前言 由于之前存在过对两者的区别考虑,所以把他们放在一起来说,更加容易区别和理解 对于有关线性表的概念这里就不展示了,这里主要是介绍线性表里面的这两个结构的知识点 一.顺序表 1.顺序表介绍 顺序表的存储结构和逻辑结构都是相邻的&a…

【前端寻宝之路】学习和总结JavaScript的书写形式

🌈个人主页: Aileen_0v0 🔥热门专栏: 华为鸿蒙系统学习|计算机网络|数据结构与算法|MySQL| ​💫个人格言:“没有罗马,那就自己创造罗马~” #mermaid-svg-oO1UdfWcWZUMkIDr {font-family:"trebuchet ms",verdana,arial,sans-serif;f…

【C语言进阶篇】自定义类型:联合体和枚举

【C语言进阶篇】自定义结构体类型:联合体和枚举 🌈个人主页:开敲 🔥所属专栏:C语言 🌼文章目录🌼 1. 联合体 1.1 联合体类型的声明 1.2 联合体的特点 1.3 联合体大小的计算 2. 枚举 2.1 枚举…

2.5、栅格布局(GridRow/GridCol)

概述 栅格布局是一种通用的辅助定位工具,对移动设备的界面设计有较好的借鉴作用。主要优势包括: 提供可循的规律:栅格布局可以为布局提供规律性的结构,解决多尺寸多设备的动态布局问题。通过将页面划分为等宽的列数和行数,可以方便地对页面元素进行定位和排版。 统一的定…

设计模式 模板方法模式

01.如果接到一个任务,要求设计不同型号的悍马车 02.设计一个悍马车的抽象类(模具,车模) public abstract class HummerModel {/** 首先,这个模型要能够被发动起来,别管是手摇发动,还是电力发动…

AI训练,为什么需要GPU?

随着人工智能热潮,GPU成为了AI大模型训练平台的基石,决定了算力能力。为什么GPU能力压CPU,成为炙手可热的主角呢?首先我们要先了解一下GPU的分类。提到分类,就得提及到芯片。 半导体芯片分为数字芯片和模拟芯片。其中&…

浅谈亚信安慧AntDB-M条件下推

概述 “下推”是数据库管理系统优化查询性能的一种思路,集中式数据库支持谓词下推和投影下推,通过将Filter(过滤)和Project(映射)算子在算子数中向下移动,提前对行/列进行裁剪,减少…

从嵌套事务的日志看MyBatis的sqlSession生命周期

service层业务代码 Override public void test(){QueryWrapper<StoreRebateCalculateLog> queryWrapper;queryWrapper new QueryWrapper<>();queryWrapper.eq("delete_flag", 0);//执行查询A,以非事务方式执行List<StoreRebateCalculateLog> sto…

代码学习第24天----回溯算法

随想录日记part24 t i m e &#xff1a; time&#xff1a; time&#xff1a; 2024.03.10 主要内容&#xff1a;回溯算法在代码学习中尤其重要&#xff0c;所以今天继续加深对其的理解&#xff1a;1&#xff1a;递增子序列 &#xff1b;2.全排列 &#xff1b;3.全排列II 491.递…

Android:adb命令

执行adb命令的窗口如下 Mac或Linux系统里的终端窗口&#xff1b; window系统运行输入cmd打开的指令窗口&#xff1b; Android Studio 里控制下面的Terminal窗口 1. 查看已链接的设备和模拟器 adb devices -l 2. 查看Android内核版本号 adb shell getprop ro.build.version.re…

近期TRO案件盘点,外观专利又双叒叕成维权高发地

近期&#xff0c;多个权利人进行外观专利维权&#xff0c;众多国内卖家被告&#xff0c;建议卖家自查。 案例一&#xff1a;尿布收纳袋——商标外观专利版权 案例关于这款尿布收纳袋&#xff0c;涉及商标、外观专利和版权。 &#xff08;图源网络&#xff0c;侵删&#xff09…

HarmonyOS NEXT应用开发之跨文件样式复用和组件复用

介绍 本示例主要介绍了跨文件样式复用和组件复用的场景。在应用开发中&#xff0c;我们通常需要使用相同功能和样式的ArkUI组件&#xff0c;例如购物页面中会使用相同样式的Button按钮、Text显示文字&#xff0c;我们常用的方法是抽取公共样式或者封装成一个自定义组件到公共组…

汽车KL15、KL30、ACC的区别

文章目录 前言一、KL30是什么&#xff1f;二、KL15是什么&#xff1f;KL15信号的演变 三、为啥用KL15、KL30呢&#xff1f; 前言 相信刚接触汽车电子的伙伴都会有一个疑惑&#xff0c;什么是KL15?什么是KL30? 内心一脸懵逼…… KL是德语Klemme的缩写&#xff0c;指的是ECU的…

软件测评中心分享:软件鉴定测试与验收测试有什么联系和区别?

1、软件鉴定测试   软件鉴定测试是在软件开发完成后进行的一个核心环节&#xff0c;是通过对软件进行功能性、性能、安全性等方面的综合测试&#xff0c;来验证软件是否符合规定的需求和标准。 2、软件验收测试   软件验收测试是软件开发工作结束后的最后一个环节&#xf…

深入理解 CSS:基础概念、注释、选择器及优先级

在构建网页的过程中&#xff0c;我们不仅需要HTML来搭建骨架&#xff0c;还需要CSS来装扮我们的网页。那么&#xff0c;什么是CSS呢&#xff1f;本文将带大家了解css的基础概念&#xff0c;注释、选择器及优先级。 一、CSS简介 1.1 什么是CSS CSS&#xff0c;全称为Cascadin…

IoT 物联网场景中 LoRa + 蓝牙Bluetooth 室内场馆高精定位技术全面解析

基于LoRa蓝牙的室内场景定位技术&#xff0c;蓝牙主要负责位置服务&#xff0c;LoRa主要负责数据传输。 01 LoRa和蓝牙技术 LoRa全称 “Long Rang”&#xff0c;是一种成熟的基于扩频技术的低功耗、超长距离的LPWAN无线通信技术。LoRa主要采用的是窄带扩频技术&#xff0c;抗干…