二维测量--胎圈检查

本文介绍了一种基于图像处理的轮胎胎圈缺陷检测方法,包括粘合胶缺失、过多或位置偏差等问题。通过创建和应用胎圈检测模型,实现自动化质量控制。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

对应示例程序:
apply_bead_inspection_model.hdev

目标: 胎圈检查可用于检测以下错误:
            1.缺少粘合胶的部分
            2.粘合剂过多或过少的部分
            3.粘合胶离其预定位置太远的部分
思路为:
      1.前期准备 提取准备好对准模型 生成投影变换矩阵 以及透视匹配创建可变形模型
      2.定义粘合胶条的参考路径,以及胶条的宽度,还有误差容忍值
      3. 利用算子create_bead_inspection_model 生成胶条模型
      4.校正胎圈的位置,并生成四条平行轮廓,进行显示
      5.读入待检测图像,并进行校正,最后利用算子apply_bead_inspection_model进行胎圈检测
      6.根据不同的检测类型在窗口上进行相关显示

图像:
在这里插入图片描述

代码:

*在本例中,对齐基于平面可变形匹配。
dev_update_off ()
* 
* Create the planar deformable model to align images with the
* reference contour
*创建平面可变形模型以将图像与参考轮廓对齐

prepare_alignment (RegionPart, RowT, ColumnT, ModelID)  //前期准备  提取准备好对准模型 
smallest_rectangle1 (RegionPart, PartRow1, PartColumn1, PartRow2, PartColumn2)   
* 
* Define the reference path of the adhesive beads. This path could
* also be generated by drawing it on a reference image with, e.g.,
* draw_nurbs.
*定义粘合胶条的参考路径。

*也可以通过在参考图像上绘制该路径来生成,例如使用算子draw_nurbs.
gen_contour_nurbs_xld (ContourRef, [701.767,626.953,538.867,443.54,390.447,360.28,354.247,363.9,400.1,458.02,509.907,588.34,659.533,696.94], [319.24,336.133,367.507,431.46,489.38,546.093,646.247,722.267,776.567,826.04,869.48,912.92,934.64,929.813], 'auto', [15,15,15,15,15,15,15,15,15,15,15,15,15,15], 3, 1, 5)
* 
* Create a new bead inspection model with the following parameters
*使用以下参数创建新的焊道检查模型
TargetWidth := 14
WidthTolerance := 7
PositionTolerance := 30
Polarity := 'dark'

*创建模型以检查图像中的珠子或粘合胶。
create_bead_inspection_model (ContourRef, TargetWidth, WidthTolerance, PositionTolerance, Polarity, [], [], BeadInspectionModel)
* 
* Show a correct adhesive bead together with the reference contour
*显示正确的胶条和参考轮廓
read_image (Image, 'bead/adhesive_bead_01')
align_bead (Image, ImageAligned, ModelID, RowT, ColumnT)  //校正
* 
* Create two parallel contours to give an impression of how
* thick a correct adhesive bead should be
*创建两个平行轮廓,以显示正确胶条的厚度
gen_parallel_contour_xld (ContourRef, ModelSide1, 'regression_normal', TargetWidth * 0.5)
gen_parallel_contour_xld (ContourRef, ModelSide2, 'regression_normal', -TargetWidth * 0.5)
concat_obj (ModelSide1, ModelSide2, ModelSides)
* 
* Create two parallel contours to give an impression of where
* a correct adhesive bead should be located
*创建两个平行轮廓,以给出正确胶条位置 容忍度计算得出
gen_parallel_contour_xld (ContourRef, PositionToleranceSide1, 'regression_normal', PositionTolerance)
gen_parallel_contour_xld (ContourRef, PositionToleranceSide2, 'regression_normal', -PositionTolerance)
concat_obj (PositionToleranceSide1, PositionToleranceSide2, PositionToleranceSides)
dev_close_window ()
dev_open_window_fit_size (0, 0, PartColumn2 - PartColumn1 + 1, PartRow2 - PartRow1 + 41, -1, -1, WindowHandle)
set_display_font (WindowHandle, 16, 'mono', 'true', 'false')
dev_set_part (PartRow1 - 20, PartColumn1, PartRow2 + 20, PartColumn2)
dev_display (ImageAligned)
dev_set_line_width (2)
dev_set_color ('green')
dev_display (ContourRef) //粘合胶条的参考路径
dev_set_line_width (1)
dev_display (ModelSides)  //胶条的厚度/轮廓
dev_set_color ('yellow')
dev_display (PositionToleranceSides)  //容忍的位置

