
Halcon学习
枫呱呱
这个作者很懒,什么都没留下…
展开
-
Halcon学习---案例实战(15)--断裂点提取
inspect_solar_fingers.hdev* For the solar industry, a common problem is the damage of* fingers of solar cells. This example shows how to* extract the broken fingers using morphology.* dev_update_off ()dev_close_window ()ImageName := 'solar_cell/原创 2022-02-28 10:14:09 · 1243 阅读 · 0 评论 -
Halcon学习---案例实战(14)--最大化利用木板有效面积
inner_rectangle1.hdev思路:先将脏点剔除,再用最大内接矩形的方法不断分割木板inner_rectangle1* This example program shows how to use inner_rectangle1 to find knot-free* rectangles in a piece of wood. Typically, the piece of wood is then cut along* the rectangles to obtain kn原创 2022-02-18 11:45:38 · 1951 阅读 · 0 评论 -
Halcon学习---intersection计算直线与圆的交叉点
*求交叉区域intersection (Region1, Region2, RegionIntersection)*求circle与轮廓的交叉点intersection_circle_contour_xld (Contour, CircleRow, CircleColumn, CircleRadius, 0, 6.28318, 'positive', Row, Column)*求直线与轮廓的交叉点(计算的时候会自动延长直线,得到直线的延长线与轮廓的交叉点)intersection_lin.转载 2022-02-17 09:56:06 · 2421 阅读 · 0 评论 -
Halcon学习---案例实战(13)--提取相交点与端点
read_image (Image66134E9b13f720b82e9b, 'G:/6_6134_e9b13f720b82e9b.png')*彩色转灰度rgb1_to_gray(Image66134E9b13f720b82e9b, GrayImage)*提取中间圆区域threshold (GrayImage, Regions, 60, 255)*抠出亮圆区域reduce_domain(GrayImage, Regions, ImageReduced)*图像增强,对比度拉伸emphasiz.原创 2022-02-17 09:38:31 · 3617 阅读 · 0 评论 -
Halcon学习---案例实战(12)--动态阈值使用
crystal.hdev* crystal.hdev: extraction of hexagonally shaped crystals via local thresholding and region post-processing* dev_close_window ()dev_update_window ('off')* ***** step: acquire image* ****read_image (Image, 'crystal')get_image_size (原创 2022-02-11 10:44:46 · 1644 阅读 · 0 评论 -
Halcon学习---案例实战(11)--检测小石子
count_pellets.hdev思想:核心代码很简单,但这里有个技巧;阈值分割后有石头连通在一起,先打散,腐蚀缩小区域,再打散,以同样参数膨胀恢复区域,能很好的分开重叠区域* This programs demonstrates the use of basic morphology* operators.* The aim of the program is to detect each single pellet* (bright particle on a darker backg原创 2022-01-19 10:08:27 · 940 阅读 · 0 评论 -
Halcon学习---案例实战(10)--根据颜色分辨物体
color_fuses.hdev将图像拆分为RGB,再转到HSV,抠出区域后,根据饱和度划分阈值断,以此分辨不同的颜色* color_fuses.hdev: classify fuses by colordev_update_window ('off')* ***** step: set up fuse properties and hue ranges* ****FuseColors := ['Orange','Red','Blue','Yellow','Green']FuseTyp原创 2022-01-18 10:49:01 · 2632 阅读 · 0 评论 -
Halcon学习---案例实战(9)--求物体的方向
clip.hdev这个案例的核心是求物体的角度,核心算子是orientation_region为什么它能判定物体的方向勒,可能是halcon制定了某种规则;具体分析见以下两篇博文:Halcon学习(5.1):orientation_region算子分析_SeventhBlue-优快云博客_halcon orientation_regionhalcon区域方向算子orientation_region参数Phi理解_hsjuzhn的博客-优快云博客_halcon orientation_re原创 2022-01-18 10:20:17 · 2009 阅读 · 0 评论 -
Halcon学习---c++判断图像/数组是否为空
//判断一张halcon图像是否为空int Halcon_img_if_empty(HObject img){ //↓↑↓↓↓↓判断图像是否为空 if (!img.IsInitialized())//IsInitialized只能用来判断图像有无初始化,不能判断图像空不空或有没有 return -1; HTuple hv_n; HObject ho_Null; GenEmptyObj(&ho_Null); TestEqualObj(img, ho_Null, &hv_.原创 2022-01-04 15:17:44 · 1578 阅读 · 0 评论 -
Halcon学习---案例实战(8)--拟合圆
circles.hdev* * The edges in the image are segmented into lines and circles.* For the edges that are part of a circle, the circle parameters* are estimated and the resulting circle is displayed.read_image (Image, 'double_circle')* * Init windowde原创 2021-12-27 17:55:30 · 4203 阅读 · 0 评论 -
Halcon学习---案例实战(7)--饼干完整度检测
check_hazelnut_wafer.hdev* This example demonstrates a quality inspection on hazelnut wavers.* Using the morphology tools the waver is extracted and examined* according to a few shape features like Rectangularity and AreaHoles.* This program also sho原创 2021-12-27 11:43:34 · 674 阅读 · 0 评论 -
Halcon学习--鱼棒长度测量--被测物体显示不全--去除方法
check_fish_stick_dimension.hdev说明: 这个案例不详细分析了,方法很简单,用旋转矩形框测量长度;但里面有一张图片需要注意,图片里面有4个鱼棒,有一个鱼棒在图片的边缘,没有拍全,里面的处理方法能把这个介于边缘的图片筛选出来。...原创 2021-12-27 11:33:08 · 520 阅读 · 0 评论 -
Halcon学习---案例实战(6)--瓶子计数
check_bottle_crate.hdev* This example counts bottles in bottle crates of returned empties.* With diffuse front light, correctly inserted bottles can* be segmented relatively easy with a simple thresholding operation,* followed by some basic morpholog原创 2021-12-27 10:00:56 · 1552 阅读 · 0 评论 -
Halcon学习---案例实战(5)--药片检测(高斯混合模型分类)
check_blister_mixed.hdev说明:这个案例很有意思,既运用了Blob分析定位+决策判断,也运用了高斯混合模型进行训练分类;把这个案例反复读几遍,抠细节,体会整个解题思路;* This example demonstrates an application from the pharmaceutical* industry. The task is to check the content of manually filled* blisters. The first i原创 2021-12-24 15:32:22 · 2181 阅读 · 0 评论 -
Halcon学习---案例实战(4)--药片检测
check_blister.hdev* This example demonstrates an application from the pharmaceutical* industry. The task is to check the content of automatically filled* blisters. The first image (reference) is used to locate the chambers* within a blister shape as.原创 2021-12-23 18:03:43 · 1457 阅读 · 0 评论 -
Halcon学习---案例实战(3)--球焊检查2
ball_seq.hdev* ball_seq.hdev: Inspection of Ball Bonding* dev_update_off ()ImageNames := 'die/' + ['die_02','die_03','die_04','die_07']dev_set_colored (12)read_image (Bond, ImageNames[0])get_image_size (Bond, Width, Height)dev_close_window ()dev原创 2021-12-23 15:51:01 · 268 阅读 · 0 评论 -
Halcon学习---案例实战(2)--球焊检查
ball.hdev* ball.hdev: Inspection of Ball Bonding* dev_update_window ('off')dev_close_window ()dev_open_window (0, 0, 728, 512, 'black', WindowID)read_image (Bond, 'die/die_03')dev_display (Bond)set_display_font (WindowID, 14, 'mono', 'true', 'fal原创 2021-12-23 14:20:13 · 450 阅读 · 0 评论 -
Halcon学习---案例实战(1)--车道线检测
autobahn.hdev* autobahn.hdev: Fast detection of lane markers* dev_update_window ('off')dev_close_window ()dev_open_window (0, 0, 768, 575, 'black', WindowID)MinSize := 30get_system ('init_new_image', Information)set_system ('init_new_image', 'fal原创 2021-12-23 13:48:45 · 2320 阅读 · 0 评论 -
Halcon学习--凹痕检测
read_image (Image002, 'G:/learning_halcon_file/img/001.png')decompose3(Image002, R, G, B)trans_from_rgb(R, G, B, H, S, V, 'hsv')binary_threshold(H, Region1, 'max_separability', 'light', UsedThreshold)connection(Region1, ConnectedRegions1)select_s.原创 2021-06-10 18:08:32 · 1585 阅读 · 0 评论 -
Halcon学习--深度学习(5)--classify_预处理、训练、验证、推断的简化过程
dev_close_window ()dev_update_off ()set_system ('seed_rand', 42)* * *** 0) SET INPUT/OUTPUT PATHS **** get_system ('example_dir', PathExample)* Give all folders that contain images.ImageBaseFolder := PathExample + '/images/food/'RawImageFold..原创 2021-06-08 15:59:29 · 1541 阅读 · 0 评论 -
Halcon学习--深度学习(3)-classify_evaluation
* * This example is part of a series of examples, which summarizes* the workflow for DL classification. It uses the MVTec pill dataset.* The four parts are:* 1. Dataset preprocessing* 2. Training of the model.* 3. Evaluation of the trained model.* .原创 2021-06-08 10:04:42 · 715 阅读 · 1 评论 -
Halcon学习--深度学习(2)-classify_train
* * This example is part of a series of examples, which summarizes* the workflow for DL classification. It uses the MVTec pill dataset.* * The four parts are:* 1. Dataset preprocessing.* 2. Training of the model.* 3. Evaluation of the trained model.原创 2021-06-07 17:47:30 · 854 阅读 · 0 评论 -
Halcon学习--深度学习(1)-classify_preprocess
* * This example is part of a series of examples, which summarizes* the workflow for DL classification. It uses the MVTec pill dataset.* * The four parts are:* 1. Dataset preprocessing.* 2. Training of the model.* 3. Evaluation of the trained model.原创 2021-06-07 16:07:59 · 851 阅读 · 0 评论 -
Halcon学习--数组操作
assign:对数据赋值,对数组的初始化。但不能对数组中的某一个值进行赋值。举例:Tuple1:=[1,0,3,4,5,6,7,8,9]//对数组进行初始化Val:=sin(1.2)+cos(1.2) //对某一个值进行赋值 Tuple2:=[] //数组定义assign_at:对数组中的某一个值进行赋值。举例:Tuple1...转载 2020-11-02 13:58:31 · 8881 阅读 · 0 评论 -
Halcon学习---车牌识别简单应用
read_image (T0153a1b02bef525641, '../img/car_id.jpg')dev_close_window ()dev_open_window (0, 0, 512, 512, 'black', WindowHandle)*拆分为三个通道decompose3 (T0153a1b02bef525641, R, G, B)*转换到hsv控件trans_from_rgb (R, G, B, ImageResult1, ImageResult2, ImageResu.原创 2020-09-07 14:56:59 · 624 阅读 · 0 评论 -
Halcon学习---精准找出被检测区域的矩形轮廓
find_pads.hdevdev_update_pc ('off')dev_update_window ('off')dev_update_var ('off')read_image (Image, 'die_pads')dev_close_window ()get_image_size (Image, Width, Height)dev_open_window (0, 0, Width * 2, Height * 2, 'black', WindowHandle)dev_set_pa原创 2020-07-04 13:55:48 · 9894 阅读 · 3 评论 -
Haclon学习---饼干完整度检测
check_hazelnut_wafers.hdevread_image (Image, 'food/hazelnut_wafer_01')dev_close_window ()dev_open_window_fit_image (Image, 0, 0, -1, -1, WindowHandle)dev_update_window ('off')dev_set_line_width (3)dev_set_draw ('margin')set_display_font (WindowHan原创 2020-07-02 14:38:46 · 423 阅读 · 0 评论 -
Halcon学习---边界轮廓提取与圆弧段拟合
circles.hdevread_image (Image, 'double_circle')* * Init windowdev_close_window ()get_image_size (Image, Width, Height)dev_open_window (0, 0, Width, Height, 'black', WindowHandle)* * Segment a region containing the edges*快速阈值分割fast_threshold (Im原创 2020-07-02 13:54:51 · 9323 阅读 · 0 评论 -
Halcon学习---分割连通域connection的用法
connection.hdevread_image (Image, 'mreut')*二值化,可用灰度直方图进行可视化threshold (Image, Region, 190, 255)*将不相连的区域都分割成单独的区域connection (Region, ConnectedRegions)*根据面积进行特征选择,可用特征直方图进行可视化,只选出有道路的区域select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 5原创 2020-07-01 16:58:49 · 9986 阅读 · 3 评论 -
Halcon学习---鱼棒宽度的合格性检测
count_fish_sticks.hdev* This program performs a completeness check by counting the* fish sticks contained in each package.* Here, one-dimensional measuring tools are used to determine* the boundary between adjacent fish sticks.* dev_update_off (.原创 2020-06-29 17:17:08 · 801 阅读 · 0 评论 -
Halcon---基本形态学操作分割豆子,并计数
count_pellets.hdev* This programs demonstrates the use of basic morphology* operators.* The aim of the program is to detect each single pellet* (bright particle on a darker background).* dev_update_off ()read_image (Image, 'pellets')dev_close_win原创 2020-06-28 15:39:44 · 1822 阅读 · 0 评论 -
Halcon学习---提取六边形晶体气泡
crystal.hdevdev_close_window ()dev_update_window ('off')* ***** step: acquire image* ****read_image (Image, 'crystal')get_image_size (Image, Width, Height)dev_open_window_fit_image (Image, 0, 0, Width, Height, WindowID)set_display_font (WindowID原创 2020-06-28 15:12:01 · 1219 阅读 · 0 评论 -
Halcon学习---提取连续的不规则边缘
思路:边缘提取---》阈值分割(1-255)---》分割连通域---》将每个小区域,根据线的曲率分割成多个线段---》根据线段生成多边形edge_segments.hdevdev_update_off ()dev_close_window ()* ***** step: acquire image* ****read_image (Image, 'mreut')get_image_size (Image, Width, Height)dev_open_window_fit_im.原创 2020-06-28 11:57:23 · 2294 阅读 · 0 评论 -
Halcon学习---毛刺凸点检测
思路:二进制阈值分割图像---》用圆形区域进行闭运算---》背景差分,得出不同点---》用矩形开操作去除小点,保留真正的差异点---》得到真正差异点的面积和中心点fin.hdevdev_update_window ('off')read_image (Fins, 'fin' + [1:3])get_image_size (Fins, Width, Height)dev_close_window ()dev_open_window (0, 0, Width[0], Height[0], 'b原创 2020-06-28 11:20:39 · 4484 阅读 · 0 评论 -
Halcon学习---提取圆孔区域并测量圆孔直径
measure_ball_bond.hdevdev_update_off ()dev_close_window ()FileName := 'bonds/ball_bond_ccd_'read_image (Image, FileName + 1$'02')dev_open_window_fit_image (Image, 0, 0, -1, -1, WindowHandle)dev_set_line_width (2)set_display_font (WindowHandle, .原创 2020-06-24 15:07:20 · 3906 阅读 · 3 评论 -
Halcon学习---玻璃瓶口的缺陷检测
inspect_bottle_mouth.hdev巧妙运用了极坐标变换法,细节很精细,值得学习* tuning parametersSmoothX := 501ThresholdOffset := 25MinDefectSize := 50* * initializationPolarResolution := 640RingSize := 70get_system ('store_empty_region', StoreEmptyRegion)set_system ('stor原创 2020-06-20 16:23:21 · 2542 阅读 · 1 评论 -
Halcon学习---高度纹理图像中的mura缺陷
对应示例程序:detect_mura_defects_texture.hdev目标:实现高纹理图像中缺陷的检测(黑色)。思路为:1.对彩色图像进行R G B分解,选取B作为后续图像。2. 生成背景模板,将图像傅里叶变换到频域中,通过高斯滤波,然后傅里叶反变换回来,得到的图像就是背景模板。3 .背景差分。采用sub_image函数进行图像差分,增强两幅图像的差异4 .分水岭算法分割,在分割之前采用中值滤波来抑制小斑点或细线。分水岭后,图像分割为多个轮廓(region)。5 .计算多个轮廓re转载 2020-06-19 17:38:23 · 1216 阅读 · 0 评论 -
Halcon学习之缺陷检测-凸点检测
思路:读取图片--》图片转化为灰度---》快速傅里叶变换把图像转到频域---》频域滤波器进行卷积---》快速傅里叶反变换---》用一个矩形掩膜计算像素点的灰度范围---》求图片灰度值的最大和最小值和变换范围---》利用全局阈值对图像进行分割---》连通区域---》根据面积筛选区域---》合并区域---》使用圆形元素对区域进行闭运算---》连通区域---》根据面积筛选区域---》计算区域的面积以及中心位置---》显示结果例程:detect_indent_fft.hdev说明:这个程序展示了如何利用快速原创 2020-06-19 16:19:00 · 3294 阅读 · 0 评论 -
Halcon学习---颜色通道的改变分割披萨饼
*读取披萨图片,一个碗中好多披萨read_image(Image1,'./color/pizza_03.png') *将图片拆分成RGB的三通道decompose3(Image1, red, green, blue)*将RGB分别转到HSVtrans_from_rgb(red, green, blue, ImageH, ImageS, ImageV, 'hsv')*阈值分割S通道图片threshold (ImageS, Regions1, 46, 60)*连接各区域connection(.原创 2020-06-17 20:05:36 · 585 阅读 · 0 评论