Halcon self-study notes 1

I am working on machine vision recently, and I found that it is not quite the same as I thought. . . . Learn the development of halcon from scratch. I feel that the development of halcon is really simple compared to opencv. It is about to catch up with the visual interface programming, but in the later stage, it will definitely be joint development with C++, C#, etc., let's talk about it.

The reason why halcon is simply based on its powerful packaging, a large number of function operators can be used directly, and the user interface is also extremely simplified, let's introduce an example.

What we have to do is to divide the paper clips in the above picture and count them clearly. Of course, it can be done very quickly with opencv, filtering-thresholding-contour detection, and then you can get the number, but it will be simple with halcon Complete this function.

The final result is like this, the number is recognized and displayed.

read_image (Image, 'C:/Users/41608/Pictures/005AFwmPzy6Kgy9XlFQee&690.jpg')
get_image_size(Image,Witdh,Height)
dev_open_window (0, 0, Witdh/2, Height/2, 'black', WindowHandle)
dev_display(Image)
gauss_filter (Image, ImageGauss, 5)
threshold(ImageGauss,Region, 0, 128)
connection (Region, ConnectedRegions)
select_shape (ConnectedRegions, SelectedRegions, 'area_holes', 'and', 150, 99999)
count_obj (SelectedRegions, Number)
set_display_font(WindowHandle, 14, 'mono', 'true', 'false')
dev_set_color('green')
dev_set_line_width(3)
dev_set_draw('margin')
disp_message (WindowHandle, Number, 'window', 12, 12, 'black', 'true')
dev_display(ConnectedRegions)

The function can be completed in just a few lines. Whenever you use an operator, you only need to click on the required operator in the operator window, and the following function parameter selection will be displayed. You can directly select the parameters in the function with There is a small amount of analysis, which is very convenient.

But halcon's tutorials are not as many as opencv, and you need to study more by yourself. Some functions that are not encapsulated have to be completed with opencv, so take your time. . . . The egg hurts.

Guess you like

Origin blog.csdn.net/wi162yyxq/article/details/88662354