Visual detection method for in-place installation of high-voltage connecting rod key
Through the combination of visual detection methods and support vector machine and HOG features, the efficiency and accuracy of high-voltage connecting rod key installation detection is solved, and a higher detection accuracy and automation level is achieved.
Patent Information
- Application Number
- CN202411963876.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-05-02
AI Technical Summary
In the prior art, manual detection efficiency is low, detection accuracy decreases with time, and the detection requirements for high-voltage connecting rod keys cannot be met, and there is a risk that the keys are not installed in place.
The visual detection method is adopted, by obtaining the high-voltage connecting rod image, detecting the keyway area, generating a mask, intercepting the rivet area, and using the support vector machine and HOG feature extraction method to classify the rivets, and determine that the key is installed in place.
It improves the detection accuracy of key installation, reduces the risk of key installation, enhances the degree of production automation, and reduces manual inspection costs.
Smart Images

Figure CN119915808A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of intelligent manufacturing technology, and more specifically, to a method for visually detecting whether a high-voltage connecting rod key is installed in place. Background Art
[0002] Key installation is an important part of the connecting shaft assembly. Whether the connecting shaft can transmit stably depends on the reliability of key installation. The key is usually pressed into the keyway of the rod by a press. While pressing into the keyway, a rivet cutter will press on the surface of the rod, forming a rivet mark. At present, the detection of whether the key is correctly installed is mainly through manual visual inspection, which has low detection efficiency and leads to long detection time. The method of visual key detection can improve the detection efficiency, quickly and accurately determine whether the key is installed in place, and improve the degree of automation of the equipment.
[0003] With the upgrade of automation, visual inspection technology has been widely used, and the SVM+HOG method has a higher recognition accuracy for scratches and defects on metal parts. The main disadvantages of the existing technology are as follows:
[0004] 1. Manual detection is inefficient, and detection accuracy decreases over time;
[0005] 2. There are threaded textures on the surface of the high-voltage connecting rod, and the background environment is complex. The existing visual inspection method cannot meet the inspection requirements for key installation;
[0006] 3. After the high-pressure connecting rod key is installed, it may fall out after being pressed in, and NG parts may be mixed with OK parts, causing production accidents. Summary of the invention
[0007] The purpose of the present invention is to overcome the shortcomings of the prior art and provide a visual inspection method for whether a high-voltage connecting rod key is installed in place. The method can use the state of the rivet mark as an evaluation indicator of whether the key will fall out, thereby reducing the risk of the key not being installed in place during production and improving the accuracy of detecting whether the key is installed in place.
[0008] As a first aspect of the present invention, a method for visually inspecting whether a high-voltage connecting rod key is installed in place is provided, comprising the following steps:
[0009] Step S1: Acquire an image of a high-voltage connecting rod to be inspected;
[0010] Step S2: detecting a keyway region from the image of the high-voltage connecting rod to be detected, and determining whether there is a key in the keyway region;
[0011] Step S3: when there is a key in the keyway area, a mask is generated using the keyway area, and then a rivet mark area on the left side of the keyway and a rivet mark area on the right side of the keyway are cut out from the image of the high-voltage connecting rod to be inspected;
[0012] Step S4: classifying the rivet mark area on the left side of the keyway and the rivet mark area on the right side of the keyway by a support vector machine, so as to obtain a detection result of whether there is a left rivet mark in the rivet mark area on the left side of the keyway and a detection result of whether there is a right rivet mark in the rivet mark area on the right side of the keyway;
[0013] Step S5: When the left rivet mark detection result and the right rivet mark detection result are both that the rivet mark exists, outputting the key installation in place visual detection result of the image of the high-voltage connecting rod to be detected.
[0014] Furthermore, the step S2 further includes:
[0015] Step S21: Roughly locate the keyway area in the image of the high-voltage connecting rod to be detected; if the rough positioning is not successful, output the visual detection result that the key of the image of the high-voltage connecting rod to be detected is not installed in place; otherwise, output the keyway rough positioning area in the image of the high-voltage connecting rod to be detected, and execute step S22; wherein the formula for rough positioning is as follows:
[0016] T0(x,y)=T p (x+α,y+β) (1)
[0017] In formula (1), T p (x, y) is the original area of the keyway in the image of the high-voltage connecting rod to be detected, α is the distance required to be offset in the X-axis direction, β is the distance required to be offset in the Y-axis direction, and T0(x, y) is the rough positioning area of the keyway in the image of the high-voltage connecting rod to be detected;
[0018] Step S22: precisely locate the keyway area in the image of the high-voltage connecting rod to be detected; if the precise positioning is not successful, output the visual detection result that the key of the image of the high-voltage connecting rod to be detected is not installed in place; otherwise, output the keyway precise positioning area in the image of the high-voltage connecting rod to be detected, and execute step S23; wherein the formula for precise positioning is as follows:
[0019] T1(x,y)=T0(x+η,y+λ) (2)
[0020] In formula (2), T0(x, y) is the keyway coarse positioning area in the image of the high-voltage connecting rod to be detected, η is the distance required to be offset in the X-axis direction, λ is the distance required to be offset in the Y-axis direction, and T1(x, y) is the keyway fine positioning area in the image of the high-voltage connecting rod to be detected;
[0021] Step S23: using a precision positioning caliper circle tool to fit a left semicircular arc of the keyway and a right semicircular arc of the keyway in the precision positioning area of the keyway, so as to form a final area of the keyway in the image of the high-voltage connecting rod to be inspected;
[0022] Step S24: determine whether there is a key in the final area of the key slot; if there is a key, execute step S3; otherwise, output a visual inspection result that the key of the high-voltage connecting rod image to be inspected is not installed in place.
[0023] Furthermore, the step S23 further includes:
[0024] Step S231: Use a precision positioning caliper circle tool to fit the left semicircular arc of the keyway and the right semicircular arc of the keyway in the precision positioning area of the keyway to obtain the center coordinates (X left ,Y left ) and radius R left , and the center coordinates of the semicircular arc on the right side of the keyway (X right , Y right ) and radius R right ;
[0025] Step S232: Connect the center of the semicircular arc on the left side of the keyway and the center of the semicircular arc on the right side of the keyway to obtain a line segment between the two centers, and translate the line segment between the two centers by ±R in the vertical direction of the line segment. min , to obtain two translated line segments, and the area formed by the intersection of the two translated line segments and the two semicircular arcs is used as the keyway final area T in the image of the high-voltage connecting rod to be detected. final (x,y); where R min The calculation formula is as follows:
[0026] R min =min(R left ,R right ) (3)
[0027] In formula (3), R left is the radius of the semicircular arc on the left side of the keyway, R right is the radius of the semicircular arc on the right side of the keyway, R min For R left and R right The minimum value in .
[0028] Furthermore, the step S24 further includes:
[0029] Step S241: Calculate the grayscale average value in the final area of the key slot in, The calculation formula is as follows:
[0030]
[0031] Wherein, M is the image width of the final area of the keyway, N is the image height of the final area of the keyway, T final(x, y) is the final area of the keyway, is the grayscale average value;
[0032] Step S242: Determine the average grayscale value in the final area of the key slot Is it greater than the grayscale reference value K? base ;like Represents the final area T of the keyway final If there is no key in (x, y), the key of the high-voltage connecting rod image to be inspected is not installed in place. Otherwise, it represents the final area T of the key slot. final If there is a key in (x, y), proceed to step S3.
[0033] Furthermore, the step S3 further includes:
[0034] Step S31: When there is a key in the final area of the keyway, a mask is generated using the final area of the keyway, and then the final area T of the rivet mark on the left side of the keyway in the image of the high-voltage connecting rod to be detected is calculated. mleft (x, y) and the final area T of the rivet mark on the right side of the keyway mright (x,y), where T mleft (x,y) and T mright The calculation formula for (x,y) is as follows:
[0035] T mleft (x,y)=T pleft (x+δ1,y) (5)
[0036] T mright (x,y)=T pright (x+δ2,y) (6)
[0037] Among them, T pleft (x, y) is the original area of the rivet mark on the left side of the keyway in the image of the high-voltage connecting rod to be detected, T pright (x, y) is the original area of the rivet mark on the right side of the keyway in the image of the high-voltage connecting rod to be detected, T mleft (x, y) is the final area of the rivet mark on the left side of the keyway in the image of the high-voltage connecting rod to be detected, T mright (x, y) is the final area of the rivet mark on the right side of the keyway in the image of the high-voltage connecting rod to be detected, δ1 is the offset along the left side of the X-axis, and δ2 is the offset along the right side of the X-axis, and both δ1 and δ2 are empirical values;
[0038] Step S32: extracting the final rivet mark area T on the left side of the keyway from the image of the high-voltage connecting rod to be detected. mleft (x, y) and the final area T of the rivet mark on the right side of the keyway mright (x,y).
[0039] Furthermore, the step S4 further includes:
[0040] Step S41: extracting the left Hog feature of the final area of the rivet mark on the left side of the keyway and the right Hog feature of the final area of the rivet mark on the right side of the keyway respectively;
[0041] Step S42: training the support vector machine to obtain a trained support vector machine;
[0042] Step S43: Input the left Hog feature and the right Hog feature into the trained support vector machine for classification, so as to obtain the left rivet mark detection result Re of the final area of the left rivet mark of the keyway. left and whether there is a detection result Re of the right rivet mark in the final area of the right rivet mark of the keyway right .
[0043] Furthermore, the step S42 further includes:
[0044] Step S421: establishing a rivet mark recognition library, and dividing a plurality of keyway rivet mark area images in the rivet mark recognition library into a training set and a test set; wherein each keyway rivet mark area image in the rivet mark recognition library is labeled with whether or not there is a rivet mark;
[0045] Step S422: Use the training set to train the support vector machine; wherein, during the training process, the accuracy Acc of the support vector machine is calculated using the test set. When the accuracy Acc of the support vector machine meets the requirements, it means that the training of the support vector machine is completed, and the trained support vector machine is obtained.
[0046] Furthermore, the step S422 further includes:
[0047] Step S4221: classifying all keyway rivet mark area images in the test set by the support vector machine to obtain rivet mark presence or absence detection results of all keyway rivet mark area images in the test set, wherein the rivet mark presence or absence detection results are divided into rivet mark presence and rivet mark absence;
[0048] Step S4222: Calculate the accuracy Acc of the support vector machine, where the calculation formula of the accuracy Acc is as follows:
[0049]
[0050] Among them, TP is the number of keyway rivet mark area images in the test set that are labeled as having rivet marks and classified as having rivet marks, TN is the number of keyway rivet mark area images in the test set that are labeled as having no rivet marks and classified as having no rivet marks, FP is the number of keyway rivet mark area images in the test set that are labeled as having no rivet marks but classified as having rivet marks, and FN is the number of keyway rivet mark area images in the test set that are labeled as having rivet marks but classified as having no rivet marks.
[0051] Furthermore, the step S5 further includes:
[0052] When the left rivet mark detection result and the right rivet mark detection result are not both indicating that a rivet mark exists, a visual detection result of the key not being installed in place of the high-voltage connecting rod image to be detected is output.
[0053] The visual inspection method for whether the high-voltage connecting rod key is installed in place provided by the present invention has the following beneficial effects:
[0054] (1) Improve the automation level of the system and reduce the cost of manual inspection.
[0055] (2) Use support vector machine (SVM) and HOG feature extraction method to classify rivet marks, improve the accuracy of visual inspection of key installation, and reduce the risk of NG parts (defective parts) where the keys are not installed properly being mixed into OK parts (good parts). BRIEF DESCRIPTION OF THE DRAWINGS
[0056] The accompanying drawings are used to provide further understanding of the present invention and constitute a part of the specification. Together with the following specific embodiments, they are used to explain the present invention, but do not constitute a limitation of the present invention.
[0057] Figure 1 The present invention is a flowchart of a method for visually inspecting whether a high-voltage connecting rod key is installed in place.
[0058] Figure 2 A flowchart of a specific implementation of the method for visually inspecting whether the high-voltage connecting rod key is installed in place provided by the present invention.
[0059] Figure 3 A schematic diagram of the rough positioning of the keyway area of the high-voltage connecting rod image to be inspected provided by the present invention.
[0060] Figure 4 A schematic diagram of precise positioning of the keyway area of the high-voltage connecting rod image to be inspected provided by the present invention.
[0061] Figure 5 This is a schematic diagram of the detection results of the semicircular arc on the left side of the keyway provided by the present invention.
[0062] Figure 6This is a schematic diagram of the detection results of the semicircular arc on the right side of the keyway provided by the present invention.
[0063] Figure 7 A schematic diagram of the final area of the keyway provided by the present invention.
[0064] Figure 8 A schematic diagram of the rivet mark area on the left side of the keyway and the rivet mark area on the right side of the keyway provided by the present invention. DETAILED DESCRIPTION
[0065] In order to further explain the technical means and effects adopted by the present invention to achieve the predetermined invention purpose, the specific implementation method, structure, characteristics and effects of a visual inspection method for the installation of a high-voltage connecting rod key proposed by the present invention are described in detail below in combination with the accompanying drawings and preferred embodiments. Obviously, the described embodiments are part of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work belong to the protection scope of the present invention.
[0066] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so as to describe the embodiments of the present invention described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0067] In this embodiment, a visual inspection method for whether the high-voltage connecting rod key is installed in place is provided. Figure 1 As shown, the visual inspection method for the high-voltage connecting rod key being installed in place comprises the following steps:
[0068] Step S1: Acquire an image of a high-voltage connecting rod to be inspected;
[0069] Step S2: detecting a keyway region from the image of the high-voltage connecting rod to be detected, and determining whether there is a key in the keyway region;
[0070] Preferably, if Figure 2 As shown, the step S2 further includes:
[0071] Step S21: Use the PatMax model matching detection method to roughly locate the key slot area in the image of the high-voltage connecting rod to be detected; if the rough positioning is not successful, output the visual detection result that the key is not installed in place in the image of the high-voltage connecting rod to be detected; otherwise, output the key slot rough positioning area in the image of the high-voltage connecting rod to be detected, such as Figure 3 As shown, and step S22 is executed; wherein the formula for coarse positioning is as follows:
[0072] T0(x,y)=T p (x+α,y+β) (1)
[0073] In formula (1), T p (x, y) is the original area of the keyway in the image of the high-voltage connecting rod to be detected, α is the distance required to be offset in the X-axis direction, β is the distance required to be offset in the Y-axis direction, and T0(x, y) is the rough positioning area of the keyway in the image of the high-voltage connecting rod to be detected;
[0074] Step S22: using the PatMax model matching detection method, using the keyway edge detection model to accurately locate the keyway area in the image of the high-voltage connecting rod to be detected; if the accurate positioning is not successful, outputting the visual detection result that the key is not installed in place in the image of the high-voltage connecting rod to be detected; otherwise, outputting the keyway accurate positioning area in the image of the high-voltage connecting rod to be detected, such as Figure 4 As shown, and step S23 is executed; wherein the formula for precise positioning is as follows:
[0075] T1(x,y)=T0(x+η,y+λ) (2)
[0076] In formula (2), T0(x, y) is the keyway coarse positioning area in the image of the high-voltage connecting rod to be detected, η is the distance required to be offset in the X-axis direction, λ is the distance required to be offset in the Y-axis direction, and T1(x, y) is the keyway fine positioning area in the image of the high-voltage connecting rod to be detected;
[0077] Step S23: Use a precision positioning caliper circle tool to fit the left semicircular arc of the keyway and the right semicircular arc of the keyway in the precision positioning area of the keyway, such as Figure 5-6 As shown, to form the final keyway area in the image of the high-voltage connecting rod to be detected, as shown Figure 7 As shown;
[0078] Specifically, the step S23 further includes:
[0079] Step S231: Use a precision positioning caliper circle tool to fit the left semicircular arc of the keyway and the right semicircular arc of the keyway in the precision positioning area of the keyway to obtain the center coordinates (X left ,Y left ) and radius Rleft , and the center coordinates of the semicircular arc on the right side of the keyway (X right , Y right ) and radius R right ;
[0080] Step S232: Connect the center of the semicircular arc on the left side of the keyway and the center of the semicircular arc on the right side of the keyway to obtain a line segment between the two centers, and translate the line segment between the two centers by ±R in the vertical direction of the line segment. min , to obtain two translated line segments, and the area formed by the intersection of the two translated line segments and the two semicircular arcs is used as the keyway final area T in the image of the high-voltage connecting rod to be detected. final (x,y); where R min The calculation formula is as follows:
[0081] R min =min(R left ,R right ) (3)
[0082] In formula (3), R left is the radius of the semicircular arc on the left side of the keyway, R right is the radius of the semicircular arc on the right side of the keyway, R min For R left and R right The minimum value in .
[0083] It should be noted that the parameters of the precision positioning caliper circle tool are shown in Table 1:
[0084] Table 1 Parameters of the precision positioning caliper circle tool
[0085]
[0086] The width of the single caliper of the two caliper circles is 4, the height of the single caliper is 14, the number of calipers is 30, the caliper detection direction is from black to white, the detection radius is 80, and the starting angle is 90 degrees; the coordinates of the center of the caliper circle on the left are (X left ,Y left ), the end angle is 280 degrees, and the coordinates of the center of the caliper circle on the right are (X right , Y right ), with the end angle being -100 degrees.
[0087] Step S24: determine whether there is a key in the final area of the key slot; if there is a key, execute step S3; otherwise, output a visual inspection result that the key of the high-voltage connecting rod image to be inspected is not installed in place.
[0088] Specifically, the step S24 further includes:
[0089] Step S241: Calculate the grayscale average value in the final area of the key slot in, The calculation formula is as follows:
[0090]
[0091] Wherein, M is the image width of the final area of the keyway, N is the image height of the final area of the keyway, T final (x, y) is the final area of the keyway, is the grayscale average value;
[0092] Step S242: Determine the average grayscale value in the final area of the key slot Is it greater than the grayscale reference value K? base ;like Represents the final area T of the keyway final If there is no key in (x, y), the key of the high-voltage connecting rod image to be inspected is not installed in place. Otherwise, it represents the final area T of the key slot. final If there is a key in (x, y), proceed to step S3.
[0093] Step S3: when there is a key in the keyway area, a mask is generated using the keyway area, and then a rivet mark area on the left side of the keyway and a rivet mark area on the right side of the keyway are cut out from the image of the high-voltage connecting rod to be inspected;
[0094] Preferably, if Figure 2 As shown, the step S3 further includes:
[0095] Step S31: When there is a key in the final area of the keyway, a mask is generated using the final area of the keyway, and then the final area T of the rivet mark on the left side of the keyway in the image of the high-voltage connecting rod to be detected is calculated. mleft (x, y) and the final area T of the rivet mark on the right side of the keyway mright (x,y), such as Figure 8 As shown, where T mleft (x,y) and T mright The calculation formula for (x,y) is as follows:
[0096] T mleft (x,y)=T pleft (x+δ1,y) (5)
[0097] T mright (x,y)=T pright (x+δ2,y) (6)
[0098] Among them, T pleft (x, y) is the original area of the rivet mark on the left side of the keyway in the image of the high-voltage connecting rod to be detected, Tpright (x, y) is the original area of the rivet mark on the right side of the keyway in the image of the high-voltage connecting rod to be detected, T mleft (x, y) is the final area of the rivet mark on the left side of the keyway in the image of the high-voltage connecting rod to be detected, T mright (x, y) is the final area of the rivet mark on the right side of the keyway in the image of the high-voltage connecting rod to be detected, δ1 is the offset along the left side of the X-axis, and δ2 is the offset along the right side of the X-axis, and both δ1 and δ2 are empirical values;
[0099] Step S32: extracting the final rivet mark area T on the left side of the keyway from the image of the high-voltage connecting rod to be detected. mleft (x, y) and the final area T of the rivet mark on the right side of the keyway mright (x,y), such as Figure 8 shown.
[0100] Step S4: classifying the rivet mark area on the left side of the keyway and the rivet mark area on the right side of the keyway by a support vector machine, so as to obtain a detection result of whether there is a left rivet mark in the rivet mark area on the left side of the keyway and a detection result of whether there is a right rivet mark in the rivet mark area on the right side of the keyway;
[0101] Preferably, if Figure 2 As shown, the step S4 further includes:
[0102] Step S41: extracting the left Hog feature of the final area of the rivet mark on the left side of the keyway and the right Hog feature of the final area of the rivet mark on the right side of the keyway respectively;
[0103] Step S42: training the support vector machine to obtain a trained support vector machine;
[0104] Specifically, the step S42 further includes:
[0105] Step S421: establishing a rivet mark recognition library of SVM+HOG features, and dividing a plurality of keyway rivet mark area images in the rivet mark recognition library into a training set and a test set; wherein each keyway rivet mark area image in the rivet mark recognition library is labeled with or without a rivet mark;
[0106] Step S422: Use the training set to train the support vector machine; wherein, during the training process, the accuracy Acc of the support vector machine is calculated using the test set. When the accuracy Acc of the support vector machine meets the requirements, it means that the training of the support vector machine is completed, and the trained support vector machine is obtained.
[0107] Specifically, the step S422 further includes:
[0108] Step S4221: classifying all keyway rivet mark area images in the test set by the support vector machine to obtain rivet mark presence or absence detection results of all keyway rivet mark area images in the test set, wherein the rivet mark presence or absence detection results are divided into rivet mark presence and rivet mark absence;
[0109] Step S4222: Calculate the accuracy Acc of the support vector machine, where the calculation formula of the accuracy Acc is as follows:
[0110]
[0111] Among them, TP is the number of keyway rivet mark area images in the test set that are labeled as having rivet marks and classified as having rivet marks, TN is the number of keyway rivet mark area images in the test set that are labeled as having no rivet marks and classified as having no rivet marks, FP is the number of keyway rivet mark area images in the test set that are labeled as having no rivet marks but classified as having rivet marks, and FN is the number of keyway rivet mark area images in the test set that are labeled as having rivet marks but classified as having no rivet marks.
[0112] For example, the training set has 1000 images of keyway rivet mark areas, of which 500 images have rivet marks and 500 images do not have rivet marks; the test set has 250 images of keyway rivet mark areas, of which 125 images have rivet marks and 125 images do not have rivet marks. After testing, the accuracy of the support vector machine of the present invention is 96%, which is suitable for actual detection.
[0113] Step S43: Input the left Hog feature and the right Hog feature into the trained support vector machine (SVM) for classification, so as to obtain the left rivet mark detection result Re of the final area of the left rivet mark of the keyway. left and whether there is a detection result Re of the right rivet mark in the final area of the right rivet mark of the keyway right .
[0114] Step S5: When the left rivet mark detection result and the right rivet mark detection result are both that the rivet mark exists, outputting the key installation in place visual detection result of the image of the high-voltage connecting rod to be detected.
[0115] Preferably, if Figure 2 As shown, the step S5 further includes:
[0116] When the left rivet mark detection result and the right rivet mark detection result are not both indicating that a rivet mark exists, a visual detection result of the key not being installed in place of the high-voltage connecting rod image to be detected is output.
[0117] To sum up, the present invention proposes a visual inspection method for whether the key of a high-voltage connecting rod is in place, which is mainly composed of a visual inspection method for whether there is a key and a visual inspection method for whether there are rivet marks. The state of the rivet marks can be used as an evaluation indicator of whether the pressed key will fall out, thereby reducing the risk of the key not being installed in place during production and improving the detection accuracy of whether the key is in place.
[0118] The above description is only a preferred embodiment of the present invention and does not limit the present invention in any form. Although the present invention has been disclosed as a preferred embodiment as above, it is not used to limit the present invention. Any technician familiar with this profession can make some changes or modifications to equivalent embodiments of equivalent changes using the technical contents disclosed above without departing from the scope of the technical solution of the present invention. However, any simple modification, equivalent change and modification made to the above embodiments based on the technical essence of the present invention without departing from the content of the technical solution of the present invention still falls within the scope of the technical solution of the present invention.
Claims
1. A method for visually inspecting whether a high-voltage connecting rod key is installed in place, characterized in that: The steps include: Step S1: Acquire an image of a high-voltage connecting rod to be inspected; Step S2: detecting a keyway region from the image of the high-voltage connecting rod to be detected, and determining whether there is a key in the keyway region; Step S3: when there is a key in the keyway area, a mask is generated using the keyway area, and then a rivet mark area on the left side of the keyway and a rivet mark area on the right side of the keyway are cut out from the image of the high-voltage connecting rod to be inspected; Step S4: classifying the rivet mark area on the left side of the keyway and the rivet mark area on the right side of the keyway by a support vector machine, so as to obtain a detection result of whether there is a left rivet mark in the rivet mark area on the left side of the keyway and a detection result of whether there is a right rivet mark in the rivet mark area on the right side of the keyway; Step S5: When the left rivet mark detection result and the right rivet mark detection result are both that the rivet mark exists, outputting the key installation in place visual detection result of the image of the high-voltage connecting rod to be detected.
2. A method for visually inspecting whether a high-voltage connecting rod key is installed in place according to claim 1, characterized in that: The step S2 further includes: Step S21: Roughly locate the keyway area in the image of the high-voltage connecting rod to be detected; if the rough positioning is not successful, output the visual detection result that the key of the image of the high-voltage connecting rod to be detected is not installed in place; otherwise, output the keyway rough positioning area in the image of the high-voltage connecting rod to be detected, and execute step S22; wherein the formula for rough positioning is as follows: T0(x,y) = T p (x+α,y+β) (1) In formula (1), T p (x, y) is the original area of the keyway in the image of the high-voltage connecting rod to be detected, α is the distance required to be offset in the X-axis direction, β is the distance required to be offset in the Y-axis direction, and T0(x, y) is the rough positioning area of the keyway in the image of the high-voltage connecting rod to be detected; Step S22: precisely locate the keyway area in the image of the high-voltage connecting rod to be detected; if the precise positioning is not successful, output the visual detection result that the key of the image of the high-voltage connecting rod to be detected is not installed in place; otherwise, output the keyway precise positioning area in the image of the high-voltage connecting rod to be detected, and execute step S23; wherein the formula for precise positioning is as follows: T1(x,y) = T0(x+η,y+λ) (2) In formula (2), T0(x, y) is the keyway coarse positioning area in the image of the high-voltage connecting rod to be detected, η is the distance required to be offset in the X-axis direction, λ is the distance required to be offset in the Y-axis direction, and T1(x, y) is the keyway fine positioning area in the image of the high-voltage connecting rod to be detected; Step S23: using a precision positioning caliper circle tool to fit a left semicircular arc of the keyway and a right semicircular arc of the keyway in the precision positioning area of the keyway, so as to form a final area of the keyway in the image of the high-voltage connecting rod to be inspected; Step S24: determine whether there is a key in the final area of the key slot; if there is a key, execute step S3; otherwise, output a visual inspection result that the key of the high-voltage connecting rod image to be inspected is not installed in place.
3. A method for visually inspecting whether a high-voltage connecting rod key is installed in place according to claim 2, characterized in that: The step S23 further includes: Step S231: Use a precision positioning caliper circle tool to fit the left semicircular arc of the keyway and the right semicircular arc of the keyway in the precision positioning area of the keyway to obtain the center coordinates (X left ,Y left ) and radius R left , and the center coordinates of the semicircular arc on the right side of the keyway (X right , Y right ) and radius R right ; Step S232: Connect the center of the semicircular arc on the left side of the keyway and the center of the semicircular arc on the right side of the keyway to obtain a line segment between the two centers, and translate the line segment between the two centers by ±R in the vertical direction of the line segment. min , to obtain two translated line segments, and the area formed by the intersection of the two translated line segments and the two semicircular arcs is used as the keyway final area T in the image of the high-voltage connecting rod to be detected. final (x,y); where R min The calculation formula is as follows: R min =min(R left ,R right ) (3) In formula (3), R left is the radius of the semicircular arc on the left side of the keyway, R right is the radius of the semicircular arc on the right side of the keyway, R min For R left and R right The minimum value in .
4. A method for visually inspecting whether a high-voltage connecting rod key is installed in place according to claim 2, characterized in that: The step S24 further includes: Step S241: Calculate the grayscale average value in the final area of the key slot in, The calculation formula is as follows: Wherein, M is the image width of the final area of the keyway, N is the image height of the final area of the keyway, T final (x, y) is the final area of the keyway, is the grayscale average value; Step S242: Determine the average grayscale value in the final area of the key slot Is it greater than the grayscale reference value K? base ;like Represents the final area T of the keyway final If there is no key in (x, y), the key of the high-voltage connecting rod image to be inspected is not installed in place. Otherwise, it represents the final area T of the key slot. final If there is a key in (x, y), proceed to step S3.
5. A method for visually inspecting whether a high-voltage connecting rod key is installed in place according to claim 2, characterized in that: The step S3 further includes: Step S31: When there is a key in the final area of the keyway, a mask is generated using the final area of the keyway, and then the final area T of the rivet mark on the left side of the keyway in the image of the high-voltage connecting rod to be detected is calculated. mleft (x, y) and the final area T of the rivet mark on the right side of the keyway mright (x,y), where T mleft (x,y) and T mright The calculation formula for (x,y) is as follows: T mleft (x,y)=T pleft (x+δ1,y) (5) T mright (x,y)=T pright (x+δ2,y) (6) Among them, T pleft (x, y) is the original area of the rivet mark on the left side of the keyway in the image of the high-voltage connecting rod to be detected, T pright (x, y) is the original area of the rivet mark on the right side of the keyway in the image of the high-voltage connecting rod to be detected, T mleft (x, y) is the final area of the rivet mark on the left side of the keyway in the image of the high-voltage connecting rod to be detected, T mright (x, y) is the final area of the rivet mark on the right side of the keyway in the image of the high-voltage connecting rod to be detected, δ1 is the offset along the left side of the X-axis, and δ2 is the offset along the right side of the X-axis, and both δ1 and δ2 are empirical values; Step S32: extracting the final rivet mark area T on the left side of the keyway from the image of the high-voltage connecting rod to be detected. mleft (x, y) and the final area T of the rivet mark on the right side of the keyway mright (x,y).
6. A method for visually inspecting whether a high-voltage connecting rod key is installed in place according to claim 5, characterized in that: The step S4 further includes: Step S41: extracting the left Hog feature of the final area of the rivet mark on the left side of the keyway and the right Hog feature of the final area of the rivet mark on the right side of the keyway respectively; Step S42: training the support vector machine to obtain a trained support vector machine; Step S43: Input the left Hog feature and the right Hog feature into the trained support vector machine for classification, so as to obtain the left rivet mark detection result Re of the final area of the left rivet mark of the keyway. left and whether there is a detection result Re of the right rivet mark in the final area of the right rivet mark of the keyway right .
7. A method for visually inspecting whether a high-voltage connecting rod key is installed in place according to claim 6, characterized in that: The step S42 further includes: Step S421: establishing a rivet mark recognition library, and dividing a plurality of keyway rivet mark area images in the rivet mark recognition library into a training set and a test set; wherein each keyway rivet mark area image in the rivet mark recognition library is labeled with whether or not there is a rivet mark; Step S422: Use the training set to train the support vector machine; wherein, during the training process, the accuracy Acc of the support vector machine is calculated using the test set. When the accuracy Acc of the support vector machine meets the requirements, it means that the training of the support vector machine is completed, and the trained support vector machine is obtained.
8. A method for visually inspecting whether a high-voltage connecting rod key is installed in place according to claim 7, characterized in that: The step S422 further includes: Step S4221: classifying all keyway rivet mark area images in the test set by the support vector machine to obtain rivet mark presence or absence detection results of all keyway rivet mark area images in the test set, wherein the rivet mark presence or absence detection results are divided into rivet mark presence and rivet mark absence; Step S4222: Calculate the accuracy Acc of the support vector machine, where the calculation formula of the accuracy Acc is as follows: Among them, TP is the number of keyway rivet mark area images in the test set that are labeled as having rivet marks and classified as having rivet marks, TN is the number of keyway rivet mark area images in the test set that are labeled as having no rivet marks and classified as having no rivet marks, FP is the number of keyway rivet mark area images in the test set that are labeled as having no rivet marks but classified as having rivet marks, and FN is the number of keyway rivet mark area images in the test set that are labeled as having rivet marks but classified as having no rivet marks.
9. A method for visually inspecting whether a high-voltage connecting rod key is installed in place according to claim 1, characterized in that: The step S5 further includes: When the left rivet mark detection result and the right rivet mark detection result are not both indicating that a rivet mark exists, a visual detection result of the key not being installed in place of the high-voltage connecting rod image to be detected is output.