Halcon产品圆缺陷检测VC源码
#include "HalconCpp.h"
#include <math.h>
using namespace Halcon;
Hobject pImage;
void inspect_bottle_mouth(unsigned int nSmoothX,float* information)
{
using namespace Halcon;
// Local iconic variables
Hobject Image, ImageSmooth, Rectangle, ImageReduced;
Hobject Regions, DarkRegion, RegionOpening, RegionClosing;
Hobject RegionFillUp, RegionBorder, RegionDilation, Edges;
Hobject ContoursSplit, UnionContours, LongestContour, Circle;
Hobject RegionErosion, RegionDifference, ImageReduced1;
Hobject ImagePolar, ImagePart,ImageScaleMax, ImageMean, Connection1;
Hobject SelectedRegions, RegionUnion, XYTransRegion;
// Local control variables
HTuple StoreEmptyRegion, WindowHandle1, Index;
HTuple Width, Height, Number, area1, Row1, Column1, Length;
HTuple Row, Column, Radius, StartPhi, EndPhi, PointOrder;
//用递归过滤器平滑图像
smooth_image(pImage, &ImageSmooth, "gauss", 0.3);
//获取图像的尺寸
get_image_size(ImageSmooth, &Width, &Height);
/* //创建一个平行于坐标轴的矩形
gen_rectangle1(&Rectangle, 50, 100, Height, Width-80);
//图像与区域结合,选取矩形内的区域作为ROI
reduce_domain(ImageSmooth, Rectangle, &ImageReduced);
//利用形态学原理检测螺母
//分割图像,选取灰度值在 80~255 之间的区域
//threshold (ImageReduced, Regions, 140, 255)
threshold(ImageReduced, &Regions, 80, 255); */
//分割图像,选取灰度值在 80~255 之间的区域

本文介绍了一种基于Halcon的圆缺陷检测算法实现,通过图像处理技术如平滑、分割、边缘检测等步骤来识别瓶口缺陷。文章详细展示了如何通过VC源码实现这一过程。
最低0.47元/天 解锁文章

被折叠的 条评论
为什么被折叠?



