# Robust and Accurate Recognition of Carriage Linear Array Images for Train Fault Detection
## 3 Methodology
### Objective Function Design  
When both the scene and target point sets possess an equal number of points with known correspondence, the weight vector \(w\) can be directly determined using the least squares method. However, the correspondence between point sets, based solely on object detection results, is often uncertain. Additionally, object detection imperfections, such as false positives or negatives, can cause point count mismatches between the scene and target sets. This makes an analytical determination of the weight variables challenging.  
To address this, we employed numerical optimization techniques. Iterative optimization, guided by the objective function, yields the weight variables.  
The objective function's design aims to measure the alignment between two point sets, particularly when their sizes differ and correspondence is unclear. The Gaussian Mixture Model (GMM) is introduced to represent these point sets. Alignment is gauged by evaluating the congruence between the GMMs of both sets. The GMM's probability density at location \(x\) is defined as \(gmm(x,U)=\sum_{i=1}^{k}\omega_{i}\phi(x|u_{i},\Sigma_{i})\), where \(u_{i}\) represents a point in set \(U\), the Gaussian distribution centered at \(u_{i}\) is expressed as follows:  
\[\phi(x|u_{i},\Sigma_{i})=\frac{\exp\left[-\frac{1}{2}(x-\mu_{i})^{T}\Sigma_{i} ^{-1}(x-\mu_{i})\right]}{\sqrt{\left(2\pi\right)^{d}|\det(\Sigma_{i})|}} \tag{3}\]  
The L2 distance is chosen to determine the similarity between the GMMs of the two sets. \(M\) represents the target point set, corresponding to centers of components in a standard carriage image, and \(x\) a point within \(M\). \(S\) denotes the scene point set, representing centers of bounding boxes in the image being identified. \(w\) is the vector of transformation parameters from \(S\) to \(M\), comprising weights. The goal is to identify the optimal weight vector \(w\) that minimizes the function \(F(S,M,w)\):  
\[\begin{split} F(S,M,w)=\min_{w}(\int Gx)\\ G=\left(gmm(x,T(S,M,w))-gmm(x,M)\right)^{2}\end{split} \tag{4}\]  
The squared term in the objective function can be decomposed into three components as shown in Equation (5). Since the third term, \(gmm(x,M)^{2}\), is constant during optimization, focus is placed on the remaining two parts.  
\[\begin{split}\left(gmm(x,T(S,M,w))-gmm(x,M)\right)^{2}=A-B+C\\ A=gmm(x,T(S,M,w))\\ B=2 gmm(x,T(S,M,w))gmm(x,M)\\ C=gmm(x,M)^{2}\end{split} \tag{5}\]  
Considering that the scale distortion in linear array images mainly manifests in the scanning direction, only 1D GMM similarity calculations based on horizontal coordinates are considered. If optimal transformation parameters are identified within a specific horizontal range, any point sampled within this range ensures a minimized objective value. Thus, uniform sampling within the model point set's horizontal range is adopted for quick GMM similarity estimation.  
For optimization, the Levenberg-Marquardt (L-M) algorithm is utilized, a nonlinear least squares optimization method that merges the Gauss-Newton method with gradient descent [33]. Each iteration requires gradient and Hessian matrix computations for parameter updates. In this context, the objective function's Jacobian matrix is essential. Applying the chain rule, we derived the following:  
\[\frac{\partial F}{\partial w_{i}}=2{\sum}_{i=1}^{N}\frac{\partial\Delta(x_{i}) }{\partial w_{i}} \tag{6}\]  
where \(\Delta(x)=gmm(x,T(M,w))-gmm(x,S)\). As \(gmm(x,S)\) is a known constant, the partial derivative of \(\Delta(x)\) with respect to \(w