## 4 Object Detection in High-Resolution Images Using OPAI
### Modification of DeepSORT for Particle Tracking  
The DeepSORT tracking algorithm associates newly observed objects with existing tracked targets based on both their position and movement information, as well as the similarity of their appearance. This similarity is assessed by computing deep learning feature maps for both the candidate object and the tracked target. The cosine similarity between these feature maps is then calculated and used to link the observed object to the appropriate track. To understand the computational cost of this process, consider the following:  
The output feature map size \(\Phi\) is given by the following:  
\[\Phi= \left(\frac{M+2p-l}{s}+1\right)\times\left(\frac{N+2p-l}{s}+1\right) \tag{11}\]  
where \(M\) is the height of the input image, \(N\) is the width of the input image, \(l\) is kernel size of the convolution, \(s\) is the stride, and \(p\) is padding. For each convolution operation, \(l\times l\) multiplications and additions are performed for each position in the feature map. Therefore, for one filter, the number of computations is as follows:  
\[\Phi\times l^{2} \tag{12}\]  
For \(F\) filters, the total number of computations is as follows:  
\[\Phi\times l^{2}\times F \tag{13}\]  
Assuming \(s=1\) and \(p=\frac{l-1}{2}\), the output size \(\Phi\) approximates \(M\times N\). Therefore, the computational cost for calculating the CNN-based feature map is as follows:  
\[O\left(M\times N\times l^{2}\times F\right) \tag{14}\]  
In contrast, the computational cost for calculating the normalized correlation coefficient (NCC) \(r\) between two images is given in Equation (7). In order to compute the NCC, the following operations are needed:  
- Mean calculation: \(2\times M\times N\) operations;  
- Subtractions: \(2\times M\times N\) operations;  
- Multiplications for the numerator: \(M\times N\) operations;  
- Squaring for the denominator: \(2\times M\times N\) operations;  
- Summations: \(2\times M\times N\) operations;  
- Square roots: one operation;  
- Final division: one operation;  
- Total operations for the NCC: \(9\times M\times N\) operations. The computational cost for calculating the CNN-based feature map is significantly higher than that for computing the normalized correlation coefficient. Consequently, while DeepSORT uses a deep learning appearance descriptor, this study proposes using the normalized correlation coefficient instead to assess object similarity, reducing the computational burden while maintaining an effective object tracking performance. This approach leverages the benefits of appearance-based tracking without the high computational cost associated with deep learning inference in each frame, making it more suitable for real-time applications. Furthermore, the IoU (Intersection over Union) metric used in DeepSORT to calculate the cost between the predicted position and size of a target, based on the Kalman filter, and the observed object is not suitable for objects moving inside a flexible fluid bag. The movement distance of objects such as foreign particles or air bubbles is significantly largerthan their size, making it highly unlikely for the predicted and actual observed object regions to overlap, resulting in an IoU value close to zero most of the time. Therefore, the IoU cannot be used to associate the tracked trajectory with the newly observed target object. To address this, this paper introduces a cost function \(C_{size}(A,\ B)\) based on the object's size, considering that the size of moving objects does not change significantly between movements. The cost function decreases when the sizes of the two objects are similar and increases when the sizes differ. This approach is presented as follows:  
\[C_{size}(A,\ B)=\left|\frac{\left(Size(A)^{2}-Size(B)^{2}\right)}{Size(A)\cdot Size (B)}\right| \tag{15}\]  
where \(A\) and \(B\) are two images to be compared and \(Size()\) is a function that returns the size of an image. This cost function ensures that, when the difference in the sizes of two images is small, the cost becomes small.