{'fraction_non_alphanumeric': 0.03467071251966734, 'fraction_numerical': 0.014553832321870084, 'mean_word_length': 4.69786552828175, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Research on Fast Recognition and Localization of an Electric Vehicle Charging Port Based on a Cluster Template Matching Algorithm

With the gradual maturity of driverless and automatic parking technologies, electric vehicle charging has been gradually developing in the direction of automation. However, the pose calculation of the charging port (CP) is an important part of realizing automatic charging, and it represents a problem that needs to be solved urgently. To address this problem, this paper proposes a set of efficient and accurate methods for determining the pose of an electric vehicle CP, which mainly includes the search and aiming phases. In the search phase, the feature circle algorithm is used to fit the ellipse information to obtain the pixel coordinates of the feature point. In the aiming phase, contour matching and logarithmic evaluation indicators are used in the cluster template matching algorithm (CTMA) proposed in this paper to obtain the matching position. Based on the image deformation rate and zoom rates, a matching template is established to realize the fast and accurate matching of textureless circular features and complex light fields. The EPnP algorithm is employed to obtain the pose information, and an AUBO-i5 robot is used to complete the charging gun insertion. The results show that the average CP positioning errors (x, y, z, Rx, Ry, and Rz) of the proposed algorithm are 0.65 mm, 0.84 mm, 1.24 mm, 1.11 degrees, 0.95 degrees, and 0.55 degrees. Further, the efficiency of the positioning method is improved by 510.4% and the comprehensive plug-in success rate is 95%. Therefore, the proposed CTMA in this paper can efficiently and accurately identify the CP while meeting the actual plug-in requirements.


Introduction
With the reduction of petroleum energy amounts, new energy-based vehicles have become more important [1]. Electric vehicles have the advantages of producing no harmful gas emissions, being clean and environmentally friendly, having fast acceleration and low cost, and not consuming petroleum energy. Therefore, they have received significant financial support from the governments of many countries and have become the future development direction of most automobile manufacturers. Due to all of these factors, electric vehicles have been developing rapidly in recent years [2][3][4][5], and automatic parking and driverless technologies have gradually matured [6]. Accordingly, electric vehicle users do not need to reach parking spaces and garages. It should be noted that manual charging is impractical, the fast-charging connector cable is heavy and thick, and the plugging force is large. In addition, manual insertion also has potential safety hazards [7]. Therefore, a method for the automatic charging of new-energy electric vehicles is urgently needed.
The main solution to the problem of electric car charging is that a robot realizes an automatic connection between the charging gun and the electric car charging port (CP). At present, a number of research institutions and companies have proposed their own implementation plans for overcoming the mentioned problem [8][9][10][11][12]. Currently, the main strategy for the automatic charging of electric vehicles includes the recognition of a charging port's pose and robotic insertion machinery. Thus, the recognition and positioning of a CP denote a prerequisite for a robot to complete the charging, and thus ensuring the accuracy and stability of CP recognition is an important guarantee for successful robot charging. Therefore, the realization of rapid and high-precision identification and positioning of a CP is crucial to the automatic charging technology of electric vehicles.
The CP identification methods can be roughly divided into feature recognition-based identification methods and non-feature recognition-based identification methods. Feature recognition means adding a specific mark to a CP to reduce the difficulty of identification, but the CP needs to be modified. In the identification methods without feature recognition, the original CP features are recognized directly without changing the CP. In terms of feature recognition, in [13], the authors added white labels to the four fixed-point positions of a CP, and based on monocular vision, they used feature matching to achieve preliminary positioning and adjusted the visual error according to the six-dimensional force sensor data to achieve the plug-in. However, they did not provide information on positioning accuracy. In [14], five white circular features around a CP were used, and based on the principle of the farthest distance from the center to the contour, the distance from the center of the ellipse was obtained. In addition, the geometric solution method was used to obtain the pose information on the CP. Under the light intensity of 4 klux, the positioning error of this method was 1.4 mm, the angle error was 1.6 • , and the insertion success rate was 98.9%. In [15], Halcon commercial vision software and template matching were used to obtain the location of features, and the least square fitting method was employed to calculate the perspective transformation to obtain information on the CP pose, with a successful insertion rate of 80%. In [16], the authors used the surf feature point matching method to perform an indoor target positioning and insertion experiment. The specific positioning accuracy was not given, and the obtained insertion success rate was 96%. Further, in [17], the positioning error of an indoor CP was tested by Halcon commercial vision software using the template matching algorithm based on binocular positioning. The average position error was 2.5 mm, and the average angle error was 0.8 • . In [18], the authors used the Hough circle to obtain the contour features of a CP by the monocular vision method. However, the recognition time was long, and the positioning distance was strict. The position error was ± 1 mm, and the angle error was ± 1 • . In [19], the recognition accuracy was tested in different scenarios based on monocular vision. The position coordinates of the characteristic points were obtained by the quadratic curve standardization method. In all test scenarios, the average position error was 0.88 mm, and the average angle error was 0.89 • .
According to the above-presented research, the positioning of feature points is a key step for obtaining the CP pose. As a common feature acquisition method, a template matching algorithm has been applied to various areas of production and life. However, light, background, and occlusion can affect the accuracy of template matching. When the object size and rotation angle change, the number of templates increases, thereby increasing the template matching time and affecting the matching efficiency. In recent years, a number of studies have achieved certain contributions to the efficiency and robustness of template matching [20][21][22][23][24][25][26][27]. In [20], a template matching algorithm that combines the Gaussian pyramid transform and a particle swarm optimization algorithm, and which can improve the algorithm matching efficiency, was proposed. In [21], the authors proposed an edge template matching algorithm, which uses gradient contour information, adopts a strategy of a directional guide pixel difference, and can reduce the interference of image noise on the matching result. In [22], the authors developed a block matching algorithm, which is based on voting strategy, to reduce the computational burden and a block matching algorithm according to the characteristics of spatial intensity distribution, which can improve the robustness to speckle noise and occluded targets. In [23], a fast template matching algorithm based on the network control, which uses down-sampling to ensure the original accuracy and to improve the matching efficiency, was proposed. Further, in [24], a robust objective function based on the maximum correlation criterion was defined to match features, and then it was optimized for translation and rotation parameters; the effectiveness and robustness of the proposed method were verified. A non-texture target recognition method, which uses the edge layered template matching method to detect and recognize, and thus improves the detection efficiency, was proposed in [25]. In [26], a detector that can detect straight-line contours was proposed for recognition of non-textured parts. The geometric feature gray-scale inversion invariance algorithm based on straight-line contours was used to improve the accuracy and robustness of template matching.
However, the current research on the automatic charging of electric vehicles has still been in the laboratory phase, and the recognition speed of the algorithm is slow. By adding identification, a vehicle has to be modified, which is not conducive to large-scale application. Therefore, this study uses a method of featureless identification. In the search phase, the round recognition positioning method based on the characteristic root is used for rough positioning, and the EPnP algorithm is used to calculate the CP pose. In the aiming phase, for template matching algorithms, most of the above-mentioned algorithms are for images with texture features and linear contour positioning without texture. However, for untextured circular feature images, it is difficult to improve the efficiency and accuracy of the matching algorithm due to the lack of locating corners. Based on the CP characteristics, this paper proposes a cluster template matching algorithm (CTMA) which improves the efficiency and robustness of recognition in a complex-light field and provides a guarantee for accurate positioning of the EPnP algorithm, thereby realizing efficient and accurate CP recognition.

CP Structure and Complex Scene Description
This study considers the fast-charging ports of electric vehicles. The national standard number is GBT20234.3-2011. A CP is shown in Figure 1. The relative position coordinates of a CP are also shown in Figure 1. A CP consists of a total of nine cylindrical holes, which correspond to charging terminal communication 1 (S+), charging terminal communication 2 (S−), vehicle connection confirmation 1 (CC1), vehicle connection confirmation 2 (CC2), DC power supply positive (DC+), DC power supply negative (DC−), low voltage auxiliary power positive (A+), low voltage auxiliary power negative (A−) and DC protective ground (PE). Although the CP considered in this study is of a standard size, the actual use of a CP shows different degrees of wear. In addition, factors such as the manufacturer's differentiation and surface reflection can interfere with the identification and positioning of a CP. A CP's surface will also be differentiated under different environments and lighting, which introduces severe difficulties to identification and positioning.

Experimental Platform
The data acquisition and experiment plug-in platform mainly include the control module, vision module, and robot plug-in actuator. The CP image data collection platform

Experimental Platform
The data acquisition and experiment plug-in platform mainly include the control module, vision module, and robot plug-in actuator. The CP image data collection platform is shown in Figure 2. According to the plug-in requirements, the actuator used an AUBO-i5 articulated robot, and the repeat positioning accuracy was 0.02 mm. The camera, from Daheng Image Vision Co., Ltd. (Haidian District, Beijing), was model number MER-125-30GM/C-P, and the resolution was 1292 × 964 pixel. The camera lens model was M0814-MP2 from Combada Company, with a lens size of 8 mm. We used the camera calibration method of Zhang [28], and hand-eye calibration was done using Axelrod's method [29].

Experimental Platform
The data acquisition and experiment plug-in platform mainly include the control module, vision module, and robot plug-in actuator. The CP image data collection platform is shown in Figure 2. According to the plug-in requirements, the actuator used an AUBO-i5 articulated robot, and the repeat positioning accuracy was 0.02 mm. The camera, from Daheng Image Vision Co., Ltd.( Haidian District, Beijing), was model number MER-125-30GM/C-P, and the resolution was 1292 × 964 pixel. The camera lens model was M0814-MP2 from Combada Company, with a lens size of 8 mm. We used the camera calibration method of Zhang [28], and hand-eye calibration was done using Axelrod's method [29].

Image Data Collection
To verify the reliability of the algorithm, the weather was divided into sunny and overcast weather, and the time was divided into four time periods: time 1: 8:30-11:30, time 2: 11:30-14:30, time 3: 14:30-17:30, and time 4: 18:00-21:00. Since the indoor daytime test environment was relatively stable, it was subdivided into six situations according to actual scenes, as shown in Tables 1 and 2. Further, to improve the actual positioning accuracy, the positioning process was divided into two phases, the search phase and the aiming phase, as shown in Figure 3.

Image Data Collection
To verify the reliability of the algorithm, the weather was divided into sunny and overcast weather, and the time was divided into four time periods: time 1: 8:30-11:30, time 2: 11:30-14:30, time 3: 14:30-17:30, and time 4: 18:00-21:00. Since the indoor daytime test environment was relatively stable, it was subdivided into six situations according to actual scenes, as shown in Tables 1 and 2. Further, to improve the actual positioning accuracy, the positioning process was divided into two phases, the search phase and the aiming phase, as shown in Figure 3.

Technical Route
As mentioned above, the recognition process was divided into two phases, the phase and the aiming phase. In the search phase, the complexity of positioning wa but the requirements for positioning accuracy were low. Therefore, in this phase, adaptable recognition and positioning algorithm was selected. In contrast, in the phase, the complexity of positioning was low, but the requirements for posi

Technical Route
As mentioned above, the recognition process was divided into two phases, the search phase and the aiming phase. In the search phase, the complexity of positioning was high, but the requirements for positioning accuracy were low. Therefore, in this phase, a more adaptable recognition and positioning algorithm was selected. In contrast, in the aiming phase, the complexity of positioning was low, but the requirements for positioning accuracy were high, so in this phase, an algorithm with high positioning accuracy was selected. Based on these requirements, the CP identification process in this paper is shown in Figure 4.
The specific steps presented in Figure 4 are described within the description of the phase they belong to, as set out below.
In the search phase, the following operations are conducted: (1) The image data are collected and converted into a gray image, and bilateral filtering is performed on the obtained gray image. (2) The canny algorithm is used to obtain contours, and the smaller contours are eliminated. We will re-screen the outline based on the length breadth ratio of the minimum outer rectangle. (3) The characteristic root method is used to fit the contour to an ellipse, and eliminate irrelevant ellipses according to the discrimination conditions. (4) When the number of qualified feature points is not less than six, the qualified feature information is converted into a pixel position matrix, the corresponding threedimensional space position information is formed into a space position matrix, and the EPnP algorithm is used to solve the pose so as to obtain the pose information on the CP relative to the camera. accuracy were high, so in this phase, an algorithm with high positioning accuracy was selected. Based on these requirements, the CP identification process in this paper is shown in Figure 4.  Figure 4. Flow chart of the CP identification method.
The specific steps presented in Figure 4 are described within the description of the phase they belong to, as set out below.
In the search phase, the following operations are conducted: (1) The image data are collected and converted into a gray image, and bilateral filtering is performed on the obtained gray image. In the aiming phase, the following operations are conducted: (1) Before the recognition, the robotic arm is inserted into the CP in the robot teaching mode, and then, according to the result of the hand-eye calibration, the robot arm is controlled to pull out the CP. (2) Images are collected in front of the CP as a template, and the developed template extraction software is used to make the feature template and gradient feature template of the CP. (3) During recognition, image information is collected at the aiming position. First, the bilateral filtering is performed on the image, and then the image contour information is extracted using the canny operator. (4) To improve the accuracy and efficiency of template matching, this paper proposes a method based on the CTMA. In the proposed method, the area of each feature point is matched according to the contour information, thereby reducing the matching time and improving the robustness of the template matching algorithm in an unstable light field environment. (5) Effective features are selected according to decision-making conditions; the effective feature center point position is converted into a pixel position matrix, and the position corresponding to the effective feature is transferred into a spatial position matrix. The EPnP algorithm is used to obtain the CP pose relative to the camera.
The robot is guided to complete the plug-in according to the positioning result.

Feature Recognition Method of a CP in Search Phase
In the search phase, a CP has a large deflection angle relative to the camera, and this study uses the characteristic root method to fit the ellipse based on the mathematical characteristics of the ellipse. Namely, the characteristic root method is used to fit the ellipse using the principle of coordinate transformation between the ellipse coordinate system and the measurement coordinate system. The ellipse can be expressed in the standard coordinate system as follows: where X e = ( x e y e ) T denotes the ellipse coordinate and a and b are the semi-major and semi-minor axes of the ellipsoid, respectively. The conversion relationship between the measurement coordinate X and the ellipse coordinate X e is given by: where (X 0 Y 0 ) represents the translation between the ellipse coordinate system and the measurement coordinate system and R(α) is the rotation matrix, which is defined as: The part where the coordinate of the measuring point does not satisfy the elliptic equation denotes a residual, and the residual equation is given by: The Taylor series expansion and linearization are used to obtain the following relationship: The error equations for all the characteristic points are listed and iteratively solved under the principle of least quadratic, and the characteristic parameters of the ellipse are obtained. By using Equation (2), the conversion relationship between the measured coordinates and the ellipse coordinates can be obtained; in addition, by substituting (0, 0) T into the left side of Equation (2), the coordinates of the center of the ellipse in the measurement coordinate system are obtained by using the calculated parameters.
Thus, the position of the ellipse of the CP and the center point of the ellipse can be fitted. The result is shown in Figure 5.
In the aiming phase, the deflection angle and deflection position of a CP are relatively small, and the complexity of this phase is low, but the requirements for positioning accuracy and efficiency are high. Based on the above situation, a template matching algorithm is used to locate the feature points in the aiming phase. Since the accuracy of the template matching algorithm is sensitive to light, rotation, and object size, the CTMA is developed to improve the accuracy and adaptability of template matching.
The error equations for all the characteristic points are listed and iteratively solv under the principle of least quadratic, and the characteristic parameters of the ellipse a obtained. By using Equation (2), the conversion relationship between the measured co dinates and the ellipse coordinates can be obtained; in addition, by substituting (0,0) in the left side of Equation (2), the coordinates of the center of the ellipse in the measureme coordinate system are obtained by using the calculated parameters.
Thus, the position of the ellipse of the CP and the center point of the ellipse can fitted. The result is shown in Figure 5.

Objectives of the search phase
Canny operator obtains contour information of preprocessed image In the aiming phase, the deflection angle and deflection position of a CP are relative small, and the complexity of this phase is low, but the requirements for positioning acc racy and efficiency are high. Based on the above situation, a template matching algorith is used to locate the feature points in the aiming phase. Since the accuracy of the templ matching algorithm is sensitive to light, rotation, and object size, the CTMA is develop to improve the accuracy and adaptability of template matching.
(1) Template design The camera is kept at the focal length of the CP so that the axis of the camera is p allel to the axis of the CP. The camera's exposure is adjusted to obtain stable ima (1) Template design The camera is kept at the focal length of the CP so that the axis of the camera is parallel to the axis of the CP. The camera's exposure is adjusted to obtain stable image information. In the actual exposure algorithm, the average measurement value of an image is adjusted to between 110-140. The specific operation flowchart is shown in Figure 6. information. In the actual exposure algorithm, the average measurement value of an image is adjusted to between 110-140. The specific operation flowchart is shown in Figure 6.
Image acquisition with fixed exposure B0 Exposure adjustment factor K Calculate the average brightness value L0 of the picture L0 less than 140 L0 greater than 110 Targeting phase positioning/ template making Figure 6. The flowchart of the automatic exposure algorithm.
The collected CP images are taken as the original template data, and the self-made template-making software is used to extract the template of each feature, as shown in Figure 7. The collected CP images are taken as the original template data, and the self-made template-making software is used to extract the template of each feature, as shown in Figure 7.
Targeting phase positioning/ template making   Figure 7 shows the preprocessed original image template and the gradient map template, which are stored in the matching file directory. The above step completes the template production process.
(2) Recognition process based on CTMA To improve the efficiency and accuracy of template matching, the CTMA uses the location information on feature points to match the location information on the feature contour, and then matches the search area. Based on the coordinate system in Figure 1, this study defines DC−, DC+, S−, CC2, S+, CC1, A−, PE, and A+ as features 1-9,  Figure 7 shows the preprocessed original image template and the gradient map template, which are stored in the matching file directory. The above step completes the template production process.
(2) Recognition process based on CTMA To improve the efficiency and accuracy of template matching, the CTMA uses the location information on feature points to match the location information on the feature contour, and then matches the search area. Based on the coordinate system in Figure 1, this study defines DC−, DC+, S−, CC2, S+, CC1, A−, PE, and A+ as features 1-9, respectively. The position and radius information of each feature point are obtained as (x on , y on , r on ), where n = 1, 2, · · · , 9. In this study, an image was obtained in the aiming phase, and the contour information was obtained after image preprocessing. The three special features obtained from all contours are feature 1, feature 2, and feature 8. The specific implementation process is as follows.
The feature points that meet the primary selection conditions are screened out, and all the contour pixel positions and the circumscribed rectangle contour information are defined as x pn , y pn , w pn , h pn , where n = 1, 2, · · · , n, thereby establishing feature 1. The contour matching function between features 2 and 8 is given by: c pn w pn +c pn h pn 2r on x pn − x pm 2 + y pn − y pm 2 = c length nm c pn w pn + c pn h pn + c pm w pm + c pm h pm /4 + D nm x pn − x pj 2 + y pn − y pj 2 = c length_nj (c pn w pn + c pn h pn + c pj w pj + c pj h pj )/2 where D nm denotes the shortest distance between the circumscribed surfaces of features n and m; c length nm is the deviation coefficient of features n and m; c length nj is the deviation coefficient of features n and j; c pn , c pm , and c pj denote the contour adjustment factors of features n, m, and j, respectively; a represents the coefficient for adjusting the matching trend, which is 10 here; and R(n) represents the matching degree under the nth combination.
According to all obtained contour information, Equation (6) is used to perform contour matching. Based on the contour matching degree R(n), x p1 , y p1 , w p1 , h p1 , x p2 , y p2 , w p2 , h p2 , and x p8 , y p8 , w p8 , h p8 are obtained, and thus the matching preselected positions can be determined. The specific implementation equations are as follows: x pn = sin arccot y on x on − arccot ·s + arccot 2d o1 x o2 −x o1 ·s · x on 2 + y on 2 y pn = cos arccot y on x on − arccot where s is the direction of the feature point; the value of s for features 1, 3, 4, and 6-8 is one and for features 2, 5, and 9 it is −1.
Thus, the position x pn , y pn of the characteristic points of the template matching can be obtained. Then, the area information of the feature can be calculated by: x rn ∈ x pn − c f ·r on l op , x pn + c f ·r on l op y rn ∈ y pn − c f ·r on l op , y pn + c f ·r on l op , where l op is the density of pixels; x rn and y rn are the matching ranges in the x and y directions, respectively; and c f is the matching area coefficient. Before template matching, a suitable template needs to be obtained, and the template scaling factors in the x and y directions are established as follows: where x op1 , y op1 , x op2 , y op2 , x op8 , and y op8 denote the coordinate information on the templates of features 1, 2, and 8 in the original image, respectively, and c mx and c my are the scaling factors of the template in the x and y directions, respectively. In this way, the rotation angle and zoom factor of the template are obtained, thereby providing the best conditions for template matching. This study uses the normalized square method for the evaluation of template matching. The matching decision conditions are given by Equation (10): where T(x , y ) is the pixel value of the template image at (x , y ) and I(x + x , y + y ) is the original image's pixel value at (x + x , y + y ). By performing the above-presented operations on the preprocessed and gradient images, the position information on the feature points is obtained. The final matching decision condition is given by: x hpn − x gpn < ∆error1 y apn = y hpn +y gpn 2 y hpn − y gpn < ∆error1 x pn − x apn < ∆error2 where (x hpn , y hpn ) is the matching coordinate value of the feature point in the original image, (x gpn , y gpn ) is the matching coordinate value of the feature point in the gradient image, (x apn , y apn ) is the final coordinate value of the feature point; (x pn , y pn ) is the coordinate value of the contour feature point, ∆error1 is the allowable error range of a single matching degree, and ∆error2 is the allowable error range of the final matching degree. The specific operation process and results of the CTMA are shown in Figure 8.  Figure 8. Obtaining feature points.

CP Pose Calculation
By using the above-mentioned algorithm, the pixel position information of the effective feature points can be obtained, and when combined with the space coordinate position of a CP, it can be transformed into a PNP problem [30]. This study uses the pixel coordinates and and the corresponding spatial position coordinates ( , , and ) to obtain the position information ( , , and ) and angle information ( , , and ). To solve the PNP problem, different solving methods require different effective feature points. Therefore, to improve the positioning accuracy, based on at least six feature points in the space, the space coordinate point vector and the pixel coordinate point vector are established, and the position of a coordinate point in the space can be expressed by setting the weighting factor as follows: where is the known three-dimensional coordinate point in the world coordinate system, is the nth feature point of in the world coordinate system, and is the

CP Pose Calculation
By using the above-mentioned algorithm, the pixel position information of the effective feature points can be obtained, and when combined with the space coordinate position of a CP, it can be transformed into a PNP problem [30]. This study uses the pixel coordinates x apn and y apn and the corresponding spatial position coordinates (x on , y on , and z on ) to obtain the position information x pos , y pos , and z pos and angle information x ang , y ang , and z ang . To solve the PNP problem, different solving methods require different effective feature points. Therefore, to improve the positioning accuracy, based on at least six feature points in the space, the space coordinate point vector and the pixel coordinate point vector are established, and the position of a coordinate point in the space can be expressed by setting the weighting factor as follows: where p w m is the known three-dimensional coordinate point in the world coordinate system, c w n is the nth feature point of p w m in the world coordinate system, and α mn is the weighting factor. The positioning process of the EPnP algorithm is as follows: (1) Select at least four feature points in the world coordinate system; (2) Calculate the weighting factor α mn ; (3) Calculate the feature points in the camera coordinate system; (4) Calculate the minimum error by the Gauss-Newton algorithm and define the error as follows: where c c m is the nth feature point of c w m in the camera coordinate system; (5) Obtain the three-dimensional coordinates of the feature in the camera coordinate system;

CP Pose Error
During data collection, to obtain the actual pose information on a CP relative to the camera, the specific operations were performed: (1) The world coordinates of the robot base and the CP were kept unchanged.
(2) When the robot was in the state of teaching, the charging gun was moved into the CP, and this pose was used as the robot's zero pose. (3) The charging gun was moved out of the CP, and the robot moved randomly within the recognition range to obtain image information. (4) Based on the zero-pose information and pose information of the robot, the pose information of the camera relative to the CP was obtained, which denoted the actual pose information of the camera relative to the CP. (5) The absolute value of the difference between the actual pose information and the theoretical pose was used as a basis for error judgment.

Search-Phase Pose Accuracy Test
The search phase can be roughly divided into CP feature recognition and pose calculation. The recognition effect results of feature points are presented in Figure 9. The pose error results of the CP are given in Table 3.  (5) The absolute value of the difference between the actual pose information and the theoretical pose was used as a basis for error judgment.

Search-Phase Pose Accuracy Test
The search phase can be roughly divided into CP feature recognition and pose calculation. The recognition effect results of feature points are presented in Figure 9. The pose error results of the CP are given in Table 3.  According to the results in Table 3, it can be concluded that the errors could be divided into three categories: (1) indoor-night pose errors that were small; the positioning accuracy was the highest and the average pose errors in the directions of ( , , , , , and ) were 1.57 mm, 1.80 mm, 2.02 mm 1.96°, 2.17°, and 1.67°, respectively; (2) outdoor-overcast condition pose errors; the error at noon was relatively large and the overall pose error was small. The average pose errors in the directions of ( , , , , , and ) were 1.75 mm, 1.86 mm, 2.16 mm, 2.10°, 2.19°, and 1.87°, respectively; (3) outdoor-sunny day pose errors that were the largest, especially at noon; the average outdoor pose errors in the directions of ( , , , , , and ) were 2.22 mm, 2.27 mm, 2.58 mm, 2.53°, 2.68°, and 1.97°, respectively. According to the obtained results, the change and intensity of light had a significant impact on the position and orientation of the CP. Under strong light, the CP surface and the light form a certain angle, making the illumination uneven, and thus causing errors in feature positioning or even resulting in unrecognizable situations.

Aiming-Phase Pose Accuracy Test
The aiming phase can be mainly divided into feature recognition and pose calculation. The recognition effect results of feature points in different scenarios are presented in Figure 10. The theoretical pose information was obtained by the pose calculation algorithm, and the actual pose error information was obtained based on the error judgment basis. The pose errors of the CP in different scenarios are shown in Table 4. According to the results in Table 3, it can be concluded that the errors could be divided into three categories: (1) indoor-night pose errors that were small; the positioning accuracy was the highest and the average pose errors in the directions of (x, y, z, Rx, Ry, and Rz) were 1.57 mm, 1.80 mm, 2.02 mm 1.96 • , 2.17 • , and 1.67 • , respectively; (2) outdoor-overcast condition pose errors; the error at noon was relatively large and the overall pose error was small. The average pose errors in the directions of (x, y, z, Rx, Ry, and Rz) were 1.75 mm, 1.86 mm, 2.16 mm, 2.10 • , 2.19 • , and 1.87 • , respectively; (3) outdoor-sunny day pose errors that were the largest, especially at noon; the average outdoor pose errors in the directions of (x, y, z, Rx, Ry, and Rz) were 2.22 mm, 2.27 mm, 2.58 mm, 2.53 • , 2.68 • , and 1.97 • , respectively. According to the obtained results, the change and intensity of light had a significant impact on the position and orientation of the CP. Under strong light, the CP surface and the light form a certain angle, making the illumination uneven, and thus causing errors in feature positioning or even resulting in unrecognizable situations.

Aiming-Phase Pose Accuracy Test
The aiming phase can be mainly divided into feature recognition and pose calculation. The recognition effect results of feature points in different scenarios are presented in Figure 10. The theoretical pose information was obtained by the pose calculation algorithm, and the actual pose error information was obtained based on the error judgment basis. The pose errors of the CP in different scenarios are shown in Table 4.

Aiming-Phase Pose Accuracy Test
The aiming phase can be mainly divided into feature recognition and pose calculation. The recognition effect results of feature points in different scenarios are presented in Figure 10. The theoretical pose information was obtained by the pose calculation algorithm, and the actual pose error information was obtained based on the error judgment basis. The pose errors of the CP in different scenarios are shown in Table 4.  Based on the results in Table 4, it can be concluded that the errors could be divided into three categories: (1) indoor-night pose positioning errors that were relatively small, achieving the highest positioning accuracy; the average pose errors in the directions of ( , , , , , and ) were 0.52 mm, 0.66 mm, 1.05 mm, 1.01°, 0.73°, and 0.42°, respectively; (2) outdoor-overcast condition pose positioning errors; the error at noon was relatively large; the overall pose error was small; the average pose errors in the directions of ( , , , , , and ) were 0.65 mm, 0.80 mm, 1.24 mm, 1.09°, 0.84°, and 0.51°, respectively; (3) sunny-outdoor condition pose positioning errors; the overall pose error increased significantly, especially at noon; the average outdoor pose errors in the directions of ( , , , , , and ) were 0.80 mm, 1.08 mm, 1.42 mm, 1.24°, 1.29°, and 0.73°, respectively. Based on the presented results, it can be concluded that during the aiming phase, the external light caused great interference to the positioning. The influence of the external light on the aiming phase was much greater than the influence on the search phase, and it was the dominant affecting factor of pose positioning.

Charging Gun Insertion Test Verification
As the above-presented test results show, the indoor and night test results were basically the same, the outdoor overcast test results were basically the same, and the outdoor sunny test results were basically the same, and thus the test was divided into three cases: (1) indoor case (sunny/overcast time 1/time 2/time 3/time 4); (2) outdoor-sunny case (time 1/time 2/time 3); and (3) outdoor-overcast case (time 1/time 2/time 3). We tested 100 sheets for each condition, as shown in Table 5. Table 5. Plug-in data information.

Positioning
Time Min Light Max Light Number of Based on the results in Table 4, it can be concluded that the errors could be divided into three categories: (1) indoor-night pose positioning errors that were relatively small, achieving the highest positioning accuracy; the average pose errors in the directions of (x, y, z, Rx, Ry, and Rz) were 0.52 mm, 0.66 mm, 1.05 mm, 1.01 • , 0.73 • , and 0.42 • , respectively; (2) outdoor-overcast condition pose positioning errors; the error at noon was relatively large; the overall pose error was small; the average pose errors in the directions of (x, y, z, Rx, Ry, and Rz) were 0.65 mm, 0.80 mm, 1.24 mm, 1.09 • , 0.84 • , and 0.51 • , respectively; (3) sunny-outdoor condition pose positioning errors; the overall pose error increased significantly, especially at noon; the average outdoor pose errors in the directions of (x, y, z, Rx, Ry, and Rz) were 0.80 mm, 1.08 mm, 1.42 mm, 1.24 • , 1.29 • , and 0.73 • , respectively. Based on the presented results, it can be concluded that during the aiming phase, the external light caused great interference to the positioning. The influence of the external light on the aiming phase was much greater than the influence on the search phase, and it was the dominant affecting factor of pose positioning.

Charging Gun Insertion Test Verification
As the above-presented test results show, the indoor and night test results were basically the same, the outdoor overcast test results were basically the same, and the outdoor sunny test results were basically the same, and thus the test was divided into three cases: (1) indoor case (sunny/overcast time 1/time 2/time 3/time 4); (2) outdoor-sunny case (time 1/time 2/time 3); and (3) outdoor-overcast case (time 1/time 2/time 3). We tested 100 sheets for each condition, as shown in Table 5. Aiming at the above test plan and using the proposed identification and localization method, the test was conducted using an AUBO-i5 robot as an actuator. The results are shown in Table 6. Based on the test results, for the indoor case (sunny/overcast time 1/time 2/time 3/ time 4), the average plug-in rate of the CP was 99%; for the outdoor-sunny case (time 1/ time 2/time 3), the average plug-in rate of the CP was 92%; and lastly, for the outdoorovercast case (time 1/time 2/time 3), the average plug-in rate of the CP was 94%. The positioning accuracy is positively correlated with the success rate of plug-in.

Results Comparison
To evaluate the performance and advanced nature of the proposed method, the algorithm was compared with the two most advanced CP pose positioning methods. The method was implemented in Python programming language with PyCharm 2017 on a personal computer equipped with an Intel ® Core™ i5-6300HQ processor and 16 GB of memory. The running time was the average time of all test data. The comparison results are given in Table 7. Based on the results in Table 5, the combination of the feature recognition algorithm based on this paper and the EPNP algorithm has the highest positioning accuracy, and the proposed CP identification and positioning method overperformed the comparison methods regarding the identification efficiency. In terms of positioning accuracy, the overall positioning accuracy of the proposed method was improved during the search phase. In the aiming phase, the average positioning accuracy of the proposed algorithm was improved compared with that of Yin's algorithm [18] and was basically the same as that of Quan's algorithm [19]. In the two phases, the overall recognition efficiency is 510.4% higher than the current optimal method. The proposed algorithm achieved obviously higher recognition accuracy and efficiency than the other two algorithms.

System Error
The system error can be mainly divided into two parts. The first part is the error generated by a robot, and the repeated positioning accuracy of the robot in this study was about 0.05 mm. The second part is the error of the photographing process-the disturbance of the base and the impact during plug-in can affect the zero-position pose, thus reducing the positioning accuracy.

Feature Point Recognition Deviation in Search Phase
In the search phase, the main factors that affect the location of feature points are kernel selection during bilateral filtering and selection of contour height and low thresholds when obtaining contour information. When the inclination angle was too large, the characteristic arc chamfers overlapped; due to the CP contour deformation and wear, the contour fitting deviation occurred.

Feature Point Recognition Deviation in Aiming Phase
In the aiming phase, the proposed CTMA was used for feature point recognition. Based on the exposure algorithm proposed in this paper, the image can be quickly adjusted to the appropriate exposure, and the logarithmic function evaluation standard is used to match the position of contour features, which can reduce the large deviation of template matching position caused by uneven illumination of the image, as shown in Figure 11. It should be noted that conventional template matching methods had large matching errors under both gradient and gray map matchings. The main reason for this was that under the external light, the inclination of the light source and the similarity of features caused the failure of the conventional template matching methods. Compared with the current advanced matching methods, our method improves the matching efficiency and accuracy in the complex light field environment, and the matching robustness is also significantly improved.
the proposed CP identification and positioning method overperformed the comparison methods regarding the identification efficiency. In terms of positioning accuracy, the overall positioning accuracy of the proposed method was improved during the search phase. In the aiming phase, the average positioning accuracy of the proposed algorithm was improved compared with that of Yin's algorithm [18] and was basically the same as that of Quan's algorithm [19]. In the two phases, the overall recognition efficiency is 510.4% higher than the current optimal method. The proposed algorithm achieved obviously higher recognition accuracy and efficiency than the other two algorithms.

System Error
The system error can be mainly divided into two parts. The first part is the error generated by a robot, and the repeated positioning accuracy of the robot in this study was about 0.05 mm. The second part is the error of the photographing process-the disturbance of the base and the impact during plug-in can affect the zero-position pose, thus reducing the positioning accuracy.

Feature Point Recognition Deviation in Search Phase
In the search phase, the main factors that affect the location of feature points are kernel selection during bilateral filtering and selection of contour height and low thresholds when obtaining contour information. When the inclination angle was too large, the characteristic arc chamfers overlapped; due to the CP contour deformation and wear, the contour fitting deviation occurred.

Feature Point Recognition Deviation in Aiming Phase
In the aiming phase, the proposed CTMA was used for feature point recognition. Based on the exposure algorithm proposed in this paper, the image can be quickly adjusted to the appropriate exposure, and the logarithmic function evaluation standard is used to match the position of contour features, which can reduce the large deviation of template matching position caused by uneven illumination of the image, as shown in Figure 11. It should be noted that conventional template matching methods had large matching errors under both gradient and gray map matchings. The main reason for this was that under the external light, the inclination of the light source and the similarity of features caused the failure of the conventional template matching methods. Compared with the current advanced matching methods, our method improves the matching efficiency and accuracy in the complex light field environment, and the matching robustness is also significantly improved. The influence of the type and inclination of the light source on the recognition result is shown in Figure 12. In the actual environment, the light source characteristics of a CP are mainly defined by three factors: direct sunlight (A), ambient scattered light (B), and The influence of the type and inclination of the light source on the recognition result is shown in Figure 12. In the actual environment, the light source characteristics of a CP are mainly defined by three factors: direct sunlight (A), ambient scattered light (B), and lighting (C). D, E, F and O represent the vertices that make up the sun's altitude angle θ 1 and the sun's deflection angle θ 2 . At night, the light mainly comes from lighting (C). In the case of indoors and outdoors under overcast conditions, the light source mainly comes from the scattered light (B) of the environment. When it is sunny outdoors, the light source mainly comes from direct sunlight (A), while the light from lighting (C) is covered, and thus a CP will be affected by the sun's altitude angle θ 1 and the sun's deflection angle θ 2 . The angles θ 1 and θ 2 cause different degrees of shadows in CP features, which is the main reason for the recognition deviation; particularly, in the template matching method, the matching accuracy is relatively significantly lower in this than in other recognition scenarios. This causes a severe problem for template matching algorithms. Although the mentioned factors can affect the matching effect, compared with the results before the improvement, the accuracy of feature matching is significantly improved under the proposed CTMA, which can successfully solve the problem of poor robustness of the template matching algorithms in complex scenarios.
lighting (C). D, E, F and O represent the vertices that make up the sun's altitude angle and the sun's deflection angle . At night, the light mainly comes from lighting (C). In the case of indoors and outdoors under overcast conditions, the light source mainly comes from the scattered light (B) of the environment. When it is sunny outdoors, the light source mainly comes from direct sunlight (A), while the light from lighting (C) is covered, and thus a CP will be affected by the sun's altitude angle and the sun's deflection angle . The angles and cause different degrees of shadows in CP features, which is the main reason for the recognition deviation; particularly, in the template matching method, the matching accuracy is relatively significantly lower in this than in other recognition scenarios. This causes a severe problem for template matching algorithms. Although the mentioned factors can affect the matching effect, compared with the results before the improvement, the accuracy of feature matching is significantly improved under the proposed CTMA, which can successfully solve the problem of poor robustness of the template matching algorithms in complex scenarios.

Feature Point Pose Calculation Error
When solving the pose by using the EPnP method, the positioning accuracy mainly depends on the three-dimensional space position of the feature point and the coordinate position of the feature point pixel. During the plug-in process of a CP, different degrees of deformation and wear can be caused, resulting in changes in the three-dimensional space position of the CP. In the process of pose calculation, the spatial mapping relationship changes, which affects the pose calculation accuracy.

Calibration Influence on Result Accuracy
The positioning process involves camera parameter calibration and hand-eye parameter calibration. The camera calibration accuracy is mainly affected by the calibration board, calibration picture definition, and calibration method. This part of the impact is very small. The hand-eye calibration error is mainly the error of the matrix conversion between the end of the robot arm and camera position, and this error is relatively small. Therefore, the location of feature points is the major factor that affects the pose identification accuracy.

Conclusions
In this paper, an identification and positioning system of a CP of an electric vehicle is proposed, and the positioning accuracy of the proposed system is tested in different scenarios. The plugging test of the charging gun is completed under the drive of the robotic arm. Compared with the advanced CP positioning methods, in the search phase, the proposed method uses the feature root algorithm to fit the gradient map and the

Feature Point Pose Calculation Error
When solving the pose by using the EPnP method, the positioning accuracy mainly depends on the three-dimensional space position of the feature point and the coordinate position of the feature point pixel. During the plug-in process of a CP, different degrees of deformation and wear can be caused, resulting in changes in the three-dimensional space position of the CP. In the process of pose calculation, the spatial mapping relationship changes, which affects the pose calculation accuracy.

Calibration Influence on Result Accuracy
The positioning process involves camera parameter calibration and hand-eye parameter calibration. The camera calibration accuracy is mainly affected by the calibration board, calibration picture definition, and calibration method. This part of the impact is very small. The hand-eye calibration error is mainly the error of the matrix conversion between the end of the robot arm and camera position, and this error is relatively small. Therefore, the location of feature points is the major factor that affects the pose identification accuracy.

Conclusions
In this paper, an identification and positioning system of a CP of an electric vehicle is proposed, and the positioning accuracy of the proposed system is tested in different scenarios. The plugging test of the charging gun is completed under the drive of the robotic arm. Compared with the advanced CP positioning methods, in the search phase, the proposed method uses the feature root algorithm to fit the gradient map and the preprocessed image contour to obtain the position information of the feature points. In the aiming phase, based on the proposed CTMA, the logarithmic function discriminant method is used to achieve contour matching, and precise matching is performed in the contour area to obtain the position information on feature points. The CP poses were calculated using the EPnP algorithm, and the manipulator is adjusted to complete the insertion work according to the obtained CP pose.
According to the test results, it can be concluded that the indoor, night pose accuracy is the highest, and the pose accuracy is the worst in the outdoor environment on sunny days. The average positioning accuracy values in the directions of (x, y, z, Rx, Ry, and Rz) are 0.65 mm, 0.84 mm, 1.24 mm, 1.11 • , 0.95 • , and 0.55 • , respectively. The results show that the success rate of insertion in different scenarios is positively correlated with the positioning accuracy. The success rates of indoor and outdoor insertions are 99% and 93%, respectively. Compared with the advanced recognition methods, while improving the recognition accuracy, the proposed method achieves significantly improved recognition efficiency, which provides a guarantee for efficient and accurate CP recognition.
In the future, the proposed recognition algorithm could be optimized to achieve a good recognition effect even on a sunny day outdoors and to further improve the positioning efficiency and robustness of the proposed algorithm.