# Comparative Analysis of Measurement Tools in the Cognex D900 Vision System
## 4 Comparative Analysis of Cognex D900 Measurement Tools
### Machine Learning-Based Inspection  
_ViDiDetect_ and _ViDiRead_ tools based on deep learning were used to recognize correct and incorrect details and the mold cavity number. The initial part of the program remained unchanged compared to the solution presented using the method presented in the previous section, so was included the _AcquireImage_, _TrainPatMaxRedLine_ and _FindPatMaxRedLine_ functions. The last two functions were used to tell the _ViDi tools_ to move the ROI coordinate system--the system was trained on image fragments that contained detail. The _Image_ field indicates cell _SAS0_, which contains the data structure of the current image. In the _External Fixture_ field, cell _SAS4_ is indicated, containing the displacements of the object in the current photo relative to the template. The _Region_ has been selected to include the part of the detail being inspected. By entering the _Open ViDi Editor_ tab, the vision system training window was opened. Before starting training, it was necessary to prepare a set of photos of details and mark them as good or bad (Figures 16 and 17). In the Bad detail photos, a gray circle indicates the area that the user believed was a defect. The training set contained 24 photos. For the solution search process, it was recommended that the system use 50% of the set of photos so that the operation of the solution could be checked on the remaining photos. The time taken to calculate the solution took approximately one hour. The result is shown in Figure 18.  
Areas recognized by the system as defective, i.e., deviating from the pattern common to photos marked as good, are marked with red spots. The graph on the right side of Figure 19 shows how the solution distinguishes between good and bad photos. As noted, the difference between the result classifying the detail as good and bad was 0.56 mm\({}^{2}\) in the range of 4.8-6.4 mm\({}^{2}\), which is a result sufficient to correctly detect detail defects. Figure 16: Learning images marked as good—green ribbon. In the next step, the _ViDiRead_ function used to read the socket number is placed in cell _A8_. As in the case of the previous function, the Image field shows cell _SA50_ and the _External Fixture_ field shows cell _SA54_. The region was designated to include the nest number--Figure 19.  
After the initial configuration of the _ViDiRead_ tool, the learning screen was opened by pressing the _Open ViDi Editor_ button. A set of training images containing different numbers of sockets in different positions was implemented. In each photo, the area where the sign was placed was indicated and its value was assigned to it. Moreover, 50% of the prepared photos were used for the learning process. The system took about one hour to prepare the solution. The final effect is shown in Figure 20.  
Figure 17: Learning images marked as bad—red ribbon. Figure 18: _ViDiDetect_ tool result. It is important to note that the ViDiDetect function mentioned in the provided text is not something you need to write yourself; it is a pre-existing tool within the Cognex In-Sight Vision Suite software. Cognex, a leading manufacturer of machine vision systems and software, offers a variety of tools and functions as part of their software suite for machine vision applications. ViDiDetect is a specialized tool provided by Cognex for defect detection using deep learning techniques. It is designed to recognize and analyze defects or anomalies in images or visual data. This tool leverages machine learning and artificial intelligence algorithms to identify deviations from a trained model and provides a Pass/Fail result based on its analysis. Users of Cognex's machine vision systems can configure and utilize built-in tools like ViDiDetect to develop and fine-tune machine vision applications for various quality control,  
Figure 19: Configuring the _ViDiRead tool_. Figure 20: The result of running the _ViDiDetect_ and _ViDiRead_ tools. inspection, and defect detection tasks.