## 5 Image Processing  
For the experiment, computer vision was used to approximate the bending angle of the finger joint. The use of image processing for this type of experiment setup ensures an accurate approach to collecting measurements, which means that, apart from the calculation error, the measurement error is reduced to the initial marking of the object and the appropriate placement of the camera (both calibrations are addressed in the first instance of the experiment). The advantage of setting up an experiment with a high color contrast in the imaged scene lies in the fact that black and white image regions have a distinct difference in pixel values between the object and the background, which helps in detecting the desired object region. In the presented experiment, 3D-printed finger of black color is placed on the white background. The image processing task is divided into two parts: recognizing the segment of the joint of the 3D-printed finger that bears the load and determining the bending angle when the joint is loaded.  
The camera records the video from which the necessary images are extracted (in the initial position of the 3D-printed finger and under the mentioned loaded case) for real-time object detection. One of the most effective object detection techniques that serve as a point of reference for object detection in computer vision projects is the bounding-box-based object detection. Bounding-box detections are represented by outlining the rectangles, which fully bound the objects in the image, with the x- and y-image coordinates of the rectangles' centers, as well as with the width, and height of the rectangles. After that, the bending angle about the y-axis (vertical axis of the image coordinate system) is calculated. As was said in Section 4, image processing is performed using a program written in Python, using the OpenCV library of algorithms with the function cv2.MinAreaRect(). The cv2.MinAreaRect() function employs the rotating calipers approach to identify the minimal rectangle that encompasses the object region in the image. First, the original image (Figure 8 left) is segmented using thresholding-based segmentation. The rectangle extraction procedure begins by determining the convex hull of the set of points on the boundary of segmented object region and subsequently rotating a line segment, known as \"calipers\" around the convex hull while measuring the dimensions of the rectangle created by the calipers and convex hull during each rotation. The rectangle with the least area is selected as the minimum area rectangle.  
\begin{table}
\begin{tabular}{c c} \hline \hline
**Printing Parameter** & **Value** \\ \hline Printing temperature & 235 \({}^{\circ}\)C \\ Print bed temperature & 90 \({}^{\circ}\)C \\ Bed surface & Glass \\ Layer height & 0.15 mm \\ Nozzle diameter & 0.4 mm \\ Flexure hinge infill & 100\% \\ Color & Black \\ Nominal diameters of the filament & 1.75 mm \\ \hline \hline \end{tabular}
\end{table}
Table 2: Parameters used for 3D-printed Taulman Nylon 230.  
Figure 8 shows an example of extracting an object using the function cv2.minAreaRect() [31], which extracts a rectangle (bounding box) of the smallest area around the desired shape. The lower portion of the compliant finger that is being imaged is covered to guarantee that just the rectangle that is of interest for the presented analysis, i.e., the rectangle with the smallest area, will be extracted.  
Figure 9 shows an example of a loaded finger joint using the developed function for measuring the bending angle about the y-axis (vertical axis of the image coordinate system). A segment of interest is isolated by markers of contrasting color value because the algorithm separates pixels of low and high color properties (hue, color saturation, and value) and then identifies the largest morphologically closed contour inside the processed image.  
The value shown in Figure 9a is the initial position, while Figure 9b represents the difference between the found bending angle and the image coordinate system y-axis.