Home
HDevelop User's Manual
Contents
1. Information dev clear window is local and processed completely exclusively without parallelization D Possible Predecessor Functions 2 dev set window dev open window dev display Possible Successor Functions o 1 dev_display See 802 4424044 4 4 4 4 46 2 clear window gt System Close an inspect window of a control variable dev close inspect ctrl is the opposite operator to dev inspect ctrl and closes the in spect window corresponding to Variable The window can also be closed by pressing the Close button of the dialog LLL Attention This operator is not supported for exported C code Parameter o o o gt Variable input control real array real integer string Name of the variable which inspect window has to be closed Example SSS HDevelop 2003 08 01 135 Var 1 dev inspect ctrl Var Var 2 L1 2 3 9 5456 7 9 Var 3 4 Stop dev close inspect ctrl Var LLL Reto If an inspect window associated with Variable is open dev_close_inspect_ctr1 returns 2 MSG TRUP LLL Parallelization Information gt dev close inspect ctrl is local and processed completely exclusively without paralleliza tion Possible Predecessor Functions 1 dev inspect ctrl Module 0000000000 o Basic operators dev close window Close the active g
2. Basic operators Image region management Image filterz sub pixel operators Template matching a Region processing Morphology Background estimation Optical character recognition Fourier descriptors wiener filter Camera calibration Tools System Barcode reader Optical character verification Figure 2 8 The modules window HDevelop File Execute Visualization Operators Suggestions Window Help Urda E E Er e ls cs uc nix TE Copy Ctrl C Paste Str iP Delete Find Operator Ctrl F Find Again Replace Variables Ctrl H 4 Cut program line s Figure 2 9 Main window s menu item Edit Edit gt Undo You may undo your previous activities by clicking Edit gt Undo For example by click ing three times this item you cancel the last three user actions Edit gt Cut keyboard shortcut Ctrl Z You may use the items Edit gt Cut Edit gt Copy and Edit gt Paste for changing the program contents First you have to select the part of the program at least one program line that has to be changed use the left mouse button Then you may delete this part by clicking the item Edit gt Cut The deleted program part is stored in an internal buffer Thus by using the item Edit gt Paste keyboard shortcut lt Ctrl gt V the buffer remains HALCON 6 0 4 20 CHAPTER 2 GRAPHICAL USER INTE
3. fori ito 100 l tuple tuple 4711 endfor Because this is not very convenient a special function called gen tuple const is available to construct a tuple of a given length where each element has the same value Using this function the program from above is reduced to assign gen tuple const 100 4711 tuple which is displayed as tuple gen tuple const 100 4711 If we want to construct a tuple with the same length as a given tuple there are two ways to get an easy solution The first one is based on tuple const assign gen tuple const tuple o1dl 4711 tuple new which is displayed as tuple new tuple const ltuple old 4711 The second one is a bit tricky and uses arithmetic functions assign tuple old 0 4711 tuple new which is displayed as tuple new tuple old 0 4711 Here we get first a tuple of the same length with every element set to zero Then we add the constant to each element In the case of tuples with different values we have to use the loop version to assign the values to each position assign tuple fori 5 2 lto t00 l assign tuple i i tuple endfor which is displayed as HDevelop 2003 08 01 3 5 EXPRESSIONS FOR INPUT CONTROL PARAMETERS 71 tuple fordi 5 2 1 amie tuple tuple i i endfor In this example we construct a tuple with the square values from 1 to 1007 3 5 5 Simple Arithmetic Operations T
4. slal s ELE Classification gt Inspection of Ball Filter read image Bond die3 Fite iBl x x Program ba Y Affine Transformations threshold Bond Bright 100 BlePhics Arithmetic shape trans Bright Die re Image gt Bit reduce domain Bond Die Lines Color b threshold DieGrey Wires C Morphology gt Edges gt opening_circle VMiresFilled dak 4 connection Balls SingleBall Regions select shape SingleBalls Ir Segmentation Lines sort region IntermediateBal System Match b smallest circle FinalBalls F Tools gt Misc gt NumBalls Radius Diameter 2 Radius 21 d Notes i meanDiameter sum Diameter A smoothing d _ diff mimDiameter min Diameter Testure gt eliminate min max Wiener Filter gt eliminate sp fill interlace gauss image info smooth mean image mean n mean sp median image median separate median weighted midrange image rank image sigma image smooth image trimmed mean Variable Watch Iconic Variables 125 879310345 130 277777778 130 411764706 130 448529412 15 117 120689655 220 5 326 941176471 429 772058824 535 5 b41 18 8480195564 18 5645276853 18 3522385752 19 3302061918 1 Diameter 37 6960391127 37 1290553706 36 7044771504 38 6604123836
5. 1 2 3 1 2 4711 Hugo 4711 Hugo hugo 2 1 2 1 0 5 4 1 5 4 2 1 2501 true false Hugo Table 3 13 Examples for the comparison of tuples The four comparison operators compute the lexicographic order of tuples On equal index positions the types must be identical however values of type integer real and boolean are adapted automatically The lexicographic order applies to strings and the boolean false 15 considered to be smaller than the boolean true false lt true In the program compare dev you can find examples for the comparison operators 3 5 9 Boolean Operators The boolean operators and or xor and not are defined only for tuples of length 1 1 and 1 is set to true 1 if both operands are true 1 whereas 1 1 returns true 1 if at least one HALCON 6 0 4 76 CHAPTER 3 LANGUAGE negation logical and logical or logical xor Table 3 14 Boolean operators of the operands is true 1 1 xor 1 return true 1 if exactly one of both operands is true not lreturns true 1 if the input is false 0 and false 0 if the input 1s true 1 3 5 10 Trigonometric Functions these functions work on tuples of numbers as arguments The input can either be of type integer or real However the resulting type will be of type real The functions are applied to all tuple values and the resulting tuple has the same length as the input tuple For ata
6. 4 2 2 1 Array Assignment If a single value 15 assigned to a variant array a special subroutine is called to ensure that the index is valid If the array 1s to small it 1s resized 4 2 2 2 Expressions parameter expression inside HDevelop are translated into expressions based on the HAL CON tuple operators Therefore an expression might look somewhat complex In many cases these expressions can be changed to simple Visual Basic expressions like tuple_sub becomes a simple subtraction To ensure that the exported program has the same effect in Visual Basic this exchange is not applied automatically because the semantic is not always identical 4 2 2 3 Stop The HDevelop operator stop is translated into a subroutine in Visual Basic which creates a message box This message box causes the program to halt until the button 1s pressed 4 2 2 4 Exit The HDevelop operator exit is translated into the Visual Basic routine End Because this routine has no parameter the parameters of exit are suppressed 4 2 2 5 Used Classes There are only six classes types that are used Variant for control parameters and HUntypedObjectX for iconic data In addition there is the container class HTupleX which comprises all operators of HALCON processing tuples in this case the data type Variant Then there are the classes HWindowXCtr1l and its low level content HWindowX HWindowXCtrl is used inside the project for the output window and a variable of clas
7. Chapter 5 Program Examples This chapter contains examples that illustrate how to program with HDevelop To understand the examples you should have a basic knowledge of image analysis The user interface 15 described in chapters 1 2 and 2 Language details are explained chap ter 3 The examples of this chapter are also available as program code in the directory AHALCONROOT NexamplesMhdevelopMManualsMIDevelop To experiment with these examples we recommend to create a private copy in your working directory More detailed information on HALCON operators 15 available in the reference manuals 5 1 Stamp Segmentation File name stamps dev The first example performs a document analysis task Figure 5 1 shows a part of a stamp catalog page It contains two types of information about stamps a graphical presentation and a textual description of the stamp In this example you have to transform the textual information into a representation that can be processed by a computer with little effort You might use an OCR program for this task but you will soon recognize that most of the available products create many errors due to the graphical presentation of the stamps Thus another task has to be preprocessed the elimination of all stamps 1 changing stamps to the gray value of the paper After this preprocessing it is possible to process the remaining text using an OCR program When creating an application to solve this kind of pr
8. LLL If dev set line width should be used for exported Code C please note the description of set line width due to the different semantics in Parameter gt o gt LineWidth input control a Rom nbd integer integer Line width for region output in contour mode Default Value 1 Restriction LineWidth gt 1 HDevelop 2003 08 01 147 Example SSS read_image Image monkey threshold Image Region 128 255 dev_set_draw margin dev_set_line_width 5 dev_clear_window dev_display Region a Result 0000000 dev set line width always returns 2 H MSG TRUE ao Information _ dev_set_line_width is local and processed completely exclusively without parallelization Possible Successor Functions 2 dev_display SC See AlsSO ooo set line width query line width Module _ System dev set lut LutName Set look up table lut dev set lut sets look up table of the the output window A look up table defines the transfor mation of a value within an image into a gray value or color on the screen It describes the screen gray value color as a combination of red green and blue for any image gray value 0 255 so it is a table to look up the screen gray value color for each image gray value look up table Transformation into screen colors is performed in real time at every time the screen is disp
9. HDevelop images are automatically scaled to fit the current window size This is not the case in exported programs If for example you load and display two images of different size the second one will appear clipped if it is larger than the first image or filled up with black areas if it is smaller For a correct display you must use the operator dev set part before displaying an 1mage with dev display as follows dev set part 0 0 ImageHeight 1 ImageWidth 1 dev display Image In this example Image is the image variable ImageHeight and ImageWidth denote its size You can query the size of an image with the operator get image pointer Please consult the HALCON Reference Manuals for more details Note that the operator dev set part and its HALCON library equivalent set part is more commonly used for displaying and thereby zooming parts of images By calling it with the full size of an image as shown above you assure that the image exactly fits the window Changing display parameters If you change the way how results are displayed color line width etc in HDevelop interactively via the menu Visualization these changes will not be incorporated in the exported program We recommend to insert the corresponding Develop operators e g dev set color ordev set line width in the HDevelop program explicitely This will result in the appropriate call set_color set line width etc in the exported code HDevelop 2003 08 01
10. inv cubic root colorl1 color2 color3 color4 three six twelfe twenty four rainbow temperature cyclic_gray cyclic temperature hsi changel change2 change3 Example SS read_image Image mreut dev_set_lut inverse For true color only dev_display Image Result gt dev set lut always returns 2 H MSG TRUE LLL Parallelization Information _ __________ _ _ dev set lut 1s local and processed completely exclusively without parallelization Possible Successor Functions o o o Y dev_display See Also i o set_lut Module System dev set paint Define the grayvalue output mode dev set paint defines the output mode for grayvalue display in the graphics window The mode is used by dev display This page describes the different modes that can be used for grayvalue output It should be noted that the mode default is the most suitable A different way to display grayvalues is the histogram mode histogram This mode has three additional parameter values Row second value and column third value They denote row and column of the histogram center for positioning on the screen The scale factor fourth value determines the histogram size a scale factor of 1 distinguishes 256 grayvalues 2 distinguishes 128 grevalues and so on The four v
11. 6 Miscellaneous 61 Keycodes 6 2 Interactions During Program Execution 63 6 4 Warning and Error Windows 03 eae ox mom ox Rom x Ro RR Ox 5 BO d XOXE 4e X X A Control assign 83 93 93 94 85 85 88 88 88 89 91 91 92 92 92 93 93 95 95 97 100 103 104 106 107 110 112 113 114 119 119 119 120 120 120 123 MEME 124 cn uo s oom oho o om om baw X Row Xo 9 0xQ 40 E EO ES 125 MEM uuo wow www sw 199 Ww x9 wu wd 4 wer ww 125 uoo we BOwe dus ox om E ON XE EE OE EO BE 126 5499 9 95ws59 abe eee RS REM ee 128 cx 3 3urXW ERU EA ESEE E dr mE 129 PI 22545584 9 409 9 x WW E RM EUR SS RS RUE E ER 129 BE 4 22 52 5 5 med EE S 130 BH Nm P NES STE Sd EE EERE REG EEG 131 B Develop 133 div Nei r0 8 BERR ERA EAGER SOARES eee 133 1 133 due REE REE rds 343433 134 dev close window 135 auus ue omo oho om omo XR og Gav xo X XXE OE XX ow 136 iu rl kee eae ew wae eae eo he ee ee eS 136 dev_inspect ctrl 6o whe oom 9
12. As you can see from this example the indices of a tuple start at O An insertion into a tuple can generally be performed in one of the following ways 1 In case of appending the value at the back or at the front the concatenation can be used Here the assign operator is used with the following parameters assign Tuple NewVal Tuple which is displayed as Tuple Tuple NewVal 2 If the index position 15 somewhere in between the operator insert has to be used It takes the following arguments as input first the tuple in which the new value should be inserted then the new value and after that the index position as the third input parameter The result the fourth parameter 1s almost identical with the input tuple except of the new value at the defined index position HALCON 6 0 4 68 CHAPTER 3 LANGUAGE In the following example regions are dilated with a circle mask and afterwards the areas are stored into the tuple Areas In this case the operator insert is used read image Mreut mreut threshold Mreut Region 190 255 Areas for Radius 1 to 50 by 1 dilation circle Region RegionDilation Radius area center RegionDilation Area Row Column Areas Radius 1 Area endfor Please note that first the variable Areas has to be initialized 1n order to avoid a runtime error In the example Areas is initialized with the empty tuple Instead of insert the operator assign with tuple co
13. Basic operators dev map var Map the variable window on the screen dev_map_var maps the variable window on the screen i e makes it visible that has been unmapped using dev unmap var oo Attention This operator is not supported for exported C code SI _ dev_map_var always returns 2 H MSG TRUE HALCON 6 0 4 140 APPENDIX B DEVELOP o Information dev_map_var is local and processed completely exclusively without parallelization Possible Predecessor Functions 1 dev_unmap_var Possible Successor Functions 2 dev_unmap_var See Also dev_map_par dev_map_prog Module SSS Basic operators Open a graphics window dev_open_window opens a new graphics window which can be used to perform output of gray value data regions and graphics as well as to perform textual output This new window auto matically becomes active which means that all output dev_display and automatical display of operator results 1s redirected to this window This is shown by the green dot in the Active button In the case of the standard display operators like disp_image disp_region disp_line etc instead of dev display the logical window number WindowHandle has to be used The background of the created window 15 set to the color specified in Background Pressing the Clear button clears the graphics window contents and the history of the window This c
14. Column i 1 60 else set tposition WindowID Row i 1 2 5 Radius i 1 Column i 1 60 endif write string WindowID Diam Diameter i 1 endfor dev set color green dev update window on Result for returns 2 H_ MSG_TRUE if the evaluation of the expression yields no error endfor as operator always returns 2 H MSG TRUE LLL Parallelization Information gt for is reentrant local and processed without parallelization Alternatives while See Also 444404444 4 4 4 464 2 if ifelse Module Basic operators if Condition Conditional statement if 1s a conditional statement The condition contains a boolean expression If the condition is true the body is executed Otherwise the execution is continued at the first expression or operator call that follows the corresponding endif Parameter gt Condition input control 27 adeunt nda ca d doi ores gie aer iin det integer integer Condition for the if statement Default Value 1 Result _ if returns 2 H MSG TRUD if the evaluation of the expression yields no error endif as operators always returns 2 MSG TRUE S Parallelizzation Information gt if is reentrant local and processed without parallelization Alternatives T ifelse See Also 444444446 4642 for while Module Basic operators HDevelop 2003 08 01 129 ifelse Condition Condition with alternative
15. For this you press the left mouse button to indicate the rectangle s upper left corner Hold the button and drag the mouse to the lower right corner s position Release the button and correct the size by grabbing the borders or corners of the rectangle By pressing the right mouse button inside your specified rectangle you display the objects inside the rectangle in the graphics window You also have the possibility to enter the coordinates of the desired clipping manu ally In order to do so you have to specify the coordinates of the upper left corner and the lower right corner in the respective text fields Please note that the text fields sometimes behave unexpectedly HDevelop 2003 08 01 2 3 MAIN WINDOW 35 Visualization Parameters Lut Pen Upper row Left column 30 193 Interactive Lower row Right column 234 263 Center row Center column 132 220 Interactive Zoom out Zoom in Aspect Figure 2 22 Settings of parameter zoom Below the coordinates of the rectangle you see its center This center can also be specified interactively using the button Interactive Activating this mode you first have to click with the left button into the active graphics window Now you can correct this position by again pressing the left mouse button To quit press the right mouse button The buttons Zoom Out and Zoom In activate a zooming with factor 2 or 0 5 respec tively To get the image
16. It evaluates Input right side of assignment and stores it in Result left side of assignment However in the program text the assignment is represented by the usual syntax of the assign ment operator The following example outlines the difference between an assignment in C syntax and its transformed version in HDevelop The assignment in C syntax u sin x cos y HDevelop 2003 08 01 3 5 EXPRESSIONS FOR INPUT CONTROL PARAMETERS 67 is defined in HDevelop using the assignment operator as assign sin x cos y u which is displayed in the program window as u sin x cos y If the result of the expression doesn t need to be stored into a variable the expression can directly be used as input value for any operator Therefore an assignment is necessary only if the value has to be used several times or if the variable has to be initialized e g for a loop A second assignment operator is available insert Input Value Index Result It is used to assign tuple elements If the first input parameter and the first output parameter are identical the call insert Areas Area Radius 1 Areas is not presented in the program text as an operator call but in the more intuitive form as Areas Radius 1 Area To construct a tuple with insert normally an empty tuple is used as initial value and the elements are inserted in a loop Tuple 59016 1 bob Eb l Tuple i sqrt real i endfor
17. Module Basic operators dev update pc DisplayMode Specify the behaviour of the PC during program execution dev update pc specifies the behaviour of the PC during program execution In the mode on default the PC 1s always displayed in front of the current operator In addition the program text is scrolled if necessary so that the current operator is visible In the mode off the PC is not visible during program execution and the program text will not be scrolled automatically This option can also be controled by the dialog File gt Options gt Update PC LLL Attention This operator is not supported for exported C code Parameter o o o gt DisplayMode input control 22 95 04 80 EUR EH cte dU dH a string string Mode for runtime behaviour Default Value off Value List DisplayMode on off o Reto dev_update_pc always returns 2 H MSG TRUE Parallelization Information _ dev update pc is reentrant local and processed without parallelization HALCON 6 0 4 156 APPENDIX B DEVELOP See Also SSS dev_update_time dev_update_window dev_update_var Module Basic operators dev update time DisplayMode Switch time measurement for operators on or off dev update time controls if the execution time of an operator has to be measured This option can also be controled by the dialog File gt Options gt Show
18. Type Width Height dev_open_window 0 0 Width Height black Window ID dev zd dev rt 0 0 Height 1 VMidth 1 fill i inte m e Chri ristof ImageFilled add mean image ImageFilled ImageMean 29 29 threshold ImageFilled ImageMean RegionDynThresh 5 light 2 v set colored 12 nection esh ConnectedRegionsDynThresh dis 58 shape ConnectedRegionsDynThresh SelectedRegion h area ness and 150 1 QN aR isDynThre sh ImageFilled Marks ret 120 255 dev isplay ImageFilled dev Regions Marks v region object Anisometry amp nisometry v real Bulkiness Bulkiness real StructureFactor StructureFactor real a Enter Cancel 3600 1 12702204804 1 11467319487 1 18047551603 1 12294618312 1 42797741283 1 1t 1 00416718505 1 00426336515 1 00007240412 1 00253432078 1 00587046647 1 0 Figure 1 4 Region selection based on shape features In the next step you have to specify the regions which correspond to the circular marks of the indicated person in shape and size For this you have to call the operator select_shape in menu Operators gt Regions gt Features The first call is used to obtain a preselection with the estimated object size given in pixels With an estimated size of 15 x 15 pixels you will get approximately 225 pixels After choosing select_shape you specify the parameters as follows 1 The
19. appropriate program segment looks as follows mean image Particle Mean 31 31 dyn threshold Particle Mean Small 3 light The operator dyn threshold compares two images pixel by pixel You can see the segmenta tion result in figure 5 6 left at Dum uu Figure 5 6 Small objects simple left and advanced segmentation right As we see all objects have been found Unfortunately the edges of the large particles and several very small regions that emerged due to the noisy image material were found too We first try to suppress the edges One way is to eliminate all objects that exceed a certain maximum size You can do this by calling connection Small SmallSingle select shape SmallSingle ReallySmall area and 1 300 By the same method you might also eliminate all objects which are too small blurring For this you would just have to increase the minimum size with the call of select shape But if you examine the segmentation results again you will notice that some of the resulting pixels were already extracted by the first segmentation Thus you should search the small particles within the complement of the large ones only To avoid the segmentation of small particles in the direct neighbourhood of the large ones those are enlarged before building their complement Thus we get the following modified program HALCON 6 0 4 102 CHAPTER 5 PROGRAM EXAMPLES dilation circle Large LargeD
20. stop 38 Stop 35 82 130 String 72 160 Concatenation 66 Operations 72 Suggestion 42 Alternative 43 Keyword 43 Predecessor 42 See also 43 Successor 43 Syntax 61 Termination 125 Texture 98 Texture energy 99 texture laws 98 Threshold 97 99 100 104 106 109 112 115 threshold 28 97 109 116 true 63 159 Tuple 52 56 160 Arithmetic 66 Concatenation 67 68 Index Type 54 160 boolean 63 66 75 159 Control parameter 61 62 Iconic object 61 65 integer 62 integer 52 65 66 72 159 Numerical 62 real 52 62 65 66 72 159 160 string 52 62 65 66 159 160 Tuple 52 UNIX 2 14 84 9 Variable 64 _ 64 Control 54 56 Iconic 40 54 55 Visualization 16 Variable window 40 Variable window 9 18 54 160 Visual Basic 12 88 Export 88 Visualization Line width 39 Region 39 Regions 32 Segmentation results 32 XLD 32 watersheds 42 while 35 80 93 131 159 Window 133 135 140 152 Halcon 41 ID 39 Window size 152 Windows 2000 2 Windows NT 2 Windows NT 2000 XP 84 91 XLD 54 160 165 HALCON 6 0 4
21. 01 2 6 VARIABLE WINDOW 55 V arrable Watch Iconic variables 125 8 2310345 130 277 777778 130 411764706 130 148528412 1 117 1208588555 220 5 325 8411 5471 429 77 2050044 535 5 b41 18 848 0195554 18 554527 5853 18 3522385 52 18 3302 061818 15 NumbBalls b Diameter 37 6960391127 37 1290553706 35 704477 1504 38 5B504123835 meanLilameter 37 6464465501 mal mnn mh m Tw TAA ad Figure 2 38 Variable window for both iconic and control data 2 6 1 Area for Iconic Data Here you can see iconic variables They are represented by icons which contain a gray image a region or an XLD depending on the current value The icons are created depending on the type of data according the following rules e the case of images the icon contains a zoomed version of it filling the icon completely Due to the zooming onto the square shape of the icon the aspect ratio of the small image might be wrong If there is more than one image in the variable only the first image is used for the icon Similarily for multi channel images only the first channel 1s used e Regions are displayed by first calculating the smallest surrounding rectangle and then zooming it so that it fills the icon using a border of one pixel In contrast to images the aspect ratio 1s always correct This can lead to black bars at the borders The color used to draw the region 15 always white without further modifications exc
22. 18 you see an image of such a road sequence on the left side Figure 5 18 Part of an image sequence left and search grid for marking band right Assume that there 1s no specialized operator for this task Thus you have to make use of standard methods The data structure used consists of a gray value image with a covering mask i e the definition range operators work only on those parts of the image data that lie within the definition range This can be exploited to reduce computation time The following assumptions on the image data help to specify a region as a search mask 1 Road markings remain in a certain 1mage part only 2 Road markings have a certain minimum length in y direction 3 Road markings are separated by an edge from their environment The first two assumptions can restrict the search area enormously To make use of this we create a region as a grid whose line distance is determined by the minimum size of the road marking Figure 5 18 shows the corresponding region line grid on the right side While performing an edge filter within the grid all pixels with a high gradient are candidates on the contour of a road marking By enlarging these pixels by the minimum diameter of the markings dilation with rectangle you will get the search window shown in figure 5 19 on the left side Now the road markings can be easily extracted by a thresholding within the search windows The segmentation result is s
23. 2 3 The Menu Execute In this menu item you find all necessary functions to execute a HDevelop program the pro gram window see chapter 2 4 You have the following items to choose from HDevelop clip2 dev EE x File Edt Beer Visualization Operators Suggestions Window Help Os ME gt ses 2 ea 5 OE x Activate Deactivate F4 Active Set Break Paint Clear Break Point Clear All Break Points eight Program ght 2 black indo and 5000 10000 Execute next program F5 Figure 2 12 Main window s menu item Execute Execute gt Run keyboard shortcut F5 By selecting Execute gt Run HDevelop executes your program depending on the PC s position in the program window The PC indicates the next program line to execute AII following program lines are going to be performed until the program end Notice that a break point may interrupt the run of your program During the execution of operators the following special behaviour occurs e Although the mouse pointer indicates that HDevelop 15 not ready to handle user in put clock shape of the mouse pointer you may initiate limited transactions For HALCON 6 0 4 22 CHAPTER 2 GRAPHICAL USER INTERFACE example if you click variables they will be visualized you may modify output parameters for graphics windows you may even modify the program N
24. 4 60 HDevelop 2003 08 01 CHAPTER 2 GRAPHICAL USER INTERFACE Chapter 3 Language The following chapter introduces the syntax and the semantics of the HDevelop language In other words it illustrates what you can enter into a parameter slot of an operator In the simplest case this is the name of a variable but it might also be an expression like sqrt A Besides control structures like loops and the semantics of parameter passing are described Chapter 5 explains the application of this language in image analysis Note that the HALCON operators themselves are not described in this chapter For this purpose refer to the HALCON reference manual All program examples used in this chapter can also be found in the directory HALCONROOT examples hdevelop Manuals HDevelop 3 1 Basic Types of Parameters HALCON distinguishes two kinds of data control data numerical string and iconic data im ages regions etc By further distinguishing input from output parameters we get four different kinds of parame ters These four kinds always appear in the same order in the HDevelop parameter list Table 3 1 shows their order of appearance Table 3 1 Order of appearance of the four basic parameter types As you see iconic input objects are always passed as the first parameter s followed by the iconic output objects The iconic data 15 followed by the control data and again the input parameters succeed the output parameters E
25. In a a gt 0 decadic logarithm log a a gt 0 4182 a1 282 exp a log a log O a 1 2 ldexp a1 2a2 Table 3 16 Exponential functions is of type real If all elements are of type integer the resulting value will also be of type integer The same applies to the function sum that determines the sum of all values If the input arguments are strings string concatenation will be used instead of addition min t max t sum t mean a deviation a sqrt a deg a rad a real a round a abs a fabs a ceil a floor a fmod a1 a2 minimum value of the tuple maximum value of the tuple sum of all elements of the tuple or string concatenation mean value standard deviation square root 4 a convert radians to degrees convert degrees to radians convert integer to real convert real to integer absolute value of integer or real absolute value of a always real smallest integer value not smaller than a largest integer value not greater than a fractional part of a1 a2 with the same sign as a1 Table 3 17 Numerical functions The functions sqrt mean deviation deg rad fabs ceil floor and fmod can work with integer and real the result is always of type real The function mean calculates the mean value and deviation the standard deviation of numbers sqrt calculates the square root of a number deg and rad convert numbers from radians to degrees and from degrees to radi
26. Mean Contacts 5 light connection Contacts ContactsConnect fill_up ContactsConnect ContactsFilled select_shape ContactsFilled ContactsRes area and 10 100 The result of the intersection is still not satisfying Too many small and too many wrong regions have been found So we have to eliminate them by using select_shape Figure 5 14 shows the final result of the segmentation on the right side 5 8 Cell Walls File name wood_cells dev In this example we will examine the alteration of the cell wall s proportion during a tree s growth The input image is a microscope view of wooden cells see figure 5 15 You can clearly see the single cells and the discontinuity that is caused by the stopped growing in winter Extracting cell walls is simple because they are significantly darker The remaining difficulty lies in the computation of the distribution in growth direction 1 e along the image x axis First we define the width of the window over which the cell distribution is computed by assigning it to the variable X in the program Then we fetch the image size using get image pointer1 to get the corresponding loop parameters The broader the search range the stronger the smoothing during the measurement Now the loop starts from the left side to compute the whole image The ratio of the area of the cell walls and a rectangle of width X is computed for every value of the loop variable i The
27. Processing Time LLL Attention 0000000000000 This operator is not supported for exported code Parameter o gt o o gt DisplayMode input control string string Mode for graphic output Default Value off Value List DisplayMode on off dev update time always returns 2 H MSG TRUE oo Parallelization Information dev_update_time 1s reentrant local and processed without parallelization See Also gt dev update pc dev update window dev_update_var Module Basic operators dev update var DisplayMode Specify the behaviour of the variable window during program execution dev update var specifies the behaviour of the variable window during program execution Using the mode on default the contents of the variable window iconic and control variables is updated each time a variable is modified by the program In the mode off the variables are updated only when the execution 15 finished Please not that update this contents only means the graphical representation of the internal values in the variable window This option can also be controled by the dialog File gt Options gt Update Variables LLL Attention 0000000000000 This operator 15 not supported for exported code HDevelop 2003 08 01 157 Parameter o gt o o gt DisplayMode input con
28. The menu item Help gt About delivers information about the current HALCON HALCON 6 0 4 46 CHAPTER 2 GRAPHICAL USER INTERFACE HDevelop clip dev Of x File Edit Execute Visualization Operators Suggestions 0770 Help 18 sakaf ae Arrange icons Program Clear P 1 Program bin threshold Clip Dark wv 2 Operator connection Dark Single select shape Single Selected area and 5000 10000 dew set draw fill 4 Graphics Window dev set colored 12 dev display Selected stop dew display Clip dev zet calor green dev display Selected orientation region Selected Phi area center Selected Area Row Column dev set line width 3 dev set draw margin Length 80 for i Oto Phi 1 by 1 dev color blue disp arrow Column i Rav Lenath sin Phi i Colum dev set color orange set tposition Column i write string vindowlD dea Phi i deg endfor dev update window Con Variable Watch Iconic Aariables Operator Operator select shape Features ores st Operation st 0 696166660103 2 487 75531802 D 5712204498793 0 5791 6469 6792 6265 6161 5702 5532 6369 691 125 582751455 155 135822337 1378174255868 270 4 162 452299605 437 956981201 522 510131835 239 B 12 dev update window 0 00s Fi
29. been given to the field width precision The precision specifies the minimum number of digits to appear for the d o x or X conversions the field 1s padded with leading zeros the number of digits to appear after the radix character for the e and f conversions the maximum number of significant digits for the g conversion or the maximum number of characters to be printed from a string in s conversion The precision takes the form of a period followed by a decimal digit string A null digit string is treated as a zero conversion characters A conversion character indicates the type of conversion to be ap plied d o x X The integer argument is printed in signed decimal d unsigned octal o or unsigned hexadecimal notation x and X The x conversion uses the numbers and letters 0123456789abcdef and the X conversion uses the numbers and letters 0123456789ABCDEF The precision component of the argument specifies the min imum number of digits to appear If the value being converted can be represented in fewer digits than the specified minimum it is expanded with leading zeroes The default precision 1s 1 The result of converting a zero value with a precision of 0 15 no characters f The floating point number argument is printed in decimal notation in the style dddrddd where the number of digits after the radix character is equal to the precision specification If the precision is omitted from the argument six digits are outpu
30. click on an icon variable inside the variable window LLL Attention If dev_display should be used for exported Code C please note the description of disp obj due to the different semantics in Parameter gt o gt o o gt Object input object object array Hobject Image objects to be displayed Example SSS read image Image fabrik regiongrowing Image Regions 3 3 6 100 dev_clear_window dev_display Image dev_set_colored 12 dev set draw margin dev display Regions LLL Reato dev_display always returns 2 H MSG TRUE LLL Parallelization Information dev_display is local and processed completely exclusively without parallelization Alternatives disp obj disp_image disp region disp_xld See AlISo ooo ooo dev set color dev set colored dev set draw dev set line width Module 0 o System dev error Var ErrorVar Mode Define or undefine an error variable HDevelop 2003 08 01 137 dev error var defines an error variable 1 e a variable which contains the status of the last call of an operator ErrorVar will be H MSG TRUE 2 if no error had occured The parameter Mode specifies if the error variable should be used 1 or not 0 If an error variable is active it will be updated each an operator excetion is finished Thus a value is only valid until the next call of an opera
31. clip dev ix dev ix clip dev pm rot dey fir dev ix rim de Files af type HDevelop Cancel Open as read only Figure 2 3 The dialog window to open an HDevelop file In the topmost text field you may specify a directory which contains your HDevelop programs A combo box at the right hand side helps you browsing your directories To move one directory level up you press the button on the right hand side of this text field The next button creates a new folder to store HDevelop programs By pressing the last button you can activate or deactivate the option to see more details about your HDevelop programs i e the program size the program type the date when the most recent user update occurred and file attributes The middle text area displays all available HDevelop files to choose from By clicking the left mouse button on a file name you select it Double clicking a file name opens the file 1mmediately and displays it in the program window see chapter 2 4 Furthermore you may specify the file name in the text field below The combo box for file type has no effect because only HDevelop programs with the extension dev can be loaded If you want to open your file with a write protection choose the checkbox at the bottom of this dialog window To open your specified file you press the Open button This action deletes an already loaded HDevelop program and all created variables The same actions as
32. combo box Send determines the graphics window in which the result is displayed This mode is useful to interactively set a window of gray values that should be displayed with a large dynamic range If you want to select threshold parameters for a single image display the image in the active graphics window and open the histogram tool For optimum visualization of the segmentation results it is best to set the visualization color to a color different from black or white see Visualization gt Color below Now set Display to threshold and interactively drag the two vertical bars until you achieve the desired segmentation result The parameters of the threshold operation can now be read off the two vertical lines If you want to select threshold parameters for an image which is derived from another image but want to display the segmentation on the original image e g if you want to select thresholds for a gradient image two different possibilities exist First you can display the derived image open the histogram tool deselect Accept display the original image and then select the appropriate thresholds This way only one window is needed for the visualization For the second possibility you can display the derived image in one window activate another window or open a new window display the original image there activate the first window again open the histogram tool activate the second window again set Send to to active and select your
33. control real real integer string Value that has to be inserted Default Value 1 Typical Range of Values 0 lt Value lt 1000000 gt Index Control integer integer Index position for new value Default Value 0 Value Suggestions Index 0 1 2 3 4 5 6 Minimal Value Step 1 gt Result output control real array real integer string Result tuple with inserted values LLL Reto insert returns 2 H MSG TRUE if the evaluation of the expression yields no error o Parallelization Information insert is reentrant local and processed without parallelization Alternatives _ assign Module SSS Basic operators Stop program execution stop stops the program execution of HDevelop The PC is then placed at the program line behind stop The operator 1s equivalent the presing the stop button in the menu bar Attention stop is not available in C Example SSS read image Image fabrik regiongrowing Image Regions 3 3 6 100 Number Regions dev_update_window off for 1 1 to Number by 1 RegionSelected Regions li dev clear window dev display RegionSelected stop endfor LLL Reto stop always returns 2 H MSG TRUE Parallelization Information _ stop is reentrant local a
34. derived from the regions geometric moments The calculation 15 done by the operator eccentricity The input param eters are all regions of the variable Marks The computed values Anisometry Bulkiness and HALCON 6 0 4 1 INTRODUCING HDEVELOP StructureFactor are displayed as a list a tuple in HALCON terminology in the variable window Figure 1 5 shows the example session s result As you can see in figure 1 5 and 1 4 it 1s possible to combine the two successive calls of select shape into one call This reduces the length of the program and saves runtime 1 3 Additional Sources of Information Further information can be found in the following manuals Getting Started with HALCON An introduction to HALCON in general including how to install and configure HALCON HALCON C User s Manual How to use the HALCON library in your programs HALCON C User s Manual How to use the HALCON library in your C programs HALCON COM User s Manual How to use the HALCON library in your COM programs e g in Visual Basic Extension Package Programmer s Manual How to extend the HALCON system with your own operators Frame Grabber Integration Programmer s Manual A guide on how to integrate a new frame grabber in the HALCON system Note that in some cases you might define new operators using the Extension Package Interface instead of using the standard HALCON Frame Grabber Integration Interface in order to exploit specifi
35. dev close window dev clear window The operators dev open window dev close window are used to open and to close a graphics window respectively During opening the parameterization allows you to specify the window s size and position The operator dev clear window clears the active window s content and its history This corresponds to the usage of the button Clear in the graphics window Please note that dev open window dev close window are not supported for Visual Basic export because here one HWindowXCtrl is used e dev set window extents With this operator you can set the size and position of the active HDevelop graphics window e dev set window This operator activates the graphics window containing the given ID This ID 15 an output parameter of dev open window After the execution the output is redirected to this window This operator is not needed for exported code in C because here every window operation uses the ID as a parameter The operator has no effect for exported code in Visual Basic e dev_set_color dev_set_colored dev set color has the same effects as the menu item Visualization gt Color dev_set_colored is equal to the menu item Visualization gt Colored e dev_set_draw This operator has the same effects as Visualization gt Draw e dev_set_line_width For an explanation see item Visualization gt Line Width e dev_set_lut For an explanation see item Visualization gt Lut e dev set pa
36. dev_error_var Error 1 dev set check give error get mposition WindowHandle R C Button dev_error_var Error 0 dev set check give error if Error H MSG TRUE and Button 0 break endif endwhile stop The stop construct stops the program after the operator 15 executed The program be continued by pressing the Step or Run button exit The exit construct terminates the session of HDevelop 3 8 Limitations This section summarizes the restritions of the HDevelop language e Maximum number of objects per parameter 100000 e Maximum length of strings 1024 characters e Maximum length of a variable name 256 characters e Maximum length of a tuple 1000000 The general restrictions of the HALCON operators can be found in the manual Getting Started with HALCON HDevelop 2003 08 01 Chapter 4 Code Generation The idea of code generation 1s as follows After developing a program according to the given requirements it has to be translated into its final environment Here you often don t want to use HDevelop to save memory or disk space In addition the program should execute as fast as possible especially without the overhead of an interpreter Therefore the program i1s transfered into another programming language that be compiled and allows a faster execution In addition to this features of the new environment like special libraries or graphical user interface builder can thus be used HDev
37. draw is set to mode margin only Visualization gt Shape Here you specify the representation shape for regions Thus you are able to display not only the region s original shape but also its enclosing rectangle or its enclosing circle Visualization gt Lut This menu activates different look up tables which can be used to display gray images and color images in different intensities and colors In the case of a true color display the image has to be redisplayed due to the missing support of a look up table in the graphics hardware For color images only the gray look up tables can be used which change each channel separately with the same table Visualization gt Paint This menu defines the mode to display gray images For more information see the menu item Visualization gt Set Parameters Visualization gt Set Parameters By using this menu item a dialog called Visualization Parameters is opened which handles more complex parameter settings Select one setting with your left mouse button HDevelop 2003 08 01 2 3 MAIN WINDOW 33 Visualization Parameters Made 3D pict hidden Scale Eve height Eve distance Row o 150 E 150 Column Step o Colored 7 Figure 2 20 Settings of parameter paint and the window brings up the according parameter box Each box contains different buttons text fields or check boxes to modify parameters Each box has an Update button If this button 1s pressed ever
38. e Experienced Programmer This option was introduced to facilitate the development of HDevelop by MVTec HALCON 6 0 4 18 CHAPTER 2 GRAPHICAL USER INTERFACE It is not suitable for the normal use of HDevelop e Syntax Using a combo box you may specify the output mode inside the program window Depending on the mode each HALCON or HDevelop operator is shown in a spe cific syntax like Hal conDevelop default syntax or C e Digits With this checkbox you can control how many digits of floating point numbers are displayed in the Variable window The selected number is the total number of digits displayed Therefore if you have selected four digits the result of the following assignment assign 4xatan 1 is displayed as 3 142 Note that the changes do not take effect until the values of the variables are actually updated by running the program 1 the the variables are not redisplayed automatically Before continuing your HDevelop session you have to close the option window by press ing the button Ok or by cancelling the action If Insert Interactions is activated the changes applied inside the dialog will result 1n automatic operator insertion after pressing OK HDevelop saves the current selections for the options Show Variable Usage Show Low Level Errors Automatic Program Save Experienced Programmer Syntax and Digits and restores them upon start Under Windows the options are stored
39. graphics window are identical to those when starting HDevelop The first four parameters of the menu File gt Options are reset to their initial state The update of windows variables PC and time is on A security check prevents you from deleting the current program accidentally if the pro gram has not been saved A dialog box appears and waits for your response whether you really want to delete the HDevelop program Your confirmation only deletes the HDe velop program you are working on and not the file associated with it Now you are ready to input a new HDevelop program If you give a negative response nothing will happen You have to press one of the two buttons before you are able to continue interacting with HDevelop File gt Open keyboard shortcut lt Ctrl gt 0 By clicking on the menu item File gt Open you can load an existing HDe velop program Alternatively you can select File gt Insert to insert a file HDevelop 2003 08 01 2 3 MAIN WINDOW 13 into the current program at the line in which the insert cursor 15 located In both cases a dialog window pops up and waits for your input see figure 2 3 It 1s called Load HDevelop Program File Please note that text Visual Basic C or versions of a file cannot be loaded Load HDevelop Program File HE Look in E Fa i mL 2 rime dev a ball dev ix hales dev a ball2 dev hull dev board dev e Ic dev board dev pattern dev
40. i 2 1 to Number by 1 SingleSelected CompactRegians i area center SingleSelected Area Row Column dev set color areen if amp rea 500 and amp rea 500007 dev set color red Eyes SingleSelected Eyes endif endfor dev display mage dev set color red Figure 2 35 Program example with the PC the arrow pointing to the right insertion cursor and a break point BP nothing is selected no action is performed In contrast when an action is called via the context menu and no line is selected in the program the action 1s performed for the line onto which you clicked with the right mouse button The big text area at the right side of the program window contains the program code of the HDevelop program Here the user has the possibility to obtain information about the inserted operators A program is built up such that every line contains exactly one operator with its parameters or an assignment exception are the condition constructs if and ifelse respec tively and the loop constructs while and for They contain two in case of ifelse even three program lines which enclose the body Every line starts with an operator name which 15 in dented if necessary to highlight the structure created by the above mentioned control structures After the operator name the parameters are displayed in parentheses Parameters are separated by commas The program window 15 used to visualize program lines but not to
41. iconic variables Clicking on a variable will select it Similar to iconic variables all program lines that use this variable are then marked with a black rectangle on the left Double clicking a control variable opens a window that displays all its values In most cases this will be a dialog containing a scrolled list This is helpful if you have variables with a large number of values that you want to inspect In the case of a frame grabber handle a dialog representing basic frame grabber parameters is opened see figure 2 39 Here you find the size name device port and other features of the frame grabber The toggle button Online allows to grab images continuously and to display them in the active graphics window If an error occurs during grabbing it is displayed in the status bar of the dialog At most one of these frame grabber dialogs can be opened at the same time 2 Graphics Window This window displays iconic data It has the following properties You have to keep in mind that a floating point number without significant fractional part is represented as integer e g 1 0 is represented as 1 HDevelop 2003 08 01 2 7 GRAPHICS WINDOW 57 FGHandle Port Device Trigger Online Figure 2 39 Variable inspection for frame grabber handles The user may open several graphics windows The active graphics window is shown by the green dot in the Active button Pressing the Clear button clears the gra
42. information see the menu Visualization gt Set Parameters Zoom Visualization gt Colored This is an easy way to display multiple regions or XLDs Each region is displayed in a different color where the number of different colors 15 specified the submenu You can choose between 3 6 and 12 colors If all regions are displayed with one color you have to use the operator connection beforehand You can check this also with the operator count obj Visualization gt Color This item enables color specification to display segmentation results regions and XLD text vurite string and general line drawings e g 3D plots contour lines and bar charts The number of colors which are available in the submenu depends on the graph ics display 1 e the number of bits used for displaying After selecting a color the pre viously displayed region or XLD object will be redisplayed with this color The default color is white Visualization gt Draw Here you can select a visualization mode to display region data It can either be filled item 111 or the borders are displayed only item margin The border line thickness of the displayed regions 15 specified using the menu item Line Width see figure 2 21 Visualization gt Line Width Here you determine the line width for painting XLDs borders of regions or other types of lines You can select between a wide range of widths using the submenu This parameter is effective if dev set
43. input region will be ConnectedRegionsDynThresh 2 the output variable name remains unchanged HDevelop 2003 08 01 1 2 EXAMPLE SESSION 7 3 values area and and remain unchanged 4 The region s minimum size should be 150 Min and 5 the region s maximum size should not exceed 500 Max 6 The mean intensity should be between 120 and 255 In figure 1 4 the extended program can be seen Now you have to extract from the remaining regions the regions that match the objects to look for As you can see the regions representing the marks have a circular shape con trary to all others This is expressed by a compactness value close to 1 For this you have to choose the operator select shape once again Use the combo box of the parameter text field Features to specify the value compactness As a range of values you may spec ify the parameters Min and Max with the values 1 0 and 1 4 respectively The output re gions of the first call SelectedRegions are the input regions for the second call of opera tor select shape The output parameter s name SelectedRegions is replaced by the name selectedRegionsDynThresh The last step to make the application stable is to add a selection of regions based on gray value features This is done by using the operator select_gray In this case the mean gray value is used to discriminate the objects File Edit Execute Visualization Operators Suggestions Window Help Hell 5 ase
44. is texture laws You have to specify the filter size and type Both attributes determine the frequency properties In this program the filter e1 with mask size 5 x 5 15 used It performs a derivation in vertical direction and a smoothing in horizontal direction Thus structures in verti cal direction are intensified You cannot directly use the computed result of texture laws see HDevelop 2003 08 01 5 2 CAPILLARY VESSEL 99 Figure 5 3 vessel left and texture transformation right figure 5 3 right because it 1s too speckled Therefore you must generalize the texture image by a mean filter nean image From this you obtain the so called texture energy figure left Figure 5 4 Capillary vessel texture energy left and segmentation right The filter mask is chosen very large within this program The mask size for the horizontal direction 1s 211 and 61 for the vertical direction The asymmetry is used because the vessel 1s nested in horizontal direction From this you obtain an image with an upper and lower part that is brighter than that in the middle read image Image vessel texture laws Image Texture el 5 5 mean image Texture Energy 211 61 bin threshold Energy Vessel To separate these areas you just have to find the appropriate threshold In this case we have only two types of textures the threshold can be found automatically This 1s done by the operator bin thre
45. leads to a runtime error Variable x not instantiated HDevelop provides a pre defined variable named single underscore You can use this vari able for output control parameters whose value you are not interested in Please note that it is not allowed to use this variable for HDevelop specific operators chapters Control and Develop see the appendix for a complete list HDevelop 2003 08 01 3 4 OPERATIONS ON ICONIC OBJECTS 65 Instantiated variables contain tuples of values Depending on the kind of the variable the data items are either iconic objects or control data The length of the tuple is determined dynamically by the performed operation A variable can get new values any number of times but once a value has been assigned the variable will always keep beeing instantiated unless you select the menu item Execute Reset Program The content of the variable 15 deleted before the variable 15 assigned with new values The concept of different kinds of variables allows a first coarse typification of variables control or iconic data whereas the actual type of the data e g real integer string etc is undefined until the variable gets assigned with a concrete value Therefore it is possible that the type of a new data item differs from that of the old 3 4 Operations on Iconic Objects Iconic objects are exclusively processed by HALCON operators HALCON operators work on tuples of iconic objects which are represen
46. may clean this region using a simple opening The radius here 15 5 should correspond to the minimum size of one ball In both images you see an erroneous segmentation that was created by a rectangular dark region This can be suppressed by a shape segmentation Since in practice a bonding detection would be performed only close to the anticipated positions of bonding balls Figure 5 10 shows the results of the whole segmentation Balls are shown in white color Every radius of a ball you can find in the tuple variable Radius The number of balls within the example you can get with the absolute value of Radius HALCON 6 0 4 106 CHAPTER 5 PROGRAM EXAMPLES Figure 5 10 Detected bonding positions NumBalls Radius Diameter 2 Radius MeanDiameter sum Diameter NumBalls MinDiameter min Diameter Diameter MeanDiameter and MinDiameter are some examples for calculations possible with HDevelop 5 6 Calibration Board File name calib dev This example works with the image of a calibration board It 1s used to specify the internal parameters of a CCD camera Therefore you have to extract the circles on the board see left side of figure 5 11 This example describes an interesting operator It is called gray inside and is a so called fuzzy operator In this case fuzzy means that the value of each pixel 1s not interpreted as gray value but as the affiliation to a certain class The bigger the number max 1 the stronger
47. modify them You cannot change a program by moditying the text directly Editing the program text in HDevelop is done in the operator window this will be described below The main reason for this principle is the advantage of providing sophisticated help Thus you are able to avoid many input errors To edit a line of a program you chose an operator in the program window by clicking the left mouse button twice In case of conditions and loops it is unimportant which lines e g for or endfor are selected In any case the head with its parameters is selected You may edit only one operator at a time Besides editing the parameters of a single operator single and multiple lines can be deleted cut or pasted one step using simple mouse functions To use this feature one has to select one or more lines using the mouse e The selection of one line is done by clicking on it Previously activated lines will then become deactivated e To activate more than one line you have to press the Ctr1 key while clicking on the HALCON 6 0 4 50 CHAPTER 2 GRAPHICAL USER INTERFACE line If the line is already activated it will become deactivated while the state of all other lines remains unchanged e The Shift key 15 used to activate a sequence of lines using one mouse click lines between the most recent activation and the new one will become activated After the selection of lines the edit function can be activated by either usi
48. multichannel image image arrays and a as the definition domain All image arrays have the same dimension but they be of different pixel types The size of the region is smaller or equal than the size of the image arrays The region determines all image points that should be processed Iconic object Generic implementation of data in HALCON integer is the type name for integer numbers Integers are implemented using the C type long 4 or 8 byte Operator data base The operator data base contains information about the HALCON opera tors They are loaded at runtime from the binary files in 4HALCONROOT help Program window In HDevelop the program window contains the program It is used to edit copy delete and paste lines and to run or debug the program 159 160 APPENDIX C GLOSSARY Operator window In the operator window of HDevelop the parameters of the selected opera tors can be entered or modified Real is the type name for floating point numbers They are implemented using the C type double 8 bytes Region A region is a set of image points without gray values A region can be imagined as a binary image mask Regions are implemented using run length encoding region size is not limited to the image size see also set_system clip_region true false inthe HALCON reference manual String is the type name for character strings A string starts and ends with a singl
49. of the gray histogram inspection window You can display an image or region by double clicking on it in the variable window or you can select a region or an image which is already displayed by single clicking it If you display or click into an image the gray value features of the entire image will be calculated If you click into a region that 1s not underlaid with an image only the shape features of this region will be displayed If you click into a region that is underlaid with an image or into a region that has gray value information e g from reduce domain or add channels both the shape and gray value features of that region will be displayed Finally if you have overlaid an image with a region but click into a part of the image that is outside the region only the gray value features of the entire image will be calculated Analogously to the gray histogram inspection window the gray value features of a multi channel image are calculated from the first channel by default You can use the combo box Channel to select the desired channel The shape features on the left side of the region inspection window are grouped into seven categories which correspond roughly to individual HALCON shape feature operators The topmost of the displays shows the most basic region features namely the area and center of gravity of the region see area center in the Reference Manual and the width and height of the smallest axis parallel rectangle of the re
50. operator as assign sin x cos y w which is displayed in the program window as u sin x cos y Parameter S o gt Input input control real array real integer string New value Default Value 1 gt Result output control real array real integer string Variable that has to be changed 123 124 APPENDIX A CONTROL Example _ 1 1 1 0 3 4 5 6 7 8 9 Val sin 1 2 cos 1 2 Tuplei 1 2 Tuple2 for i 0 to 10 by 1 Tuple2 i i endfor Result assign returns 2 MSG TRUD if the evaluation of the expression yields no error LLL Parallelization Information gt assign is reentrant local and processed without parallelization Alternatives _ insert Module SSS Basic operators break Terminate loop execution break terminates the smallest enclosing for or while loop Program execution is continued at the next program line after the end of the loop or at the next line after the break statement in case no enclosing loop exists Example SS read_image Image monkey threshold Image Region 160 180 connection Region Regions Number Regions AllRegionsValid 1 check if for all regions area lt 30 for 1 to Number by 1 ObjectSelected 1 area_center ObjectSelected Area Row Column if Area gt 30 AllRegionsVali
51. printed b Similar to the s conversion specifier except that the string can contain backslash escape sequences which are then converted to the characters they represent In no case does a nonexistent or insufficient field width cause truncation of a field if the result of a conversion is wider than the field width the field is simply expanded to contain the conversion result Examples for the string conversion can be found in the program string dev The string concatenation can be applied in combination with strings or all numerical types if necessary the operands are first transformed into strings according to their standard repre sentation At least one of the operands has to be already a string so that the operator can act as a string concatenator In the following example a filename e g Name5 tiff is gener ated For this purpose two string constants Name and tiff and an integer value the loop index i are concatenated fori 1 OM b 1 read image Bild Name i tiff endfor str r chr s1 s2 returns the index of the first last as a tuple occurrence of one character in 52 in string s1 or 1 if none of the characters occurs in the string str r str si1 s2 returns the index of the first last occurrence of string s2 in string 51 or 1 1f s2 does not occur in the string strlen s returns the number of characters s s i returns the character at index position i in s The index r
52. program When the stop button is pressed the execution is stopped at the active HALCON operator Other features of the HDevelop interpreter are the possibility to display iconic variables by simply double clicking on them and the facility to set the parameters which control the display to the appropriate values In addition to this it is possible to insert commands into the program text no matter whether this makes any sense or not Please note that interactions during the execution of HALCON application can only be used in a sensible way if the single operators have short runtimes because HDevelop can only react within the gaps that 1s between the calls to the HALCON library Please note that neither the PC nor the BP can be set during the execution of the HALCON application 6 3 Online Help Online documentation is available in PDF and partly in HTML format In a UNIX environment the full documentation is available in postscript format as well To display the HTML files containing information on HALCON operators you need a browser It is not provided in the HALCON distribution but nevertheless used by HDevelop Such a tool may already be installed on your computer Otherwise you may obtain it for free e g via the Internet One browser that 1s suitable for displaying HTML files is Netscape Navigator It is a WWW browser that is able to display HTML documents Since the reference manual for HALCON operators 15 also stored in HTML f
53. set colored NumColors Set multiple output colors dev set colored allows the user to display a tuple of regions in different colors NumColors defines the number of colors that are used Valid values for NumColors can be queried with query colored HDevelop 2003 08 01 145 LLL Attention 0000000000000 If dev set colored should be used for exported Code C please note the description of set colored due to the different semantics in Parameter gt NumColors input control o d dbi integer integer Number of output colors Default Value 6 Value List NumColors c 3 6 12 Example SSS read_image Image monkey threshold Image Region 128 255 dev_set_colored 6 connection Region Regions o Redt o dev set colored always returns 2 H MSG TRUE Parallelization Information dev set colored is local and processed completely exclusively without parallelization Possible Predecessor Functions 7H dev open window Possible Successor Functions SSS dev display Alternatives dev set color See ASQ 44444444 o set line width set colored Module _ System dev set draw DrawMode Detine the region fill mode dev set draw defines the region fill mode If DrawMode 15 set to fill output regions are filled if set to margin only contours are displayed It is used by
54. systems HALCON offers an algorithm that computes an interpolated full image from such a video image The name of the appropriate operator 1s fill interlace see the HALCON Reference Manual The next step 15 to specify this name in the operator window s operator name field If it is indicated completely HDevelop shows the operator immediately in the operator window Now you have to specify the variable name of your image For this you put in the name Christof in the parameter field ImageCamera To do so you have two possibilities e Direct input via the keyboard e Using the combo box that is associated with the parameter text field you may choose an appropriate name The system s suggestion for the interpolated image is ImageFilled By clicking button OK you insert this operator into the program and execute it immediately The computed image is displayed automatically in the active graphics window HDevelop marks dev File Edit Execute Visualization Operators Suggestions Window Help image pointer1 Christof Pointer Type Width Height Width Height VVindow ID v image object v image object Variable Watch Iconic Variables v extent x integer 24 extent y integer Help mean image 0 06s Figure 1 2 With the help of the opened combo box you may specify a reasonable filter size for the operator mean image In the next step you try to separate bright from dark pixe
55. thresholds Although in this case it is not necessary to deselect Accept it is advantageous to do so because this prevents the histogram from being updated if you click into a graphics window accidentaly Visualization gt Region Info This menu item opens a tool for the convenient inspection of shape and gray value fea tures of individual regions It can for instance be used to determine thresholds for op erators that select regions based on these features e g select shape or select gray Figure 2 18 shows the layout of the region feature inspection window HDevelop 2003 08 01 2 3 MAIN WINDOW 29 Region Features Miel Shape Features Gray value Features area 1881n channel center rc 301 14 205 79 intensity 88 1483 height 253 set 3 4 maximum 103 shape elipse 148 454 53 1283 angle degrees angle 32 5125 E contour length 1535 71 On Id le dir mean compactness 9 9774 convexity 1 correlation 0 650979 entropy 3 93026 Ed 3541085 homogeneity 0 7 r997 bulkiness 1 46616 contrast 1 58384 structure 2 68131 O A connected 1 holes 23 07081 005 0 0425406 Figure 2 18 Online region feature inspection The strategy to determine the data from which to compute the features is very similar to that
56. value Please note that it is not necessary that the loop index has to be equal to the termination value before terminating the loop The loop index is set to the termination value when the loop is being left Please note that the expressions for start and termination value are evaluated only once when entering the loop A modification of a variable that appears within these expressions has no influence on the termination of the loop The same applies to the modifications of the loop index It also has no influence on the termination The loop value is assigned to the correct value each time the for operator is executed If the for loop is left too early e g 1f you press Stop and set the PC and the loop is entered again the expressions will be evaluated as if the loop were entered for the first time a Attention SSS For exported C please note the different semantics of the for loop Parameter o o o p Start put Conio 59294252 992954 number integer real Start value for the loop variable Default Value 1 gt End _ number integer real End value for the loop variable Default Value 5 HDevelop 2003 08 01 127 b Step OnDUCCOBE DD number integer real Increment value for the loop variable Default Value 1 gt Variable output control number integer re
57. variable that already has a value this value is deleted during execution before overwriting it with new results It 1s possible to specify a variable both in an input and output position Control input parameters These parameters normally possess a default value In particular this 1s to support novices selecting an appropriate value As an alternative you may use the text field s button to open a combo box and to select a value suggestion In addition this combo box contains a list of variables that contain values of the required type A restriction of proposed variables is especially used for parameters that contain data like file frame grabber or ocr handles Input control parameters may contain constants variables and expressions Common types are integer numbers integer floating point numbers real boolean values true and false and character strings string You are able to use multiple values of these types at once This 15 done by using the tuple type This is an enumeration of values separated by commas and enclosed in brackets Furthermore you may build up expressions with these values The possibilities of using tuples are very extensive You may use expressions in HDevelop similar to the use of expressions in C or in Pascal You will find a more detailed description in section 3 5 Control output parameters These parameters are handled in the same way as output object parameters Their de faults are variables nam
58. with which the condition becomes false for the first time In HDevelop it contains the end value which was calculated when the loop was entered HDevelop 2003 08 01 4 4 GENERAL ASPECTS OF CODE GENERATION 93 Looking at the mentioned points we recommend to do the programming according to the fol lowing rules 1 Don t modify the loop variable or the step value inside the loop If you need this behavior use the while loop 2 Don t use the loop variable after the loop 4 4 3 System Parameters You should know that HDevelop performs some changes of system parameters of HALCON by calling the operator set system see reference manual This might cause the exported program not to produce identical output If such a problem arises you may query the system parameters by means of get system in HDevelop after or while running the original HDevelop version of the program Depending to the problem you can now modify relevant parameters by explicitly calling the operator set system in the exported program 4 4 4 Graphics Windows The graphics windows of HDevelop and the basic windows of HALCON libraries class HWindow Visual Basic class HWindowXCtrl C addressed via handles have different functionality e Multiple windows If you use the operator dev open windov to open multiple graphics windows in HDe velop these calls will be converted into corresponding calls of open window only for and C programs In the export
59. 1 March 1998 The chapters About this Manual Graphical User Interface and Code Generation for C have been revised The menu Options has been extended A visualization of a frame grabber handle with automatic online grabbing double click inside Variable Window has been introduced Online inspection of gray values and basic image features has been introduced in the menu Visualization gt Image Info e Edition 2 November 1997 The menu Visualization gt Set Parameters has been extended and the descrip tion has been revised Contents 1 Introducing HDevelop 3 1 1 Facts about HDevelop ls 1 2 Example Session 1 3 Additional Sources of Information Graphical User Interface 2 1 Interacting with HDevelop 2 Mouse Handing 2 Man Window se sss scese srest ow ERE deum de deo de ecd deo de Re 4 2 Ee ae eee Be oo s PC 52 uowoxu aam X AIEO eee ee Bee Bw Ww eel S mox P 2 3 4 Window 12 24 Program Window 2 5 Operator Window 2 5 1 Operator Name 2 5 2 Parameter Display 2 5 3 Control 2 6 Variable Window 2 6 1 Area for Iconic D
60. 10 dev set colored 6 connection Dark ConnectedRegions fill up ConnectedRegions RegionFillUp select shape RegionFillUp StampCandidates area 10000 200000 select shape StampCandidates Stamps compactness 1 5 smallest rectanglei Stamps Row1 Columni Row2 Column2 dev display Catalog dev set draw margin dev set line width 3 disp 1 1 WindowID Rowi Columni Row2 Column2 Figure 5 2 shows the segmentation result Due to the unknown operators and unfamiliar syntax this program appears unclear to the user at first glance But if you look closer at the operators you will notice the direct relation to the description above threshold selects all image pixels darker than the paper connection merges all selected pixels touching each other to connected regions select shape selects the regions with areas attribute area inside a specified interval smallest rectanglei computes each region s coordinates row column of the enclosing rectangle Once the user 1s familiar with the single operators and their syntax the transformation becomes easy In particular it 1s not important to the program whether an image or a set of regions 1s processed You can handle them both in the same way In addition memory management of internal data structuresis transparent to the user Thus you do not need to bother about memory management and you can concentrate on the image
61. 7 You may look for a detailed description of each operator in the HALCON reference manual The menu has a cascade structure according to the chapter structure of the HALCON reference manual As this menu has to be built up after opening the program window it might take some time until it is available During the build up time the menu is grayed out Selecting a chapter of the menu opens a pulldown menu with the corresponding subchapters or operators respectively This operator hierarchy is especially useful for novices because it offers all operators sorted by thematic aspects This might be interesting for an experienced user too if he wants to compare e g different smoothing filters because they reside the same sub chapter To get additional information a short description of an operator while activating its name in the menu 15 displayed the status bar see figure 2 27 Note that some operators are visible in the menus but cannot be selected e g open window in Operators gt Graphics gt Window orreset obj db in Operators gt System gt Database In the case of most of these operators you should use the cor Operators of the menus Control and Develop are special operators of HDevelop Thus you will not find them in the reference manuals HALCON 6 0 4 42 CHAPTER 2 GRAPHICAL USER INTERFACE HDevelop ball dev File Edit Execute Visualization Suggestions Window Help Dig x Control alke
62. APPENDIX A CONTROL exit returns o k to the calling environment of HDevelop operating system LLL Parallelization Information _ ________ __ __ exit is reentrant local and processed without parallelization See Also 2 stop Module SS Basic operators for Start End Step Variable Execute the body for a fixed number The for loop is controlled by a start and termination value and an incrementation value that determines the number of loop steps These values may also be expressions which are evaluated immediately before the loop is entered The expressions may be of type integer or of type real If all input values are of type integer the loop variable will also be of type integer In all other cases the loop variable will be of type real If the start value is less or equal to the termination value the loop index is assigned with the starting value and the body of the loop is entered If the increment is less than zero the loop is entered if the start value is larger or equal to the end value Each time the body is executed the loop index is incremented by the incrementation value If the loop index 15 equal to the termination value the body of the loop 15 performed for the last time If the loop index is larger than the termination value the body will not be excecuted any longer For negative increment values the loop is terminated if the loop index is less than the termination
63. HALCON Version 6 0 4 MT MVTec Software GmbH HDevelop User s Manual HDevelop the interactive developing environment of HALCON Version 6 0 4 rights reserved No part of this publication may be reproduced stored in a retrieval system or transmitted in any form or by any means electronic mechanical photocopying recording or otherwise without prior written permission of the publisher Edition 1 July 1997 Edition 2 November 1997 Edition 3 March 1998 HALCON 5 1 Edition 4 April 1999 HALCON 5 2 Edition 5 October 2000 HALCON 6 0 Edition 5a August 2002 HALCON 6 0 3 Edition 5b August 2003 HALCON 6 0 4 EC Copyright 1997 2003 by MVTec Software GmbH M nchen Germany esee Microsoft Windows Windows NT Windows 2000 Windows XP and Visual Basic are either trademarks or registered trademarks of Microsoft Corporation other nationally and internationally recognized trademarks and tradenames are hereby rec ognized More information about HALCON can be found at http www mvtec com halcon About This Manual This manual is a guide to HDevelop the graphical user interface for HALCON HDevelop facilitates rapid prototyping by offering a highly interactive programming environment for de signing and testing image analysis programs Together with the HALCON library it is a so phisticated image analysis package suitable for product development research and education HALCON provi
64. HDevelop 2003 08 01 5 8 CELL WALLS LLLA LA LLLLAT T LLITID MALULLLLLLL ILL ALLL LLLLLLTITITITTTTT FTTTIITITTTTH LIFILIT 000007 LIUFPTM ee 211 HLIIITIITTI Tr 121 47 Ld T EX LI AAALLLLLLLLLLILLLILLII LILLLLILLLILLLLLL 8 a Ld ou ELE NM LJ dti aa rM MARLLALLLIZRLILZIITILITTTTTIIDETT TOUIT CLLR rt PL ITI li CCT AMILT MAII 888446 mere TTT TT 1 1 Sth PLL T Crt tre 8 Ng mr E FETT E TIETEET TTET T miT LI TII LI LLLI T BHO itii TT LEE fT HTIITITTIL ToT iii TTT 4i TE RA T LELEII A LAA TELTTA Reet 111 111 TETEE fT 111 SENE TILIILAIEIIM 2 TI
65. ON are declared locally in the procedure action Iconic variables belong to the class Hobject and all other variables belong to HTup1e 4 1 1 2 Compiling and Linking in Windows NT 2000 XP Environments The next step 15 to compile and link this new program In the Windows environment Visual 15 used for the compiling and linking Example projects can be found in the directory AHALCONROOT examples Ncpp M i586 nt4 If you want to use Parallel HALCON you have to include the libraries 1 11 411 and 1 115 411 instead of halcon lib dl1l and halconcpp lib d1ll in your project see the HALCON C User s Manual for more details 4 1 1 3 Compiling and Linking in UNIX Environments To compile and link the new program called e g test cpp in the case of UNIX you can use the example makefile which can be found in the directory HALCONROOT examples cpp by calling make TEST PROG test Alternatively you can set the variable TEST PROG in makef ile to test and then just type make You can link the program to the Parallel HALCON libraries by calling make parallel TEST PROG test just type make parallel if you set the variable TEST PROG as described above For more details see the HALCON C User s Manual 4 1 2 Optimization Optimization might be necessary for variables of class HTuple This kind of optimization can either be done in HDevelop or in the generated C code In most cas
66. RFACE HDevelop 2 dev B x File Edit Execute Visualization Operators Suggestions Window Help Djela eel AEN pel gt Graphics Window Find Operator Find Operator dev set Find Backwards Edit stop Find Mark All Clear Cancel dev display Clip dew set color green dev display Selected orientation region Selected Phi area center Selected Area Rowe Column dey line width 3 dev set draw margin Length 80 far i Oto Phi 1 by 1 dew set color blue disp arrowe Rove i Calumn i Ravv i Leneath sin Phi i celumn i z Lenath cost dev set color lorange set tpozition Column wvrite string deg Philiji ded Program bin threshold Clip connection Dark select shape Sina dev set drawvw fill dev colored 1 dev display Select Figure 2 10 Searching for an operator unchanged Edit gt Copy keyboard shortcut Ctrl C By clicking Copy you store the selected program lines directly in an internal buffer Edit gt Paste keyboard shortcut lt Ctrl gt V To insert this buffer in the HDevelop program you place your mouse pointer at the desired position and then click item Edit gt Paste Edit gt Delete The menu item Edit Delete deletes all selected program lines without storing them in an internal buffer The only way to get the deleted line
67. Set Parameters The dialog is used to configure the modes to display data like images regions or polygons LLL Attention 0000000000000 This operator is not supported for exported code Example SSS read image Image fabrik threshold Image Region 128 255 dev par HDevelop 2003 08 01 139 Result dev_map_par always returns 2 H_ MSG_TRUE LLL Parallelization Information _ dev_map_par 15 local and processed completely exclusively without parallelization Possible Successor Functions dev unmap par Module Basic operators dev map prog Make the main window of HDevelop visible dev map prog is used to map the main window of HDevelop after it has been unmapped by dev unmap prog LLL Attention 0000000000000 This operator is not supported for exported code Depending on the operating system or the window manager the execution of dev map prog will result only in a visible icon of the window In this case it has to be opened by the user with mouse interaction SSS dev map prog always returns 2 MSG TRUE ao Parallelization Information _ dev prog is local and processed completely exclusively without parallelization Possible Predecessor Functions 2 dev unmap prog Possible Successor Functions o 1 dev unmap prog See Also dev map par dev_map_var Module SSS
68. T Tilly yt TUR TT TTCL L vid TOY LLL Au GEL T Figure 5 15 Microscope image of wooden cells 111 number of pixels belonging to a cell wall Area is determined by area center This value 15 transformed to percent for the output X 20 read image WoodCellsi woodcell threshold WoodCellsi CellBorder 0 120 get image pointer1 4 1151 Pointer Type Width Height open file wood cells dat output FileHandle for 1 5 7 07150 dt XA clip region CellBorder Part 0 i Height 1 1 area center Part Area Row Col fwrite string FileHandle i Area 100 0 X Height fnew line FileHandle endfor close file FileHandle Figure 5 16 shows the measurement result To allow further processing of the data such as for plotting using gnuplot as in figure 5 16 it has to be written to a file Therefore a text file is opened first open file Now you can write to this file by using fwrite string and fnew line Note the formatting of output when using fwrite string The output text starts with the loop variable that is followed by a space HALCON 6 0 4 112 CHAPTER 5 PROGRAM EXAMPLES wood cells dat Anzahl 0 100 200 300 400 500 600 700 800 900 Position Figure 5 16 Cell wall proportion in growth direction in percent character Thus the number is transformed
69. Window Figure 2 40 HDevelop s graphics window history and are not redrawn Only the object classes image region and XLD that are displayed with the HDevelop operator or by double clicking on an icon are part of the history You may change the size of the graphics window interactively by gripping the window border with the mouse Then you can resize the window by dragging the mouse pointer After this size modification the window content is redisplayed Now you see the same part of the window with changed zoom The menu area of the graphics window has an additional function If the mouse cursor is in this area the look up table of the window is reactivated This is necessary if other programs use their own look up table Thus if there is a strange graphics window presentation you may load the proper look up table by placing the mouse near the buttons If you want to specify display parameters for a window you may select the menu item Visualization in the menu bar Here you can set the appropriate parameters by clicking the desired item see section The parameters you have set in this way are used for all windows The effects of the new parameters will be applied direcly to the ast object of the window history and alter its parameters only HDevelop 2003 08 01 2 7 GRAPHICS WINDOW 59 For further information on parameter effects please refer to the appropriate HALCON operators in the reference manual HALCON 6 0
70. able 3 9 shows an overview of the available simple arithmetic operations operations are left associative except the right associative unary minus operator The evalu ation usually is done from left to right However parentheses can change the order of evaluation and some operators have a higher precedence than others see chapter 3 5 14 division multiplication addition and concatenation of strings subtraction negation Table 3 9 Arithmetic operations The arithmetic operations in HDevelop match the usual definitions Expressions can have any number of parentheses The division operator a a be applied to integer as well as to real The result is of type real if at least one of the operands is of type real If both operands are of type integer the division 15 an integer division The remaining arithmetic operators multiplication addition subtraction and negation can be applied to either integer or real numbers If at least one operand is of type real the result will be a real number as well In the following example 4 3 WEE we de EU UE V1 is set to 1 V2 to 1 3333333 and to 2 0 Simple examples can be found in the program arithmetic dev 3 5 6 Bit Operations This section describes the operators for bit processing of numbers The operands have to be integers The result of 18h i1 i2 is a bitwise left shift of 11 that is applied i2 times If there is no overflow this is equivalent
71. ach parameter 15 separated from its neighbours by a comma read image Image area center Region Area Row Column mean image Image Mean 11 11 61 62 CHAPTER 3 LANGUAGE In the above example the operator read image has one output parameter for iconic objects Image and one input control parameter filename area center accepts regions as in put iconic and three control parameters as output Area Row Column The filter operator mean image has one iconic parameter as input and one as output Its two input control param eters specify the size of the filter mask Input control parameters can either be variables constants or even complex expressions An ex pression is evaluated before it is passed to a parameter that receives the result of the evaluation Since iconic objects always are represented by variables all iconic parameters only accept vari ables Control output parameters must always contain variables too as they store the results of an operator evaluation 3 2 Control Types and Constants non iconic data is represented by so called control data numerical string in HDevelop The name is derived from their respective functions within HALCON operators where they control the behaviour the effect of 1mage processing operators e g thresholds for a segmentation operator Control parameters in HDevelop may contain arithmetic or logical operations A control data item can be of one of the follow
72. active or deactivate more than one line using single mouse clicks Clicking at an item for the second time after a short pause will deactivate it e g lines in the program window or variables in the variable window Similarly the activation passes to another item by clicking at it Very important is the possibility to set the program counter PC at the left side of the pro eram window see 2 4 By combining a mouse click with special keys you can activate further functions Clicking the left mouse button once while pressing the Shift key This places the insert cursor in the program window see 2 4 Clicking the left mouse button once while pressing the Ctr1 key A break point will bet set in the program window By performing this action once more the break point will disappear see 2 4 e Clicking the left mouse button twice results in an action that will be performed with the activated item In the program window the operator corresponding to the program line together with its parameters is displayed directly in the operator window and can then be modified Iconic and control variables are displayed in the graphics window or in specific dialogs 2 3 Main Window The main window contains the other four HDevelop windows and possibly additional graphics windows The main window can handle HDevelop programs manipulate the graphics output offer all HALCON and HDevelop operators give suggestions and help on choosi
73. ags gt lt field width gt lt precision gt lt conversion characters So conversion might look like 1332 4554 gt 6e flags Zero or more flags in any order which modify the meaning of the conversion specifi cation Flags may consist of the following characters The result of the conversion is left justified within the field HDevelop 2003 08 01 3 5 EXPRESSIONS FOR INPUT CONTROL PARAMETERS 73 The result of a signed conversion always begins with a sign or lt space gt If the first character of a signed conversion is not a sign a space character 1s prefixed to the result This means that if the space flag and flag both appear the space flag 1s ignored The value is to be converted to an alternate form For d and s conversions this flag has no effect For o conversion see below it increases the precision to force the first digit of the result to be a zero For x or X conversion see below a non zero result has Ox or OX prefixed to it For e E f g and G conversions the result always contains a radix character even if no digits follow the radix character For g and G conversions trailing zeros are not removed from the result contrary to usual behavior field width optional string of decimal digits to specify a minimum field width For an output field if the converted value has fewer characters than the field width it 1s padded on the left or right if the left adjustment flag has
74. al Loop variable Example S dev update window off close window dev open window 0 0 728 512 black WindowID read image Bond die3 dev display Bond stop threshold Bond Bright 100 255 shape trans Bright Die rectangle2 dev set color green dev set line width 3 dev set draw margin dev display Die stop reduce domain Bond Die DieGrey threshold DieGrey Wires O 50 fill up shape Wires WiresFilled 1 100 dev display Bond dev set draw 73111 dev set color red dev display WiresFilled stop opening circle WiresFilled Balls 15 5 dev set color green dev display Balls Stop connection Balls SingleBalls select shape SingleBalls IntermediateBalls circularity and 0 85 1 0 sort region IntermediateBalls FinalBalls first true column dev display Bond dev set colored 12 dev display FinalBalls stop smallest_circle FinalBalls Row Column Radius NumBalls Radius Diameter 2 Radius meanDiameter sum Diameter NumBalls mimDiameter min Diameter dev display Bond disp circle WindowID Row Column Radius dev set color white set font WindowID system26 HALCON 6 0 4 128 APPENDIX A CONTROL for 1 1 to NumBalls by 1 if fmod i 2 1 set tposition WindowID Row i 1 1 5 Radius i 1
75. alues are passed as a tuple e g histogram 256 256 1 If only the first value is passed histogram the other values are set to defaults or the last values respectively For histogram computation see gray histo The modes line and column allow to display gray values along lines or columns respecively The position line and columnindex is passed with the second paramter value The third parameter value 15 the scale factor in percent 100 means 1 pixel per grayvalue 50 means one pixel per two grayvalues HDevelop 2003 08 01 149 Gray images can also be interpreted as 3d data depending on the grayvalue To view these 3d plots select the modes contourline 3D plot or 3D plot hidden Paramters for modes that need more than one parameter can be passed the following ways e Only the name of the mode is passed the defaults or the last values are used respectively Example dev set paint contourline e All values are passed all output characteristics can be set Example dev set paint contourline 10 1 e Only the first n values are passed only the passed values are changed Example dev set paint contourline 10 LLL Attention 0000000000000 If dev set paint should be used for exported Code C please note the description of set paint due to the different semantics in Parameter o o o gt Mode input control string array st
76. am Export The first step 1s to export the program using the menu File gt Save As Here select the lan guage C and save it to file In UNIX you specify the language by giving the file the extension c A file will be created that contains the HDevelop program as C source code in a proce dure action This procedure is called in function main Besides the program code the file contains all necessary include instructions variables iconic as well as control are declared locally in the procedure action Iconic variables belong to the class Hobject and all other variables belong to Htuple Please note that in the current version the generated C code is not optimized for readability yet 4 3 1 2 Compiling and Linking in Windows NT 2000 XP Environments The next step is to compile and link this new program In the Windows environment Visual 15 used for the compiling and linking Example projects can be found in the directory 4AHALCONROOTA examples Vc 1586 nt4 If you want to use Parallel HALCON you have to include the libraries 1 11 411 and parhalconc lib dll instead of halcon lib d1l and halconc lib dll in your project see the HALCON C User s Manual for more details 4 3 1 3 Compiling and Linking in UNIX Environments To compile and link the new program called e g test c in the case of UNIX you can use the example makefile which can be found in the directory SHALCONROOT examples c
77. am window and inserts a first program line similar to the following line into your program read image Marks Files MVTec Halcon images marks tif This new program line is executed immediately and the loaded image 15 displayed in the active graphics window Please note the double backslashes which are necessary since a single backslash is used to quote special characters see page 63 In our example we change the default for the name from Marks to Christof Using this selection box you are able to search images rapidly without knowing their exact file HALCON 6 0 4 4 CHAPTER 1 INTRODUCING HDEVELOP names In contrast to the two other possibilities the parameters of operator read image are specified automatically Thus an explicit input of path and file name is not necessary in this case An icon with an appropriate variable name is created in the iconic variable area of the variable window Double clicking on such an icon displays its contents in the currently active eraphics window Figure 1 1 shows a complete configuration of HDevelop for the explained scenario In addition a new window is opened after closing the default window to display the image in its original size If you look closer at the image in figure 1 1 you will see the typical temporal offset between two half images that occurs when taking images with a video camera This temporal offset is 20 ms for PAL systems and 16 6 ms for NTSC
78. an also be achived by using the operator dev clear window You close a graphics win dow using the Close button of the window frame or by calling dev close window The the origin of the graphics window 1s the upper left corner with the coordinates 0 0 The x values column increase from left to right the y values increase from top to bottom Normally the coordinate system of the graphics window corresponds to the the most recently displayed image which is automatically zoomed so that every pixel of the image 1s visible The coordinate system be changed interactively using the menu Visualization gt Set Parameters gt Zoom or with the operator dev set part Every time an image with a different size is displayed the coordinate system will be adapted automatically Each window has a history which contains all e objects and e display parameters which have been displayed or changed since the most recent clear action or display of a full image This history is used for redrawing the contents of the window Other output like text or general graphics like disp line or disp circle or iconic data that is displayed using HAL CON operators like disp image or disp region are not part of the history and are not re drawn Only the object classes image region and XLD that are displayed with the HDevelop operator dev display or by double clicking on an icon are part of the history HDevelop 2003 08 01 141 You may change the size of
79. analysis tasks to solve 5 2 Capillary Vessel File name vessel dev The task of this example 15 the segmentation of a capillary vessel In particular you have to separate the cell area the upper and lower part of figure 5 3 left image from the area in the middle of the image HALCON 6 0 4 98 CHAPTER 5 PROGRAM EXAMPLES 1491 80 150 75 1990 6 3 2 Mensch und 1422 80 C mehrfarbig 350 3 25 FDC amp Sa 5 4 SS FOG 12 1413 3 75 Fischer 19 9 1990 6 3 Mica FDC 3 50 1414 50C 1 40 50 50125 mehrtarbig 3 50 3 50 25 C mehrfar 39 FOC 18 Block 26 15 i Figure 5 2 Segmentation result for stamps The area boundaries are very blurred and even a human viewer has difficulties recognizing them At first glance it seems very difficult to find a segmentation criterion There is neither a clear edge nor a significant difference between the gray values of both areas Thus it is not very promising to use an edge operator or a threshold operation One solution of this problem makes use of the different textures within the areas Cells are more textured than the part which 1s supplied with blood To emphasize this difference you can use a texture transformation by Laws Texture transformations are linear filters that intensify certain frequencies which are typical for the requested texture The corresponding HALCON operator
80. anges from zero to the length of the string minus 1 The result of the operator 15 a string of length one s ii i2 returns all characters from index position 11 up to position i2 in s as a string index ranges from zero to the length of the string minus 1 5 11 51 52 devides the string s1 into single substrings The string is split at those positions where it contains a character from s2 As an example the result of split usr image usr proj image consists of the two strings L usr image usr proj image HDevelop 2003 08 01 3 5 EXPRESSIONS FOR INPUT CONTROL PARAMETERS 75 3 5 8 Comparison Operators In HDevelop the comparison operators are defined not only on atomic values but also on tuples with an arbitrary number of elements They always return values of type boolean Table 3 12 shows all comparison operators less than greater than less or equal greater or equal equal not equal Table 3 12 Comparison operators t t and t are defined on all types Two tuples are equal true if they have the same length and all the data items on each index position are equal If the operands have different types integer and real the integer values are first transformed into real numbers Values of type string cannot be mixed up with numbers 1 string values are considered to be not equal to values of other types Ist Operand 2nd Operand 1 1 0 1 9 2 1 52 1 2
81. ans respectively The function round always returns an integer value and the function abs always returns the absolut value that is of the same type as the input value real converts an integer to a real For real as input it returns the input round converts a real to an integer and rounds the value For integer it returns the input The following example filename euclid_distance dev shows the use of some numerical functions HALCON 6 0 4 78 CHAPTER 3 LANGUAGE 192 4 33 1933 V2 233 23 32 766 230 4224 63 33 Diff gt VI V2 Distance sqrt sum Diff Diff Dotvalue sum V1 V2 First the Euclidian distance of the two vectors Vi and V2 is computed by using the formula d 2 V1 V2 1 The difference and the multiplication square are successively applied to each element of both vectors Afterwards sum computes the sum of the squares Then the square root of the sum 15 calculated After that the dot product of V1 and V2 is determined by the formula V1 V2 gt V1 V2 1 3 5 13 Miscellaneous Functions sort t sorting in increasing order sort index t return index instead of values inverse t reverse the order of the values is_number v testif value is a number number v convert string to a number environment s value of an environment variable ord a ASCII number of a character chr a convert an ASCII number to a character ords s ASCII number of a tuple of st
82. arallelization Possible Successor Functions 1 dev display See Also gt dev update pc dev update var dev update time Module SS Basic operators HALCON 6 0 4 158 APPENDIX B DEVELOP HDevelop 2003 08 01 Appendix C Glossary Boolean is the type name for the truth values true and false as well as for the related boolean expressions Body A body is part of a conditional instruction if or a loop while or for and consists of a sequence of operator calls If you consider the for loop for instance all operator calls that are located between for and endfor form the body Button A button is part of a graphical user interface With the mouse the user can press a button to cause an action to be performed Control data Control data can be either numbers Tinteger and 1 character strings string and truth values boolean This data can be used as atomic values 1 single values or as Ttuples 1 arrays of values Empty region An empty contains no points at all 1 its area is zero Graphics window graphics window is used in HDevelop for displaying Jimages Tregions or JXLD HDevelop is an interactive program for the creation of HALCON applications Iconic data are image data 1 image arrays and data which are described by coordinates and are derived from image arrays e g 5 Jimage and 7 XLD Image An image consists of or more
83. ariable iconic and con trol is updated by default in the variable window see page 54 This is very useful HDevelop 2003 08 01 2 3 MAIN WINDOW 17 in the test phase primarily to examine the values of control data since iconic data is also displayed the graphics window If you want to save time while excecuting a program with many operator calls you may suppress this output Independent of the selected mode the display of all variables will be updated after the program has stopped e Update Window This item concerns the output of iconic data the graphics window after the exe cution of a HALCON operator With the default setting all iconic data computed in the Run mode see page 21 1s displayed in the current graphics window You may want to suppress this automatic output e g because it slows down the performance time If the output is suppressed you have the same behavior as exported C or Visual Basic code where automatic output of data 1s not supported e Show Processing Time This checkbox indicates whether the required runtime of the last operator should be displayed after the execution has stopped It is a measurement of the needed time for the current operator without output and other management tasks of HDevelop Along with the required runtime the name of the operator is displayed in the status bar at the bottom of the main window Please note that the displayed runtime can vary considerably This is cau
84. ase By clicking the appropri ate item you set the text field and the list disappears e The third column indicates the parameter s default type in parentheses This 1s a raw hint for the user what types of data have to be specified for each operator Please refer to the following rules on how parameters obtain their values and how you may specify them Iconic input parameters These are the only parameters that do not have any defaults You have to make sure that there is an input Possible inputs are iconic variables of the corresponding list If there is no need to execute the operator immediately you may even specify new variable names i e names that do not already exist in the variable window but will be instantiated later by adding further operators to the program In any case you have to specify iconic parameters exclusively with variable names It 1s not possible to use expressions Iconic output parameters These parameters contain default variables which have the same names as the param eters themselves If a variable with the same name as the output parameter 15 already being used a number is added to the name to make it unique Because the parameter HALCON 6 0 4 52 CHAPTER 2 GRAPHICAL USER INTERFACE names characterize the computed result very well you may adopt these default names in many cases Besides this you are free to choose arbitrary names either by yourself or by opening the list see above If you use a
85. ata 2 6 2 Area for Control Data 2 7 Graphics Window uuu de ox ow X ox Xo om he eee Moe mox 9 x he XR eG Language 3 1 Basic Types of Parameters 32 Control Types and Constants 5 7 Leu noe eh Rok eee eee Ke 3 4 Operations on Iconic 3 5 Expressions for Input Control Parameters 3 5 1 General Features of Tuple Operations Ao wk xou ode E RARE SE DGS Basic Touple Operaio gt e ke como kx Eee ee RO x e 3934 Tople realon 3 5 5 Simple Arithmetic Operations AAO 2 5 eee wee EE Be Gwe 3 5 7 String 3 5 8 Comparison Operators 3 5 9 Boolean Operators akis rpa N E 3 5 10 3 5 11 3 2 12 225 13 3 5 14 Trigonometric Exponential Functions Numerical Functions Miscellaneous Functions Operator Precedence 3 6 Reserved 3 7 Control 3 8 Limitations 4 Code Generation 4 1 4 2 4 3 4 4 Co
86. ause they have to be distinguished from the IC contacts This can be done by restricting the search on a region of interest IC contacts may only appear either on the right or the left side of IC s The coarse region of interest 1s defined by enlarging the IC regions with a following set subtraction Then the result is resized appropriately by using another dilation Figure 5 14 shows the operator result on the left side Now you only have to intersect the result of the thresholding with the region of interest One matrix is shared by several iconic objects to reduce costs of memory and computation time HALCON 6 0 4 110 CHAPTER 5 PROGRAM EXAMPLES gt 4 41 72 mp Dhow SOO 9 Oo ogargq Plo I 0 C3 C e que m NET gJ BO Fone m X 0 bz b gt 9 gt 9 9 Y 9 LE DI E I I E D T T T EFP 02 c PARI Q F908 e d AP CS en 47 Figure 5 14 Searching regions for contacts left and IC contacts right dilation rectanglei1 IC ICWidth 5 1 difference ICWidth IC SearchingArea dilation rectanglei1 SearchingArea SearchingAreaWidth 14 1 unioni SearchingAreaWidth SearchingAreaUnion reduce_domain Intensity SearchingAreaUnion SearchGray mean_image SearchGray Mean 15 15 dyn_threshold SearchGray
87. ayed in the program window by X cy uz The operator insert implements the assignment of a single value tuple of length 1 at a specified index position of a tuple Thus an array assignment here in C syntax a i v 15 entered as insert a v i a in the operator window and 15 displayed as HALCON 6 0 4 38 CHAPTER 2 GRAPHICAL USER INTERFACE ali v in the HDevelop program window The operators stop and exit are used to terminate the program More precisely stop interrupts an execution and exit terminates HDevelop Having interrupted the execution you may continue the program by pressing Step or Run This is useful e g in demo programs to install defined positions for program interruption Under UNIX you can use exit in combination with a startup file and the option run see section 1 2 Thus HDevelop will not only load and run your application automatically but also terminate when reaching exit The operator comment allows to add a line of text to the program This text has no effect on the execution of the program A comment may contain any sequence of characters Operators gt Develop This menu contains several operators that help to adapt the user interface These operators offer the same functionality that you have using mouse interaction otherwise They are used to configure the environment without or with little user interaction Using these operators the program performs actions similar to the settin
88. ber cannot be directly determined using For this purpose however HALCON operators are offered which carry out the equivalent tasks In table 3 8 you can see tuple operations that work on control data and their counterparts that work on iconic data In the table the symbol t represents a control tuple and the symbols p and q represent iconic tuples Further examples can be found in the program tuple dev gen_empty_obj O t count obj p num t1 t2 concat_obj 1 p2 tli select obj p 1 1 tli jl copy_obj p itt j i 1 Table 3 8 Equivalent tuple operations for control and iconic data 3 5 4 Tuple Creation The simplest way to create a tuple as mentioned in section 3 2 is the use of constants together with the assign operator assign empty tuple assign 4711 0ne integer assign 4711 0 815 two numbers This code 16 displayed as 1 4711 4711 0 815 empty tuple one integer two numbers This 1s useful for constant tuples with a fixed small length More general tuples can be created by successive application of the concatenation or the insert function together with variables expressions or constants If we want to generate a tuple of length 100 where each element has the value 4711 it might be done like this assign tuple fori 1 160 1100 assign tuple 4711 tuple endfor HALCON 6 0 4 70 CHAPTER 3 LANGUAGE which 1s transformed to tuple
89. bo box is opened in which you may select an item Thus you are able to choose a certain variable or value without risking erroneous typing This item is transferred to the operator name field Previous entries are deleted Afterwards the combo box is closed If there are no variables or appropriate values the combo box remains closed HDevelop 2003 08 01 2 5 OPERATOR WINDOW 53 2 5 3 Control Buttons Below the parameter edit fields you find four buttons that comprise the following functions see figure 2 37 Operator OF x Operator select shape Regions Region region object SelectedRegions gt electedRegions region object Features ares string Operation anc string Min 180 real 39999 real Enter Cancel Apply Help Figure 2 37 Operator window with operator select shape OK By clicking OK you execute the operator with the specified parameters In doing so the execution mode is dependent on the position of the PC If the PC is placed above the insertion position the system computes the program from the PC until the insertion position first Then the operator that has been edited in the operator window is executed The reason for this 1s that the parameter values that are used as input values for the new operator have to be calculated In case the PC is placed at or after the insertion position this operator is executed only Before execu
90. button within the window the loop continues You can terminate it by pressing any other mouse button 5 4 Annual Rings File name wood dev Everyone knows the task to determine the age of a tree by counting its annual rings This will now be done automatically using the example program The first step is the segmentation of annual rings This is quite simple as you can see them clearly as bright or dark lines Again the dynamic thresholding dyn_threshold can be used as before during the particle segmentation in section 5 3 To achieve a suitable threshold image you apply the mean filter mean_image with size 15 x 15 first The segmentation result contains many tiny regions that are no annual rings To eliminate them you have to create the connected components connection and suppress all regions that are too small select_shape Counting the rings becomes difficult as there might be fissures in the wood see figure 5 8 Thus we suggest the following method You define the start and end point of a line across the annual rings using your mouse Then the number of intersections with annual rings is counted along this line This can be done by the following HALCON operators The start and end points represented by their x and y coordinates are transformed into a line gen_region_line This line is intersected intersection with the annual rings SelectedRegions The number of the connected regions count obj in this intersection is th
91. by calling make TEST PROG test Alternatively you can set the variable TEST PROG in makefile to test and then just type make You can link the program to the Parallel HALCON libraries by calling make parallel TEST PROG test just type make parallel if you set the variable TEST PROG as described above For more details see the HALCON C User s Manual HALCON 6 0 4 92 CHAPTER 4 CODE GENERATION 4 4 General Aspects of Code Generation In the following general differences 1n the behavior of a HDevelop program and its exported versions are described 4 4 1 Assignment In HDevelop each time a new value is assigned to a variable its old contents are removed au tomatically independent of the type of the variable In the exported code this 1s also the case for iconic objects C Hobject Visual Basic HUntypedObjectX and for the class HTuple C and the type Variant Visual Basic as they all have a destructor which removes the stored data As the language C does not provide destructors the generated C code calls the operators clear obj and destroy tuple to remove the content of iconic output parameters Hobject and control output parameters Htuple before each operator call However problems arise if a tuple variant contains a handle for example for a file a window or for OCR In this case the memory of the handle is automatically removed but not the data which it points at In the exported programs this data has th
92. by using the Error Goto command This allows to access the reason for the exception and to continue accordingly Thus for HDevelop programs containing error handling dev_set_error_var the corresponding code is automatically included Please note that a call of dev set check give error has no influence on the operator call The exception will always be raised This is also true for messages like MESS FAIL which are not handled as exceptions in e g When handling exceptions you also have to be aware that the COM interface always resets the output parameters at the beginning of the operator execution Thus when the exception occures output variables are set to Nothing Therefore you cannot use the values of variables used as output parameters of the operator causing the exception 4 2 3 4 Special Comments HDevelop comments containing the symbol as the first character are exported as Visual Basic statement Thus the line Call MsgBox Press button to continue vbYes Program stop 1000 in HDevelop will result in Call MsgBox Press button to continue vbYes Program stop 1000 in Visual Basic This feature can be used to integrate Visual Basic code into an HDevelop program HDevelop 2003 08 01 4 3 CODE GENERATION FOR C 91 4 3 Code Generation for C This section describes how to create a HALCON application in C starting from a program developed in HDevelop 4 3 1 Basic Steps 4 3 1 1 Progr
93. c hardware features of a frame grabber board HALCON HDevelop HALCON C HALCON C HALCON COM The reference manuals for all HALCON operators versions for HDevelop C C and COM these manuals are available as PDF documents The reference manuals are available as HTML documents as well For the latest version of the manuals please check http www mvtec com halcon HDevelop 2003 08 01 Chapter 2 Graphical User Interface HDevelop 15 an interactive tool to create image analysis programs It comprises an editor an interpreter with debug functions a management unit for variables iconic and control data and extensive possibilities to visualize iconic data You may use HDevelop for rapid prototyping as well as for developing complete programs You create a program by choosing operators and specifying their parameters To do so you may use default values or values proposed by HDevelop After having selected the appropriate parameters you execute the operator and insert it into the program text 1 e the program window You can modify and verify your generated program interactively All intermediate results variables are displayed graphically images regions and polygons XLD or textually numbers and strings After starting the tool as described in section 1 2 the main window which includes the follow ing windows will appear on your screen see also figure 2 1 e a program window e operator window e a va
94. casting in T1 HTuple 2 T2 2 Change the order of the Operands in HDevelop and export the program again Ti T2 2 Both changes will do The first one would be used by the code generation anyway The second error mentioned above is caused by a similar reason The program might look like this T1 T2 long 1 2 val Both concrete errors shown above are hypothetical as they would be avoided by the automatic code generation in this special case But they are good examples for similar errors that might be caused by conflicting operators HALCON 6 0 4 88 CHAPTER 4 CODE GENERATION In this case val is a long variable and there is no multiplication available for the type long in the class HTuple So again we have to change the program slightly by adding the cast Operator Hruple long val T1 T2 HTuple va1 4 2 Code Generation for Visual Basic This section describes how to create a HALCON application in Visual Basic starting from a program developed in HDevelop HALCON can be used together with Visual Basic based on the COM interface of HALCON A detailed description of this interface can be found in the HALCON COM User s Manual 4 2 1 Basic Steps 4 2 1 1 Export The first step is to export the program using the menu File gt Save As Here select the lan guage Visual Basic and save it to file In UNIX you specify the file by giving it the cor responding extension which is bas Th
95. character as an integer chr converts an ASCII number to a character ords converts a tuple of strings into a tuple of ASCII integers chrt converts a tuple of integers into a string 3 5 14 Operator Precedence Table 3 19 shows the precedence of the operators for control data Some operations like func tions t etc are left out because they mark their arguments clearly or xor bor bxor and band lt gt lt gt unary minus 9 Table 3 19 Operator precedence increasing from top to bottom 3 6 Reserved Words The strings shown in table 3 20 are reserved words and their usage is strictly limited to their predefined meaning They cannot be used as variables 3 Control Structures HDevelop provides the following constructs to structure programs if The simplest control structure is if The condition contains a boolean expression If the condition is true the body 1s executed Otherwise the execution is continued at the first expression or operator call that follows the word endif if lt Condition gt endif HALCON 6 0 4 80 CHAPTER 3 LANGUAGE true false and OP bor bxor chr ord chrt ords band bnot not sum sin COS tan asin acos atan sinh cosh tanh exp log logi0 ceil floor atan2 pow fabs abs fmod ldexp round deg rad min max sort inverse strlen strchr Strrchr strstr strrstr split environment is_number number real lsh rsh deviation mean sqrt gen_t
96. contain regions images or XLDs You may assign new values as often as you want to But you cannot change them to the state before the first assignment see above Creation of a new variable happens in the operator dialog area during specification of operator parameters Here every sequence of characters without single quotation marks 15 interpreted as a variable name If this name did not exist before the variable is created in the operator dialog area by pressing OK or Enter The variable type is specified through the type of the parameter where it was used for the first time Variables that correspond to an iconic object parameter create an iconic variable variables for a control parameter create a control variable Every time an operator 15 excecuted the results are stored in variables connected to its output parameters This 15 done by first deleting the contents of the variable and then assigning the new value to it The variable window is a kind of watch window used in window oriented debuggers Inside this window you are able to keep track of variable values Corresponding to the two variable types there are two areas in the variable window One for iconic data above and the other for control data below see figure 2 38 computed variables are displayed showing their iconic or control values see page 16 In case of a tuple result which 15 too long the tuple presentation 15 shortened indicated by three dots HDevelop 2003 08
97. cs window The operator dev close window has to be used instead If dev open window should be used for exported Code C please note the description of open window due to the different semantics in C Parameter gt Row _ rectangle origin y integer Row index of upper left corner Default Value 0 Typical Range of Values 0 lt Row Minimal Value Step 1 Recommended Value Step 1 Restriction Row gt 0 p Column Onpat colllrol rectangle origin x integer Column index of upper left corner Default Value 0 Typical Range of Values 0 lt Column Minimal Value Step 1 Recommended Value Step Restriction Column gt 0 b Width EET ERI cians rectangle extent x integer Width of the window Default Value 256 Typical Range of Values 0 lt Width Minimal Value Step 1 Recommended Value Step 1 Restriction Width gt 0 V Width 1 HALCON 6 0 4 142 APPENDIX B DEVELOP gt Height input control rectangle extent y integer Height of the window Default Value 256 Typical Range of Values 0 lt Height Minimal Value Step 1 Recommended Value Step 1 Restriction Height gt 0 V Height 1 gt Background input control integer integer string Color of the background of the new window Default Value b
98. ctangle2 If you look closer at this program segment you will notice some obvious enhancements that can be made One is necessary due to the color model The thresholding of the color image chooses all pixels with a certain color This selection is independent of the color saturation Thus it might happen that very bright pixels nearly white pixels or very dark pixels nearly black pixels have the same color value as the components But you are only looking for stronger colors For this you select all pixels first whose color is strong 1 all pixels with a high saturation The second enhancement concerns the objects shape As the devices are rectangular you can specify the smallest enclosing rectangle of all connected components to enhance the seg ments On the left side of figure 5 13 the resulting components are marked In a second step we will search for all ICs This seems to be easy as they are rather large and dark However some problems emerge due to the bright labels that are printed across some ICs Thus a simple thresholding alone is not sufficient In addition you have to combine the segments belonging to one IC This is done by examining the spatial adjacencies of the segments A dilation 15 used to enlarge the regions until they overlap each other This dilation must not be so large that different ICs are merged Thus gaps caused by labels have to be smaller than gaps between ICs Now you can separate the enlarged ICs in th
99. d 0 break endif endfor a Redt o break always returns 2 H MSG TRUE HDevelop 2003 08 01 125 2 Parallelization Information 2 break is reentrant local and processed without parallelization See Also 440444646 4 4 4 2 for while Module o Basic operators comment Comment Add a comment of one line to the program comment allows to add a comment of one line to the program As parameter value i e as comment all characters are allowed This operator has no effect on the program execution Parameter gt Comment input control string string Arbitrary sequence of characters Example SSS This is a program width comments this is a string as comment here are numbers 4711 0 815 stop comment always returns 2 H MSG TRUE 2 Parallelization Information SS comment 15 reentrant local and processed without parallelization Module Basic operators Terminate HDevelop exit terminates HDevelop The operator is aquivalent to the menu File gt Quit Internally and for exported C code the C function call exit 0 is used Example SSS read image Image fabrik intensity Image Image Mean Deviation open file intensity txt output FileHandle fwrite string FileHandle Mean Deviation close file FileHandle exit HALCON 6 0 4 126
100. d as numbers If more than three channels are present only the gray value of the first channel 1s displayed Below the gray values the coordinates of the mouse position 1s displayed Below these the size pixel type and the number of channels of the selected image are shown Visualization gt Zooming With this menu item a tool for real time viewing of zoomed parts of an image object is opened Figure 2 16 shows the layout of the real time zooming window The upper part of the tool contains a window of fixed size 256 x 256 in which the part of the graphics window over which the mouse pointer 1s located 1s displayed enlarged In the zooming window this pixel is marked by a red square its coordinates are displayed at the bottom of the zooming window The factor by which the enlargement is done can be adjusted with the combo box Zooming factor A zooming factor of corresponds HALCON 6 0 4 26 CHAPTER 2 GRAPHICAL USER INTERFACE Zooming Zooming factor Row Column 133 387 Figure 2 16 Real time zooming to displaying the contents of the graphics window in to normal resolution 1 one pixel in the image object corresponds to one pixel in the zooming window Increasing the zooming factor by 1 roughly increases the enlargement by a factor of 2 You can select a particular pixel by single clicking on it with the left mouse button The zooming tool stores this position internally and will redisplay the thus se
101. de Generation for ld IO ga eA RRR ER 825 4 1 2 Optimization uo 444 5 GS dm ded SdoeSS A43 25 41 4 Limitations and Troubleshooting lll rss Code Generation for Visual Basic Sl Basic Steps novem ouem oom omo om om oom kw ew ew 6 4 2 20 Program Structure 42 3 Limitations and Troubleshooting Code Generation TOF GL 4 3 1 Basic Steps bea eee wo omo RR OR x om x Yom m E ow General Aspects of Code Generation As ignment ss ss sos oom RRR RD ER Bom ALI xc 44 3 system Parameters 444 Graphics Windows 5 Program Examples 5 1 Stamp Segmentation 5 2 Capillary Vess l uua ouo x AXES X EXAx3445x33 5JX3 E23 2 PIDE 22x53 50 43 4 3 OM RO eee WWE S S EXC 5 4 Annual Rings ma BONUM uu Ree HRD RADE HESS 5 6 m TIENE 25 3o ade eee ee X 5 X93 4 x923 342995959 5545 Oc SYS oe the x3 35 43544 24 15 35 4 4 M Wow wg 2 9 Region Selection 5 10 Exception Handling cee kh eed eaten dd ee Bate eee oe Se eG Koad o ss scos spea ee OO a a a a a a a a
102. der the line width for border mode and the shape of the regions You can select up to 12 colors by clicking the appropriate checkbox They are used to emphasize the connectivity of different regions in the graphics window If you choose a single color presentation you may specify this color by selecting it in the list box see figure 2 21 With the parameter shape default is original you may specify the presentation shape for regions Thus you are able to display not only the region s original shape but also its enclosing rectangle or its enclosing circle etc For regions the draw mode can be specified Either it might be filled item fill or the borders are displayed item margin only The border line thickness of the presented regions is specified with help of the menu item border width This menu is visible only if the draw mode 15 set to margin because in the draw mode fill this parameter has no effect Visualization gt Set Parameters gt Zoom The menu item specifies which part of an image region XLD or other graphic item 15 going to be displayed see figure 2 22 The upper left four text fields spec ify the coordinate system left upper defines the pixel which will be displayed at the upper left corner of the window lower right defines the pixel which will be displayed at the lower right side of the window By selecting the upper button Interactive you specify a rectangular part in the graphics window interac tively
103. des operators covering a wide range of applications Factory automation qual ity control remote sensing aerial image interpretation medical image analysis and surveil lance tasks This manual provides all necessary information to understand HDevelop s basic philosophy and to use HDevelop This manual is intended for all new users of HALCON It does not assume that you are an expert in image processing Regardless of your skills it is quite easy to work with HDevelop Nevertheless it 1s helpful to have an idea about the functionality of graphical user interfaces GUI and about some basic image processing aspects The manual is divided into the following chapters e Introducing HDevelop This chapter explains the basic concepts of HDevelop and contains a first example that illustrates how to work with HDevelop e Graphical User Interface This chapter explains the graphical user interface of HDevelop and how to interact with it e Language This chapter explains syntax and semantics of the language used in HDevelop programs e Code Generation This chapter explains the export of a HDevelop program to C C or Visual Basic e Program Examples This chapter contains example programs for typical image processing tasks e Miscellaneous This chapter explains how to start HDevelop and describes keycodes warning and error windows and restrictions Consult your platform s documentation for general information Release Note
104. dev set shape 15 ocal and processed completely exclusively without parallelization 2 Possible Successor Functions dev display dev set color See Also set shape dev set line width Module System HALCON 6 0 4 152 APPENDIX B DEVELOP dev set window WindowID Activate a graphics window dev set window activates a graphics window This 1s equivalent to pressing the Active button of the graphics window LLL Attention If dev set window should be used for exported Code C please note the different handling of windows in C dev_set_window is not supported for C Parameter o o o gt WindowID input control window integer Window 2 Example SSS dev_open_window 1 1 200 200 black WindowID1 dev open window 1 220 200 200 black WindowID2 read_image Image monkey dev set window WindowID1 dev_display Image dev set window WindowID2 dev_display Image LLL Parallelization Information dev set window 1s local and processed completely exclusively without parallelization Possible Predecessor Functions 2 dev open window Possible Successor Functions o 1 dev display Module 00000000000 o Basic operators Change position and size of a graphics window dev set window extents changes the position and or the size of the currently active graphics window The parameters Row and C
105. displayed see the operator cooc feature image The combo box 1d can be used to select the number of gray values to be distinguished 24 The combo box dir selects the direction in which the coocurrence matrix is computed The resulting features energy correlation homogeneity and contrast have self explanatory names A detailed description can be found in the reference of the operator cooc feature matrix The final display contains the output of the operator moments gray plane These the angles of the normal vector of a plane fit through the gray values of the selected region Dialog Minimum Maximum o 100000 y x f oy sqn x C y logi 0 7 CT y logi Oflogd Q x3 OK Apply Reset Cancel Figure 2 19 Configuration dialog for single region features Each of the gauges corresponding to a display can be configured to set the minimum and maximum values for each gauge Furthermore the scaling function of the gauge can be determined This can be used to make the relation of the features of different regions more intuitive For example features that depend on the area of the region are more intuitively grasped when the scaling is set to sqrt x The configuration dialog 15 the same for all gauges and is shown in figure 2 19 It can be brought up by pressing the button next to each gauge Visualization gt Size Window There are convenient methods to change the size of the active graphics window depend
106. dow If the Normally upon starting HDevelop automatically opens one graphics window HALCON 6 0 4 24 HDevelop clip dev File Edit Execute Visualization Operators Suggestions Window Help Dias x E Open window Reset Parameters Clear Window Close Window Pinel Info Zooming Gray Histogram Info Region Info Size Window Zooming Enlored Color Draw Line Width original Lut Paint k k k k k k Li k k Set Parameters rectangles ellipse Bl B fios outer circle inner circle rectangle CHAPTER 2 GRAPHICAL USER INTERFACE x Pale x inl x lel Es Active Figure 2 13 Submenu Shape of menu Visualization Hew Window window height and width are set to Row o Column 0 Height 1 Background back Cancel Figure 2 14 Dialog window of menu item Visualization gt Open Window 1 the window obtains the same size as the largest image in the current session A position value of 1 specifies that the window position is determined by the window manager UNIX If you have not already created an image the size 512 x 512 1s used The handling of graphics windows 15 described in chapter 2 7 at page 56 Visualization gt Reset Parameters HDevelop 2003 08 01 2 3 MAIN WINDOW 25 Here the display paramete
107. down menu henceforth abbreviated as menu with optional submenus You open a menu by HALCON 6 0 4 12 CHAPTER 2 GRAPHICAL USER INTERFACE clicking a menu item inside the appropriate text or via the keyboard by pressing the key lt Alt gt in combination with the underlined letter of the menu item All menu items are going to be explained in the following 2 3 2 1 Menu ltem File In the menu item File you will find all functions to load an image and existing programs and to save recently created or modified programs respectively Furthermore you may export HDevelop programs to C C and Visual Basic and also print them Figure 2 2 shows all the functions in this menu item STATE DENT Im x Edit Execute Visualization Operators Suggestions Window Help Open gt Er Taal E x Active Insert Save Les Save as Print Chrl P Print Selection Head Image Cleanup Options Modules Quit 1 marks dev er Type Width Hei ight black Create new program clear the current program Figure 2 2 The menu item File File gt New keyboard shortcut Ctrl N The menu item File gt New deletes the current program and all associated variables The contents of the variables are deleted before removing them In addition all graphics windows except one are closed The last window will be cleared The display parameters for the remaining
108. e To have explicit control over the result state two HDevelop operators are available dev error var and dev set check The following example shows how to use these operators The task 1s to get online information about the position of the mouse inside a graphics window and to display the gray value at this position This can be achieved using the two operators get mposition and get grayval The problem with get mposition in HDevelop 15 that it returns MSG FAIL if the mouse is outside of the window to indicate that the mouse coordinates are invalid This would lead to an interruption of the program Therefore an explicit error handling is needed The complete program is given below read image Image mreut dev close window dev open window 0 0 1 1 black WindowID dev display Image Button 1 while Button 4 dev error var Error 1 dev set check give error get mposition WindowID Row Column Button dev error var Error 0 dev set check give error if Error MSG TRUE get grayval Image Row Column Grayval dev set color black disp 1 1 WindowID 0 0 22 85 dev set color white set tposition WindowID 15 2 write string WindowID Rowt Column Grayval endif endwhile After loading an image and opening a window we enter the loop to query the mouse position Because the operator get mposition might cause an exception we call dev set c
109. e with the same area as the region see the operator compactness The compactness of a region 15 always larger than 1 The compacter the region the closer the value of the compactness is to 1 The third display shows the convexity of the selected region 1 the ratio of the area of the region and the area of the convex hull of the region see the operator convexity The convexity of a region is always smaller than 1 Only convex regions will reach the optimum convexity of 1 The last but one display shows shape features derived from the ellipse parameters of the selected region which are calculated with the operator eccentricity The anisometry of the region 15 the ratio of the major and minor axis of the ellipse 1 the ratio of ra and rb in the second display if you set shape to 111 This feature measures how elongated the region 15 Its value is always larger than 1 with isometric regions having a value of 1 The definition of the more complex features bulkiness and structure factor abbreviated as structure in the display can be obtained from the HALCON Reference Manual The final shape feature display shows the connected components and number of holes of the selected region as computed by the operator connect and holes The gray value features are grouped into five displays on the right side of the region inspection window Again they correspond roughly to individual HALCON operators The first display shows the mean gra
110. e first call of dev error var ErrVariable true In C this means that all successive lines 1 lines below until the first dev error var ErrVariable false will have the assignment to ErrVariable This might lead to a different behavior compared with HDevelop if dev error var is called inside a loop because here the operators inside the loop before dev error var might also use ErrVariable after the second excecution of the loop body Therefore Try not to use dev error var inside a loop Use it right at the beginning of the program 4 1 4 2 Compiler errors Sometimes it happens that messages like CC example cpp line 17 bad operands for int HTuple Or CC example cpp line 17 error ambiguous call CC example cpp line 17 choices of HTuple operator CC example cpp line 17 HTuple operator const HTuple amp const CC example cpp line 17 HTuple operator double const 1 line 17 HTuple operator int const are reported by the compiler Both errors are caused by conflicting operators In this case one either has to change the HDevelop or the C program To understand how let us look at the code which caused the errors above For the first error the C program would look like this HTuple T1 T2 2 5 5 Because there is operator int HTuple a compiler error is given This error can be handled in two ways 1 Do appropriate type
111. e left mouse button and the Shift key e A is set by pressing the left mouse button and the Ctr1 key The program counter resides in the line of the next operator to execute The insertion cursor indicates the position to insert a new program line A break point shows the program line before which the program is stopped Clicking on a break point again while pressing the Ctr1 key deletes it A break point is active only if itis visible In figure 2 35 you see a program and the column with the PC indicated as an arrow a BP and the insertion cursor By clicking into the column on the left with the right mouse button you can open a context menu which contains shortcuts to some of the actions of the menus Edit e g copy and paste lines and Execute e g activate and deactivate lines or set and clear break points Please note that these actions behave slightly differently than their counterparts in the main menus When called via the main menus the actions are performed only on the selected part of the program if HDevelop 2003 08 01 2 4 PROGRAM WINDOW 49 Program OP x dev open weindowe 0 0 Width Height black window ID dev set_dravy fill dev set part 0 0 Height 1 Yvidth 1 threshold Image Region 128 255 dev set color white connection Region ConnectedRegions select shape ConnectedRegions CompactRegioanz campactness and 1 5 1 8 Number CompactRegionsz gen empty obj Eyes for
112. e nature too the operator gen lowpass which is used to create a lowpass filter in the frequency domain 15 a reasonable reference to a Gaussian filter ouggestions gt Keywords This menu item gives access to HALCON operators by using keywords which are asso ciated with each operator You get a window divided into two parts which contains all keywords on the left hand side and the selected operators on the right see figure 2 29 After the suggestions for an operator have been generated all keywords belonging to this HALCON 6 0 4 2 4 CHAPTER 2 GRAPHICAL USER Keywords Keywords Operators Class clip contours xld Classification partition rectangle partition dynarmnic clip region rel clip region crop domain rel Comparison Figure 2 29 Operator suggestions according to keyword Clipping operator are marked reversed on the left hand side of the window On the right side you will find all operators associated with at least one of these keywords Clicking a keyword on the left list causes the addition of operators belonging to this keyword If you want to transfer one of these operators to the operator dialog area you click one of them with the left mouse button Afterwards the selection window 15 closed 2 3 2 7 The Menu ltem Window This menu item offers support to manage your four windows 1 the program operator vari able and graphics window They are very useful while working w
113. e number of annual rings The complete program looks as follows HALCON 6 0 4 104 CHAPTER 5 PROGRAM EXAMPLES SE S E EE SSS 2 a SS oe TUN iW Figure 5 8 Annual rings of a tree dev_close_window read image WoodPiecei woodring get image pointer1 WoodPiece1 Pointer Type Width Height dev open window 0 0 Width 2 Height 2 black WindowID mean image WoodPiecei ImageMean 9 9 dyn threshold WoodPiecei ImageMean Regions 5 0 dark threshold WoodPiecei Dark O 90 dilation rectanglei1 Dark DarkDilation 30 7 difference Regions DarkDilation RegionBright connection RegionBright ConnectedRegions select shape ConnectedRegions SelectedRegions cunc 30 10000000 get mbutton WindowID Rowi Columni Button1 get mbutton WindowID Row2 Column2 Button2 gen region line Line Row1 Columni Row2 Column2 intersection Line SelectedRegions Inters connection Inters ConnectedInters Number ConnectedInters 5 5 Bonding File name ball dev This 1s the first example in the field of quality inspection The task 1s to detect bonding balls Figure 5 9 shows two typical microscope images of a die The die border and the bonding wires appear dark Thus you may apply a thresholding Since the background is also dark we have to extract the die before doing the segmentation T
114. e quote in between any character can be used except single quote The empty string consists of two consecutive single quotes The maximum length of a character string is limited to 1024 characters Tuple A tuple is an ordered multivalue set In case of Tcontrol data a tuple can consist of a large number of items with different data types The term tuple 15 also used in conjunction with Ticonic objects if it is to be emphasized that several Ticonic objects will be used Type iconic variables can be assigned with data items of type Timage and The types of Tcontrol data items can be of Jinteger freal boolean or string Variable window In HDevelop the variable window manages the control and Ticonic data XLD is the short term for eXtended Line Description It is used as a superclass for contours polygons and lines see also the HALCON Reference Manual HDevelop 2003 08 01 Index add channels 26 29 109 anisometry 3l Applications 95 area center 29 111 assign 35 37 66 67 69 123 Attributes 95 bin threshold 99 Boolean 159 Break 124 break 35 81 124 Break point 22 23 48 Buffer 140 Button 159 C 1 91 Compile 91 Export 1 91 Link 91 C 1 12 83 Compile 84 Export 1 83 Link 84 Cleanup 16 54 Clear 133 clear_obj 121 Clearing 133 clip_region 116 Closing 135 Code generation 83 88 91 Color 108 COM 1 88 Export 1 Comment 125 commen
115. e result is a new file with the given name and the extension bas 4 2 1 2 The Visual Basic Template The exported file is intended to be used together with the predefined Visual Basic project that can be found in the directory HALCONROOT examples vb HDevelopTemplate This project contains a form with a display window HWindowXCtrl and a button labeled Run The file generated by HDevelop has to be added to this project This 1s done by using the menu Project gt Add Module gt Existing and selecting the file Now the project 1s ready for execution Run the project and then press the Run button of the form which will call the exported code 4 2 2 Program Structure The file created by HDevelop consists of the subroutine RunHalcon which corresponds to the original program In addition another subroutine is created with the name InitHalcon This subroutine applies the same initializations which HDevelop does Most of the variables iconic as well as control are declared locally in the subroutine RunHalcon Iconic variables inside RunHalcon belong to the class HUntypedObjectX HDevelop 2003 08 01 4 2 CODE GENERATION FOR VISUAL BASIC 89 and control variables belong to Variant The subroutine RunHalcon has a parameter Window which is of type HWindowX This 1s the link to the window the panel where all output opera tions are passed to Depending on the program additional subroutines and variables are declared
116. e the printing process File gt Print Selection In contrast to the menu item File gt Print the menu item File gt Print Selection prints only the currently selected part of a program HDevelop 2003 08 01 2 3 MAIN WINDOW 15 File gt Read Image The menu File gt Read Image contains several directories from which images are usu ally loaded The first entry of this menu always is the directory from which the most re cent image was loaded This 15 useful when several images from a non standard directory must be read The remaining entries except the last one are the directories contained in the HALCONIMAGESY environment variable The final directory denoted by is the current working directory of the HDevelop program which usually will be A4HALCONROOT on Windows systems and the directory in which HDevelop was started on UNIX systems i HDevelop D gt lt Edit Execute Visualization Operators Suggestions Window Help New veles of me us tu Open rl O xi Insert Save Chrl 5 5 ave as see g Read Image W curentsbinibBb ntd halcanshalcan current images Cleanup images Options Modules Quit 1 clipe dey 4 Save the current program with a diferent name Figure 2 5 The menu item File gt Read Image When any of the directories is selected an image file selection box appears Again its functionality is sim
117. ecessor gt Keywords threshold Operator read image IPegiongrowing Ei x count channels a decomposes Image Image class ndim mor bject gausz image FileName fabrik fill_interlace string zoom image size Enter zoom image factor Ip crop part image rgbl to gray Maegliche Nachfalge Prozedur Figure 2 28 Suggestions to select a successor of HALCON operator read image ouggestions gt Successor In many cases the task results in a natural sequence of operators Thus as a rule you use a thresholding after executing an edge filter or you execute a region processing e g morphological operators after a segmentation To facilitate a reasonable processing all the possible operators are offered in this menu item ouggestions gt Alternatives Since HALCON includes a large library this menu item suggests alternative operators Thus you may for example replace mean image with operators such as gauss image sigma image or smooth image ouggestions gt also Contrary to Alternatives operators are offered here which have some connection to the current operator Thus the median filter nedian image is not a direct alternative to the mean filter nean image Similarly the regiongrowing operator regiongrowing 15 no alternative for a thresholding In any case they offer another approach to solve a task References might consist of pure informativ
118. ed with their parameter names Other possibilities to obtain a control output variable name are either using the combo box or specifying variable names manually You cannot use any expressions for these parameters either After discussing what can be input for different parameters it is explained how this is done Nevertheless you have to keep in mind that you need to modify a parameter only if it contains no values or if you are not satisfied with the HALCON default values Text input To specify a parameter using your keyboard is the simplest but not the most often used method Here you have to click into a text field with the left mouse button This activates the field and prepares it for user input Simultaneously the writing position 1s marked by a vertical bar Now you may input numbers strings expressions or variables There are some editing functions to help you doing input lt gt deletes the left and Delete deletes the right character You may also select invert a sequence of charac ters the text field using the mouse If there 16 a succeeding input the marked region 15 going to be deleted first and afterwards the characters are going to be written in the text field You can find additional editing functions on page 119 Combo box selection Using this input method you can obtain rapid settings of variables and constants To do so you have to click the button on the text field s right side A com
119. eir connected HDevelop 2003 08 01 5 7 DEVICES 109 Figure 5 13 Resistors and capacitors left and ICs right components Unfortunately they have become too large by the dilation Another thresholding for each connected component will detect the dark pixels of each IC Finally you can specify the enclosing rectangles analogously to the resistors and the capacitors see above threshold Intensity Dark 0 50 dilation rectanglei1 Dark DarkDilate 15 15 connection DarkDilate ICLarge add channels ICLarge Intensity ICLargeGray threshold ICLargeGray ICsDark 0 50 shape trans ICsDark IC rectangle2 The right side of figure 5 13 shows the resulting ICs We have to mention two aspects about the program segment above Here the operator add channels has been used instead of reduce domain This is necessary as several regions have to be supplied with gray values The situation of previous programs was quite different there the number of valid pixels of one image has been restricted From this follows the second point here the operator threshold gets several images as input The thresholding is performed in every image Thus you receive as many regions as input images Finally the segmentation of IC contacts has to be done They are bright and small Thus it is easy to extract them using a dynamic thresholding compare chapter 5 3 However several other tin elements on the board remain a problem bec
120. elop allows to export a developed HDevelop program to the programming languages C Visual Basic and C by writing the corresponding code to a file The sections 4 1 4 2 and 4 3 describe the general steps of program development using this feature for the three languages including some language specific details of the code generation and optimization aspects Because HDevelop does more than just execute a HALCON program the behavior of an ex ported program will differ in some points from its HDevelop counterpart prominent example is that 1n HDevelop all results are automatically displayed while in the exported programs you have to insert the corresponding display operators explicitely Section 4 4 describes these differences more detail 4 1 Code Generation for C This section describes how to create a HALCON application in C starting from a program developed in HDevelop 4 1 1 Basic Steps 4 1 1 1 Program Export The first step 1s to export the program using the menu File gt Save As Here select the lan guage and save it to file In UNIX you specify the language by giving the file the exten sion cpp A file will be created that contains the HDevelop program as C source code in a procedure action This procedure is called in function main Besides the program code the file contains all necessary include instructions variables 1conic as well as control 83 84 CHAPTER 4 CODE GENERATI
121. elve twenty four colord color colors color4 cyclic gray cyclic temperature hsi Figure 2 23 Settings of parameter 1ut that means any sequence of characters to the program The corresponding menu is shown in figure 2 24 lel Es HDevelop break while dev SE Suggestions Window Help assign E amp l Lic File Edit Execute Visualization 18 x es e e Develop inzert Program Classification if Fil ifl igl xi Filter for Variable Watch Graphics while BI x Graphics Window EEE break Oe gt Lines stop Morphology comment Object Regions Segmentation System Tools Tuple ALD Fr ox F F Control structure Figure 2 24 Menu item Control Selecting a menu item displays the corresponding control construct in the operator win dow where you can set the necessary parameters After specifying all parameters you may transfer the construct into your program A direct execution for loops and conditions is not possible in contrast to other HDevelop and HALCON operators because you have HDevelop 2003 08 01 2 3 MAIN WINDOW 3 to specify the loop s and condition s body first to obtain useful semantics If necessary you may execute the program after the input with Step or Run The insertion cursor is positioned after the construct head to ensure the input of the construct s b
122. ent on the size of the previously displayed image Using the submenu Original the window is set to the same size as the most recently displayed image that means for each pixel of the image one pixel on the screen is used for displaying Similar to this you can select Original half or Original quarter to make the window half or a quarter as big as the displayed image The submenus Half and Double change the size of the graphics window to half and double its current size respectively independent of the size of the previously displayed image You can combine Double with Original The submenu Aspect changes the aspect ratio of the graphics window so that pixels are displayed as Squares on the screen For this operation again the size of the previously displayed image is used Visualization gt Zooming This is a convenient menu for manipulation of the zooming mode The submenu Reset switches zooming off 1 e an image will be displayed so that it fills the graphics window HALCON 6 0 4 32 CHAPTER 2 GRAPHICAL USER INTERFACE completely The submenus Zoom In and Zoom Out apply a zooming in and out to the image or region by a factor of two Finally there are two interactive modes to control zooming Draw Rectangle allows the specification of a rectangular part of the window to be zoomed while Draw Center allows the definition of a pixel coordinate that should be at the center of the window e g for a successive Zoom In For more
123. ept zooming e XLD data is displayed using the coordinate system of the largest image used so far The color used for XLD objects is white on black background Due to the different ways of displaying objects you have to be aware that the coordinates cannot be compared The variable name 15 positioned below each icon They are displayed in the variable window in the order of creation from left to right If there is not enough space horizontal scrollbar is created which you can use to scroll the icons Clicking on an icon with the mouse will select this icon This 1s indicated by the black back ground for the icon name For an activated icon all operators that use the corresponding variable are marked in the program area with a black rectangle on the left Double clicking with the left mouse button on an icon displays the data in the active graphics window If you use images of different sizes in a program the system uses the following output strategy for an automatic adaption of the zooming Every window keeps track of the size of the most recently displayed image If you display an image with a different size the system HALCON 6 0 4 56 CHAPTER 2 GRAPHICAL USER INTERFACE modifies the graphics window coordinate system in a way that the image is visible completely in the graphics window If a partial zooming has been activated before see chapter 2 7 it 1s going to be suppressed Normally regions images and XLDs are represented i
124. epts Furthermore you will learn the main aspects of HDevelop s graphical user in terface for more details see chapter 2 A simple introduction can be found the manual Getting Started with HALCON as well In this example the task 15 to detect circular marks attached to a person s body in a gray value image The program can be found in the file HALCONROOT examples HDevelop Manuals HDevelop marks dev You start HDevelop under Windows NT or Windows 2000 by calling Start gt Programs gt MVTec HALCON gt HDevelop Under UNIX HDevelop is started from the shell like any other program Optionally an appli cation name can be specified as a parameter hdevelop lt File gt dev This application is then loaded This is identical to an invocation of HDevelop without any parameter and a subsequent loading of the application If you want to run the application im mediately after it has been loaded invoke HDevelop as follows hdevelop run lt File gt dev This 15 equivalent to starting HDevelop loading the application and then pressing Run in the menu bar of HDevelop After starting HDevelop your first step is to load the image marks tif from the directory AHALCONROOT ANimages You may perform this step in three different ways necessary settings for the operation system are described in the manual Getting Started with HALCON HDevelop 2003 08 01 1 2 EXAMPLE SESSION 3 HDevelop marks dev File Edit Execute Vi
125. erefore to be removed explicitely by calling the corresponding operators like close_ocr or close ocv Please insert the close_ operators for all handles in use e before a new value 15 assigned to a handle e atthe end of the program In Visual Basic the ideal way would be to use the specific COM classes for this kind of data in combination with the member function This exchange has to be done by hand because the export is not able to generate appropriate code 4 4 2 for Loops HDevelop and the programming languages have different semantics for loops which can cause confusion Because the problems are so rare and the generated code would become very difficult to understand otherwise the code generation ignores the different semantics These differences are 1 In the programming languages you can modify the loop variable e g by setting it to the end value of the condition to terminate the loop This can t be done in HDevelop because here the current value is stored inside the for operator and is automatically updated when it is executed again 2 In the programming languages you can modify the step range if you use a variable for the increment This 15 also not possible with HDevelop because the increment 15 stored inside the for operator when the loop is entered 3 The last difference concerns the value of the loop variable after exiting the loop In the programming languages it has the value
126. es optimization is not necessary if you program according to the following rules 1 Using the tuple concatenation it is more efficient to extend a tuple at the right side like T T Nevw because this can the transformed to T Append New in and requires no creation of a new tuple whereas HDevelop 2003 08 01 4 1 CODE GENERATION FOR C 85 1 News which 1s translated into T New Append T would need the creation of a new tuple 2 Another good way to modify a tuple is the operator insert see section 3 5 2 In this case HDevelop code like Tli New can directly be translated into the efficient and similar looking code TLi New 4 1 3 Used Classes There are only two classes that are used HTuple for control parameters Hobject for iconic data There is no need for other classes as long as the program has the same functionality as in HDevelop When editing a generated program you are free to use any of the classes of HALCON C to extend the functionality 4 1 4 Limitations and Troubleshooting Besides the restrictions mentioned in this section and in section 4 4 please also check the de scription of the HDevelop operators on page 38 4 1 4 1 Exception Handling In HDevelop every exception normally causes the program to stop and report an error message in a dialog window This might not be useful in C In addition there are different default behaviors concerning the result
127. et or clear a break point on the line s that are currently selected in the program In most cases however it 15 easier to set and clear individual break points pressing the left mouse button and the lt Ctrl gt key in the left column of the Program Window as described in section 2 4 Execute gt Clear All Break Points With this menu item you can clear all break points in the program Execute gt Reset Program With the menu item Execute Reset Program you can reset the variables of the cur rent program to their initial states 1 e all variables have undefined values Furthermore the program counter is set to the first executable line of the program The break points however are not cleared This menu item 15 useful for testing and debugging of pro grams 2 3 2 4 The Menu ltem Visualization items which can be selected are shown in figure 2 13 With this you are able to open or to close graphics windows and to clear their displays Further more you may specify their output behavior during runtime Visualization gt Open Window By using this menu item you open additional graphics windows For this a dialog window pops up see figure 2 14 Here you may specify some graphics windows attributes The position size and background color of the new graphics window can be specified For example it is more convenient to have a white background while building graphics for slides or reports see the HALCON operator dump win
128. ev set line width can take place This 15 also true for all other modes outer circle Each region is displayed by the smallest surrounding circle smallest circle See inner circle Each region is displayed by the largest included circle See inner circle ellipse Each region is displayed by an ellipse with the same moments and orientation See elliptic axis rectanglel Each region is displayed by the smallest surrounding rectangle parallel to the coordinate axes See smallest rectanglel rectangle2 Each region is displayed by the smallest surrounding rectangle smallest rectangle2 convex Each region is displayed by its convex hull See shape trans icon Each region is displayed by the icon set with set icon in the center of gravity Attention See If dev_set_shape should be used for exported Code C please note the description of set shape due to the different semantics in Parameter gt Shape input control string string Region output mode Default Value original Value List Shape original convex outer circle inner circle rectangle1 rectangle2 ellipse icon Example read_image Image monkey threshold Image Region 128 255 connection Region Regions 1 1 dev set draw margin dev display Regions Parallelization Information
129. f colors are used that are not displayable on the screen HALCON can choose a similar displayable color of the output For this set check color must be called The defined color is used until dev set color or dev set colored is called Colors are defined for all graphics windows in contrast to the operator set color LLL Aftention 0000000000000 If dev set color should be used for exported Code please note the description of set color due to the different semantics in Parameter o gt o o gt ColorName input control string array string Output color names Default Value white Value Suggestions ColorName white black gray green blue Example ee read_image Image mreut set draw fill set color red threshold Image Region 180 255 dev set color green threshold Image Region 0 179 LLL Redt o dev set color always returns 2 H MSG TRUE LLL Information _________ _ _ dev set color is local and processed completely exclusively without parallelization LLL Possible Predecessor Functions SS dev open window query color query_all_colors Possible Successor Functions 1 dev_display Alternatives _ dev set colored See ASQ i o set line width set color Module _ System dev
130. frequencies When you select Rel the frequencies of individual gray values are displayed as percentages when you select Abs they are dis played as the actual number of pixels having a particular gray value See the operator gray histo in the HALCON Reference Manuals for details Sometimes it is desirable to suppress the updating of the histogram when new image data is available e g if you want to select thresholds for a gradient image but want to visualize the original image along with the segmentation see below To do so you can deselect the checkbox Accept The main part of the tool 15 the area in which the histogram of the 1mage 15 displayed in blue This area contains static parts and parts that can be interactively manipulated The first static part 1s the horizontal coordinate axis which displays the gray values in the image For byte images this range is always 0 255 For all other image types e g real images the horizontal axis runs from the minimum to the maximum gray value of HALCON 6 0 4 28 CHAPTER 2 GRAPHICAL USER INTERFACE the image and the labeling of the axis 1s changed accordingly To the left of the display the vertical axis representing the frequency of the gray values is drawn in white The final static parts of the display are three cyan arrows The two upward pointing arrows denote the maximum and minimum grayvalue of the image The downward pointing arrow denotes the gray value that occurs most freq
131. g example the sine from up to is computed and printed in to the graphical window filename sine dev old x 0 old_y 0 dev set color dev set part 0 0 511 511 torke 1 1897 Silt El y sin x 511 0 2 3 1416 3 255 disprin Window Dem codem M LL bo old x x old y lt y endfor In this example the assumption is made that the window is of size 512x 512 The drawing is always done from the most recently evaluated point to the current point Further examples on how to use the for loop can be found in chapter 5 8 and 5 9 break The instruction break enables you to exit for and while loops The program is then continued at the next line after the end of the loop A typical use of the instruction break is to terminate a for loop as soon as a certain condition becomes true e g as in the following example For negative increment values the loop is terminated if the loop index is less than the termination value HALCON 6 0 4 82 CHAPTER 3 LANGUAGE Number Regions AllRegionsValid 1 check whether all regions have an area lt 30 Dorm LIONE ObjectSelected Regions i area center ObjectSelected Area Row Column if Area gt 30 AllRegionsValid 0 break endif endfor In the following example the instruction break is used to terminate an infinite while loop as soon as one clicks into the Graphics Window while 1 grab_image Image FGHandle
132. g of a color in the parameter window see section 2 7 opening a window in the menu bar see section 2 3 2 4 or iconifying the program window with the help of the window manager All operators in this menu start with the prefix dev It has been introduced to have a distinction to the underlying basic HALCON operators e g dev set color and set color You can find the complete listing in figure 2 26 HDevelop File Edit Execute Visualization 11 Suggestions Window Help glelelol F Le el Control k el L Develop dev open window k Classification P close window 215 5 i k i Variable watch Filter dew sel window op m Graphics k dev set colored Graphics Windo Image set draw PII Es euo Lines k dev set line width EF Morphology dev set color Object k dev set lut Hegions k dev set paint Segmentation P dev shape System k dev set part Tools dex display k AL dew inspect ctrl dew close inspect dev map par dev unmap par dev map war dev unmap war dev map prog dev unmap prog dev update window dev update var dew update time dev update pc dew eror war dev set check Internal HDevelop Operator Figure 2 26 Operators in menu item Develop The effects of each operator are described as follows HDevelop 2003 08 01 2 3 MAIN WINDOW 39 e dev open window
133. gion The latter 15 computed from the output of the operator smallest rectanglel HALCON 6 0 4 30 CHAPTER 2 GRAPHICAL USER INTERFACE The second display contains information about the orientation angle and size of the region along the two principal directions ra and rb of the region With the combo box shape you can select by what means the size is computed If you select ellipse the size is computed with the operator elliptic axis This means that the parameters ra and rb are the major and minor axis of an ellipse that has the same moments as the selected region Note that this ellipse need not enclose the region If you set shape to rectangle the size is computed with the operator smallest rectangle2 This means that ra and rb are half the width and height of the smallest rectangle with arbitrary orientation that completely contains the selected region The orientation of the region is computed in both cases with the operator orientation region to get the full range of 3607 for the angle You can select whether to display the angle in degrees or radians with the corresponding combo box The next three displays show simpler shape features of the selected region The first of these displays shows the contour lenght of the region 1 the euclidean length of its boundary see the operator contlength The second one shows the compactness of the region 1 the ratio of the contour length of the region and the circumference of a circl
134. gram needs an average of 20 ms on a standard Pentium Notice that this 15 even possible under the following restrictions 1 Only standard operators have been used 2 Only encapsulated data structures have been used 3 Despite optimization the program 15 quite comprehensible 4 The program is very short This example shows that you can write efficient programs even while using complex data struc HDevelop 2003 08 01 5 11 ROAD SCENE 117 tures Hence a significant reduction of development time 1s achieved Furthermore data encap sulation is a basic condition for the portability of the whole system and the user software HALCON 6 0 4 118 CHAPTER 5 PROGRAM EXAMPLES HDevelop 2003 08 01 Chapter 6 Miscellaneous This chapter contains helpful information for working with HDevelop 6 1 Keycodes In order to speed up the entering of values in the input fields of HDevelop e g operator pa rameters several keycodes are defined which have special functions They conform to the standards of the emacs editor This feature 16 only available for UNIX systems Some of them are shown in table 6 1 Table 6 1 Keycodes for special editing functions 6 2 Interactions During Program Execution The interpreter of HDevelop allows some user interactions during the execution of a program First the stop button has to be mentioned which is responsible for interrupting the execution 119 120 CHAPTER 6 MISCELLANEOUS of a
135. gure 2 31 The window management function Tile version see figure 2 32 Furthermore it lists host IDs detected by the license manager see the manual Getting Started with HALCON for more information About HDevelop G HALCON Version 6 0 HDevelop Version 3 1 MYT ec Software GmbH Munich Germany IAAL mec cam 1996 2000 MVTec Software GmbH The hastids of this computer 0 02958 0005 10 01 3 FLEXID 36e079bd Figure 2 32 Information about the current HALCON version HDevelop 2003 08 01 2 3 MAIN WINDOW 47 Help gt HALCON Operators The next menu item is Help Halcon Operators This help is based on an HTML browser see chapter 6 3 The browser will display the main page of all HALCON and HDevelop operators It 1s quite easy for you to browse through this operator menu and to find the desired operator Another possibility of requesting information about the current operator is pressing button Help inside the operator window see page 50 Help gt HDevelop Language The menu item Help HDevelop Language starts the HTML browser with a descrip tion of the language similar to chapter 3 of this manual Help gt HALCON News WWW The menu item Help HALCON News WWW lets you check for the latest news about HALCON on MVTec s WWW server e g whether new extension packages frame grab ber interfaces or HALCON versions are available 2 3 3 Tool Bar You use most ico
136. he die is rather bright Thus we can select the pixels by their gray values HDevelop 2003 08 01 5 5 BONDING 105 Figure 5 9 Examplary images with bonding balls on a die read image Bond die3 threshold Bond Bright 120 255 shape trans Bright Die rectangle2 pixels of the die that got lost by the thresholding can be recoverd by using a hull compu tation Since the die is rectangular and may be slightly turned during the assembly we use the smallest enclosing rectangle as a hull Now you can start the segmentation of wires and bonding balls Since only those parts of wires and balls are of interest that lie within the die area you may restrict the segmentation to this region dark pixels within the die area belong to wires Unfortunately there are some bright reflections on the wires that are not found by the segmentation You may fill these gaps by using fill up shape In our case the gaps with a certain size 1 up to 100 pixels are filled reduce domain Bond Die DieGray threshold DieGray Wires O 100 fill up shape Wires WiresFilled 1 100 opening circle WiresFilled Balls 15 5 connection Balls SingleBalls select shape SingleBalls IntermediateBalls circularity and 0 85 1 0 sort region IntermediateBalls FinalBalls FirstPoint True column smallest_circle FinalBalls Row Column Radius Since the balls are wider than the wires you
137. he new image File gt Cleanup The menu item File gt Cleanup deletes all unused variables iconic and control data These are variables in the variable window that are no longer used in any operator of the program This can happen after the deletion of program lines or after editing variable names because the corresponding variables are not deleted automatically You may use this menu item during a longer editing process to reorganize your variable window see also page 54 File gt Options The menu item File gt Options opens a control window which you can use to modify output behavior during runtime see figure 2 7 Options Update PC v Update variables Update Window Show Processing Time Insert Interactions Show Variable Usage Show Low Level Errors Automatic Program Save Experienced Programmer syntax HsiconDevelop Digits 12 Cancel Figure 2 7 The options window e Update PC The first item see page 48 concerns the display of the current position while run ning the program The so called PC Program Counter always indicates the line of the currently executing operator or the line before the next operator to execute Using the PC in this way 1s time consuming Therefore you may suppress this op tion after your test phase or while running a program with a lot of small operators inside a loop e Update Variables This checkbox concerns the execution of a program Every v
138. he window Default Value 256 Typical Range of Values 0 lt Height Minimal Value Step 1 Recommended Value Step 1 Restriction Height gt 0 V Height 1 Example SSS dev_close_window read image For5 for5 get image pointer For5 Pointer Type Width Height dev open window 0 0 Width Height black WindowHandle dev display For5 stop dev set window extents 1 1 Width 2 Height 2 dev display For5 stop dev set window extents 200 200 1 1 If the values of the specified parameters are correct window extents returns 2 H_MSG_TRUE If necessary an exception handling is raised oo Information window extents is local and processed completely exclusively without paralleliza tion HALCON 6 0 4 154 APPENDIX B DEVELOP ao Possible Successor Functions gt gt dev display dev set lut dev set color dev set draw dev set part See set window extents Module gt o System dev unmap Hide the window for the graphic parameters dev unmap par hides the window for the graphic parameters so that it is no longer visible It can be mapped again using the operator dev map par LLL Attention This operator is not supported for exported C code dev unmap par always returns 2 MSG TRUE LLL Parallelization Information gt dev
139. heck to declare that HDevelop should not stop if an exception occurs dev set check has to be called before and after the critical call s If we want to know which error occurred we have to specify the variable in which the return value will be stored This is done by using error var Now get mposition can be called independent of the context To check 1f the coordinates are valid the error variable is compared to one of the constants for standard return values like MSG TRUE H MSG FAIL If the call succeeded this coordinate is used to query the gray value of the corresponding pixel in the image which is then displayed in the window 5 11 Road Scene File name road signs dev The computing time is a critical factor in many image analysis tasks Thus the system has to offer features to speed up the processing But direct hardware access must be avoided in HDevelop 2003 08 01 5 11 ROAD SCENE 115 case operators should work on encapsulated data structures To allow optimization for performance data structures have to be used that support transparent and efficient programming The example segmentation of a road scene demonstrates how HALCON helps to achieve this goal Here the task is to find the middle and border road markings of a motorway The program is performed by a normal workstation with a processing time of maximum 20 ms per half image video frequency at a resolution of 512 x 512 pixels In figure 5
140. hese differ in shape size and arrangement The left side of figure 5 12 shows the input image First you extract resistors and capacitors This 1s quite simple because you have a color image and both component types have different colors The input image consists of three channels containing the red green and blue channels Since segmentation in the RGB space is difficult you have to transform the image into the HSV space Here the color information is stored in one single channel The right side of figure 5 12 shows the image representation in this channel Hue Elements that are too small can be eliminated via select shape The program sequence to extract resistors and capacitors 15 shown below HALCON 6 0 4 108 CHAPTER 5 PROGRAM EXAMPLES Figure 5 12 Board with electronic devices left and the corresponding color value image in the HSV space right read image ICs ic decompose3 ICs Red Green Blue trans from rgb Red Green Blue Hue Saturation Intensity threshold Saturation Colored 100 255 reduce domain Hue Colored HueColored threshold HueColored Blue 114 137 connection Blue BlueConnect select shape BlueConnect BlueLarge area and 150 100000 shape trans BlueLarge Condensators rectangle2 threshold HueColored Red 10 19 connection Red RedConnect select shape RedConnect RedLarge area and 150 100000 shape trans RedLarge Resistors re
141. hown on the right side of figure 5 19 The corresponding HDevelop program looks as follows See the manual Getting Started for a short introduction to the data structures used by HDevelop HALCON 6 0 4 116 CHAPTER 5 PROGRAM EXAMPLES Figure 5 19 Search areas for markings left and segmentation right MinSize 30 set system init new image false read image Motorway motorway count_seconds Seconds1 gen_grid_region Grid MinSize MinSize lines 512 512 clip_region Grid GridRoad 130 10 450 502 reduce_domain Motorway GridRoad Mask sobel_amp Mask Gradient sum_abs 3 threshold Gradient Points 40 255 dilation rectanglei1 Points RegionDilation MinSize MinSize reduce domain Motorway RegionDilation SignsGray threshold SignsGray Signs 190 255 count seconds Seconds2 Time Seconds2 Seconds dev display Signs First you create a grid by using grid region It is reduced to the lower image half with clip region The operator reduce domain creates an image containing this pattern as def inition range This image is passed to the operator sobel amp You obtain pixels with high gradient values using threshold These pixels are enlarged to the region of interest ROI by a dilation with a rectangular mask Within this region another thresholding 1s performed Correct road markings are equivalent to bright areas in the search window ROI The HALCON pro
142. i 3 Variable Watch dev close window C 4 Graphics Window dev open window 0 widhi Height dey display Clip stop 0 bin threshold Clip Dark connection Dark Single select shape Single Selected area and 5000 10000 dev set draw fill dev set colored 12 dev display Selected stop dev display lig dev set color green dev display Selected orientation region Selected Phi area center Selected Area Row Column dev zet line width 31 dew zet dravv margin Length 8n for i 2 Oto Phi 1 by 1 dew color blue disp arrow Row i calumn Raw Leneth sinrPhi i i Column i length cos Pt dev set color lorange set tposition Calumn i write string degrPhi i i deg endfor dev update window t on vy Iovi 1 Figure 2 30 Window management functions Window gt Next By using this item you bring the top window in the background Hence it looses its window focus The window to get the window focus and to become the top window 15 the window which was only hidden by the former top window If you use one of the next four items Program Window Operator Window Variable Window and Graphics Window the specified window will become the top window and gets the window focus 2 3 2 8 The Menu Item Help Here you may query information about HALCON itself and all HALCON and HDevelop oper ators Help gt About
143. ifelse is a condition with an alternative If the condition 1s true 1 not 0 all expressions and calls between the head and operator endif are performed If the condition is false 1 0 the part between else and endif is executed Note that the operator is called ifelse and it is displayed as if in the program text area Parameter p Condition Onpult collfol 2 259 244392 integer integer Condition for the if statement Default Value 1 Result ifelse returns 2 MSG TRUD if the evaluation of the expression yields no error else endif as operators always return 2 H MSG TRUE LLL Parallelization Information gt ifelse is reentrant local and processed without parallelization Alternatives S o if See Also 222 for while Module __ gt o Basic operators insert Input Value Index Result Assignment of a value into a tuple insert assigns a single value into an tuple If the first input parameter and the first output parameter are identical the call insert Areas Area Radius 1 Areas is not presented in the program text as an operator call but in the more intuitive form as Areas Radius 1 Area Parameter gt Input input control real array real integer string Tuple where the new value has to be inserted Default Value HALCON 6 0 4 130 APPENDIX A CONTROL gt Value input
144. ilar to the dialog discribed in menu item File gt Open Figure 2 6 shows an example of the Load Image File dialog Load Image File HE Look in E images 21 autobahn i angio part gif combine tif 28 bvlab 2 audi2 ti die ti fin ti bwlab hp autobahn tif egypt tif n ic tif 28 calib 1 tif engraved tif ic2 tif A fonts a bitrot tf Fabrik tif forest airl tif ic3 tif stamps bottle tit face tit forest road tf letters tif J sing ix caltab Hf ix faces tit ix horses Hf ix Marks Hf alphal tif clip tif face tif hull tif meninqg5 tif Filename Files of type Files Cancel Open as read only Figure 2 6 The dialog window to load an image HALCON 6 0 4 CHAPTER 2 GRAPHICAL USER INTERFACE After selecting a file name the name of the variable for the image the HDevelop pro eram has to be selected To do this a small dialog appears after pressing Open or double clicking a file For easy handling HDevelop suggests a name derived from the selected file name You may adopt or edit this name If you want to use a name of an already created iconic variable a combo box offers you all iconic variable names To do so you click the button on the right side of the text field Note that the reuse of a variable name deletes the old content and replaces it with t
145. ilation 8 5 complement LargeDilation NotLarge reduce domain Particle NotLarge ParticleRed mean image ParticleRed Mean 31 31 dyn threshold ParticleRed Mean Small light This method shows two advantages First the reliable model of the large particles can be used to extract the small ones This increases the quality of the segmentation Second the processing speed 15 increased as the second segmentation works only on a part of the image data The right side of figure 5 6 shows the segmentation result Unfortunately the image still contains noise To remove it you may either sort out noisy objects by their area as described above or by an opening operation We prefer the second method as it additionally smooths the object edges opening circle Small SmallClean 2 5 Here a circle is used as the structuring element of the opening operation The operator preserves regions only that may at least cover a circle of radius 2 5 Smaller regions are eliminated 4 P 2 4 a T 7 e v er 2 dp e e E2 2 y o e c o a 5 j e a vo u d Pe 7 47 4 1 ry e 5 0 ry e 5 e m spa E p oes 24 y a Figure 5 7 Noise removed segmentation left and final result right Figure 5 7 shows the result of the segmentation with n
146. in the registry under UNIX the options are stored in the subdirectory hdevelop of the directory referenced by the environment variable HOME File gt Modules The menu item File Modules opens a window in which the HALCON modules used by the current program are displayed see figure 2 8 This window allows you to get an estimate of how many modules your application would need in a runtime license Only calls to the HALCON library are taken into account for the computation of the modules and not HDevelop control structures like assign or ifelse or HDevelop operators like dev open windov or dev set color Therefore when you export your program to C C or Visual Basic the actual number of modules required may be higher than the modules displayed in the Module window depending on how many operators you add to the program e g for visualization purposes By clicking Save the modules required by the current program are saved in a file with the extension mod in the currently used directory File gt Quit The menu item File gt Quit terminates HDevelop without saving the current program File History At the bottom the menu File displays the most recently loaded files 2 3 2 2 Menu ltem Edit In this menu item you find all necessary functions to modify a HDevelop program in the pro gram window see chapter 2 4 You have the following items to choose from HDevelop 2003 08 01 2 3 MAIN WINDOW 19 Used Modules
147. included into brackets see figure 3 1 Tuple constant Value string C Value integer 2 gt real gt boolean Figure 3 1 The syntax of tuple constants oq Lol L specifies the empty tuple A tuple with just one element is to be considered as a special case because it can either be specified in the tuple notation or as an atomic value 55 defines the same constant as 55 Examples for tuples are 4711 0 815 16 100 0 100 0 200 0 200 0 FileName Extension 4711 0 815 Hugo The maximum length of a tuple is limited to 1000000 3 3 Variables Names of variables are built up as usual by composing letters digits and the underscore _ The maximum length of a variable name 15 limited to 256 characters The kind of a variable iconic or control variable depends on its position in the parameter list in which the variable identifier is used for the first time see also chapter 3 1 The kind of the variable is determined during the input of the operator parameters whenever a new identifier appears a new variable with the same identifier 15 created Control and iconic variables must have different names The value of a variable iconic or control is undefined until the first assignment defines it the variable hasn t been instantiated yet A read access to an undefined variable
148. ing types integer real boolean and string integer and real The types integer and real are used under the same syntactical rules as in C Integer numbers can be input in the standard decimal notation in hexadecimal by prefixing the number with Ox and in octal by prefixing the number with 0 For example 4711 123 Oxfeb12 073421 73 815 0 32214 400 17 32e 122 32E19 Data items of type integer or real are converted to their machine internal representa tions real becomes the C type double 8 bytes and integer becomes the C type long 4 or 8 bytes string A String string is a sequence of characters that is enclosed in single quotes The maximum string length is limited to 1024 characters Special characters like the line feed are represented in the C like notation as you can see in table 3 2 see the reference of the C language for comparison Examples of strings are shown in table 3 3 HDevelop 2003 08 01 3 2 CONTROL TYPES AND CONSTANTS 63 Abbreviation line feed horizontal tabulator vertical tabulator backspace carriage return form feed bell backslash single quote Table 3 2 Surrogates for special characters Hugo letters 10 9 numbers not real Text n NL at the end of the string t Texti Nt Text2 two tabs in a text Sobel s edge filter single quote within the text gt c Programs MVTec Halcon images Directory Table 3 3 String examples b
149. int For an explanation see item Visualization gt Paint If you want to specify all possible parameters of a given paint mode you have to specify them as a tuple analogously to the HALCON operator set paint e dev set shape For an explanation see item Visualization gt Shape e dev set part This operator adjusts the coordinate system for image region XLD and other graphic output This is done by specifying the upper left and the lower right corner coordinates This specified part 1s shown in the entire graphics window If the width or height of the specified rectangle has a negative value e g Row1 gt Row2 the result is equivalent to the menu Visualization gt Zooming gt Reset the zoom mode is switched off 1 e the most recently displayed 1mage fills the whole graph ics window This feature of dev set part is not supported for exported C and Visual Basic code e dev display Iconic variables are displayed in the active graphics window by this opera HALCON 6 0 4 40 CHAPTER 2 GRAPHICAL USER INTERFACE tor It is reasonable to do this when the automatic output is suppressed see dev update window and File gt Options onpage 16 dev clear obj This operator deletes the iconic object stored in the HDevelop variable that is passed as the input parameter In the variable window the object is displayed as undefined with a as its icon dev inspect ctrl This operator opens an inspection window displaying
150. integer integer HALCON 6 0 4 132 APPENDIX A CONTROL while Button 1 dev set color get mbutton WindowID Row Column Button dev display Image dev display SmallConnection dev set color red select region point SmallConnection SmallSingle Row Column dev display SmallSingle NumSingle SmallSingle if NumSingle 1 intensity SmallSingle Image MeanGray DeviationGray area center SmallSingle Area Row Column dev set color yellow set tposition WindowID Row Column write string WindowID Area Area Int MeanGray endif endwhile dev set line width 1 dev update window on while returns 2 MSG TRUD if the evaluation of the expression yields no error endwhile as operator always returns 2 MSG TRUE Parallelization Information while 15 reentrant local and processed without parallelization Alternatives for See Also 44040446 4 46464 2 if ifelse Module Basic operators HDevelop 2003 08 01 Appendix B Develop Delete an iconic object from the HALCON database dev_clear_obj deletes iconic objects which are no longer needed from the HALCON database It should be noted that dev_clear_obj cannot be exported to C due to the au tomatic memory management in Affe Never use clear_obj to clear objects in HDevelop operator dev_clear_obj has to be used instead Pa
151. into a string Finally the proportion of the cell wall in percent is concatenated to the string At this it is important that the first or second value of the expression is a string so that the following numbers are converted into strings Here denotes the concatenation of characters instead of the addition of numbers 5 9 Region Selection File name eyes dev This example explains how to handle single iconic objects In contrast to numerical data where many different functions may be executed on parameter positions see chapter 3 5 iconic ob jects may only be handled by using HALCON operators The most important operators to select and combine iconic objects are shown in this example The task 1s to search the eyes of the mandrill in figure 5 17 This is a simple task First we extract the bright parts by a thresholding Then we have to examine the connected components according to their shape and size to select the eyes At this you could use the operator select shape and get a fast program of five lines that processes the task For demonstration purpose we use a kind of low level version instead every region is extracted separately and examined afterwards If it conforms to a given shape it is added to a result variable HDevelop 2003 08 01 5 10 EXCEPTION HANDLING 113 Figure 5 17 Mandrill and the detected result dev close window read image Image monkey threshold Image Region 128 255 connecti
152. ion with dev_error_var which allows to check for the result state of an operator oO Attention If dev_set_check should be used for exported Code C please note the description of set_check due to the different semantics in C Parameter gt gt Mode Gnput comOl string string Mode of error handling Default Value give error Example SSS dev_close_window dev open window 0 0 512 512 black WindowHandle dev error var Error 1 dev set check give error FileName wrong read image Image FileName dev set check give error headError 2 Error if ReadError H MSG TRUE write string WindowHandle wrong file name FileName endif Now the program will stop with an exception read image Image FileName LLL Redt o dev set check always returns 2 H MSG TRUE LLL Parallelization Information dev set check is local and processed completely exclusively without parallelization Possible Successor Functions dev error var See Also i o set_check Module System dev set color ColorName Set output color dev set color defines the color for region and line oriented output in the graphics windows The available colors can be queried with the operator query_color colors black HALCON 6 0 4 144 APPENDIX B DEVELOP and white are available for all screens I
153. ith HDevelop You see the items in figure 2 30 This menu item is not supported in a UNIX environment because ac cording to the X Windows style we don t have a main window with a functionality similar to Windows Window gt Cascade By pressing this item HDevelop arranges the four windows in a cascade as you can see in figure 2 30 Window gt Tile When selecting this item you see all four windows inside the main window They have the same size and fit exactly in the main window Thus you get a global view of the windows contents at once Notice that the four windows may shrink depending on their size to fit in the main window Figure 2 31 shows you the effect using this item Window gt Arrange Icons As in every system using windows you are able to iconify and deiconify your windows You may even move your icons on the display This might create a confusing working en vironment if you are handling several graphics tools simultaneously To get the HDevelop icons back on top of the main window s status bar you just have to press this button Because there are many entries in the left keyword list you may see all marked keywords only by scrolling it HDevelop 2003 08 01 2 3 MAIN WINDOW 45 HDevelop 2 dev Ele Edit Execute Visualization Operators Suggestions PT Help sone Variable Watch Next Ico Graphics Window 1 Program Zope get image pointer Clip Width He
154. lack gt WindowHandle output control window integer Window identifier Example SSS dev_close_window read_image For5 for5 get image For5 Pointer Type Width Height dev open window 0 0 Width Height black WindowHandle dev display For5 set lut rainbow dev display For5 stop dev set lut default dev display For5 stop dev set part 100 100 300 300 dev display For5 LLL Reato If the values of the specified parameters are correct dev open window returns 2 H_MSG_TRUE If necessary an exception handling is raised oo Information windov is local and processed completely exclusively without parallelization 81 Successor Functions SSS dev display dev set lut dev set color dev set draw dev set part Alternatives _ open window See Also i o query color Module 7 System dev set check Mode Specify the error handling HDevelop 2003 08 01 143 dev set check specifies how HDevelop should react 1f an error occures If Mode has the value give error which is the system default HDevelop stops the program execution if an ex ception occures and displays an error message If you use give error the exception will be ignored and the program continues dev set check is intended to be used in connect
155. layed new typically this happens about 60 70 times per second So it is possible to change the look up table to get a new look of images or regions Please remind that not all machines support changing the look up table e g monochrome resp truecolor For common monitors only one look up table can be loaded per screen Whereas dev set lut can be activated separately for each window There is the following solution for this problem It will always be activated the look up table that 1s assigned to the active window a window is set into the state active by placing the mouse inside the window look up tables can also be used with truecolor displays In this case the look up table will be simulated in software This means that the look up table will be used each time an image is displayed query lut lists the names of all look up tables LLL Attention 2 If dev set lut should be used for exported Code C please note the description of set lut due to the different semantics in HALCON 6 0 4 148 APPENDIX B DEVELOP Parameter o o o gt LutName input control 22 string string Name of look up table values of look up table RGB or file name Default Value default Value Suggestions LutName c default linear inverse sqr inv sqr cube inv cube sqrt inv sqrt cubic root
156. le particle threshold Particle Large 110 255 The variable Large contains all pixels whose gray values are brighter than 110 You can see the result on the right side of figure 5 5 It is more difficult to find the small dark particles A first effort to specify a threshold inter actively shows that there 1s no fixed threshold suitable to extract all particles But if you look closer at the 1mage you will notice that the smaller particles are much brighter than their local environment 1 you may specify suitable threshold values that are valid for a small image part HDevelop 2003 08 01 5 8 PARTICLES 101 each Now it is easy to transform this observation into an algorithm One way is to determine the threshold values locally e g from a bar chart Another solution might be the definition of a local environment by an n x n window This method is used in the example The window s mean value is used as an approximation of the background intensity This can be done by ap plying a low pass filter such as a mean filter or a Gaussian filter The window size n defines the size of the local environment and should approximately be twice as large as the objects to search for Since they show an average diameter of 15 pixels a mask size of 31 1s used The resulting pixels are specified by the comparison of the original gray values with the mean image To reduce problems caused by noise you add a constant to the mean image 3 The
157. le e g dev set color On the other hand some low level operators exist like reset obj db or clear_obj that will bring HDevelop of balance Not the whole functionality of HDevelop can be transferred to a C program because the graphics windows of HDevelop are more comfortable than the simple HALCON windows However the points described above are very special and will not bother the normal user because the appropriate functions can be found in both working environments If you use dev set color in HDevelop for example you would use set color as its counterpart in HALCON C Further restrictions can be found in section 4 1 4 HALCON 6 0 4 122 CHAPTER 6 MISCELLANEOUS HDevelop 2003 08 01 Appendix A Control assign Input Result Assign a new value to a control variable assign assigns a new value to a variable In HDevelop an assignment is treated like an op erator To use an assignment you have to select the operator assign Input Result This operator has the following semantics It evaluates Input right side of assignment and stores it in Result left side of assignment However in the program text the assignment is repre sented by the usual syntax of the assignment operator The following example outlines the difference between an assignment in C syntax and its transformed version in HDevelop The assignment in C syntax u sin x cos y is defined in HDevelop using the assignment
158. lected part of the image object when you leave the graphics window This enables you to have a meaningful display in the zooming tool whenever you want to do actions outside of the graphics window Visualization gt Gray Histogram Info This menu item opens a sophisticated tool for the inspection of gray value histograms that can also be used to select thresholds interactively and to set the range of displayed eray values dynamically Figure 2 17 shows the layout of the gray histogram inspection window When opening the tool the histogram of the image shown in the currently active graphics window 15 displayed When the tool 15 already open four modes of sending new image data to the tool are available The simplest mode 15 to display an image in the active graph ics window Whenever you do so the histogram of this image is computed and drawn and the tool records the graphics window from which the image was sent Another sim ple method to send new data to the tool is to single click into an image that is displayed in a graphics window The third mode can be used whenever image data 16 displayed overlaid with region data in a graphics window the graphics window does not need to be active for this In this mode you can click into any of the segmented regions and the histogram of the image within that region will be computed and shown If you click into a part of the image that 1s not contained in any of the overlaid regions the histogram of
159. loop is entered if the start value is larger or equal to the end value Each time the body is HDevelop 2003 08 01 3 7 CONTROL STRUCTURES 81 executed the loop index is incremented by the incrementation value If the loop index 15 equal to the termination value the body of the loop is performed for the last time If the loop index is larger than the termination value the body will not be excecuted any longer Please note that the loop index does not need to become equal to the termination value in order terminate the loop The loop index 15 set to the termination value when the loop is being left The loop can be terminated immediately with the instruction break see below Please note that the expressions for start and termination value are evaluated only once when entering the loop modification of a variable that appears within these expressions has no influence on the termination of the loop The same applies to the modifications of the loop index It also has no influence on the termination The loop value 15 as signed to the correct value each time the for operator is executed For more details see section 4 4 2 on the code generation of for loops If the for loop is left too early e g if you press Stop and set the PC and the loop is entered again the expressions will be evaluated as 1f the loop were entered for the first time for loop value lt Start gt to End by lt Increment gt endfor In the followin
160. ls in the image using a threshold ing operation In this case a segmentation using the simple thresholding operator threshold HDevelop 2003 08 01 1 2 EXAMPLE SESSION 5 does not result in a satisfying output Hence you have to use the dynamic thresholding op erator dyn threshold For execution you need the original image 1 the interpolated full image and an image to compare containing the thresholds You obtain this image by us ing the smoothing filter e g mean image As input image you choose your original image ImageFilled After estimating the marks size in pixels you specify a filter size which is approximately twice the marks size compare the HALCON Reference Manual entry for dyn threshold To choose the operator mean image you traverse the menu hierarchy Operators gt Filter gt Smoothing gt mean image It will be displayed in the operator window immediately Now you specify the image variable names ImageFilled in the text field called Image and ImageMean in the output text field The filter matrix size 1s chosen by opening the combo boxes of the corresponding text fields MaskWidth MaskHeight These combo boxes contain a selection of reasonable input values which 15 offered by HDevelop our example the size 15 set to 29 see figure 1 2 By clicking the button OK you insert the operator mean image in the program and execute it Now you have to search for the name of the dynamic thresholding For this you s
161. mbo box disappears Now the operator s parameters are shown in the operator window If you are already more familiar with HDevelop it is reasonable to select an operator in the operator name field However in order to do so you obviously have to be familiar with the operator names 2 5 2 Parameter Display The parameter display is the main part of the operator window It is empty in its initial state If you have selected an operator HDevelop displays the operator s parameter data 1 e name number type and default values in the display e first column of the operator window you find the parameter names HDevelop 2003 08 01 2 5 OPERATOR WINDOW 51 HDevelop File Edit Execute Visualization Operators Suggestions Window Help oem s males e p tin Operator B x ww Operator read ocr trainf names read ocr trainf select Figure 2 36 Operator selection in the operator name field e The second column consists of the text fields which contain variable names in case of iconic and control output parameters and expressions in case of control input parameters If you want to change the suggestions offered by the system variable names or default values you may do so either manually or by pressing the arrow button connected with the respective text field This opens a list containing a selection of already defined variables and other reasonable values from the operator knowledge b
162. meanDiameter 37 6264463801 7700447744604 Smooth by averaging Figure 2 27 Menu hierarchy of all HALCON operators responding Develop operator e g dev open window instead of open window within HDevelop Some operators e g reset obj db cannot be called at all within HDevelop 2 3 2 6 The Menu ltem Suggestions This menu shows you another possibility how to select HALCON operators But here they are proposed to you in a different manner It is assumed that you have already selected or executed an operator in a previous step Depending on this operator five different suggestions are offered Figure 2 28 shows possible successor suggestions for operator read image Suggestions are separated into groups as follows ouggestions gt Predecessor Many operators require a reasonable or necessary predecessor operator For example be fore computing junction points in a skeleton junctions skeleton you have to com pute this skeleton itself Skeleton To obtain a threshold image you have to use a low pass filter before executing a dynamic threshold dyn threshold Using the watershed algorithms watersheds it is reasonable to apply a smoothing filter on an image first because this reduces runtime considerably HDevelop 2003 08 01 2 3 MAIN WINDOW 43 HDevelop File Edit Execute Visualization Operators lt window Help 28 E IgE Altematives k zl See alza Pred
163. n menu item Operators gt Regions gt Transformations The input region RegionDynThresh is specified in the text field Region The output variable s default name ConnectedRegions is changed to ConnectedRegionsDynThresh After the operator s exe cution all resulting regions are stored in this output variable This shows a great advantage of HALCON s tuple philosophy although you have several different results you do not have to worry how to handle them This is done transparently by HALCON HALCON operators rec ognize a tuple type variable and process it accordingly This results in more compact programs because you may combine several similar operator calls in one operator To obtain a better visualization of the results after calling connection you select the menu Visualization gt Colored Here you specify the 12 predefined color presentation Now every computed region receives one of the 12 colors This presentation mode is very useful to indicate each region with a different color If there are more than 12 regions the system uses the same color for several different regions With dev display of the image ImageFilled you refresh the graphics window to see the results of next step much better Select the menu perators gt Develop gt dev display File Edit Execute Visualization Operators Suggestions Window Help Dg e Haee 1s I 0 ead image sis marks ee ae ointer1 Christof Pointer
164. n variable icons Besides this there are three exceptions which are shown by special icons e Empty variables are displayed as a question mark icon You may to write but not read them because they do not have any values e Brackets are used if a variable 15 instantiated but does not contain an iconic object empty tuple This may be the case using operators like select shape with wrong specified thresholds or using operator empty obj Such a value might be reasonable if you want to collect iconic objects in a variable gradually in a loop concat obj Here an empty tuple is used as starting value for the loop e A last exception is an empty region This is one region that does not contain any pixels points 1 e the area number of points is You must not confuse this case with the empty tuple because there the area 1s not defined The empty region is symbolized by an empty set icon 2 6 2 Area for Control Data To the right of the variable name you find their values in the default representation If you specify more than one value for one variable tuple they are separated by commas and enclosed by brackets If the number of values exceeds an upper limit the output is clipped This 15 indicated by three dots at the end of the tuple For empty variables their name and a are shown in the variable field An empty tuple is represented by Both exceptions use the same symbols as the corresponding cases for the
165. n2 the two input tuples have to be of equal length Table 3 15 shows the provided trigonometric sin a sineofa cos a cosine of a tan a tangent of a asin a arc sine of a in the interval 7 2 7 2 a acos a arc cosine a in the interval 7 2 7 2 a atan a arc tangent a in the interval 7 2 1 2 a 1 1 atan2 a b arc tangent a b in the interval 7 7 sinh a hyperbolic sine of a cosh a hyperbolic cosine of a tanh a hyperbolic tangent of a Table 3 15 Trigonometric functions functions For the trigonometric functions the angle is specified in radians 3 5 11 Exponential Functions All these functions work on tuples of numbers as arguments The input can either be of type integer or real However the resulting type will be of type real The functions are applied to all tuple values and the resulting tuple has the same length as the input tuple For pow and ldexp the two input tuples have to be of equal length Table 3 16 shows the provided exponential functions 3 5 12 Numerical Functions The functions min and max select the minimum and the maximum values of the tuple values All values either have to be of type string or integer real It is not allowed to mix strings with numerical values The resulting value will be of type real if at least one of the elements HDevelop 2003 08 01 3 5 EXPRESSIONS FOR INPUT CONTROL PARAMETERS 77 exponential function e natural logarithm
166. ncatenation Areas Areas Area could be used because the element is appended at the back of the tuple More examples can be found in the program assign dev 3 5 3 Basic Tuple Operations A basic tuple operation may be selecting one or more values combining tuples concatenation or reading the number of elements concatenation of tuples number of elements selection of an element selection of a part of a tuple Table 3 7 Basic operations on tuples The concatenation accepts one or more variables or constants as input They are all listed between the brackets separated by commas The result again is a tuple t1 t2 is the concatenation of tuple t and t Example 5 Text 5 911 5 Text 5 9 So even the following holds t t t t returns the number of elements of a tuple The indices of elements range from zero to the number of elements minus one 1 t 1 Therefore the selection index has to be within this 2 range Please note that the index of objects e g select object ranges from 1 to the number of elements HDevelop 2003 08 01 3 5 EXPRESSIONS FOR INPUT CONTROL PARAMETERS 69 Tuple V1 V2 V3 V4 for O to Tuplel l by 1 fwrite string FileHandle Tuple i n endfor There are no direct operations on parameter position for the handling of iconic variables This means that single iconic objects cannot be directly selected using and their num
167. nd processed without parallelization HDevelop 2003 08 01 See Also exit Module Basic operators while Condition Continue to execute the body as long as the condition is true 131 while executes the body as long as the condition is true The while loop has a boolean ex pression as the conditional part As long as it is true 1 e not equal 0 the body of the loop 1s performed In order to enter the loop the condition has to be true in the first place Parameter gt Condition input control uu eux uk odor nier an CAO RC Ch E IR Condition for loop Example dev update window off dev close window dev open window 0 0 512 512 black WindowID read image Image particle dev display Image stop threshold Image Large 110 255 dilation circle Large LargeDilation 7 5 dev display Image dev set draw margin dev set line width 3 dev set color green dev display LargeDilation dev set draw fill stop complement LargeDilation NotLarge reduce domain Image NotLarge ParticlesRed mean image ParticlesRed Mean 31 31 threshold ParticlesRed Mean SmallRaw 3 light opening circle SmallRaw Small 2 5 connection Small SmallConnection dev display Image dev set colored 12 dev display SmallConnection stop dev set color green dev display Image dev display SmallConnection Button 1
168. ng 111 gen grid region 1106 gen region line 103 gen tuple const 70 get mbutton 102 get grayval 114 get image pointeri 110 get mposition 114 get system 93 Gnuplot 111 Graphics 140 152 Graphics window Close 39 Position 39 Graphics window 9 56 93 159 Activate 39 Clear 25 Close 25 Color 32 Draw 32 History 58 Line width 32 Look up table 32 35 Open 23 3 39 Paint 32 33 Parameter 38 Pen 33 Reset 25 Size 31 39 Zoom 31 34 gray histo 27 gray inside 106 H MSG FAIL 63 85 114 H MSG FALSE 63 85 MSG TRUE 63 85 114 H MSG VOID 63 85 Help 45 History 58 133 140 Iconic data 159 Iconic object 54 61 112 159 Iconic Object 133 163 if 35 79 128 159 ifelse 35 80 129 Image 54 159 Image analysis 41 insert 35 37 67 69 85 129 Insertion cursor 48 Inspection 137 intensity 30 Interaction 119 Internet Explorer 120 Interpreter 9 Intersection 110 intersection 103 junctions skeleton 42 Keyboard shortcuts lt Ctrl gt 20 Ctrl F 20 Ctrl G 20 lt Ctrl gt 21 Ctrl N 12 Ctrl 0 12 lt Ctrl gt P 14 Ctrl S 14 Ctrl V 19 20 Ctrl Z 19 5 21 6 22 F9 22 119 Language definition 61 Laws filter 98 Loop 37 126 131 Body 159 Lut 35 Main window 9 10 Menu bar 11 Title bar 11 Tool bar 47 mean image 99 103 Memory management 97 Menu bar 38 min max gra
169. ng operators and manage the HDevelop windows After starting HDevelop you will see a window configu ration similar to figure 2 1 The main window comprises five areas e atitle bar e amenu bar a UNIX environment the main window comprises the program window and the operator window It has no special Window manager functionality like e g in Windows NT HDevelop 2003 08 01 2 3 MAIN WINDOW 11 HDevelop OF x File Edit Execute Visualization Uperstors Suggestions Window Help Bee s sse e vete 1188 Operator Op Variable Watch 15 Ico Graphics Window Mn x Clear Active Col E 4 __ Figure 2 1 The main window e atool bar e a window area and e astatus bar In the following chapters you will find all necessary information to interact with this window 2 3 1 Title Bar Your HDevelop main window is identified by the title HDevelop in the window s title bar After loading or saving a file the file name will be displayed in the title bar Additionally it offers three buttons on the right hand side to iconify and to maximize the window and to exit the HDevelop session 2 3 2 Menu Bar In the menu bar of the main window HDevelop functionality is offered Here you may perform the important actions to solve your image processing tasks 1 to choose any HALCON or HDevelop operators or to manipulate the graphical output Every menu item opens a pull
170. ng the menu Edit see sections 2 3 2 2 or the tool bar see sections 2 3 3 Further information on the use of the mouse can be found in section 2 2 2 5 Operator Window This window is mainly used to edit and display an operator and all its parameters Here you will obtain 1nformation about the number of the operator s parameters the parameter types and parameter values You are able to modify the parameter values according to your image processing tasks For this you may adopt the proposed system values or specify your own values The operator window consists of the following three parts e The first one 15 the operator text field e The second one 15 the largest part It is called parameter display and 15 used to edit the parameters of an operator e The last one is a row of buttons to control the parameter display 2 5 1 Operator Name Field The operator name field 1s another possibility to select operators You simply have to enter a substring of an operator name By pressing Return or pressing the button of the combo box the system 1s looking for all operators in the menu Operators that contain the user specified substring see figure 2 36 If there 16 an unambiguous search result the operator is displayed immediately in the operator window If there are several matching results a combo box opens and displays all operators containing the specified substring By clicking the left mouse button you select one operator and the co
171. ns in this tool bar to accelerate accessing important HDevelop features These are features which you are performing many times while working with HDevelop Hence there are buttons to handle your HDevelop programs and to edit them The most important buttons are used to start and to stop a program or parts of a program These icons are explained in figure 2 34 osla x ese S I E i I Figure 2 33 The HDevelop tool bar 2 3 4 Window Area The window area contains all necessary windows to show your HDevelop programs to visual ize your iconic and control results and to specify any operator s parameters Additionally you may open as many graphics windows as you want to get a detailed view of your iconic results You are free to move the windows according to your needs and preferences inside this area You may iconify and or deiconify them To handle these windows in a comfortable way HDevelop supports you with some window management functions see 2 3 2 7 2 3 5 Status Bar The status bar at the bottom of the program window shows you information which is important while working with HALCON e g context sensitive information about a specific user action or the operator runtime if time measurement has not been deactivated HALCON 6 0 4 48 CHAPTER 2 GRAPHICAL USER INTERFACE These icons are shortcuts for the menu items File gt New File gt Load and File gt Save in the menu bar For a detailed descripti
172. o develop image analysis applications using HDevelop e Rapid prototyping in the interactive environment HDevelop You can use HDevelop to find the optimal operators or parameters to solve your image analysis task and then build the application using the programming languages C C or COM Visual Basic e Development of an application that runs within HDevelop Using HDevelop you can also develop a complete image analysis application and run it within the HDevelop environment e Export of an application as C C or COM source code Finally you can export an application developed in HDevelop as C C or COM source code This program can then be compiled and linked with the HALCON library so that it runs as a stand alone console application Of course you can also extend the generated code or integrate it into existing software Let s start with some facts describing the main characteristics of HDevelop followed by an example session in section 1 2 1 1 Facts about HDevelop While developing programs HDevelop actively supports the user in different ways O With the graphical user interface of HDevelop operators and iconic objects can be di rectly selected analyzed and changed within one environment O HDevelop suggests operators for specific tasks In addition a thematically structured operator list helps you to find an appropriate operator quickly O An integrated online help contains information about each HALCON operat
173. o o Pos EERE odo OD deos 137 226526 ewe x 9E A dk A dm d 138 DLE eee ee E 139 noua xou E WoR RO ROROROR OE x 139 140 SUE 40 0 MEET 142 ERES EDU x29 x kx ERG RORIM RE Amo CORO 4 od 143 COC AEG uu om ou oe wok REG x9 4 4343e24244254593333 144 a ssa 39349 59994 0 ow 145 dev_setline width 146 2252 56 5554 147 we ee ee ee ee we eG 148 2 55 HAE EEE Ee eS 149 9 3 5 Bu du dedok Ro d dp 150 _ _ 152 dev_set window extents 152 154 UOV DEDE cu carae dod dee RISE dE d E d usd Ad 3 154 dev_unmap var 155 155 PC REA RHE SD oR 156 dev_update var 156 dev_update windoWw eee x X EAA 56 o ded ew ee 157 C Glossary 159 Index 161 Chapter 1 Introducing HDevelop In fact HDevelop is more than a graphical user interface to HALCON It 1s a highly interactive programming environment for the development of image analysis applications There are three basic ways t
174. oblem it is helpful to describe characteristic attributes of the objects to be searched here stamps This task can be solved by a novice with some experience too In this case a characterization might look as follows e Stamps are darker than paper e Stamps are connected image areas that do not overlap e Stamps have a minimum and maximum size 95 96 CHAPTER 5 PROGRAM EXAMPLES 1421 50 C mehrfarbig 1422 80 C mehrfarbia Bal 1417 35415 C 1418 50 20 C 1419 80 40 C mehrlarbig 4 35 3 50 1420 90 40 C 450 4 1430 5024 25 C mehrfar 350 3 50 131 Salz 4 W 12 50 11 Foe a Block i 15 15 Figure 5 1 Part of the page of a Michel catalog e Stamps are rectangular The task would be very simple if the attribute list would directly represent the program Unfor tunately this is not possible due to the ambiguity of spoken language Thus you need language constructs with a precise syntax and a semantics that are as close as possible to the informal description Using the HDevelop syntax an appropriate program would look like this HDevelop 2003 08 01 5 2 CAPILLARY VESSEL 97 dev close window read image Catalog swissi tiff get image pointer1 Catalog Pointer Type Width Height dev open window 0 0 Width 2 Height 2 black WindowID dev set part 0 O Height 1 Width 1 dev set draw 741117 threshold Catalog Dark O 1
175. ody occurs in the correct place This body is indented to make the nesting level of the control constructs visible and thus to help you in understanding the program structure see figure 2 25 To get an idea how to use loops you may look at the example session in section 1 2 and at the programs in chapters 5 3 5 8 and 5 9 The semantics for loops and conditions are shown in chapter 3 7 Program dev open weindowe 0 0 width Height black window ID dev set_dravy fill dev set part 0 0 Height 1 Yvidth 13 threshold Image Region 128 255 dev set color white connection Region ConnectedRegions select shape ConnectedRegians CompactRegioanz campactness and 1 5 1 8 Number CompactRegionsz gen empty obj Eyes for i 2 1 to Number by 1 SingleSelected CompactRegians i area center SingleSelected Area Row Column dev zet color areen if 4rea 500 and amp rea SO000 dev set color red Eyes SingleSelected Eyes endif endfor dev display mage dev set color red Figure 2 25 Example for using a for loop The operator assign serves as an assignment operator for control variables numbers and strings Analogously to normal operators the input is made in the operator win dow by specifying both parameters Input and Result 1 right and left side of the assignment An instruction in C e g x bz is declared inside the operator window as assacn 2 and displ
176. of Visual Basic programs all window operations are suppressed because the exported code 15 intended to work together with the Visual Basic template If you want to use more than one window in Visual Basic you have to modify the code and project manually Note that the export of programs containing multiple windows to or C might be incorrect if the Activate button was used during program execution e Window size In exported Visual Basic programs the size of the window in the panel 15 predefined 512 x 512 thus it will normally not fit to your image size Therefore you must adapt the size interactively or by using the properties of the window e Displaying results Normally the result of every operator 15 displayed in the graphics window of HDevelop This is not the case when using an exported program It behaves like the HDevelop pro gram running with the options update window off We recommend to insert the operator dev display in the HDevelop program at each point where you want to dis play data This will not change the behavior of the HDevelop program but result 1n the appropriate call disp image disp region etc in the exported code When generating code for C close the default graphics window using dev close window and open a new one using dev open window before the first call of display in order to assure a correct export HALCON 6 0 4 94 CHAPTER 4 CODE GENERATION e Displaying images
177. of the green arrow which is used as the program counter PC see chapter 2 4 The mouse pointer changes its shape to a clock This indicates that HDevelop is active and not available for any user input After the operator has terminated all computed values are assigned to their respective variables that are named in the ouput parameter positions Their graphical or textual representation in the variable window 15 also replaced If iconic data has been computed you will see its presentation in the current graphics window In the status bar of the program window the operator runtime is indicated if the time measurement has not been deactivated The PC 15 set before the next operator to execute If the operators are specified in a sequential order this is the textual successor In case of control statements e g if endif or for endfor the PC is set on the end marker e g endif or endfor after the execution of the last operator inside the statement s body After endfor and endwhile the PC 15 always set the beginning of the loop If a condition as if or while evaluates to FALSE the PC 1s set behind the end marker Suggestions in the menu Suggestions are determined for the recently executed operator Finally the mouse pointer s shape switches to the arrow shape and HDevelop 15 available for further transactions Any user input which has been made during execution is handled now Execute gt Stop keyboard shortcut F9 You ma
178. oise removal on the left side The right side contains the final result Finally we would like to show within this example how to select regions with the mouse 1n teractively At this a loop 1s executed until you press the middle or right mouse button When pressing a mouse button the operator get mbutton returns the button that was pressed and the position coordinates where it was pressed This information is used to select the chosen object In the following you see the corresponding program part HDevelop 2003 08 01 5 4 ANNUAL RINGS 103 dev clear window WindowID connection SmallClean SmallSingle Button 1 dev set color while Button 1 get mbutton WindowID Row Column Button select region point SmallSingle OneObject Row Column intensity OneO0bject Particle MeanGray Deviation endwhile First the window is cleared via dev clear window After that connection calculates all connected components to allow the selection of single regions This also displays the region components in the HDevelop window Then you may set the drawing color here red to visualize the selected regions The loop is initialized by assigning 1 to the variable Button 1 is the code for the left mouse button Within the loop the mouse state 1s queried and the chosen region is selected As an example the mean gray value and the standard deviation are computed for each selected region As long as you press only the left mouse
179. olumn specify the new position upper left corner of the window If one of both values 15 negative the position will remain unchanged The parameters Width and Height specify the new size of the window This is the size of the inner part that actually displayes the data If one of the two values 1s negative the size will remain unchanged LLL Attention 0000000000000 Never use set window extents to change the size and position of an HDevelop graphics win dow The operator dev set window extents has to be used instead HDevelop 2003 08 01 153 Parameter Row MPU xau gs e eikean He are te IU RH rectangle origin y integer Row index of upper left corner Default Value 0 Typical Range of Values 0 lt Row Minimal Value Step 1 Recommended Value Step 1 Restriction Row gt 0 V Row 1 Column input control rectangle origin x integer Column index of upper left corner Default Value 0 Typical Range of Values 0 lt Column Minimal Value Step 1 Recommended Value Step 1 Restriction Column gt 0 V Column 1 Width input control rectangle extent x integer Width of the window Default Value 256 Typical Range of Values 0 lt Width Minimal Value Step 1 Recommended Value Step 1 Restriction Width gt 0 V Width 1 Height input control rectangle extent y integer Height of t
180. on Region ConnectedRegions select shape ConnectedRegions CompactRegions compactness 15 125 Number CompactRegions Eyes for i 1 to Number by 1 SingleSelected CompactRegions i area_center SingleSelected Area Row Column dev set color green if Area gt 500 and Area lt 50000 dev set color Eyes SingleSelected Eyes endif endfor Note that you have to specify the number of regions count obj in order to run a for loop from 1 to Number Within this loop a region is selected select obj according to the loop variable i in order to evaluate its attributes If its area 1s within certain bounds the region 1s added to variable Eyes concat_obj You have to specify the variable Eyes properly as it is also used as input for concat obj This can be done by using empty object that assigns no iconic object in a defined way to the variable 1 count obj returns zero for it During the run time of the program you can see how the individual regions are selected and examined To speed up the processing you can use the menu File gt Options to suppress the automatic output 5 10 Exception Handling File name exception dev HALCON 6 0 4 114 CHAPTER 5 PROGRAM EXAMPLES In some applications it 1s necessary to have explicit control over the result state of an operator By default HDevelop stops if an operator returns a different state than MSG TRUE and gives an error messag
181. on see page 1 2ff These 1cons are shortcuts for the menu items Edit gt Cut Edit gt Copy Edit gt Paste and Edit gt Undo in the menu bar For a detailed description see page 1 8ff These icons are shortcuts for the menu items Execute gt Run Execute gt Step and Execute gt Stop in the menu bar For a detailed description see page 211 These icons are shortcuts for the menu items Execute gt Activate Execute gt Deactivate and Execute gt Reset Program in the menu bar For a detailed descrip tion see page 211f This icon 18 a shortcut for the menu item Visualization D Set Parameters in the menu bar For a detailed description see page 231 These icons are shortcuts for the menu items Visualization Pixel Info Visualization gt ZOOMING sss Visualization gt Gray Histogram Info and Visualization gt Region Info inthe menu bar For a detailed description see page 231 Figure 2 34 The different parts to the HDevelop toolbar 2 4 Program Window The program window 15 divided into two areas The left one a small column contains the program counter PC represented as a green arrow pointing to a program line the insertion cursor a triangle between two program lines and optionally one or more break points BP a red STOP sign You may position or activate these three labels as follows e The PC is set by pressing the left mouse button only e The insertion cursor 15 set by pressing th
182. oolean The constants true and false belong to the type boolean The value true is internally represented by the number 1 and the value false by 0 This means that in the expression Val true the effective value of Val is set to 1 In general every integer value 0 means true Please note that some HALCON operators take logical values for input e g set system In this case the HALCON operators expect string constants like true or false rather than the represented values true or false constants There are constants for the return value result state of an operator The constants can be used together with the operator dev error var dev set check These constants represent the normal return value of an operator so called messages For errors no con stants are available H MSG TRUE No error for tests true MSG FALSE For tests false H MSG VOID No result could be computed 4 H MSG FAIL Operator did not succeed Table 3 4 Return values for operators In table 3 4 all return messages can be found There exist more than 400 error numbers internally see Extension Package Programmer s Manual HALCON 6 0 4 64 CHAPTER 3 LANGUAGE The control types are only used within the generic HDevelop type tuple tuple of length 1 is interpreted as an atomic value A tuple may consist of several numerical data items with different types The standard representation of a tuple 15 a listing of its elements
183. or such as a detailed description of the functionality typical successor and predecessor operators complexity of the operator error handling and examples of application The online 2 1 INTRODUCING HDEVELOP help 16 based on an internet browser such as Netscape Navigator or Microsoft Internet Explorer O HDevelop comprises a program interpreter with edit and debug functions It supports programming features such as loops and conditions Parameters can be changed even while the program 15 running O HDevelop immediately displays the results of operations You can try different operators and or parameters and immediately see the effect on the screen Moreover you can preview the results of an operator without changing the program O Several graphical tools allow to examine iconic and control data online For example you can extract shape and gray value features by simply clicking onto the objects in the graphics window or inspect the histogram of an image interactively and apply real time segmentation to select parameters O Variables with an automatic garbage collection are used to manage iconic objects or control values 1 2 Example Session To get a first impression how to use HDevelop you may have a look at the following ex ample session Every important step during the image processing session is explained in de tail Thus having read this chapter thoroughly you will understand the main HALCON ideas and conc
184. ormat it is convenient to use a standard WWW browser In the tool HDevelop you may call Netscape via the menu Help gt html help It will start Netscape with the corresponding help files see page 45 An alternative to Netscape 15 to use the Microsoft Internet Explorer Besides HTML the documentation is available in PDF format as well To display the manuals the Adobe file viewer Acrobat Reader 1s included in the distribution for Windows systems This viewer is not activated from HDevelop but has to be started from the Windows start menu 6 4 Warning and Error Windows Warning and error windows are popups that make the user aware of user errors Usually they interrupt the faulty actions with a description of the error For this purpose information about the kind of the error 1s determined during the execution Figure 6 1 shows an example of an error window 6 5 Restrictions Not every HALCON operator that is available in HALCON C or can or should be used in HDevelop There are two reasons for this On the one hand the HALCON system is influenced by HDevelop so deeply that some operators don t behave like in a normal user HDevelop 2003 08 01 6 5 RESTRICTIONS 121 Error x syntax eror in parameter 1 lt gt Figure 6 1 Example for an error window program Usually this concernes the graphical operators like set color For this class of operators specific versions for HDevelop are availab
185. ote that HDevelop may be slow to react to your actions while the program is running This is caused by the fact that HALCON reacts to user input only between calls to oper ators e A variable window update during runtime will only be performed if it has not been suppressed see page 25 In any case the values of all variables are shown in the variable window after the execution s termination While the program is running the menus Execute gt Run and Execute gt Step and the toolbar buttons Run and Step are grayed out 1 you cannot execute them You have the following possibilities to stop your HDevelop program 1 The program runs until the last operator in this program has been called The PC is positioned behind this operator This 15 the usual way to terminate a program 2 The menu Execute gt Stop or the toolbar button Stop has been pressed 3 A break point has been set see chapter 2 4 In this case the last operator that will be executed 1s situated before the break point 4 Menu item File gt Quit has been executed see page 18 5 A runtime error occurred An input variable without a value or values outside a valid range might be typical reasons In this case the PC remains in the line of the erroneous operator Execute gt Step keyboard shortcut F6 Selecting Execute gt Step enables you to execute a program even if it is not complete step by step HDevelop executes the operator directly to the right
186. oth tuples have a length greater than one both tuples must have the same length other wise a runtime error occurs In this case the selected operation is applied to all elements with the same index The length of the resulting tuples is identical to the length of the input tuples HALCON 6 0 4 66 CHAPTER 3 LANGUAGE Symbol integer arithmetic that is integer or real boolean string all types atomic all types tuple Table 3 5 Symbolic variables for the operation description 5 5 5 1 2 3 1 2 3 1 2 3 1 2 3 Text1 Text2 17 23 Text Texti 99 Text Text 3 1 2 3 1 2 Text Sol 2 cB Text e If one of the tuples is of length 0 a runtime error occurs In table 3 6 you can find some examples for arithmetic operations with tuples In this example 25 25 2 4 6 fi 1 14 2 16 3 1 4 9 runtime error 1 2 17 23 Text Text1 99 Text2 Text 6 2 runtime error b 1 Text 912 Text Text 2 13 3 1 2 Text Text 42 1 d 3 Table 3 6 Examples for arithmetic operations with tuples and strings you should pay special attention to the order in which the string concatenations are performed 3 5 2 Assignment In HDevelop an assignment is treated like an operator To use an assignment you have to se lect the operator assign Input Result This operator has the following semantics
187. pecify a substring that is included in the operator name in the operator window s operator name text field Three letters are already sufficient to produce a result You will notice the open combo box that presents all HALCON and or HDevelop operators containing the first three specified letters Now you are able to select the operator dyn threshold and to specify its input parameters The value ImageFilled is used for Originallmage ImageMean is used as the component to compare here ThresholdImage For the output parameter RegionDynThresh the variable name remains unchanged see figure 1 3 HDevelop marks dev File Edi Execute Visualization Operators Suggestions Window Help x Galery tn Il i get image pointer1 Christof Pointer Type Width Height dev open window 0 0 Width Height black VVindowID dev set drawv fill set part 0 0 Height 1 VMidth 1 fill interlace Christof ImageFilled odd mean image ImageFilled ImageMean 29 29 dyn threshold ImageFilled ImageMean RegionDynThresh 5 light 26076640 byte 768 575 3600 Figure 1 3 The displayed image is the threshold operation result Image pixels touching each other and remaining above the given threshold have to be merged to single regions The computation of these connected components is realized by operator HALCON 6 0 4 6 1 INTRODUCING HDEVELOP connectio
188. phics window content and the history of the window You close a graphics window using the close button of the window frame Figure 2 40 shows an example for a graphics window The the origin of the graphics window 1s the upper left corner with the coordinates 0 0 The x values column increase from left to right the y values increase from top to bottom Normally the coordinate system of the graphics window corresponds to the the most recently displayed image which is automatically zoomed so that every pixel of the image is visible The coordinate system can be changed interactively using the menu Visualization gt Set Parameters gt Zoom see section 2 3 2 4 or with the operator dev_set_part see page 38 Every time an image with another size 1s displayed the coordinate system will be adapted automatically Each window has a history that contains all e objects and e display parameters that have been displayed or changed since the most recent Clear or display of an image This history is used for redrawing the contents of the window The history is limited to a maximum number of 30 redraw actions where one redraw action contains all objects of one displayed variable Other output like text or general graphics like disp_line or disp_circle or iconic data that displayed using HALCON operators like disp_image or disp_region are not part of the HALCON 6 0 4 58 CHAPTER 2 GRAPHICAL USER u Graphics
189. pt pattem dew fing dev ix ball dev hales dev ball2 dev hull dev ix board dev Ic dev boards dev pattern dey ix clip dev pm dev clip dev e pm illu ix fin dev rim de File name Save Save type HDevelop dev b Cancel Open as read only Figure 2 4 The dialog window to save a program to a file A dialog box similar to the window described in menu item File gt Open is opened in which you can specify the appropriate settings You may specify a new file name and a directory where to locate this file You may indicate whether the HDevelop program remains a HDevelop program or is transformed to a C C Visual Basic an ASCII file This is done by clicking the combo box of the text field called Files of type In UNIX the selection of the file type has to be done by entering the corresponding file extension manually For C code you have to add cpp to the file name for C code c and for ASCII txt The extension for Visual Basic is bas Default type is the HDevelop type extension dev The details of code generation are described in chapter 4 Similar to loading the file name of the program you save is appended at the end of the menu File File gt Print keyboard shortcut lt Ctrl gt P The menu item File gt Print enables you to print the current program Upon se lecting the menu item a dialog appears in which you can configur
190. rameter o gt o o gt Objects nput object object array gt Hobject Objects to be deleted dev clear obj returns 2 H_MSG_TRUE if the variable is instantiated If necessary ex ception is raised LLL Information dev_clear_obj is local and processed completely exclusively without parallelization Also gt clear obj test obj def dev set check reset ob db Module SSS Basic operators dev clear window Clear the active graphics window dev clear window clears the graphics window content and the history of the active window Parameters assigned to this window e g with dev set color dev set draw etc remain unmodified The operator is equivalent to pressing the Clear button of the active graphics window A graphics window can be activated by calling dev set window 133 134 APPENDIX B DEVELOP LLL Attention 0000000000000 If dev clear window should be used for exported Code C please note the description of clear window due to the different semantics in C Example SSS read image Image fabrik regiongrowing Image Regions 3 3 6 100 Number Regions dev update window off for 1 to Number by 1 RegionSelected Regions li dev clear window dev display RegionSelected stop endfor LLL Redt o dev_clear_window always returns 2 H MSG TRUE ao
191. raphics window dev_close_window closes the active graphics window which has been opened by dev_open_window or by HDevelop default window operator is equivalent to press ing the Close button of the active window A graphics window be activated by calling dev set window Attention 0000000000000 If dev_close_window should be used for exported Code C please note the description of close window due to the different semantics in Example SSS close all windows for i 1 to 10 by 1 dev close window endfor read image For5 for5 get image pointer For5 Pointer Type Width Height dev open window 0 0 Width Height black WindowHandle dev display For5 LLL Redt o dev close window always returns 2 MSG TRUE ao Information _ dev close window is local and processed completely exclusively without parallelization o Possible Predecessor Functions gt gt gt gt o o Y dev set window dev_open_window HALCON 6 0 4 136 APPENDIX B DEVELOP Possible Successor Functions gt gt Y Y dev_open_window See 444444 4 4 4 4 2 close window Module _ S System dev display Object Displays image objects in the current graphics window dev display displays an image object image region or XLD in the active graphics window This is equivalent to a double
192. region output like dev display disp region disp circle disp rectanglei1 disp rectangle2 disp arrow etc If the mode is margin the contour can be affected by dev set line width set line approx set line style Attention 0000000000000 If dev set draw should be used for exported Code C please note the description of set draw due to the different semantics in HALCON 6 0 4 146 APPENDIX B DEVELOP Parameter gt DrawMode input control ion Lee eduobuarirea datar tice dard Eder d string string Fill mode for region output Default Value fill Value List DrawMode fill margin Example SSS read_image Image monkey threshold Image Region 128 255 dev_clear_window set color red dev set draw fill display Region dev set color white dev set draw margin dev_display Region o Reto dev set draw always returns 2 H MSG TRUE LLL Parallelization Information SSS dev set draw 15 local and processed completely exclusively without parallelization LLL Possible Successor dev set line width dev display See 802 4444464 4 4 4 4 4 2 set draw Module _ System the line width for region contour output dev set line width defines the line width in pixel in which a region contour or lines are displayed e g with dev display disp region disp line disp polygon etc
193. riable window and e agraphics window In the following you will learn the functionality of these five windows and their effective use while creating HDevelop programs Please note that in the UNIX environment the main window the program window and the operator window are combined into one window Thus there are only three windows 2 1 Interacting with HDevelop You interact with HDevelop through its graphical user interface With the mouse you can ma nipulate visual controls such as menus or buttons in the HDevelop windows 2 2 Mouse Handling You can use the mouse as follows 10 CHAPTER 2 GRAPHICAL USER INTERFACE e Clicking the left mouse button once you are able to select window specific components such as menu items iconic variables control variables action buttons checkboxes and you give the insertion focus to a specific text field Some of these text fields comprise a combo box which you may open in the same way Furthermore you select invert text in certain windows e g in the program window With this you are able to perform the general editor functions like cut copy and paste see sections 2 3 2 2 and 2 3 3 In the program window there is an extended mode to select lines by pressing the Shift or the Ctrl key during the mouse click More than one line can be activated using the Shift key lines between the last activation and the new one will become activated The lt Ctr1 gt key is used to
194. ring integer Grevalue output name Additional parameters possible Default Value default Value List Mode default histogram line column contourline 3D plot 3D plot hidden 3D plot point Example SSS read_image Image fabrik dev_set_paint 3D plot dev_display Image LLL Parallelization Information dev set paint 15 ocal and processed completely exclusively without parallelization Possible Predecessor Functions TH dev open window oT Possible Successor Functions gt o o o dev set color dev display See Also 0 o set paint Module _ S o System Modify the displayed image part dev set part modifies the image part that is displayed in the graphics window Rowi Columni denotes the upper left corner and Row2 Column2 the lower right corner of the image part to display HALCON 6 0 4 150 APPENDIX B DEVELOP If Row1 1s larger than Row2 the zooming will be reset That means that the last displayed image will be completetly visible Please note that this is not possible with the operator set part outside HDevelop LLL Attention If dev set part should be used for exported Code C please note the description of set part due to the different semantics in Parameter o o o gt Rowi input control rectangle origin y integer Ro
195. rings chrt i convert a tuple of integers into a string Table 3 18 Miscellaneous functions sort sorts the tuple values in ascending order that means that the first value of the resulting tuple is the smallest one But again strings must not be mixed up with numbers sort index sorts the tuple values in ascending order but in contrast to sort it returns the index positions 0 of the sorted values The function inverse reverses the order of the tuple values Both sort and inverse are the identity operation if the input 1s empty if the tuple 1s of length 1 or if the tuple contains only one value in all positions e g 1 1 1 is number returns true for variables of the type integer or real and for variables of the type string that represent a number The function number converts a string representing a number to an integer or a real de pending on the type of the number Note that strings starting with Ox are interpreted as hex adecimal numbers and strings starting with 0 as octal numbers for example the string 20 is converted to the integer 20 020 to 16 and 0x20 to 32 HDevelop 2003 08 01 3 6 RESERVED WORDS 79 If called with a string that does not represent a number or with a variable of the type integer or real number returns a copy of the input environment returns the value of an environment variable Input is the name of the environ ment variable as a string ord gives the ASCII number of a
196. rol variable HALCON 6 0 4 138 APPENDIX B DEVELOP dev inspect ctrl opens a dialog to check the contents of a control variable This dialog has a scrolled list with all the values of the variable In the case of an frame grabber handle a specific dialog 1s opened which displays the most important frame grabber parameters and can be used to switch the frame grabber only interactively The contents of the dilaog will be updated whenever the value s of variable changes The update mode can influenced by the operator dev update var The dialog can be closed by pressing the Close button or by calling dev close inspect ctrl LLL Attention This operator is not supported for exported C code Parameter SSS gt Variable input control integer array integer real string Name of the variable to be checked Example SSS read image Image fabrik regiongrowing Image Regions 3 3 6 100 area center Regions Area Row Column dev inspect ctrl Area SSS dev_inspect_ctr1 always returns 2 5 a Parallelization Information dev inspect ctrl is local and processed completely exclusively without parallelization See Also o dev update var Module o Basic operators dev map par Open the dialog to specify the display parameters dev map par opens the dialog which can also be accessed from the menu Visualization gt
197. rs of all graphics windows are set to their initial state the state after starting the program The only exception is the history of previously displayed objects and the size of each window To clear the history you can use Visualization gt Clear Window to set the size you can use Visualization gt Size Window Visualization Close Window Selecting this item closes the active graphics window Visualization Clear Window The active graphics window is cleared The history previously displayed objects of the window 15 also removed Visualization gt Pixel Info Here you can open an inspection display This is used for interactive examination of gray values of images Apart from this the size pixel type and the number of channels are displayed Fixel Information Gray RGB 201 Row Column 553 823 Width Height amp 30 822 Pixel Type Channels Figure 2 15 Online gray value inspection and basic image features The upper part of the dialog contains a gauge to display the gray value graphically The range goes from left to 255 right Normally the gray value of the first channel is displayed with a black bar For color images in RGB space three channels with red green and blue values three colored bars are used If the gray value is below 1 the gauge is white background If the value 16 above 255 the gauge 16 black or colored for rgb images Below the gauge the gray values are displaye
198. s ts i dow ead image e Chri ristof marks image ointer1 Christof Pointer Type Width Height dev window 0 Width Height black WindowD dey yh AAN dev set part 0 0 Height 1 Wicth 1 jis Christof Image eFille d add Variable Watch _image ImageFilled ImageMean 29 29 Iconic variables pm pi eFilled ImageMean RegionDynThresh 5 light peu set c 12 ed 12 nectioi ser E esh ConnectedRegionsDynThresh shape ConnectedRegionsDynThresh SelectedRegionsDyn nmre esh mpactness and 150 1 select gray SelectedRegion isDynThresh ImageFilled Marks mean at oe 1 dev s dev ks eccentrici icy Marks amp nisometry Bulkiness StructureFactor 32322696 byte 768 575 3600 1 12702204804 1 11467319487 1 18047551603 1 12294618312 1 42797741283 1 182460 1 004167 18505 1 00426336515 1 00007240412 1 00253432078 1 00587046547 1 006111 StructureFactor 0 131718557464 0 119425453718 0 180560987328 0 125792088964 0 436360306355 0 14 Figure 1 5 After calling the operator eccentricity the output parameters are displayed in the variable window in tuple notation Finally we want to obtain some numerical information about the matched marks For example we might want to compute three shape features of the marks They are
199. s Please note the latest updates of this manual e Edition 5b HALCON 6 0 4 August 2003 The manual now also describes the new internal operator break and contains more infor mation about the function number and octal hexadecimal numbers e Edition 5a HALCON 6 0 3 August 2002 The manual now describes how to find operators and search and replace variable names via the menu items Edit gt Find Operator and Edit gt Replace Variables respec tively Furthermore it shows how to print HDevelop programs and how to access cus tomized software news about the HALCON version that 1s installed on the user s com puter e Edition 5 HALCON 6 0 October 2000 The chapter describing Code Generation has been extended by a section on the export to C The structure of the manual has been revised e Edition 4 HALCON 5 2 January 1999 manual now also describes the newly introduced keyboard shortcuts the new menu entries File gt Insert and File gt Modules the new menu Execute and the new tools for real time zooming of graphics window contents Visualization gt Zooming for visualizing the gray value histogram of an image and selecting thresholds Visualization gt Gray Histogram Info and for shape and gray value features of regions Visualization gt Region Info Furthermore it shows how to find the op timum parameters of an operator even more quickly using the new button Apply in the operator window e Edition 3 HALCON 5
200. s HWindowX directs the output to this window Finally the class HOperatorSetX is used as a container for all HALCON operators There 15 no need for other classes as long as the program has the same functionality as in HDevelop When editing a generated program you are free to use any of the classes of HALCON COM to extend the functionality 4 2 3 Limitations and Troubleshooting Besides the restrictions mentioned in this section and in section 4 4 please also check the de scription of the HDevelop operators on page 38 HALCON 6 0 4 90 CHAPTER 4 CODE GENERATION 4 2 3 1 Duplicate Parameters Due to the parameter handling of Visual Basic COM it 1s not possible to use the same variable more than once in one call Thus for input and output parameters different variables have to be used Also it is not possible to use the same variable twice for input or output Examples for code which is not allowed are mean image Image Image 3 3 add image Image Image Add 1 0 You have to introduce additional variables 4 2 3 2 Reserved Words In contrast to C C or HDevelop Visual Basic has many reserved words Thus the export adds the prefix HXP to all variables to avoid collisions with these reserved words 4 2 3 3 Exception Handling In HDevelop every exception normally causes the program to stop and report an error message in a dialog window This might not be useful in Visual Basic The standard way to handle this in Visual Basic is
201. s back in your program 15 to use the item Edit gt Undo Edit gt Find Operator keyboard shortcut Ctrl F The menu item Edit gt Find Operator allows to search for the appearance of an operator in the current program Figure 2 10 depicts the corresponding dialog Specify an operator name in the text field then find the next appearance by clicking the button Find or the previous one by checking the box Find Backwards The figure shows the result of clicking Mark A11 If you check the box Edit the Operator Window pops up and lets you edit the found operator instance Edit gt Find Again keyboard shortcut lt Ctrl gt The menu item Edit gt Find Againrepeats the search specified via the menu item Edit gt Find perator HDevelop 2003 08 01 2 3 MAIN WINDOW 21 Replace Variables Ed Find Selected Replace ClipRegions v Find Cancel Figure 2 11 Replacing variables Edit gt Replace Variables keyboard shortcut Ctr1 The menu item Edit gt Replace Variables allows to search and replace variable names Figure 2 11 depicts the corresponding dialog After specifying the variable name to find and the name to replace it by you can let HDevelop replace all instances of the variable by clicking Replace 11 If you click Find the next instance of variable 15 displayed in the Program Window you can then replace its name by clicking Replace 2 3
202. s full view back on your graphics window you simply click the checkbox Reset Visualization gt Set Parameters Lut Using Lut you are able to load different look up tables for visualization see figure 2 23 With the help of a false color presentation you often get a better impression of the gray values of an image In the case of a true color display the image has to be redisplayed due to the missing support of a look up table in the graphics hard ware For color images only the gray look up tables can be used which change each channel separately with the same table 2 3 2 5 The Menu ltem Operators This menu item comprises all HALCON and HDevelop operators including the HDevelop con trol constructs In the following you will see a description of all items to select perators gt Control Here you may select control structures for the program This involves the execution of a program segment henceforth named body depending on a test 1f and ifelse and the repetition of a program segment for while and break Furthermore you may stop the program s execution at any position stop or terminate HDevelop exit The operators assign and insert do not influence the execution but serve to specify values for control data assignment The operator comment is used to add a comment HALCON 6 0 4 36 CHAPTER 2 GRAPHICAL USER INTERFACE Visualization Parameters Pen Lut cubic root v update ine cubic raat three Six tw
203. sed by the inaccuracy of the operating system s time measurement procedure e Insert Interactions Sometimes it is very helpful to record user interactions as a sequence of operators in the program To do so you select this option From now on interactions are inserted as a program line in the program window For example select the graphic color red by choosing the appropriate menu inserts the program line dev set color red into the program window e Show Variable Usage If you activate a variable by single clicking on 10 all lines in the program that contain the variable are marked on the left with a black frame This works with iconic and control variables You can activate one iconic and one control variable simultaneously Each activated variable is marked by a black background for the name in the variable window e Show Low Level Errors Low level errors of HALCON are normally invisible for the user because they are transferred into more comprehensive error messages or simply ignored Activating this item generates a message box each time a low level error occurs e Automatic Program Save If you activate this option the program is automatically saved before each execution of the program 1 e before Run or Step operation The file name the program is saved to is the file name of the current program Therefore if you create a new program you have to select File gt Save as manually first to give the program a file name
204. shold which also applies the resulting threshold and thus extracts the vessel The right side of figure shows the result of the segmentation HALCON 6 0 4 100 CHAPTEH 5 PROGRAM EXAMPLES 5 3 Particles File name particle dev This program example processes an image that was taken from a medical application It shows tissue particles on a carrier figure 5 5 left Figure 5 5 Tissue particles left and large objects right As in many other medical applications the existing objects have to be evaluated statistically This means that different objects have to be extracted and classified according to their size or other attributes for example After this you can analyze them An important step to solve this problem is the image segmentation that locates the relevant objects For the statistical evaluation you may have a look at appropriate literature about statistics In our case there are two object classes e large bright particles e small dark particles The large bright particles differ clearly from the background because of their gray values The informal description brighter than the background leads directly to the algorithmic solution using a thresholding The only thing to decide 15 whether you specify the threshold automat ically or empirically In our case a fixed threshold is completely sufficient due to the good contrast Hence you get the following simple segmentation operator read image Partic
205. state of operators Messages In the case of C only severe errors cause an exception handling which termi nates the program and prints an error message This might cause problems with minor errors so called messages in HALCON These messages are handled as return values of the operators and can have the following values which are also available in HDevelop as constants H_MSG_TRUE H_MSG_FALSE H_MSG_FAIL H_MSG_VOID HALCON 6 0 4 86 CHAPTER 4 CODE GENERATION One of these messages 15 always returned indicating the status of the operator Normally the result is MSG TRUE Some operators return MSG FAIL like read image or read region to indicate that they could not open a file or there was no permission to read it In this case the programmer has to check the return value and apply some adequate action If the message H MSG FALSE is ignored errors like Halcon Error 4056 Image data management object ID is NULL will happen in successive operators because the predecessor operator did not calculate an ap propriate value Errors the case of hard errors 1 no message as described above the program stops with an error message prevent this behavior the HDevelop operators dev_error_var and dev set check can be used to control the exception handling in the application This works similarly in HDevelop and C One difference is caused by the dynamic evaluation of dev_error_var in HDevelop This means that each time
206. sualization Operators Suggestions Window Helk x tes I dev close window read image Christof marks get image pointer1 Christof Pointer Type Width Height dev open wvindow 0 0 Width Height black VVindowlD 32322696 byte 768 575 3600 Figure 1 1 Screen configuration after image loading e First you may specify the operator name read_image in the operator window s input text field e Secondly you may select this operator in Operators gt File gt Images gt read_image e The most often used and most convenient way is the third one Here you open the image selection box pressing menu item File gt Read Image gt The menu File gt Read Image contains several predefined directories of which is HALCONROOT images Usually this directory will be C Program Files MVTec Halcon images Select this directory by pressing the appropriate menu button Now you can browse to your target directory and choose a file name By clicking the button Open a dialog window appears in which you may specify a new name for the iconic variable which contains the image you are about to load The variable will be used later in the program to access this image To facilitate the specification process HDevelop offers you a default variable name which is derived from the image s file name Pressing the button Ok transfers the operator into the progr
207. t 23 35 38 125 compactness 30 concat_obj 113 Condition 129 connect_and_holes 30 Connected components 103 108 connection 97 103 contlength 30 161 Control structures ifelse 80 Control data 54 159 Control parameter 61 Control structures 35 37 79 break 81 exit 82 for 80 LL 79 stop 82 while 80 Control Variable 137 convexity 30 cooc feature image 31 cooc feature matrix 31 Coordinate system 39 Coordinate System 140 count obj 103 113 Data structures 61 62 65 Database 133 dev clear obj 40 133 dev clear window 39 103 133 dev close inspect ctrl 40 134 dev close window 39 dev close window 135 dev_display 39 136 dev display 93 dev error var 41 63 86 114 136 inspect ctrl 40 137 dev map par 40 138 dev_map_prog 139 dev map prog 40 dev map var 40 139 dev open window 39 dev open window 93 dev open window 140 dev set check 40 63 86 114 142 dev set color 39 dev set color 143 dev set colored 39 144 162 dev set draw 39 dev set draw 145 dev set line width 39 dev set line width 146 dev set lut 39 147 dev set paint 39 148 dev set part 94 dev set part 39 149 dev set shape 39 150 dev set window 39 152 dev set window extents 39 dev set window extents 152 dev unmap par 40 154 dev unmap prog 40 154 dev unmap var 155 dev_unmap_var 40 update pc 40 155 de
208. t if the precision is explicitly 0 no radix appears e E floating point number argument is printed in the style drddde dd where there is one digit before the radix character and the number of digits after it is equal to the precision When the precision 15 missing six digits are produced if the precision is 0 no radix character appears The E conversion character produces number with E introducing the exponent instead of e The exponent always contains at least two digits However if the value to be printed requires an exponent greater than two digits additional exponent digits are printed as necessary g G The floating point number argument is printed in style f or e or in style E in the case of a G conversion character with the precision specifying the number of significant digits The style used depends on the value converted style e is used only if the exponent resulting from the conversion 1s less than h or greater than or equal to the HALCON 6 0 4 74 CHAPTER 3 LANGUAGE precision Trailing zeros are removed from the result A radix character appears only if it is followed by a digit s The argument is taken to be a string and characters from the string are printed until the end of the string or the number of characters indicated by the precision specification of the argument is reached If the precision is omitted from the argument it is interpreted as infinite and all characters up to the end of the string are
209. ted by their surrogates in the HALCON data management The results of those operators are again tuples of iconic objects or control data elements For a detailed description of the HALCON operators refer to the HALCON reference manual and the remarks in chapter 3 5 3 3 5 Expressions for Input Control Parameters In HDevelop the use of expressions is limited to control input parameters all other kinds of parameters must be assigned by variables 3 5 1 General Features of Tuple Operations This chapter is intended to give you a short overview over the features of tuples and their oper ations A more detailed description of each operator mentioned here is given in the following sections Please note that in all following tables variables and constants have been substituted by letters These letters give information about possible limitations of the areas of definition A single letter inside these tables represents a data type Operations on these symbols can only be applied to parameters of the indicated type or to expressions that return a result of the indicated type To begin with table 3 5 specifies the names and types of the symbolic names Operators are normally described assuming atomic tuples tuples of length 1 If the tuple contains more than one element most operators work as follows e If one of the tuples is of length one all elements of the other tuples are combined with that single value for the chosen operation e If b
210. ter the line into the program some unused variables may thus be created You can easily remove them by selecting File gt Cleanup Cancel Clicking Cancel clears the contents of the operator window Thus there are neither changes in the program nor in any variables Help Clicking Help invokes an appropriate help text for the selected operator For this the system activates an HTML browser see chapter 6 3 2 6 Variable Window There are two kinds of variables in HALCON This corresponds to the two parameter types of HALCON iconic objects 1mages regions and XLDs and control data numbers strings In HALCON the corresponding variables are called iconic and control variables These variables may possess a value or be undefined An undefined variable is created for example when load ing a program or after inserting an operator with a new variable that is not executed immediately into a program You may access these undefined variables by writing them only If you try to read such a variable a runtime error occurs If a variable obtains a value the variable type 1s specified more precisely A control variable that contains for example an integer is of type integer This type might change after specification of new values for this variable to real or a tuple of integer But it always remains a control variable The more refined type is bound to the value and not to the variable Similarly this is the case for iconic variables which may
211. the affiliation By applying gray inside to an image every pixel value is interpreted as the potential energy you have to afford to get from the pixel position to the image border The dark pixels present valleys and the bright pixels mountains Thus a dark region in the middle of an image 15 equiv alent to a hole in a mountain that needs a lot of energy to be left This 15 also true for the dark circles on the bright background in the image of the calibration board Before calling gray_inside you should use a smoothing filter to suppress small valleys This reduces runtime considerably If you look at the operator result on the right side of figure 5 11 you will notice the circles as significant bright points Now a simple thresholding is sufficient to extract them HALCON the range of 0 to 1 is mapped to values of a byte image 0 to 255 HDevelop 2003 08 01 5 7 DEVICES 107 Figure 5 11 Calibration board and gray inside result read image Caltab caltab gauss image Caltab ImageGauss 9 gray inside ImageGauss ImageDist threshold ImageDist Bright 110 255 connection Bright Circles elliptic axis Circles Ra Rb Phi After calculating the ellipse parameters of each circle elliptic axis you may compute the camera parameters 5 7 Devices File name ic dev This example discusses the combination of different segmentation methods It works with an image of multiple electronic components T
212. the entire image will be displayed In the fourth mode the same mechanism 15 used for re gions that have gray value information e g image objects created by reduce domain or add channels the histogram of the image object you click into will be displayed Yes only roughly by a factor of 2 since the image is scaled such that the red square that indicates the mouse pointer position is located in the middle of the zooming window Therefore the zoom factor is adjusted to display one pixel more than the power of 2 indicated by the zooming factor The width and height of the zoomed part of the image hence are 28 1 where f is the zooming factor HDevelop 2003 08 01 2 3 MAIN WINDOW 27 Gray Histogram OF x Channel 1 Rel C Abs V Accept Display None Send Back Static data Grayyvalue Pixels number Min Gray value Grayvalue Dynamic data Pixel number min 96 Pixel number max 0 24 96 Figure 2 17 Online gray histogram inspection Finally when the graphics window the image was sent from is cleared the histogram is not reset When a multi channel image e g a RGB color image is sent to the tool by default the histogram of the first channel is displayed The combo box Channel lets you select the channel from which to compute the histogram The radio box in the upper center of the tool lets you select whether to display the his togram with relative or absolute
213. the graphics window interactively by gripping the window border with the mouse Then you can resize the window by dragging the mouse pointer After this size modification the window content 15 redisplayed Now you see the same part of the window with changed zoom If the mouse cursor is inside the window its look up table is reactivated This is necessary if other programs use their own look up table Thus if there 15 a strange graphics window presentation you may load the proper look up table by placing the mouse inside the window Opening a window causes the assignment of a default font It is used in connection with pro cedures like write string and you may overwrite it by performing set font after calling dev open window On the other hand you have the possibility to specify a default font by call ing set system default font lt Fontname gt before opening a window and all following windows see also query font If you want to specify display parameters for a window you may select the menu item Visualization in the menu bar Here you can set the appropriate parameters by clicking the desired item Parameters which you have set in this way are used for all windows in con trast to standard windows opened with open window The effects of the new parameters will be applied direcly to the last object of the window history and alter its parameters only LLL Aftention 0000000000000 Never use close window to close an HDevelop graphi
214. the operator is executed e g in a loop the use of the error variable might change In contrast to this in special code is added to store the return values of operators This code will therefore be static and cannot change during program excecution To understand how the code generation works let us have a look at a short example Here at first the HDevelop program dev set check give error dev error var error true threshold image region 100 255 dev error var error false if error H MSG TRUE write string WindowId error number error exit endif dev set check give error This program will be translated into HTuple error Set check give error error threshold image amp region 100 255 if error 2 i write string WindowId HTuple error number HTuple error exit DE Set check give error As can be seen the operator dev error var is eliminated and replaced by the use of the error variable later on The points mentioned above might cause these two problems e If the second parameter of dev error var cannot be derived from the program because no constant false or true are used but expressions the value will be interpreted as true HDevelop 2003 08 01 4 1 CODE GENERATION FOR C 87 that means start to use the variable To avoid confusion use only the constants false or true as values for the second parameter e The usage of a variable starts after th
215. the values of the variable passed to the operator In most cases a list dialog is opened which shows all values of the variable In the case of a frame grabber handle a description of this frame grabber is opened In addition this dialog allows online grabbing of images This operator is not supported for exported C and Visual Basic code dev_close_inspect_ctrl This is the opposite operator to dev_inspect_ctr1 and closes the inspect window This operator is not supported for exported C and Visual Basic code dev_map_par dev_unmap_par These operators open and close the parameter dialog which can also be opened us ing the menu Visualization gt Set Parameters This operator is not sup ported for exported C and Visual Basic code dev_map_var dev_unmap_var These operators iconify the variable window dev_unmap_var and retransform the iconified window to the normal visualization size respectively dev_map_var This means that the variable window always remains visible on the display in one of the two ways of visualization These operators can be executed with the help of the window manager These operators are not supported for exported C and Visual Basic code dev_map_prog dev_unmap_prog Analogously to dev_map_var and dev_unmap_var these operators iconify or de iconify the program window These operators are not supported for exported C and Visual Basic code dev_update_window dev_update_var dev_update_time dev_
216. tion the operator is entered into the program window The PC and the insertion cursor are positioned after the new operator The computed output parameter values are displayed in the variable window Iconic variables are shown in the current graphics window if you haven t suppressed this option see page 25 Afterwards the operator window 15 cleared If you did not specify all parameters or if you used wrong values an error dialog is raised and execution is canceled In this case the operator window remains open to support appropriate changes Enter By clicking the button Enter the program line is only transferred in the program window There is no operator execution 1 e the position of the PC 1s not changed The insertion cursor is positioned after the new operator Apply If you click Apply the operator is executed with the specified parameters but not entered into or changed in the program This enables you to determine the optimum parameters of an operator rapidly since the operator dialog remains open and hence you can change HALCON 6 0 4 54 CHAPTER 2 GRAPHICAL USER INTERFACE parameters quickly Unlike the button OK only the single line you edit or enter 16 executed no matter where the PC 1s located Thus you have to ensure that all the input variables contain maningful values By pressing Apply the corresponding output variables are changed or created if necessary to allow you to inspect their values If you decide to not en
217. to a multiplication by 212 The result of rsh i1 i2 is a bitwise right shift of 11 that is applied i2 times For non negative 11 this is equivalent to a division HALCON 6 0 4 72 CHAPTER 3 LANGUAGE lsh i i left shift rsh i i right shift i band i bitwise and i bor i bitwise or i bxor i bitwise xor bnot i bitwise complement Table 3 10 Bit operations by 212 For negative 11 the result depends the used hardware For 1sh and rsh the result is undefined if the second operand has a negative value or the value 15 larger than 32 More examples can be found in the program bit dev 3 5 7 String Operations There are several string operations available to modify select and combine strings Furthermore some operations allow to convert numbers real and integer to strings v s string conversion v v concatenation of strings and addition strchr s s search character in string strstr s s search substring strrchr s s search character in string reverse strrstr s s search substring reverse strlen s length of string s i selection of one character s i i selection of substring split s s splitting in substrings Table 3 11 String operations converts numbers to strings or modifies strings The operator has two parameters The first one left of the is the number that has to be converted The second one right of the specifies the conversion This format string consists of the following four parts lt fl
218. tor The value can be saved by assigning it to another variable see example or by calling dev_error_var 0 eS ee AO n If dev_error_var should be used for exported Code C please note the different handling of return values in C Parameter 1 gt ErrorVar input control integer array integer Name of the variable which shall contain the error status gt Mode input control doin Pe Para qoe integer integer Switch the error variable on or off Default Value 1 Value List Mode 0 1 Example SSS close window dev open window 0 0 512 512 black WindowHandle dev error var Error 1 dev set check give error FileName wrong read image Image FileName ReadError Error if ReadError H MSG TRUE write string WindowHandle wrong file name FileName endif LLL Redt o dev error var always returns 2 H MSG TRUE LLL Parallelization Information ___________ _ _ dev error var is local and processed completely exclusively without parallelization Possible Predecessor Functions 2 dev set check LLL Possible Successor Functions _ gt gt o Y Y dev set check if ifelse assign See Also 4446 4 4642 set check Module 00000 o Basic operators Open a window to inspect a cont
219. trol osa cerae aired string string Mode for graphic output Default Value off Value List DisplayMode c on off LLL Reto dev_update_var always returns 2 H MSG TRUE LLL Parallelization Information gt dev update var is reentrant local and processed without parallelization See Also gt dev update pc dev update window dev update time Module Basic operators dev update window DisplayMode Specify the output behaviour during program execution dev update window specifies the output behaviour during program execution By default every object image region or XLD is displayed in the active graphics window This can be changed by using the value off for DisplayMode In this case objects only displayed in single step mode Here one would use the operator dev display to output objects This option can also be controled by the dialog File gt Options gt Update Window LLL Attention This operator is not supported for exported C code Parameter o i o gt DisplayMode input control string string Mode for graphic output Default Value off Value List DisplayMode on off dev update window always returns 2 MSG TRUE LLL Parallelization Information dev update window is reentrant local and processed without p
220. uently 1 the peak of the histogram These data are displayed in textual form within the Static data area of the display The dynamic parts of the histogram area are the three colored lines which can be manip ulated The dashed horizontal yellow line can be dragged vertically The label on this line indicates the frequency of gray values above this line The vertical green and red lines denote the minimum and maximum selected gray value of the histogram respectively The selected range is drawn as a white bar below the horizontal gray value axis The gray values on which the two vertical lines lie are displayed next to the lines in the same color The frequency of the respective gray values is displayed within the Dynamic data area of the display The selected range of gray values can be used for two major purposes If the combo box Display is set to threshold the image from which the histogram was computed is segmented with a threshold operation with the selected minimum and maximum gray value Depending on the setting of the combo box Send the segmentation result 15 either displayed in the graphics window from which the image was originally sent Send back or in the active graphics window Send to active If Display 15 set to scale the gray values of the 1mage are scaled such that the gray value 0 of the scaled image corresponds to the minimum selected gray value and the gray value 255 to the maximum selected gray value Again the
221. unmap par is local and processed completely exclusively without parallelization Possible Successor Functions SS dev map prog gt dev_map_par dev map prog dev map var Module o Basic operators dev_unmap_prog Hide the main window dev_unmap_prog hides the main window so that it is no longer visible It can be mapped again using the operator dev_map_prog oo Attention This operator is not supported for exported C code dev unmap prog always returns 2 H MSG TRUE oS Parrallelization Information _ dev unmap prog is local and processed completely exclusively without parallelization Possible Successor Functions SSS dev_map_prog stop See Also gt dev_map_par dev map prog dev map var HDevelop 2003 08 01 155 Module gt o Basic operators dev_unmap_var Hide the variable window dev_unmap_var hides the variable window so that it is no longer visible It can be mapped again using the operator dev map var LLL Attention This operator is not supported for exported C code dev unmap var always returns 2 MSG TRUE LLL Parallelization Information _ ___________ _ __ dev unmap var 15 reentrant local and processed without parallelization Possible Successor Functions gt dev map var See Also o dev_map_par dev_map_prog
222. update_pc Using these operators you may configure the output at runtime It corresponds to the settings in menu Visualization gt Options see page 25 These operators are not supported for exported C and Visual Basic code dev_set_check This operator is equivalent to set check of the HALCON library It is used to handle runtime errors caused by HALCON operators that are executed inside HDe velop The parameter value give error which is the default leads to a stop of the program together with an error dialog if a value not equal to MSG TRUE is returned Using the value give_error errors other messages are ignored and the program can continue This mode is useful in connection with operators like get mposition file exists read image or test region point which can return H MSG FAIL An example can be found on page 113 dev_error_var HDevelop 2003 08 01 2 3 MAIN WINDOW 41 This operator specifies a variable that contains the return value error code of an operator after execution This value can be used to continue depending on the given value dev error var is normally used in connection with dev set check An example how to use dev error var in connection with dev set check can be found in AHALCONROOT NexamplesMhdevelopNGraphicsMMouseNget mposition dev Please note that operations concerning graphics windows and their corresponding op erators have additional functionality as HALCON operators
223. uple_const H_MSG_TRUE H_MSG_FALSE H_MSG_FAIL H_MSG_VOID Table 3 20 Reserved words ifelse Another simple control structure is the condition with alternative If the condition is true all expressions and calls between the head and the word endif are performed If the condition is false the part between else and endif is executed Note that the operator 1s called ifelse and itis displayed as if in the program text area JUS Conc Edo else endif while The while loop has a boolean expression as the conditional part As long as it is true for the body of the loop is performed In order to enter the loop the condition has to be true in the first place loop can be terminated immediately with the instruction break see below while Condition endwhile In chapter 5 3 you can find an example for using the while loop The for loop is controlled by a start and termination value and an incrementation value that determines the number of loop steps These values may also be expressions which are evaluated 1mmediately before the loop is entered The expressions may be of type integer or of type real If all input values are of type integer the loop variable will also be of type integer In all other cases the loop variable will be of type real If the start value 15 less or equal to the termination value the starting value is assigned to the loop index and the body of the loop is entered If the increment 15 less than zero the
224. v update time 40 dev update time 156 dev update var 40 dev update var 156 dev update window 40 dev update window 157 Dilation 108 115 Document analysis 95 dyn threshold 42 dyn threshold 101 103 eccentricity 30 Edit Copy 19 20 Cut 19 Paste 19 Undo 19 Editor 9 elliptic axis 30 elliptic axis 107 empty obj 113 Encapsulation 115 entropy gray 30 Environment Variable HALCONIMAGES 15 Environment Variable HALCONROOT 15 Error message 120 Error code 136 Example 61 Annual Rings 103 Board 107 HDevelop 2003 08 01 Index Bonding 104 Calibration board 106 Capillary vessel 97 Cell walls 110 Devices 107 Exception 114 IC 108 Medical 100 Region selection 112 Road scene 114 Stamps 95 Tissue particles 100 Example session 2 Exception 136 Exception handling 85 90 Execute Activate 23 Clear all break points 23 Clear break point 23 Deactivate 23 Reset program 23 65 Run 21 23 Set break point 23 step 22 25 Stop 22 23 Execution time 17 Exit 125 exit 35 38 82 125 false 63 159 File 111 Cleanup 16 54 History 18 Insert 12 Modules 18 New 12 13 Open 12 14 Options 12 16 Print 14 Print Selection 14 Quit 22 Read image 15 save 14 Save as 14 17 fill up shape 105 Filter Gaussian 101 Linear 98 Low pass 101 Index Mean 101 Smoothing 106 fnew_line lll for 80 for 35 92 113 126 159 Frame Grabber 40 fwrite stri
225. w of the upper left corner of the chosen image part Default Value 0 gt Columni input control rectangle origin x integer Column of the upper left corner of the chosen image part Default Value 0 gt Row2 input control rectangle corner y integer Row of the lower right corner of the chosen image part Default Value 128 gt Column2 input control rectangle corner x integer Column of the lower right corner of the chosen image part Default Value 128 Example SSS read image Image fabrik for 1 1 to 240 by 10 set part i 1 511 1 511 1 dev display Image endfor dev set part 1 1 1 1 dev display Image LLL Reato dev set part always returns 2 H MSG TRUE LLL Parallelization Information dev set part is local and processed completely exclusively without parallelization Possible Successor Functions 1 dev display See 150 o set part Module S System dev set shape Shape Define the region output shape HDevelop 2003 08 01 151 dev set shape defines the shape for region output The output shape 16 used by dev display for regions The available shapes can be queried with query shape Available modes original The shape is displayed unchanged Nevertheless modifications via parameters like d
226. with File gt New are performed Now you can see your new program in the program window The file name 15 displayed in the title bar of the main window its uninstantiated variables are shown in the variable window To indicate that they do not have any computed values the system provides the iconic and control variables with a question mark The program counter is placed on top of your program and you are ready to execute it The visualization and options will be reset after loading same as File gt New If you want to cancel this task you have to press the corresponding button By using one of these two buttons Open or Cancel the dialog window disappears HALCON 6 0 4 14 CHAPTER 2 GRAPHICAL USER INTERFACE After you have loaded a program the corresponding file name will be appended at the end of the menu File after the menu item Quit This allows you to switch between recently loaded files quickly The most recently loaded file 1s always listed first File gt Save keyboard shortcut Ctrl 6 The menu item File gt Save saves current program to a file If no file name has been specified so far the dialog corresponding to File gt Save will be activated File gt Save As The menu item File Save As saves the current program to a file The type of file HDevelop text Visual Basic C or can be selected see Figure 2 4 save HDevelop Program File HE Save J Fa EN EJ ada
227. with corresponding names without dev_ graphics windows in HDevelop are based on HALCON windows see open window in the HALCON reference manual but in fact they have an enhanced functionality e g history of displayed objects interactive modification of size and control buttons This is also true for operators that modify visualization parameters dev set color dev set draw etc For example the new visualization parameter is registered in the parameter window when the operator has been executed You can eas check this by opening the dialog Visualization gt Set Parameters Pen and apply the operator dev set color Here you will see the change of the visualization parameters in the dialog box You have to be aware of this difference if you export to and Visual Basic code In contrast to the parameter dialog for changing display parameters like color the cor responding operators like dev set color do not change to contents of the graphics window 1 they don t cause a redisplay They are used to prepare the parameters for the next display action Operators gt Classification File In the following items you can find all HALCON operators arranged chapters and subchapters This set of image analysis operators forms the most important part of HAL CON the HALCON library HALCON operators implement the different image analysis tasks such as preprocessing filtering or measurement see figure 2 2
228. y 30 Miscellaneous 119 moments gray plane 31 Mouse handling 9 Netscape Navigator 120 HALCON 6 0 4 164 Noise removal 102 Notation Decimal 62 Hexadecimal 62 Octal 62 open file 111 Opening 102 Operation Arithmetics 71 Boolean 75 Comparison 75 String 72 Trigonometric 76 Tuple 68 Operator Data base 159 Name field 50 Sequence 43 Suggestions 42 Operator text field 50 Operator window 9 47 50 52 53 160 Apply 53 Cancel 54 Enter 53 54 Help 54 Input parameter 51 52 OK 53 54 Output parameter 51 52 Optimization 84 orientation region 30 Output 16 39 Paint mode 33 Parallel HALCON 84 91 Parameter display 50 Parameter expressions 65 Parameter types 61 Preprocessing 41 Program 12 49 Counter 16 22 48 Execution 21 23 35 Termination 38 Program window 9 48 159 Programming 95 Rapid prototyping 9 read image 42 reduce domain 26 29 109 116 Region 54 160 HDevelop 2003 08 01 Index Empty 159 Region of interest 109 115 Reserved words 79 reset obj db 121 Restrictions 82 85 89 120 ROI 116 Run 2 38 Run mode 17 Runtime error 22 86 114 Segmentation 95 97 114 select gray 28 select obj 113 select shape 28 97 101 103 107 110 112 Semantics 61 set system 93 Shell 2 Skeleton 42 smallest rectangle1 29 smallest rectangle1 97 smallest rectangle2 30 sobel amp 116 Status bar 47 Step 38 Stop 130
229. y change of a parameter will immediately lead to a redisplay of the image regions or XLD in the graphics window If the button is off the parameters become active for the next display of an object double click on an icon or excecution of an operator By default the update is deactivated for the boxes Lut and Paint You may specify the following parameter settings Visualization gt Set Parameters Pb Paint Here you can select between several graphical presentations for images Examples are contourline and 3D plot In the default mode the image will be displayed as a picture see figure 2 20 If you have chosen a presentation mode the window displays all possible parameters you may modify For example after selecting the item 3D plot you have to specify the following parameters Step the distance of plot lines in pixels Colored use the gray value of a pixel to draw a line segment instead of one eraphic color Eye height Eye distance view point Scale height of 3D plot Row and Column position of the center Visualization gt Set Parameters gt Pen Here the display modes for regions and XLDs are specified You can select the color HALCON 6 0 4 34 CHAPTER 2 GRAPHICAL USER INTERFACE Visualization Parameters Lut fill margin shape original Line width 7 Example Figure 2 21 Settings of parameter pen single or multiple the drawing mode filled or bor
230. y terminate the execution of a program mode Run by selecting Execute gt HDevelop 2003 08 01 2 3 MAIN WINDOW 23 Stop If you do so HDevelop continues processing until the current operator has com pleted its computations This may take a long time if the operator 15 taking a lot of time to execute There is no way of interrupting a HALCON operator After interrupting a pro eram you may continue it by selecting Execute gt Run and Execute gt Step You may even edit the program before restarting it e g by parameter modification by exchanging operators with alternatives or by inserting additional operators Execute gt Deactivate Edit gt Activate It is often useful for testing purposes to prevent some lines of the program from being executed This can be done by selecting the appropriate lines in the program window and calling Execute gt Deactivate from the menu With this an asterisk 15 placed on the beginning of the selected lines and hence appear as comments in the program window They have no influence on the program during runtime The deactivated lines are still part of the program 1 they are stored like all other lines in a file and their variables are still needed like all other variables To reverse this action you may press item Edit Activate Note that you can insert a comment into your program by using the operator comment Execute gt Set Break Point Execute gt Clear Break Point These menu items s
231. y value intensity and the corresponding standard deviation of the selected region These are computed with the operator intensity The second display shows the output of the operator min max gray This operator com putes the distribution histogram of gray values in the image and returns the gray values corresponding to an upper and lower percentile of the distribution This percentile can be selected with the slider at the top of the display For a percentile of 0 the default the minimum and maximum gray values of the region are returned The display also shows the range of gray values in the region 1 the difference between the maximum and minimum gray values In the third display the gray value entropy of the selected region is displayed see the operator entropy gray Again this is a feature derived from the histogram of gray values in the region The feature entropy measures whether the gray values are distributed equally within the region This measure 15 always smaller than 8 for byte images the HDevelop 2003 08 01 2 3 MAIN WINDOW 31 only supported image type for this operator Only images with equally distributed gray values reach this maximum value The feature anisometry measures the symmetry of the distribution see the operator anisometry Perfectly symmetric histograms will have an anisometry of 0 5 The fourth display contains gray value features derived from the coocurrence matrix of the selected region are
Download Pdf Manuals
Related Search
Related Contents
June 2008 - Texas Department of Aging and Disability Services Drame MVCA2 : Reference and Installation manual Télécharger le réglement du POS INSTRUCTIONS 取扱説明書 ESPECIFICACIÓN DE PRODUCTO VEGEfast PACK Kenwood KAC-6203 Car Amplifier User Manual Application Note Template Modulo 5 Copyright © All rights reserved.
Failed to retrieve file