## 2 Materials and Methods
### Image Processing for Calculating 3D Surface Coordinates  
As part of the program design, it is necessary to design a code to process the images acquired by the ESP32-CAM devices with the current settings. This code must adjust the image by rectification for distortion correction based on the distortion vectors obtained by calibration. Initially, the rectification of the cameras is computed using the cv2 stereoRectify library. Subsequently, the maps are computed as a basis for distortion correction and image rectification. Subsequent to the rectification of the maps, the rectification of the images is performed. This function yields aligned images with aligned epipolar planes, thereby enabling depth calculation based on the distortion of the image points. Consequently, extraction of the projected laser beam within the image points was implemented. A method employing thresholding was selected. Initially, the camera image undergoes processing and conversion into a monochromatic color image through the utilization of the cv2.cvtColor and cv2.COLOR_BGR2 GRAY functions. The representation of the image frames prior to the extraction of the laser pattern can be observed in Figure 7. Subsequently,  
Figure 5: The photograph illustrates the scene during the process of device calibration. Figure 6: Representation of laser beam projection within the device testing. the image is transformed into binary code using the cv2.trreshold and cv2.TRESH_BINARY functions, and a threshold is chosen within the brightness (threshold) below which all pixels have a value of 0 and above which they have a value of 1. In this way, with respect to the brightness of the monochrome image, it is possible to extract the lighter pixels. Given the utilization of a laser line within the device, it is presumed that the projected laser image is more luminous than its surroundings within the camera image. however. This method of extracting the projected laser beam is simple and efficient, but is sensitive to light reflections or bright areas illuminated by a stronger light source [28]. Consequently, a function for adjusting the threshold is proposed, since brightness is influenced by several factors and settings, from the software adjustment of the settings to the lighting conditions within the scene. Initially, a threshold of 230 is designated. The image within the current threshold is then displayed, and the user can press the + and \(-\) buttons to add and remove threshold values in increments of 5. This process is illustrated in Figure 8.  
As part of the program design, it is necessary to select an appropriate program function to calculate the depth of the 3D point cloud based on the obtained binary image and the disparity between these images. The initial function evaluated was cv2.stereoBM, which utilizes depth calculation based on entire image frames. In this approach, common visual features are sought within a stereo pair of images, allowing for registration across both camera frames and unique distinction. The generation of blocks with similar disparity is  
Figure 8: The display of the acquired binary image of the left camera. (**a**) Using thresholding before adjustment, (**b**) after adjustment of thresholding value. Figure 7: Representation of images before laser pattern extraction. (**a**) Left image, (**b**) right image. predicated on these common features. A similar function is cv2.stereoSGBM, which has been demonstrated to produce more accurate results by taking into account not only the visual elements but also the surrounding blocks. However, when implemented within the proposed program, both cv2.stereoBM and cv2.stereoSGBM failed to generate a 3D point cloud. This failure can be attributed to the fact that these functions are designed to analyze a color stereo image pair and look for correspondences based on visual features. They are not designed to be used in combination with a laser projector.