├── .gitignore
├── Doc
├── SolutionGuides
│ └── Solution Guide II-A
│ │ └── ImageAcquisition.hdev
└── reference
│ └── acquisition
│ ├── acq-overview.html
│ ├── hAcqBitFlow.html
│ ├── hAcqDirectFile.html
│ ├── hAcqDirectShow.html
│ ├── hAcqEnsenso-NxLib.html
│ ├── hAcqFile.html
│ ├── hAcqGenICamTL.html
│ ├── hAcqGigEVision2.html
│ ├── hAcqLinX.html
│ ├── hAcqMILLite.html
│ ├── hAcqMultiCam.html
│ ├── hAcqO3D3xx.html
│ ├── hAcqSICK-3DCamera.html
│ ├── hAcqSaperaLT.html
│ ├── hAcqSiliconSoftware.html
│ ├── hAcqUSB3Vision.html
│ ├── hAcqVideo4Linux2.html
│ ├── hAcqpylon.html
│ └── hAcquEye.html
├── Example
├── CSDN
│ └── halcon测量:用卡尺找边
│ │ ├── 1.jpg
│ │ └── empty.hdev
├── MVBBS
│ └── segment_logo.hdev
└── README.md
├── GitProj
└── Halcon-master.zip
├── HalconCpp
├── Configuration1.png
├── Configuration2.png
├── Configuration3.png
├── Configuration4.png
├── Configuration5.png
├── Configuration6.png
├── Configuration7.png
├── Create Project1.png
├── Create Project2.png
├── Create Project3.png
├── HalCppException
│ ├── HalCppException.md
│ └── InstrumentRecognition.cpp
├── Halcon18.5VS2017
│ ├── Halcon18.5VS2017.sln
│ └── Halcon18.5VS2017
│ │ ├── Hal.cpp
│ │ ├── Hal.h
│ │ ├── Halcon18.5VS2017.cpp
│ │ ├── Halcon18.5VS2017.vcxproj
│ │ ├── Halcon18.5VS2017.vcxproj.filters
│ │ ├── Led.cpp
│ │ ├── pch.cpp
│ │ └── pch.h
├── HalconX64.vssettings
├── HalconX64.zip
└── README.md
├── HalconProcedures
└── 51halcon
│ ├── Halcon拟合圆spoke、拟合直线算子rake 用于测量
│ └── 1.png
│ ├── halcon找顶点函数
│ ├── 1 画roi.JPG
│ ├── 11.bmp
│ ├── 2 检测结果.JPG
│ └── arrow.png
│ └── 用spoke提取圆心坐标及半径
│ └── 1.jpg
├── HalconProj
├── Barcode
│ ├── BarCodeHandle.bcm
│ ├── BarCodeHandle0605.bcm
│ ├── DataCodeHandle.dcm
│ ├── README.md
│ ├── barcode_training.hdev
│ ├── empty.hdev
│ ├── image_display_barcode.hdvp
│ ├── image_display_datacode.hdvp
│ ├── image_get_bar.hdvp
│ ├── image_seg_bar.hdvp
│ └── test_barcode.hdvp
├── Cali
│ ├── CaliGenFunc.hdev
│ ├── CaliGenMap.hdev
│ ├── CaliGenMapFunc.hdev
│ ├── CaliPreImage.hdev
│ ├── HK2.cal
│ ├── HK2.dat
│ ├── HalconExampleCaliImages-scratch - 快捷方式.lnk
│ ├── README.md
│ ├── caltab.descr
│ ├── caltab.pdf
│ ├── caltab.ps
│ └── scratch - 快捷方式.lnk
├── Cam
│ ├── CamCap.hdev
│ └── CamLive.hdev
├── Color
│ ├── Color.md
│ ├── ColorDetectionPaper.hdev
│ └── MonoDetectionPaperCam.hdev
├── DefectDetection
│ ├── Egg
│ │ └── empty.hdev
│ └── empty.hdev
├── Detection
│ ├── DetectionCircle.hdev
│ ├── DetectionLine.hdev
│ ├── DetectionLines.hdev
│ ├── DetectionModel.hdev
│ ├── DetectionPeak.hdev
│ └── image_get_corner_line.hdvp
├── Display
│ └── Display.hdev
├── Enhance
│ ├── Enhance.hdev
│ └── Enhance.md
├── Export
│ ├── Export.png
│ ├── ExportV1.md
│ ├── ExportV2.md
│ └── ExportV2.png
├── Filter
│ ├── Filter.hdev
│ └── Filter.md
├── Line
│ ├── Line.hdev
│ ├── Line.jpg
│ ├── Line.md
│ ├── LineCrossMain.hdev
│ └── LineDetectionMain.hdev
├── Localization
│ ├── Localization.md
│ └── Mark
│ │ └── Mark.md
├── MixedLang
│ ├── MixedLang.cs
│ ├── MixedLang.hdev
│ └── MixedLang.md
├── Preprocessing
│ ├── BW.hdev
│ ├── CaliMapMainPre.hdev
│ ├── PicPre.hdev
│ ├── Preprocessing.hdev
│ └── Rgb2Gray.hdev
├── README.md
├── Read
│ ├── Read.cpp
│ ├── Read.cs
│ ├── Read.hdev
│ └── ReadMain.cs
├── Region
│ ├── Region.hdev
│ └── Region.md
├── Robot
│ └── Precision.hdev
├── Rotate
│ └── RotateTest.hdev
├── Segmentation
│ ├── SegObjects.hdev
│ └── SegmentationPcb.hdev
├── Shadow
│ ├── Shadow.hdev
│ └── Shadow.md
├── Socket
│ ├── Client.hdev
│ └── Server.hdev
├── Status
│ ├── README.md
│ └── StatusMain.hdev
├── Stitch
│ └── HalconProj.hdev
└── Window
│ ├── Window.hdev
│ └── Window.md
├── Images
├── Circle.PNG
├── CircleGear.png
├── CirclePcb.jpg
├── DetectionPeak (1).JPG
├── DetectionPeak (2).JPG
├── IntelLogo.jpeg
├── LineBarcode.jpg
├── Model.jpg
├── Pcb1.png
├── Pcb2.png
├── PeakArrow.png
├── PeakRake.bmp
└── lena.png
├── LICENSE
├── Procedures
├── 3rd
│ ├── README.md
│ ├── draw_rake.hdvp
│ ├── draw_spoke2.hdvp
│ ├── find_peak_point.hdvp
│ ├── find_peak_ponit_2.hdvp
│ ├── gen_measure_pairs.hdvp
│ ├── get_rectangle_points.hdvp
│ ├── measur_edges_tool.hdvp
│ ├── measure_edges_tool.hdvp
│ ├── measure_pairs_tool.hdvp
│ ├── p_disp_edge_marker.hdvp
│ ├── peak.hdvp
│ ├── pts_to_best_circle.hdvp
│ ├── pts_to_best_line.hdvp
│ ├── rake.hdvp
│ ├── rect1_gen_lines.hdev
│ ├── rect2_gen_lines.hdev
│ ├── region_to_spoke.hdvp
│ ├── roi_gen_lines.hdev
│ ├── select_min_max_length_contour.hdvp
│ ├── spoke.hdvp
│ └── spoke2.hdvp
├── Own
│ ├── image_cali_map.hdvp
│ ├── image_judge_stop.hdvp
│ ├── image_seg_paper.hdvp
│ └── region_get_corner.hdvp
└── inte_xld.hdev
├── README.md
├── Textbook
└── Halcon数字图像处理
│ ├── c3s1.hdev
│ ├── c3s2.hdev
│ ├── c3s3.hdev
│ ├── c4s1.hdev
│ ├── c4s2.hdev
│ ├── c4s3.hdev
│ ├── c5s1.hdev
│ ├── c5s2.hdev
│ ├── c5s3.hdev
│ ├── c6s1.hdev
│ ├── c6s2.hdev
│ ├── c6s3.hdev
│ ├── c6s4.hdev
│ ├── c6s5.hdev
│ ├── c6s6.hdev
│ ├── c7s1.hdev
│ ├── c7s2.hdev
│ ├── c7s3.hdev
│ ├── c7s4.hdev
│ ├── c7s5.hdev
│ ├── c7s6.hdev
│ ├── c8s1.hdev
│ ├── c9s1.hdev
│ └── c9s2.hdev
└── empty.hdev
/Doc/SolutionGuides/Solution Guide II-A/ImageAcquisition.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | *Chapter 2
7 |
8 | * Image Acquisition 01: Code generated by Image Acquisition 01
9 | * open_framegrabber ('DirectShow', 1, 1, 0, 0, 0, 0, 'default', 8, 'rgb', -1, 'false', 'default', '[0] ', 0, -1, AcqHandle)
10 | * grab_image_start (AcqHandle, -1)
11 | * grab_image_async (Image, AcqHandle, -1)
12 | * stop ()
13 | * grab_image_async (Image1, AcqHandle, -1)
14 |
15 | * Image Acquisition 01: Do something
16 | * close_framegrabber (AcqHandle)
17 |
18 |
19 | * Image Acquisition 01: Code generated by Image Acquisition 01
20 | * open_framegrabber ('DirectShow', 1, 1, 0, 0, 0, 0, 'default', 8, 'rgb', -1, 'false', 'default', '[0] ', 0, -1, AcqHandle)
21 | * grab_image_start (AcqHandle, -1)
22 | * while (true)
23 | * grab_image_async (Image, AcqHandle, -1)
24 | * Image Acquisition 01: Do something
25 | * write_image (Image, 'tiff', 0, 'cam')
26 | * endwhile
27 | * close_framegrabber (AcqHandle)
28 |
29 |
30 | read_image (Image, 'cam')
31 | dev_display (Image)
32 | auto_threshold (Image, Regions, 10)
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/Example/CSDN/halcon测量:用卡尺找边/1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/liuwake/HalconPractise/42c2bf5b75c380a1261d830be171a264c641a9f4/Example/CSDN/halcon测量:用卡尺找边/1.jpg
--------------------------------------------------------------------------------
/Example/CSDN/halcon测量:用卡尺找边/empty.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | dev_get_window (WindowHandle)
7 |
8 | *读图
9 | read_image (Image, '1.jpg')
10 | get_image_size (Image, Width, Height)
11 |
12 | *在我们要检的边界上画线
13 | draw_line (WindowHandle, Row1, Column1, Row2, Column2)
14 | shapeParam:= [Row1,Column1,Row2,Column2]
15 |
16 | *创建句柄
17 | create_metrology_model (MetrologyHandle)
18 | set_metrology_model_image_size (MetrologyHandle, Width, Height)
19 |
20 | *添加线模型
21 | add_metrology_object_generic (MetrologyHandle, 'line', shapeParam, 20, 5, 1, 30, [], [], Index)
22 |
23 | *设置参数,这里根据自己需求设置,这一坨用的都是同一个算子
24 | set_metrology_object_param (MetrologyHandle, 'all', 'measure_transition', 'negative')
25 | set_metrology_object_param (MetrologyHandle, 'all', 'num_measures',50)
26 | set_metrology_object_param (MetrologyHandle, 'all', 'num_instances', 40)
27 | set_metrology_object_param (MetrologyHandle, 'all', 'measure_sigma', 1)
28 | set_metrology_object_param (MetrologyHandle, 'all', 'measure_length1', 80)
29 | set_metrology_object_param (MetrologyHandle, 'all', 'measure_length2', 1)
30 | set_metrology_object_param (MetrologyHandle, 'all', 'measure_threshold',50)
31 | set_metrology_object_param (MetrologyHandle, 'all', 'measure_interpolation', 'bicubic')
32 | set_metrology_object_param (MetrologyHandle, 'all', 'measure_select', 'all')
33 | set_metrology_object_param (MetrologyHandle, 'all', 'min_score', 0.7)
34 |
35 | *开始找边缘,顺便把边缘上卡尺找到的所有点坐标输出在ROW,Column里面(数组形式)
36 | apply_metrology_model (Image, MetrologyHandle)
37 | get_metrology_object_measures (Contours, MetrologyHandle, 'all', 'all', Row, Column)
38 |
39 | dev_set_line_width (5)
40 | *把点显示出来
41 | gen_cross_contour_xld (Cross, Row, Column, 6, 0.785398)
42 |
43 | *得到线的起点和终点坐标并显示出来
44 | get_metrology_object_result (MetrologyHandle, 'all', 'all', 'result_type', 'all_param', Parameter)
45 | get_metrology_object_result_contour (Contour, MetrologyHandle, 'all', 'all', 1.5)
46 |
47 | *释放测量句柄
48 | clear_metrology_model (MetrologyHandle)
49 |
50 |
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/Example/MVBBS/segment_logo.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | **** Misc
7 | ** Data Create: 2020/12/30
8 | ** Data Modify: None
9 | ** Contributor: Wake
10 | **** Log
11 | ** 2020/12/30 Created and run M1 and M2; Debug 1;
12 |
13 |
14 | ** Init
15 | * Init Env
16 |
17 | dev_close_window ()
18 | dev_update_off ()
19 |
20 | * read Image
21 |
22 | read_image (Image, 'C:/Users/iwake/OneDrive - wake/Desktop/HalconPractise/Images/IntelLogo.jpeg')
23 |
24 |
25 |
26 | ** Method 1
27 |
28 |
29 | * mean_image (Image, ImageMean, 30, 30)
30 |
31 | * dyn_threshold (Image, ImageMean, RegionDynThresh, 3, 'dark')
32 |
33 | * connection (RegionDynThresh, ConnectedRegions)
34 |
35 | * select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 200, 99999)
36 |
37 | * closing_circle (SelectedRegions, RegionClosing, 5)
38 |
39 | **方法2
40 |
41 | * rgb1_to_gray(Image, Image)
42 |
43 | * get_image_size(Image, Width, Height)
44 |
45 | * Sigma1 :=0.7
46 |
47 | * gen_gauss_filter (GaussFilter1, Sigma1, Sigma1, 0.0, 'none', 'rft', Width, Height)
48 |
49 | * Perform the convolution in the frequency domain
50 |
51 | * rft_generic (Image, ImageFFT, 'to_freq', 'none', 'complex', Width)
52 |
53 | * convol_fft (ImageFFT, GaussFilter1, ImageConvol)
54 |
55 | * rft_generic (ImageConvol, ImageFiltered, 'from_freq', 'n', 'real', Width)
56 |
57 | * stop()
58 |
59 | * mean_image(ImageFiltered, ImageMean, 80, 110)
60 |
61 | * dyn_threshold(ImageFiltered, ImageMean, RegionDynThresh, 4, 'dark')
62 |
63 | * connection(RegionDynThresh, ConnectedRegions)
64 |
65 | * select_shape(ConnectedRegions, SelectedRegions, 'area', 'and',150, 99999)
66 |
67 | *方法3
68 |
69 | get_image_size(Image, Width, Height)
70 |
71 | dev_close_window()
72 |
73 | dev_open_window_fit_image(Image, 0, 0, Width, Height, WindowHandle)
74 |
75 | dev_display(Image)
76 |
77 | decompose3(Image, R, G, B)
78 |
79 | trans_from_rgb(R, G, B, H, S, V, 'hsv')
80 |
81 | scale_image_max(V, ImageScaleMax)
82 |
83 | emphasize(ImageScaleMax, ImageEmphasize, 25, 25, 5)
84 | threshold (ImageEmphasize, Regions, 100, 255) //阈值参数调试不适合,所以字母A,M在转角处有空缺;已调整成功
85 |
86 |
87 | complement(Regions, RegionComplement)
88 |
89 | connection(RegionComplement, ConnectedRegions)
90 |
91 | select_shape(ConnectedRegions, SelectedRegions, 'area', 'and', 210, 99999)
92 |
93 |
94 |
95 | ** dilation_circle(SelectedRegions, RegionDilation, 2.5)也可
96 |
97 | expand_region(SelectedRegions, SelectedRegions, RegionExpanded, 2, 'image')
98 |
99 | dev_set_draw('fill')
100 |
101 | dev_display(Image)
102 |
103 | dev_display(RegionExpanded)
104 |
105 | *方法4
106 |
107 |
108 |
109 | * rgb1_to_gray (Image, GrayImage)
110 |
111 | * scale_image_max (Image, ImageScaleMax1)
112 |
113 | * emphasize (ImageScaleMax1, ImageEmphasize1, 25, 25, 5)
114 |
115 | * threshold (ImageEmphasize1, Region, 0, 40)
116 |
117 | * connection (Region, ConnectedRegions1)
118 |
119 | * select_shape (ConnectedRegions1, SelectedRegions1, 'area', 'and', 200, 99999)
120 |
121 | * dilation_circle (SelectedRegions1, RegionDilation, 2)
122 |
123 |
124 |
125 |
126 |
127 |
128 |
--------------------------------------------------------------------------------
/Example/README.md:
--------------------------------------------------------------------------------
1 | #
2 |
3 | ## Example
4 | ----
5 | ## hdevelop
6 |
7 | ```C:\Users\Public\Documents\MVTec\HALCON-18.11-Steady\examples```
8 | ### Filters
9 | #### Geometric-Transformations
10 | - [ ] affine_transform_image.hdev
11 | - [ ]
12 |
13 |
14 | ----
15 | ## Applications
16 |
17 | `C:\Users\Public\Documents\MVTec\HALCON-18.11-Steady\examples\hdevelop\Applications\` and `/opt/MVTec/HALCON-23.11-Progress/examples/hdevelop/Applications/`
18 |
19 | ### Object-Recognition-2D
20 | - classify_pills_auto_select_features.hdev
21 | - 分割药片.可以用来分割硬币,蛤蜊等.
22 |
23 |
24 | ### Completeness-Check 完整性检测
25 | - [x] segment_plants:分割树叶
26 | - [x] 转换到cielab颜色空间;利用segment_image_mser分割.
27 |
28 | ### Bar-Codes
29 | - [x] circular_barcode:圆拉伸变换
30 | - [x] 轴承变换,识别二维码
31 |
32 |
33 | ### SurfaceInspect
34 | #### 表面
35 | - [x] detect_indent_fft.hdev Detect defects on the surface of plastic items
36 | - 在塑料表面检测突起
37 | - [x] detect_mura_defects_blur.hdev
38 | - [ ] Detect mura defects in blurred images
39 | - [ ] 在*模糊?*图像中检测不均匀(线状)
40 | - [x] detect_mura_defects_texture.hdev
41 | - [ ] xx
42 | - [x] 检测不匀纹理
43 | #### 光度立体学
44 | - [ ] determine_tilt_slant_photometric_stereo.hdev
45 | - [x] 照圆球光照角度
46 | - [ ] inspect_blister_photometric_stereo.hdev
47 | - [ ] 光度立体学检测药片锡纸包装起泡(blister)
48 | - [ ] inspect_flooring_photometric_stereo.hdev
49 | - [ ] 光度立体学检测墙面
50 | - [ ] inspect_flooring_uncalib_photometric_stereo.hdev
51 | - [ ] 同上,没cali
52 | - [ ] inspect_leather_photometric_stereo.hdev
53 | - [ ] 皮革
54 | - [ ] inspect_shampoo_label_photometric_stereo.hdev
55 | - [ ] 洗发水瓶子
56 |
57 | ### 3D
58 | - check_for_holes_sheet_of_light.hdev
59 | - 检测孔眼
60 | - compare_surface_sheet_of_light.hdev
61 | - 用什么方法检测零件??
62 |
63 | ## Method 方法
64 | ### 拼接
65 |
66 | - [x] adjust_mosaic_images
67 | - [ ] 教堂图片弯曲拼接
68 | - [x] blended_mosaic
69 | - [ ] 教堂图片弯曲拼接,*???啥区别*
70 | - [x] bundle_adjusted_mosaicking
71 | - [ ] 10张芯片拼成一张*??? 啥区别*
72 | - [x] *gen_projective_mosaic*
73 | - [ ] 6张PCB拼一张
74 | - [ ] 适合面阵车底拼接
75 |
76 |
77 | - [x] mosaicking
78 | - [ ] 10张芯片拼成一张
79 | - [x] inspect_bottle_label_360_degree.hdev
80 | - [x] 4张图像恢复瓶身标签带
81 | - [x] mosaicking_pyramid.hdev
82 | - [x] 两张芯片图像不同金字塔层级拼接,并比较速度.
83 | - [x] proj_match_points_distortion_ransac.hdev
84 | - [ ] 两张楼房图片成功(失败)拼接
85 | - [ ] proj_match_points_distortion_ransac_guided
86 | - [x] 两张楼房图片成功拼接 *???guided*
87 | - [x] stationary_camera_self_calibration
88 | - [ ] *标定*
89 |
90 | ----
91 | ## solution_guide
92 | ```C:\Users\Public\Documents\MVTec\HALCON-18.11-Steady\examples\solution_guide```
93 | ### 1d_measuring
94 | - [ ] measure_ring
95 | - [ ] 测量多个螺母的半径
96 | - [ ] 测试运行,效果测量了一行螺母的半径?
97 |
98 |
99 | ### 3d_vision
100 | - [ ] two_camera_calibration
101 | - [ ] 双cam cali拼接尺子图像,并测算损失
102 |
103 | - [ ] Ref
104 | - [x] [Halcon一日一练:图像拼接技术2:步骤与例程](https://www.cnblogs.com/amosyang/p/8478213.html?utm_source=debugrun&utm_medium=referral) 中文讲解
--------------------------------------------------------------------------------
/GitProj/Halcon-master.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/liuwake/HalconPractise/42c2bf5b75c380a1261d830be171a264c641a9f4/GitProj/Halcon-master.zip
--------------------------------------------------------------------------------
/HalconCpp/Configuration1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/liuwake/HalconPractise/42c2bf5b75c380a1261d830be171a264c641a9f4/HalconCpp/Configuration1.png
--------------------------------------------------------------------------------
/HalconCpp/Configuration2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/liuwake/HalconPractise/42c2bf5b75c380a1261d830be171a264c641a9f4/HalconCpp/Configuration2.png
--------------------------------------------------------------------------------
/HalconCpp/Configuration3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/liuwake/HalconPractise/42c2bf5b75c380a1261d830be171a264c641a9f4/HalconCpp/Configuration3.png
--------------------------------------------------------------------------------
/HalconCpp/Configuration4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/liuwake/HalconPractise/42c2bf5b75c380a1261d830be171a264c641a9f4/HalconCpp/Configuration4.png
--------------------------------------------------------------------------------
/HalconCpp/Configuration5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/liuwake/HalconPractise/42c2bf5b75c380a1261d830be171a264c641a9f4/HalconCpp/Configuration5.png
--------------------------------------------------------------------------------
/HalconCpp/Configuration6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/liuwake/HalconPractise/42c2bf5b75c380a1261d830be171a264c641a9f4/HalconCpp/Configuration6.png
--------------------------------------------------------------------------------
/HalconCpp/Configuration7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/liuwake/HalconPractise/42c2bf5b75c380a1261d830be171a264c641a9f4/HalconCpp/Configuration7.png
--------------------------------------------------------------------------------
/HalconCpp/Create Project1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/liuwake/HalconPractise/42c2bf5b75c380a1261d830be171a264c641a9f4/HalconCpp/Create Project1.png
--------------------------------------------------------------------------------
/HalconCpp/Create Project2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/liuwake/HalconPractise/42c2bf5b75c380a1261d830be171a264c641a9f4/HalconCpp/Create Project2.png
--------------------------------------------------------------------------------
/HalconCpp/Create Project3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/liuwake/HalconPractise/42c2bf5b75c380a1261d830be171a264c641a9f4/HalconCpp/Create Project3.png
--------------------------------------------------------------------------------
/HalconCpp/HalCppException/HalCppException.md:
--------------------------------------------------------------------------------
1 | #
2 |
3 | ##
4 |
5 | ###
6 |
7 | ```
8 | try
9 | {
10 | //Halcon procedures
11 | //ResultAnalog = Analog(InstrumentPath, ImageAnalogPath);
12 | //std::cout << ResultAnalog << "\n";
13 | }
14 | catch (HException &except) {
15 | //Print to console
16 | std::cout << string(except.ErrorMessage()) << "\n";
17 | }
18 |
19 | ```
--------------------------------------------------------------------------------
/HalconCpp/HalCppException/InstrumentRecognition.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/liuwake/HalconPractise/42c2bf5b75c380a1261d830be171a264c641a9f4/HalconCpp/HalCppException/InstrumentRecognition.cpp
--------------------------------------------------------------------------------
/HalconCpp/Halcon18.5VS2017/Halcon18.5VS2017.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.28307.705
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Halcon18.5VS2017", "Halcon18.5VS2017\Halcon18.5VS2017.vcxproj", "{E76D8A38-8690-4936-B8DB-8EB8EDE48DDD}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {E76D8A38-8690-4936-B8DB-8EB8EDE48DDD}.Debug|x64.ActiveCfg = Debug|x64
17 | {E76D8A38-8690-4936-B8DB-8EB8EDE48DDD}.Debug|x64.Build.0 = Debug|x64
18 | {E76D8A38-8690-4936-B8DB-8EB8EDE48DDD}.Debug|x86.ActiveCfg = Debug|Win32
19 | {E76D8A38-8690-4936-B8DB-8EB8EDE48DDD}.Debug|x86.Build.0 = Debug|Win32
20 | {E76D8A38-8690-4936-B8DB-8EB8EDE48DDD}.Release|x64.ActiveCfg = Release|x64
21 | {E76D8A38-8690-4936-B8DB-8EB8EDE48DDD}.Release|x64.Build.0 = Release|x64
22 | {E76D8A38-8690-4936-B8DB-8EB8EDE48DDD}.Release|x86.ActiveCfg = Release|Win32
23 | {E76D8A38-8690-4936-B8DB-8EB8EDE48DDD}.Release|x86.Build.0 = Release|Win32
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {C40C3CFB-4FC0-4ED1-B8BE-6A576686896B}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/HalconCpp/Halcon18.5VS2017/Halcon18.5VS2017/Hal.h:
--------------------------------------------------------------------------------
1 | using namespace std;
2 | #include
3 |
4 | #ifndef HAL_H
5 | #define HAL_H
6 |
7 |
8 | string action(string path);
9 |
10 | #endif
11 |
12 |
--------------------------------------------------------------------------------
/HalconCpp/Halcon18.5VS2017/Halcon18.5VS2017/Halcon18.5VS2017.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/liuwake/HalconPractise/42c2bf5b75c380a1261d830be171a264c641a9f4/HalconCpp/Halcon18.5VS2017/Halcon18.5VS2017/Halcon18.5VS2017.cpp
--------------------------------------------------------------------------------
/HalconCpp/Halcon18.5VS2017/Halcon18.5VS2017/Halcon18.5VS2017.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Header Files
20 |
21 |
22 | Header Files
23 |
24 |
25 |
26 |
27 | Source Files
28 |
29 |
30 | Source Files
31 |
32 |
33 | Source Files
34 |
35 |
36 |
--------------------------------------------------------------------------------
/HalconCpp/Halcon18.5VS2017/Halcon18.5VS2017/Led.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/liuwake/HalconPractise/42c2bf5b75c380a1261d830be171a264c641a9f4/HalconCpp/Halcon18.5VS2017/Halcon18.5VS2017/Led.cpp
--------------------------------------------------------------------------------
/HalconCpp/Halcon18.5VS2017/Halcon18.5VS2017/pch.cpp:
--------------------------------------------------------------------------------
1 | // pch.cpp: source file corresponding to pre-compiled header; necessary for compilation to succeed
2 |
3 | #include "pch.h"
4 |
5 | // In general, ignore this file, but keep it around if you are using pre-compiled headers.
6 |
--------------------------------------------------------------------------------
/HalconCpp/Halcon18.5VS2017/Halcon18.5VS2017/pch.h:
--------------------------------------------------------------------------------
1 | // Tips for Getting Started:
2 | // 1. Use the Solution Explorer window to add/manage files
3 | // 2. Use the Team Explorer window to connect to source control
4 | // 3. Use the Output window to see build output and other messages
5 | // 4. Use the Error List window to view errors
6 | // 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
7 | // 6. In the future, to open this project again, go to File > Open > Project and select the .sln file
8 |
9 | #ifndef PCH_H
10 | #define PCH_H
11 |
12 | // TODO: add headers that you want to pre-compile here
13 |
14 | #endif //PCH_H
15 |
--------------------------------------------------------------------------------
/HalconCpp/HalconX64.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/liuwake/HalconPractise/42c2bf5b75c380a1261d830be171a264c641a9f4/HalconCpp/HalconX64.zip
--------------------------------------------------------------------------------
/HalconCpp/README.md:
--------------------------------------------------------------------------------
1 | # Halcon Cpp on VS
2 |
3 | ## 0. Before 前期准备
4 |
5 | - 安装Halcon
6 | - 需要安装完毕18.11stead(19年建议版本)或者19.05stead(19年目前最新版)版本
7 | - 如果需要调试品牌相机,则需安装相应SDK
8 | - 如果需要X86环境调试,则安装Halcon Runtime X86
9 |
10 | - 安装VS
11 |
12 | ## 1. VS Project VS项目
13 |
14 | ### 1. Create Project 创建项目
15 | 1. 创建新项目```Ctrl + Shift + N```
16 |
17 |
18 |
19 |
20 | 1. 在下拉菜单中选定需要的
21 | ```
22 | Language: C++
23 | Platform: Windows
24 | Project Type: Desktop OR Console
25 | ```
26 |
27 |
28 | 2. 选定一个项目(此处以```Console App```为例);
29 | 点击下一步;
30 | 文本框根据需求修改:
31 |
32 |
33 | ```
34 | Project Name: Led(按需修改,此处Led为例)
35 | Location: C:\xxx\Desktop(按需修改,此处以桌面为例)
36 | Solution: 保持默认
37 | Solution Name: 保持默认(默认生成Project Name 同名)
38 | ```
39 | 点击下一步;
40 | ### 2. Configuration 配置
41 |
42 | 1. Build-> Configuration Management 配置管理器:
43 | 把平台改为```X64 OR X86```(此处以X86为例)
44 |
45 |
46 | 1. Project -> Led Properties Led项目属性 -> Configuration Properties配置属性 -> VC++ Directories VC++目录 -> Include Directories 包含目录
47 |
48 |
49 |
50 | -> 添加 ```$(HALCONROOT)\include;$(HALCONROOT)\include\halconcpp```;*也可写绝对路径;也可使用```./```;下同*
51 |
52 |
53 |
54 | 2. Project -> Led Properties Led项目属性 -> Configuration Properties配置属性 -> VC++ Directories VC++目录 -> Library Directory 库目录
55 |
56 |
57 |
58 | -> 添加 ```$(HALCONROOT)\lib\$(HALCONARCH)```;
59 | *$(HALCONARCH)也可手动改为```x64-win64```或```x86sse2-win32```*
60 |
61 |
62 |
63 | 1. Project -> Led Properties Led项目属性 -> Configuration Properties配置属性 -> Linker 链接器 -> Input 输入 -> 附加依赖项
64 |
65 |
66 |
67 | -> 添加 ```halconcpp.lib```
68 |
69 |
70 |
71 | 4. 添加头文件:
72 |
73 | Solution Explorer -> Led -> Header Files -> 右击 -> Add -> Add Exiting Item -> 添加 Hal.h
74 |
75 | 5. Led.cpp中加入
76 |
77 | ```
78 | //Halcon库
79 | #include "HalconCpp.h"
80 | using namespace HalconCpp;
81 |
82 | //公共库
83 | using namespace std;
84 | #include
85 | #include
86 |
87 | //自写函数头
88 | #include "Hal.h"
89 | ```
90 |
91 |
92 |
93 |
94 |
95 | ## PS
96 | ### 1. 去掉预编译PCH
97 | - 配置属性
98 | - 点选C/C++
99 | - 预编译头
100 | - 不使用预编译头(NO)
101 | ### 2. 解决mvc140.dll缺失等问题
102 | - 使用mtd编译
103 | - 配置属性
104 | - C/C++
105 | - 代码生成
106 | - 运行库
107 | - 调试方式
108 | - Debug下多线程调试(/MTd)
109 | - Release下多线程调试(/MT)
110 |
111 | ### 3. 项目属性所有配置
112 |
113 |
114 |
115 |
116 |
117 |
118 | ## Reference 参考
119 |
120 | - [Integrate HDevelop code into a C++ application using the HDevelop Library Project Export](https://www.mvtec.com/news-press/video/detail/hdevelop-library-project-export0/?no_cache=1&cHash=08ee6d47d22df249a146cf637790946e)
121 | - [WIN10 64位下VS2015 MFC直接添加 halcon 12的CPP文件实现视觉检测](https://www.cnblogs.com/tmdsleep/p/5485882.html)
122 | - [Halcon学习(四) 导出C++代码,在VS2010下编译](https://blog.csdn.net/chaipp0607/article/details/69514982)
123 | - [Halcon/MFC混合编程入门](https://blog.csdn.net/lsh_2013/article/details/50539003)
124 | - [halcon第九讲:halcon联合vc实现ocr识别](https://blog.csdn.net/qq_24946843/article/details/82114589)
125 | - [原MFC+Halcon混合编程,图像读入,显示和存储](https://blog.csdn.net/bettyshasha/article/details/51544203)
126 | - [[Halcon]Halcon12在vs2013下的配置](https://blog.csdn.net/kingcooper/article/details/50774760)
127 | - [VS中的多线程(/MT)、多线程调试(/MTd)、多线程DLL(/MD)、多线程调试DLL(/MDd)的区别](https://blog.csdn.net/qq_33757398/article/details/82156956)
128 |
129 | ## TODO
130 | - [ ] 项目属性所有配置
131 |
--------------------------------------------------------------------------------
/HalconProcedures/51halcon/Halcon拟合圆spoke、拟合直线算子rake 用于测量/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/liuwake/HalconPractise/42c2bf5b75c380a1261d830be171a264c641a9f4/HalconProcedures/51halcon/Halcon拟合圆spoke、拟合直线算子rake 用于测量/1.png
--------------------------------------------------------------------------------
/HalconProcedures/51halcon/halcon找顶点函数/1 画roi.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/liuwake/HalconPractise/42c2bf5b75c380a1261d830be171a264c641a9f4/HalconProcedures/51halcon/halcon找顶点函数/1 画roi.JPG
--------------------------------------------------------------------------------
/HalconProcedures/51halcon/halcon找顶点函数/11.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/liuwake/HalconPractise/42c2bf5b75c380a1261d830be171a264c641a9f4/HalconProcedures/51halcon/halcon找顶点函数/11.bmp
--------------------------------------------------------------------------------
/HalconProcedures/51halcon/halcon找顶点函数/2 检测结果.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/liuwake/HalconPractise/42c2bf5b75c380a1261d830be171a264c641a9f4/HalconProcedures/51halcon/halcon找顶点函数/2 检测结果.JPG
--------------------------------------------------------------------------------
/HalconProcedures/51halcon/halcon找顶点函数/arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/liuwake/HalconPractise/42c2bf5b75c380a1261d830be171a264c641a9f4/HalconProcedures/51halcon/halcon找顶点函数/arrow.png
--------------------------------------------------------------------------------
/HalconProcedures/51halcon/用spoke提取圆心坐标及半径/1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/liuwake/HalconPractise/42c2bf5b75c380a1261d830be171a264c641a9f4/HalconProcedures/51halcon/用spoke提取圆心坐标及半径/1.jpg
--------------------------------------------------------------------------------
/HalconProj/Barcode/BarCodeHandle.bcm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/liuwake/HalconPractise/42c2bf5b75c380a1261d830be171a264c641a9f4/HalconProj/Barcode/BarCodeHandle.bcm
--------------------------------------------------------------------------------
/HalconProj/Barcode/BarCodeHandle0605.bcm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/liuwake/HalconPractise/42c2bf5b75c380a1261d830be171a264c641a9f4/HalconProj/Barcode/BarCodeHandle0605.bcm
--------------------------------------------------------------------------------
/HalconProj/Barcode/DataCodeHandle.dcm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/liuwake/HalconPractise/42c2bf5b75c380a1261d830be171a264c641a9f4/HalconProj/Barcode/DataCodeHandle.dcm
--------------------------------------------------------------------------------
/HalconProj/Barcode/README.md:
--------------------------------------------------------------------------------
1 | ##
2 |
3 |
4 | ## TODO
5 | - [ ] 增加训练模块
--------------------------------------------------------------------------------
/HalconProj/Barcode/empty.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/HalconProj/Barcode/image_display_barcode.hdvp:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | *** DISPLAY
17 | ** DISPLAY BARCODE
18 | for BarIndex := 1 to |DecodedDataStrings| by 1
19 | select_obj (SymbolRegions, ObjectSelected, BarIndex)
20 | area_center (ObjectSelected, Area, Row, Column)
21 |
22 | set_tposition (WindowHandle, Row - BarHeight, Column - 0.25* BarWidth)
23 | write_string (WindowHandle, DecodedDataStrings[BarIndex-1])
24 | endfor
25 | ** DISPLAY INFO
26 | * stop()
27 | return ()
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/HalconProj/Barcode/image_display_datacode.hdvp:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | * Display all symbols, the strings encoded in them, and the module size
17 | dev_set_color ('green')
18 | for i := 0 to |ResultHandles| - 1 by 1
19 | select_obj (SymbolXLDs, SymbolXLD, i+1)
20 | dev_display (SymbolXLD)
21 | get_contour_xld (SymbolXLD, Row, Col)
22 | set_tposition (WindowHandle, min(Row), max(Col))
23 | write_string (WindowHandle, DecodedDataStrings[i])
24 | get_data_code_2d_results (DataCodeHandle, ResultHandles[i], \
25 | ['module_height','module_width'], ModuleSize)
26 | new_line (WindowHandle)
27 | * write_string (WindowHandle, 'module size = ' + ModuleSize[0] + 'x' + \
28 | ModuleSize[1])
29 | endfor
30 | return ()
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/HalconProj/Barcode/image_get_bar.hdvp:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | *
22 | * Use autodiscrimination to decode any of the bar code types
23 | * supported by HALCON (except PharmaCode) or determine the bar
24 | * code type of unknown bar codes
25 | *
26 | ** INIT CONST
27 | * BarWidth := 800
28 | * BarHeight := 100
29 | CodeTypes := ['Code 128']
30 | * CodeTypes := ['auto']
31 |
32 | * read_bar_code_model ('C:/Users/iwake/OneDrive - wake/Desktop/HalconPractise/HalconProj/Barcode/BarCodeHandle.bcm', BarCodeHandle)
33 | * read_bar_code_model ('BarCodeHandle.bcm', BarCodeHandle)
34 | * set_bar_code_param (BarCodeHandle, 'check_char', 'present')
35 | *
36 | * Set display defaults
37 | * get_image_size (Image, Width, Height)
38 |
39 |
40 | *
41 | * Find and decode bar codes. Measure the time needed.
42 | * if (|DecodedDataStrings| == 0)
43 | find_bar_code (Image, SymbolRegions, BarCodeHandle, CodeTypes, DecodedDataStrings)
44 | * endif
45 |
46 |
47 | * get_bar_code_result (BarCodeHandle, 'all', 'someitem', someitem)
48 |
49 |
50 | ** DISPLAY BARCODE
51 | set_display_font (WindowHandle, 14, 'mono', 'true', 'false')
52 | dev_set_draw ('margin')
53 | dev_set_line_width (3)
54 | dev_set_color ('forest green')
55 | dev_display (SymbolRegions)
56 | for BarIndex := 1 to |DecodedDataStrings| by 1
57 | select_obj (SymbolRegions, ObjectSelected, BarIndex)
58 | area_center (SymbolRegions, BarcodeArea, BarcodeRow, BarcodeColumn)
59 | height_width_ratio (ObjectSelected, BarHeight, BarWidth, BarRatio)
60 | set_tposition (WindowHandle, BarcodeRow - BarHeight, BarcodeColumn - 0.5* BarWidth)
61 | write_string (WindowHandle, DecodedDataStrings[BarIndex-1])
62 | endfor
63 |
64 | someitem := [BarcodeRow,BarcodeColumn]
65 |
66 | return ()
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
--------------------------------------------------------------------------------
/HalconProj/Barcode/image_seg_bar.hdvp:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | CropBig := 1
19 | flagDisp := 0
20 | ** 预处理
21 | gen_gauss_pyramid (Image, ImagePyramid, 'weighted', 0.5)
22 | get_image_size (Image, Width, Height)
23 | select_obj(ImagePyramid,ImageSelected,2)
24 |
25 | rgb1_to_gray (ImageSelected,GrayImage)
26 | equ_histo_image (GrayImage, ImageEq)
27 | median_image (ImageEq, ImageMedian, 'circle', 1, 'mirrored')
28 | gauss_image (ImageEq, ImageEqGauss, 3)
29 | sobel_amp (ImageEqGauss, EdgeX, 'x', 3)
30 | abs_image (EdgeX, EdgeXAbs)
31 | sobel_amp (ImageEqGauss, EdgeY, 'y', 3)
32 | * Y方向处理
33 | abs_image (EdgeY, EdgeYAbs)
34 | binary_threshold (EdgeYAbs, YRegion, 'max_separability', 'light', UsedThreshold)
35 | dilation_circle (YRegion, RegionDilation, 4)
36 | overpaint_region (EdgeYAbs, RegionDilation, 127, 'fill')
37 | * 提取Y方向线条
38 | sub_image (EdgeXAbs, EdgeYAbs, ImageSub, 1, 0)
39 | * abs_image (ImageSub, ImageAbs)
40 | mean_image (ImageSub, ImageMean, 3, 3)
41 | ** 二值化 0806 37/179
42 | binary_threshold (ImageMean, Region, 'max_separability', 'light', UsedThreshold)
43 | region_to_bin (Region, BinImage, 255, 0, Width, Height)
44 | * 开闭运算
45 | closing_circle (Region, RegionClosing, 7)
46 | * 腐蚀膨胀
47 | erosion_circle (RegionClosing, RegionErosion, 7)
48 | connection (RegionErosion, ConnectedRegions)
49 | area_center (ConnectedRegions, Area, Row, Column)
50 | select_shape (ConnectedRegions, SelectedRegions, 'area', 'and',max(Area), 99999)
51 | dilation_circle (SelectedRegions, RegionDilation2, 7)
52 | dilation_circle (RegionDilation2, RegionDilation3, 7)
53 | dilation_circle (RegionDilation3, RegionDilation4, 7)
54 | * 框选
55 | * smallest_rectangle1 (RegionDilation4, Row1, Column1, Row2, Column2)
56 | * gen_rectangle1 (Rectangle, Row1*2, Column1*2, Row2*2, Column2*2)
57 | smallest_rectangle2 (RegionDilation4, BarRow, BarCol, Phi, Length1, Length2)
58 | if(CropBig == 1)
59 | BarcodeAreaScale := 2
60 | gen_rectangle2 (Rectangle, BarRow*2, BarCol*2, 0, Length2*2*8*BarcodeAreaScale, Length2*2*BarcodeAreaScale*2)
61 | else
62 | gen_rectangle2 (Rectangle, BarRow*2, BarCol*2, Phi, Length2*2*8, Length2*2)
63 | endif
64 |
65 | reduce_domain (Image, Rectangle, ImageReduced)
66 | crop_domain (ImageReduced, ImageCrop)
67 | * 展示
68 | if (flagDisp == 1)
69 | dev_display (ImageCrop)
70 | dev_set_draw('margin')
71 | dev_set_color ('green')
72 | dev_display (Rectangle)
73 | endif
74 | return ()
75 |
76 |
77 | WK
78 |
79 |
80 |
81 | any
82 |
83 |
84 | image
85 |
86 |
87 | image
88 |
89 |
90 |
91 |
92 |
93 |
--------------------------------------------------------------------------------
/HalconProj/Barcode/test_barcode.hdvp:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | ** 测试用
18 | * NumFailure := 0
19 | Failure := 0
20 | flagSeg := 0
21 | flagCrop := 0
22 |
23 | flagFind := 1
24 |
25 | ** Init
26 | get_image_size (Image, Width, Height)
27 | *** 增强算法
28 | ** 分割纸张
29 | if (flagSeg == 1)
30 | image_seg_paper (Image, paper, WindowHandle, 1)
31 | get_image_size (paper, paperWidth, paperHeight)
32 |
33 |
34 | * dev_display (Image)
35 | * scale_image (Image, Image, 1.8, -100)
36 | * binary_threshold (Image, Region, 'max_separability', 'dark', UsedThreshold)
37 | Image := paper
38 | endif
39 | *** 检测二维码/分割二维码
40 | if (flagCrop == 1)
41 | image_seg_bar (Image, ImageCrop, BarRow, BarCol)
42 |
43 |
44 | endif
45 | * 再处理
46 | *对barcode没用
47 | * illuminate (ImageCrop, ImageCrop, 101, 101, 1)
48 | * emphasize (ImageCrop, ImageCrop, 3, 3, 1)
49 | * Motion 管用
50 | simulate_motion (Image, MovedImage, 60, 90, 3)
51 | convert_image_type (MovedImage, Image, 'byte')
52 | * stop()
53 | * 缩小画幅
54 | * 裁剪1/4区域方法识别条码 27/118
55 | * gen_rectangle1 (Rectangle, 0, paperWidth/2, paperHeight/3, paperWidth)
56 | * reduce_domain(paper,Rectangle,Mask) //裁剪区域
57 | * crop_domain(Mask, paper) //切割图像
58 | ** 检测二维码区域
59 |
60 |
61 |
62 |
63 | if (flagFind == 1)
64 | ** Init Barcode这行代码放到初始化位置,函数最上边,打开相机之前
65 | * create_bar_code_model ([], [], BarCodeHandle)
66 | set_current_dir ('C:/Users/iwake/OneDrive - wake/Desktop/HalconPractise/HalconProj/Barcode')
67 | read_bar_code_model ('BarCodeHandle.bcm', BarCodeHandle)
68 |
69 | * read_bar_code_model ('BarCodeHandle0605.bcm', BarCodeHandle)
70 | * set_bar_code_param (BarCodeHandle, 'check_char', 'present')
71 | * set_bar_code_param (BarCodeHandle, 'quiet_zone',true)
72 | * set_bar_code_param (BarCodeHandle, 'timeout', 50)
73 | * set_bar_code_param (BarCodeHandle, 'majority_voting', true)
74 | set_bar_code_param (BarCodeHandle, 'num_scanlines', 30)
75 | * set_bar_code_param (BarCodeHandle, 'start_stop_tolerance', 'low')
76 | * set_bar_code_param (BarCodeHandle, 'contrast_min', 2)
77 | * set_bar_code_param (BarCodeHandle, 'timeout', 50)
78 | ** Recognition Barcode这行代码什么时候想识别二维码放到那里,输入Image,BarCodeHandle, WindowHandle,
79 | **输出SymbolRegions,DecodedDataStrings, BarcodeLocation
80 | image_get_bar (Image, SymbolRegions, BarCodeHandle, WindowHandle, DecodedDataStrings, BarcodeLocation)
81 | endif
82 |
83 | * stop()
84 | return ()
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
--------------------------------------------------------------------------------
/HalconProj/Cali/CaliGenFunc.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | * Calibration 01: Code generated by Calibration 01
7 | ImageFiles := []
8 | ImageFiles[0] := 'C:/Users/iwake/OneDrive - wake/Desktop/HalconPractise/HalconProj/Cali/ImgageCali0/image_01.png'
9 | ImageFiles[1] := 'C:/Users/iwake/OneDrive - wake/Desktop/HalconPractise/HalconProj/Cali/ImgageCali0/image_02.png'
10 | ImageFiles[2] := 'C:/Users/iwake/OneDrive - wake/Desktop/HalconPractise/HalconProj/Cali/ImgageCali0/image_03.png'
11 | ImageFiles[3] := 'C:/Users/iwake/OneDrive - wake/Desktop/HalconPractise/HalconProj/Cali/ImgageCali0/image_04.png'
12 | ImageFiles[4] := 'C:/Users/iwake/OneDrive - wake/Desktop/HalconPractise/HalconProj/Cali/ImgageCali0/image_05.png'
13 | ImageFiles[5] := 'C:/Users/iwake/OneDrive - wake/Desktop/HalconPractise/HalconProj/Cali/ImgageCali0/image_06.png'
14 | ImageFiles[6] := 'C:/Users/iwake/OneDrive - wake/Desktop/HalconPractise/HalconProj/Cali/ImgageCali0/image_07.png'
15 | ImageFiles[7] := 'C:/Users/iwake/OneDrive - wake/Desktop/HalconPractise/HalconProj/Cali/ImgageCali0/image_08.png'
16 | ImageFiles[8] := 'C:/Users/iwake/OneDrive - wake/Desktop/HalconPractise/HalconProj/Cali/ImgageCali0/image_09.png'
17 | TmpCtrl_ReferenceIndex := 0
18 | TmpCtrl_PlateDescription := 'C:/Program Files/MVTec/HALCON-18.11-Steady/calib/caltab_30mm.descr'
19 | StartParameters := ['area_scan_division',0.008,0,2.4e-006,2.4e-006,2012,1518,4024,3036]
20 | TmpCtrl_FindCalObjParNames := ['gap_tolerance','alpha','skip_find_caltab']
21 | TmpCtrl_FindCalObjParValues := [1,1,'false']
22 | * Calibration 01: Create calibration model for managing calibration data
23 | create_calib_data ('calibration_object', 1, 1, CalibHandle)
24 | set_calib_data_cam_param (CalibHandle, 0, [], StartParameters)
25 | set_calib_data_calib_object (CalibHandle, 0, TmpCtrl_PlateDescription)
26 | * Calibration 01: Collect mark positions and estimated poses for all plates
27 | for Index := 0 to |ImageFiles|-1 by 1
28 | read_image (Image, ImageFiles[Index])
29 | find_calib_object (Image, CalibHandle, 0, 0, Index, TmpCtrl_FindCalObjParNames, TmpCtrl_FindCalObjParValues)
30 | endfor
31 | * Calibration 01: Perform the actual calibration
32 | calibrate_cameras (CalibHandle, TmpCtrl_Errors)
33 | get_calib_data (CalibHandle, 'camera', 0, 'params', CameraParameters)
34 | get_calib_data (CalibHandle, 'calib_obj_pose', [0, TmpCtrl_ReferenceIndex], 'pose', CameraPose)
35 | * Calibration 01: Adjust origin for plate thickness
36 | set_origin_pose (CameraPose, 0.0, 0.0, 0, CameraPose)
37 | stop ()
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/HalconProj/Cali/CaliPreImage.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | *
7 | * Convert All Image to GrayScale
8 | * Output direction is current direction
9 |
10 | * Image Acquisition 01: Code generated by Image Acquisition 01
11 | *** OPEN IMAGE
12 | ** Open Image By list
13 | * ImageFiles := []
14 | * ImageFiles[0] := 'C:/Users/iwake/OneDrive - wake/Desktop/Localization/Images/Ori/InvV1 (1).bmp'
15 | * ImageFiles[1] := 'C:/Users/iwake/OneDrive - wake/Desktop/Localization/Images/Ori/InvV1 (2).bmp'
16 | * ImageFiles[2] := 'C:/Users/iwake/OneDrive - wake/Desktop/Localization/Images/Ori/InvV1 (3).bmp'
17 | * ImageFiles[3] := 'C:/Users/iwake/OneDrive - wake/Desktop/Localization/Images/Ori/InvV1 (4).bmp'
18 | * ImageFiles[4] := 'C:/Users/iwake/OneDrive - wake/Desktop/Localization/Images/Ori/InvV1 (5).bmp'
19 | * ImageFiles[5] := 'C:/Users/iwake/OneDrive - wake/Desktop/Localization/Images/Ori/InvV1 (6).bmp'
20 | * ImageFiles[6] := 'C:/Users/iwake/OneDrive - wake/Desktop/Localization/Images/Ori/InvV1 (7).bmp'
21 | * ImageFiles[7] := 'C:/Users/iwake/OneDrive - wake/Desktop/Localization/Images/Ori/InvV1 (8).bmp'
22 | * ImageFiles[8] := 'C:/Users/iwake/OneDrive - wake/Desktop/Localization/Images/Ori/InvV1 (9).bmp'
23 | * ImageFiles[9] := 'C:/Users/iwake/OneDrive - wake/Desktop/Localization/Images/Ori/InvV1 (10).bmp'
24 | ** Open Image By Floder选择一个位置作为待cali图像的路径
25 | ImageDirection := 'C:/Users/iwake/OneDrive - wake/Desktop/HalconPractise/HalconProj/Cali/ImageToCali'
26 | * ImageDirection := 'C:/Users/iwake/MVS/Data'
27 | list_image_files (ImageDirection, 'default', [], ImageFiles)
28 |
29 |
30 | for Index := 0 to |ImageFiles| - 1 by 1
31 | read_image (Image, ImageFiles[Index])
32 | * Image Acquisition 01: Do something
33 | read_image (Image,ImageFiles[Index])
34 | image_cali_map (Image, TmpObj_RectifiedImage, [], [])
35 |
36 | tuple_split (ImageFiles[Index],'/', Substrings)
37 | tuple_length (Substrings, Length)
38 | NameImage := Substrings[Length-1]
39 | write_image (TmpObj_RectifiedImage, 'bmp', 0, ImageDirection + '/Cali' + NameImage)
40 | endfor
41 |
42 | * PathImage := 'C:/Users/iwake/OneDrive - wake/Desktop/Inventory/Images/'
43 | * list_image_files (PathImage, 'default', [], ImageFiles)
44 |
45 | * for Index := 0 to |ImageFiles|-1 by 1
46 | * read_image (Image,ImageFiles[Index])
47 | * rgb1_to_gray (Image, GrayImage)
48 |
49 | * tuple_split (ImageFiles[Index],'/', Substrings)
50 | * tuple_length (Substrings, Length)
51 | * NameImage := Substrings[Length-1]
52 | * write_image (GrayImage, 'jpg', 0, NameImage)
53 |
54 | * endfor
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/HalconProj/Cali/HK2.cal:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/liuwake/HalconPractise/42c2bf5b75c380a1261d830be171a264c641a9f4/HalconProj/Cali/HK2.cal
--------------------------------------------------------------------------------
/HalconProj/Cali/HK2.dat:
--------------------------------------------------------------------------------
1 | #
2 | # 3D POSE PARAMETERS: rotation and translation
3 | #
4 |
5 | # Used representation type:
6 | f 0
7 |
8 | # Rotation angles [deg] or Rodriguez vector:
9 | r 13.3655936917803 0.504334009458555 90.2620716496257
10 |
11 | # Translation vector (x y z [m]):
12 | t 0.00207284752665489 -0.111611268790476 0.434522173286243
13 |
14 | #
15 | # HALCON Version 18.11 -- Wed Dec 18 11:52:19 2019
16 |
17 | #
18 |
--------------------------------------------------------------------------------
/HalconProj/Cali/HalconExampleCaliImages-scratch - 快捷方式.lnk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/liuwake/HalconPractise/42c2bf5b75c380a1261d830be171a264c641a9f4/HalconProj/Cali/HalconExampleCaliImages-scratch - 快捷方式.lnk
--------------------------------------------------------------------------------
/HalconProj/Cali/README.md:
--------------------------------------------------------------------------------
1 | # HalconPractise
2 |
3 | ## HalconProj
--------------------------------------------------------------------------------
/HalconProj/Cali/caltab.descr:
--------------------------------------------------------------------------------
1 | # Plate Description Version 2
2 | # HALCON Version 18.11 -- Thu Dec 12 17:37:51 2019
3 | # Description of the standard calibration plate
4 | # used for the camera calibration in HALCON
5 | # (generated by gen_caltab)
6 | #
7 | #
8 |
9 | # 7 rows x 7 columns
10 | # Width, height of calibration plate [meter]: 0.1, 0.1
11 | # Distance between mark centers [meter]: 0.0125
12 |
13 | # Number of marks in y-dimension (rows)
14 | r 7
15 |
16 | # Number of marks in x-dimension (columns)
17 | c 7
18 |
19 | # offset of coordinate system in z-dimension [meter] (optional):
20 | z 0
21 |
22 | # Rectangular border (rim and black frame) of calibration plate
23 | # rim of the calibration plate (min x, max y, max x, min y) [meter]:
24 | o -0.05125 0.05125 0.05125 -0.05125
25 | # outer border of the black frame (min x, max y, max x, min y) [meter]:
26 | i -0.05 0.05 0.05 -0.05
27 | # triangular corner mark given by two corner points (x,y, x,y) [meter]
28 | # (optional):
29 | t -0.05 -0.0375 -0.0375 -0.05
30 |
31 | # width of the black frame [meter]:
32 | w 0.003125
33 |
34 | # calibration marks: x y radius [meter]
35 |
36 | # calibration marks at y = -0.0375 m
37 | -0.0375 -0.0375 0.003125
38 | -0.025 -0.0375 0.003125
39 | -0.0125 -0.0375 0.003125
40 | 0 -0.0375 0.003125
41 | 0.0125 -0.0375 0.003125
42 | 0.025 -0.0375 0.003125
43 | 0.0375 -0.0375 0.003125
44 |
45 | # calibration marks at y = -0.025 m
46 | -0.0375 -0.025 0.003125
47 | -0.025 -0.025 0.003125
48 | -0.0125 -0.025 0.003125
49 | 0 -0.025 0.003125
50 | 0.0125 -0.025 0.003125
51 | 0.025 -0.025 0.003125
52 | 0.0375 -0.025 0.003125
53 |
54 | # calibration marks at y = -0.0125 m
55 | -0.0375 -0.0125 0.003125
56 | -0.025 -0.0125 0.003125
57 | -0.0125 -0.0125 0.003125
58 | 0 -0.0125 0.003125
59 | 0.0125 -0.0125 0.003125
60 | 0.025 -0.0125 0.003125
61 | 0.0375 -0.0125 0.003125
62 |
63 | # calibration marks at y = 0 m
64 | -0.0375 0 0.003125
65 | -0.025 0 0.003125
66 | -0.0125 0 0.003125
67 | 0 0 0.003125
68 | 0.0125 0 0.003125
69 | 0.025 0 0.003125
70 | 0.0375 0 0.003125
71 |
72 | # calibration marks at y = 0.0125 m
73 | -0.0375 0.0125 0.003125
74 | -0.025 0.0125 0.003125
75 | -0.0125 0.0125 0.003125
76 | 0 0.0125 0.003125
77 | 0.0125 0.0125 0.003125
78 | 0.025 0.0125 0.003125
79 | 0.0375 0.0125 0.003125
80 |
81 | # calibration marks at y = 0.025 m
82 | -0.0375 0.025 0.003125
83 | -0.025 0.025 0.003125
84 | -0.0125 0.025 0.003125
85 | 0 0.025 0.003125
86 | 0.0125 0.025 0.003125
87 | 0.025 0.025 0.003125
88 | 0.0375 0.025 0.003125
89 |
90 | # calibration marks at y = 0.0375 m
91 | -0.0375 0.0375 0.003125
92 | -0.025 0.0375 0.003125
93 | -0.0125 0.0375 0.003125
94 | 0 0.0375 0.003125
95 | 0.0125 0.0375 0.003125
96 | 0.025 0.0375 0.003125
97 | 0.0375 0.0375 0.003125
98 |
--------------------------------------------------------------------------------
/HalconProj/Cali/caltab.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/liuwake/HalconPractise/42c2bf5b75c380a1261d830be171a264c641a9f4/HalconProj/Cali/caltab.pdf
--------------------------------------------------------------------------------
/HalconProj/Cali/scratch - 快捷方式.lnk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/liuwake/HalconPractise/42c2bf5b75c380a1261d830be171a264c641a9f4/HalconProj/Cali/scratch - 快捷方式.lnk
--------------------------------------------------------------------------------
/HalconProj/Cam/CamCap.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | **** CamCap
7 | **** Camera Capture Auto
8 | **** 使用前先建立Proj/文件夹;除了ObjectName文件夹自动建立,其他需要手动建立
9 | ****
10 | ***Init
11 | ** Init Dir
12 |
13 | dirName := 'C:/Images/' //set dir
14 | proj_name := 'UVSS'// set proj
15 |
16 | Object := '车底测试01' //set object
17 | * Object := 'd01实验5MM'
18 | * Object := 'd02实验25MM'
19 |
20 | floder_name := dirName + proj_name + '/' + Object + '/'
21 | file_exists (floder_name, FileExists1)
22 | if (FileExists1 == 0)
23 | make_dir (floder_name)
24 | endif
25 |
26 |
27 | times := 0
28 | FileExists := 1
29 |
30 | while (FileExists)
31 | file_name := floder_name + times +'1' + '.jpg'
32 | file_exists (file_name , FileExists)
33 | if (FileExists)
34 | times := times + 1
35 | endif
36 | endwhile
37 |
38 | * Image Acquisition 01: Code generated by Image Acquisition 01
39 | ** Open Dalsa using SaperaLT
40 | * open_framegrabber ('SaperaLT', 1, 1, 0, 0, 0, 0, 'default', -1, 'default', -1, 'false', 'C:/Program Files/Teledyne DALSA/Sapera/CamFiles/User/T_Nano-M2420_M2420_Paper.ccf', 'Nano-M2420_1', -1, -1, AcqHandle)
41 | ** Open Dalsa using GigE
42 | open_framegrabber ('GigEVision2', 0, 0, 0, 0, 0, 0, 'progressive', -1, 'default', -1, 'false', 'default', 'S1195113', 0, -1, AcqHandle)
43 |
44 | grab_image_start (AcqHandle, -1)
45 | while (true)
46 | for Index := 1 to 999 by 1
47 | grab_image_async (Image, AcqHandle, -1)
48 | * Image Acquisition 01: Do something
49 | write_name := floder_name + times + Index
50 | write_image (Image, 'jpg', 0, write_name)
51 | endfor
52 |
53 | endwhile
54 | close_framegrabber (AcqHandle)
55 |
56 |
57 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/HalconProj/Cam/CamLive.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | * Image Acquisition 01: Code generated by Image Acquisition 01
7 | * Image Acquisition 01: Attention: The initialization may fail in case parameters need to
8 | * Image Acquisition 01: be set in a specific order (e.g., image resolution vs. offset).
9 | * open_framegrabber ('GigEVision2', 0, 0, 0, 0, 0, 0, 'progressive', -1, 'default', -1, 'false', 'default', 'c42f90f2b7fa_Hikvision_MVCE12010GM', 0, -1, AcqHandle)
10 | * For WebCam
11 | open_framegrabber ('DirectShow', 1, 1, 0, 0, 0, 0, 'default', 8, 'rgb', -1, 'false', 'default', '[0] ', 0, -1, AcqHandle)
12 | ** Set cam param, if nessary
13 |
14 | * set_framegrabber_param (AcqHandle, 'TriggerMode', 'On')
15 | * set_framegrabber_param (AcqHandle, 'TriggerSource', 'Software')
16 | * set_framegrabber_param (AcqHandle, 'Width', 4024)
17 | * set_framegrabber_param (AcqHandle, 'Height', 3036)
18 | * set_framegrabber_param (AcqHandle, 'TestPatternGeneratorSelector', 'Region0')
19 | * set_framegrabber_param (AcqHandle, 'TriggerSelector', 'FrameBurstStart')
20 | * set_framegrabber_param (AcqHandle, 'HDREnable', 0)
21 | * set_framegrabber_param (AcqHandle, 'HDRSelector', 1)
22 | * set_framegrabber_param (AcqHandle, 'Gain', 0.2872)
23 | * grab_image_start (AcqHandle, -1)
24 | while (true)
25 | grab_image_async (Image, AcqHandle, -1)
26 | * Image Acquisition 01: Do something
27 | intensity (Image,Image, Mean, Deviation)
28 | endwhile
29 | close_framegrabber (AcqHandle)
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/HalconProj/Color/Color.md:
--------------------------------------------------------------------------------
1 | # HalconPractise
2 |
3 | ## HalconProj
4 |
5 | # Color
6 |
7 | ## Color Space
8 | - [halcon第六讲:基于颜色空间的颜色检测](https://blog.csdn.net/qq_24946843/article/details/82048974)
9 |
10 | ##
--------------------------------------------------------------------------------
/HalconProj/Color/ColorDetectionPaper.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | dev_close_window ()
7 | PathImages := 'D:/WK/Hospital/实际采集图像'
8 |
9 | read_image (Image, PathImages + '/BoxG2 (7).jpg')
10 |
11 | dev_open_window_fit_image (Image, 110,110, -1, -1, WindowHandle)
12 |
13 | dev_display (Image)
14 |
15 | decompose3 (Image, Red, Green, Blue)
16 |
17 | trans_from_rgb (Red, Green, Blue, Hue, Saturation, Intensity, 'hsv')
18 | *对饱和度图像进行二值化
19 |
20 | * auto_threshold (Saturation, Regions, 20)
21 | binary_threshold (Saturation, Region, 'max_separability', 'dark', UsedThreshold)
22 | * threshold (Saturation, HighSaturation, 100, 255)
23 |
24 | hough_lines (Region, 4, 100, 5, 5, Angle, Dist)
25 |
26 | dev_display (Region)
27 | * dev_display (ImageReduced)
28 | stop ()
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/HalconProj/Color/MonoDetectionPaperCam.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | dev_close_window ()
7 | PathImages := 'C:/Users/iwake/OneDrive - wake/Desktop/HalconPractise/Images'
8 |
9 | read_image (Image, PathImages + '/PaperBlank (3).jpg')
10 |
11 | dev_open_window_fit_image (Image, 110,110, -1, -1, WindowHandle)
12 |
13 | dev_display (Image)
14 |
15 |
16 | ** Region
17 | * set_system ('clip_region', 'false')
18 |
19 | * Image Acquisition 02: Code generated by Image Acquisition 02
20 | open_framegrabber ('GigEVision2', 0, 0, 0, 0, 0, 0, 'progressive', -1, 'default', -1, 'false', 'default', 'c42f90f2b7fa_Hikvision_MVCE12010GM', 0, -1, AcqHandle)
21 | grab_image_start (AcqHandle, -1)
22 | while (true)
23 | grab_image_async (Image, AcqHandle, -1)
24 | * Image Acquisition 02: Do something
25 | * decompose3 (Image, Red, Green, Blue)
26 |
27 | * trans_from_rgb (Red, Green, Blue, Hue, Saturation, Intensity, 'hsv')
28 | *对饱和度图像进行二值化
29 | Saturation := Image
30 | * auto_threshold (Saturation, Regions, 20)
31 |
32 | ** Seg
33 | binary_threshold (Saturation, Region, 'max_separability', 'light', UsedThreshold)
34 | connection (Region, ConnectedRegions)
35 | select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 999999, 9999999)
36 | *area = 8,000,000
37 | * zoom_region (SelectedRegions,RegionZoom, 0.8, 0.8)
38 | dilation_circle (SelectedRegions, RegionDilation, 50)
39 | erosion_circle (RegionDilation, RegionErosion, 150)
40 | difference (RegionDilation,RegionErosion, RegionDifference)
41 | reduce_domain (Image, RegionDifference, ImageReduced)
42 |
43 | ** Hough NG
44 | * sobel_dir(ImageReduced,EdgeAmplitude,EdgeDirection,'sum_abs', 3)
45 | * convert_image_type
46 | * hough_lines_dir( ImageReduced,HoughImage, Lines, 4, 2, 'mean', 3, 25, 5, 5, 'true', Angle, Dist)
47 | * convert_image_type (ImageReduced, ImageConverted, 'direction')
48 | * hough_lines_dir(ImageConverted, HoughImage, Lines, 2, 4, 'mean', 5, 1000, 5, 5, 'true', Angle, Dist)
49 | * gen_region_hline(LinesHNF, Angle,Dist)
50 | * threshold (Saturation, HighSaturation, 100, 255)
51 | * hough_lines (Region, 4, 100, 5, 5, Angle, Dist)
52 |
53 |
54 |
55 | dev_display (Region)
56 | endwhile
57 | close_framegrabber (AcqHandle)
58 |
59 |
60 |
61 |
62 | * dev_display (ImageReduced)
63 | stop ()
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
--------------------------------------------------------------------------------
/HalconProj/DefectDetection/Egg/empty.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/HalconProj/DefectDetection/empty.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/HalconProj/Detection/DetectionCircle.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | **** DetectionCircle
7 | ****
8 | **** Ref
9 | **** halcon检测圆 https://www.baidu.com/s?ie=UTF-8&wd=halcon%20%E6%A3%80%E6%B5%8B%E5%9C%86
10 |
11 |
12 | **** 手动华园拟合
13 |
14 | dev_open_window (0, 0, 512, 512, 'black', WindowHandle)
15 | * dev_get_window (WindowHandle)
16 |
17 | read_image (Image, 'C:/Users/iwake/OneDrive - wake/Desktop/HalconPractise/Images/CircleGear.png')
18 | draw_spoke2 (Image, Regions, WindowHandle, 30, 60, 15, ROIRows, ROICols, Direct)
19 | spoke (Image, Regions1, 30, 60, 15, 1, 20, 'all', 'max', ROIRows, ROICols, Direct, ResultRow, ResultColumn, ArcType)
20 | pts_to_best_circle (Circle, ResultRow, ResultColumn, 15, ArcType, RowCenter, ColCenter, Radius)
21 |
22 |
23 | dev_set_line_width (5)
24 | dev_display(Circle)
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/HalconProj/Detection/DetectionLine.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | dev_get_window (WindowHandle)
7 | dev_set_colored (3)
8 |
9 | *读图
10 | read_image (Image, 'C:/Users/iwake/OneDrive - wake/Desktop/HalconPractise/Images/LineBarcode.jpg')
11 | get_image_size (Image, Width, Height)
12 |
13 | *在我们要检的边界上画线
14 | draw_line (WindowHandle, Row1, Column1, Row2, Column2)
15 | shapeParam:= [Row1,Column1,Row2,Column2]
16 |
17 | *创建句柄
18 | create_metrology_model (MetrologyHandle)
19 | set_metrology_model_image_size (MetrologyHandle, Width, Height)
20 |
21 | *添加线模型
22 | add_metrology_object_generic (MetrologyHandle, 'line', shapeParam, 20, 5, 1, 30, [], [], Index)
23 |
24 | *设置参数,这里根据自己需求设置,这一坨用的都是同一个算子
25 | set_metrology_object_param (MetrologyHandle, 'all', 'measure_transition', 'negative')
26 | set_metrology_object_param (MetrologyHandle, 'all', 'num_measures',50)
27 | set_metrology_object_param (MetrologyHandle, 'all', 'num_instances', 40)
28 | set_metrology_object_param (MetrologyHandle, 'all', 'measure_sigma', 1)
29 | set_metrology_object_param (MetrologyHandle, 'all', 'measure_length1', 80)
30 | set_metrology_object_param (MetrologyHandle, 'all', 'measure_length2', 1)
31 | set_metrology_object_param (MetrologyHandle, 'all', 'measure_threshold',50)
32 | set_metrology_object_param (MetrologyHandle, 'all', 'measure_interpolation', 'bicubic')
33 | set_metrology_object_param (MetrologyHandle, 'all', 'measure_select', 'all')
34 | set_metrology_object_param (MetrologyHandle, 'all', 'min_score', 0.7)
35 |
36 | *开始找边缘,顺便把边缘上卡尺找到的所有点坐标输出在ROW,Column里面(数组形式)
37 | apply_metrology_model (Image, MetrologyHandle)
38 | get_metrology_object_measures (Contours, MetrologyHandle, 'all', 'all', Row, Column)
39 |
40 | dev_set_line_width (5)
41 | *把点显示出来
42 | gen_cross_contour_xld (Cross, Row, Column, 6, 0.785398)
43 |
44 | *得到线的起点和终点坐标并显示出来
45 | get_metrology_object_result (MetrologyHandle, 'all', 'all', 'result_type', 'all_param', Parameter)
46 | get_metrology_object_result_contour (Contour, MetrologyHandle, 'all', 'all', 1.5)
47 |
48 | *释放测量句柄
49 | clear_metrology_model (MetrologyHandle)
50 |
51 |
52 |
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/HalconProj/Detection/DetectionLines.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | dev_get_window (WindowHandle)
7 | dev_set_colored (3)
8 |
9 | *读图
10 | read_image (Image, 'D:/WK/Hospital/1.jpg')
11 |
12 | gen_gauss_pyramid (Image, ImagePyramid, 'weighted', 0.5)
13 |
14 | select_obj (ImagePyramid, ObjectSelected, 5)
15 | get_image_size (ObjectSelected, Width, Height)
16 |
17 | *在我们要检的边界上画线
18 | draw_line (WindowHandle, Row1, Column1, Row2, Column2)
19 | shapeParam:= [Row1,Column1,Row2,Column2]
20 |
21 | *创建句柄
22 | create_metrology_model (MetrologyHandle)
23 | set_metrology_model_image_size (MetrologyHandle, Width, Height)
24 |
25 | *添加线模型
26 | add_metrology_object_generic (MetrologyHandle, 'line', shapeParam, 20, 5, 1, 30, [], [], Index)
27 |
28 | *设置参数,这里根据自己需求设置,这一坨用的都是同一个算子
29 | set_metrology_object_param (MetrologyHandle, 'all', 'measure_transition', 'negative')
30 | set_metrology_object_param (MetrologyHandle, 'all', 'num_measures',50)
31 | set_metrology_object_param (MetrologyHandle, 'all', 'num_instances', 40)
32 | set_metrology_object_param (MetrologyHandle, 'all', 'measure_sigma', 1)
33 | set_metrology_object_param (MetrologyHandle, 'all', 'measure_length1', 80)
34 | set_metrology_object_param (MetrologyHandle, 'all', 'measure_length2', 1)
35 | set_metrology_object_param (MetrologyHandle, 'all', 'measure_threshold',50)
36 | set_metrology_object_param (MetrologyHandle, 'all', 'measure_interpolation', 'bicubic')
37 | set_metrology_object_param (MetrologyHandle, 'all', 'measure_select', 'all')
38 | set_metrology_object_param (MetrologyHandle, 'all', 'min_score', 0.7)
39 |
40 | *开始找边缘,顺便把边缘上卡尺找到的所有点坐标输出在ROW,Column里面(数组形式)
41 | apply_metrology_model (Image, MetrologyHandle)
42 | get_metrology_object_measures (Contours, MetrologyHandle, 'all', 'all', Row, Column)
43 |
44 | dev_set_line_width (5)
45 | *把点显示出来
46 | gen_cross_contour_xld (Cross, Row, Column, 6, 0.785398)
47 |
48 | *得到线的起点和终点坐标并显示出来
49 | get_metrology_object_result (MetrologyHandle, 'all', 'all', 'result_type', 'all_param', Parameter)
50 | get_metrology_object_result_contour (Contour, MetrologyHandle, 'all', 'all', 3)
51 |
52 | *释放测量句柄
53 | clear_metrology_model (MetrologyHandle)
54 |
55 |
56 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/HalconProj/Detection/DetectionModel.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | dev_close_window ( )
7 | read_image (Image, 'C:/Users/iwake/OneDrive - wake/Desktop/HalconPractise/Images/Model.jpg')
8 | scale_image (Image, ImageScaled1, 1.81, 0)
9 | dev_open_window_fit_image (Image, 0, 0, -1, -1, WindowHandle)
10 | dev_display (Image)
11 |
12 | * gen_rectangle1 (Rectangle, 1247, 1182, 1632, 1842)
13 | gen_rectangle1 (Rectangle, 101.375, 442.625, 300.125, 722.625)
14 |
15 | area_center (Rectangle, Area, Row3, Column3)
16 | reduce_domain (ImageScaled1, Rectangle, ImageReduced)
17 | *stop()
18 | create_shape_model (ImageReduced, 'auto', rad(0), rad(360), 'auto', 'auto', 'use_polarity', 'auto', 'auto', ModelID)
19 | draw_rake (Regions, WindowHandle,30, 160, 15, Row1First, Column1First, Row2First, Column2First)
20 | draw_rake (Regions2, WindowHandle, 30, 160, 15, Row1Secound, Column1Secound, Row2Secound, Column2Secound)
21 | draw_rake (Regions3, WindowHandle, 30, 160, 15, Row1thress, Column1thress, Row2thress, Column2thress)
22 | find_shape_model (Image, ModelID, rad(0), rad(360), 0.5, 0, 0.5, 'least_squares', 0, 0.9, Row, Column, Angle, Score)
23 | stop()
24 | gen_empty_obj(EmptyObject)
25 | for Index := 0 to |Row|-1 by 1
26 | dev_display_shape_matching_results (ModelID, 'red', Row[Index], Column[Index], Angle[Index], 1, 1, 0)
27 | vector_angle_to_rigid ( Row3, Column3, 0, Row[Index], Column[Index], Angle[Index], HomMat2D)
28 | affine_trans_pixel (HomMat2D, Row1First, Column1First, RowTrans, ColTrans)
29 | affine_trans_pixel (HomMat2D, Row2First, Column2First, RowTrans1, ColTrans1)
30 | rake (ImageScaled1, Regions1, 5, 20, 1, 1, 20, 'all', 'max', RowTrans, ColTrans, RowTrans1, ColTrans1, ResultRow, ResultColumn)
31 | pts_to_best_line (LineFirst, ResultRow, ResultColumn, 2, Row12, Column12, Row22, Column22)
32 | affine_trans_pixel (HomMat2D, Row1Secound, Column1Secound, RowTrans2, ColTrans2)
33 | affine_trans_pixel (HomMat2D, Row2Secound, Column2Secound, RowTrans3, ColTrans3)
34 | rake (ImageScaled1, Regions4, 5, 20, 1, 1, 20, 'all', 'max', RowTrans2, ColTrans2, RowTrans3, ColTrans3, ResultRow1, ResultColumn1)
35 | pts_to_best_line (LineSecound, ResultRow1, ResultColumn1, 2, Row1, Column1, Row2, Column2)
36 | affine_trans_pixel (HomMat2D, Row1thress, Column1thress, RowTrans4, ColTrans4)
37 | affine_trans_pixel (HomMat2D, Row2thress, Column2thress, RowTrans5, ColTrans5)
38 | rake (ImageReduced, Regions5, 5, 20, 1, 1, 20, 'all', 'max',RowTrans4, ColTrans4,RowTrans5, ColTrans5, ResultRow2, ResultColumn2)
39 | pts_to_best_line (Linethress, ResultRow2, ResultColumn2, 2, Row11, Column11, Row21, Column21)
40 |
41 | intersection_ll (Row1, Column1, Row2, Column2, Row12, Column12, Row22, Column22, Row4, Column4, IsParallel)
42 | gen_cross_contour_xld (Cross, Row4, Column4, 16, Angle)
43 | intersection_ll (Row11, Column11, Row21, Column21, Row12, Column12, Row22, Column22, Row5, Column5, IsParallel1)
44 | gen_cross_contour_xld (Cross1, Row5, Column5, 16, Angle)
45 | ROIRow:=(Row5+Row4)/2
46 | ROICol:=(Column5+Column4)/2
47 | gen_cross_contour_xld (Cross2, ROIRow, ROICol, 16, Angle)
48 | dev_display (Image)
49 | concat_obj(EmptyObject, LineFirst, EmptyObject)
50 | concat_obj(EmptyObject, LineSecound, EmptyObject)
51 | concat_obj(EmptyObject, Linethress, EmptyObject)
52 | concat_obj(EmptyObject, Cross, EmptyObject)
53 | concat_obj(EmptyObject, Cross1, EmptyObject)
54 | concat_obj(EmptyObject, Cross2, EmptyObject)
55 | dev_display (LineFirst)
56 | dev_display (LineSecound)
57 | * dev_display (Linethress)
58 | dev_display (Cross)
59 | dev_display (Cross1)
60 | dev_display (Cross2)
61 | *stop ()
62 | endfor
63 | dev_display(EmptyObject)
64 |
65 |
66 |
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/HalconProj/Detection/DetectionPeak.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | **** DetectionPeak
7 | ****
8 | **** Ref
9 | ****
10 | **** 手动 拟合
11 |
12 |
13 | read_image(Image2,'C:/Users/iwake/OneDrive - wake/Desktop/HalconPractise/Images/PeakArrow.png')
14 | ImageCurrent := Image2
15 | dev_get_window (WindowHandle)
16 |
17 | *画仿射矩形(箭尾临近最高点)
18 | dev_set_color ('green')
19 | draw_rectangle2 (WindowHandle, Row, Column, Phi, Length1, Length2)
20 |
21 | *生成仿射矩形xld
22 | gen_rectangle2_contour_xld (Rectangle, Row, Column, Phi, Length1, Length2)
23 | *找顶点工具(基于卡尺工具)
24 | peak (ImageCurrent, Row, Column, Phi, Length1, Length2, 2, 0.41, 20, 'negative', 'first', EdgesY, EdgesX, ResultRow, ResultColumn)
25 |
26 | *显示图像
27 | dev_display (ImageCurrent)
28 | *显示仿射矩形
29 | dev_display (Rectangle)
30 | *显示所有边缘点
31 | if(|EdgesY|>0)
32 | dev_set_color ('yellow')
33 | gen_cross_contour_xld (Cross, EdgesY, EdgesX, 0.5, 0)
34 | *显示顶点
35 | dev_set_color ('green')
36 | gen_cross_contour_xld (Cross,ResultRow, ResultColumn, 3, 0)
37 | *显示顶点坐标
38 | disp_message (WindowHandle, 'x:='+ResultColumn+'\r\ny:'+ResultRow, 'image', ResultRow, ResultColumn, 'blue', 'false')
39 | endif
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/HalconProj/Detection/image_get_corner_line.hdvp:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | ** Detection Line Corner
18 |
19 |
20 | NumPy := 5
21 | tuple_pow (2, NumPy-1, NumPyScale)
22 |
23 | gen_gauss_pyramid (Image, ImagePyramid, 'weighted', 0.5)
24 | select_obj(ImagePyramid, ObjectSelected, NumPy)
25 | sobel_dir (ObjectSelected, EdgeAmplitude, EdgeDirection, 'sum_abs', 3)
26 | dev_set_color ('red')
27 | threshold (EdgeAmplitude, Region, 55, 255)
28 | * Reduce the direction image to the edge region
29 | reduce_domain (EdgeDirection, Region, EdgeDirectionReduced)
30 | * Start the Hough transform using the edge direction information
31 | hough_lines_dir (EdgeDirectionReduced, HoughImage, Lines, 4, 2, 'mean', 3, 25, 5, 5, 'true', Angle, Dist)
32 | * Store input lines described in HNF
33 | gen_region_hline (LinesHNF, Angle, Dist)
34 |
35 | count_obj(LinesHNF,NumLines)
36 | LinePoint := []
37 | LinePointRow :=[]
38 | LinePointCol :=[]
39 |
40 | for IndexLine := 1 to NumLines-1 by 1
41 | select_obj (LinesHNF, Line1, IndexLine)
42 | select_obj (LinesHNF, Line2, IndexLine+1)
43 | intersection (Line1, Line2, RegionIntersection)
44 | area_center (RegionIntersection, RegionIntersectionArea, Row, Col)
45 | LinePointRow[IndexLine] := Row * NumPyScale
46 | LinePointCol[IndexLine] := Col * NumPyScale
47 | endfor
48 | dev_display (Image)
49 | disp_cross (WindowHandle, LinePointRow, LinePointCol, 72,0)
50 | stop()
51 | return ()
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/HalconProj/Display/Display.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/HalconProj/Enhance/Enhance.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/HalconProj/Enhance/Enhance.md:
--------------------------------------------------------------------------------
1 | # HalconPractise
2 |
3 | ## HalconProj
--------------------------------------------------------------------------------
/HalconProj/Export/Export.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/liuwake/HalconPractise/42c2bf5b75c380a1261d830be171a264c641a9f4/HalconProj/Export/Export.png
--------------------------------------------------------------------------------
/HalconProj/Export/ExportV1.md:
--------------------------------------------------------------------------------
1 | # HalconPractise
2 |
3 | ## HalconProj
4 | ### Export
5 | ----
6 |
7 | # Export
8 |
9 | ## Step
10 | ### 导出
11 | 
12 | - 文件 - 导出
13 | - 选择文件路径
14 | - eg:```C:/Users/iwake/OneDrive - wake/Desktop/HalconPractise/HalconProj/Export/HalFeature.cs```建议功能和类名字相同,统一改成```HalFeature```eg.```HalScan```,```HalMeasure```
15 | - 选语言
16 | - [ ] 文本文件
17 | - [ ] C
18 | - [ ] C++
19 | - [ ] VB
20 | - [x] C# - HALCON/.NET
21 | - 导出范围
22 | - [x] 程序
23 | - 函数属性:
24 | - [x] 导出本地函数内容
25 | - [x] 导出外部函数内容
26 | - [x] 导出所有引用的外部函数
27 | - 外部函数目标地址:单个文件
28 | - 窗口导出
29 | - [ ] 使用halcon窗口:建议文件名```HalFeatureIso.cs```(```Iso```abbr.```Isolated```)
30 | - ```导出一个独立的工程```(GUI注释)
31 | - 2Class(装饰有```#if !(NO_EXPORT_MAIN || NO_EXPORT_APP_MAIN)```)
32 | - ```public class HDevelopExportApp;```
33 | - ```static void Main(string[] args)```
34 | - ````public partial class HDevelopExport````
35 | - ```public HDevelopExport()```构造函数
36 | - ```private void action()```
37 | - etc.
38 | - 比较适合做```Program.cs```(C# Main程序)
39 | - [x] 使用导出模板:建议文件名```HalFeatureIso.cs```
40 | - ```使用提供的工程模板导出成一个工程,(仅支持HALCON/.NET和HALCON/COM)```(GUI注释)
41 | - 1Class
42 | - ```public partial class HDevelopExport```
43 | - Member
44 | - ```public HTuple hv_ExpDefaultWinHandle;```
45 | - ```HTuple hv_AcqHandle = new HTuple();``` 建议增加
46 | - Method
47 | - ```private void action()```action()函数
48 | - ```public void InitHalcon()```初始化函数:初始化默认窗口,一般不用
49 | - ```public void RunHalcon(HTuple Window)```run函数:输入```Window```,调用action()
50 | - ```public void HDevelopStop()```HDevelopStop()函数:输出```MessageBox
51 | - ```public void SomeFeatureStop()```:后期继承增加函数:停止action,关闭相机等;
52 |
53 | - 编码
54 | - [ ] 原始
55 | - [x] UTF-8(用来更好的支持中文)
56 |
57 |
58 | ### 导出代码处理
59 | - 修改
60 | - ```public partial class HDevelopExport``` -> ```public partial class HalFeature```(eg:```public partial class HalScan```)
61 | - 将```HTuple hv_AcqHandle = new HTuple();```从method```private void action()```中移动到```public partial class HalFeature```类内
62 | - 增加
63 | - method```public void StopHalcon()```
64 | ```
65 | public void StopHalcon()
66 | {
67 | HOperatorSet.CloseFramegrabber(hv_AcqHandle);
68 | }
69 | ```
70 | - 删除
71 | - ```public void HDevelopStop()```
72 |
73 |
74 | ## TODO
75 | - [ ] 增加export不同设置的doc
76 | - [ ] 导出简单的read,cam,引用一个自写函数的模板导出和halcon窗口导出的对比
--------------------------------------------------------------------------------
/HalconProj/Export/ExportV2.md:
--------------------------------------------------------------------------------
1 | # HalconPractise
2 |
3 | ## HalconProj
4 | ### Export
5 | ----
6 |
7 | # Export
8 |
9 | ## Step
10 | ### 导出
11 | 
12 | - 文件 - 导出
13 | - 选择文件路径
14 | - eg:```C:/Users/iwake/OneDrive - wake/Desktop/HalconPractise/HalconProj/Export/HalFeature.cs```建议功能和类名字相同,统一改成```HalFeature```eg.```HalScan```,```HalMeasure```
15 | - 选语言
16 | - [ ] 文本文件
17 | - [ ] C
18 | - [ ] C++
19 | - [ ] VB
20 | - [x] C# - HALCON/.NET
21 | - 导出范围
22 | - [x] 程序
23 | - 函数属性:
24 | - [x] 导出本地函数内容
25 | - [x] 导出外部函数内容
26 | - [x] 导出所有引用的外部函数
27 | - 外部函数目标地址:多个单独文件文件
28 | - 窗口导出
29 | - [ ] 使用halcon窗口:建议文件名```HalFeatureIso.cs```(```Iso```abbr.```Isolated```)
30 | - ```导出一个独立的工程```(GUI注释)
31 | - 2Class(装饰有```#if !(NO_EXPORT_MAIN || NO_EXPORT_APP_MAIN)```)
32 | - ```public class HDevelopExportApp;```
33 | - ```static void Main(string[] args)```
34 | - ````public partial class HDevelopExport````
35 | - ```public HDevelopExport()```构造函数
36 | - ```private void action()```
37 | - etc.
38 | - 比较适合做```Program.cs```(C# Main程序)
39 | - [x] 使用导出模板:建议文件名```HalFeatureIso.cs```
40 | - ```使用提供的工程模板导出成一个工程,(仅支持HALCON/.NET和HALCON/COM)```(GUI注释)
41 | - 1Class
42 | - ```public partial class HDevelopExport```
43 | - Member
44 | - ```public HTuple hv_ExpDefaultWinHandle;```
45 | - ```HTuple hv_AcqHandle = new HTuple();``` 建议增加
46 | - Method
47 | - ```private void action()```action()函数
48 | - ```public void InitHalcon()```初始化函数:初始化默认窗口,一般不用
49 | - ```public void RunHalcon(HTuple Window)```run函数:输入```Window```,调用action()
50 | - ```public void HDevelopStop()```HDevelopStop()函数:输出```MessageBox
51 | - ```public void SomeFeatureStop()```:后期继承增加函数:停止action,关闭相机等;
52 |
53 | - 编码
54 | - [ ] 原始
55 | - [x] UTF-8(用来更好的支持中文)
56 |
57 |
58 | ### 导出代码处理
59 | - 修改
60 | - ```public partial class HDevelopExport``` -> ```public partial class HalFeature```(eg:```public partial class HalScan```)
61 | - 将```HTuple hv_AcqHandle = new HTuple();```从method```private void action()```中移动到```public partial class HalFeature```类内
62 | - 增加
63 | - method```public void StopHalcon()```
64 | ```
65 | public void StopHalcon()
66 | {
67 | HOperatorSet.CloseFramegrabber(hv_AcqHandle);
68 | }
69 | ```
70 | - 删除
71 | - ```public void HDevelopStop()```
72 |
73 |
74 | ## TODO
75 | - [ ] 增加export不同设置的doc
76 | - [ ] 导出简单的read,cam,引用一个自写函数的模板导出和halcon窗口导出的对比
--------------------------------------------------------------------------------
/HalconProj/Export/ExportV2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/liuwake/HalconPractise/42c2bf5b75c380a1261d830be171a264c641a9f4/HalconProj/Export/ExportV2.png
--------------------------------------------------------------------------------
/HalconProj/Filter/Filter.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/HalconProj/Filter/Filter.md:
--------------------------------------------------------------------------------
1 | # HalconPractise
2 |
3 | ## HalconProj
4 | ### Filter
5 | ----
6 |
7 | # Filter
8 | ## Class
9 | ### Homo Filter
10 | - Halcon没有原生算法;
11 | - 极性和该滤波器关系
12 | ### Gause
13 |
14 | ###
15 |
16 |
17 | ## TODO
18 | - [ ] start
--------------------------------------------------------------------------------
/HalconProj/Line/Line.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | **** Line
7 |
8 | *** Line Function
9 | ** Gen Line
10 | * gen_region_line 注意Hesse normal 法线形式?
11 | * gen_region_line (RegionLines, 100, 70, 100, 130)
12 |
13 | * Test 6 paraments via gen_region_line in loop
14 | * Degree := [0, 10, 30, 45, 90]
15 | * for Index := 0 to 4 by 1
16 | * gen_region_hline (Regions,rad(Degree[Index]) , 10)
17 | * endfor
18 |
19 | * Test 4 paraments via gen_region_line
20 | * gen_region_hline (Regions, 0, 10)
21 | * gen_region_hline (Regions, rad(10), 10)
22 | * gen_region_hline (Regions, 30, 30)
23 | * gen_region_hline (Regions, 45, 45)
24 | * gen_region_hline (Regions, 90, 90)
25 |
26 | * Test 4 45degrees via gen_region_line
27 | * 1st and 3rd quadrants
28 | * gen_region_hline (RegionsCorner,rad(-45) , -200)
29 | * gen_region_hline (RegionsCorner,rad(-45) , 200)
30 |
31 | * 2nd and 4th quadrants
32 | * gen_region_hline (RegionsCorner,rad(45) , 600)
33 | * gen_region_hline (RegionsCorner,rad(45) , 200)
34 |
35 | * gen_region_line
36 | * for Index := 1 to 5 by 1
37 | * gen_region_line (RegionLines, 100, 70, 100, 130)
38 | * endfor
39 |
40 | ** Cal Cross
41 | *
42 | * intersection (RegionLines, RegionLines1, RegionIntersection)
43 | * get_region_points (RegionIntersection, Rows, Columns)
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/HalconProj/Line/Line.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/liuwake/HalconPractise/42c2bf5b75c380a1261d830be171a264c641a9f4/HalconProj/Line/Line.jpg
--------------------------------------------------------------------------------
/HalconProj/Line/Line.md:
--------------------------------------------------------------------------------
1 | # HalconPractise
2 |
3 | ## HalconProj
--------------------------------------------------------------------------------
/HalconProj/Line/LineCrossMain.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | *** Init
10 |
11 | read_image (Image, 'printer_chip/printer_chip_01')
12 | dev_display (Image)
13 | dev_open_window_fit_image (Image, 0, 0, -1, -1, WindowHandle)
14 | **
15 | *** Line and Region Cross
16 | ** Gen Rect
17 | gen_rectangle1 (Rectangle, 30, 20, 800, 800)
18 | ** Gen Line
19 |
20 | * gen_region_hline (RegionsCorner,rad(-45) , 700 )
21 | ** Gen Line In Loop
22 | * for Index := 0 to HalfDiagonal by 1
23 |
24 | * gen_region_hline (RegionsCorner,rad(-45) , HalfDiagonal - Index)
25 |
26 |
27 | * endfor
28 | ** Detect Corner
29 | Region_get_corner (Image, Rectangle, WindowHandle, Rows, Cols)
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/HalconProj/Line/LineDetectionMain.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | **** LineDetectionMain
7 | *** Init
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/HalconProj/Localization/Localization.md:
--------------------------------------------------------------------------------
1 | # HalconPractise
2 |
3 | ## HalconProj
4 |
5 | ### Localization
6 | ----
--------------------------------------------------------------------------------
/HalconProj/Localization/Mark/Mark.md:
--------------------------------------------------------------------------------
1 | # HalconPractise
2 |
3 | ## HalconProj
4 |
5 | ### Localization
6 | #### Mark
7 |
8 | ----
9 | # Mark Mark点定位法
10 | ## Sum
11 | - 光学定位点(mark点)
12 | - Mark点是使用机器焊接时用于定位的点。
13 |
14 | - 表贴元件的pcb更需要设置Mark点,因为在大批量生产时,贴片机都是操作人员手动或者机器自动寻找Mark点进行校准。极少数不设置Mark点也可以,操作非常麻烦,需要使用几个焊盘或孔作为mark点,这些点不能挂焊锡,效率和精度都会下降。使用过孔当作Mark,误差一般在0.15mm左右 ,**使用标准Mark 偏差小于0.05mm**。
15 | - 设:相机1200W Pixel(4000Pixel X 3000Pixel),视野物象80MM X 60MM;
16 | - 此时PixelEquation=80MM/4000Pixel=0.02MM/Pixel;拟合mark点实际误差的max: PixelErrorMax=5Pixel;
17 | - 亚像素处理后PixelErrorMaxPre=2.5Pixel;
18 | - 实际RealError=PixelEquation X PixelErrorMaxPre= 0.02MM/Pixel X 2.5Pixel = 0.05MM
19 |
20 |
21 | ##
22 |
23 |
24 | ## Reference
25 | -
26 | - [光学定位点(mark点)](https://www.cnblogs.com/darren-pty/p/9357621.html)
27 | -
--------------------------------------------------------------------------------
/HalconProj/MixedLang/MixedLang.cs:
--------------------------------------------------------------------------------
1 | //
2 | // File generated by HDevelop for HALCON/.NET (C#) Version 18.11.1.1
3 | // Non-ASCII strings in this file are encoded in local-8-bit encoding (cp936).
4 | //
5 | // Please note that non-ASCII characters in string constants are exported
6 | // as octal codes in order to guarantee that the strings are correctly
7 | // created on all systems, independent on any compiler settings.
8 | //
9 | // Source files with different encoding should not be mixed in one project.
10 | //
11 |
12 | using HalconDotNet;
13 |
14 | public partial class HDevelopExport
15 | {
16 | #if !(NO_EXPORT_MAIN || NO_EXPORT_APP_MAIN)
17 | public HDevelopExport()
18 | {
19 | // Default settings used in HDevelop
20 | HOperatorSet.SetSystem("width", 512);
21 | HOperatorSet.SetSystem("height", 512);
22 | if (HalconAPI.isWindows)
23 | HOperatorSet.SetSystem("use_window_thread","true");
24 | action();
25 | }
26 | #endif
27 |
28 | #if !NO_EXPORT_MAIN
29 | // Main procedure
30 | private void action()
31 | {
32 |
33 |
34 | // Local iconic variables
35 |
36 | // Local control variables
37 |
38 | HTuple hv_a = new HTuple(), hv_b = new HTuple();
39 | HTuple hv_c = new HTuple();
40 | // Initialize local and output iconic variables
41 | hv_a.Dispose();
42 | hv_a = 1;
43 | hv_b.Dispose();
44 | hv_b = 2;
45 | hv_c.Dispose();
46 | using (HDevDisposeHelper dh = new HDevDisposeHelper())
47 | {
48 | hv_c = hv_a+hv_b;
49 | }
50 |
51 | hv_a.Dispose();
52 | hv_b.Dispose();
53 | hv_c.Dispose();
54 |
55 | }
56 |
57 | #endif
58 |
59 |
60 | }
61 | #if !(NO_EXPORT_MAIN || NO_EXPORT_APP_MAIN)
62 | public class HDevelopExportApp
63 | {
64 | static void Main(string[] args)
65 | {
66 | new HDevelopExport();
67 | }
68 | }
69 | #endif
70 |
71 |
--------------------------------------------------------------------------------
/HalconProj/MixedLang/MixedLang.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | a := 1
7 | b := 2
8 | c := a + b
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/HalconProj/MixedLang/MixedLang.md:
--------------------------------------------------------------------------------
1 | # HalconPractise
2 |
3 | ## HalconProj
4 | ###
5 | ----
6 |
7 | #
8 |
9 | ##
--------------------------------------------------------------------------------
/HalconProj/Preprocessing/BW.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | *
7 | * Convert All Image to GrayScale
8 | * Output direction is current direction
9 | dev_close_window ()
10 | dev_open_window (111,111,512, 512, 'black', WindowHandle)
11 |
12 | PathImage := 'C:/Users/iwake/OneDrive - wake/Desktop/Localization/Images/Inv'
13 | list_image_files (PathImage, 'default', [], ImageFiles)
14 |
15 | for Index := 0 to |ImageFiles|-1 by 1
16 | read_image (Image,ImageFiles[Index])
17 | * rgb1_to_gray (Image, GrayImage)
18 | dev_display (Image)
19 | * 分割出现锯齿
20 | * gauss_filter (Image, Image, 5)
21 | binary_threshold (Image, Region, 'max_separability', 'light', UsedThreshold)
22 |
23 | reduce_domain (Image, Region, ImageReduced)
24 | scale_image (ImageReduced, ImageScaled, 0.01, 250)
25 |
26 |
27 |
28 |
29 | * exp_image (Image, ExpImage, 2)
30 | * binary_threshold (ExpImage, ExpRegion, 'max_separability', 'dark', UsedThreshold)
31 |
32 | * illuminate (Image, ImageIlluminate, 101, 101, 0.7)
33 | * equ_histo_image (Image, ImageEquHisto)
34 |
35 | * scale_image (ExpImage, ImageScaled,1, 255)
36 | * var_threshold (Image, Region, 15, 15, 0.2, 2, 'dark')
37 | tuple_split (ImageFiles[Index],'/', Substrings)
38 | tuple_length (Substrings, Length)
39 | NameImage := Substrings[Length-1]
40 | * convert_image_type (ImageScaled, ImageConverted, 'byte')
41 | write_image (ImageScaled, 'jpg', 0, NameImage)
42 |
43 | endfor
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/HalconProj/Preprocessing/CaliMapMainPre.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | *
7 | * Convert All Image to GrayScale
8 | * Output direction is current direction
9 |
10 | * Image Acquisition 01: Code generated by Image Acquisition 01
11 | *** OPEN IMAGE
12 | ** Open Image By list
13 | * ImageFiles := []
14 | * ImageFiles[0] := 'C:/Users/iwake/OneDrive - wake/Desktop/Localization/Images/Ori/InvV1 (1).bmp'
15 | * ImageFiles[1] := 'C:/Users/iwake/OneDrive - wake/Desktop/Localization/Images/Ori/InvV1 (2).bmp'
16 | * ImageFiles[2] := 'C:/Users/iwake/OneDrive - wake/Desktop/Localization/Images/Ori/InvV1 (3).bmp'
17 | * ImageFiles[3] := 'C:/Users/iwake/OneDrive - wake/Desktop/Localization/Images/Ori/InvV1 (4).bmp'
18 | * ImageFiles[4] := 'C:/Users/iwake/OneDrive - wake/Desktop/Localization/Images/Ori/InvV1 (5).bmp'
19 | * ImageFiles[5] := 'C:/Users/iwake/OneDrive - wake/Desktop/Localization/Images/Ori/InvV1 (6).bmp'
20 | * ImageFiles[6] := 'C:/Users/iwake/OneDrive - wake/Desktop/Localization/Images/Ori/InvV1 (7).bmp'
21 | * ImageFiles[7] := 'C:/Users/iwake/OneDrive - wake/Desktop/Localization/Images/Ori/InvV1 (8).bmp'
22 | * ImageFiles[8] := 'C:/Users/iwake/OneDrive - wake/Desktop/Localization/Images/Ori/InvV1 (9).bmp'
23 | * ImageFiles[9] := 'C:/Users/iwake/OneDrive - wake/Desktop/Localization/Images/Ori/InvV1 (10).bmp'
24 | ** Open Image By Floder
25 | ImageDirection := 'C:/Users/iwake/OneDrive - wake/Desktop/HalconPractise/HalconProj/Cali/ImageToCali'
26 | list_image_files (ImageDirection, 'default', [], ImageFiles)
27 |
28 |
29 | for Index := 0 to |ImageFiles| - 1 by 1
30 | read_image (Image, ImageFiles[Index])
31 | * Image Acquisition 01: Do something
32 | read_image (Image,ImageFiles[Index])
33 | image_cali_map (Image, TmpObj_RectifiedImage, [], [])
34 |
35 | tuple_split (ImageFiles[Index],'/', Substrings)
36 | tuple_length (Substrings, Length)
37 | NameImage := Substrings[Length-1]
38 | write_image (TmpObj_RectifiedImage, 'bmp', 0, ImageDirection + '/Cali' + NameImage)
39 | endfor
40 |
41 | * PathImage := 'C:/Users/iwake/OneDrive - wake/Desktop/Inventory/Images/'
42 | * list_image_files (PathImage, 'default', [], ImageFiles)
43 |
44 | * for Index := 0 to |ImageFiles|-1 by 1
45 | * read_image (Image,ImageFiles[Index])
46 | * rgb1_to_gray (Image, GrayImage)
47 |
48 | * tuple_split (ImageFiles[Index],'/', Substrings)
49 | * tuple_length (Substrings, Length)
50 | * NameImage := Substrings[Length-1]
51 | * write_image (GrayImage, 'jpg', 0, NameImage)
52 |
53 | * endfor
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/HalconProj/Preprocessing/PicPre.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | dev_clear_window ()
7 |
8 | PathImage := 'C:/Users/iwake/OneDrive - wake/Desktop/Localization/Images/SignBox'
9 | * NameImage := 'PicInv1.jpg'
10 |
11 | list_image_files (PathImage, 'default', [], ImageFiles)
12 | read_image (Image, ImageFiles)
13 |
14 | * dev_open_window_fit_image (Image, 0, 0, -1, -1, WindowHandle)
15 |
16 | dev_open_window (110, 110, 512, 512, 'black', WindowHandle)
17 | dev_display (Image)
18 |
19 |
20 | * draw_line (WindowHandle, Row1, Column1, Row2, Column2)
21 |
22 | * div := (Row2 - Row1)/(Column2 - Column1)
23 | * tuple_atan (div, phi)
24 |
25 | * tuple_atan2 (Row2 - Row1,Column2 - Column1, phi)
26 |
27 | rotate_image (Image, ImageRotate, 90, 'nearest_neighbor')
28 |
29 |
30 |
31 | write_image (ImageRotate, 'jpg', 0, ImageFiles)
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/HalconProj/Preprocessing/Preprocessing.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | **** INIT
7 | ***FLAG
8 | ** IMAGE SOURCE
9 | * 1 for imge file; 2 for live;3 for others
10 | IMAGE_SOURCE := 1
11 | * IMAGE_SOURCE := 2
12 | * IMAGE_SOURCE := 3
13 | ** SAVE
14 | SAVE := 0
15 | * SAVE := 1
16 | *** DISPLAY
17 | dev_open_window (0, 0, 512, 512, 'black', WindowHandle)
18 |
19 | *** IMAGE FILE
20 | * Image Acquisition 01: Code generated by Image Acquisition 01
21 | * list_files ('C:/Users/iwake/OneDrive - wake/Desktop/HalconPractise/HalconProj/Preprocessing', ['files','follow_links','recursive'], ImageFiles)
22 | list_files ('D:/WK/Hospital/表单扫描/0820扫描表单/黑/imgBarcode2', ['files','follow_links','recursive'], ImageFiles)
23 | tuple_regexp_select (ImageFiles, ['\\.(tif|tiff|gif|bmp|jpg|jpeg|jp2|png|pcx|pgm|ppm|pbm|xwd|ima|hobj)$','ignore_case'], ImageFiles)
24 |
25 |
26 | **** LOOP
27 |
28 | *** IMAGE FILE
29 | if (IMAGE_SOURCE == 1)
30 | for Index := 0 to |ImageFiles| - 1 by 1
31 | read_image (Image, ImageFiles[Index])
32 | * Image Acquisition 01: Do something
33 | loop_preprocessing (Image, Regions, SAVE)
34 | endfor
35 | endif
36 |
37 | *** IMAGE LIVE
38 | * Image Acquisition 02: Code generated by Image Acquisition 02
39 | if (IMAGE_SOURCE == 2)
40 | open_framegrabber ('GigEVision2', 0, 0, 0, 0, 0, 0, 'progressive', -1, 'default', -1, 'false', 'default', 'c42f90f2b7fa_Hikvision_MVCE12010GM', 0, -1, AcqHandle)
41 | grab_image_start (AcqHandle, -1)
42 | while (true)
43 | grab_image_async (Image, AcqHandle, -1)
44 | * Image Acquisition 02: Do something
45 | loop_preprocessing (Image, Regions, SAVE)
46 | endwhile
47 | close_framegrabber (AcqHandle)
48 | endif
49 |
50 | *** LOOP SOURCE
51 |
52 |
53 | **** DISPLAY
54 | ***
55 | dev_display(Regions)
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 | *** PREPROCESSING
77 | ** WhiteSheet
78 |
79 | auto_threshold (Image, Regions, 2)
80 | * Exp
81 | * exp_image (Image, LogImage, 2)
82 | * Scale
83 | * scale_image (Image, ImageScaled, 2, 0)
84 | * ruihua
85 | * emphasize (Image, ImageEmphasize, 3, 3, 1)
86 | * laplace (Image, ImageLaplace, 'absolute', 3, 'n_4')
87 | * laplace_of_gauss (ImageLaplace, ImageLoG, 3)
88 | * Motion Simulation
89 | * gen_psf_motion (Psf, 256, 256, 20, 0, 3)
90 | simulate_motion (Image, MovedImage, 50, 90, 3)
91 | dev_display (MovedImage)
92 | stop()
93 | **
94 |
95 | *** AFTER
96 | if(SAVE == 1)
97 | write_image (Image, 'bmp', 0, SAVE)
98 | endif
99 | return ()
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
--------------------------------------------------------------------------------
/HalconProj/Preprocessing/Rgb2Gray.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | *
7 | * Convert All Image to GrayScale
8 | * Output direction is current direction
9 |
10 | PathImage := 'C:/Users/iwake/OneDrive - wake/Desktop/Inventory/Images/'
11 | list_image_files (PathImage, 'default', [], ImageFiles)
12 |
13 | for Index := 0 to |ImageFiles|-1 by 1
14 | read_image (Image,ImageFiles[Index])
15 | rgb1_to_gray (Image, GrayImage)
16 |
17 | tuple_split (ImageFiles[Index],'/', Substrings)
18 | tuple_length (Substrings, Length)
19 | NameImage := Substrings[Length-1]
20 | write_image (GrayImage, 'jpg', 0, NameImage)
21 |
22 | endfor
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/HalconProj/README.md:
--------------------------------------------------------------------------------
1 | # HalconPractise
2 |
3 | ## HalconProj
4 | ###
5 | ----
6 |
7 | #
8 |
9 | ##
--------------------------------------------------------------------------------
/HalconProj/Read/Read.cs:
--------------------------------------------------------------------------------
1 | //
2 | // File generated by HDevelop for HALCON/.NET (C#) Version 18.11.1.1
3 | // Non-ASCII strings in this file are encoded in local-8-bit encoding (cp936).
4 | //
5 | // Please note that non-ASCII characters in string constants are exported
6 | // as octal codes in order to guarantee that the strings are correctly
7 | // created on all systems, independent on any compiler settings.
8 | //
9 | // Source files with different encoding should not be mixed in one project.
10 | //
11 |
12 | using HalconDotNet;
13 |
14 | public partial class HDevelopExport
15 | {
16 | #if !(NO_EXPORT_MAIN || NO_EXPORT_APP_MAIN)
17 | public HDevelopExport()
18 | {
19 | // Default settings used in HDevelop
20 | HOperatorSet.SetSystem("width", 512);
21 | HOperatorSet.SetSystem("height", 512);
22 | if (HalconAPI.isWindows)
23 | HOperatorSet.SetSystem("use_window_thread","true");
24 | action();
25 | }
26 | #endif
27 |
28 | #if !NO_EXPORT_MAIN
29 | // Main procedure
30 | private void action()
31 | {
32 |
33 |
34 | // Local iconic variables
35 |
36 | HObject ho_Image;
37 |
38 | // Local control variables
39 |
40 | HTuple hv_Width = new HTuple(), hv_Height = new HTuple();
41 | // Initialize local and output iconic variables
42 | HOperatorSet.GenEmptyObj(out ho_Image);
43 | ho_Image.Dispose();
44 | HOperatorSet.ReadImage(out ho_Image, "printer_chip/printer_chip_01");
45 | if (HDevWindowStack.IsOpen())
46 | {
47 | HOperatorSet.DispObj(ho_Image, HDevWindowStack.GetActive());
48 | }
49 | hv_Width.Dispose();hv_Height.Dispose();
50 | HOperatorSet.GetImageSize(ho_Image, out hv_Width, out hv_Height);
51 |
52 |
53 | ho_Image.Dispose();
54 |
55 | hv_Width.Dispose();
56 | hv_Height.Dispose();
57 |
58 | }
59 |
60 | #endif
61 |
62 |
63 | }
64 | #if !(NO_EXPORT_MAIN || NO_EXPORT_APP_MAIN)
65 | public class HDevelopExportApp
66 | {
67 | static void Main(string[] args)
68 | {
69 | new HDevelopExport();
70 | }
71 | }
72 | #endif
73 |
74 |
--------------------------------------------------------------------------------
/HalconProj/Read/Read.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ****
7 | *** Init
8 |
9 | NumFailure := 0
10 | ImageFailure := []
11 | ** WinHandle
12 | dev_open_window (0, 0, 512, 512, 'black', WindowHandle)
13 | dev_update_off ()
14 |
15 | ** Dir
16 | get_current_dir (DirName)
17 |
18 |
19 | ** Init Image
20 | * read_image (Image, 'printer_chip/printer_chip_01')
21 | * read_image (Image, 'C:/Users/iwake/OneDrive - wake/Desktop/Mia/Images/ScanRaw.jpg')
22 | * read_image (Image, 'C:/Users/iwake/OneDrive - wake/Desktop/HospitalPaperFormAudit/A_文档/E_待解决项/条形码识别非数字问题/1597391432646.jpg')
23 | * Image Acquisition 01: Code generated by Image Acquisition 01
24 | ImageFiles := []
25 | * list_files ('D:/WK/Hospital/表单扫描/0820扫描表单/黑/img', ['files'], ImageFiles)
26 | * list_files ('D:/WK/Hospital/表单扫描/0820扫描表单/彩/img', ['files'], ImageFiles)
27 | * list_files ('D:/WK/Hospital/表单扫描/0806扫描表单/img', ['files'], ImageFiles)
28 | * list_files ('C:/Users/iwake/OneDrive - wake/Desktop/Mia/Images/0821Seg', ['files'], ImageFiles)
29 | * list_files ('D:/WK/Hospital/表单扫描/0820扫描表单/黑/imgSegBarcode', ['files'], ImageFiles)
30 | * list_files ('D:/WK/Hospital/表单扫描/0820扫描表单/黑/imgBarcode2', ['files'], ImageFiles)
31 | * list_files ('D:/WK/Hospital/表单扫描/0828扫描表单/SegBarcode', ['files'], ImageFiles)
32 | list_files ('D:/WK/Hospital/表单扫描/0903扫描表单', ['files'], ImageFiles)
33 | * list_files ('D:/WK/Hospital/表单扫描/0903扫描表单', ['files'], ImageFiles)
34 | for Index := 0 to |ImageFiles| - 1 by 1
35 | read_image (Image, ImageFiles[Index])
36 | rgb1_to_gray (Image, Image)
37 | * rotate_image (Image, Image, 90, 'constant')
38 |
39 | * dev_display (Image)
40 | FileName := ImageFiles[Index]
41 | * tuple_length (FileName, Length)
42 | tuple_strlen (FileName, Length)
43 | * tuple_select_range (FileName,0,Length-4, FileNameNoExtend)
44 | tuple_substr (FileName, 0, Length-5, FileNameNoExtend)
45 |
46 | * Image Acquisition 01: Do something
47 | * dev_display (Image)
48 | get_image_size (Image, Width, Height)
49 |
50 |
51 | *** Detection
52 | * image_get_corner_line (Image, WindowHandle, LinePointRow, LinePointCol)
53 |
54 | ** Seg Paper
55 | * try
56 | * Failure := 0
57 | * image_seg_paper (Image, Image_rectified, WindowHandle, 1)
58 | * dev_display(Image_rectified)
59 |
60 | * write_image (Image_rectified, 'jpg', 0, FileNameNoExtend)
61 | * catch (Exception)
62 | * Failure :=1
63 | * endtry
64 |
65 | **Barcode
66 | * try
67 | * test_barcode (Image, ImageCrop, WindowHandle)
68 | ** Bin
69 | * binary_threshold (ImageCrop, Region, 'max_separability', 'light', UsedThreshold)
70 | * get_image_size (ImageCrop, CropWidth, CropHeight)
71 | * region_to_bin (Region, BinImage, 255, 0, CropWidth, CropHeight)
72 | ** Eq
73 | * equ_histo_image ( ImageCrop, ImageEq)
74 | * write_image (ImageCrop, 'jpg', 0, FileName)
75 |
76 | * catch (Exception)
77 | * NumFailure := NumFailure + 1
78 | * ImageFailure := ImageFailure + ImageFiles[Index]
79 | * stop()
80 | * endtry
81 |
82 |
83 | * stop()
84 | endfor
85 |
86 |
87 |
88 |
89 |
90 | ** Proc
91 | * test_barcode (Image, ImageReduced1, WindowHandle)
92 | * create_bar_code_model ([], [], BarCodeHandle)
93 | * set_bar_code_param (BarCodeHandle,'check_char','present')
94 | * set_bar_code_param (BarCodeHandle,'check_char','absent')
95 | * set_bar_code_param (BarCodeHandle, 'num_scanlines', 10)
96 | * set_bar_code_param(BarCodeHandle,'start_stop_tolerance','low')
97 | * find_bar_code (Image, SymbolRegions, BarCodeHandle, 'Code 128', DecodedDataStrings)
98 | * image_get_bar (Image, SymbolRegions, Width, Width, DecodedDataStrings, someitem)
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
--------------------------------------------------------------------------------
/HalconProj/Read/ReadMain.cs:
--------------------------------------------------------------------------------
1 | //
2 | // File generated by HDevelop for HALCON/.NET (C#) Version 18.11.1.1
3 | // Non-ASCII strings in this file are encoded in UTF-8.
4 | //
5 | // Please note that non-ASCII characters in string constants are exported
6 | // as octal codes in order to guarantee that the strings are correctly
7 | // created on all systems, independent on any compiler settings.
8 | //
9 | // Source files with different encoding should not be mixed in one project.
10 | //
11 | // This file is intended to be used with the HDevelopTemplate or
12 | // HDevelopTemplateWPF projects located under %HALCONEXAMPLES%\c#
13 |
14 | using System;
15 | using HalconDotNet;
16 |
17 | public partial class HDevelopExport
18 | {
19 | public HTuple hv_ExpDefaultWinHandle;
20 |
21 | // Main procedure
22 | private void action()
23 | {
24 |
25 |
26 | // Local iconic variables
27 |
28 | HObject ho_Image;
29 |
30 | // Local control variables
31 |
32 | HTuple hv_Width = new HTuple(), hv_Height = new HTuple();
33 | // Initialize local and output iconic variables
34 | HOperatorSet.GenEmptyObj(out ho_Image);
35 | ho_Image.Dispose();
36 | HOperatorSet.ReadImage(out ho_Image, "printer_chip/printer_chip_01");
37 | HOperatorSet.DispObj(ho_Image, hv_ExpDefaultWinHandle);
38 | hv_Width.Dispose();hv_Height.Dispose();
39 | HOperatorSet.GetImageSize(ho_Image, out hv_Width, out hv_Height);
40 |
41 |
42 | ho_Image.Dispose();
43 |
44 | hv_Width.Dispose();
45 | hv_Height.Dispose();
46 |
47 | }
48 |
49 | public void InitHalcon()
50 | {
51 | // Default settings used in HDevelop
52 | HOperatorSet.SetSystem("width", 512);
53 | HOperatorSet.SetSystem("height", 512);
54 | }
55 |
56 | public void RunHalcon(HTuple Window)
57 | {
58 | hv_ExpDefaultWinHandle = Window;
59 | action();
60 | }
61 |
62 | }
63 |
64 |
--------------------------------------------------------------------------------
/HalconProj/Region/Region.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | dev_close_window ()
7 | dev_update_off ()
8 | dev_open_window (110, 110, 512, 512, 'black', WindowHandle)
9 |
10 |
11 | gen_empty_region (Name)
12 | for i := 1 to 5 by 1
13 |
14 | gen_rectangle1 (Temp, 20 *i,10,20*i +10,200)
15 | concat_obj (Temp,Name,Name)
16 |
17 | endfor
18 | dev_display (Name)
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/HalconProj/Region/Region.md:
--------------------------------------------------------------------------------
1 | # HalconPractise
2 |
3 | ## HalconProj
--------------------------------------------------------------------------------
/HalconProj/Robot/Precision.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | * 横向纵向视觉机器人联合矫正
8 | * - 纵向矫正以确定:视觉像素当量+视觉算法结果+通信+机器人反馈=准确
9 | * - 横向确定:视觉像素当量+视觉算法结果+通信+机器人反馈=准确
10 | * - 偶有横向笛卡尔机器人横向确认笛卡尔机器人脉冲当量无异常
11 |
12 |
13 |
14 | ** METHOD 1: 对比每张图的差值
15 |
16 |
17 |
18 |
19 |
20 |
21 | ** METHOD 2: 对比黑色区域面积
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/HalconProj/Rotate/RotateTest.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | read_image (Image, 'C:/Users/iwake/OneDrive - wake/Desktop/Mia/Images/V0.0/CWDL.jpg')
7 |
8 | ** Method 1 rotate 不可以指定圆点旋转
9 | rotate_image (Image, ImageRotate, 30, 'constant')
10 |
11 | x1 :=1535
12 | y1 := 370
13 |
14 | x2 := 260
15 | y2 := 2557
16 |
17 |
18 | tuple_atan2 (x2-x1,y2-y1,ATan)
19 |
20 | d := deg(ATan)
21 | rotate_image (ImageRotate, ImageRotate2, d, 'constant')
22 |
23 |
24 | ** Method 2 affine_trans 可以指定原点旋转
25 | hom_mat2d_identity (HomMat2D)
26 | hom_mat2d_rotate( HomMat2D, ATan, 1110, 1500, HomMat2DRotate)
27 | affine_trans_image (ImageRotate, ImageAffineTrans, HomMat2DRotate, 'constant', 'false')
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/HalconProj/Segmentation/SegObjects.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | *读入一张图片
10 | read_image (Image, 'rings_and_nuts')
11 | *灰度处理,仅黑白两色的图片无需灰度处理
12 | *rgb1_to_gray(Image,ImageGray)
13 | *阈值分割
14 | threshold(Image,Image_t,0,200)
15 | *连通分量计算
16 | connection(Image_t,Image_c)
17 | *统计区域个数
18 | count_obj(Image_c,count)
19 | for i:=1 to count by 1
20 | *获取元组中的单个元素
21 | select_obj(Image_c,Image_so,i)
22 | *缩小图像的阈
23 | *之前很不解为什么write_image之前为什么还要经过reduce_domain和crop_domain处理?
24 | *后面才知道连通分量计算connection中得到的对象是区域,并不是正真的图像。
25 | *reduce_domain就是通过区域来框定原图中的某个特定的图型
26 | reduce_domain(Image,Image_so,Image_rd)
27 |
28 | *从已定义的灰度值中删除
29 | crop_domain(Image_rd,Image_cd)
30 | *将元素写出
31 | * write_image(Image_cd,'bmp',-1,'C:/Users/斌/Desktop/test/'+i)
32 |
33 | endfor
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/HalconProj/Segmentation/SegmentationPcb.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | read_image (Image, 'C:/Users/iwake/OneDrive - wake/Desktop/HalconPractise/Images/Pcb2.png')
7 | dev_display(Image)
8 |
9 | binary_threshold (Image, Region, 'max_separability', 'light', UsedThreshold)
10 |
11 | erosion_rectangle1 (Region, RegionEnrosion, 3, 1)
12 |
13 | connection (Region, ConnectedRegions)
14 |
15 |
16 |
17 | select_shape (ConnectedRegions, SelectedRegions, 'area', 'and',5000, 99999)
18 | erosion_rectangle1(SelectedRegions,SelectedRegionsEnrosion,5,5)
19 |
20 | reduce_domain (Image, SelectedRegionsEnrosion, ImageReduced)
21 |
22 | union1(SelectedRegionsEnrosion,SelectedRegionsEnrosionUnion)
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/HalconProj/Shadow/Shadow.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/HalconProj/Shadow/Shadow.md:
--------------------------------------------------------------------------------
1 | # HalconPractise
2 |
3 | ## HalconProj
4 |
5 | ### Shadow
6 | ----
7 |
8 | ##
--------------------------------------------------------------------------------
/HalconProj/Socket/Client.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | * 关闭错误显示
7 | dev_set_check ('~give_error')
8 |
9 | * 参数设置
10 | Protocol := 'TCP4'
11 | Timeout := 3.0
12 |
13 | * 打开SOCKET 仅用于接连接服务端
14 | open_socket_connect ('localhost', 7080,['protocol','timeout'], [Protocol,Timeout], Socket)
15 |
16 | * 获取客户端地址和端口信息
17 | get_socket_param (Socket, 'address_info', Address)
18 | * 获取对方IP和端口信息
19 | if(|Address|=4)
20 | To:=[]
21 | To:= [Address[2],Address[3]]
22 | endif
23 |
24 | Answer := []
25 | * 数据通讯 发送End字符串结束监听
26 | while (Answer != 'End')
27 | Format := 'z'
28 | * 获取客户度发送的消息
29 | receive_data (Socket, Format, Answer, From)
30 | if (|Answer|>0)
31 | Data:='Recv:'+Answer
32 | send_data (Socket, Format, Data, To)
33 | endif
34 |
35 | endwhile
36 |
37 | close_socket (Socket)
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/HalconProj/Socket/Server.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | * 关闭错误显示
7 | dev_set_check ('~give_error')
8 |
9 | * 参数设置
10 | Protocol := 'TCP4'
11 | Timeout := 3.0
12 |
13 | * 打开SOCKET 仅用于接受客户端连接
14 | open_socket_accept (7080, ['protocol','timeout'], [Protocol,Timeout], AcceptingSocket)
15 |
16 | * 判断协议
17 | tuple_regexp_match (Protocol, 'TCP|HALCON', BaseProtocol)
18 | if (BaseProtocol == 'TCP' or BaseProtocol == 'HALCON')
19 | dev_error_var (Error, 1)
20 | OpenStatus := 5
21 | * 等待客户端连接
22 | while (OpenStatus != 2)
23 | socket_accept_connect (AcceptingSocket, 'auto', Socket)
24 | OpenStatus := Error
25 | endwhile
26 |
27 | * 为当前连接的客户端创建新socket 用于通讯
28 | set_socket_param (Socket, 'timeout', Timeout)
29 | else
30 | *
31 | * UDP sockets 不需要 accept()方法
32 | Socket := AcceptingSocket
33 | endif
34 |
35 | * 获取客户端地址和端口信息
36 | get_socket_param (Socket, 'address_info', Address)
37 | * 获取对方IP和端口信息
38 | if(|Address|=4)
39 | To:=[]
40 | To:= [Address[2],Address[3]]
41 | endif
42 |
43 | Answer := []
44 | * 数据通讯 发送End字符串结束监听
45 | while (Answer != 'End')
46 | Format := 'z'
47 | * 获取客户度发送的消息
48 | receive_data (Socket, Format, Answer, From)
49 | if (|Answer|>0)
50 | Data:='Recv:'+Answer
51 | send_data (Socket, Format, Data, To)
52 | endif
53 |
54 | endwhile
55 |
56 | close_socket (Socket)
57 | close_socket (AcceptingSocket)
58 |
59 |
60 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/HalconProj/Status/README.md:
--------------------------------------------------------------------------------
1 | #
2 |
3 |
4 |
5 |
6 | # Status
7 | ## Intro
8 | - 判定图像的状态
9 | - 静止
10 | - 移动
11 | - 模糊
12 | - 图像质量
--------------------------------------------------------------------------------
/HalconProj/Status/StatusMain.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | dev_clear_window ()
7 |
8 | dev_open_window (0, 0, 512, 512, 'black', WindowHandle)
9 |
10 | image_judge_stop (ImageBefore1, ImageLater1, Selected, juadge_stop)
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/HalconProj/Stitch/HalconProj.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/HalconProj/Window/Window.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | dev_close_window ()
11 | dev_open_window (110, 110, 512, 512, 'black', WindowHandle)
12 | for i := 1 to 99 by 1
13 | get_window_extents (WindowHandle, Row, Column, Width, Height)
14 | stop()
15 | endfor
16 |
17 | *设置字体颜色
18 | dev_set_color ('green')
19 | *设置文字大小
20 | set_display_font (WindowHandle, 30, 'mono', 'true', 'false')
21 | *设置文字位置
22 | set_tposition (WindowHandle, 240, 120)
23 | *设置文字内容
24 | write_string (WindowHandle, 'hello')
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/HalconProj/Window/Window.md:
--------------------------------------------------------------------------------
1 | # HalconPractise
2 |
3 | ## HalconProj
4 | ###
5 | ----
6 |
7 | #
8 |
9 | ##
--------------------------------------------------------------------------------
/Images/Circle.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/liuwake/HalconPractise/42c2bf5b75c380a1261d830be171a264c641a9f4/Images/Circle.PNG
--------------------------------------------------------------------------------
/Images/CircleGear.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/liuwake/HalconPractise/42c2bf5b75c380a1261d830be171a264c641a9f4/Images/CircleGear.png
--------------------------------------------------------------------------------
/Images/CirclePcb.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/liuwake/HalconPractise/42c2bf5b75c380a1261d830be171a264c641a9f4/Images/CirclePcb.jpg
--------------------------------------------------------------------------------
/Images/DetectionPeak (1).JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/liuwake/HalconPractise/42c2bf5b75c380a1261d830be171a264c641a9f4/Images/DetectionPeak (1).JPG
--------------------------------------------------------------------------------
/Images/DetectionPeak (2).JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/liuwake/HalconPractise/42c2bf5b75c380a1261d830be171a264c641a9f4/Images/DetectionPeak (2).JPG
--------------------------------------------------------------------------------
/Images/IntelLogo.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/liuwake/HalconPractise/42c2bf5b75c380a1261d830be171a264c641a9f4/Images/IntelLogo.jpeg
--------------------------------------------------------------------------------
/Images/LineBarcode.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/liuwake/HalconPractise/42c2bf5b75c380a1261d830be171a264c641a9f4/Images/LineBarcode.jpg
--------------------------------------------------------------------------------
/Images/Model.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/liuwake/HalconPractise/42c2bf5b75c380a1261d830be171a264c641a9f4/Images/Model.jpg
--------------------------------------------------------------------------------
/Images/Pcb1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/liuwake/HalconPractise/42c2bf5b75c380a1261d830be171a264c641a9f4/Images/Pcb1.png
--------------------------------------------------------------------------------
/Images/Pcb2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/liuwake/HalconPractise/42c2bf5b75c380a1261d830be171a264c641a9f4/Images/Pcb2.png
--------------------------------------------------------------------------------
/Images/PeakArrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/liuwake/HalconPractise/42c2bf5b75c380a1261d830be171a264c641a9f4/Images/PeakArrow.png
--------------------------------------------------------------------------------
/Images/PeakRake.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/liuwake/HalconPractise/42c2bf5b75c380a1261d830be171a264c641a9f4/Images/PeakRake.bmp
--------------------------------------------------------------------------------
/Images/lena.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/liuwake/HalconPractise/42c2bf5b75c380a1261d830be171a264c641a9f4/Images/lena.png
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 刘维克
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Procedures/3rd/README.md:
--------------------------------------------------------------------------------
1 | #
2 |
3 | ## 3rd
4 | ----
5 |
6 | ## Intro
7 |
8 | ## Proc
9 |
10 | ### Draw
11 | - draw_rake
12 | - draw_spoke
13 |
14 |
15 | ### PTS
16 |
17 |
18 | ### Measure
19 |
20 |
--------------------------------------------------------------------------------
/Procedures/3rd/draw_rake.hdvp:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | *提示
23 | disp_message (WindowHandle, '点击鼠标左键画一条直线,点击右键确认', 'window', 12, 12, 'red', 'false')
24 | *产生一个空显示对象,用于显示
25 | gen_empty_obj(Regions)
26 | *画矢量检测直线
27 | draw_line(WindowHandle, Row1, Column1, Row2, Column2)
28 | *产生直线xld
29 | gen_contour_polygon_xld (RegionLines, [Row1,Row2], [Column1,Column2])
30 | *存储到显示对象
31 | concat_obj(Regions, RegionLines, Regions)
32 | *计算直线与x轴的夹角,逆时针方向为正向。
33 | angle_lx (Row1, Column1, Row2, Column2, ATan)
34 |
35 | *边缘检测方向垂直于检测直线:直线方向正向旋转90°为边缘检测方向
36 | ATan:=ATan+rad(90)
37 |
38 | *根据检测直线按顺序产生测量区域矩形,并存储到显示对象
39 | for i:=1 to Elements by 1
40 | *如果只有一个测量矩形,作为卡尺工具,宽度为检测直线的长度
41 | if(Elements=1)
42 | RowC := (Row1+Row2)*0.5
43 | ColC := (Column1+Column2)*0.5
44 | distance_pp(Row1, Column1, Row2, Column2, Distance)
45 | gen_rectangle2_contour_xld(Rectangle, RowC, ColC,ATan, DetectHeight/2,Distance/2)
46 | else
47 | *如果有多个测量矩形,产生该测量矩形xld
48 | RowC := Row1+(((Row2-Row1)*(i-1))/(Elements-1))
49 | ColC := Column1+(Column2-Column1)*(i-1)/(Elements-1)
50 | gen_rectangle2_contour_xld(Rectangle, RowC, ColC, ATan, DetectHeight/2,DetectWidth/2)
51 | endif
52 | *把测量矩形xld存储到显示对象
53 | concat_obj (Regions, Rectangle, Regions)
54 | if(i=1)
55 | *在第一个测量矩形绘制一个箭头xld,用于只是边缘检测方向
56 | RowL2:=RowC+DetectHeight/2*sin(-ATan)
57 | RowL1:=RowC-DetectHeight/2*sin(-ATan)
58 | ColL2:=ColC+DetectHeight/2*cos(-ATan)
59 | ColL1:=ColC-DetectHeight/2*cos(-ATan)
60 | gen_arrow_contour_xld (Arrow1, RowL1, ColL1, RowL2, ColL2, 25, 25)
61 | *把xld存储到显示对象
62 | concat_obj (Regions, Arrow1, Regions)
63 | endif
64 | endfor
65 |
66 | return ()
67 |
68 |
69 |
70 |
71 | 检测区域起点的x
72 | real
73 |
74 | - real
75 |
76 |
77 |
78 | 检测区域终点的x
79 | real
80 |
81 | - real
82 |
83 |
84 |
85 | 60
86 | 检测边缘的卡尺工具的高度
87 | integer
88 |
89 | - 30
90 | - 60
91 | - 90
92 | - 120
93 |
94 |
95 |
96 | 15
97 | 检测边缘的卡尺工具的宽度
98 | integer
99 |
100 | - 5
101 | - 10
102 | - 15
103 | - 20
104 | - 25
105 | - 30
106 | - 40
107 |
108 |
109 |
110 | 30
111 | 检测边缘数
112 | integer
113 |
114 | - real
115 |
116 |
117 | - 10
118 | - 20
119 | - 30
120 | - 50
121 | - 60
122 |
123 |
124 |
125 | 输出边缘点检测区域及检测方向
126 | object
127 |
128 |
129 | 检测区域起点的y
130 | false
131 | real
132 |
133 | - real
134 |
135 |
136 |
137 | 检测区域终点的y
138 | real
139 |
140 | - real
141 |
142 |
143 |
144 | 图形窗口句柄
145 | false
146 | window
147 |
148 | - integer
149 |
150 |
151 |
152 |
153 |
154 |
155 |
--------------------------------------------------------------------------------
/Procedures/3rd/find_peak_point.hdvp:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | /SXCqzVSNZCJs3CA88kPhIuyIc07vkjF56TbHXzU6FzybFyIAb9fDsGUXNJ7DZ9oflSfXoKOTUXwOzC1Fk1ixx1B2UGQXBbpw4Sti81CW3b6UhqXgQ4+u+by7oWU0O/Lt7RjXozFU/snV2caICfLHC22ioBuHphx/7quXTazs4CsxMoYhdIPRqyzXgqnlY0WlHGxa9wS/k23risHmJYu74tuBjXUiLWQ2JOUx4WWGFs/dVdISD0G8Qu7YJzs3Uk+F1AWW9wHASQ0c53O2+ur9DgDPvVyUrsH16VyIQimTlmCQ/eRhPLDp34uUbIzzd8KOopHYL4fHm/LC6s37ZpPcHoDfxvTzglSxjJJCq7AwcUhv5pRHXpTitTCNw+g0ULk9EP0aOFrtgvjDg2O9GbOdUcycvD/wqJEqKV8C39urfINN8J9D8e/PEL6G0hXx1XTOkKK+7gW8TcrZm77vw1Ewi+nXlOU7wf+kWAlkB3o4cbwsLKYMGCv2HgQa0F2MRa8I8eP8Rx2i1E+Vrx8JuhPEAkFsvuMUd+NVnG8S0FCRrPL/iYigWqthGFIRNcdshz028TrwGSJwOToTsdN1hpBCuZIij/yvm/FvWhXaKbFTKbnsTU1LGC2WJq5ryEJqJHHS6leB+t9voXhQcZdOena+wzHMlel6GwzmRckAd341Z3BYe2/3K/+0mWDzD7gY0bPkQlyuSaI6B/mQxXVFeLu5L2g6x1GyB/T65RWe8Ni8oVnbzs3Y2/P0mcjUbKTITzp9fi8dSB2TF15yAjrBmT5VWx2lgdNr3XuqaC0UQexGmYSKhRTf1Dqh4QcPDhLnPw2yNxAIWLxbjmFf5M+9smENw+NxWAh+sC5yNr4jx4gq5QcnqLVS7Njf2EroOS3sMXFknt1F1Be8X/Mt/XQ6+xBHPjCkV83Z1EX3CK42epkIgXeShDKH8zOSYEK0lq7Ct7xf92N++cAVsifC5FGIa/pdoCJ7dI8Cem6ObHx5ki1KZWDUp11lTSPhveF62FVvP3tZ1YleSDxb4myH53Ba6piq/lAqdgflrdlyHi0rWQl4zNQPS9NRStdTjPnGR1JGof8ueuM/a9d8jqhyW/o7VklCMM2IXBqhLC1b7NCNykNr8ljVt3J+k/IxtlsGuk51FTa3k4ocp/vfteu9sPuWV3l0IcXtByf0D3dmOvtvfZDOseN5dGZQoyM3DKKqxByWuwtNWq1da/5Wj0GlCl8S6Wik/c5LO+RMyO303SVzPSuB3726N1XxACCYPd9604Vh926N71N+WE5yMMpOYRMIp7PQ69KNv5beUq5d6ee9WpfE4EzxiDVHi9xjCnmOjV8N+QMNmjdiR0Tqb7WC4ieIS/pSnjGoFbARGPPD32ymol7WaPI6mRfSTQUC/K5IZSoHS/sJ1dsW6F3CIRYoHxxa3rDfw/4Z64C28DCSSZ41kYzWd67Rz3MFeF3u8fJh4KH0yRgJyitRRbrH5471J30XWdn+5PomTN7YnD64W8Hg30L/4HaqTLLavmWg3MclqDGH2315nTEGavwrMW293Qh3Kf6bkpCVKzi9O5e0N55jFF21YzFs/LWJvnr81okDXCSPOLPotqXWm7kNvDZw49ArHRsVegigBC5bQFzIldzzVyWe5KpTonYcEEnyOk+dZgMxpwelO6XtZ+NsQqAdBqspvfkAsjRE48x5zKf5fRVK6lQ7f2X1ZvX/ywQ11qLIIQbiVai+/vLmVbq+uo7A2CnwBZJ1eBCzv/kRw9j1YV7Fxhui2HLwhp1fpxHqNmf22cW9QHHfsM3uo2ZmXljinIxtr5FYhxTvwIyOQfilblR7C/VjM/Yc3ZWVO7F69vLupPErY8reb1mu5pWyunv2KpNb06ZuG9J88qfFCjZwLSfoapmea+sJ8gZ3yHxBm8f2UFS/2ywbaXynMwWOKkclVuGLZRbfvsu6FcypPly9i88BUR/sX22LEO0bk4P14wNRL8n1BDF+VILMXcDn1AsAWxB4r5pdmFTnHId75nI6pu/tVvA6bxTUlYRerCyl4BRVouE5UUyS0ZGX9PQRsnEdXhSTiT7KvX/BxJ7LjtJWSQfv/tujDSHQTchzTeSA7cVcM/IWTvZr1keINK7QxvKh8MWlvqzvHXnPJtuUVsCFcuHKu7nhTIfNFhi0wnICDMWN+OZ6KXzeL/yyYRjstKrGcyU7NVYnhULI7Nw2hE8SmQaI4pyN6Pcmjw5/2pSEEOZm1tQKdZYkBDj0h8/EQ1WTaXyUltOBhI6J3gRiwUVdFzpf5Gz6kBhDHIz/+tDQjVhADk+0YxTMVIdymIbcBHCOf3r0Mnybg
22 |
23 |
24 |
25 | 1
26 |
27 |
28 |
29 |
30 | 40
31 |
32 |
33 |
34 | 20
35 |
36 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/Procedures/3rd/find_peak_ponit_2.hdvp:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 | HhktJbjZUqQrWIcIKaKTRdolmWtsUahrv3XrzM+2wTJlskHPbhERsSZPByDkhby/72R2ZN6MQIhU1szRTG4mtmu7YWeqBtIm7zoeomksaVp5YOnajvqy1CneSSWjlMcTNPx5Z7sn225eZI8z//+etXGKX4smhF53t8bk8rpc4bgOp7gBoqUP5ArVHbuGw9mYaf+Gn8ijNZws4RtLAIBoE7fi1Y28iUvUkT47mkBgy5W99/nBNDo1TiTQxQ0HLSHQxfJV859MHnQ71pRjhaciFaXYJIIPmYWb9eNt9w7P/AwO9o99L5pspcaPkvoiRvjglSFCEcbrALq44LHswUiACaHypnDA4r09PyNVvY2Z4E5I4bq4tCsO2BAP+iWW3azXiAPLbHP2AUf4dVLdg7DCDHR5LHPTbRj6bVYRCUBTN2RQvbALbnLRSkljz1+ZCI3Fx3ZuudDmoIUjI7L33Wp9uwi+QsG4DU5MdQEoTFLpXFAGlMQV10PbtUd51S885glmjBS6t9esyPpd1u04dw0UgEhdSvRIrzFrrA4IVHJsj5y5I0jky73EpeGo3NExFnnP7LTf+qWNoCLcb0qpUrIhz8OXTYCR9pofkTv6u+Th1hKjdQifC2LZKwtDfA9GWThkA1i452+a08YlWw6cGJ4rL6fRHDM1Tsn62WM4aPIWuv9L2iN5+p9rauVPH+i+BHHDMo0dzS503tro+76avoupSxBRJYQvpx2L36aKBhxxl+fr0RQamAhk/ruYF//2rFCxwHUCH5TaV5GfdgSiy00SNnE948HFSN6YxVXk7ni16LklbVet2xnLd5xqwMBvt2Z2J9gmDizmFkKizVsSOKaUj8eArSSYu67HXbDmNvOYtluarckewiHJQ4Ocuof8Wz9qgzuBJbzO9ErkYIGDttae5D+pafoWBlaFY5xFojDjYR3oecWXQFTMsHKEAvh01GMNosEvSnJYnYQwQ2y79J0x4FTockOk5UDlw3yPlohGZThRJJtQJZtUtJI4J+RLCvld4axI7Wa2dwvXxgkMvycl5O2ZD6WS8THOaBJTNOfpxZidXt17DlotNQ2W/4z6W4wKDKvN3jougm9IN5SJCqL+KvwQLWY9LotRH08FNBOdWuwUZUvsTx5owku3LbkJlqndh5XrmgLXj5Q2Tf+wvq3VcW04v5RgP/IUVGiwYeII53t/8USFBkzcRjHbu7Z+E41wTjg/oTCUpAhEHdyNJd5gz/Ygq8ndhu3Jo2SuqQe1e1IdPgLvvxpX1DhJjv0dErVCZPFzhHBhgw2f4t5lX0vfgCTxv0cVI4/6SHnX0qECQbjv5bb5O+EB9O+uI8NdgHx44uKr2TG8xGsUcF7TkpUwftMyebnI512DtnHtREk4p0AJ5lDzQB++62qDJ7mbx/beCWCiQ0wT0OL5MLMln0WwSJeDJBJrv+u+hiiZeTKv52iDEI1kv9pj/LLPSvcDwgbAPcUF9/3pEb0J12U7a87zJHsiLMJI+rOqBNzzar17Drm/z02ikSLbxdLIr9dnONd4MG6hM0dCzDwVRaWGxAF78mJUphc/OwRJ5DU6p6aRzZgCmVfdNp8iw7IqnF4GUV+YEvbSK73qyFc1pwz13e2ZXvoYXUVaJ0c0RuyE8H8uBwzmI78Ua3w8LqVlK6CJUAJG7mg6Lkzvvj2pgmOE2Z6qbqGRgjHGlYX+MpShq2/JHZ3yX72Atm0u4YP7fjL8fRKcnkGZTBIELgkMi5XS7mk0Y3G0mU0/4N31jBLzMb8lSFvmG/0Gp/uxKo7KWeb5xzd4FRdK+uR4S+OnmgNePzUqeGRGWKltpk3E/2WO2Io7Xi/TZzlSCTWKCZC1UkThkUayfSVlymx9PCw6Wd4D2jsSF8yfAPEK3ho8ioKTEKCDu/x342ZuNJb+zGKveSclfejVcmMn/nqs1K8MobGApC7TF950h3JCrkzjqN69RHlsn0B9qSYXtmjR19KmWsnJ5IwEaBX0ikoGNl6xsqT4uVLjh4mmTESC0285EqGSEdhNm4D7QvEGqVzD4FUo9VYpNxbVGaGqMO6Mwfs1MKYpBl5LPDFFgPk6fvh6ZnYpM5Jz03/B2Y92lKQtbw
29 |
30 |
31 |
32 | 1
33 |
34 |
35 |
36 | any
37 |
38 |
39 |
40 |
41 | 40
42 |
43 |
44 | image
45 |
46 |
47 | real
48 | real
49 |
50 | - real
51 |
52 |
53 |
54 | real
55 | real
56 |
57 | - real
58 |
59 |
60 |
61 | 20
62 |
63 |
64 | real
65 | real
66 |
67 | - real
68 |
69 |
70 |
71 | region
72 |
73 |
74 | any
75 |
76 |
77 |
78 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/Procedures/3rd/gen_measure_pairs.hdvp:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | * CloseSlotLength1:=15
23 | *根据测量句柄方向和测量中心点生成边缘直线
24 | CloseSlotRowStart:= Row1_Measure_01_0 + CloseSlotLength1 * cos(TmpCtrl_Phi)
25 | CloseSlotRowEnd := Row1_Measure_01_0 - CloseSlotLength1 * cos(TmpCtrl_Phi)
26 | CloseSlotColStart := Column1_Measure_01_0 + CloseSlotLength1 * sin(TmpCtrl_Phi)
27 | CloseSlotColEnd := Column1_Measure_01_0 - CloseSlotLength1 * sin(TmpCtrl_Phi)
28 | dev_set_color ('green')
29 | dev_set_line_width (2)
30 | gen_contour_polygon_xld (CloseSlotMarker1, [CloseSlotRowStart,CloseSlotRowEnd], [CloseSlotColStart,CloseSlotColEnd])
31 | return ()
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/Procedures/3rd/get_rectangle_points.hdvp:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | *矩形端点坐标变量、边中心变量初始化
21 | CornerX:=[]
22 | CornerY:=[]
23 | LineCenterX:=[]
24 | LineCenterY:=[]
25 |
26 | *临时变量初始化
27 | RowT:=0
28 | ColT:=0
29 |
30 | *判断仿射矩形是否有效
31 | if (Len1<=0 or Len2<=0)
32 | return ( )
33 | endif
34 |
35 | *计算仿射矩形角度的正弦值、余弦值
36 | tuple_cos (Phi, Cos)
37 | tuple_sin (Phi, Sin)
38 |
39 | *矩形第一个端点坐标
40 | ColT:=CenterX-Len1*Cos-Len2*Sin
41 | RowT:=CenterY-(-Len1*Sin+Len2*Cos)
42 | CornerY:=[CornerY,RowT]
43 | CornerX:=[CornerX,ColT]
44 |
45 | *矩形第二个端点坐标
46 | ColT:=CenterX+Len1*Cos-Len2*Sin
47 | RowT:=CenterY-(Len1*Sin+Len2*Cos)
48 | CornerY:=[CornerY,RowT]
49 | CornerX:=[CornerX,ColT]
50 |
51 | *矩形第三个端点坐标
52 | ColT:=CenterX+Len1*Cos+Len2*Sin
53 | RowT:=CenterY-(Len1*Sin-Len2*Cos)
54 | CornerY:=[CornerY,RowT]
55 | CornerX:=[CornerX,ColT]
56 |
57 | *矩形第四个端点坐标
58 | ColT:=CenterX-Len1*Cos+Len2*Sin
59 | RowT:=CenterY-(-Len1*Sin-Len2*Cos)
60 | CornerY:=[CornerY,RowT]
61 | CornerX:=[CornerX,ColT]
62 |
63 | *矩形第一条边中心坐标
64 | LineCenterY[0] := (CornerY[0]+CornerY[1])*0.5
65 | LineCenterX[0] := (CornerX[0]+CornerX[1])*0.5
66 |
67 | *矩形第二条边中心坐标
68 | LineCenterY[1] := (CornerY[1]+CornerY[2])*0.5
69 | LineCenterX[1] := (CornerX[1]+CornerX[2])*0.5
70 |
71 | *矩形第三条边中心坐标
72 | LineCenterY[2] := (CornerY[2]+CornerY[3])*0.5
73 | LineCenterX[2] := (CornerX[2]+CornerX[3])*0.5
74 |
75 | *矩形第四条边中心坐标
76 | LineCenterY[3] := (CornerY[0]+CornerY[3])*0.5
77 | LineCenterX[3] := (CornerX[0]+CornerX[3])*0.5
78 |
79 | *返回
80 | return ( )
81 | return ()
82 | return ()
83 | return ()
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
--------------------------------------------------------------------------------
/Procedures/3rd/measur_edges_tool.hdvp:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | ImageOut := Image
26 | *提示
27 | disp_message (WindowHandle, '点击鼠标左键画一条直线,点右键确认', 'window', 12, 12, 'red', 'false')
28 | *画线
29 | draw_line (WindowHandle, Row1, Col1, Row2, Col2)
30 | *阈值
31 | threshold:=Threshold
32 | *测量矩形的半宽度
33 | RoiWidth:=len/2
34 | *直线测量区域的起点和终止点
35 | * Row1:=ROW1
36 | * Col1:=COL1
37 | * Row2:=ROW2
38 | * Col2:=COL2
39 |
40 | *根据测量矩形的半宽度+直线测量区域的起点和终止点,形成测量矩形具体参数
41 | TmpCtrl_Row := 0.5*(Row1+Row2)
42 | TmpCtrl_Column := 0.5*(Col1+Col2)
43 | TmpCtrl_Dr := Row1-Row2
44 | TmpCtrl_Dc := Col1-Col2
45 | Phi := atan2(TmpCtrl_Dr, TmpCtrl_Dc)
46 | TmpCtrl_Len1 := 0.5*sqrt(TmpCtrl_Dr*TmpCtrl_Dr + TmpCtrl_Dc*TmpCtrl_Dc)
47 | TmpCtrl_Len2 := RoiWidth
48 | *生成测量矩形的句柄
49 | gen_measure_rectangle2 (TmpCtrl_Row, TmpCtrl_Column, Phi, TmpCtrl_Len1, TmpCtrl_Len2, \
50 | 1440, 1080, 'nearest_neighbor', MsrHandle_Measure_01_0)
51 | copy_obj (ImageOut, ImageOut, 1, 1)
52 | **测量边缘
53 | sigma:=Sigma
54 | *极性
55 | transition:=Transition
56 | *点的选择
57 | select:=Select
58 | *测量
59 | measure_pos (ImageOut, MsrHandle_Measure_01_0, sigma, threshold, transition, select, ResultRow, ResultColumn, Amplitude, Distance)
60 | close_measure (MsrHandle_Measure_01_0)
61 | return ()
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/Procedures/3rd/measure_edges_tool.hdvp:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | *阈值
26 | Threshold:=threshold
27 |
28 | *测量矩形的半宽度
29 | RoiWidth:=len/2
30 | *直线测量区域的起点和终止点
31 | Row1:=LineRowStart_Measure_01_0
32 | Col1:=LineColumnStart_Measure_01_0
33 | Row2:=LineRowEnd_Measure_01_0
34 | Col2:=LineColumnEnd_Measure_01_0
35 | *根据测量矩形的半宽度+直线测量区域的起点和终止点,形成测量矩形具体参数
36 | TmpCtrl_Row := 0.5*(Row1+Row2)
37 | TmpCtrl_Column := 0.5*(Col1+Col2)
38 | TmpCtrl_Dr := Row1-Row2
39 | TmpCtrl_Dc := Col2-Col1
40 | Phi := atan2(TmpCtrl_Dr, TmpCtrl_Dc)
41 | TmpCtrl_Len1 := 0.5*sqrt(TmpCtrl_Dr*TmpCtrl_Dr + TmpCtrl_Dc*TmpCtrl_Dc)
42 | TmpCtrl_Len2 := RoiWidth
43 | *生成测量矩形的句柄
44 | gen_measure_rectangle2 (TmpCtrl_Row, TmpCtrl_Column, Phi, TmpCtrl_Len1, TmpCtrl_Len2, \
45 | 1440, 1080, 'nearest_neighbor', MsrHandle_Measure_01_0)
46 | copy_obj (Image, Image, 1, 1)
47 | **测量边缘
48 | Sigma:=1
49 | *极性
50 | Transition:='all'
51 | *点的选择
52 | Select:='all'
53 | measure_pos (Image, MsrHandle_Measure_01_0, 1, Threshold, Transition, Select, \
54 | ResultRow, ResultColumn, Amplitude, Distance)
55 | close_measure (MsrHandle_Measure_01_0)
56 | return ()
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
--------------------------------------------------------------------------------
/Procedures/3rd/measure_pairs_tool.hdvp:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 | *阈值
29 | AmplitudeThreshold := Threshold
30 | *测量矩形宽度
31 | RoiWidthLen2 := RoiWidthLen
32 | *测量矩形起点和终止点
33 | LineRowStart_Measure_01_0 := LineRowStart_Measure
34 | LineColumnStart_Measure_01_0 := LineColumnStart_Measure
35 | LineRowEnd_Measure_01_0 := LineRowEnd_Measure
36 | LineColumnEnd_Measure_01_0 := LineColumnEnd_Measure
37 | *形成测量矩形具体参数
38 | TmpCtrl_Row := 0.5*(LineRowStart_Measure_01_0+LineRowEnd_Measure_01_0)
39 | TmpCtrl_Column := 0.5*(LineColumnStart_Measure_01_0+LineColumnEnd_Measure_01_0)
40 | TmpCtrl_Dr := LineRowStart_Measure_01_0-LineRowEnd_Measure_01_0
41 | TmpCtrl_Dc := LineColumnEnd_Measure_01_0-LineColumnStart_Measure_01_0
42 | TmpCtrl_Phi := atan2(TmpCtrl_Dr, TmpCtrl_Dc)
43 | TmpCtrl_Len1 := 0.5*sqrt(TmpCtrl_Dr*TmpCtrl_Dr + TmpCtrl_Dc*TmpCtrl_Dc)
44 | TmpCtrl_Len2 := RoiWidthLen2
45 | *生成测量矩形的句柄
46 | get_image_size (Image, Width, Height)
47 | gen_measure_rectangle2 (TmpCtrl_Row, TmpCtrl_Column, TmpCtrl_Phi, TmpCtrl_Len1, TmpCtrl_Len2, Width, Height, 'nearest_neighbor', MsrHandle_Measure_01_0)
48 | copy_obj (Image, Image, 1, 1)
49 | **测量边缘对
50 | measure_pairs (Image, MsrHandle_Measure_01_0, 1, 40, 'all', 'all', Row1_Measure_01_0, Column1_Measure_01_0, Amplitude1_Measure_01_0, Row2_Measure_01_0, Column2_Measure_01_0, \
51 | Amplitude2_Measure_01_0, Width_Measure_01_0, Distance_Measure_01_0)
52 | close_measure (MsrHandle_Measure_01_0)
53 | return ()
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/Procedures/3rd/p_disp_edge_marker.hdvp:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | * Determine the number of edges
17 | NumRows := |Rows|
18 | NumCols := |Cols|
19 | Num := min([NumRows,NumCols])
20 | *
21 | * Loop over the edges
22 | for i := 0 to Num - 1 by 1
23 | Row := Rows[i]
24 | Col := Cols[i]
25 | *
26 | * Determine start and end point of the edge marker.
27 | RowStart := Row + Length * cos(Phi)
28 | RowEnd := Row - Length * cos(Phi)
29 | ColStart := Col + Length * sin(Phi)
30 | ColEnd := Col - Length * sin(Phi)
31 | *
32 | * Generate a contour that connects the start and end point.
33 | gen_contour_polygon_xld (Marker, [RowStart,RowEnd], [ColStart,ColEnd])
34 | *
35 | * Display the contour with the specified style.
36 | dev_set_color (Color)
37 | dev_set_line_width (LineWidth)
38 | dev_display (Marker)
39 | endfor
40 | return ()
41 |
42 |
43 | Displays a marker, which indicates the position of an edge
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/Procedures/3rd/pts_to_best_circle.hdvp:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | *初始化
25 | RowCenter := 0
26 | ColCenter := 0
27 | Radius := 0
28 | *产生一个空的直线对象,用于保存拟合后的圆
29 | gen_empty_obj (Circle)
30 | *计算边缘数量
31 | tuple_length(Cols, Length)
32 | *当边缘数量不小于有效点数时进行拟合
33 | if (Length>=ActiveNum and ActiveNum>2)
34 | *halcon的拟合是基于xld的,需要把边缘连接成xld
35 | if(ArcType='circle')
36 | *如果是闭合的圆,轮廓需要首尾相连
37 | gen_contour_polygon_xld(Contour, [Rows,Rows[0]], [Cols,Cols[0]])
38 | else
39 | gen_contour_polygon_xld(Contour, Rows, Cols)
40 | endif
41 | *拟合圆。使用的算法是''geotukey'',其他算法请参考fit_circle_contour_xld的描述部分。
42 | fit_circle_contour_xld (Contour, 'geotukey', -1, 0, 0, 3, 2, RowCenter, ColCenter, Radius, StartPhi, EndPhi, PointOrder)
43 | *判断拟合结果是否有效:如果拟合成功,数组中元素的数量大于0
44 | tuple_length(StartPhi, Length1)
45 | if(Length1<1)
46 | return()
47 | endif
48 | *根据拟合结果,产生直线xld
49 | if(ArcType='arc')
50 | gen_circle_contour_xld(Circle, RowCenter, ColCenter, Radius, StartPhi, EndPhi, PointOrder, 1)
51 | else
52 | StartPhi:=0
53 | EndPhi:=rad(360)
54 | gen_circle_contour_xld(Circle, RowCenter, ColCenter, Radius, StartPhi, EndPhi, PointOrder, 1)
55 | endif
56 | endif
57 |
58 | return ()
59 | return ()
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
--------------------------------------------------------------------------------
/Procedures/3rd/pts_to_best_line.hdvp:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | *初始化
22 | Row1:=0
23 | Column1:= 0
24 | Row2:=0
25 | Column2:= 0
26 | *产生一个空的直线对象,用于保存拟合后的直线
27 | gen_empty_obj(Line)
28 | *计算边缘数量
29 | tuple_length(Cols, Length)
30 | *当边缘数量不小于有效点数时进行拟合
31 | if (Length>=ActiveNum and ActiveNum>1)
32 | *halcon的拟合是基于xld的,需要把边缘连接成xld
33 | gen_contour_polygon_xld(Contour, Rows, Cols)
34 | *拟合直线。使用的算法是'tukey',其他算法请参考fit_line_contour_xld的描述部分。
35 | fit_line_contour_xld (Contour, 'tukey', -1, 0, 5, 2, Row1, Column1, Row2, Column2, Nr, Nc, Dist)
36 | *判断拟合结果是否有效:如果拟合成功,数组中元素的数量大于0
37 | tuple_length(Dist, Length1)
38 | if(Length1<1)
39 | return()
40 | endif
41 | *根据拟合结果,产生直线xld
42 | gen_contour_polygon_xld (Line, [Row1,Row2], [Column1,Column2])
43 | endif
44 |
45 | return ()
46 |
47 |
48 |
49 |
50 | 2
51 | 最小有效点数
52 | any
53 |
54 | - integer
55 | - real
56 |
57 |
58 |
59 | 拟合直线的输入x数组
60 | real
61 |
62 |
63 | 拟合的直线起点x值
64 | real
65 |
66 | - integer
67 | - real
68 |
69 |
70 |
71 | 拟合的直线终点x值
72 | real
73 |
74 | - integer
75 | - real
76 |
77 |
78 |
79 | 输出拟合直线的xld
80 | xld
81 |
82 |
83 | 拟合的直线起点y值
84 | real
85 |
86 | - integer
87 | - real
88 |
89 |
90 |
91 | 拟合的直线终点y值
92 | real
93 |
94 | - integer
95 | - real
96 |
97 |
98 |
99 | 拟合直线的输入y数组
100 | real
101 |
102 |
103 |
104 |
105 |
106 |
--------------------------------------------------------------------------------
/Procedures/3rd/rect1_gen_lines.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | dev_set_colored(12)
8 | dev_get_window (WindowHandle)
9 |
10 |
11 | angle := 90
12 | num := 5
13 | read_image(Image,'monkey')
14 | dev_display (Image)
15 | *画仿射矩形(箭尾临近最高点)
16 | dev_set_color ('green')
17 | draw_rectangle1 (WindowHandle, Row1, Column1, Row2, Column2)
18 |
19 | *生成仿射矩形xld
20 | gen_rectangle1 (Rectangle, Row1, Column1, Row2, Column2)
21 |
22 | * dev_display(Rectangle)
23 |
24 | dev_set_color('red')
25 | step := (Row2 - Row1)/num
26 |
27 | switch (angle)
28 | case 90:
29 | Row_Current := Row1
30 | for Index := 1 to num + 1 by 1
31 | gen_contour_polygon_xld (Line, [Row1,Row1], [Column1,Column1])
32 | * dev_display (Line)
33 | disp_line (WindowHandle, Row_Current, Column1, Row_Current, Column2)
34 | * Row_Curent := Row_Current + step
35 | tuple_add (Row_Current, step, Row_Current)
36 |
37 | endfor
38 |
39 |
40 | endswitch
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/Procedures/3rd/rect2_gen_lines.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | dev_set_colored(12)
8 | dev_get_window (WindowHandle)
9 |
10 |
11 | angle := 90
12 | num := 5
13 | read_image(Image,'monkey')
14 | dev_display (Image)
15 | *画仿射矩形(箭尾临近最高点)
16 | dev_set_color ('green')
17 | draw_rectangle2 (WindowHandle, Row, Column, Phi, Length1, Length2)
18 | get_degree (Phi, Degree)
19 | *生成仿射矩形xld
20 | gen_rectangle2 (Rectangle, Row, Column, Phi, Length1, Length2)
21 |
22 | dev_display(Rectangle)
23 |
24 | dev_set_color('red')
25 | step := (Length1)/num
26 | Length_Line := Length2/2
27 | Fix_Col := Length_Line * sin(Degree)
28 | Fix_Row := Length_Line * cos(Degree)
29 | gen_contour_polygon_xld (Line, [Row - Fix_Row,Row + Fix_Row], [Column - Fix_Col,Column + Fix_Col])
30 |
31 |
32 |
33 | * Row_Current := Row1
34 | * for Index := 1 to num + 1 by 1
35 | * gen_contour_polygon_xld (Line, [Row1,Row1], [Column1,Column1])
36 | * dev_display (Line)
37 | * disp_line (WindowHandle, Row_Current, Column1, Row_Current, Column2)
38 | * Row_Curent := Row_Current + step
39 | * tuple_add (Row_Current, step, Row_Current)
40 |
41 | * endfor
42 |
43 |
44 | * gen_line2(Rectangle, Row, Column, Phi, Length1, Length2)
45 | * a := step + tan(Degree)
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/Procedures/3rd/region_to_spoke.hdvp:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | try
18 | SpokeRows:=[]
19 | SpokeCols:=[]
20 | select_shape_std (Region, SelectedRegions, 'max_area', 70)
21 | fill_up (SelectedRegions, RegionFillUp)
22 | smallest_circle (RegionFillUp, Row, Column, Radius)
23 | opening_circle (RegionFillUp, RegionOpening, Radius/16)
24 | closing_circle (RegionOpening, RegionClosing, Radius/8)
25 | fill_up (RegionClosing, RegionFillUp1)
26 | shape_trans (RegionFillUp1, RegionTrans, 'outer_circle')
27 | gen_contour_region_xld (RegionTrans, Contours, 'border')
28 | get_contour_xld (Contours, Rows, Cols)
29 | tuple_length (Rows, Length)
30 | SpokeRows:=[Rows[Offset],Rows[Offset+Length/4],Rows[Offset+Length*2/4],Rows[Offset+Length*3/4],Rows[Offset]]
31 | SpokeCols:=[Cols[Offset],Cols[Offset+Length/4],Cols[Offset+Length*2/4],Cols[Offset+Length*3/4],Cols[Offset]]
32 | catch (Exception)
33 | SpokeRows:=[]
34 | SpokeCols:=[]
35 | endtry
36 | return ()
37 |
38 |
39 |
40 |
41 | 0
42 | integer
43 |
44 |
45 | false
46 | region
47 |
48 |
49 | integer
50 | number
51 |
52 | - integer
53 | - real
54 |
55 |
56 |
57 | integer
58 | number
59 |
60 | - integer
61 | - real
62 |
63 |
64 |
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/Procedures/3rd/roi_gen_lines.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | dev_set_colored(12)
8 | dev_get_window (WindowHandle)
9 |
10 |
11 | angle := 90
12 | num := 5
13 | read_image(Image,'monkey')
14 | dev_display (Image)
15 | *画仿射矩形(箭尾临近最高点)
16 | dev_set_color ('green')
17 | draw_rectangle1 (WindowHandle, Row1, Column1, Row2, Column2)
18 |
19 | *生成仿射矩形xld
20 | gen_rectangle1 (Rectangle, Row1, Column1, Row2, Column2)
21 |
22 | * dev_display(Rectangle)
23 |
24 | dev_set_color('red')
25 | step := (Row2 - Row1)/num
26 |
27 | switch (angle)
28 | case 90:
29 | Row_Current := Row1
30 | for Index := 1 to num + 1 by 1
31 | gen_contour_polygon_xld (Line, [Row1,Row1], [Column1,Column1])
32 | * dev_display (Line)
33 | disp_line (WindowHandle, Row_Current, Column1, Row_Current, Column2)
34 | * Row_Curent := Row_Current + step
35 | tuple_add (Row_Current, step, Row_Current)
36 |
37 | endfor
38 |
39 |
40 | endswitch
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/Procedures/3rd/select_min_max_length_contour.hdvp:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | *打开错误信息
15 | dev_set_check ('give_error')
16 | *最长轮廓变量初始化
17 | gen_empty_obj (MaxLengthContour)
18 | */gen_empty_obj (MinLengthContour)
19 |
20 | *开始捕获异常
21 | try
22 | *统计轮廓集合的数量
23 | count_obj (Edges, Number)
24 | *捕获异常
25 | catch (Exception)
26 | *异常处理
27 | return ( )
28 | endtry
29 | *如果轮廓数量无效,返回
30 | if (Number<1)
31 | return ( )
32 | endif
33 |
34 | *最长长度、最长长度索引初始化
35 | Max_Length:=0
36 | Max_Index:=0
37 | *最短长度、最短长度索引初始化
38 | Min_Length:=99999
39 | Min_Index:=0
40 |
41 | *遍历每个轮廓的长度
42 | for i := 1 to Number by 1
43 | *选择轮廓
44 | select_obj (Edges, ObjectSelected, i)
45 | *求轮廓长度
46 | length_xld (ObjectSelected, Length)
47 | *保存最长轮廓的长度和索引
48 | if (Max_Length<Length)
49 | Max_Length:=Length
50 | Max_Index:=i
51 | endif
52 | *保存最短轮廓的长度和索引
53 | if (Min_Length>Length)
54 | Min_Length:=Length
55 | Min_Index:=i
56 | endif
57 | endfor
58 | *选择最长轮廓
59 | select_obj (Edges, MaxLengthContour, Max_Index)
60 | *选择最短轮廓
61 | select_obj (Edges, MinLengthContour, Min_Index)
62 | *返回
63 | return ()
64 | return ()
65 | return ()
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
--------------------------------------------------------------------------------
/Procedures/Own/image_judge_stop.hdvp:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | *** 初始化图片
18 | ** 测试traffic demo
19 | * read_image (ImageBefore, 'traffic1')
20 | * read_image (ImageLater, 'traffic2')
21 | ** 测试 高拍测试
22 | * read_image (ImageBefore, 'C:/Users/iwake/MVS/Data/Hos0.bmp')
23 | * read_image (ImageLater, 'C:/Users/iwake/MVS/Data/Hos1.bmp')
24 | * read_image (ImageLater2, 'C:/Users/iwake/MVS/Data/Hos2.bmp')
25 |
26 | ** 对比图像
27 | * difference
28 | * diff_of_gauss (ImageLater, DiffOfGauss, 3, 1.6)
29 | * traffic demo 参数
30 | * check_difference (ImageBefore, ImageLater2, Selected, 'diff_outside', -15, 255, 0, 0, 0)
31 | * 高拍测试 参数
32 | check_difference (ImageBefore, ImageLater, Selected, 'diff_outside', -15, 255, 0, 0, 0)
33 |
34 | area_center (Selected, Area, Row, Column)
35 | * disp_obj (Selected, WindowHandle)
36 |
37 | *** 判断
38 | juadge_stop := 0
39 | if (Area <= 10000)
40 | juadge_stop := 1
41 | endif
42 | return ()
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/Procedures/Own/image_seg_paper.hdvp:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | *** Prog
18 | get_image_size (Image, Width, Height)
19 | *对饱和度图像进行二值化
20 |
21 | ** Detecting Paper
22 | * auto_threshold (Saturation, Regions, 20)
23 | binary_threshold (Image, Region, 'max_separability', 'light', UsedThreshold)
24 | fill_up_shape (Region, RegionFill, 'area', 1, 40000)
25 | connection (RegionFill, ConnectedRegions)
26 |
27 | area_center (ConnectedRegions, Area, Row, Column)
28 | select_shape (ConnectedRegions, Paper, 'area', 'and', max(Area), 99999999)
29 |
30 |
31 | ** Detecting Corner
32 |
33 | region_get_corner (Image, Paper, WindowHandle, Rows, Cols)
34 | * 计算分割角点质检距离
35 | * Distance := []
36 | * for Index := 1 to 4 by 1
37 | * if (Index == 4)
38 | * distance_pp (Rows[Index], Cols[Index], Rows[1], Cols[1], Distance)
39 | * break
40 | * endif
41 | * distance_pp (Rows[Index], Cols[Index], Rows[Index+1], Cols[Index+1], Distance)
42 | * endfor
43 | * dev_set_colored (12)
44 | * for Index := 1 to 4 by 1
45 | * disp_circle(WindowHandle,Rows[Index],Cols[Index],64)
46 | * endfor
47 | distance_ss(Rows[1], Cols[1], Rows[2], Cols[2], Rows[3], Cols[3], Rows[4], Cols[4], DistanceHeight, DistanceRMax)
48 | distance_ss(Rows[2], Cols[2], Rows[3], Cols[3], Rows[1], Cols[1], Rows[4], Cols[4], DistanceWidth, DistanceCMax)
49 |
50 |
51 |
52 |
53 | XCoordCorners :=[Rows[2],Rows[3],Rows[4],Rows[1]]
54 | YCoordCorners :=[Cols[2],Cols[3],Cols[4],Cols[1]]
55 |
56 | * factorScale := 0.5
57 | paperHeight := factorScale * DistanceHeight
58 | paperWidth := factorScale * DistanceWidth
59 |
60 | hom_vector_to_proj_hom_mat2d (XCoordCorners, YCoordCorners, [1,1,1,1], [0,paperHeight,paperHeight,0], [0,0,paperWidth,paperWidth], [1,1,1,1], 'normalized_dlt', HomMat2D)
61 | projective_trans_image (Image, Image_trans, HomMat2D, 'bilinear', 'false', 'false')
62 | gen_rectangle1 (Rectangle, 0, 0, paperHeight, paperWidth)
63 | reduce_domain(Image_trans,Rectangle,Mask) //裁剪区域
64 | crop_domain(Mask, Image_rectified) //切割图像
65 | return ()
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/Procedures/Own/region_get_corner.hdvp:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | ** Gen Line In Loop and juage cross
19 | get_image_size (Image, Width, Height)
20 | tuple_sqrt(Width*Width + Height*Height, LengthDiagonal)
21 | HalfDiagonal := LengthDiagonal/2
22 | * PolarityDegree := 1
23 | * PolarityLength := 1
24 | * Polarity := 3
25 | Rows := []
26 | Cols := []
27 | for Polarity := 1 to 4 by 1
28 | if (Polarity == 1)
29 | for Index := 0 to HalfDiagonal by 1
30 | gen_region_hline (RegionsLine3,rad(-45) , 1 * (1*HalfDiagonal - Index) )
31 | intersection (RegionsLine3, Rectangle, RegionIntersection)
32 | area_center (RegionIntersection, RegionIntersectionArea, Row, Column)
33 | if (RegionIntersectionArea > 0 )
34 | Rows[Polarity] := Row
35 | Cols[Polarity] := Column
36 | break
37 | endif
38 | endfor
39 | endif
40 | if (Polarity == 2)
41 | for Index := 0 to HalfDiagonal by 1
42 | gen_region_hline (RegionsLine3,rad(45) , 1 * (0 *HalfDiagonal + Index) )
43 | intersection (RegionsLine3, Rectangle, RegionIntersection)
44 | area_center (RegionIntersection, RegionIntersectionArea, Row, Column)
45 | if (RegionIntersectionArea > 0 )
46 | Rows[Polarity] := Row
47 | Cols[Polarity] := Column
48 | break
49 | endif
50 | endfor
51 | endif
52 | if (Polarity == 3)
53 | for Index := 0 to HalfDiagonal by 1
54 | gen_region_hline (RegionsLine3,rad(-45) , -1 * (1*HalfDiagonal - Index) )
55 | intersection (RegionsLine3, Rectangle, RegionIntersection)
56 | area_center (RegionIntersection, RegionIntersectionArea, Row, Column)
57 | if (RegionIntersectionArea > 0 )
58 | Rows[Polarity] := Row
59 | Cols[Polarity] := Column
60 | break
61 | endif
62 | endfor
63 | endif
64 | if (Polarity == 4)
65 | for Index := 0 to HalfDiagonal by 1
66 | gen_region_hline (RegionsLine3,rad(45) , 1 * (2* HalfDiagonal - Index) )
67 | intersection (RegionsLine3, Rectangle, RegionIntersection)
68 | area_center (RegionIntersection, RegionIntersectionArea, Row, Column)
69 | if (RegionIntersectionArea > 0 )
70 | Rows[Polarity] := Row
71 | Cols[Polarity] := Column
72 | break
73 | endif
74 | endfor
75 | endif
76 | * get_region_points (RegionIntersection, Rows, Columns)
77 | * disp_message (WindowHandle, 'Intesection Row:'+ Row +'Col'+ Column, 'window', Row, Column, 'black', 'true')
78 | endfor
79 | * dev_set_colored (12)
80 | * for Index := 1 to 4 by 1
81 | * disp_circle(WindowHandle,Rows[Index],Cols[Index],64)
82 | * endfor
83 | return ()
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
--------------------------------------------------------------------------------
/Procedures/inte_xld.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | *轮廓的创建,区域边缘生成轮廓,提取,分割,合并
7 | *画圆生成圆轮廓
8 | dev_open_window (0, 0, 512, 512, 'black', WindowHandle)
9 | draw_circle (WindowHandle, Row, Column, Radius)
10 | gen_circle_contour_xld (ContCircle, Row, Column, Radius, 0, 6.28318, 'positive', 1)
11 | *画矩形生成矩形轮廓
12 | draw_rectangle2 (WindowHandle, Row1, Column1, Phi, Length1, Length2)
13 | gen_rectangle2_contour_xld (Rectangle, Row1, Column1, Phi, Length1, Length2)
14 | *生成箭头轮廓
15 | gen_arrow_contour_xld (Arrow, Row, Column, Row1, Column1, 25, 50)
16 | *生成十字叉轮廓
17 | gen_cross_contour_xld (Cross, Row, Column, 25, 0)
18 | *画一个区域并将将区域边缘生成轮廓
19 | draw_region (Region, WindowHandle)
20 | gen_contour_region_xld (Region, Contours, 'border')
21 | *区域生成骨骼,骨骼转轮廓
22 | skeleton (Region, Skeleton)
23 | gen_contours_skeleton_xld (Skeleton, Contours1, 1, 'filter')
24 | *图像边缘提取得到轮廓
25 | read_image (Image, 'fabrik')
26 | threshold_sub_pix (Image, Border, 128)
27 | *带通滤波:滤波器是提取出图像,白的更白,黑的更黑
28 | bandpass_image (Image, ImageBandpass, 'lines')
29 | threshold_sub_pix (ImageBandpass, Border, 128)
30 | *索蓓尔放大器,把边缘区域变亮,不是边缘的都变暗,也是梯度值变化,就是保留梯度值变化的位置
31 | sobel_amp (ImageBandpass, EdgeAmplitude, 'sum_abs', 3)
32 | threshold_sub_pix (EdgeAmplitude, Border, 128)
33 | *高通滤波器:梯度值低和高的变化会变亮
34 | highpass_image (EdgeAmplitude, Highpass, 9, 9)
35 | *亚像素提取轮廓,通过过滤器和梯度变化率来获取边缘
36 | edges_sub_pix (Image, Edges, 'canny', 1, 20, 40)
37 | *从最大宽度和提取线的对比度计算出lines_gauss的参数Sigma、Low和High。
38 | calculate_lines_gauss_parameters (8, [12,0], Sigma, Low, High)
39 | *精确的抽出线,返回亚像素轮廓,三平滑系数,四五阈值范围,越小线越多,第六个参数标识提
40 | *取亮线还是暗线,七,是否提取线的宽度(如果获取线的宽度,则线提前的位置越宽则显示的线就越宽)
41 | lines_gauss (Highpass, Lines, Sigma, Low, High, 'light', 'true', 'bar-shaped', 'true')
42 | circularity_xld (Lines, Circularity)//获取圆度
43 | length_xld (Lines, Length)//获取长度
44 | area_center_xld (Lines, Area, Row2, Column2, PointOrder)//获取面积中心点
45 | *轮廓等高线过滤
46 | select_contours_xld (Lines, SelectedContours, 'contour_length', 20, 200, -0.5, 0.5)
47 | *轮廓几何形状过滤
48 | select_shape_xld (SelectedContours, SelectedXLD, 'area', 'and', 150, 99999)
49 |
50 |
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # HalconPractise
2 |
3 | ## Halcon
4 | ### Download 下载
5 |
6 | - [MVtec官方下载](https://www.mvtec.com/download/halcon/)*需注册MVtec用户;如果网络卡顿,请将VPN挂在国外服务器节点.建议美国香港日本*
7 |
8 | - [iHalcon(Halcon学习网)下载](http://www.ihalcon.com/read-7605-1.html)
9 | - [iHalcon(Halcon学习网)最新下载地址19.05](http://www.ihalcon.com/read-11123.html)
10 | - [大恒图像国内代理下载](http://www.daheng-imaging.com)
11 |
12 | ### HalconLicense 许可证
13 |
14 | - [大恒图像国内代理购买](http://www.daheng-imaging.com)
15 | - [51Halcon网适用许可证](https://www.51halcon.com/thread-387-1-1.html)
16 |
17 | ### Install 安装
18 | #### win/mac
19 | - 一直下一步
20 | - 只要能勾选✔就都打勾
21 | #### linux
22 | - Download __SOM__
23 | - ./som
24 | - open `localhost:8188` and login.(You cannot login with ssh -L $REMOTE:8188. Only can you login locally!)
25 | - select what you want, and install for all users.
26 |
27 | ## HalconProj
28 | ### Cam
29 |
30 | ### PicPre 图像预处理相关
31 | #### Rgb2Gray 彩色图像转黑白
32 |
33 | ## Tools
34 |
35 | ## GitProj
36 | - https://github.com/bitbyte27/Halcon s28
37 |
38 |
39 | ## TODO
40 |
41 | - [ ] **Right Now**
42 | - [ ] 测量划痕长度eg
43 |
44 |
--------------------------------------------------------------------------------
/Textbook/Halcon数字图像处理/c3s1.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | * 3.1.1
7 |
8 | *eg 3-1
9 | cont := 2
10 | if(cont >= 2)
11 | cont := cont - 1
12 | endif
13 |
14 | *eg 3-2
15 | cont := 2
16 | if(cont >= 2)
17 | cont := cont - 1
18 | else
19 | cont := cont + 1
20 | endif
21 |
22 | *eg 3-3
23 | cont := 2
24 | if(cont >= 2)
25 | cont := cont - 1
26 | elseif(cont <= -1)
27 | cont := cont + 1
28 | else
29 | cont := cont + 2
30 | endif
31 |
32 | *eg 3-4
33 | I := 5
34 | switch(I)
35 | case 1:
36 | I := I -1
37 | break
38 | case 5:
39 | I := I + 5
40 | break
41 | default:
42 | I := 2 * I
43 | endswitch
44 |
45 | *eg 3-5
46 | In := 1
47 | In_Sum := 0
48 | while (In <= 100)
49 | InSum := InSum + In
50 | In := In + 10
51 | endwhile
52 |
53 | *eg 3-6
54 | I := 0
55 | for J := 1 to 10 by 1
56 | if (J < 5)
57 | continue
58 | endif
59 | I := I + J
60 | endfor
61 |
62 | *eg 3-7
63 | I := 0
64 | for J := 1 to 10 by 1
65 | if (J > 5)
66 | break
67 | endif
68 | if( J == 3)
69 | continue
70 | endif
71 | I := I + J
72 | endfor
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
--------------------------------------------------------------------------------
/Textbook/Halcon数字图像处理/c3s2.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Textbook/Halcon数字图像处理/c3s3.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | *eg 3-8
7 | * ImagePath := []
8 | * ImagePath[0] := 'fin1.png'
9 |
10 | *eg 3-9
11 | * Image Acquisition 01: Code generated by Image Acquisition 01
12 | * open_framegrabber ('DirectShow', 1, 1, 0, 0, 0, 0, 'default', 8, 'rgb', -1, 'false', 'default', '[0] ', 0, -1, AcqHandle)
13 | * grab_image_start (AcqHandle, -1)
14 | * while (true)
15 | * grab_image_async (Image, AcqHandle, -1)
16 | * Image Acquisition 01: Do something
17 | * endwhile
18 | * close_framegrabber (AcqHandle)
19 |
20 | *eg3-10
21 |
22 | *eg3-12
23 | * dev_close_window ()
24 | * dev_open_window (0, 0, 400, 400, 'black', win0)
25 | * dev_set_color ('red')
26 | * disp_arrow (win0, 255-20,255-20,255,255, 1)
27 | * disp_message (win0, 'disp text', 'window', 20, 20, 'black', 'true')
28 | * dev_set_color('blue')
29 | * set_tposition (win0, 40,40)
30 | * write_string(win0, 'hello')
31 | * set_tposition (win0, 255, 255)
32 | * read_string (win0,'', 10, OutString)
33 |
34 | *eg3-13
35 | * read_image (Earth, 'earth.png')
36 | * rgb1_to_gray(Earth, GrayImage)
37 |
38 | *eg 3-14
39 | * read_image (Image,'fabrik')
40 | * regiongrowing(Image, Regions, 3, 3, 6, 100)
41 | * region_to_mean (Regions, Image, Disp)
42 | * dev_open_window (0, 0, 512, 512, 'black', WindowHandle)
43 | * dev_display(Disp)
44 |
45 | *eg 3-15
46 | read_image (Image, 'a01.png')
47 | copy_image(Image, dupImage)
48 | regiongrowing(dupImage, regions,3, 3, 1, 100)
49 | region_to_bin (regions,binImage, 255, 0, 512, 512)
50 | region_to_label (regions,imageLabel,'int2', 512, 512)
51 |
52 |
53 |
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/Textbook/Halcon数字图像处理/c4s1.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | *eg 4-1
7 | * read_image (image, 'claudia.png')
8 | * count_channels (image, Channels)
9 | * for index := 1 to Channels by 1
10 | * access_channel (image,channel1, index)
11 | * endfor
12 | * decompose3(image, image1, image2, image3)
13 | * trans_from_rgb (image1, image1, image1, imageResult1, ImageResult2, ImageResult3, 'hsv')
14 | * compose2(image3, image2, multiChannelImage1)
15 | * append_channel (multiChannelImage1, image3, imageExtend)
16 |
17 | *eg 4-2
18 | dev_close_window ()
19 | dev_open_window (0, 0, 512, 512, 'black', WindowHandle)
20 | gen_image_const (image, 'byte', 50, 50)
21 | get_image_size (image, Width, Height)
22 | gen_image_proto (image,Image, 164)
23 | get_domain (image, domain)
24 | disp_message (WindowHandle, Width, '', 12, 12, 'black', 'true')
25 | crop_domain (image, ImagePart)//似乎是固定值裁切出一个小矩形
26 | get_grayval(ImagePart, 10, 10, Grayval)
27 | set_grayval(ImagePart, 10, 10, 255)
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/Textbook/Halcon数字图像处理/c4s3.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | *eg 4-16
7 | * read_image (Image, 'mvtec_logo')
8 | * threshold_sub_pix (Image, Border, 128)
9 | * edges_sub_pix (Image, Edges, 'canny', 1, 20, 40)
10 | * select_shape_xld (Edges, SelectedXLD, 'area', 'and', 150, 99999)
11 | * select_contours_xld (Border, SelectedContours, 'contour_length', 0.5, 200, -0.5, 0.5)
12 |
13 | *eg 4-17
14 | * read_image (Image, 'mvtec_logo')
15 | * get_image_size (Image, Width, Height)
16 | * dev_open_window (0, 0, Width, Height, 'black', WindowHandle)
17 | * threshold (Image, Region, 0, 125)
18 | * gen_contour_region_xld (Region, Contours, 'border')
19 | * select_shape_xld (Contours, SelectedXLD, 'area', 'and', 14500,99999)
20 | * get_contour_xld (SelectedXLD, Row, Col)
21 | * dev_clear_window ()
22 | * gen_contour_polygon_xld (Contour, Row, Col)
23 | * gen_polygons_xld (Contour,Polygons, 'ramer', 2)
24 |
25 | *eg 4-18
26 | * dev_open_window (0, 0, 512, 512, 'black', WindowHandle)
27 | * read_image (Image, 'screw_thread')
28 | * threshold_sub_pix (Image, Border, 128)
29 | * edges_sub_pix (Image, Edges, 'canny', 1, 20, 40)
30 | * threshold(Image, Region, 0, 100)
31 | * select_shape_xld (Edges, SelectedXLD, 'area', 'and', 20000,99999)
32 | * fill_up (Region, RegionFillUp)
33 | * gen_contour_region_xld (RegionFillUp, Contours, 'border')
34 | * area_center_xld (Contours, Area, Row1, Column, PointOrder)
35 | * select_shape_xld (Contours, SelectedXLD1, 'area', 'and', 150, 99999)
36 | * get_contour_xld (SelectedXLD,Row1, Col)
37 | * gen_contour_polygon_xld (Contour1, Row1, Col)
38 | * query_contour_attribs_xld (SelectedXLD, Attribs)
39 | * get_contour_attrib_xld (SelectedXLD, 'angle', Attrib)
40 | * stop ()
41 |
42 | *eg 4-19//
43 |
44 |
45 | *eg 4-20//
46 |
47 | *eg 4-21//
48 |
49 | *eg 4-22
50 | * dev_open_window (0, 0, 512, 512, 'black', WindowHandle)
51 | * gen_circle_contour_xld (ContCircle, 290, 260, 100, 0, 1,'positive', 1)
52 | * query_contour_global_attribs_xld (ContCircle, Attribs)
53 | * regress_contours_xld (ContCircle, RegressContours, 'no', 1)
54 | * query_contour_global_attribs_xld (RegressContours, Attribs1)
55 | * get_contour_global_attrib_xld (RegressContours, 'regr_norm_row', Attrib)
56 | * get_regress_params_xld (RegressContours, Length, Nx, Ny, Dist, Fpx, Fpy, Lpx, Lpy, Mean, Deviation)
57 |
58 |
59 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/Textbook/Halcon数字图像处理/c5s1.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | *eg 5-1//?
7 | * read_image (Image, 'patras')
8 | * rgb1_to_gray (Image, GrayImage)
9 | * convert_image_type (GrayImage, ImageConverted, 'real')
10 | * gen_image_const (Image1, 'real', 432, 769)
11 | * for i := 1 to 10 by 1
12 | * add_noise_white (Image1, ImageNoise, 90)
13 | // add_image (ImageNoise, Image1, ImageResult, 1,0)
14 |
15 | * endfor
16 | * scale_image (ImageResult, ImageScaled, 0.1, 0)
17 | * scale_image (ImageNoise, ImageScaled, 0.1, 0)
18 |
19 | *eg 5-2//
20 |
21 |
22 | *eg 5-3//
23 |
24 | *eg 5-4//
25 | * read_image (Image, 'dog.jpeg')
26 |
27 | *eg 5-5//
28 |
29 |
30 | *eg 5-6//
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/Textbook/Halcon数字图像处理/c5s2.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | *eg 5-7//
7 |
8 | *eg 5-8//
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/Textbook/Halcon数字图像处理/c5s3.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | *eg 5-10//
7 |
8 | *eg 5-11//
9 | * Ref Example for operator projective_trans_image:2d_data_codes_rectify_symbol.hdev
10 | dev_update_off ()
11 | dev_close_window ()
12 | read_image (Image, 'datacode/ecc200/ecc200_to_preprocess_001')
13 | dev_open_window_fit_image (Image, 0, 0, -1, -1, WindowHandle)
14 | dev_set_color('white')
15 | dev_set_line_width (3)
16 | stop ()
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/Textbook/Halcon数字图像处理/c6s1.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Textbook/Halcon数字图像处理/c6s2.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | *eg 6-1//
7 |
8 | *eg 6-2
9 | * read_image (Image, 'lena')
10 | * get_image_size (Image, Width, Height)
11 | * dev_close_window ()
12 | * dev_open_window_fit_image (Image, 0, 0, -1, -1, WindowHandle)
13 | * dev_display (Image)
14 | * min_max_gray (Image, Image, 0, Min, Max, Range)
15 | * scale_image_max (Image, ImageScaleMax)
16 | * write_image (ImageScaleMax, 'bmp', 0, 'result.bmp')
17 |
18 | *eg 6-3
19 | * read_image (Image, 'monkey')
20 | * get_image_size (Image, Width, Height)
21 | * dev_close_window ()
22 | * dev_open_window_fit_size (0, 0, Width, Width, -1, -1, WindowHandle)
23 | * dev_display (Image)
24 | * rgb1_to_gray (Image, GrayImage)
25 | * log_image (GrayImage, LogImage, 'e')
26 | * dump_window (WindowHandle, 'bmp', 'log.bmp')
27 |
28 | *eg 6-4//
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/Textbook/Halcon数字图像处理/c6s3.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | *eg 6-5
7 | *method 1
8 | * read_image (Image, 'lena')
9 | * get_image_size (Image, Width, Height)
10 | * dev_close_window ()
11 | * dev_open_window_fit_size (0, 0, Width, Width, -1, -1, WindowHandle)
12 | * dev_display (Image)
13 | * rgb1_to_gray (Image, GrayImage)
14 |
15 | *method 2//
16 |
17 | *eg 6-7
18 | read_image (Image, 'lena')
19 | get_image_size (Image, Width, Height)
20 | dev_close_window ()
21 | dev_open_window_fit_size (0, 0, Width, Width, -1, -1, WindowHandle)
22 | dev_display (Image)
23 | rgb1_to_gray (Image, GrayImage)
24 | equ_histo_image (GrayImage, ImageEquHisto)
25 | dump_window (WindowHandle,'bmp', 'equ.bmp')
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/Textbook/Halcon数字图像处理/c6s4.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | *eg 6-8
7 | * read_image (Image, 'monkey')
8 | * get_image_size (Image, Width, Height)
9 | * dev_close_window ()
10 | * dev_open_window_fit_size (0, 0, Width, Width, -1, -1, WindowHandle)
11 | * dev_display (Image)
12 | * gauss_distribution (20, Distribution)
13 | * add_noise_distribution (Image, ImageNoise, Distribution)
14 | * dump_window (WindowHandle,'bmp','medianFilter,bmp')
15 | * mean_image (ImageNoise,ImageMean, 9, 9)
16 | * dump_window (WindowHandle, 'bmp', 'meanFiler.bmp')
17 |
18 | *eg 6-9//
19 |
20 | *eg 6-10//
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Textbook/Halcon数字图像处理/c6s5.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | *eg 6-11
7 | * read_image (Image, 'monkey')
8 | * get_image_size (Image, Width, Height)
9 | * dev_close_window ()
10 | * dev_open_window_fit_size (0, 0, Width, Width, -1, -1, WindowHandle)
11 | * dev_display (Image)
12 |
13 | * sobel_amp (Image, EdgeAmplitude, 'sum_abs', 3)
14 | * dump_window (WindowHandle, 'bmp', 'sobel.bmp')
15 | * sobel_amp (Image, EdgeAmplitude1, 'x', 3)
16 | * dump_window (WindowHandle, 'bmp', 'sobelX.bmp')
17 | * sobel_amp (Image, EdgeAmplitude2, 'y', 3)
18 | * dump_window (WindowHandle, 'bmp', 'sobelY.bmp')
19 |
20 | *eg 6-12//
21 |
22 | *eg 6-13
23 | read_image (Image, 'monkey')
24 | get_image_size (Image, Width, Height)
25 | dev_close_window ()
26 | dev_open_window_fit_size(0, 0, Width, Width, -1, -1, WindowHandle)
27 | dev_display (Image)
28 | gen_highpass (ImageHighpass, 0.1, 'none', 'dc_center', Width, Height)
29 | fft_generic (Image,ImageFFT, 'to_freq', -1, 'sqrt', 'dc_center', 'complex')
30 | convol_fft (ImageFFT,ImageHighpass, ImageConvol)
31 | fft_generic (ImageConvol, ImageFFT1, 'from_freq', 1, 'sqrt', 'dc_center', 'byte')
32 | dump_window (WindowHandle, 'bmp', 'highPass.bmp')
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/Textbook/Halcon数字图像处理/c6s6.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | *
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/Textbook/Halcon数字图像处理/c7s1.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | *eg 7-1
7 | * read_image (Image, 'fabrik')
8 | * get_image_size (Image, Width, Height)
9 | * dev_close_window ()
10 | * dev_open_window_fit_size (0, 0, Width, Width, -1, -1, WindowHandle)
11 | * threshold (Image, Region, 179, 255)
12 | * dev_display (Image)
13 | * dev_display (Region)
14 |
15 | *eg 7-2
16 | * dev_close_window ()
17 | * read_image (Image, 'letters')
18 | * get_image_size (Image, Width, Height)
19 | * dev_open_window (0, 0, Width/2, Height/2, 'black', WindowHandle)
20 | * dev_set_color ('red')
21 | * gray_histo (Image, Image, AbsoluteHisto, RelativeHisto)
22 | * gen_region_histo (Histo, AbsoluteHisto, 255, 255, 1)
23 | * histo_to_thresh (AbsoluteHisto, 8, MinThresh, MaxThresh)
24 | * dev_set_colored (12)
25 | * threshold (Image, Region, MinThresh[0], MaxThresh[0])//select foreground
26 | ** threshold (Image, Region, MaxThresh[0], MaxThresh[1])//select background
27 | * dev_display (Region)
28 |
29 | *eg 7-3//
30 |
31 | *eg 7-4//
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/Textbook/Halcon数字图像处理/c7s2.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | *eg 7-5
7 | * read_image (Image, 'fabrik')
8 | * get_image_size (Image, Width, Height)
9 | * dev_close_window ()
10 | * dev_open_window_fit_size (0, 0, Width, Width, -1, -1, WindowHandle)
11 | * roberts (Image, ImageRoberts, 'gradient_max')
12 | * threshold (ImageRoberts, Region, 9, 255)
13 | * skeleton (Region, Skeleton)
14 | * dev_display (Image)
15 | * dev_set_color ('red')
16 | * dev_display (Skeleton)
17 |
18 | *eg 7-6
19 | read_image (Image, 'fabrik')
20 | dev_close_window ()
21 | get_image_size (Image, Width, Height)
22 | dev_open_window (0, 0, Width, Height, 'black', WindowHandle)
23 |
24 | sobel_amp (Image, EdgeAmplitude, 'sum_abs', 3)
25 | threshold (EdgeAmplitude, Region, 10, 255)
26 | skeleton (Region, Skeleton)
27 |
28 | dev_display (Skeleton)
29 | dev_set_color ('red')
30 | dev_display (Skeleton)
31 |
32 | *eg 7-7//
33 |
34 | *//
35 |
36 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/Textbook/Halcon数字图像处理/c7s3.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | *eg 7-12
7 | read_image (Image, 'fabrik')
8 | get_image_size (Image, Width, Height)
9 | dev_close_window ()
10 | dev_open_window_fit_size (0, 0, Width, Width, -1, -1, WindowHandle)
11 | dev_set_colored (12)
12 | regiongrowing (Image, Regions, 1, 1, 1, 1000)
13 | gen_empty_region (EmptyRegion)
14 | expand_gray (Regions, Image, EmptyRegion, RegionExpand, 'maximal', 'image', 4)//!!
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Textbook/Halcon数字图像处理/c7s4.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | *eg 7-13
7 | read_image (Image, 'fabrik')
8 | rectangle1_domain (Image, ImageReduced, 170, 280, 310, 370)
9 | sobel_dir (ImageReduced, EdgeAmplitude, EdgeDirection, 'sum_abs', 3)
10 | dev_set_color ('red')
11 | threshold (EdgeAmplitude, Region, 55,255)
12 | reduce_domain (EdgeDirection, Region, ImageDrectionReduced)
13 | hough_lines_dir (ImageDrectionReduced, HoughImage, Lines, 4, 2, 'mean', 3, 5, 5, 5, 'true', Angle, Dist)
14 | gen_region_hline (LinesHNF, Angle, Dist)
15 | dev_display (Image)
16 | dev_set_colored (6)
17 | dev_set_draw ('margin')
18 | dev_display (LinesHNF)
19 | dev_set_draw ('fill')
20 | dev_display (Lines)
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Textbook/Halcon数字图像处理/c7s5.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Textbook/Halcon数字图像处理/c7s6.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | *eg 7-14
7 | dev_close_window ()
8 | * read_image (Image, 'meningg5')
9 | read_image (Image, 'fabrik')
10 | get_image_size (Image, Width, Height)
11 | dev_open_window (0, 0, Width, Height, 'black', WindowHandle)
12 |
13 | derivate_gauss (Image, DerivGauss, 2, 'none')
14 | convert_image_type (DerivGauss, ImageConverted, 'byte')
15 | watersheds (ImageConverted, Basins, Watersheds)
16 | dev_set_draw ('margin')
17 | dev_set_colored (6)
18 | dev_display (Watersheds)
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/Textbook/Halcon数字图像处理/c8s1.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ** eg 8-1//
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/Textbook/Halcon数字图像处理/c9s1.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Textbook/Halcon数字图像处理/c9s2.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | *eg 9-1
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/empty.hdev:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | aaa (Image)
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | read_image (Image, 'printer_chip/printer_chip_01')
20 | return ()
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------