*校正胶条和参考轮廓。黄色轮廓表示位置公差范围
Message := 'Correct adhesive bead and the reference contour. The'
Message[1] := 'yellow contours indicate the range of position tolerance.'
disp_message (WindowHandle, Message, 'window', 12, 12, 'black', 'true')
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
* 
* Now, perform the inspection task  现在,执行检查任务
TextOffset := 20  //偏移值
NumImages := 7
for Index := 1 to NumImages by 1
    read_image (Image, 'bead/adhesive_bead_' + Index$'02')
    *  
    * Align the input image with the reference image     将输入图像与参考图像对齐
    align_bead (Image, ImageAligned, ModelID, RowT, ColumnT)
    * 
    * Apply the bead inspection model to the aligned image 将胎圈检测模型应用于对齐图像
    apply_bead_inspection_model (ImageAligned, LeftContour, RightContour, ErrorSegment, BeadInspectionModel, ErrorType)
    * 
    * Display the segmented adhesive bead with its error segments  显示分段胶条及其误差段
    dev_display (ImageAligned)
    dev_set_line_width (1)
    dev_set_color ('white')
    dev_display (ContourRef)
    dev_display (ModelSides)
    dev_display (PositionToleranceSides)
    dev_set_line_width (2)
    dev_set_color ('green')
    dev_display (LeftContour)  //检测出的内部XLD
    dev_display (RightContour)  //检测出的外部XLD
    dev_set_color ('red') 
    dev_display (ErrorSegment)  //错误部分区域
    
    if (|ErrorType| == 0)
        * No errors detected
        Message := 'Adhesive bead is OK'
        disp_message (WindowHandle, Message, 'window', 12, 12, 'white', 'forest green')
        disp_continue_message (WindowHandle, 'black', 'true')
        stop ()
    else
        * Display errors by error class  显示误差值
        Message[0] := 'Adhesive bead is not OK:'
        * 
        ErrorClasses := ['no bead','too thin','too thick','incorrect position']
        for ClassIndex := 0 to |ErrorClasses| - 1 by 1
            Class := ErrorClasses[ClassIndex]
            ErrorIndices := find(ErrorType,Class)
            if (ErrorIndices != -1)
                select_obj (ErrorSegment, SelectedSegments, ErrorIndices + 1)
                dev_set_color ('red')
                dev_set_line_width (3)
                if (Class != 'no bead')
                    gen_display_segments (SelectedSegments, LeftContour, RightContour, ErrorParts)
                    dev_display (ErrorParts)
                else
                    dev_display (SelectedSegments)
                endif
                area_center_points_xld (SelectedSegments, Area, Row, Column)
                for E := 0 to |ErrorIndices| - 1 by 1
                    disp_message (WindowHandle, ErrorIndices[E] + 1, 'image', Row[E], Column[E] - TextOffset, 'white', 'red')
                    TextOffset := 20 - TextOffset
                endfor
            endif
        endfor
        disp_message (WindowHandle, Message, 'window', 12, 12, 'white', 'red')
        disp_message (WindowHandle, [1:|ErrorType|] + ': ' + ErrorType, 'image', 500, 500, 'red', 'false')
        if (Index < NumImages)
            disp_continue_message (WindowHandle, 'black', 'true')
            stop ()
        endif
    endif
endfor
* 
* Release all allocated memory  释放空间
clear_bead_inspection_model (BeadInspectionModel)
clear_deformable_model (ModelID)

用到的几个算子:
      vector_to_proj_hom_mat2d --利用给定点的对应关系计算投影变换矩阵。
      projective_trans_image --对图像应用投影变换。
      create_planar_uncalib_deformable_model-- 为未校准的透视匹配创建可变形模型
      find_planar_uncalib_deformable_model–在图像中寻找平面投影不变变形模型的最佳匹配
      clear_deformable_model–释放可变形模型的内存
      gen_contour_nurbs_xld –将Nurbs曲线转换为XLD轮廓
      create_bead_inspection_model --创建模型以检查图像中的珠子或粘合胶
      apply_bead_inspection_model–按照胎圈检查模型的定义,检查图像中的胎圈
      ;clear_bead_inspection_model–删除胎圈检查模型并释放分配的内存
      gen_parallel_contour_xld --计算XLD轮廓的平行轮廓。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值