3362 potentiometer mechanical angle resetting system and method based on machine vision
Technical Field
The invention belongs to the technical field of 3362 potentiometer mechanical angle resetting, and particularly relates to a 3362 potentiometer mechanical angle resetting system and method based on machine vision.
Background
3362 in the production process of potentiometer, it is required to detect whether the resistance value and the mechanical angle change keep linear relation, the detection steps are: firstly, a cross-shaped groove of a 3362 potentiometer is rotated to an initial mechanical angle to detect zero resistance, then the cross-shaped groove is rotated clockwise from the initial mechanical angle to an end mechanical angle, and whether the resistance value and the change of the mechanical angle keep a linear relation or not is detected. However, the 3362 potentiometer produced on-line is typically at any mechanical angle due to manufacturing process issues. At present, whether manufacturing enterprises detect the resistance and the change of mechanical angle and keep the in-process of linear relation, the mechanical angle reset operation to the 3362 potentiometre mainly adopts manual mode, promptly when the 3362 potentiometre that awaits measuring gets into the anchor clamps that detect the station, the manual work is rotatory to initial mechanical angle with cross type groove and is detected again. The manual reset mode is high in cost, low in efficiency and difficult to guarantee accuracy for a long time.
Disclosure of Invention
The invention provides a 3362 potentiometer mechanical angle reset system and a reset method based on machine vision, aiming at solving the problems in the prior art.
In order to achieve the purpose, the invention adopts the following technical scheme: a3362 potentiometer mechanical angle resetting system based on machine vision comprises a machine controller, a bus, a mechanical angle detection device and a mechanical angle resetting device, wherein the machine controller is in communication connection with the bus, the mechanical angle detection device comprises a visual camera and an industrial personal computer, the visual camera is installed right above a 3362 potentiometer clamp for detecting mechanical angles, the visual camera is in communication connection with the industrial personal computer, the industrial personal computer is in communication connection with the machine controller, the mechanical angle resetting device comprises an air cylinder, a servo drive, a servo motor and a cross screwdriver head, the air cylinder is in communication connection with the machine controller through an I/O module, the servo drive is in communication connection with the machine controller through the bus, the servo motor is in communication connection with the servo drive, a telescopic rod of the air cylinder is connected with the servo motor, an output shaft of the servo motor is fixedly connected with the cross screwdriver head, the mechanical angle resetting device is located right above a 3362 potentiometer clamp to be reset by a mechanical angle, the area where the mechanical angle detecting device is located is a mechanical angle detecting station, and the area where the mechanical angle resetting device is located is a mechanical angle resetting station.
Further, the bus is an EtherCAT bus.
Furthermore, the vision camera is in communication connection with the industrial personal computer through the GigE.
Furthermore, the industrial personal computer is in communication connection with the machine controller through Ethernet.
The invention also provides a reset method of the 3362 potentiometer mechanical angle reset system based on machine vision, which comprises the following steps:
step 1.1: when the 3362 potentiometer enters the clamp of the mechanical angle detection station, the machine controller sends a mechanical angle detection station ready signal to the industrial personal computer through Ethernet;
step 1.2: after the industrial personal computer obtains a mechanical angle detection station ready signal, a trigger signal is sent to the visual camera through the GigE;
step 1.3: after the visual camera obtains the trigger signal, shooting an image, and transmitting the shot image to the industrial personal computer through the GigE;
step 1.4: after the industrial personal computer obtains the image, the current mechanical angle alpha of the potentiometer is calculated 3362 according to a mechanical angle detection algorithm, and then the initial mechanical angle alpha obtained by the initial mechanical angle detection algorithm is utilized0Calculating to obtain a deflection angle beta, and transmitting the beta to the machine controller through Ethernet, wherein the calculation formula of the deflection angle beta is as follows:
β=α-α0;
step 1.5: after the machine controller obtains the deflection angle beta, the servo motor is controlled to rotate clockwise from an initial position by the EtherCAT bus and the servo drive, and meanwhile, the transmission mechanism is informed to transmit the 3362 potentiometer to a mechanical angle reset station by the EtherCAT bus;
step 1.6: after the servo motor rotates, sending a servo motor ready signal to a machine controller through an EtherCAT bus;
step 1.7: after the 3362 potentiometer enters the clamp of the mechanical angle reset station, a mechanical angle reset station ready signal is sent to a machine controller through an EtherCAT bus;
step 1.8: after receiving a servo motor ready signal and a mechanical angle reset station ready signal simultaneously, the machine controller controls the air cylinder to move downwards from a high position to a low position through the I/O module, so that the cross-shaped batch head extends into a cross-shaped groove of the 3362 potentiometer, and after the completion, the machine controller sends an air cylinder ready signal to the machine controller through the I/O module;
step 1.9: after receiving the cylinder ready signal, the machine controller controls the servo motor to rotate anticlockwise by beta through the EtherCAT bus and the servo drive, and sends a mechanical angle reset completion signal to the machine controller through the EtherCAT bus after the rotation is completed;
step 1.10: after the mechanical angle reset completion signal is received by the machine controller, the air cylinder is controlled by the I/O module to move upwards from a low position to a high position, the servo motor is controlled to rotate to an initial position through the EtherCAT bus and the servo drive, and meanwhile the transmission mechanism is informed through the EtherCAT bus to transmit the 3362 potentiometer to a detection station whether the resistance value and the mechanical angle change keep a linear relation or not.
Further, the mechanical angle detection algorithm comprises the following steps:
step 2.1: intercepting square image sub-blocks with the size of 500 multiplied by 500 pixels from the center of an image shot by a visual camera of a mechanical angle detection device to serve as an input image of a mechanical angle detection algorithm;
step 2.2: extracting 3362 a circular area in the center of the potentiometer from the input image by using a circular area detection algorithm, and setting the rest part to be white as the input image of the indication point area detection algorithm;
step 2.3: detecting to obtain 2 indication point areas in a circular area at the center of the 3362 potentiometer by using an indication point area detection algorithm;
step 2.4: calculating area descriptors for the 2 indication point areas to respectively obtain the centroid coordinates (x) of the 2 indication point areasc1,yc1) And (x)c2,yc2);
Step 2.5: calculating to obtain the center point coordinate (x) between the centroids of the 2 indication point areas by using the centroid coordinates of the 2 indication point areasc,yc) The calculation formula is as follows:
step 2.6: extracting 3362 a circular area in the center of the potentiometer from the input image by using a circular area detection algorithm, and setting the rest part of the circular area to be black as an input image of a non-indication point area detection algorithm;
step 2.7: detecting to obtain 2 non-indication point areas in a circular area at the center of the 3362 potentiometer by using a non-indication point area detection algorithm;
step 2.8: calculating area descriptors for 2 non-indication point areas to respectively obtain the main shaft angles alpha of the 2 non-indication point areas1And alpha2In which α is1∈[-90°,90°]、α2∈[-90°,90°];
Step 2.9: calculating the average angle of the principal axes of the 2 non-point-indicating regions
The calculation formula is as follows:
Step 2.10: constructing a new coordinate system with the center (x) of the circleo,yo) Is the origin, is vertically downward 0 degree, and clockwise 0 degree and 360 degree];
Step 2.11: under the new coordinate system of the construction, the circle center (x) of the circular area is simultaneously utilized
o,y
o) And the midpoint coordinate (x) among the centroids of the 2 indication point areas
c,y
c) 2 average angle of principal axis of non-indication point region
The current mechanical angle alpha of the 3362 potentiometer is obtained by calculation, and the calculation formula is as follows:
further, the circular region detection algorithm comprises the following steps:
step 3.1: in a color name space, taking a blue channel for an input image of a mechanical angle detection algorithm;
step 3.2: negating the blue channel and normalizing;
step 3.3: performing binarization operation on the normalization result by using an Otsu method, and filling holes in the binarization result;
step 3.4: calculating a region descriptor for the hole filling result to obtain the area and the centroid coordinate of each region;
step 3.5: in the hole filling result, only the region R with the largest area is reserved, and the centroid coordinate of the region is recorded as (x)o,yo);
Step 3.6: using Sobel operator, edge detection is performed on the region R, and the coordinates (x) of each pixel p on the edge are usedp,yp) Calculating p to coordinate (x)o,yo) Euclidean distance r ofpThe calculation formula is as follows:
step 3.7: all edge pixels to coordinate (x) at region Ro,yo) In the Euclidean distance of (1), the maximum Euclidean distance is taken and recorded as ro;
Step 3.8: with (x)o,yo) As a center of circle, roThe area with the radius is the circular area obtained by the circular area detection algorithm.
Further, the indicator region detection algorithm comprises the following steps:
step 4.1: in a color name space, taking a black channel for an input image of an indication point region detection algorithm, and normalizing;
step 4.2: performing binarization operation on the normalization result by using an Otsu method, and filling holes in the binarization result;
step 4.3: constructing a disc-shaped structural element with the radius of 20, and carrying out corrosion operation on the hole filling result by using the structural element;
step 4.4: taking the corrosion result as a marked image, taking the hole filling result as a mask image, and executing morphological reconstruction operation;
step 4.5: subtracting the morphological reconstruction result from the hole filling result, and performing binarization operation on the difference image by using an Otsu method;
step 4.6: calculating a region descriptor for the difference image binarization result to obtain the area of each region;
step 4.7: in the difference image binarization result, only 2 regions with the largest area are reserved, namely the indication point regions obtained by the indication point region detection algorithm.
Further, the non-indicator region detection algorithm comprises the following steps:
step 5.1: in an RGB color space, taking a red channel for an input image of a non-indication point region detection algorithm;
step 5.2: constructing a matrix with the size of 5 multiplied by 5 and all element values of 1, and respectively executing maximum value filtering operation and minimum value filtering operation on a red channel;
step 5.3: subtracting the minimum filtering result from the maximum filtering result to obtain a difference image;
step 5.4: calculating a global threshold value by using an Otsu method, performing binarization operation on the difference image, and filling holes in a binarization result;
step 5.5: constructing a disc-shaped structural element with the radius of 5, and carrying out corrosion operation on the hole filling result by using the structural element to obtain a corrosion result 1;
step 5.6: constructing a disc-shaped structural element with the radius of 20, and carrying out corrosion operation on the corrosion result 1 by using the structural element to obtain a corrosion result 2;
step 5.7: performing morphological reconstruction operation by taking the corrosion result 2 as a marked image and the corrosion result 1 as a mask image;
step 5.8: calculating a region descriptor for the morphological reconstruction result to obtain a centroid coordinate of each region;
step 5.9: combining the regions in the morphological reconstruction result pairwise, calculating the midpoint coordinate between the centroids of any two regions, and setting a region RmAnd region RnRespectively, are (x)m,ym) And (x)n,yn) Then region RmAnd RnThe coordinate of the midpoint between the centroids is (x)mn,ymn) The calculation formula is as follows:
step 5.10: the midpoint coordinate (x) among the centroids of the 2 indicating point areas obtained by the mechanical angle detection algorithm step 2.5 is utilizedc,yc) Calculating all (x)mn,ymn) To the coordinate (x)c,yc) Euclidean distance of dmnThe calculation formula is as follows:
step 5.11: in all OldhamDistance dmnFinding the maximum Euclidean distance;
step 5.12: in the morphological reconstruction result, 2 regions corresponding to the maximum euclidean distance are generated, namely the non-indication point regions obtained by the non-indication point region detection algorithm.
Further, the initial mechanical angle detection algorithm comprises the following steps:
step 6.1: manually rotating a cross-shaped groove in a 3362 potentiometer standard element to an initial position, and placing the cross-shaped groove into a clamp of a mechanical angle detection station;
step 6.2: shooting an image through a visual camera of the mechanical angle detection device;
step 6.3: the current mechanical angle calculated by the mechanical angle detection algorithm from step 2.1 to step 2.11 is the initial mechanical angle alpha0。
Compared with the prior art, the invention has the beneficial effects that: the invention solves the problems of high cost, low efficiency and poor accuracy caused by the manual mode adopted by the mechanical angle resetting operation of the existing 3362 potentiometer. The method adopts an image triggering and collecting device to collect image information of a 3362 potentiometer to be mechanically reset, detects the current mechanical angle of the 3362 potentiometer through a defined mechanical angle detection algorithm, and then realizes the automatic mechanical angle resetting operation of the 3362 potentiometer by using a mechanical angle resetting device; the device has the advantages of remarkably reducing the manual reset cost, increasing the mechanical angle reset accuracy, improving the detection efficiency of whether the resistance value and the mechanical angle change keep a linear relation or not, having small investment, being convenient for operation and having great market prospect.
Drawings
Fig. 1 is a schematic structural diagram of a mechanical angle resetting system of a 3362 potentiometer based on machine vision according to the present invention;
FIG. 2 is a block diagram of a mechanical angle detection algorithm of a reset method of a 3362 potentiometer mechanical angle reset system based on machine vision according to the present invention;
FIG. 3 is a block diagram of a circular area detection algorithm for a reset method of a mechanical angle reset system of a 3362 potentiometer based on machine vision according to the present invention;
FIG. 4 is a block diagram of a flow of a reset method indication point area detection algorithm of a 3362 potentiometer mechanical angle reset system based on machine vision according to the present invention;
FIG. 5 is a block diagram of a non-indication point area detection algorithm of a reset method of a 3362 potentiometer mechanical angle reset system based on machine vision according to the present invention;
FIG. 6 is a schematic view of the 3362 potentiometer initial mechanical angle collected by the mechanical angle detection algorithm of the present invention;
FIG. 7 is a schematic view of 3362 potentiometer arbitrary mechanical angles collected by the mechanical angle detection algorithm of the present invention;
FIG. 8 is a schematic diagram illustrating the definition of the indicated point region and the non-indicated point region in the mechanical angle detection algorithm according to the present invention;
FIG. 9 is a schematic diagram of the result of the circular region detection algorithm of the present invention inverting and normalizing the blue channel of FIG. 7 in the color name space;
FIG. 10 is a schematic diagram of the result of binarization and hole filling of FIG. 9 by the circular region detection algorithm according to the present invention;
FIG. 11 is a schematic diagram of the calculation of the centroid coordinates of the maximum area region and the Euclidean distance from the region edge pixels to the centroid, which is obtained by the circular region detection algorithm of the present invention for the region descriptor calculated in FIG. 10;
FIG. 12 is a diagram illustrating the results of a circular region obtained by the circular region detection algorithm of the present invention;
FIG. 13 is an input image of an indicated point region detection algorithm in accordance with the present invention;
FIG. 14 is a schematic diagram of the result of the indicator point region detection algorithm of the present invention in color namespace, taking the black channel of FIG. 13 and normalizing;
FIG. 15 is a schematic diagram of the result of binarization and hole filling of FIG. 14 by the indicated point region detection algorithm according to the present invention;
FIG. 16 is a diagram illustrating the result of morphological reconstruction of FIG. 15 using a disc-shaped structural element with a radius of 20 according to the pointing region detection algorithm of the present invention;
FIG. 17 is a schematic diagram of the difference image of FIGS. 15 and 16 calculated by the indicated point region detection algorithm and normalized by the difference image according to the present invention;
fig. 18 is a schematic diagram of the result of the indicator region obtained by retaining only 2 regions with the largest area in fig. 17 by the indicator region detection algorithm according to the present invention;
FIG. 19 is a diagram illustrating the results of the mechanical angle detection algorithm of the present invention on the centroid coordinates of the 2 indicator regions obtained by the area descriptor calculated in FIG. 18 and the midpoint coordinates between the centroids of the 2 indicator regions;
FIG. 20 is an input image of a non-indicative point region detection algorithm in accordance with the present invention;
FIG. 21 is a schematic diagram showing a result of the non-indicator region detection algorithm of the present invention taking the red channel from FIG. 20 in the RGB color space and performing maximum filtering on the red channel by using a 5 × 5 full 1 matrix;
FIG. 22 is a schematic diagram showing the result of the non-indicator region detection algorithm of the present invention taking the red channel from FIG. 20 in the RGB color space and performing minimum filtering on the red channel using a 5 × 5 full 1 matrix;
FIG. 23 is a schematic diagram of the result of the difference image obtained by subtracting the minimum value filter of FIG. 22 from the maximum value filter of FIG. 21 by the non-indicative point region detection algorithm of the present invention;
FIG. 24 is a schematic diagram of the result of binarization and hole filling of FIG. 23 by the non-indicative point region detection algorithm according to the present invention;
FIG. 25 is a schematic diagram of a corrosion result 1 obtained by the non-indicator region detection algorithm of the present invention using a disc-shaped structural element with a radius of 5 to perform a corrosion operation on FIG. 24;
FIG. 26 is a schematic diagram of a corrosion result 2 obtained by the non-indicator region detection algorithm of the present invention using a disc-shaped structural element with a radius of 20 to perform a corrosion operation on FIG. 25;
FIG. 27 is a schematic diagram illustrating the morphological reconstruction of FIGS. 25 and 26 by the non-indicative point region detection algorithm of the present invention;
FIG. 28 is a schematic diagram illustrating symbol definitions of the non-pointing region detection algorithm of FIG. 27 for detecting non-pointing regions in accordance with the present invention;
FIG. 29 is a schematic diagram illustrating the process of detecting the non-indicative point regions of FIG. 27 by the non-indicative point region detection algorithm of the present invention;
FIG. 30 is a schematic diagram of the results of non-pointing regions obtained by the non-pointing region detection algorithm of the present invention;
FIG. 31 is a schematic diagram of the principal axis angle α of 2 non-pointing regions obtained by the mechanical angle detection algorithm according to the present invention from the region descriptor calculated in FIG. 30
1And alpha
2And using alpha
1And alpha
2Calculating the average angle of the main axes of the 2 non-indication point areas
Schematic diagram of the results of (1);
FIG. 32 is a schematic diagram of a new coordinate system constructed by the mechanical angle detection algorithm of the present invention;
FIG. 33 is a diagram illustrating the result of the mechanical angle detection algorithm of the present invention on the current mechanical angle α detected in FIG. 6;
fig. 34 is a schematic diagram of the result of the mechanical angle detection algorithm of the present invention on the current mechanical angle α detected in fig. 7.
Detailed Description
The technical solution in the embodiments of the present invention will be clearly and completely explained below with reference to the drawings in the embodiments of the present invention.
Referring to fig. 1-34 to illustrate the embodiment, a 3362 potentiometer mechanical angle resetting system based on machine vision comprises a machine controller, a bus, a mechanical angle detecting device and a mechanical angle resetting device, wherein the machine controller is in communication connection with the bus, the mechanical angle detecting device comprises a visual camera and an industrial personal computer, the visual camera is installed right above a 3362 potentiometer clamp to be detected for a mechanical angle, the visual camera is in communication connection with the industrial personal computer, the industrial personal computer is in communication connection with the machine controller, the mechanical angle resetting device comprises an air cylinder, a servo drive, a servo motor and a cross batch head, the air cylinder is in communication connection with the machine controller through an I/O module, the servo drive is in communication connection with the machine controller through the bus, the servo motor is in communication connection with the servo drive, and a telescopic rod of the air cylinder is connected with the servo motor, the output shaft of the servo motor is fixedly connected with the cross-shaped batch head, the mechanical angle resetting device is located right above a 3362 potentiometer clamp to be reset by a mechanical angle, the area where the mechanical angle detecting device is located is a mechanical angle detecting station, and the area where the mechanical angle resetting device is located is a mechanical angle resetting station.
The bus is an EtherCAT bus, the vision camera is in communication connection with an industrial personal computer through GigE, and the industrial personal computer is in communication connection with a machine controller through Ethernet.
The embodiment is a resetting method of a 3362 potentiometer mechanical angle resetting system based on machine vision, which comprises the following steps:
step 1.1: when the 3362 potentiometer enters the clamp of the mechanical angle detection station, the machine controller sends a mechanical angle detection station ready signal to the industrial personal computer through Ethernet;
step 1.2: after the industrial personal computer obtains a mechanical angle detection station ready signal, a trigger signal is sent to the visual camera through the GigE;
step 1.3: after the visual camera obtains the trigger signal, shooting an image, and transmitting the shot image to the industrial personal computer through the GigE;
step 1.4: after the industrial personal computer obtains the image, the current mechanical angle alpha of the potentiometer is calculated 3362 according to a mechanical angle detection algorithm, and then the initial mechanical angle alpha obtained by the initial mechanical angle detection algorithm is utilized0Calculating to obtain a deflection angle beta, and transmitting the beta to the machine controller through Ethernet, wherein the calculation formula of the deflection angle beta is as follows:
β=α-α0;
step 1.5: after the machine controller obtains the deflection angle beta, the servo motor is controlled to rotate clockwise from an initial position by the EtherCAT bus and the servo drive, and meanwhile, the transmission mechanism is informed to transmit the 3362 potentiometer to a mechanical angle reset station by the EtherCAT bus;
step 1.6: after the servo motor rotates, sending a servo motor ready signal to a machine controller through an EtherCAT bus;
step 1.7: after the 3362 potentiometer enters the clamp of the mechanical angle reset station, a mechanical angle reset station ready signal is sent to a machine controller through an EtherCAT bus;
step 1.8: after receiving a servo motor ready signal and a mechanical angle reset station ready signal simultaneously, the machine controller controls the air cylinder to move downwards from a high position to a low position through the I/O module, so that the cross-shaped batch head extends into a cross-shaped groove of the 3362 potentiometer, and after the completion, the machine controller sends an air cylinder ready signal to the machine controller through the I/O module;
step 1.9: after receiving the cylinder ready signal, the machine controller controls the servo motor to rotate anticlockwise by beta through the EtherCAT bus and the servo drive, and sends a mechanical angle reset completion signal to the machine controller through the EtherCAT bus after the rotation is completed;
step 1.10: after the mechanical angle reset completion signal is received by the machine controller, the air cylinder is controlled by the I/O module to move upwards from a low position to a high position, the servo motor is controlled to rotate to an initial position through the EtherCAT bus and the servo drive, and meanwhile the transmission mechanism is informed through the EtherCAT bus to transmit the 3362 potentiometer to a detection station whether the resistance value and the mechanical angle change keep a linear relation or not.
The mechanical angle detection algorithm in the embodiment comprises the following steps:
step 2.1: intercepting square image sub-blocks with the size of 500 multiplied by 500 pixels from the center of an image shot by a visual camera of a mechanical angle detection device to serve as an input image of a mechanical angle detection algorithm;
step 2.2: extracting 3362 a circular area in the center of the potentiometer from the input image by using a circular area detection algorithm, and setting the rest part to be white as the input image of the indication point area detection algorithm;
step 2.3: detecting to obtain 2 indication point areas in a circular area at the center of the 3362 potentiometer by using an indication point area detection algorithm;
step 2.4: calculating area descriptors for the 2 indication point areas to respectively obtain the centroid coordinates (x) of the 2 indication point areasc1,yc1) And (x)c2,yc2);
Step 2.5: calculating to obtain the center point coordinate (x) between the centroids of the 2 indication point areas by using the centroid coordinates of the 2 indication point areasc,yc) The calculation formula is as follows:
step 2.6: extracting 3362 a circular area in the center of the potentiometer from the input image by using a circular area detection algorithm, and setting the rest part of the circular area to be black as an input image of a non-indication point area detection algorithm;
step 2.7: detecting to obtain 2 non-indication point areas in a circular area at the center of the 3362 potentiometer by using a non-indication point area detection algorithm;
step 2.8: calculating area descriptors for 2 non-indication point areas to respectively obtain the main shaft angles alpha of the 2 non-indication point areas1And alpha2In which α is1∈[-90°,90°]、α2∈[-90°,90°];
Step 2.9: calculating the average angle of the principal axes of the 2 non-point-indicating regions
The calculation formula is as follows:
Step 2.10: constructing a new coordinate system with the center (x) of the circleo,yo) Is at the origin and vertically downwardIs 0 DEG, clockwise is [0 DEG ], 360 DEG];
Step 2.11: under the new coordinate system of the construction, the circle center (x) of the circular area is simultaneously utilized
o,y
o) And the midpoint coordinate (x) among the centroids of the 2 indication point areas
c,y
c) 2 average angle of principal axis of non-indication point region
The current mechanical angle alpha of the 3362 potentiometer is obtained by calculation, and the calculation formula is as follows:
the circular region detection algorithm comprises the following steps:
step 3.1: in a color name space, taking a blue channel for an input image of a mechanical angle detection algorithm;
step 3.2: negating the blue channel and normalizing;
step 3.3: performing binarization operation on the normalization result by using an Otsu method, and filling holes in the binarization result;
step 3.4: calculating a region descriptor for the hole filling result to obtain the area and the centroid coordinate of each region;
step 3.5: in the hole filling result, only the region R with the largest area is reserved, and the centroid coordinate of the region is recorded as (x)o,yo);
Step 3.6: using Sobel operator, edge detection is performed on the region R, and the coordinates (x) of each pixel p on the edge are usedp,yp) Calculating p to coordinate (x)o,yo) Euclidean distance r ofpThe calculation formula is as follows:
step 3.7: all edge pixels to coordinate (x) at region Ro,yo) In the euclidean distance of (a),the maximum Euclidean distance is taken and recorded as ro;
Step 3.8: with (x)o,yo) As a center of circle, roThe area with the radius is the circular area obtained by the circular area detection algorithm.
The indicator region detection algorithm comprises the following steps:
step 4.1: in a color name space, taking a black channel for an input image of an indication point region detection algorithm, and normalizing;
step 4.2: performing binarization operation on the normalization result by using an Otsu method, and filling holes in the binarization result;
step 4.3: constructing a disc-shaped structural element with the radius of 20, and carrying out corrosion operation on the hole filling result by using the structural element;
step 4.4: taking the corrosion result as a marked image, taking the hole filling result as a mask image, and executing morphological reconstruction operation;
step 4.5: subtracting the morphological reconstruction result from the hole filling result, and performing binarization operation on the difference image by using an Otsu method;
step 4.6: calculating a region descriptor for the difference image binarization result to obtain the area of each region;
step 4.7: in the difference image binarization result, only 2 regions with the largest area are reserved, namely the indication point regions obtained by the indication point region detection algorithm.
The non-indicator region detection algorithm comprises the following steps:
step 5.1: in an RGB color space, taking a red channel for an input image of a non-indication point region detection algorithm;
step 5.2: constructing a matrix with the size of 5 multiplied by 5 and all element values of 1, and respectively executing maximum value filtering operation and minimum value filtering operation on a red channel;
step 5.3: subtracting the minimum filtering result from the maximum filtering result to obtain a difference image;
step 5.4: calculating a global threshold value by using an Otsu method, performing binarization operation on the difference image, and filling holes in a binarization result;
step 5.5: constructing a disc-shaped structural element with the radius of 5, and carrying out corrosion operation on the hole filling result by using the structural element to obtain a corrosion result 1;
step 5.6: constructing a disc-shaped structural element with the radius of 20, and carrying out corrosion operation on the corrosion result 1 by using the structural element to obtain a corrosion result 2;
step 5.7: performing morphological reconstruction operation by taking the corrosion result 2 as a marked image and the corrosion result 1 as a mask image;
step 5.8: calculating a region descriptor for the morphological reconstruction result to obtain a centroid coordinate of each region;
step 5.9: combining the regions in the morphological reconstruction result pairwise, calculating the midpoint coordinate between the centroids of any two regions, and setting a region RmAnd region RnRespectively, are (x)m,ym) And (x)n,yn) Then region RmAnd RnThe coordinate of the midpoint between the centroids is (x)mn,ymn) The calculation formula is as follows:
step 5.10: the midpoint coordinate (x) among the centroids of the 2 indicating point areas obtained by the mechanical angle detection algorithm step 2.5 is utilizedc,yc) Calculating all (x)mn,ymn) To the coordinate (x)c,yc) Euclidean distance of dmnThe calculation formula is as follows:
step 5.11: at all Euclidean distances dmnFinding the maximum Euclidean distance;
step 5.12: in the morphological reconstruction result, 2 regions corresponding to the maximum euclidean distance are generated, namely the non-indication point regions obtained by the non-indication point region detection algorithm.
The initial mechanical angle detection algorithm comprises the following steps:
step 6.1: manually rotating a cross-shaped groove in a 3362 potentiometer standard element to an initial position, and placing the cross-shaped groove into a clamp of a mechanical angle detection station;
step 6.2: shooting an image through a visual camera of the mechanical angle detection device;
step 6.3: the current mechanical angle calculated by the mechanical angle detection algorithm from step 2.1 to step 2.11 is the initial mechanical angle alpha0。
As shown in fig. 6, the initial mechanical angle of the 3362 potentiometer acquired by the mechanical angle detection algorithm is as shown in fig. 7, the random mechanical angle of the 3362 potentiometer acquired by the mechanical angle detection algorithm is as shown in fig. 8, the indicated point region and the non-indicated point region are defined by the mechanical angle detection algorithm, as shown in fig. 9, the blue channel is taken by the circular region detection algorithm in the color name space of fig. 7, the blue channel is taken, the inverted channel is taken and normalized, as shown in fig. 10, the fig. 9 is binarized by the circular region detection algorithm and the holes are filled, as shown in fig. 11, the region descriptor is calculated by the circular region detection algorithm with respect to fig. 10, the obtained centroid coordinates of the maximum area region and the euclidean distance from the region edge pixels to the centroid are obtained, as shown in fig. 12, the circular region is obtained by the circular region detection algorithm, as shown in fig. 13, the input image of the indicated point region detection algorithm obtained by the mechanical angle detection algorithm, as shown in fig. 14, fig. 13 is taken black channel and normalized in color namespace by the indicated point region detection algorithm, as shown in fig. 15, fig. 14 is binarized and hole-filled by the indicated point region detection algorithm, as shown in fig. 16, fig. 15 is morphologically reconstructed by the indicated point region detection algorithm using a disc-shaped structuring element with radius 20, as shown in fig. 17, the difference image of fig. 15 and fig. 16 is calculated by the indicated point region detection algorithm, and the difference image is normalized, as shown in fig. 18, only 2 regions with the largest area are retained for fig. 17 by the indicated point region detection algorithm, and the obtained indicated point region is, as shown in fig. 19, the mechanical angle detection algorithm describes the region calculated for fig. 18Sub-derived centroid coordinates (x) of 2 pointer regions
c1,y
c1) And (x)
c2,y
c2) And 2 midpoint coordinates (x) between centroids of the pointing region
c,y
c) As shown in fig. 20, the input image of the non-pointing region detection algorithm obtained by the mechanical angle detection algorithm is, as shown in fig. 21, obtained by taking a red color channel in the RGB color space by the non-pointing region detection algorithm and maximum-filtering the red color channel by using a 5 × 5 full 1 matrix, as shown in fig. 22, obtained by taking a red color channel in the RGB color space by the non-pointing region detection algorithm and minimum-filtering the red color channel by using a 5 × 5 full 1 matrix, as shown in fig. 23, obtained by subtracting the red color channel from fig. 22 from fig. 21 by the non-pointing region detection algorithm, as shown in fig. 24, obtained by binarizing and filling holes in fig. 23 by the non-pointing region detection algorithm, as shown in fig. 25, obtained by performing the etching operation on fig. 24 by using a disk-type structural element having a radius of 5 by the non-pointing region detection algorithm, as shown in fig. 1, as shown in fig. 26, the corrosion result 2 obtained by performing the corrosion operation on fig. 25 by using the disc-shaped structural element with the radius of 20 by the non-indicative point region detection algorithm is, as shown in fig. 27, morphologically reconstructed by the non-indicative point region detection algorithm on fig. 25 and 26, as shown in fig. 28, and the symbol definition of the non-indicative point region detected by the non-indicative point region detection algorithm on fig. 27, including R
1、R
2And R
3Three areas with the coordinates of the mass center of the three areas being respectively (x)
1,y
1)、(x
2,y
2) And (x)
3,y
3) The coordinates of the middle points among the centroids of the three regions are respectively (x)
12,y
12)、(x
13,y
13) And (x)
23,y
23) FIG. 29 shows a process of detecting a non-pointing region of FIG. 27 by a non-pointing region detection algorithm, wherein R is
1、R
2And R
3Coordinate of middle point between centroids of three regions to coordinate of middle point between centroids of indicated point region (x)
c,y
c) Respectively, are d
12、d
13And d
23Due to d therein
12Maximum, and thus its corresponding region R
1And R
2That is, the detected non-pointing point region is obtained by a non-pointing point region detection algorithm as shown in fig. 30, and the main axis angle α of 2 non-pointing point regions obtained by calculating a region descriptor from fig. 30 by a mechanical angle detection algorithm as shown in fig. 31
1And alpha
2And using alpha
1And alpha
2Calculating the average angle of the main axes of the 2 non-indication point areas
As shown in fig. 32, a new coordinate system is constructed by the mechanical angle detection algorithm, and as shown in fig. 33, the current mechanical angle α detected by the mechanical angle detection algorithm from fig. 6 is x
c<x
oThus, therefore, it is
I.e. the initial mechanical angle alpha
0As shown in fig. 34, the current mechanical angle α detected by the mechanical angle detection algorithm in fig. 7 is 52.1 °, since x is x
c>x
oThus, therefore, it is
Then the deflection angle beta is obtained from step 1.4 of the mechanical angle resetting method as alpha-alpha
0239.6 ° -52.1 ° -187.5 °, i.e. a mechanical angular reset of fig. 7 requires a rotation of 187.5 °.
The 3362 potentiometer mechanical angle resetting system and the resetting method based on machine vision provided by the invention are introduced in detail, and a specific example is applied in the text to explain the principle and the implementation of the invention, and the description of the above embodiment is only used for helping to understand the method and the core idea of the invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.