分类器——高斯混合模型之缺陷检测(纹理缺陷检测)
1.halcon-轮廓拟合圆fit_circle_contour_xld2.Halcon 标定例程(calibration-adjust_mosaic_images.hdev)3.Halcon 相机外部参数(camera_calibration_external.hdev)4.halcon 标定5.Halcon 相机内部参数(camera_calibration_internal.hdev)6.halcon 标定算子汇总7.halcon 拼接参考8.halcon 双目相机标定9.HALCON 杂记10.dump_window & dump_window_image 区别11.拟合——直线12.halcon崩溃,未及时保存文件临时存储路径13.halcon-——显示颜色对照表14.矩阵基本操作15.通过高斯的导数获取法向量16.halcon ——从几个不同照明的图像重建表面17.脱离halcon环境运行18.Halcon 一维测量/1D-Measuring19.Halcon——矩阵/Matrix20.dev_set_lut显示效果21.基础设置之——dev_set_check22.基础设置之——dev_open_file_dialog23.基础设置之——dev_open_dialog24.基础设置之——dev_disp_text25.基础操作之——生成一张背景图像26.基础设置之——dev_open_tool27.基本设置之——算术运算28.基础设置之——字符显示格式设置29.基础设置之——条件判断(一)30.基础操作之——tuple基本操作31.基本操作之——位运算32.基本操作之——正弦函数绘制33.基本操作之——多维空间欧几里得距离距离计算及标量积计算34.基本操作之——集合基本操作35.基本操作之——字符截取操作36.基本操作之——Unicode编码37.基本操作之——正则表达式38.基本操作之——字典39.基础设置之——条件判断(二)40.基本操作之——tuple类型41.基本操作之——tuple值分布范围获取42.基本操作之——tuple增删查改操作43.基本操作之——Object比较44.基本操作之——Object插入45.基本操作之——Object差异46.基本操作之——Object移除操作47.基本操作之——Object替换48.分类器——高斯混合模型/Gaussian-Mixture-Models(GMM)之图像分割49.分类器——高斯混合模型之水果分类
50.分类器——高斯混合模型之缺陷检测(纹理缺陷检测)
51.基本操作之——图像纹理处理texture_laws52.分类器——高斯混合模型之查找表分类器(保险丝分类)53.模版匹配——set_shape_model_param54.模板匹配——set_shape_model_clutter55.模板匹配——金字塔图像计算gen_gauss_pyramid56.模板匹配——determine_shape_model_params57.模板匹配——create_shape_model58.模版匹配——inspect_shape_model* This example program shows you how to use the GMM classifier for novelty * detection to perform a web inspection task. To perform the novelty detection, * all pixels belonging to the single trained class are computed, and are then * subtracted from the classification ROI to extract the erroneous pixels. For * the web inspection task, the GMM can consequently be used to detect * textures that do not correspond to the texture of the trained good objects. * 此示例程序向您展示如何使用 GMM 分类器进行新颖性检测以执行 网状检测任务。 *为了执行新颖性检测,将计算属于单个训练类的所有像素,然后从分类 ROI 中减去以提取错误像素。 *因此,对于卷材检测任务,GMM 可用于检测与训练好的物体的纹理不对应的纹理。 * dev_update_off () * ReadPretrainedClassifier := false * 取消注释以下行以从磁盘读取预训练的分类器。训练可能持续长达半分钟。 * ReadPretrainedClassifier := true SaveClassifier := false * 取消注释将 GMM训练样本后将分类器保存到磁盘 * SaveClassifier := true * read_image (Image, 'plastic_mesh/plastic_mesh_01') get_image_size (Image, Width, Height) dev_close_window () dev_open_window (0, 0, Width, Height, 'black', WindowHandle) dev_set_color ('red') set_display_font (WindowHandle, 16, 'mono', 'true', 'false') get_system ('example_dir', HalconExamples) * The texture filters used for the classification will return artifacts at the image * borders because the images of the plastic mesh to be inspected do not * contain an integer number of mesh cells. Because this would lead to wrongly * detected errors at the image borders, we must exclude the area close to the * image border from the training and classification. This is done with the following * rectangle. Note that the image is later scaled down by a factor of two. * 用于分类的纹理过滤器将在图像边框处返回伪影,因为要检查的塑料网格的图像不包含整数个网格单元。 *由于这会导致在图像边界处错误检测到错误,因此我们必须从训练和分类中排除靠近图像边界的区域。 *这是通过以下矩形完成的。 请注意,图像稍后会缩小两倍。 gen_rectangle1 (Rectangle, 10, 10, Height / 2 - 11, Width / 2 - 11) if (ReadPretrainedClassifier) * 从磁盘读取先前训练的GMM模型 dev_display (Image) disp_message (WindowHandle, 'Reading classifier from disk...', 'window', 10, 10, 'cyan', 'false') read_class_gmm (HalconExamples + '/hdevelop/Segmentation/Classification/novelty_detection.gmm', GMMHandle) wait_seconds (1.5) else * 创建GMM模型分类器 create_class_gmm (5, 1, [1,5], 'spherical', 'normalization', 5, 42, GMMHandle) * 以5件完好样品来训练模型 for J := 1 to 5 by 1 read_image (Image, 'plastic_mesh/plastic_mesh_' + J$'02') * The images are zoomed down because the resolution of the mesh is very * high. This saves a large amount of processing time. *由于网格的分辨率非常高,因此图像被缩小。 这节省了大量的处理时间。 zoom_image_factor (Image, ImageZoomed, 0.5, 0.5, 'constant') dev_display (ImageZoomed) disp_message (WindowHandle, '训练样本添加中...', 'window', 10, 10, 'cyan', 'false') * Generate the texture image. *生成纹理图像 gen_texture_image (ImageZoomed, ImageTexture) * 纹理图像添加至分类器 add_samples_image_class_gmm (ImageTexture, Rectangle, GMMHandle, 2.0) endfor dev_display (ImageZoomed) disp_message (WindowHandle, 'Training GMM...', 'window', 10, 10, 'cyan', 'false') * 训练模型. train_class_gmm (GMMHandle, 100, 0.1, 'training', 0.0001, Centers, Iter) if (SaveClassifier) write_class_gmm (GMMHandle, HalconExamples + '/hdevelop/Segmentation/Classification/novelty_detection.gmm') endif endif * 检测塑料网中的异常 dev_set_draw ('margin') dev_set_line_width (3) for J := 1 to 14 by 1 read_image (Image, 'plastic_mesh/plastic_mesh_' + J$'02') zoom_image_factor (Image, ImageZoomed, 0.5, 0.5, 'constant') dev_display (ImageZoomed) dev_set_color ('white') dev_display (Rectangle) gen_texture_image (ImageZoomed, ImageTexture) reduce_domain (ImageTexture, Rectangle, ImageTextureReduced) * Classify samples belonging to the trained class with the GMM. *使用 GMM 对属于训练类的样本进行分类。 classify_image_class_gmm (ImageTextureReduced, Correct, GMMHandle, 0.000002) * Subtract them from the ROI to obtain the texture errors. *从 ROI 中减去它们以获得纹理误差。 difference (Rectangle, Correct, Errors) * Postprocess the returned raw errors to remove insignificant parts of the * detected errors. * 对返回的原始错误进行后处理,以删除检测到的错误中无关紧要的部分。 opening_circle (Errors, ErrorsOpening, 3.5) closing_circle (ErrorsOpening, ErrorsClosing, 10.5) connection (ErrorsClosing, ErrorsConnected) select_shape (ErrorsConnected, FinalErrors, 'area', 'and', 300, 1000000) count_obj (FinalErrors, NumErrors) dev_set_color ('red') dev_display (FinalErrors) if (NumErrors > 0) disp_message (WindowHandle, 'Mesh not OK', 'window', 10, 10, 'red', 'false') else disp_message (WindowHandle, 'Mesh OK', 'window', 10, 10, 'forest green', 'false') endif if (J < 14) disp_continue_message (WindowHandle,'cyan', 'false') endif stop () endfor
------------------------------------
承接
**视觉检测软件开发及调试
**工业软件开发
**上位机软件开发
wechat:luoran2024
qq:565934058
email:taoyuansu@qq.com
海量教育资源及影视资源下载
微信公众号:EFun科技
------------------------------------
合集:
Halcon
分类:
视觉 / HALCON
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!