# Vessel Velocity Estimation and Docking Analysis: A Computer Vision Approach
## 4 Methodology
### Ropes on the Bollards Detection  
To analyze the docking and undocking times, one strategy has been developed for detecting the ropes on the mooring bits. According to the information provided by the port authorities, a vessel is considered \"docked\" when it is securely tied to 2 to 8 mooring bits. Once all the required mooring bits were securely tied, the docking time was recorded. It is important to note that the synchronization of each mooring bitt detection was not part of our system development. The responsibility for synchronizing the mooring bits lies with the port employees. Our work primarily focuses on the classification algorithm for the mooring bits. This subsection will outline the strategy employed to analyze each individual mooring bitt.  
The strategy used for identifying the cable tied to the mooring bitt was the comparison of image similarity through the Structural Similarity Index (SSIM). SSIM [7] is a perception metric that quantifies image quality degradation caused by processing such as data compression or loss during data transmission. It is a complete reference metric that requires two images from the same image capture, a reference image, and a posterior image. Thus, an image with the cable tied to the bitt was used as a reference to identify whether the cable was tied. Prior to using SSIM, a sequence of treatments was implemented to reduce noise and, primarily, the effects of illumination.  
The treatments were as follows:  
* Definition of the analysis region: The image was initially cropped to define the Region of Interest (ROI), which in this case, was the limits of the mooring bitt.
* Removal of the background: The image background was removed to avoid possible distortions caused by features unrelated to the ROI.
* Conversion to grayscale: The original RGB image then only had one color channel, varying in intensity between 0 (black) and 255 (white).
* Histogram equalization: The image's histogram was equalized, which aims to improve contrast, to expand the intensity range.
* Binarization: Being in grayscale, a threshold intensity value, or thresh, was established to determine whether that pixel should be considered or not.  
After the image processing steps were applied, the image with the cable tied to the mooring ball was used as the reference image for comparison. All subsequent input images were compared to this reference image using the Structural Similarity Index (SSIM)  
Figure 1: Vessel velocity model diagram.  
metric. A grid search was performed on the training dataset to determine the optimal SSIM threshold parameter (\(\theta_{1}\)). The search involved trying different threshold values and evaluating their performance in terms of accuracy and precision. The goal was to identify the best threshold value to classify tied and non-tied images accurately.  
Images with SSIM values above \(\theta_{1}\) were considered to be tied images, while images with SSIM values below \(\theta_{1}\) were classified as non-tied images. This threshold was chosen to ensure a high level of accuracy in identifying images with the cable tied to the mooring ballard while minimizing false positives. The algorithm's performance was evaluated using a separate test dataset, and the results showed that the algorithm could accurately identify tied images with a high degree of precision. The Figure 2 shows the flowchart of proposed strategy.