## 2 Materials and Methods
### System's Design and Construction
#### 2.1.3 Hardware: Sensors, Auxiliary Electronics, and Raspberry Pi
The HC-SR04 ranging module (Figure 6c) [52] includes an ultrasonic transmitter, a receiver, and a control unit for determining the distance to an object. This sensor measures a range from 2 cm to 400 cm with an accuracy of 0.3 cm. The camera and the sensors were positioned in very close proximity to one another. For the purposes of this work, a specific experiment was performed to test the calibration process of both distance sensors, while examining the possibility of the existence of linear dependence in the datasets with those of manual measurements (true height). In this study, a sample (3D-printed box with dimensions \((W\times L\times H):89.7\) mm \(\times\) 99.6 mm \(\times\) 29.7 mm) was placed sequentially every 1 cm at a distance ranging from approximately 225 mm to 700 mm below the lens of the RGB camera and the sensors (Figure A2a, of Appendix A), and 48 RGB images were captured. The sensors were employed to calculate the distance of the sample from each sensor. The purpose of this experiment in the present work was twofold: The first was to test the calibration process of both distance sensors and to establish a relationship of their outputs as compared to the ground truth height by performing measurements in a range that matches the final application (Figure 1f). The second was to gather insight regarding the scale conversion of pixels to physical measurement units such as millimeters (mm), which are necessary for analyzing measurements like the lettuce diameter or the total projected leaf area. By analyzing the object in all these images (e.g., by simple averaging the distance in pixels of both different sides of the sample object, as appear in the images versus the distance in reality in millimeters), the scale (pixels/mm) as well as the factor (mm\({}^{2}\)/pixels) along the various distances/depths could be estimated (Figure A2b, of Appendix A). From these calculations, the resolution can be approximated. Furthermore, accurate distance calculations for a lettuce plant as depicted in an image (such as its maximum diameter) can be achieved with reasonable precision, assuming that the two extremity control points on the leaves that are utilized for the maximum diameter calculation and belong to its contour's perimeter lie nearly in the same focal plane, such that they appear approximately  
Figure 7: (**a**) Scatter plot showing the relation of height (distance) measured in the experiment with the ToF (in black) and ultrasonic (in pink) distance sensors, their average readings (dashed red line), and the best fitted line after applying multiple linear regression (yellow), as related to the true height (small filled green–blue circles); (**b**) same best fitted line after applying multiple linear regression as in (**a**) but as a 3D scatter plot; (**c**) zoomed-in image of the cyan rectangular region (colored figure online). at a similar distance from the camera. However, all measurements related to the lettuce diameter and its area in this study are presented in pixels. Although this approach does not provide absolute measurements in metric units, it continues to be valuable, since it enables the relative comparative analysis of lettuce plants, since they are monitored using the same imaging system. Nevertheless, prior to fitting a specific model to the acquired data using the 2 sensors, we initially investigated if a linear relationship could be established. For this purpose, correlation coefficient matrices \((r)\) were formed, considering a pairwise variable combination of the average readings of 30 measurements per height distance acquired with each sensor (all results converted to mm) and the manual measurements as well. Since the three correlation coefficient matrices that were formed (Table 1) were too close to 1, there was a strong indication that the measurements acquired with the different sensors in pairs could be linear correlated.