Industrial target recognition and accurate positioning method based on improved Hough algorithm
Patent Information
- Application Number
- CN202610481844.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-04-13
- Publication Date
- 2026-10-20
- Estimated Expiration
- 2046-04-13
AI Technical Summary
然而,实际应用中常常遇到各种挑战,特别是当视觉系统面对工件边界被遮挡或缺失的情况时,会导致定位准确性下降
通过改进Canny边缘检测算法,获取目标的边界特征,通过改进的Hough直线检测算法,识别出检测目标的边界线,并拓扑出缺失的边界信息,计算出缺失的边界线交点和检测目标中心点位置。本发明的识别方法能够更精确、有效地检测目标边界的特征,并准确地拓扑出缺失边界特征,进而实现检测目标的精准定位。这种方法在工件分析和检测过程中具有重要的应用前景,特别是在需要精确定位和拓扑关系分析的应用场景中。
Smart Images

Figure CN122347577B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of industrial system information technology, specifically to an industrial target recognition and precise positioning method based on an improved Hough algorithm. Background Technology
[0002] With the rapid development of technology, robotics, automatic control, and intelligent technologies have been widely applied in industrial production. Machine vision, as a key technology, has been widely used for workpiece identification and positioning, guiding robots to perform tasks such as grinding, welding, and handling. However, various challenges are often encountered in practical applications, especially when the vision system faces situations where the workpiece boundary is occluded or missing, leading to a decrease in positioning accuracy.
[0003] Therefore, in view of the above situation, there is an urgent need to provide an industrial target recognition and precise positioning method based on the improved Hough algorithm to overcome the shortcomings in current practical applications. Summary of the Invention
[0004] The purpose of this invention is to provide an industrial target recognition and precise positioning method based on an improved Hough algorithm, aiming to solve the problems in the background art mentioned above.
[0005] This invention is implemented as follows: an industrial target identification and precise positioning method based on an improved Hough algorithm, which includes the following steps: Step 1: Adjust the parameters of the industrial camera to obtain clear image data of the workpiece, and preprocess the image data; Step 2: Perform edge detection on the preprocessed image based on morphological processing algorithms and Canny edge detection algorithms to obtain edge information and determine whether there are missing edges; Step 3: For cases with missing edges, target recognition and localization are performed based on the improved Hough algorithm or template matching algorithm to obtain the center point coordinates of the target object.
[0006] As a further aspect of the present invention: in step 1, the parameters of the industrial camera include exposure value, contrast, image gain, focal length, and aperture.
[0007] As a further aspect of the present invention: in step 1, the preprocessing includes spatial domain denoising and image sharpening.
[0008] As a further aspect of the present invention: in step 2, the specific steps of edge detection are as follows: Gaussian filtering smooths images by applying weights to a Gaussian function, reducing noise and detail while preserving boundary features. The Gaussian function is:
[0009] In the formula: Let be the standard deviation of the Gaussian function. Represents the Gaussian function at coordinate points The weight value at that location, and It is the coordinate offset of the current pixel relative to the center of the Gaussian kernel, which controls the intensity and range of the filter's smoothing process on the image. The formula for the convolution of a Gaussian function with the target image is:
[0010] In the formula: The image after convolution processing; The input image is shown; * represents a convolution operation.
[0011] As a further aspect of the present invention: in step 2, the edge detection further includes: For a grayscale image input to an image processing algorithm, a 3x3 matrix is used to smoothly shift the image, and the median of the pixel grayscale values in the matrix is used as an adaptive threshold. , In the formula, Indicates the current pixel. Represented by pixels Centered Spatial neighborhood, output value for calculating edge point positions: In the formula: Represents pixels The edge states are represented by 0 for non-edge background and 1 for strong edge points. For undetermined points that require neighborhood determination, where and For pixel coordinates, It is the gradient magnitude calculated using the Sobel operator. It is an adaptive threshold.
[0012] As a further aspect of the present invention: In step 2, the morphological processing includes dilation, erosion, opening operation, and closing operation, and the opening operation formula is: In the formula, The region of the image to be processed. To process structural elements, For image A subset of the decomposition, representing Depend on It consists of connected regions or pixels. structural element A subset of the decomposition, representing Depend on It consists of several basic units. To make the image Translation vector The set after, for Image regions and structural elements Elements in the intersection These are candidate points in the corrosion results. structural element The symmetric set, For a symmetric set Translate to point The set after, structural element Translate to point The morphological opening operation for image processing involves first performing an erosion operation, then using the same processing structuring element to perform Minkowski addition to remove noise points while preserving the original boundary feature points.
[0013] As a further aspect of the present invention: in step 2, the edge information extraction step is as follows: An adaptive thresholding binarization operation is performed on the preprocessed image to highlight features, and then Gaussian filtering, erosion, dilation and gradient detection are used to extract edge contours.
[0014] As a further aspect of the present invention: In step 3, the improved Hough algorithm is used for edge-missing scenarios, and the Hough transformation converts a straight line in a Cartesian coordinate system into a polar coordinate representation. in It is the distance from the straight line to the origin of the coordinate system. Is with A positive angle is used to detect a straight line through the intersection of polar coordinate curves. The ordinate is the y-coordinate of the point on the edge that is closest to the origin.
[0015] As a further aspect of the present invention: In step 3, the improved Hough algorithm includes the following sub-steps: Step 3.1: Perform Hough edge detection on the target image to identify topologically missing edges; Using the Hough line detection algorithm, the edge lines of the target image are detected. The equations of the four edge lines are:
[0016] Step 3.2: Calculate the intersection points of the multiple edges obtained from the detection, and identify intersection points with missing topological values; The positional relationship of each line can be determined from the relationship between the slopes of its sides. Error compensation is then introduced to determine the equality of slopes:
[0017] In the formula: Let be the slope of either side. Let be the slope of the remaining sides. For error compensation, when When determining if two sides intersect, the missing intersection points in the image are identified using the straight line extension characteristics detected by Hough. The intersection points of the two intersecting sides are then calculated using the following formula, resulting in four intersection points:
[0018] Equation ① is the linear expression for the line containing any of the edges, and Equation ② is the linear expression for the lines containing the remaining edges; where: Let be the slope of either side. Let be the slope of the remaining sides. The intersection of the two sides The line containing any edge and The ordinate of the intersection point of the axes; Step 3.3: Fit the opposite side line using the obtained vertex; Step 3.3: Fit the opposite side line using the obtained vertices; Identify the opposite vertex, fit a straight line to the opposite side, and calculate the four vertices in the image. A(x 1 ,y 1 ) , B(x 2 ,y 2 ) , C (x 3 ,y 3 ) , D(x 4 ,y 4 ), The following line segments are obtained: A Point and C Line segments composed of points L 5 ,as well as B Point and D Line segments composed of points L 6 The calculation formula is:
[0019] Step 3.4: Fit the intersection points of opposite straight lines; Set the intersection point as E(x 5 ,y 5 ), The calculation formula is:
[0020] Step 3.5: Construct a reference line and calculate the rotation angle; Set a reference line based on the material picking reference position. The slope of the straight line is The length of the side is determined by calculating the distance between each vertex, and the longer side is then... With reference line Calculate the included angle, longer side The slope is ,straight line , The included angle The calculation formula is: .
[0021] As a further aspect of the present invention, it also includes a hand-eye calibration step, which converts image coordinates into robot motion coordinates and guides the robot to perform operations through data communication.
[0022] Compared with the prior art, the beneficial effects of the present invention are as follows: By improving the Canny edge detection algorithm, the boundary features of the target are obtained. An improved Hough line detection algorithm is then used to identify the boundary lines of the target, and missing boundary information is topologically extracted. The intersection points of the missing boundary lines and the center point of the target are calculated. This invention's identification method can more accurately and effectively detect the features of the target boundary and accurately topologically extract missing boundary features, thereby achieving precise target positioning. This method has significant application prospects in workpiece analysis and inspection, especially in application scenarios requiring precise positioning and topological relationship analysis. Attached Figure Description
[0023] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0024] Figure 1 This is the overall flowchart of the present invention.
[0025] Figure 2 A diagram showing the composition of an experimental platform for the industrial target recognition and precise positioning method based on the improved Hough algorithm provided by this invention.
[0026] Figure 3 This is a flowchart of the Hough detection process in this invention.
[0027] Figure 4 This is a schematic diagram of the improved Canny edge detection process in this invention. Detailed Implementation
[0028] The technical solution of the present invention will now be clearly and completely described with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0029] The present invention will be further explained below with reference to specific embodiments.
[0030] The purpose of this invention is to acquire image stream data of a workpiece using an industrial camera, and to preprocess the image data by denoising and enhancement; to perform edge detection on the preprocessed image data based on morphological processing algorithms and Canny edge detection algorithms and to obtain the edge information of the image, and to determine whether there are missing edges in the image information; and to identify and locate the target based on an improved Hough algorithm or template matching algorithm for the missing edge situation, and finally obtain the center point coordinates of the target object.
[0031] Please see Figures 1-4 The present invention provides an industrial target identification and precise positioning method based on an improved Hough algorithm. Step 1: Adjust the parameters of the industrial camera (exposure value, contrast, image gain, focal length, aperture) to obtain clear and feature-rich image stream data of the workpiece, and perform preprocessing such as spatial domain denoising and image sharpening on the image data to reduce noise and enhance image quality, thereby reducing the difficulty of subsequent processing.
[0032] Step 2: Based on morphological processing algorithms and the Canny edge detection algorithm, perform edge detection on the preprocessed image data and obtain the edge information of the image to determine whether there are missing edges. The Canny detection process is as follows: Figure 4 ; Figure 4 This is a schematic diagram of the passport case edge detection process based on the improved Canny algorithm. The specific process is as follows: ① Physically adjust the camera to obtain a clear and bright image; ② The obtained image is preprocessed, including spatial denoising (median filtering) and image enhancement, to reduce or eliminate random noise in the image and improve image quality; ③ Adaptive threshold binarization is performed on the filtered image to enhance image interpretation and recognition performance; ④ Use the Gaussian filtering algorithm to denoise the image; ⑤ Perform gradient detection, use the Sober algorithm to calculate the gradient magnitude and direction of the image, and perform non-maximum suppression to accurately locate the edges and obtain the final edge image.
[0033] Step 3: For cases with missing edges, target identification and localization are performed based on the improved Hough algorithm or template matching algorithm to finally obtain the center point coordinates of the target object. The Hough detection process is as follows: Figure 3 .
[0034] Figure 3 This is a flowchart of the passport case location process. For cases with missing edges, target identification and localization are performed based on an improved Hough algorithm or template matching algorithm to ultimately obtain the center point coordinates of the target object. The specific process is as follows: For cases where the target outline is missing: ① Use the Hough transform method to detect straight lines and repair the missing edges of the target in the original image; ② Perform polygon detection, calculate the polygon intersection points for the detected polygon lines, and fill in the missing intersection points; ③ Calculate the intersection point of the two intersecting sides, and fit the opposite side line through the obtained vertex; ④ Calculate the coordinates of the center point and the rotation angle.
[0035] For cases where the target outline is complete: Use a template matching algorithm to obtain the center point coordinates and rotation angle.
[0036] A further approach involves step 2 using morphological processing algorithms and the Canny edge detection algorithm to perform edge detection on the preprocessed image data and obtain the image's edge information, including: Gaussian filtering smooths images by applying weights to a Gaussian function, reducing noise and detail while preserving boundary features as much as possible. The Gaussian function is:
[0037] In the formula: Let be the standard deviation of the Gaussian function. Represents the Gaussian function at coordinate points The weight value at each pixel, ranging from 0 to 1, determines the contribution of that pixel to the smoothing process. and It is the coordinate offset of the current pixel relative to the center of the Gaussian kernel (in pixels). This represents the natural exponential function. It controls the intensity and extent of the filter's smoothing effect on the image.
[0038] The formula for the convolution of a Gaussian function with the target image is:
[0039] In the formula: The image after convolution processing; The input image is shown; * represents a convolution operation.
[0040] A further approach involves step 2 using morphological processing algorithms and the Canny edge detection algorithm to perform edge detection on the preprocessed image data and obtain the image's edge information, including: For an m*n grayscale image input to the image processing algorithm, a 3*3 matrix is used to smoothly move the image, and the median of the pixel grayscale values in the matrix is used as an adaptive threshold. .
[0041]
[0042] The matrix smoothing bounding box performs a smoothing operation on the entire image. The pixel grayscale values within the matrix smoothing bounding box and the adaptive threshold change with the smoothing process. The adaptive threshold of the smoothing bounding box and the gradient value of the center pixel are used to calculate the output value at the edge position. The specific calculation is shown in the formula:
[0043] In the formula: Represents pixels The edge states are represented by 0 for non-edge background and 1 for strong edge points. For undetermined points that require neighborhood determination, where and For pixel coordinates, It is the gradient magnitude calculated by the Sobel operator, which quantifies the intensity of gray-scale abrupt changes. The larger the value, the more likely it is to be the workpiece boundary. It is an adaptive threshold, dynamically generated from the median grayscale value of 9 pixels within a 3×3 window, resisting uneven lighting and noise.
[0044] A further approach involves step 2 using morphological processing algorithms and the Canny edge detection algorithm to perform edge detection on the preprocessed image data and obtain the image's edge information, including: Morphological processing is a method of performing local operations on images using basic shape templates (structuring elements). These operations can include dilation, erosion, opening, and closing operations, which can enhance or weaken specific shapes and structures in an image, thereby helping to analyze and describe the feature information in the image.
[0045] In the formula, The region of the image to be processed. To process structural elements, For image Decomposition subsets ( i =1,2,…, n ),express Depend on It consists of connected regions or pixels. structural element The decomposition subset (j=1,2,…,m) represents Depend on It is composed of basic units (such as pixels). To make the image Translation vector The set after , for Image regions and structural elements Elements in the intersection These are candidate points in the corrosion results. structural element Symmetric set (rotated 180°: , For a symmetric set Translate to point The set after , structural element Translate to point The set after , For a symmetric set The elements in the image. Morphological opening operations process images by first performing an erosion operation, then using the same processing structuring element to perform Minkowski addition (dilation) to remove noise while preserving the original boundary feature points.
[0046] A further approach involves step 2 using morphological processing algorithms and the Canny edge detection algorithm to perform edge detection on the preprocessed image data and obtain the image's edge information, including: To effectively eliminate noise interference on contour edge details when extracting passport case morphology features, this paper employs a method combining morphological processing techniques and an improved Canny operator. First, adaptive threshold binarization is performed on the preprocessed image to highlight features. Second, Gaussian filtering, erosion, dilation, and gradient detection are used to extract the edge contours.
[0047] A further approach is to perform target identification and localization in step 3, based on an improved Hough algorithm or template matching algorithm, for cases with missing edges. The localization flowchart is as follows: Figure 3 As shown, the final coordinates of the center point of the target object are obtained, including: For cases where the target contour edges are missing, the Hough transform method is used for line detection. The Hough transform is a method for detecting lines in an image, converting the line representation from a Cartesian coordinate system to a polar coordinate system. In a Cartesian coordinate system, a line can be represented by the equation (…). f=kx+b The Hough transform represents the graph. In the Hough transform, each pixel is mapped to a sine curve in polar coordinates, and its parametric equation is: , in It is the distance from the straight line to the origin of the coordinate system. Is with The angle along the positive axis, This represents the ordinate of the point on the edge closest to the origin. When multiple pixels are collinear, this is represented in polar coordinates as multiple curves intersecting at a single point. By setting a threshold to filter these intersection points, the position and angle of the line in the original image can be determined. The advantage of this transformation lies in its fast detection speed and good robustness.
[0048] For cases where the target contour edges are not missing, template matching is used for identification and localization. Template matching is a common image processing technique used to find and locate the region in an image that is most similar to a predefined template. A small region is extracted from the target image as a template, and the template is slid across the target image, calculating the matching degree at each position. Common methods for calculating the matching degree include correlation coefficient and mean squared error. By comparing the matching degrees, the best matching position is found, that is, the region where the template and the target image are most similar.
[0049] A further approach is to perform target identification and localization in step 3, based on an improved Hough algorithm or template matching algorithm, to address edge-missing cases, ultimately obtaining the center point coordinates of the target object, including: A further approach is to perform Hough edge detection on the target image in step 3.1 to identify topologically missing edges.
[0050] Using the Hough line detection algorithm, the edge lines of the target image are detected. The equations of the four edge lines are:
[0051] A further solution is to calculate the intersection points of the detected multiple edges and the topological missing intersection points in step 3.2.
[0052] The positional relationship of each line can be determined from the relationship between its slopes. Since visual detection has inherent errors, error compensation is added when determining whether the slopes are equal, using the following formula:
[0053] In the formula: Let be the slope of either side. Let be the slope of the remaining sides. For error compensation. When When determining if two sides intersect, the missing intersection points in the image are identified using the straight line extension characteristics detected by Hough. The intersection points of the two intersecting sides are then calculated using the following formula, yielding four intersection points. The calculation formula is as follows:
[0054] Equation ① is the linear expression for the line containing any of the edges, and Equation ② is the linear expression for the lines containing the remaining edges; where: Let be the slope of either side. Let be the slope of the remaining sides. The intersection of the two sides The line containing any edge and The ordinate of the intersection of the axes.
[0055] A further approach is to, in step 3.3, fit the opposite side lines using the obtained vertices.
[0056] Identify the opposite vertex, fit a straight line to the opposite side, and calculate the four vertices in the image. A(x 1 ,y 1 ) , B(x 2 ,y 2 ) , C (x 3 ,y 3 ) , D(x 4 ,y 4 ) The following line segments are obtained: A Point and C Line segments composed of points L 5 ,and B Point and D Line segments composed of points L 6 The calculation formula is:
[0057] A further solution is to fit the intersection point of the opposite straight lines in step 3.4.
[0058] Set the intersection point as E : (x 5 ,y 5 ), The calculation formula is:
[0059] A further solution is step 3.5: construct a reference line and calculate the rotation angle; Set a reference line based on the material picking reference position. The slope of the straight line is The length of the side is determined by calculating the distance between each vertex, and the longer side is then... With reference line Calculate the included angle, longer side The slope is , straight line , The included angle The calculation formula is: .
[0060] In embodiments of this invention, image stream data of a workpiece is acquired using an industrial camera, and the image data undergoes preprocessing such as denoising and enhancement. Based on morphological processing algorithms and the Canny edge detection algorithm, edge detection is performed on the preprocessed image data to obtain edge information and determine whether there are missing edges. For cases of missing edges, target recognition and localization are performed based on an improved Hough algorithm or template matching algorithm, ultimately obtaining the center point coordinates of the target object. Based on hand-eye calibration, coordinate transformation is performed on the obtained coordinate parameters to obtain the robot's motion coordinates and facilitate data communication. This method can more accurately and effectively detect the features of the target boundary and accurately infer the situation of missing boundaries, thereby achieving precise positioning of the detected target.
[0061] The workflow of this invention is as follows: Adjust the parameters of the industrial camera (exposure value, contrast, image gain, focal length, aperture) to acquire clear, feature-rich image stream data of the workpiece. Perform preprocessing on the image data, including spatial domain denoising and image enhancement, to reduce noise and enhance image quality, thereby simplifying subsequent processing. The specific steps are as follows: Step 1: According to the performance requirements of the industrial camera, the mobile robot moves the industrial camera to a vertical position 600mm away from the workpiece. By monitoring the real-time image data stream, the camera's aperture and focal length parameters are physically adjusted. Aperture affects the brightness of the image, while focal length affects the image sharpness. Next, the camera settings are adjusted by monitoring the real-time image data stream. Contrast affects the image feature effect, while image gain and exposure value affect the image brightness.
[0062] Step 2: After acquiring a clear and bright image, preprocessing is performed. First, spatial domain denoising (median filtering) is used to eliminate noise through ranking statistics. The median value within a pixel's neighborhood is used as the new value for that pixel, thus eliminating isolated noise points while preserving edge information. This reduces or eliminates random noise, improving image quality. Next, image enhancement is performed. Spatial domain enhancement methods are used to manipulate image pixels. Image sharpening uses a high-pass filter to enhance edge information, improving image clarity. Finally, the image's grayscale histogram is adjusted to make the grayscale distribution more uniform, thereby improving contrast. This effectively enhances the image's visual effect and detail, improving image quality, enriching information, and strengthening image interpretation and recognition.
[0063] Based on morphological processing algorithms and Canny edge detection algorithms, edge detection is performed on the preprocessed image data to obtain the edge information of the image and determine whether there are missing edges in the image information. Step 3: Further denoising is performed on the image using a Gaussian filtering algorithm. Gaussian filtering smooths the image by applying weights to a Gaussian function, reducing noise and details while preserving boundary features as much as possible. The Gaussian function is:
[0064] In the formula: Let be the standard deviation of the Gaussian function. Represents the Gaussian function at coordinate points The weight value at each pixel, ranging from 0 to 1, determines the contribution of that pixel to the smoothing process. and It is the coordinate offset of the current pixel relative to the center of the Gaussian kernel (in pixels). This represents the natural exponential function. It controls the intensity and extent of the filter's smoothing effect on the image. The convolution formula between the Gaussian function and the target image is:
[0065] In the formula: The image after convolution processing; The input image is shown; "*" represents a convolution operation.
[0066] In step 2: Adaptive threshold binarization is performed on the filtered image to highlight the features of the target image and enhance the image interpretation and recognition effect. For the (m*n) grayscale image input to the image processing algorithm, a (3*3) matrix is used to smoothly move the image, and the average value of the pixel grayscale values of the matrix is used as the adaptive threshold. .
[0067] The matrix smoothing bounding box performs a smoothing operation on the entire image. The pixel grayscale values within the matrix smoothing bounding box and the adaptive threshold change with the smoothing process. The adaptive threshold of the smoothing bounding box and the gradient value of the center pixel are used to calculate the output value at the edge position. The specific calculation is shown in the formula:
[0068] In the formula: Represents pixels The edge states are defined as follows: 0 represents non-edge background, 1 represents a strong edge point, and p represents a point to be determined that requires neighborhood analysis. and These are pixel coordinates. It is the gradient magnitude calculated by the Sobel operator, which quantifies the intensity of gray-scale abrupt changes. The larger the value, the more likely it is to be the workpiece boundary. It is an adaptive threshold, dynamically generated from the median grayscale value of 9 pixels within a 3×3 window, resisting uneven lighting and noise.
[0069] In step 3: Morphological image processing is used to enhance the shape and structural features of the image. Morphological processing is a method of performing local operations on the image using basic shape templates (structural elements). These operations can include dilation, erosion, opening, and closing operations, which can enhance or weaken specific shapes and structures in the image, thereby helping to analyze and describe the feature information in the image.
[0070]
[0071] In the formula, The region of the image to be processed. To process structural elements, For image Decomposition subsets ( i =1,2,…, n ),express Depend on It consists of connected regions or pixels. structural element The decomposition subset (j=1,2,…,m) represents Depend on It is composed of basic units (such as pixels). To make the image Translation vector The set after , for Image regions and structural elements Elements in the intersection These are candidate points in the corrosion results. structural element Symmetric set (rotated 180°: , For a symmetric set Translate to point The set after , structural element Translate to point The set after , For a symmetric set The elements in the image. Morphological opening operations process images by first performing an erosion operation, then using the same processing structuring element to perform Minkowski addition (dilation) to remove noise while preserving the original boundary feature points.
[0072] Step 4: Perform gradient detection. Use the Sober algorithm to calculate the gradient magnitude and direction of the image. Perform non-maximum suppression (NVS) on the gradient magnitude image to accurately locate edges. NVS involves checking if each pixel is a local maximum in its gradient direction. If so, the pixel is retained as an edge point; otherwise, it is suppressed. Two thresholds (high and low) are applied for edge connection and detection. The high threshold identifies strong edges, and the low threshold identifies weak edges. Only when a weak edge connects to a strong edge is it retained as an edge. The final edge image is generated by connecting strong edges and weak edges connected to strong edges via the low threshold. Ensure the continuity and integrity of the edges.
[0073] Step 5: Train the image with complete outline to build a template, use the template matching algorithm to perform similarity matching on the outline of the real-time captured image, and classify whether it is a complete target image based on the matching score.
[0074] To determine if there are missing edges, target identification and localization are performed based on an improved Hough algorithm or template matching algorithm, and finally the center point coordinates of the target object are obtained. Step 1: Based on the judgment obtained from template matching, the target is identified and located for different images. If the detection result is a complete image, the angle and target center point coordinates are directly obtained by the template matching algorithm. If the detection result is an incomplete image, that is, the target outline in the image has missing corners or edges, the improved Hough transform algorithm is used to locate the target.
[0075] Step 2: If the target edge is incomplete, use the Hough transform to obtain the four edge lines of the target contour, including the missing edge lines and their included angles. Use the Hough line detection algorithm to detect the edge lines of the target image. The equations of the four edge lines are:
[0076] Step 3: Calculate the intersection points of the multiple edges obtained from the detection, and identify the intersection points with missing topological values.
[0077] The positional relationship of each line can be determined from the relationship between its slopes. Since visual detection has inherent errors, error compensation is added when determining whether the slopes are equal, using the following formula:
[0078] In the formula: Let be the slope of either side. Let be the slope of the remaining sides. For error compensation. When When determining if two sides intersect, the missing intersection points in the image are identified using the straight line extension characteristics detected by Hough. The intersection points of the two intersecting sides are then calculated using the following formula, yielding four intersection points. The calculation formula is as follows:
[0079] In the formula: Let be the slope of either side. Let be the slope of the remaining sides. The point where the two sides intersect.
[0080] Step 4: Fit the opposite side line using the obtained vertices: Identify the opposite vertex, fit a straight line to the opposite side, and calculate the four vertices in the image. A(x 1 ,y 1 ) , B(x 2 ,y 2 ) , C (x 3 ,y 3 ) , D(x 4 ,y 4 ) The following line segments are obtained: A Point and C Line segments composed of points L 5 ,as well as B Point and D Line segments composed of points L 6 The calculation formula is:
[0081] Step 5: Fit the intersection points of the opposite lines: Set the intersection point as E : (x 5 ,y 5), The calculation formula is:
[0082] Step Six: Construct a reference line and calculate the rotation angle: Set a reference line based on the material picking reference position. f 7 The slope of the straight line is k 7 The length of the side is determined by calculating the distance between each vertex, and the longer side is then... f 2 With reference line f 7 Calculate the included angle, longer side f 2 The slope is k 1 , straight line f 2 , f 7 The included angle The calculation formula is: .
[0083] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not 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 or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for industrial target recognition and precise positioning based on an improved Hough algorithm, characterized in that, The method includes the following steps: Step 1: Adjust the parameters of the industrial camera to obtain clear image data of the workpiece, and preprocess the image data; Step 2: Perform edge detection on the preprocessed image based on morphological processing algorithms and Canny edge detection algorithms to obtain edge information and determine whether there are missing edges; Step 3: For cases with missing edges, target recognition and localization are performed based on the improved Hough algorithm to obtain the center point coordinates of the target object; for cases with complete edges, the center point coordinates and rotation angle are obtained using a template matching algorithm. In step 3, the improved Hough algorithm includes the following sub-steps: Step 3.1: Perform Hough edge detection on the target image to identify topologically missing edges; Using the Hough line detection algorithm, the edge lines of the target image are detected. The equations of the four edge lines are: Step 3.2: Calculate the intersection points of the multiple edges obtained from the detection, and identify intersection points with missing topological values; The positional relationship of each line can be determined from the relationship between the slopes of its sides. Error compensation is then introduced to determine the equality of slopes. In the formula: Let be the slope of either side. Let be the slope of the remaining sides. For error compensation, when When determining if two sides intersect, the missing intersection points in the image are identified using the straight line extension characteristics detected by Hough. The intersection points of the two intersecting sides are then calculated using the following formula, resulting in four intersection points: Equation ① is the linear expression for the line containing any of the edges, and Equation ② is the linear expression for the lines containing the remaining edges; where: Let be the slope of either side. Let be the slope of the remaining sides. The intersection of the two sides Let any edge be the line containing the intersection with the line containing the edge. The ordinate of the intersection of the axes; Step 3.3: Fit the opposite side line using the obtained vertices; Identify the opposite vertex, fit a straight line to the opposite side, and calculate the four vertices in the image. The following line segments are obtained: Point and Line segments composed of points ,as well as Point and Line segments composed of points The calculation formula is: Step 3.4: Fit the intersection points of opposite straight lines; Set the intersection point as , The calculation formula is: Step 3.5: Construct a reference line and calculate the rotation angle; Set a reference line based on the material picking reference position. The slope of the straight line is The length of the side is determined by calculating the distance between each vertex, and the longer side is then... With reference line Calculate the included angle, longer side The slope is , straight line , The included angle The calculation formula is: 。 2. The industrial target identification and precise positioning method based on the improved Hough algorithm according to claim 1, characterized in that, In step 1, the parameters of the industrial camera include exposure value, contrast, image gain, focal length, and aperture.
3. The industrial target identification and precise positioning method based on the improved Hough algorithm according to claim 1, characterized in that, In step 1, the preprocessing includes spatial domain denoising and image sharpening.
4. The industrial target identification and precise positioning method based on the improved Hough algorithm according to claim 1, characterized in that, In step 2, the specific steps of edge detection are as follows: Gaussian filtering smooths images by applying weights to a Gaussian function, reducing noise and detail while preserving boundary features. The Gaussian function is: In the formula: Let be the standard deviation of the Gaussian function. Represents the Gaussian function at coordinate points The weight value at that location, and It represents the coordinate offset of the current pixel relative to the center of the Gaussian kernel; it controls the intensity and range of the filter's smoothing effect on the image. The formula for the convolution of a Gaussian function with the target image is: In the formula: The image after convolution processing; Input image; This represents the convolution operation.
5. The industrial target identification and precise positioning method based on the improved Hough algorithm according to claim 4, characterized in that, In step 2, the edge detection further includes: For grayscale images input into image processing algorithms, using The matrix is smoothly shifted across the image, and the median of the pixel grayscale values in the matrix is used as an adaptive threshold. , In the formula, Indicates the current pixel. Represented by pixels Centered Spatial neighborhood, output value for calculating edge point positions: In the formula: Represents pixels The edge states are represented by 0 for non-edge background and 1 for strong edge points. For undetermined points that require neighborhood determination, where and For pixel coordinates, It is the gradient magnitude calculated using the Sobel operator. It is an adaptive threshold.
6. The industrial target identification and precise positioning method based on the improved Hough algorithm according to claim 1, characterized in that, In step 2, morphological processing includes dilation, erosion, opening, and closing operations. The formula for the opening operation is: In the formula, The region of the image to be processed. To process structural elements, For image A subset of the decomposition, representing Depend on It consists of connected regions or pixels. structural element A subset of the decomposition, representing Depend on It consists of several basic units. To make the image Translation vector The set after, for Image regions and structural elements Elements in the intersection Candidate points in the corrosion results, structural element The symmetric set, symmetric set Translate to point The set after, structural element Translate to point The morphological opening operation for image processing involves first performing an erosion operation, then using the same processing structuring element to perform Minkowski addition to remove noise points while preserving the original boundary feature points.
7. The industrial target identification and precise positioning method based on the improved Hough algorithm according to claim 1, characterized in that, In step 2, the edge information extraction steps are as follows: An adaptive thresholding binarization operation is performed on the preprocessed image to highlight features, and then Gaussian filtering, erosion, dilation and gradient detection are used to extract edge contours.
8. The industrial target identification and precise positioning method based on the improved Hough algorithm according to claim 1, characterized in that, In step 3, the improved Hough algorithm is used for edge-missing scenarios. The Hough transform converts a straight line in Cartesian coordinates into polar coordinates: in It is the distance from the straight line to the origin of the coordinate system. Is with The angle along the positive axis is used to detect straight lines through the intersection of polar coordinate curves. The ordinate is the y-coordinate of the point on the edge that is closest to the origin.
9. The industrial target identification and precise positioning method based on the improved Hough algorithm according to claim 1, characterized in that, It also includes a hand-eye calibration step, which converts image coordinates into robot motion coordinates and guides the robot to perform operations through data communication.