# Comparative Analysis of Measurement Tools in the Cognex D900 Vision System
## 4 Comparative Analysis of Cognex D900 Measurement Tools
### Manual Inspection Execution  
The process of programming the application began with training the vision system on the characteristics of the inspected component. These characteristics are crucial for determining the orientation of the component in subsequent images. The _TrainPatMaxRedLine_ function was used. The _Image_ parameter indicates cell _SASO_ as a cell with an absolute location containing the current photo. The _Fixture_ parameter was set to the value (0,0,0)--the shift in the X axis, Y axis and rotation angle relative to the base photo coordinate system. The _Pattern Region_ parameter was configured. The pattern search area is shown in Figure 5.  
By confirming the selection of the region, the pre-selected photo features marked in green were obtained (Figure 6). The function also took into account a part of the slot number--in order to eliminate the influence of the slot number on pattern matching, parameter values were modified based on the effect of feature extraction. The best result was obtained for the configuration:  
* Coarse Granularity = 12.000;
* Fine Granularity = 6.000;
* Feature Threshold = 26.000. Figure 5: Set the _Pattern Region_ for the reference photo. Figure 6: Pattern features after initial configuration. The Reuse Training Image option was selected--thanks to this, after changing the _Fixture_ or _Pattern Region parameters_, the features of the reference image were updated (Figure 7). In order to search for a detail in the working area of the vision system and assign it an orientation, a function using the pattern learned by the _TrainPatMaxRedLine_ function was used. The _FindPatMaxRedLine_ function is inserted into Spreadsheet. In the configuration window, in the _Image field_, cell _$A$0_ containing the current photo is indicated. The _Fixture parameter_ is set to (0,0,0). _Find Region_ was set to cover as much of the system's field of view as possible--it was assumed that the detail could be freely moved and rotated within the system's field of view. The _Pattern_ parameter is cell _$A$2_, where the _TrainPatMaxRedLine_ function was previously placed. It was assumed that only one detail could be included in the ROI, so _Number to Find_ was set to 1. High pattern matching accuracy was selected to best match subsequent inspections in the current photo. The values in the _Find Tolerances_ field are set so that the pattern is found for a full rotation of the detail. In order to eliminate the influence of small changes in the distance of the detail from the vision sensor, a tolerance of \(\pm 10\%\) of the scale was set. Following the guidelines, the value of the _XY Overlap_ parameter was set to 100% due to the possibility of moving the detail in the ROI. After the initial configuration, the function was verified with the given parameters. The matching results were checked for 73 photos. The distribution of the fit score is shown in Figure 8.  
Analyzing the graph presented in Figure 8, it can be concluded that more than half of the examined details were within the pattern matching score above 90%, and only one photo had a matching level below 70%. The next stage of preparing the application was configuring the function that checks the color of the detail. For this purpose, the _ExtractHistogram_ function was used, which was placed in cell _A$6_. Cell _$A$0_ is indicated in the _Image_ field of the configuration window. The _Fixture_ parameter fields indicate the coordinate system shifts returned by the _FindPatMaxRedLine_ function, respectively: _X axis_ _$C$4_, _Y axis_ _$D$4_, and _rotation angle_ _$E$4_. The region is set as in Figure 5:0  
Figure 5:1 Features of the standard after calibration of the granulation value. Next, the _FindLine_ function was used to detect the edge of a hole that serves as a positioning function for a detail installed at a later stage of the production process. The mentioned function is placed in cell _A8_. _The Image_ parameter points to cell _SA50_, _Fixture_ to cells _SC54_, _SD54_ and _SE54_.