halcon-fuse.hdev
来源:互联网 发布:君泽君 知乎 编辑:程序博客网 时间:2024/06/09 21:35
* fuse.hdev: measuring the width of a fuse wire* dev_update_window ('off')dev_close_window ()* ***** step: acquire image* ****read_image (Fuse, 'fuse')get_image_size (Fuse, Width, Height)dev_open_window_fit_image (Fuse, 0, 0, Width, Height, WindowID)set_display_font (WindowID, 12, 'Courier', 'true', 'false')dev_set_draw ('margin')dev_set_line_width (3)dev_display (Fuse)set_display_font (WindowID, 12, 'courier', 'true', 'false')disp_continue_message (WindowID, 'black', 'true')stop ()* ***** step: create measure object* ***** -> specify ROIRow := 297Column := 545Length1 := 90Length2 := 10Angle := rad(90)gen_rectangle2 (ROI, Row, Column, Angle, Length1, Length2)* -> create measure objectgen_measure_rectangle2 (Row, Column, Angle, Length1, Length2, Width, Height, 'bilinear', MeasureHandle)dev_display (ROI)disp_continue_message (WindowID, 'black', 'true')stop ()* ***** step: measure* ****measure_pairs (Fuse, MeasureHandle, 1, 1, 'negative_strongest', 'all', RowEdgeFirst, ColumnEdgeFirst, AmplitudeFirst, RowEdgeSecond, ColumnEdgeSecond, AmplitudeSecond, IntraDistance, InterDistance)disp_continue_message (WindowID, 'black', 'true')stop ()* ***** step: visualize results* ****for i := 0 to |RowEdgeFirst|-1 by 1 row1:= [-sin(Angle+rad(90))*Length2+RowEdgeFirst[i], -sin(Angle-rad(90))*Length2+RowEdgeFirst[i]] column1:=[cos(Angle+rad(90))*Length2+ColumnEdgeFirst[i], cos(Angle-rad(90))*Length2+ColumnEdgeFirst[i]] row2:=[-sin(Angle+rad(90))*Length2+RowEdgeSecond[i], -sin(Angle-rad(90))*Length2+RowEdgeSecond[i]] column2:=[cos(Angle+rad(90))*Length2+ColumnEdgeSecond[i], cos(Angle-rad(90))*Length2+ColumnEdgeSecond[i]] gen_contour_polygon_xld (EdgeFirst, row1, column1) gen_contour_polygon_xld (EdgeSecond, row2, column2) dev_set_color ('cyan') dev_display (EdgeFirst) dev_set_color ('magenta') dev_display (EdgeSecond) dev_set_color ('blue') if (i = 0) set_tposition (WindowID, RowEdgeFirst[i] + 5, ColumnEdgeFirst[i]+20) else set_tposition (WindowID, RowEdgeFirst[i] - 40, ColumnEdgeFirst[i]+20) endif write_string (WindowID, 'width: '+IntraDistance[i]+' pix')endfordisp_continue_message (WindowID, 'black', 'true')stop ()* ***** step: destroy measure object* ****close_measure (MeasureHandle)dev_update_window ('on')dev_clear_window ()
重要函数解析:
gen_rectangle2 (ROI, Row, Column, Angle, Length1, Length2)
产生一个矩形,以便用于显示gen_measure_rectangle2的处理范围
gen_measure_rectangle2 (Row, Column, Angle, Length1, Length2, Width, Height, 'bilinear', MeasureHandle)
产生的这个矩形框将作为感兴趣区域
Prepare the extraction of straight edges perpendicular to a rectangle.
measure_pairs (Fuse, MeasureHandle, 1, 1, 'negative_strongest', 'all', RowEdgeFirst, ColumnEdgeFirst, AmplitudeFirst, RowEdgeSecond, ColumnEdgeSecond, AmplitudeSecond, IntraDistance, InterDistance)
第4个参数阈值比较重要
|
其中各点坐标
A:RowEdgeFirst[0],ColumnEdgeFirst[0]
A':RowEdgeSecond[0],ColumnEdgeSecond[0]
B:RowEdgeFirst[1],ColumnEdgeFirst[1]
B':RowEdgeSecon[1],ColumnEdgeSecond[1]
C:RowEdgeFirst[2],ColumnEdgeFirst[2]
C':RowEdgeSecond[2],ColumnEdgeSecond[2]
本例需要的是保险丝的宽度,即IntraDistance
gen_contour_polygon_xld (EdgeFirst, row1, column1)
本例是根据两点坐标产生一个轮廓EdgeFirst,比如row1=[1,2],column=[11,12],则产生的直线的首尾坐标是(1,11)和(2,12)
本例基本步骤:
1.输入灰度图像
2.gen_measure_rectangle2,划定ROI
3.measure_pairs.在ROI内测量边缘对
- halcon-fuse.hdev
- Halcon MFC VC++ 1D Measureing fuse.hdev
- halcon-measure_ic_leads.hdev
- halcon-clip.hdev
- halcon-disp_xld.hdev
- halcon-edge_segments.hdev
- 【Halcon】Halcon颜色识别之classify_fuses_gmm_based_lut.hdev
- halcon例程学习笔记(2)----check_smd_tilt.hdev
- HALCON 11例程1 25industrial.hdev
- 【Halcon】二维物体识别ball_seq.hdev
- halcon学习笔记之(一)label_word_process_mlp.hdev
- 【Halcon】Blob分析的形态学算子应用(count_pellets.hdev)
- fuse
- fuse
- halcon学习菜鸟级笔记---老老实实学例程1Codabar.hdev
- halcon例程学习笔记(4)---count_fish_sticks.hdev基本函数使用
- halcon例程学习笔记(7)---检测漏焊board.hdev
- halcon例程学习笔记(8)---瓶子编号识别bottle2.hdev
- DWZ (JUI) 403状态扩展
- PHP和MySQL Web开发(第4版)之第1章1.2.1源代码
- ADV7611 HDMI Receiver
- 进程管理和调度
- Tiny_Printf
- halcon-fuse.hdev
- Asp.net 服务端缓存引发的一点思考
- ++i和i++关于[自增运算符]和[顺序点]
- 黑马程序员_学习记录06:静态以及单例设计模式
- C# 线程池详解
- C++ 申请一个动态三维数组
- 服从
- 关于MFC的Debug版和Release版解析
- 堆和栈的区别?