Advertisement

检测太阳能电池片(solar cell)中的缺陷区域

阅读量:

此段代码主要基于HALCON软件平台构建,并专注于图像处理领域中的缺陷检测功能开发。该模块特别关注太阳能电池板中出现的缺陷区域(defects in solar panels),其核心算法能够精准识别并定位断指等特征(broken fingers)位置

executing off device operations
shutting down the window interface
Setting the ImageName variable to 'solar_cell/solar_cell_'
Reading image data from the specified file path: ImageName + '01'
Opening the window interface for full-screen fitting of image data
Configuring display font settings: 14-point monospace with on-vertical and off-horizontal margins
Enabling red color mode for better visibility
Setting drawing mode to margin for precise alignment
Configuring line width to 2 for improved readability and visual clarity

  • For each instance of a solar cell, identify or analyze the defective regions
    N imagery count is set to 6
    For each index in the range starting at 1 through NumImages:
    Read the image into a variable named [ImageName followed by the index with two digits]
    Decompose the image into its red (ImageR), green (ImageG), and blue (ImageB) color channels

  • Mark dark areas excepting fingers
    Threshold setting(ImageR, Region, 0-159)
    Link between Region and ConnectedRegions

  • 选择优质组件并去除杂乱区域
    select_shape (ConnectedRegions, 高质量小部件, [‘面积’,‘宽度’], 与, (面积≥3500像素、宽度≥130像素), (面积≥5000像素、宽度≥300像素))
    select_shape (ConnectedRegions, 长部件组件, [‘面积’,‘宽度’], 与, (面积≥6千像素、宽度≥3百像素), (面积≥1万像素、宽度≥5百像素))
    select_shape (ConnectedRegions, Clutter, [‘宽度’,‘高度’,‘面积’], 或者, (尺寸均达9百×9百、无任何内容), (尺寸均达1千×1千、空闲区域仅占1百))

  • 除了好的部分和杂乱的部分之外,还包含着损坏的手指
    计算ConnectedRegions与GoodSmallParts之间的差异。
    将前一个差异与GoodLongParts进行比较。
    将Clutter区域的差异与BrokenParts进行比较。
    将BrokenParts转换为矩形1。

  • Isolate the break to provide a clear visual representation
    Apply rectangular erosion using broken_parts and parameters [1][25] under region_erosion
    For connection between RegionErosion and ConnectedBreaks
    A shape transformation from ConnectedBreaks to Breaks using an outer circle
    For dilation with a circular structuring element of size 6 applied to Breaks

  • 清除空区域

  • (此功能也可通过set_system('store_empty_region', 'false')实现)

  • select_shape(基于面积划分形状)

  • count_obj(基于计数的物体)

Show the inspection outcomes. dev_display is used to display images, FaultyComponentsAnalysis, and ComponentFailures.

  • 当计数中断次数为零时显示消息到窗口位置(WindowHandle),信息文字为"Cell OK"*
    调用 disp_message 函数并设置相关属性:字体大小为12号、字体颜色为黑色以及显示标志位设为真*
    否则*
    调用 disp_message 函数并设置相关信息文字为"Cell not OK"*
    字体大小仍设为12号、字体颜色改为红色以及显示标志位维持真值*
    结束条件判断*

如果索引值与图像总数不一致*
调用 disp_continue_message 函数并设置相关信息文字为"black"*
同时终止当前处理流程

  • 如果只有一个缺陷出现,则放大查看
    if CountBreaks equals one
    open the window at position (X=248,Y=677), width and height of 32-bit color depth named WindowHandle1.
    find the center area corresponding to Breaks and Area coordinates.
    set the central region of WindowHandle1 from Row index minus fifty to Row index plus fifty and similarly for columns.
    display image data using three different windows: one for original image data "Image", another for "BrokenPartsTrans" and third for "Breaks".
    call stop() function after display operations.
    set active window as WindowHandle1.
    close WindowHandle1.
    end of if block.
在这里插入图片描述
在这里插入图片描述

代码的主要功能如下:

禁用更新与窗口:通过调用dev_update_off与dev_close_window函数来实现图像更新的禁用以及窗口的关闭。

读取并显示第一张名为solar_cell_1的图像,并通过调用dev_open_window_fit_image函数使其适应于当前图像尺寸。

配置显示字体及绘图参数:在窗口中设定文本的字号、样式等属性,并设定绘图颜色、画法与线宽。

重复处理多个图像:反复读取六个带有solar_cell标记的图片(如solar_cell_1至solar_cell_6)

图像分解:使用decompose3函数将图像分解为红色、绿色和蓝色三个通道。

分割暗区域:

通过threshold函数对红颜色通道实施阈值分离操作。
通过connection函数将相邻区域相互结合。
辨别出良好的部分与杂乱无章的区域:

通过select_shape函数依据面积及宽度筛选出优质的短形组件与长形组件。同样地,通过select_shape函数基于宽度、高度及面积筛选出杂乱的区域。针对断裂的手指进行识别:

调用difference函数从连通域中扣除关键的小组件、主要的长组件以及杂散域元素后获得分离的手指域。通过shape_trans函数将分离的手指域转换为矩形形状。采用erosion_rectangle1函数对分离的手指域执行腐蚀操作以实现分离目标。调用connection函数将腐蚀后手指域进行连通处理。通过shape_trans函数将连通后的手指域转化为包围圆边界结构。调用dilation_circle函数对手指Domain执行膨胀处理以扩大其范围。去除空隙:应用select_shape功能消除面积为空的空间部分

计数断裂区域:使用count_obj函数计算断裂区域的数量。

显示检测结果:

调用dev_display函数,在窗口中分别展示原始图像以及断裂的手指区域和断裂区域的外接圆。根据断裂区域的数量来输出提示信息:若数量为零,则输出‘Cell OK’;否则输出‘Cell not OK’。在处理过程中,请注意:若当前不是最后一张图像,则会暂时停止并提示继续操作。

仅当单一缺陷出现时(或当缺陷数量为1时),系统将对该区域进行详细查看(或启动一个新窗口用于对该断裂区域进行详细查看),并对其执行放大显示操作(或对该断裂区域进行放大显示)。

结束循环:完成所有图像的处理。

整体来看,这段代码的主要功能是:

获取多幅太阳能电池板图像样本。对于每一张图像而言,在实施颜色通道分解与阈值分割处理之后,在分析结果中识别出暗区区域。随后筛选出优质组件与干扰区域,在此基础上识别断裂手指部位。运用形态学运算方法,在分离断裂手指部分的同时实现其特征显示。在监控界面展示原始图像及断裂区域分布情况,并根据断裂数量输出相应的警示信息。该图像处理技术在光伏组件质量检测领域具有重要应用价值。

全部评论 (0)

还没有任何评论哟~