The ZW edition · Halcon-delphi Series Original Tutorial "Yogurt Automatic classification script (machine learning, artificial intelligence)

Source: Internet
Author: User

The ZW edition · Halcon-delphi series of Original tutorials

Yogurt Automatic classification script (machine learning, artificial intelligence)

Halcon's powerful image processing ability often ignores its more robust machine learning, artificial intelligence.
At least, the current domestic and overseas machine learning, artificial intelligence scholars, not a few attention to this piece.
Abroad, it could be a copyright issue, after all, Halcon is a commercial software that sells for up to tens of thousands of euros (not renminbi) and is mainly used in industrial areas such as self-control and machine vision, rather than universities.
Domestic, may be for halcon not enough understanding.
In fact, the core of image processing, image recognition, classification, are inseparable from machine learning, artificial intelligence
Look at the development of OPENCV, you can see clearly, from the image of cv1.0, to cv1.0 machine learning, as well as the current cv3.0 GPU, Cuda ai module, the AI occupies a larger share of the.

Halcon because of the front line, so many machine learning, artificial intelligence, are black-box, without programming, direct call, for example, the built-in OCR module, can identify 99% of standard industrial characters: supermarkets, customs, assembly lines
However, Halcon also provides a large number of machine learning modules, after all, a variety of applications, complex cumbersome, must be on-site customization.


Halcon comes with demo script: Matching_multi_channel_yogurl.hdev
is a simple machine learning, artificial intelligence classification application, but also a typical application scenario
The effect is good, we can see, Figure 2, Figure 4, the angle of the image is different, there is rotation, Halcon can be easily identified.
But this script, the AI aspect is not complicated, modeling is to take a few photos of the product, directly match.
In general, Halcon modeling requires 200 iterations (default parameters).

The choice of this script, one of the reasons, is because a few days ago, someone in the forum asked, how on the Enterprise line products (snacks like? ) for automatic classification.


Script more than 80 lines, very simple.

1*This example demonstrates shape based matching2*With Multi channel images3*4*Init Display5 Dev_update_off ()6Mode: ='Multi Channel'7Modelcolor: ='Green'8Circlecolor: =' White'9Names: = ['Pear Apple Hazelnut','Cherry Currant','Strawberry']TenRead_image (Image,'color/yogurt_model_01') One get_image_size (image, Width, Height) A Dev_close_window () -Dev_open_window (0,0, Width, Height,'Black', WindowHandle) -Set_display_font (WindowHandle, -,'Mono','true','false') the* -* Part1: Create shape models -Modelids: = [] -  forIndex: =1To3By1 +Read_image (Image,'Color/yogurt_model_'+ index$' Geneva') - Dev_display (Image) +* A*Create ROI automatically atAccess_channel (Image, Channel1,1) -Fast_threshold (Channel1, Region, the,255, -) - fill_up (Region, Regionfillup) -Opening_circle (Regionfillup, regionopening,170.5) -GEN_CONTOUR_REGION_XLD (regionopening, contours,'Border') -FIT_CIRCLE_CONTOUR_XLD (Contours,'Geotukey', -1,0,0,3,2, Row, Column, Radius, Startphi, Endphi, Pointorder) inGen_circle (Circle, Row, Column, Radius/2) - Reduce_domain (Image, Circle, imagereduced) to* +*Create Model -Create_shape_model (imagereduced,6, Rad (0), Rad ( the),'Auto','Auto','ignore_color_polarity', [ *, -, the], One, ModelID) theModelids: =[Modelids,modelid] ** $*Display ModelPanax Notoginseng Dev_set_color (Circlecolor) -Dev_set_draw ('margin') theDev_set_line_width (5) + Dev_display (Circle) AGet_shape_model_contours (Model1contours, ModelID,1) the Dev_set_color (Modelcolor) +Dev_set_line_width (2) -Dev_display_shape_matching_results (Modelids, Modelcolor, Row, Column,0.0,1,1, ModelID) $Disp_message (WindowHandle,'Create Shape Model'+ Names[index-1],'window', A, A,'Black','true') $Disp_message (WindowHandle,'Press \ ' run\ ' to continue','window', the, A,'Black','true') - Stop () - endfor the*Main Loop:find Yogurt -  forIndex: =1ToTenBy1WuyiRead_image (Image,'Color/yogurt_'+ index$' Geneva') the*preprocessing:reduce Search domain to speed up matching -Access_channel (Image, Channel1,1) WuFast_threshold (Channel1, Region, -,255, -) - fill_up (Region, Regionfillup) AboutErosion_rectangle1 (Regionfillup, Regionerosion, About, About) $ Reduce_domain (Image, Regionerosion, imagereduced) -*Find Yogurt -Find_shape_models (imagereduced, Modelids, Rad (0), Rad ( the),0.80,1,0.5,'Least_squares',0,0.95, Row, Column, Angle, score, Model) -* A*Display Results + Dev_display (Image) theGen_circle (Circle, Row, Column, Radius/2) - Dev_set_color (Circlecolor) $Dev_set_line_width (5) the Dev_display (Circle) theGet_shape_model_contours (modelcontours, model,1) the Dev_set_color (Modelcolor) theDev_set_line_width (2) -Dev_display_shape_matching_results (Modelids, Modelcolor, Row, Column, Angle,1,1, Model) inDisp_message (WindowHandle, Names[find (Modelids,model)] +'found','window', A, A,'Black','true') theDisp_message (WindowHandle,'score'+ Score,'window', -, A,'Black','true') the if(Index <Ten) AboutDisp_continue_message (WindowHandle,'Black','true') the Stop () the endif the endfor +* -*Cleanup Memory theClear_shape_model (modelids[0])BayiClear_shape_model (modelids[1]) theClear_shape_model (modelids[2])


"ZW Edition · Halcon-delphi series of original tutorials, website, cnblogs.com/ziwang/"

The ZW edition · Halcon-delphi Series Original Tutorial "Yogurt Automatic classification script (machine learning, artificial intelligence)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.