# Target Detection Technology of Mechanical, Electrical, and Plumbing Components Based on CV
## 3 Methods
### Camera Imaging Model  
An image comprises numerous pixels, each recording the color and brightness information at its corresponding location. A core issue in camera model research is representing the three-dimensional world in a two-dimensional image. The most commonly used camera imaging model is the Pinhole Camera Model, which describes light passing through a small aperture to form an image on the imaging plane [31]. As illustrated in Figure 1, the pinhole imaging model typically establishes a right-handed Cartesian coordinate system with the camera's optical center as the origin. The object to be captured is positioned along the positive \(z\)-axis, while the imaging plane, comprising photosensitive material, is placed on the negative \(z\)-axis. The imaging plane remains parallel to the xy-plane at z = \(-\)f, where f is the camera's focal length. The \(z\)-axis intersects the imaging plane at point O'. Any light ray emitted or reflected from an arbitrary point P on the object passes through the camera's optical center O and intersects the imaging plane at point P'. Let the coordinates of point P be \([X,Y,Z]^{T}\) and the coordinates of point P' be \([X^{\prime},Y^{\prime},Z^{\prime}]^{T}\). Since P, O, and P' are collinear, Equation (1) holds, which maps any point in three-dimensional space to its corresponding point on the imaging plane. Figure 1: Pinhole camera model. \[\frac{Z}{-f}=\frac{X}{X^{\prime}}=\frac{Y}{Y^{\prime}} \tag{1}\]  
The brightness and color information of each pixel in the image can be obtained by sampling and quantizing the imaging plane. An image coordinate system \(o-u-v\) is established on the imaging plane, typically with the origin at the image's top-left corner. The positive \(u\)-direction is horizontal to the right, parallel to the camera's \(x\)-axis, while the positive \(v\)-direction is vertically downward, parallel to the camera's \(y\)-axis. Typically, there is a simple scaling and translation transformation between the image coordinate system and the imaging plane coordinate system \(o^{\prime}-x-y\). Let the coordinates of \(O^{\prime}\) in the image coordinate system be \([c_{x},c_{y}]\), with \(\alpha\) the scaling factor for the \(u\)-axis and \(\beta\) the scaling factor for the \(v\)-axis. The relationship between the imaging plane coordinate system and the image coordinate system is formulated as follows:  
\[u=\alpha X^{\prime}+c_{x} \tag{2}\]  
\[v=\beta Y^{\prime}+c_{y} \tag{3}\]  
From Equations (1)-(3), it is derived that the pixel coordinates \([u,v]^{T}\) corresponding to any point \([X,Y,Z]^{T}\) in the three-dimensional space are related as follows:  
\[ \begin{bmatrix}u\\ v\\ 1\end{bmatrix} = \begin{bmatrix}\alpha&0&c_{x}\\ 0&\beta&c_{y}\\ 0&0&1\end{bmatrix}\begin{bmatrix}\frac{X}{Y}\\ \frac{Y}{Y}\\ 1\end{bmatrix}  \tag{4}\]  
where matrix \(K\) is the camera intrinsic matrix, which describes the relationship between the coordinates of a point in the three-dimensional space and the corresponding pixel in the image, typically fixed as the camera's inherent parameters set at the factory. It can be observed that, during the imaging process, an object's depth information, i.e., the \(z\)-coordinate, is lost. Thus, all points along the line \(OP\) in the three-dimensional world project to the same point \(P^{\prime}\) on the camera plane. In real-world applications, using the camera coordinate system established in Figure 1 may be inconvenient for model description and subsequent processing. Therefore, for practical reasons, a world coordinate system is often established based on specific requirements, leading to a misalignment between the camera coordinate system and the world coordinate system. Camera extrinsic parameters primarily handle the transformation of any point \(P_{W}=[X_{W},Y_{W},Z_{W}]^{T}\) in the world coordinate system to \(P\) in the camera coordinate system.