## 2 Materials and Methods
### System's Software Programming and Workflow
#### 2.2.4 Image Acquisition, Plant Identification, and Localization  
After the plant recognition and the recording of their positions, several measures are implemented to acquire images of the plants and analyze the data collected from the diverse sensors (Figure 11). If the _Autofind_ button has been initially activated, the _Find_Plant()_ function is executed to locate the plants before capturing the final images. The Photo_Sequence procedure will attempt to locate the specified number of plants as indicated on the control panel (number of plants set by the user). In case fewer plants are detected under the moving system, the process of finding plants will be repeated. If, once again, an insufficient number of plants is detected, the finding plants sequence will be repeated for the final time. If the desired number of plants is still not found, the photo sequence will proceed with capturing images of the plants that were detected. Upon completion of the Photo_Sequence, the LED strip will begin to flash, alerting the user to the issue. To resolve the error, the user can press the corresponding button on the control panel (\"Clear Error\" button, Figure 9a), thereby deactivating the LED strip. Otherwise, a new folder is created with the current date and time as its name. The positions of the plants are retrieved from the relevant file (this function is useful for predefined targets). The carriage is then moved to the next plant's position. Subsequently, both the NIR and RGB images are taken from the exact same spot after positioning the carriage appropriately. In the RGB image, the plant is identified, and various measurements such as the total projected leaf contour (perimeter), the centroid and total projected leaf area (PLA), etc., are computed and displayed. The carriage is repositioned multiple times in different locations around the identified central point of the plant, with the aim of collecting multiple measurements using the distance sensors. Subsequently, the weighted distance, as described by the linear model in Section 2.1.3 (Equation (1)) between the plant and the sensors, is computed. This information can be utilized further for the plant dimensions (e.g., maximum diameter) calculation. For example, in order to provide a reasonable approximation of the lettuce width (maximum diameter), the simple geometric scenario as shown in Figure A3 of Appendix A can be used. Following this and the triangulation principle, an approximation of a plant's diameter (\(D\)) in metric units (mm) is given as follows: \(D=(P\cdot L)/f\), where in the equation, the letter \(P\) denotes the plant's width as it appears in the RGB imaging sensor in pixels, \(f\) stands for the focal length of the camera in mm (i.e., \(3\pm 0.5\)% mm, [48]), and \(L\) represents the distance between the camera/sensors and the plant (in mm), as provided by Equation (1). The pixel size is known from [48] to be 3 \(\upmu\)m. The procedure, \"get data from sensors and compute the plant's dimensions\", as depicted in the Photo_Sequence flowchart in Figure 11 below, relies on both distance sensors to acquire meaningful measurements at present. This information will be enriched in a future  
Figure 11: Flowchart of _Photo_Sequence._upgrade of the system by fusing data also from the stereo imaging pair. Nevertheless, for the purposes of the present work, dimensions related to growing plants' parameters are provided in pixels. Various images including the original, cropped, and images with calculated data overlaid, are saved in the previously created folder. This entire process is repeated until all the available plants have been identified and localized. Currently, the predetermined maximum time that can be devoted for each plant identification is established at a specific value, which has been determined through empirical methods to include a margin of error (\(2\pm 0.5\) min). Should the system exceed this threshold, it is deemed a failure and proceeds to identify the subsequent plant.