# Optical High-Speed Rolling Mark Detection Using Object Detection and Levenshtein Distance
## 3 Camera-Based Rolling Marks Detection
### Parsing with the Aid of Reference Rolling Marks  
Utilizing each known textual structure, a comprehensive reference rolling mark is generated by considering all conceivable combinations of manufacturers, steel qualities, months, manufacturers, and type designations. Placeholder variables are included specifically for the years, as well as for the spaces between each distinct specification. Employing an efficient calculation method, such as tries [8], the weighted Levenshtein distance of the identified characters is computed. The YOLO neural network, employed for detecting the distinctive characters of a rolling mark, can undergo preliminary testing. To achieve this, data that has not been processed by the neural network yet is utilized. The outcomes from the object detections are then compared with the actual values and meticulously documented in a table, known as the confusion matrix. This matrix demonstrates the neural network's performance in terms of accurately identifying characters (referred to as True Positive--TP), instances in which confusion occurs, undetected characters (False Negative--FN), and instances in which characters are detected despite their absence (False Positive--FP). On the basis of the confusion matrix, tailored costs can be assigned to the network. Figure 5 depicts a confusion matrix consisting of 65 classes, encompassing 10 digits (0-9), 26 letters (A-Z), 26 special characters, a hyphen, a dot, a comma, and the background. Each entry in the matrix is normalized relative to the columns. The bluer a field appears, the closer its numerical value is to 1, while a white field corresponds to a numerical value of 0. Figure 5: Confusion matrix with 65 classes. Classes without entries indicate characters that do not occur in the data used for training or evaluation but are still considered in the model. These classes may represent potential characters that could occur in future data or may be included for completeness. The costs for the weighted Levenshtein distance are chosen as follows: characters that are often confused, falsely detected, or not found at all according to the confusion matrix are easier to correct in the subsequent distance calculation. Therefore, the following considerations are made:  
If a class is consistently detected in nearly every instance within the image (FN \(\approx\) 0), the cost of an insert operation is consequently assigned a higher weight. Conversely, for a class that is infrequently detected (FN \(\approx\) 1), the weight assigned to the insert operation is lower. Likewise, the cost of deleting a character can be ascertained by examining the false-positive (FP) values in the confusion matrix. The occurrence of predicting a character class that does not actually exist is reflected in the FP values. If certain classes are more prone to such occurrences, the cost of deleting those characters is set to a lower value. Additionally, the confidence value of the predicted class \(c\) serves as a measure of \"reliability\". For instance, if a character is partially obscured or unclear in the image, a lower confidence value is typically assigned. In reality, there is a higher likelihood of confusion between the number \"0\" and the letter \"O\" compared with, for example, the letter \"E\". The confusion matrix provides insights into which classes are more prone to such confusion (TP = 0), as well as classes that are rarely confused (TP \(\approx\) 1, FP \(\approx\) 0). When there is a high probability of confusion, the cost associated with swapping two characters should be relatively low. It is worth noting that swapping the two characters \(s[i]\) with \(t[j]\) can also be interpreted as deleting \(t[j]\) and inserting \(s[i]\) in place of \(t[j]\). Therefore, the cost must be quantified as higher than a single operation to account for this combined action. To address the potential bias toward shorter strings, the calculated weighted Levenshtein distance is further normalized by dividing it by the sum of the deletion costs \(\mathbf{L}_{0,|t|}\).