# Rapid Detection of Key Phenotypic Parameters in Wheat Grains Using Linear Array Camera
## 2 Materials and Methods
### Detection System
#### 2.2.2 Software Design  
To enhance the efficiency of wheat grain image acquisition and simplify its operation process, upper-computer software supporting the detection system's hardware was designed. The main functions of the software include real-time control of the detection system, visualizing the shooting results, adjusting and saving the motion control parameters, and setting the image detection parameters. The main interface of the software is shown in Figure 4, which includes a start button, a parameter adjustment interface, a camera calibration interface, and an ROI (Region of Interest) area selection interface. * Motion control interface  
A motion control interface is developed for the ECL608 motion control card (Shenzhen Zmotion Technology Co., Ltd., Shenzhen, China) and the servo control system, as shown in Figure 5. After the program is compiled and run, the motion control interface displays information such as the connection status, motion status, position, and speed of the servo, which facilitates the observation of relative displacement changes. Meanwhile, it also shows the status interface of input/output ports. When the system switches to the manual state, the motion control parameters on the interface can be adjusted, and the set operating parameters can be saved to the database. During the system operation, the database parameters set by the user will be called. Figure 4: Main interface of wheat grain online detection. Figure 3: Control unit flow chart. * Camera calibration interface  
When processing and analyzing images to obtain the actual parameters of wheat grains, a system is required to determine the actual value corresponding to each unit pixel in the collected image and then obtain the actual measured values of the phenotypic traits. Size calibration is necessary when the device is used for the first time or after the camera parameters are changed (the HG-150 honeycomb calibration plate is selected as the calibration plate, and the diameter of the circular dot is 5 mm). The user opens the calibration plate image taken by the MVS software in the camera calibration interface and checks whether the roundness and aspect ratio of the resulting representation meet the requirements (>0.95), as shown in Figure 6. In the camera calibration module, local images can be directly imported, and the pixel equivalent will be automatically calculated and displayed. At the same time, the data will be saved in the database. The resulting representation in the lower right corner allows the operator to observe whether the calibration image effect is feasible. The steps to obtain the actual pixel value are as follows: (1) Perform preprocessing procedures such as threshold segmentation, region screening, and morphological processing on the calibration plate image through the Halcon software to obtain the feature regions of the circular dots. (2) Use the minimum bounding rectangle operator and the roundness operator to, respectively, obtain the mean values of the horizontal and vertical pixel lengths of the diameters of all the circular dots on the calibration plate, as well as the roundness values. Convert the unit into micrometers, and the ratio of the actual value of the diameter  
Figure 5: Motion control parameter interface. Figure 6: Camera calibration interface. of the circular dot to the obtained number of pixels is the actual value of a single pixel. The specific formula is as follows:  
\[P=\frac{D\times 1000}{2L}, \tag{4}\]  
where \(P\) represents the actual physical dimension; \(D\) represents the diameter of the calibration plate dots; and \(L\) represents half the side length of the minimum bounding rectangle. Since the camera has a certain degree of distortion, after adjusting its parameters to the maximum extent, it is necessary to determine the actual shooting effect.