## 3 Proposed System
### Software Module
#### 3.1.2 Detection Framework of DataMatrix-ArUco-Hybrid Pattern  
In this section, we introduce the DAH pattern detection framework, which comprises five modules: preprocessing, contour filter, perspective transformation, decoder, and DAH pattern combination. Each module takes the output from the preceding module as input and generates a result, as shown in Figure 2.  
The first process is the preprocessing module, which functions similarly to the operations in the ArUco detection library [22]. The output from the preprocessing module contains the pixel points on each contour, the centroid of each contour, and the hierarchical relationship between each contour. The contour filtering process involves two traversals. In the first traversal, we mark the contours without internal contours as invalid regions because the DM and ArUco regions must have internal contours. According to the design rules, a set of contours with a close centroid is likely to be a DM region. If all contours in the set satisfy the conditions of being convex quadrilaterals and the size of the set is more than two but less than four, we mark these contours as processed. The largest area contour in the set is marked as a candidate DM region and is saved to the set. Each new DM region added to the DM region set must be compared to the existing regions. If the two regions being compared satisfy the following conditions:  
1. The contents of the two DM regions are identical except for the first symbol;
2. The distance between the two DM region centroids is within \(x\) times the side length of the current new DM region, and the \(x\) chosen here is between 1.5 and 2.0, we mark the two DM regions that satisfy the above two conditions as a \"friend DM region\" of the other. This is useful in the DAH pattern combination module. In the second traversal, we focus only on the remaining unprocessed contours. We mark those that can be approximated to convex quadrilaterals as ArUco regions and add them to the ArUco region set. The DM and ArUco regions undergo a preliminary filtering step, which removes regions that are too close to the image boundaries, as well as the smaller of two regions that are in proximity to each other. Each filtered region undergoes perspective transformation to produce a canonical region, which yields a higher decoding success rate. We use the idea from previous ArUco studies to perform the transformation in a different image pyramid layer according to the region size rather than all in the original image. The following process is the decoding  
Figure 2: The detection framework of DAH pattern. module, which aims to extract the encoded content from the canonical DM regions and extract the IDs from the canonical ArUco regions. We use the ZXing library for DM region decoding and the ArUco dictionary definition for ArUco region decoding. After the decode module, all regions remaining in the set are valid regions. The final step of the detection algorithm is to integrate different regions to form a proper DAH pattern region. The DAH pattern combination algorithm is presented in Algorithm 1. The core idea of Algorithm 1 is to use each DM region as an anchor region, bind its friend DM region, and compare it with all unprocessed ArUco regions. We bind the ArUco region and current anchor DM region if the ArUco region satisfies the following conditions:  
1. The ArUco ID and the content of the current DM region satisfy the mapping relationship introduced in Section 3.1.1;
2. The distance between the ArUco centroid and the DM centroid is within \(x\) times the side length of the DM region, and the \(x\) chosen here is between 0.7 and 1.5. The satisfied ArUco and DM regions are stored in a temporary DAH pattern. If the inner marker number of the temporary DAH pattern is more than two, we save the temporary DAH pattern in a temporary DAH pattern set. For each traversal, the current DM region, its friend DM region, and its binding ArUco regions are marked as processed.