before writing Halcon in C + +, make sure you have a good C + + foundation and are familiar with a set of development platforms such as Vc programmers_guide.pdf Chapter7 for creating Aplicatin with halcon/c++ detailed introduction take vs2008 as an example tool---"Options (with a picture of the unworthy text) write an example in C + + ~~ Take baboons ' eyes//#include "stdafx.h" #include "HalconCpp.h" #pragma comment (lib, "Halconcpp.lib") int Main () { using namespace halcon; himage mandrill ("monkey"); Hwindow w; & nbsp; W.display (Mandrill); W.click (); hregion Bright = (Mandrill >=128); area with brightness greater than 128 Hregionarray conn = bright.connection (); //Take area in 500~9000 area, The baboon's big nose is also greater than 128, apparently not the focus of our testing according to the area of the shed it hregionarray large = conn. Selectshape ("area", "and", 500,9000); //The eye is oval anisometry is the ratio of the eccentricity of the RA/RB two radius, visually see 1.2-1.7 Hregionarray eyes = large. Selectshape ("Anisometry", "and", 1.2,1.7); eyes. Display (w); W.click (); return 0;} //~~ extract characters include "stdafx.h" #include "HalconCpp.h" #include <iostream> #pragma comment (lib, " Halconcpp.lib ") using namespace Std;using namespace Halcon; int main () { himage image (" Alpha1 "); hregion Region; hwindow W; long Threshold; image. Display (w); w.click (); //image. GetDomain--obtain image region //sigma---Gaussian smoothing coefficient //percent---foreground background grayscale different percentage 95 Representing at most 5% is the maximum grayscale value region = image. Charthreshold (image. GetDomain (), 2,95,&threshold); image. Display (w); region. Display (w); w.click (); cout<< "Threshold for ' alpha ':" < <threshold; w.click (); return 0;} note: the operator in the reference manual is incomplete, A complete list can is found in the Le include\cpp\hcppglobal.h. 1. About parameters: The input parameters of ①.halcon are not changed by the operator, that is, by value The following code example Himage original_image ("monkey") , Smoothed_image;smoothed_image = Original_image. Meanimage (one, one, one); meanimage does not change original_image, and the median image is saved in the return value Smoothed_image ②. In contrast, the output parameter Parameters), so it is a pointer or reference 2.halcon/c++ about object-oriented and process This is the object-oriented way of invoking the method through the class Himage image ("barcode/ean13/ ean1301 "); Htuple paramname, Paramvalue; Hbarcode Barcode (paramname, paramvalue); Hregionarray code_region; Htuple result;code_region = barcode. Findbarcode (Image, "EAN-13", &result); code_region = image. Findbarcode (Barcode, "EAN-13", &result); the process-oriented way hobject image; Htuple Barcode; Hobject code_region; Htuple result;read_image (&image, "barcode/ean13/ean1301"); Create_bar_code_model (HTuple (), HTuple (), & Barcode); Find_bar_code (image, &code_region, barcode, "EAN-13", &result); 3.halcon/c++ all objects can be in C : \program Files\mvtec\halcon-10.0\include\cpp found (with HALCON installed in C drive for example) 4.halcon/c++ array mode we can use the operator to open multiple images region and so on to see if the operation supports array mode depends on its definition A few notes to the array: ① Create, initialize array C + + can be increased by [] C through Gen_empty_obj array Concat_obj② manipulating objects C + + via [N], count array elements num () C select_obj The count_obj③iconic array starts with 0, and the Hobject array starts with 1, ④ illustrates the 4th by example. #include "stdafx.h" #include "HalconCpp.h" #include <iostream> #pragma comment (lib, "Halconcpp.lib") using namespace std;using namespace Halcon; ~ ~ Extract character int main () {Himagearray images; Hregionarray regions; Htuple thresholds; Hwindow W; The for (int i = 1; I <=2;++i) {//htuple ("alpha") +i interpretation//htuple has an overload of Operater +//htuple ("Al Pha ") +i ~ ~ ~ Alpha1 alpha2 ... images[i-1] = Himage::readimage (htuple (" alpha ") +i); }//This sentence is equivalent to the charthreshold operation of all objects in the images regions = images. Charthreshold (Images[0]. GetDomain (), 2,95,&thresholds); for (int i = 0; i<regions. Num (); ++i) { images[i]. Display (w); w.click (); regions[i]. Display (w); w.click (); cout<< "threshold:" <<thresholds[i]. L () <<endl; } w.click (); return 0;} 5. About parameter conversions converting hobject into iconic parameter Classes hobject p_image;read_image (&p_image, "barcode/ean13/ ean1301 "); Himage o_image (p_image); iconic parameters can is converted from hobject to, e.g., himage simply by calling the const Ruc-tor with the procedural variable as a parameter. converting handles inTo handle Classes htuple P_barcode;create_bar_code_model (Htuple (), Htuple (), &p_barcode); Hbarcode O_barcode;o_barcode. SetHandle (P_barcode[0]); o_code_region = O_barcode. Findbarcode (O_image, "EAN-13", &result); handles cannot be converted directly via a constructor; Instead, the method SetHandle () with the procedural handle as a parameter. converting handle classes into H Andles p_barcode = O_barcode. GetHandle (); similarly, a handle can is extracted from the corresponding class via the method GetHandle (). You can even omit the method, as the handle classes provide cast operators which convert themautomatically into HANDLES.&N Bsp; p_barcode = o_barcode; converting iconic parameter Classes into Hobject hobject p_code_region = o_code_region. Id (); iconic parameters can is converted from classes like hregion back into Hobject via the Methodid (). In contrast to the handle classes no cast opeRator is provided. converting hwindow into a window Handle long p_window;open_window (0, 0, WIDTH/2, Heig HT/2, 0, "visible", "", &p_window); Hwindow O_window (0, 0, +, 0, "visible", "");p _window = O_window. WindowHandle ();d isp_obj (p_code_region, P_window); in contrast to other handles, procedural windows handles cannot be Converted into instances of Theclass hwindow! However, you can extract the handle from an instance of Hwindow via the Methodwindowhandle (). 6. The Halcon Parameter classes
6.1 Iconic ObjectsBase class is Hobject Himage, Hregion,hxld base class is Hobject
6.1.1 ReionsRegion is a set of coordinate points of the image plane, which may not be connected, may contain holes, and it can be larger than the image. Use an example to understand hregion #include "stdafx.h" #include "HalconCpp.h" #include <iostream> #pragma comment (lib, " Halconcpp.lib ") using namespace Std;using namespace halcon;/*example describes the use of region, in more detail in Progarma_guide chapter6.1.1*/int Main () {Himage image ("Mreut"); Hregion region; Hwindow W; Region = Image >=190; W.setcolor ("Red"); Region. Display (w); W.click ();//region. Fillup () Call methodHregion filled = region. FillUp (); Filled. Display (w); W.click ();//Operator overloading Open operations >> corrosion << expansion, RADIUS 4.5Hregion open = (filled >>4.5) <<4.5; W.setcolor ("green"); Open. Display (w); W.click (); W.clearwindow ();//PanningHDPOINT2D Trans (-100,-150); Hregion moved = open + trans; Hregion zoomed = moved * 2.0; Zoomed. Display (w); W.click (); return 0;} #include "stdafx.h" #include "HalconCpp.h" #include <iostream> #pragma comment (lib, "Halconcpp.lib") using Namespace Std;using namespace halcon;/*example introduces the use of Regionarry*/int Main () { himage image ("Fabrik"); //1 1 row col Smaller, finer & nbsp; //4 tolerance seed and detected pixel value Difference //100 min region Size hregionarray Regs = image. Regiongrowing (1,1,4,100); hwindow w; w.setcolored (; ) image. Display (w); w.click (); regs. Display (w); w.click (); hregionarray rect; for (int i = 0; i < regs. Num (); + + i) { //compactness ~ ~ is often called roundness in image processing and is used here as Region's tightness //c = l^2/(4 F pi)) L = Perimeter F = Area   &NBSP;&NBSP;&NBSP;//C = 1 is a circle, region is longer or region has a hole when C >1 // This is the region &nbs of the relatively square hole.P; if ((regs[i). Area () >, && (Regs[i]. Compactness () < 1.5)) rect. Append (Regs[i]);//regionarry adding elements Oh} image. Display (w); Rect. Display (w); W.click (); return 0;}
6.1.2 Images #include "stdafx.h" #include "HalconCpp.h" #include <iostream> #pragma comment (lib, "Halconcpp.lib") using Namespace std;using namespace halcon;/* drawregion painting area of interest meanimage doing median filtering and median filtering before image comparison */int main () {& Nbsp; himage image ("Mreut"); hwindow w; Image. Display (W); cout<< "width =" << image. Width () <<endl; cout << "height =" << image. Height () <<endl; hregion mask= w.drawregion (); // & Reload Take an image of the area of interest himage reduced = image & Mask; w.clearwindow (); reduced. Display (w); w.click (); himage mean = reduced. Meanimage (61,61); mean. Display (w); hregion reg = reduced. Dynthreshold (mean,3, "LiGht "); reg. Display (w); w.click (); return 0;}
6.1.2.2 Pixel valueThe two methods of manipulating pixels are int main () {hbyteimage in ("Mreut"); Hbyteimage out = in; Hwindow W; In. Display (w); W.click (); int nwidht = in. Width (); int nheight = in. Height (); Long end = NWIDHT * nheight; for (int k = 0; k < end; k++) {//Method 1//int pix = in. Getpixval (k); Out. Setpixval (K,255-pix); Method 2 out[k]= 255-in[k]; } out. Display (w); W.click (); return 0;}
6.1.3 XLD ObjectsXLD is the abbreviation for eXtended line Description.This was a data structure used for describing areas(e.g., arbitrarily sized regions or polygons) or any closed or open contour, i.e., also lines.In contrast toregions, which represent all areas at pixel precision, XLD objects provide subpixel precision. There is the basic XLD structures:contours and polygons. Similarly to images, Halcon/c++ provides both a base class Hxld and a set of specialized classes derived from hxld, e.g., Hxldcont for contours or hxldpoly for polygons. For all classes there exists a corresponding container class, e.g., Hxldarray. In contrast to the classes described in the previous sections, the XLD classes provide only member functions corresponding To HALCON operators (see also sections 5.2.2 on page 35).
6.1.4 Low-level iconic objects bottom iconic objectThe class hobject is used for all iconic parameters, being it an image, a region, or even an image array In fact, the class Hobject is HALCON's basic class for accessing the internal data management Furthermore, Hobject serves As the basis for the class Hobject and the derived classes, e.g., himage. As noted above, an instance of Hobject can also contain a tuple (array) of iconic objects. Unfortunately, Hobject provides no special member functions to add objects or select them; Instead, you must use the operators Gen_empty_obj, Concat_obj, Select_obj, and Count_obj. An Hobject instance can contain a set of iconic objects, but Hobject does not provide a member function to add or select them, so it must be resolved by Gen_empty_obj, Concat_obj, Select_obj, and Count_obj.
6.2 Control Parameters
From for notes (Wiz)
List of attachments
Halocn/c++ (first article)