Steel pipe end position determination method and device, electronic equipment and storage medium
By using a binocular imaging device and image processing technology, the edge of the steel pipe end is extracted using convolution and nonmaximum suppression. A coordinate mapping equation is constructed by combining intrinsic and extrinsic parameter matrices, which solves the problem of low efficiency in traditional steel pipe end position determination and achieves efficient and accurate steel pipe end center positioning.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CHENGDE JIANLONG SPECIAL STEEL
- Filing Date
- 2026-04-10
- Publication Date
- 2026-05-12
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Traditional methods for determining the position of steel pipe ends are inefficient and cannot meet the high-quality grinding requirements of mass production.
A binocular imaging device is used to acquire images of the first and second ends of the steel pipe. Edge images are extracted by convolution and non-maximum suppression. A coordinate mapping equation is constructed by combining intrinsic and extrinsic parameter matrices to fit the position of the center of the steel pipe end.
It achieves high-precision center positioning of steel pipe ends without manual intervention, improving inspection efficiency and automation level, and reducing inspection costs.
Smart Images

Figure CN122015779A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of steel pipe end positioning technology, and in particular to a method, device, electronic device and storage medium for determining the position of a steel pipe end. Background Technology
[0002] Pipe end grinding is a key process in steel pipe manufacturing. Its core purpose is to remove burrs, scale, and beveling residue from the pipe ends, so as to achieve a flat end face and a smooth bevel, ensuring the reliability of subsequent welding, flange connection, and anti-corrosion treatment.
[0003] The core of steel pipe end grinding is "precise control of geometric accuracy, adaptation to material characteristics, and ensuring the reliability of subsequent processes." During on-site construction, appropriate tools and parameters must be selected based on the steel pipe material, diameter, and connection method, strictly adhering to the "positioning – grinding – inspection" process.
[0004] For mass-produced steel pipes, pipe posture recognition and positioning are crucial for high-quality grinding. Traditional positioning methods use tooling and fixtures to determine the pipe's posture. However, due to the need for subsequent handling of the pipes and the limitations of production batches and specifications, traditional methods for determining pipe end positions are inefficient.
[0005] Therefore, it is necessary to develop a method for determining the position of the steel pipe end. Summary of the Invention
[0006] The present invention provides a method, apparatus, electronic device and storage medium for determining the position of steel pipe ends, which solves the problem of low efficiency in determining the position of steel pipe ends in the prior art.
[0007] In a first aspect, embodiments of the present invention provide a method for determining the position of a steel pipe end, comprising: A first pipe end image and a second pipe end image of the steel pipe are acquired, wherein the first pipe end image and the second pipe end image are acquired based on a binocular imaging device; The first tube end image and the second tube end image are processed by convolution and non-maximum suppression of pixels to obtain the first tube end edge map and the second tube end edge map. Based on the intrinsic parameter matrix, the first extrinsic parameter matrix, and the second extrinsic parameter matrix, a coordinate mapping equation is constructed for mapping the world coordinates of the tube edge to the pixel coordinates. The intrinsic parameter matrix describes the relationship between the image coordinates and the camera coordinates, and the extrinsic parameter matrix describes the relationship between the camera coordinate system and the world coordinate system. The first extrinsic parameter matrix and the second extrinsic parameter matrix correspond to the two targets of the shooting device, respectively. The coordinate mapping equation is fitted based on the first pipe end edge map and the second pipe end edge map to obtain the position of the center of the steel pipe end.
[0008] In one possible implementation, processing the first tube-end image and the second tube-end image by performing convolution and non-maximum suppression on the pixels to obtain the first tube-end edge map and the second tube-end edge map includes: For each pipe end image in the first pipe end image and the second pipe end image, perform the following steps respectively: Obtain the horizontal difference operator and the vertical difference operator; The tube end image is convolved using the horizontal difference operator and the vertical difference operator respectively to obtain a horizontal difference image and a vertical difference image; Based on the horizontal difference map and the vertical difference map, a gradient map representing the gradient values and gradient directions of image pixels is constructed; For each pixel in the gradient map, find the pixels in the gradient direction and the opposite direction of the gradient in the neighborhood as the first neighboring pixels, and retain the pixel value or set the pixel value to 0 depending on whether the pixel is greater than all the first neighboring pixels. The gradient map, which has undergone pixel value processing based on the first neighboring pixels, is used as the edge map at the tube end.
[0009] In one possible implementation, constructing a gradient map representing the gradient values and gradient directions of image pixels based on the horizontal difference map and the vertical difference map includes: For each pixel, the pixel gradient value and pixel gradient direction are extracted according to the first formula, the horizontal difference map, and the vertical difference map, and the obtained pixel gradient value and pixel gradient direction are added to the gradient map. The first formula is:
[0010] In the formula, The pixel gradient value. For pixel gradient direction, This represents the pixel value in the vertical difference image. This represents the pixel value in the horizontal difference map. This is a rounding function. Pi It is the arctangent function.
[0011] In one possible implementation, constructing the coordinate mapping equation from pipe edge world coordinates to pixel coordinates based on the intrinsic parameter matrix, the first extrinsic parameter matrix, and the second extrinsic parameter matrix includes: Construct a circular equation in a three-dimensional coordinate system with the center of the pipe end as the reference. Based on the first extrinsic matrix and the second extrinsic matrix, a first coordinate transformation equation and a second coordinate transformation equation are constructed to convert world coordinates into camera coordinates, wherein the first coordinate transformation equation and the second coordinate transformation equation correspond to the two targets of the shooting device, respectively. Based on the intrinsic parameter matrix, a third coordinate transformation equation is constructed to convert camera coordinates into pixel coordinates; By combining the circular equation, the first coordinate transformation equation, the second coordinate transformation equation, and the third coordinate transformation equation, the coordinate mapping equation is obtained.
[0012] In one possible implementation, the circular equation is:
[0013] In the formula, The world coordinates of the pipe end edge, The coordinates of the pipe end center are Where is the radius of the steel pipe. This is the output of the circular equation; The first and second extrinsic parameter matrices respectively include a rotation matrix describing the rotation relationship from the world coordinate system to the camera coordinate system and a translation vector describing the coordinates of the origin of the world coordinate system in the camera coordinate system. The first coordinate transformation equation or the second coordinate transformation equation is:
[0014] In the formula, For camera coordinates, This is the rotation matrix of either the first or second extrinsic parameter matrix. It is the translation vector of the first extrinsic parameter matrix or the translation vector of the second extrinsic parameter matrix; The third coordinate transformation equation is:
[0015] In the formula, For pixel coordinates, The distance from the edge of the tube end to the optical center of the camera. This is the intrinsic parameter matrix.
[0016] In one possible implementation, fitting the coordinate mapping equation based on the first pipe end edge map and the second pipe end edge map to obtain the position of the center of the steel pipe end includes: Obtain the radius of the steel pipe and multiple parameter arrays, where each parameter array includes the coordinates of the pipe end center and the distance from the edge of the pipe end to the optical center of the camera; Substitute each parameter array into the coordinate mapping equation to obtain the first fitting equation; For each first fitting equation, the coordinates of the tube end pixels in the first tube end edge map and the second tube end edge map are substituted into the first fitting equation, and the fitting deviation of the parameter array is determined based on the multiple outputs of the first fitting equation. If the preset number of iterations is not reached, the multiple parameter arrays are adjusted according to multiple fitting deviations, and the process jumps to the step of substituting each parameter array into the coordinate mapping equation to obtain the first fitting equation. Otherwise, the parameter array with the smallest fitting deviation is taken as the target parameter array, and the position of the pipe end center is determined based on the target parameter array.
[0017] In one possible implementation, multiple outputs of the first fitting equation determine the fitting bias of the parameter array, including: The fitting bias of the parameter array is determined based on the second formula and multiple outputs of the first fitting equation, wherein the second formula is:
[0018] In the formula, For fitting bias, The first fitting equation is the th One output, This represents the total number of tube-end pixels in the first tube-end edge map and the second tube-end edge map.
[0019] Secondly, embodiments of the present invention provide a steel pipe end position determination device for implementing the steel pipe end position determination method as described in the first aspect or any possible implementation thereof, the steel pipe end position determination device comprising: A binocular image acquisition module is used to acquire a first pipe end image and a second pipe end image of the steel pipe, wherein the first pipe end image and the second pipe end image are acquired based on a binocular imaging device; The image edge extraction module is used to process the first tube end image and the second tube end image by performing convolution and non-maximum suppression on the pixels to obtain the first tube end edge map and the second tube end edge map; The pipe edge coordinate mapping equation construction module is used to construct a coordinate mapping equation from the pipe edge world coordinates to the pixel coordinates based on the intrinsic parameter matrix, the first extrinsic parameter matrix, and the second extrinsic parameter matrix. The intrinsic parameter matrix describes the relationship between the image coordinates and the camera coordinates, and the extrinsic parameter matrix describes the relationship between the camera coordinate system and the world coordinate system. The first extrinsic parameter matrix and the second extrinsic parameter matrix correspond to the two targets of the shooting device, respectively. as well as, The pipe end center positioning module is used to fit the coordinate mapping equation according to the first pipe end edge map and the second pipe end edge map to obtain the position of the center of the steel pipe end.
[0020] Thirdly, embodiments of the present invention provide an electronic device, including a memory and a processor, wherein the memory stores a computer program executable on the processor, and the processor executes the computer program to implement the steps of the method as described in the first aspect or any possible implementation of the first aspect.
[0021] Fourthly, embodiments of the present invention provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the method as described in the first aspect or any possible implementation thereof.
[0022] The beneficial effects of the embodiments of the present invention compared with the prior art are as follows: This invention discloses a method for determining the position of a steel pipe end. First, it acquires a first and a second image of the steel pipe end, both captured by a binocular camera. Then, it processes these images by performing convolution and non-maximum suppression on the pixels to obtain a first and a second edge map of the pipe end. Next, it constructs a coordinate mapping equation from the world coordinates of the pipe end edge to the pixel coordinates based on an intrinsic matrix, a first extrinsic matrix, and a second extrinsic matrix. The intrinsic matrix describes the relationship between image coordinates and camera coordinates, while the extrinsic matrix describes the relationship between the camera coordinate system and the world coordinate system. The first and second extrinsic matrices correspond to the two eyes of the camera. Finally, it fits the coordinate mapping equation to the first and second edge maps of the pipe end to obtain the position of the center of the steel pipe end. This method requires no manual intervention throughout the entire process, forming a complete technical chain from image acquisition and edge extraction to center localization. It can replace the cumbersome operations of traditional manual measurement or single-vision inspection, reducing human error, adapting to industrial batch inspection scenarios, and lowering inspection costs.
[0023] Compared with existing technologies, the steel pipe end image edge extraction and center localization scheme of this invention is as follows: Improving the accuracy of image acquisition and edge extraction: Images are acquired using a binocular imaging device, which can supplement three-dimensional spatial information by leveraging the parallax principle, reducing the interference of shooting angle distortion and lighting changes on the features of the tube end, and providing high-quality raw data for subsequent processing; through the combination strategy of "convolution + maximum suppression", combined with the noise suppression advantage of the Sobel operator and gradient quantization optimization, single-pixel-level accurate extraction of tube end edges is achieved, effectively separating edges from the background and avoiding edge omission or redundancy.
[0024] Ensuring the reliability and universality of coordinate mapping: The coordinate mapping equation construction process integrates the physical meaning of intrinsic and extrinsic parameter matrices with the geometric constraints of the pipe end circle, fully connecting the transformation link of "world coordinates → camera coordinates → pixel coordinates", clarifying the quantitative relationship of each parameter, and adapting to pipe end inspection scenarios of steel pipes of different specifications, reducing mapping errors caused by missing parameters or logical breaks.
[0025] Achieving high precision and stability in pipe end center positioning: A fitting strategy of "iterative optimization + mean square error feedback" is adopted. By initializing a multi-parameter array to cover a reasonable range of values, the single parameter is avoided from getting stuck in a local optimum. The mean square error has a strong penalty for pixels with large deviations. Combined with the iterative parameter adjustment mechanism, it can gradually approach the true pipe end center coordinates. The positioning accuracy directly ensures the reliability of subsequent industrial applications such as steel pipe assembly and dimensional verification.
[0026] Improve the efficiency and automation level of industrial inspection: The entire process requires no manual intervention. It forms a complete technical link from image acquisition and edge extraction to center positioning. It can replace the cumbersome operation of traditional manual measurement or single vision inspection, reduce human error, adapt to industrial batch inspection scenarios, and reduce inspection costs. Attached Figure Description
[0027] To more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0028] Figure 1 This is a flowchart of the method for determining the position of the steel pipe end provided in the embodiments of the present invention; Figure 2 This is a functional block diagram of the steel pipe end position determination device provided in the embodiments of the present invention; Figure 3 This is a functional block diagram of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0029] In the following description, specific details such as particular system structures and techniques are set forth for illustrative purposes and not for limitation, so as to provide a thorough understanding of embodiments of the invention. However, those skilled in the art will understand that the invention can be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, and methods are omitted so as not to obscure the description of the invention with unnecessary detail.
[0030] To make the objectives, technical solutions, and advantages of the present invention clearer, specific embodiments will be described below in conjunction with the accompanying drawings.
[0031] The embodiments of the present invention will be described in detail below. This example is implemented based on the technical solution of the present invention, and provides detailed implementation methods and specific operation processes. However, the protection scope of the present invention is not limited to the following embodiments.
[0032] Figure 1 A flowchart of a method for determining the position of the steel pipe end provided in an embodiment of the present invention.
[0033] like Figure 1 As shown, a flowchart illustrating the implementation of the steel pipe end position determination method provided by an embodiment of the present invention is presented, and is described in detail below: In step 101, a first pipe end image and a second pipe end image of the steel pipe are acquired, wherein the first pipe end image and the second pipe end image are acquired based on a binocular imaging device.
[0034] In step 102, the first tube-end image and the second tube-end image are processed by convolution and non-maximum suppression of pixels to obtain the first tube-end edge map and the second tube-end edge map.
[0035] In some embodiments, processing the first tube-end image and the second tube-end image by performing convolution and non-maximum suppression on the pixels to obtain the first tube-end edge map and the second tube-end edge map includes: For each pipe end image in the first pipe end image and the second pipe end image, perform the following steps respectively: Obtain the horizontal difference operator and the vertical difference operator; The tube end image is convolved using the horizontal difference operator and the vertical difference operator respectively to obtain a horizontal difference image and a vertical difference image; Based on the horizontal difference map and the vertical difference map, a gradient map representing the gradient values and gradient directions of image pixels is constructed; For each pixel in the gradient map, find the pixels in the gradient direction and the opposite direction of the gradient in the neighborhood as the first neighboring pixels, and retain the pixel value or set the pixel value to 0 depending on whether the pixel is greater than all the first neighboring pixels. The gradient map, which has undergone pixel value processing based on the first neighboring pixels, is used as the edge map at the tube end.
[0036] In some implementations, constructing a gradient map representing the gradient values and gradient directions of image pixels based on the horizontal difference map and the vertical difference map includes: For each pixel, the pixel gradient value and pixel gradient direction are extracted according to the first formula, the horizontal difference map, and the vertical difference map, and the obtained pixel gradient value and pixel gradient direction are added to the gradient map. The first formula is:
[0037] In the formula, The pixel gradient value. For pixel gradient direction, This represents the pixel value in the vertical difference image. This represents the pixel value in the horizontal difference map. This is a rounding function. Pi It is the arctangent function.
[0038] For example, in the technical process of steel pipe end inspection, edge extraction is a crucial preliminary step for obtaining the pipe end contour features, and its accuracy directly affects the accuracy of subsequent core tasks such as contour matching and dimensional measurement. This step is mainly achieved by combining binocular vision image acquisition with digital image processing technology, and the specific core steps are as follows: The core task of binocular vision image acquisition is to obtain first and second images of the steel pipe end. These images are captured using a binocular imaging device. The key advantage of using a binocular imaging device is that it allows for the simultaneous acquisition of pipe end images through two cameras with different perspectives. The parallax principle of binocular vision can then be used to ensure the accuracy of subsequent edge extraction. During the shooting process, it is crucial to ensure that the optical axis of the binocular cameras maintains a reasonable angle with the axis of the steel pipe to avoid distortion of the pipe end edges due to shooting angle deviations. Simultaneously, the lighting intensity of the shooting environment must be controlled to avoid direct sunlight or excessively dark lighting, which would reduce the grayscale contrast between the pipe end and the background and affect the subsequent edge extraction results. The two acquired pipe end images must have the same resolution, be captured in a synchronized sequence, and cover the entire pipe end face area without significant occlusion or defects.
[0039] In some implementations, the first and second tube-end images are processed by convolution and non-maximum suppression of pixels to obtain first and second tube-end edge maps. Specifically, a "process image by image, execute step by step" strategy is adopted, that is, for each tube-end image in the first and second tube-end images, the following complete steps are executed independently to ensure that the processing standards of the two images are consistent, laying the foundation for subsequent binocular matching: Differential Operator Selection and Construction: Obtaining horizontal and vertical differential operators. Differential operators are the core tools for image edge enhancement. Their principle is to locate edge regions with abrupt gray-level changes by calculating the gray-level difference between adjacent pixels in the image. Considering that the edges of the tube-end image are mainly circular contours with both horizontal and vertical gray-level changes, differential operators in both the horizontal and vertical directions need to be selected simultaneously. Commonly used differential operators include the Sobel operator and the Prewitt operator. Here, the Sobel operator is preferred because it incorporates a neighborhood weighted averaging strategy while calculating the difference, effectively suppressing the interference of image noise on edge extraction. Taking a 3×3 Sobel operator as an example, the horizontal differential operator (used to detect vertical edges) is:
[0040] The vertical difference operator (used for detecting horizontal edges) is:
[0041] Convolution Operation and Difference Image Generation: The tube-end image is convolved using the horizontal and vertical difference operators to obtain horizontal and vertical difference images, respectively. The specific process of the convolution operation is as follows: the difference operator is used as a sliding window, starting from the top-left pixel of the tube-end image, sliding row by row and column by column, pixel by pixel. At each sliding position, the operator element is multiplied by the corresponding image pixel grayscale value, and all product results are summed to obtain the convolution output value at that position. The convolution output values at all positions are arranged according to the pixel coordinates of the original image to generate the corresponding difference image. In the horizontal difference image, the pixel value represents the intensity of grayscale change in the horizontal direction at the corresponding position (the larger the value, the more obvious the edge features in the vertical direction at that position), and the pixel value in the vertical difference image represents the intensity of grayscale change in the vertical direction at the corresponding position (the larger the value, the more obvious the edge features in the horizontal direction at that position).
[0042] Gradient Map Construction: Based on the horizontal and vertical difference maps, a gradient map representing the pixel gradient values and directions of the image is constructed. The gradient is an important quantitative indicator of image grayscale changes. The gradient value reflects the drasticness of the pixel grayscale change (the larger the gradient value, the more significant the edge features), while the gradient direction points to the direction of the most drastic grayscale change (i.e., the normal direction of the edge). The core purpose of constructing the gradient map is to fuse the difference information in the horizontal and vertical directions to form a complete representation of edge features, providing an accurate basis for subsequent maximum suppression.
[0043] Non-maximum suppression (NMS) refines edges: For each pixel in the gradient map, pixels in the gradient direction and the opposite direction are identified as the first neighboring pixels. The pixel's grayscale value is then determined by whether it is greater than the grayscale values of all first neighboring pixels, deciding whether to retain or set it to 0. The core function of this step is to refine the "coarse edges" (usually multi-pixel wide) obtained from convolution into "fine edges" (single-pixel wide). Since the gradient values in edge regions are generally high after convolution, but have a certain width, NMS can retain only the pixel with the largest gradient value at the edge center and remove redundant pixels on both sides of the edge, thereby improving the accuracy of edge localization. A 3×3 pixel neighborhood is typically chosen here because this size effectively covers adjacent pixels while avoiding distortion of edge information due to an excessively large neighborhood.
[0044] Edge map output: The gradient map, after processing the pixel values of the first neighboring pixels (keeping or setting them to 0), is used as the pipe end edge map corresponding to the pipe end image. In the final output pipe end edge map, only the single-pixel edge of the pipe end contour is retained, while the pixel values of the background area and non-edge areas are all 0, achieving effective separation of edge features from the background.
[0045] Detailed implementation of gradient graph construction In some implementations, constructing a gradient map representing the gradient values and directions of image pixels based on the horizontal and vertical difference maps requires precise mathematical calculations to quantize and extract the gradient parameters, specifically including the following: For each pixel in the image at the tube end, gradient parameter extraction and gradient map integration operations must be performed independently to ensure that the gradient map can completely represent the edge feature distribution of the entire image. Specifically, the pixel gradient value and pixel gradient direction of the pixel need to be accurately extracted according to the first formula, the horizontal difference map, and the vertical difference map, and the obtained pixel gradient value and pixel gradient direction are stored in the gradient map according to the corresponding pixel coordinates. Among them, the first formula is the core mathematical model for gradient parameter calculation, and the specific expression is as follows:
[0046] In the formula, The pixel gradient value. For pixel gradient direction, This represents the pixel value in the vertical difference image. This represents the pixel value in the horizontal difference map. This is a rounding function. Pi It is the arctangent function.
[0047] The detailed definitions and physical meanings of each parameter in the formula are as follows: Pixel gradient value: This is a comprehensive quantitative indicator of the intensity of grayscale changes in the horizontal and vertical directions of a pixel. The larger the value, the more drastic the grayscale change at the pixel's location, and the more likely it is to be a pixel at the edge of the control tube. By performing a square root operation on the sum of the squares of the horizontal and vertical difference grayscale values, edge information from both directions can be effectively fused, avoiding edge omissions caused by single-direction difference.
[0048] Pixel gradient direction: Represents the direction of the most drastic grayscale change of the pixel, i.e. the normal direction of the edge. Its value range has been quantized to facilitate the rapid location of neighboring pixels in subsequent maximum suppression.
[0049] The value of a pixel in the vertical difference map is the output value obtained by performing a convolution operation on the pixel using the vertical difference operator. It mainly reflects the intensity of grayscale change of the pixel in the vertical direction and is used to characterize the edge features in the horizontal direction.
[0050] The value of a pixel in the horizontal difference map is the output value obtained by performing a convolution operation on the pixel using the horizontal difference operator. It mainly reflects the intensity of grayscale change of the pixel in the horizontal direction and is used to characterize the edge features in the vertical direction.
[0051] The rounding function quantizes the calculated gradient direction into discrete angle values. Since subsequent maximum suppression requires selecting neighboring pixels in the gradient direction and its opposite direction, quantizing continuous gradient directions into fixed discrete directions (such as 0°, 45°, 90°, 135°, etc., 8 directions) can greatly simplify the neighboring pixel search logic and improve computational efficiency.
[0052] Pi (π): with a value of approximately 3.1416, is used to convert the angle unit from radians to the quantization range.
[0053] Arctangent function: used to calculate grayscale values based on horizontal differences. and vertical difference gray value The ratio is used to calculate the initial radian value of the gradient direction, and its output range is [-π / 2, π / 2]. It needs to be converted into a discrete direction that meets the requirements of neighborhood search through subsequent quantization processing.
[0054] It should be noted that, in the actual calculation process, if... In cases where there is no change in grayscale in the horizontal direction, special handling is required: If in this case... gradient direction The value can be directly taken as π / 2 (90°) or -π / 2 (270°); if and This indicates that the pixel has no grayscale change, the gradient value G is 0, and the gradient direction can be set to an invalid value. In subsequent maximum suppression, the pixel value is directly set to 0. Through the above precise mathematical calculations and special case handling, it can be ensured that the gradient parameters of each pixel in the gradient map are accurate and effective, laying a reliable foundation for subsequent maximum suppression and edge extraction.
[0055] In step 103, a coordinate mapping equation is constructed based on the intrinsic parameter matrix, the first extrinsic parameter matrix, and the second extrinsic parameter matrix to map the world coordinates of the tube edge to the pixel coordinates. The intrinsic parameter matrix describes the relationship between the image coordinates and the camera coordinates, and the extrinsic parameter matrix describes the relationship between the camera coordinate system and the world coordinate system. The first extrinsic parameter matrix and the second extrinsic parameter matrix correspond to the two targets of the shooting device, respectively.
[0056] In some implementations, constructing the coordinate mapping equation from the pipe edge world coordinates to pixel coordinates based on the intrinsic parameter matrix, the first extrinsic parameter matrix, and the second extrinsic parameter matrix includes: Construct a circular equation in a three-dimensional coordinate system with the center of the pipe end as the reference. Based on the first extrinsic matrix and the second extrinsic matrix, a first coordinate transformation equation and a second coordinate transformation equation are constructed to convert world coordinates into camera coordinates, wherein the first coordinate transformation equation and the second coordinate transformation equation correspond to the two targets of the shooting device, respectively. Based on the intrinsic parameter matrix, a third coordinate transformation equation is constructed to convert camera coordinates into pixel coordinates; By combining the circular equation, the first coordinate transformation equation, the second coordinate transformation equation, and the third coordinate transformation equation, the coordinate mapping equation is obtained.
[0057] In some embodiments, the equation of the circle is:
[0058] In the formula, The world coordinates of the pipe end edge, The coordinates of the pipe end center are Where is the radius of the steel pipe. This is the output of the circular equation; The first and second extrinsic parameter matrices respectively include a rotation matrix describing the rotation relationship from the world coordinate system to the camera coordinate system and a translation vector describing the coordinates of the origin of the world coordinate system in the camera coordinate system. The first coordinate transformation equation or the second coordinate transformation equation is:
[0059] In the formula, For camera coordinates, This is the rotation matrix of either the first or second extrinsic parameter matrix. It is the translation vector of the first extrinsic parameter matrix or the translation vector of the second extrinsic parameter matrix; The third coordinate transformation equation is:
[0060] In the formula, For pixel coordinates, The distance from the edge of the tube end to the optical center of the camera. This is the intrinsic parameter matrix.
[0061] For example, based on the intrinsic parameter matrix, the first extrinsic parameter matrix, and the second extrinsic parameter matrix, a coordinate mapping equation is constructed to map the world coordinates of the pipe edge to the pixel coordinates. This is achieved using a "geometric constraint modeling + multi-coordinate transformation link concatenation" approach, specifically including the following step-by-step implementation steps to ensure the accuracy of the mapping equation and the completeness of its physical meaning: Constructing the world coordinate geometric constraint equation (circular equation) for the pipe end edge: A circular equation is constructed in a three-dimensional coordinate system with the pipe end center as the reference. Since the pipe end ideally has a circular profile, the coordinates of any point on its edge in the preset world coordinate system satisfy the three-dimensional geometric constraint relationship of a circle. This equation serves as the "geometric prior constraint" for subsequent coordinate mapping, filtering out invalid mapping relationships that do not conform to the pipe end profile characteristics, thus improving mapping accuracy.
[0062] Constructing transformation equations from world coordinates to camera coordinates (first and second coordinate transformation equations): Based on the first and second extrinsic parameter matrices, construct the first and second coordinate transformation equations to convert world coordinates to corresponding camera coordinates. The first coordinate transformation equation corresponds to the first camera of the binocular imaging device, and the second coordinate transformation equation corresponds to the second camera. The core function of the extrinsic parameter matrix is to establish the pose relationship between the "world coordinate system" and the "camera coordinate system." Through this transformation equation, the pipe edge coordinates (3D) in the world coordinate system can be converted to coordinates (3D) in the corresponding camera coordinate system, completing the mapping from "global coordinates" to "camera local coordinates."
[0063] Constructing the transformation equation from camera coordinates to pixel coordinates (the third coordinate transformation equation): Based on the intrinsic parameter matrix, construct the third coordinate transformation equation to convert camera coordinates to pixel coordinates. The intrinsic parameter matrix contains inherent parameters such as the camera's focal length and principal point coordinates. These parameters determine how a 3D point in the camera coordinate system is mapped to pixel coordinates in the 2D image plane through perspective projection. This is the key equation for achieving dimensionality reduction mapping from "3D camera coordinates" to "2D pixel coordinates".
[0064] The final coordinate mapping equation is obtained by simultaneously solving the following equations: The constructed circular equation, first coordinate transformation equation, second coordinate transformation equation, and third coordinate transformation equation are combined to eliminate intermediate variables (camera coordinates). This yields a coordinate mapping equation with "world coordinates at the edge of the tube" as input and "pixel coordinates" as output. This simultaneous equation process solidifies the complete mapping chain from "world coordinates → camera coordinates → pixel coordinates" into a unified equation. Subsequently, the corresponding world coordinates can be directly deduced from the pixel coordinates, or the pixel coordinates can be predicted based on the world coordinates.
[0065] In some more specific implementations, the specific expressions, parameter definitions, and physical meanings of each equation are as follows: Equation for the circular shape of the pipe end edge (world coordinate geometric constraints) The specific expression for the circular equation is:
[0066] In the formula, The world coordinates of the pipe end edge, The coordinates of the pipe end center are Where is the radius of the steel pipe. This is the output of the circular equation.
[0067] The detailed definitions and physical meanings of each parameter in the formula are as follows: The world coordinates of any point on the edge of the pipe end are the core input variables of the equation, representing the three-dimensional spatial position of that point in the preset world coordinate system. The three-dimensional coordinates of the pipe end center in the world coordinate system are the reference point for the circular equation. The value of the reference point is determined by the way the world coordinate system is set (usually the origin of the world coordinate system or a fixed reference point is aligned with the pipe end center to simplify the calculation). The nominal radius (or actual measured radius) of the steel pipe is a geometric constraint parameter of the circular equation, ensuring that only points that conform to the pipe end profile radius satisfy the equation. The output of the circular equation, ideally, is the result of substituting the coordinates of a point on the edge of the pipe end into the equation. ;like This indicates that the point is not on the ideal circular profile of the pipe end edge and can be filtered as an invalid point.
[0068] Transformation equations from world coordinates to camera coordinates (first and second coordinate transformation equations) The core components of both the first and second extrinsic parameter matrices consist of two parts: one is a rotation matrix that describes the rotation relationship from the world coordinate system to the camera coordinate system. Secondly, it is a translation vector describing the coordinates of the origin of the world coordinate system in the camera coordinate system. Based on these two core components, the unified expression for the first coordinate transformation equation (corresponding to the first camera) or the second coordinate transformation equation (corresponding to the second camera) is:
[0069] In the formula, For camera coordinates, This is the rotation matrix of either the first or second extrinsic parameter matrix. It is the translation vector of the first extrinsic matrix or the translation vector of the second extrinsic matrix.
[0070] The detailed definitions and physical meanings of each parameter in the formula are as follows: The three-dimensional coordinates of a point on the edge of the pipe in the corresponding camera coordinate system are the input variables of the transformation equation. : Rotation matrix, a 3×3 orthogonal matrix, used to represent the rotation attitude of the world coordinate system relative to the camera coordinate system (such as the rotation angle around the x-axis, y-axis, and z-axis). Let R be the transpose of the rotation matrix R (since the rotation matrix is orthogonal, its transpose is equal to its inverse matrix, i.e., ...). ); T: Translation vector, a 3×1 column vector whose elements correspond to the coordinates of the origin of the world coordinate system in the x, y, and z directions in the camera coordinate system, and are used to characterize the translation and offset relationship between the world coordinate system and the camera coordinate system. The world coordinates corresponding to this point are the output variables of the transformation equation. This equation can be used to reverse the point coordinates in the camera coordinate system to the coordinates in the world coordinate system.
[0071] The transformation equation from camera coordinates to pixel coordinates (the third coordinate transformation equation) The third coordinate transformation equation is constructed based on the principle of perspective projection, and its specific expression is as follows:
[0072] In the formula, For pixel coordinates, The distance from the edge of the tube end to the optical center of the camera. This is the intrinsic parameter matrix.
[0073] The detailed definitions and physical meanings of each parameter in the formula are as follows: The pixel coordinates of a point on the edge of the tube end in the image plane are the input variables of the transformation equation, corresponding to the pixel position on the edge map extracted in step 102. The distance from the point on the edge of the tube to the corresponding camera optical center (i.e., the z-axis coordinate value of the point in the camera coordinate system) is the scaling factor of the perspective projection, and its magnitude determines the scaling ratio of the mapping between pixel coordinates and camera coordinates. The intrinsic parameter matrix is a 3×3 matrix, typically in the form of:
[0074] in , These are the equivalent focal lengths of the camera along the x-axis and y-axis (unit: pixels). , These are the pixel coordinates of the principal point of the image (the intersection of the camera's optical axis and the image plane); The inverse of the intrinsic parameter matrix K is used to perform the reverse transformation from pixel coordinates to camera coordinates. The camera coordinates corresponding to this point are the output variables of the transformation equation. This equation can be used to convert 2D pixel coordinates back to 3D camera coordinates (this needs to be combined with...). The values of are limited, therefore monocular vision cannot directly determine the absolute 3D coordinates, while binocular vision can obtain them through disparity calculation. ).
[0075] It should be further explained that the simultaneous logic of the above three types of equations is as follows: taking the "pipe edge point" as the core associated object, the relationship between world coordinates and camera coordinates is established through the first / second coordinate transformation equation; the relationship between camera coordinates and pixel coordinates is established through the third coordinate transformation equation; then, a circular equation is used to apply geometric constraints to the world coordinates; finally, the intermediate variable of camera coordinates is eliminated, resulting in " → The direct mapping relationship between the two cameras can be established. For example, for the first camera in a binocular imaging device, by simultaneously solving the circular equation, the first coordinate transformation equation, and the third coordinate transformation equation, the coordinate mapping equation corresponding to that camera can be obtained; similarly, the mapping equation corresponding to the second camera can be obtained. Subsequently, by combining the mapping equations of the two cameras with the principle of binocular parallax, the world coordinates of the edge points of the pipe end can be accurately solved, thereby realizing the reconstruction of the three-dimensional contour of the pipe end.
[0076] In step 104, the coordinate mapping equation is fitted according to the first pipe end edge map and the second pipe end edge map to obtain the position of the center of the steel pipe end.
[0077] In some embodiments, fitting the coordinate mapping equation based on the first pipe end edge map and the second pipe end edge map to obtain the position of the center of the steel pipe end includes: Obtain the radius of the steel pipe and multiple parameter arrays, where each parameter array includes the coordinates of the pipe end center and the distance from the edge of the pipe end to the optical center of the camera; Substitute each parameter array into the coordinate mapping equation to obtain the first fitting equation; For each first fitting equation, the coordinates of the tube end pixels in the first tube end edge map and the second tube end edge map are substituted into the first fitting equation, and the fitting deviation of the parameter array is determined based on the multiple outputs of the first fitting equation. If the preset number of iterations is not reached, the multiple parameter arrays are adjusted according to multiple fitting deviations, and the process jumps to the step of substituting each parameter array into the coordinate mapping equation to obtain the first fitting equation. Otherwise, the parameter array with the smallest fitting deviation is taken as the target parameter array, and the position of the pipe end center is determined based on the target parameter array.
[0078] In some implementations, multiple outputs of the first fitting equation determine the fitting bias of the parameter array, including: The fitting bias of the parameter array is determined based on the second formula and multiple outputs of the first fitting equation, wherein the second formula is:
[0079] In the formula, For fitting bias, The first fitting equation is the th One output, This represents the total number of tube-end pixels in the first tube-end edge map and the second tube-end edge map.
[0080] For example, the coordinate mapping equation is fitted based on the first and second pipe end edge maps to obtain the position of the center of the steel pipe end. A fitting strategy of "iterative optimization + deviation feedback adjustment" is adopted, continuously approximating the true pipe end center coordinates through multiple rounds of parameter iteration. Specifically, the following step-by-step implementation steps are included to ensure positioning accuracy and algorithm stability: Initialize input parameters: Obtain the radius of the steel pipe and multiple parameter arrays. The radius of the steel pipe can be the nominal radius (determined by the steel pipe manufacturing specifications) or an approximate radius obtained from previous measurements, serving as a fixed prior parameter in the fitting process. Each parameter array is a combination of unknown parameters to be optimized, specifically including two core parameters: one is the coordinates of the pipe end center in the world coordinate system. Secondly, the distance from the edge of the tube end to the corresponding camera optical center (i.e., the distance in the third coordinate transformation equation). Since the tube end edge is circular, the distance from different edge points on the same tube end to the camera's optical center is approximately equal, so it can be included in the array as a unified parameter. The purpose of setting multiple parameter arrays is to cover the possible position range of the tube end center. To ensure the reasonable range of values for the parameter array, it is important to avoid a single initial parameter from getting stuck in a local optimum. Common initialization methods include uniform sampling or random sampling to ensure the reasonable distribution of the parameter array.
[0081] Constructing the first fitting equation: Substitute each parameter array into the coordinate mapping equation to obtain the first fitting equation. Since the coordinate mapping equation includes the pipe end center coordinates... and For unknown parameters, after substituting the specific values from the parameter array, the coordinate mapping equation is transformed into one that uses only the pixel coordinates of the tube edge. Input as a circular equation, output as a circular equation ( The first fitting equation is the output. At this point, the core function of the first fitting equation is to establish the mapping relationship between the "preset parameter array" and the "edge pixel coordinates". Its output can directly reflect the degree of deviation between the preset parameters and the actual situation.
[0082] Fitting bias calculation: For each first fitting equation, the coordinates of all tube end pixels in the first tube end edge map and the second tube end edge map are calculated. Substituting each value into the first fitting equation yields multiple output results. Then, the fitting deviation of the corresponding parameter array is calculated based on these output results. The fitting deviation is the core indicator for quantifying the degree of matching between the preset parameter array and the actual pipe end features. The smaller the deviation, the closer the current parameter array is to the true value; conversely, the larger the deviation, the more adjustments are needed.
[0083] Iteration Judgment and Parameter Adjustment: The system determines whether the current iteration count has reached the preset iteration threshold (this threshold can be set based on a balance between accuracy requirements and computational efficiency, e.g., 50-200 iterations). If the preset iteration count has not been reached, feedback adjustments are made to multiple parameter arrays based on their fitting deviations. The adjustment logic is "deviation-oriented optimization," meaning that parameter arrays with smaller fitting deviations undergo local fine-sampling (reducing the parameter adjustment step size), while parameter arrays with larger fitting deviations are eliminated or significantly adjusted (guiding parameters towards regions with smaller deviations). Common adjustment algorithms include gradient descent and particle swarm optimization, ensuring that the parameter arrays gradually converge towards the true values. After parameter adjustment is complete, the system jumps to the parameter substitution step to begin the next round of fitting calculation.
[0084] Determine the target parameters and pipe end center position: If the current iteration count has reached a preset threshold, terminate the iteration process and select the parameter array with the smallest fitting deviation from all parameter arrays. This parameter array will be used as the target parameter array. Since the target parameter array is the parameter combination with the smallest fitting deviation, it contains the pipe end center coordinates. This is the final position of the center of the steel pipe end obtained by fitting, which can be directly used as the core input parameter for subsequent pipe end inspection tasks.
[0085] In some more specific embodiments, the step of determining the fitting deviation of the parameter array based on multiple outputs of the first fitting equation uses the mean squared error (MSE) as a deviation quantification index and calculates it precisely using a second formula, as detailed below: The fitting deviation of the parameter array is determined based on the second formula and multiple outputs of the first fitting equation, wherein the second formula is the formula for calculating the mean squared error, and its specific expression is as follows:
[0086] In the formula, For fitting bias, The first fitting equation is the th One output, This represents the total number of tube-end pixels in the first tube-end edge map and the second tube-end edge map.
[0087] The detailed definitions and physical meanings of each parameter in the formula are as follows: Fitting bias characterizes the degree of matching between the first fitting equation corresponding to the current parameter array and the actual pipe edge features. The smaller the value, the better the preset parameters match the actual situation. The unit is the square of the pixel gray value (due to...). It is calculated from pixel coordinates, and its unit is related to the pixel grayscale value.
[0088] The nth output of the first fitting equation, i.e., the calculation result obtained by substituting the coordinates of the nth pipe end edge pixel into the first fitting equation. Ideally, if the parameter array perfectly matches the actual pipe end center coordinates, all All should approach 0 (to satisfy the constraints of the circular equation); in actual calculations, The larger the absolute value, the greater the fitting deviation for that pixel.
[0089] The total number of edge pixels in the first and second pipe-end edge maps represents the total number of edge pixels involved in the fitting process. Selecting all edge pixels for bias calculation aims to comprehensively reflect the overall fitting effect and avoid interference from individual outlier pixels in bias judgment. The value of is determined by the resolution of the edge map and the size of the tube end profile, and is usually from hundreds to thousands of pixels.
[0090] (n=1 to N): Summation operator, used to sum all edge pixels. The squared values are summed to obtain the total deviation; then the average deviation is obtained by dividing by N. Compared to the total deviation, the average deviation more objectively reflects the average fitting level of a single pixel, making it easier to compare the deviations between different parameter arrays (unaffected by the number of pixels N).
[0091] It should be further explained that the core advantage of using mean squared error as a fitting deviation index is that it is effective for larger fitting deviations. First, pixels with larger fitting deviations are penalized more severely, effectively preventing parameter arrays that deviate significantly from the true contour from being misclassified as the optimal solution. Second, the mean squared error function is continuously differentiable (if gradient descent is used to adjust parameters), making it easy to quickly find the direction of parameter adjustment through differentiation, thus improving the efficiency of iterative optimization. Furthermore, in the actual fitting process, edge pixels can be preprocessed (e.g., removing noise pixels with excessively low grayscale values) to further improve the accuracy of fitting deviation calculation and ensure the precision of the final tube end center positioning.
[0092] The present invention discloses a method for determining the position of a steel pipe end. First, it acquires a first and a second image of the steel pipe end, both captured by a binocular imaging device. Then, it processes these images by performing convolution and non-maximum suppression on the pixels to obtain a first and a second edge map of the pipe end. Next, it constructs a coordinate mapping equation from the world coordinates of the pipe end edge to the pixel coordinates based on an intrinsic parameter matrix, a first extrinsic parameter matrix, and a second extrinsic parameter matrix. The intrinsic parameter matrix describes the relationship between image coordinates and camera coordinates, while the extrinsic parameter matrix describes the relationship between the camera coordinate system and the world coordinate system. The first and second extrinsic parameter matrices correspond to the two eyes of the imaging device, respectively. Finally, it fits the coordinate mapping equation to the first and second edge maps of the pipe end to obtain the position of the center of the steel pipe end. This method requires no manual intervention throughout the entire process, forming a complete technical chain from image acquisition and edge extraction to center localization. It can replace the cumbersome operations of traditional manual measurement or single-vision inspection, reducing human error, adapting to industrial batch inspection scenarios, and lowering inspection costs.
[0093] Compared with existing technologies, the steel pipe end image edge extraction and center localization scheme of this invention is as follows: Improving the accuracy of image acquisition and edge extraction: Images are acquired using a binocular imaging device, which can supplement three-dimensional spatial information by leveraging the parallax principle, reducing the interference of shooting angle distortion and lighting changes on the features of the tube end, and providing high-quality raw data for subsequent processing; through the combination strategy of "convolution + maximum suppression", combined with the noise suppression advantage of the Sobel operator and gradient quantization optimization, single-pixel-level accurate extraction of tube end edges is achieved, effectively separating the edges from the background and avoiding edge omission or redundancy.
[0094] Ensuring the reliability and universality of coordinate mapping: The coordinate mapping equation construction process integrates the physical meaning of intrinsic and extrinsic parameter matrices with the geometric constraints of the pipe end circle, fully connecting the transformation link of "world coordinates → camera coordinates → pixel coordinates", clarifying the quantitative relationship of each parameter, and adapting to pipe end inspection scenarios of steel pipes of different specifications, reducing mapping errors caused by missing parameters or logical breaks.
[0095] Achieving high precision and stability in pipe end center positioning: A fitting strategy of "iterative optimization + mean square error feedback" is adopted. By initializing a multi-parameter array to cover a reasonable range of values, the single parameter is avoided from getting stuck in a local optimum. The mean square error has a strong penalty for pixels with large deviations. Combined with the iterative parameter adjustment mechanism, it can gradually approach the true pipe end center coordinates. The positioning accuracy directly ensures the reliability of subsequent industrial applications such as steel pipe assembly and dimensional verification.
[0096] Improve the efficiency and automation level of industrial inspection: The entire process requires no manual intervention. It forms a complete technical link from image acquisition and edge extraction to center positioning. It can replace the cumbersome operation of traditional manual measurement or single vision inspection, reduce human error, adapt to industrial batch inspection scenarios, and reduce inspection costs.
[0097] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0098] The following are embodiments of the apparatus of the present invention. For details not described in detail, please refer to the corresponding method embodiments described above.
[0099] Figure 2 This is a functional block diagram of the steel pipe end position determination device provided in the embodiments of the present invention, with reference to... Figure 2 The pipe end position determination device includes: a binocular image acquisition module 201, an image edge extraction module 202, a coordinate mapping equation construction module 203, and a pipe end center positioning module 204, wherein: The binocular image acquisition module 201 is used to acquire a first pipe end image and a second pipe end image of the steel pipe, wherein the first pipe end image and the second pipe end image are acquired based on the binocular imaging device. The image edge extraction module 202 is used to process the first tube end image and the second tube end image by performing convolution and non-maximum suppression on the pixels to obtain the first tube end edge map and the second tube end edge map. The coordinate mapping equation construction module 203 is used to construct a coordinate mapping equation for mapping the world coordinates of the tube edge to the pixel coordinates based on the intrinsic parameter matrix, the first extrinsic parameter matrix, and the second extrinsic parameter matrix. The intrinsic parameter matrix describes the relationship between the image coordinates and the camera coordinates, and the extrinsic parameter matrix describes the relationship between the camera coordinate system and the world coordinate system. The first extrinsic parameter matrix and the second extrinsic parameter matrix correspond to the two targets of the shooting device, respectively. The pipe end center positioning module 204 is used to fit the coordinate mapping equation according to the first pipe end edge map and the second pipe end edge map to obtain the position of the center of the steel pipe end.
[0100] Figure 3 This is a functional block diagram of the electronic device provided in an embodiment of the present invention. For example... Figure 3As shown, the electronic device 3 of this embodiment includes a processor 300 and a memory 301, wherein the memory 301 stores a computer program 302 that can run on the processor 300. When the processor 300 executes the computer program 302, it implements the steps of the various steel pipe end position determination methods and embodiments described above, for example... Figure 1 Steps 101 to 104 are shown.
[0101] For example, the computer program 302 may be divided into one or more modules / units, which are stored in the memory 301 and executed by the processor 300 to complete the present invention.
[0102] The electronic device 3 can be a desktop computer, laptop, handheld computer, cloud server, or other computing device. The electronic device 3 may include, but is not limited to, a processor 300 and a memory 301. Those skilled in the art will understand that... Figure 3 This is merely an example of electronic device 3 and does not constitute a limitation on electronic device 3. It may include more or fewer components than shown, or combine certain components, or different components. For example, electronic device 3 may also include input / output devices, network access devices, buses, etc.
[0103] The processor 300 may be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor.
[0104] The memory 301 can be an internal storage unit of the electronic device 3, such as a hard disk or memory. The memory 301 can also be an external storage device of the electronic device 3, such as a plug-in hard disk, SmartMediaCard (SMC), SecureDigital (SD) card, or FlashCard. Furthermore, the memory 301 can include both internal and external storage units of the electronic device 3. The memory 301 is used to store the computer program 302 and other programs and data required by the electronic device 3. The memory 301 can also be used to temporarily store data that has been output or will be output.
[0105] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the aforementioned method embodiments, and will not be repeated here.
[0106] In the above embodiments, the descriptions of each embodiment have their own emphasis. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0107] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.
[0108] In the embodiments provided by this invention, it should be understood that the disclosed devices / electronic devices and methods can be implemented in other ways. For example, the device / electronic device embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0109] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment, depending on actual needs.
[0110] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0111] If the integrated module / unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the above-described embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various methods and apparatus embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a portable hard drive, a magnetic disk, an optical disk, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium, etc.
[0112] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit them. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.
Claims
1. A method for determining the position of a steel pipe end, characterized in that, include: A first pipe end image and a second pipe end image of the steel pipe are acquired, wherein the first pipe end image and the second pipe end image are acquired based on a binocular imaging device; The first tube end image and the second tube end image are processed by convolution and non-maximum suppression of pixels to obtain the first tube end edge map and the second tube end edge map. Based on the intrinsic parameter matrix, the first extrinsic parameter matrix, and the second extrinsic parameter matrix, a coordinate mapping equation is constructed for mapping the world coordinates of the tube edge to the pixel coordinates. The intrinsic parameter matrix describes the relationship between the image coordinates and the camera coordinates, and the extrinsic parameter matrix describes the relationship between the camera coordinate system and the world coordinate system. The first extrinsic parameter matrix and the second extrinsic parameter matrix correspond to the two targets of the shooting device, respectively. The coordinate mapping equation is fitted based on the first pipe end edge map and the second pipe end edge map to obtain the position of the center of the steel pipe end.
2. The method for determining the position of the steel pipe end according to claim 1, characterized in that, The process of processing the first tube-end image and the second tube-end image by performing convolution and non-maximum suppression on pixels to obtain the first tube-end edge map and the second tube-end edge map includes: For each pipe end image in the first pipe end image and the second pipe end image, perform the following steps respectively: Obtain the horizontal difference operator and the vertical difference operator; The tube end image is convolved using the horizontal difference operator and the vertical difference operator respectively to obtain a horizontal difference image and a vertical difference image; Based on the horizontal difference map and the vertical difference map, a gradient map representing the pixel gradient values and gradient directions of the image is constructed; For each pixel in the gradient map, find the pixels in the gradient direction and the opposite direction of the gradient in the neighborhood as the first neighboring pixels, and retain the pixel value or set the pixel value to 0 depending on whether the pixel is greater than all the first neighboring pixels. The gradient map, which has undergone pixel value processing based on the first neighboring pixels, is used as the edge map at the tube end.
3. The method for determining the position of the steel pipe end according to claim 2, characterized in that, The step of constructing a gradient map representing the gradient values and gradient directions of image pixels based on the horizontal difference map and the vertical difference map includes: For each pixel, the pixel gradient value and pixel gradient direction are extracted according to the first formula, the horizontal difference map, and the vertical difference map, and the obtained pixel gradient value and pixel gradient direction are added to the gradient map. The first formula is: In the formula, The pixel gradient value. For pixel gradient direction, This represents the pixel value in the vertical difference image. This represents the pixel value in the horizontal difference map. This is a rounding function. Pi It is the arctangent function.
4. The method for determining the position of the steel pipe end according to claim 1, characterized in that, The construction of the coordinate mapping equation from the pipe edge world coordinates to pixel coordinates based on the intrinsic parameter matrix, the first extrinsic parameter matrix, and the second extrinsic parameter matrix includes: Construct a circular equation in a three-dimensional coordinate system with the center of the pipe end as the reference. Based on the first extrinsic matrix and the second extrinsic matrix, a first coordinate transformation equation and a second coordinate transformation equation are constructed to convert world coordinates into camera coordinates, wherein the first coordinate transformation equation and the second coordinate transformation equation correspond to the two targets of the shooting device, respectively. Based on the intrinsic parameter matrix, a third coordinate transformation equation is constructed to convert camera coordinates into pixel coordinates; By combining the circular equation, the first coordinate transformation equation, the second coordinate transformation equation, and the third coordinate transformation equation, the coordinate mapping equation is obtained.
5. The method for determining the position of the steel pipe end according to claim 4, characterized in that, The equation of the circle is: In the formula, The world coordinates of the pipe end edge, The coordinates of the pipe end center are Where is the radius of the steel pipe. This is the output of the circular equation; The first and second extrinsic parameter matrices respectively include a rotation matrix describing the rotation relationship from the world coordinate system to the camera coordinate system and a translation vector describing the coordinates of the origin of the world coordinate system in the camera coordinate system. The first coordinate transformation equation or the second coordinate transformation equation is: In the formula, For camera coordinates, This is the rotation matrix of either the first or second extrinsic parameter matrix. It is the translation vector of the first extrinsic parameter matrix or the translation vector of the second extrinsic parameter matrix; The third coordinate transformation equation is: In the formula, For pixel coordinates, The distance from the edge of the tube to the optical center of the camera. This is the intrinsic parameter matrix.
6. The method for determining the position of the steel pipe end according to any one of claims 1-5, characterized in that, The step of fitting the coordinate mapping equation based on the first pipe end edge map and the second pipe end edge map to obtain the position of the center of the steel pipe end includes: Obtain the radius of the steel pipe and multiple parameter arrays, where each parameter array includes the coordinates of the pipe end center and the distance from the edge of the pipe end to the optical center of the camera; Substitute each parameter array into the coordinate mapping equation to obtain the first fitting equation; For each first fitting equation, the coordinates of the tube end pixels in the first tube end edge map and the second tube end edge map are substituted into the first fitting equation, and the fitting deviation of the parameter array is determined based on the multiple outputs of the first fitting equation. If the preset number of iterations is not reached, the multiple parameter arrays are adjusted according to multiple fitting deviations, and the process jumps to the step of substituting each parameter array into the coordinate mapping equation to obtain the first fitting equation. Otherwise, the parameter array with the smallest fitting deviation is taken as the target parameter array, and the position of the pipe end center is determined based on the target parameter array.
7. The method for determining the position of the steel pipe end according to claim 6, characterized in that, The multiple outputs of the first fitting equation determine the fitting bias of the parameter array, including: The fitting bias of the parameter array is determined based on the second formula and multiple outputs of the first fitting equation, wherein the second formula is: In the formula, For fitting bias, The first fitting equation is the th One output, This represents the total number of tube-end pixels in the first tube-end edge map and the second tube-end edge map.
8. A device for determining the position of a steel pipe end, characterized in that, For implementing the method for determining the position of a steel pipe end as described in any one of claims 1-7, the device for determining the position of a steel pipe end includes: A binocular image acquisition module is used to acquire a first pipe end image and a second pipe end image of the steel pipe, wherein the first pipe end image and the second pipe end image are acquired based on a binocular imaging device; The image edge extraction module is used to process the first tube end image and the second tube end image by performing convolution and non-maximum suppression on the pixels to obtain the first tube end edge map and the second tube end edge map; The coordinate mapping equation construction module is used to construct a coordinate mapping equation for mapping the world coordinates of the tube edge to the pixel coordinates based on the intrinsic parameter matrix, the first extrinsic parameter matrix, and the second extrinsic parameter matrix. The intrinsic parameter matrix describes the relationship between the image coordinates and the camera coordinates, and the extrinsic parameter matrix describes the relationship between the camera coordinate system and the world coordinate system. The first extrinsic parameter matrix and the second extrinsic parameter matrix correspond to the two targets of the shooting device, respectively. as well as, The pipe end center positioning module is used to fit the coordinate mapping equation according to the first pipe end edge map and the second pipe end edge map to obtain the position of the center of the steel pipe end.
9. An electronic device comprising a memory and a processor, wherein the memory stores a computer program executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method as described in any one of claims 1 to 7 above.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method as described in any one of claims 1 to 7 above.