Screw hole positioning method, device and equipment and storage medium
By performing feature enhancement and gradient feature extraction on the device casing image, and fitting the screw hole edge to be roughly circular, the problem of inaccurate screw hole positioning on electronic device casings is solved, and precise positioning is achieved.
Patent Information
- Application Number
- CN202411240164.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-04
- Publication Date
- 2025-01-14
AI Technical Summary
In the existing technology, there are problems with inaccurate positioning, incorrect drilling, and omission of screw holes in the casing of electronic devices, especially for screw holes of different models, shapes, and colors, which are difficult to accurately position.
By acquiring images of the device casing, performing feature enhancement processing, extracting gradient features, determining edge contour segments, and fitting a circular shape around the screw hole edge, the screw hole location information is obtained.
It enables precise positioning of screw holes of different models, shapes, and colors, improving the accuracy and reliability of screw hole positioning.
Smart Images

Figure CN119313729A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of image processing technology, and in particular to a screw hole positioning method, device, equipment and storage medium. Background Art
[0002] When screwing screws into the screw holes of electronic devices such as laptops, the factory usually uses a robot to locate the screw holes. This method has problems such as inaccurate positioning, wrong screwing, and missed screwing. In addition, the screw holes of electronic device casings have characteristics such as large color differences and different shapes. Therefore, how to achieve accurate positioning of screw holes for different models, shapes, and colors has become a technical problem that needs to be solved urgently. Summary of the invention
[0003] The present disclosure provides a screw hole positioning method, device, equipment and storage medium to at least solve the above technical problems existing in the prior art.
[0004] According to a first aspect of the present disclosure, a screw hole positioning method is provided, the method comprising:
[0005] Acquire an image to be processed, where the image to be processed is a shell image of a target device, and the shell of the target device includes screw holes;
[0006] Performing feature enhancement processing on the image to be processed to obtain an enhanced image;
[0007] Extracting gradient features of the enhanced image;
[0008] Determine a plurality of edge contour line segments in the enhanced image based on the gradient feature;
[0009] The screw hole edge quasi-circle is fitted based on a plurality of edge contour line segments to obtain the screw hole position information.
[0010] In one possible implementation manner, performing feature enhancement processing on the image to be processed to obtain an enhanced image includes:
[0011] Using multiple preset Gaussian filter kernels to perform denoising on the image to be processed to obtain a denoised image;
[0012] Grayscale enhancement processing is performed on the denoised image to obtain an enhanced image.
[0013] In one possible implementation manner, the determining a plurality of edge contour segments in the enhanced image based on the gradient feature comprises:
[0014] For each pixel in the enhanced image, determine, according to the gradient feature, whether the gradient amplitude of the pixel is greater than the gradient amplitude of the adjacent pixel in the specified gradient direction; if so, determine that the pixel is a target pixel; if not, set the pixel value of the pixel to 0;
[0015] A plurality of line segments formed by the target pixel points are determined as edge contour line segments, wherein adjacent pixel points in each edge contour line segment are adjacent target pixel points.
[0016] In one possible implementation, fitting the screw hole edge quasi-circle based on the plurality of edge contour line segments to obtain the screw hole position information includes:
[0017] Based on the length of each edge contour line segment, determining the number of target pixel points corresponding to each edge contour line segment;
[0018] Selecting pixel points corresponding to the target pixel points of each edge contour line segment in order to obtain a plurality of pixel points to be fitted;
[0019] Fitting the plurality of pixel points to be fitted to obtain a fitted quasi-circular shape;
[0020] The fitted quasi-circular shape is used as the quasi-circular shape of the screw hole edge;
[0021] The position information corresponding to the circle-like edge of the screw hole is determined as the screw hole position information.
[0022] In one possible implementation manner, fitting the plurality of pixel points to be fitted to obtain a fitted quasi-circle as a screw hole edge quasi-circle includes:
[0023] Fitting the multiple pixel points to be fitted;
[0024] If two fitted quasi-circles are obtained, determine whether the two fitted quasi-circles are in a completely nested relationship;
[0025] If yes, the fitted quasi-circle with the smaller area among the two fitted quasi-circles is determined as the screw hole edge quasi-circle;
[0026] If not, the fitted quasi-circle with the larger area among the two fitted quasi-circles is determined as the screw hole edge quasi-circle.
[0027] In one possible implementation manner, fitting the plurality of pixel points to be fitted to obtain a fitted quasi-circular shape includes:
[0028] Fitting the multiple pixel points to be fitted;
[0029] If at least three fitted quasi-circles are obtained, the fitted quasi-circles are sorted according to their radius, and the fitted quasi-circle with the smallest radius is used as the detection circle;
[0030] Calculating the intersection-over-union ratio between each fitted quasi-circle and the detection circle;
[0031] Determine the number of times each fitted quasi-circle is nested according to the intersection-union ratio;
[0032] Obtain the fitted quasi-circle with the largest number of nestings.
[0033] According to a second aspect of the present disclosure, a screw hole positioning device is provided, the device comprising:
[0034] An image acquisition module, used for acquiring an image to be processed, wherein the image to be processed is an image of a housing of a target device, and the housing of the target device includes screw holes;
[0035] An image enhancement module is used to perform feature enhancement processing on the image to be processed to obtain an enhanced image;
[0036] A gradient extraction module, used to extract the gradient features of the enhanced image;
[0037] A contour determination module, used for determining a plurality of edge contour segments in the enhanced image based on the gradient feature;
[0038] The positioning module is used to fit the edge circle of the screw hole based on the plurality of edge contour line segments to obtain the position information of the screw hole.
[0039] In one possible implementation manner, the image enhancement module is specifically used to perform denoising on the image to be processed using multiple preset Gaussian filter kernels to obtain a denoised image; and perform grayscale enhancement on the denoised image to obtain an enhanced image.
[0040] According to a third aspect of the present disclosure, there is provided an electronic device, including:
[0041] at least one processor; and
[0042] a memory communicatively connected to the at least one processor; wherein,
[0043] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method described in the present disclosure.
[0044] According to a fourth aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable a computer to execute the method described in the present disclosure.
[0045] The screw hole positioning method, device, equipment and storage medium disclosed in the present invention obtain an image to be processed, the image to be processed is an image of the shell of a target device, the shell of the target device includes screw holes, feature enhancement processing is performed on the image to be processed to obtain an enhanced image, the gradient features of the enhanced image are extracted, multiple edge contour line segments in the enhanced image are determined based on the gradient features, and the edge-like circles of the screw holes are fitted based on the multiple edge contour line segments to obtain the screw hole position information. That is, for images with characteristics such as uneven grayscale, low contrast and blurred edges, the edge contour line segments can be determined by the gradient features of the enhanced image, so that the gradient edge contour information of the image can be effectively extracted while retaining the contour geometric features to a large extent, and then the edge-like circles of the screw holes are determined based on the edge contour line segments to obtain the accurate screw hole positions. The screw hole positioning method disclosed in the present invention realizes the precise positioning of screw holes of different models, shapes and colors.
[0046] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] The above and other objects, features and advantages of the exemplary embodiments of the present disclosure will become readily understood by reading the detailed description below with reference to the accompanying drawings. In the accompanying drawings, several embodiments of the present disclosure are shown in an exemplary and non-limiting manner, in which:
[0048] In the drawings, the same or corresponding reference numerals represent the same or corresponding parts.
[0049] Figure 1 A schematic diagram of the implementation process of the screw hole positioning method provided by an embodiment of the present disclosure is shown;
[0050] Figure 2 An image to be processed provided by an embodiment of the present disclosure is shown;
[0051] Figure 3 A schematic diagram of a screw hole positioning method provided by an embodiment of the present disclosure is shown;
[0052] Figure 4 A schematic diagram of the structure of a screw hole positioning device provided in an embodiment of the present disclosure is shown;
[0053] Figure 5 A schematic diagram of the structure of an electronic device according to an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0054] In order to make the purpose, features, and advantages of the present disclosure more obvious and easy to understand, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present disclosure.
[0055] Since the current method of positioning screw holes by a factory robot has problems such as inaccurate positioning, wrong punching and missing punching, in order to achieve accurate positioning of screw holes, the present disclosure provides a screw hole positioning method, device, equipment and storage medium. The screw hole positioning method provided by the present disclosure can be applied to electronic devices such as mobile phones, computers and tablet computers.
[0056] The technical solution of the embodiment of the present disclosure will be described below in conjunction with the drawings in the embodiment of the present disclosure.
[0057] Figure 1 FIG. 1 shows a schematic diagram of the implementation process of the screw hole positioning method provided by the embodiment of the present disclosure, such as Figure 1 As shown, the method includes:
[0058] S101, obtaining an image to be processed, where the image to be processed is a housing image of a target device, and the housing of the target device includes screw holes.
[0059] In the present disclosure, the target device may be an electronic device such as a mobile phone, a computer, a tablet computer, and a laptop computer, or other mechanical devices having screw holes on the shell. The shell of the target device includes one or more screw holes. In the present disclosure, an image acquisition device such as a mobile phone camera or a video camera may be used to acquire an image of the shell of the target device. The acquired image of the shell of the target device may be an image of a part of the shell of the target device, or an image of the entire shell of the target device. The grayscale image of the acquired image of the shell of the target device may be used as the image to be processed. Figure 2 An image to be processed provided by an embodiment of the present disclosure is shown. Figure 2 As shown, Figure 2 An image of a portion of the C-side housing of the laptop computer is shown, and the image includes screw holes 201 of the laptop computer.
[0060] S102, performing feature enhancement processing on the image to be processed to obtain an enhanced image.
[0061] In the present disclosure, feature enhancement processing may include at least one of grayscale histogram equalization processing, noise removal processing, contrast enhancement processing and sharpening processing. In a possible implementation, performing feature enhancement processing on the image to be processed to obtain an enhanced image may include steps A1-A2:
[0062] Step A1, using multiple preset Gaussian filter kernels to perform denoising on the image to be processed to obtain a denoised image.
[0063] In the present disclosure, a Gaussian filter can be used to filter the image to be processed. The Gaussian filter can use different Gaussian filter kernels to filter the image to be processed respectively to obtain multiple filtered images corresponding to the image to be processed, and then the multiple filtered images can be superimposed to obtain a denoised image, wherein the superimposition of the multiple filtered images may include: accumulating the pixel values of the corresponding pixels of the multiple filtered images and then averaging them. Specifically, the Gaussian filter represented by the following formula can be used to filter the image to be processed:
[0064]
[0065] Wherein, G(x, y, σ) represents a Gaussian filter, x and y represent the horizontal and vertical coordinates of the pixel to be processed, and σ is a filtering parameter.
[0066] The Gaussian filter is used to filter the image to be processed, which can remove the Gaussian noise in the image to be processed while maintaining the details and contour features of the image.
[0067] Step A2, performing grayscale enhancement processing on the denoised image to obtain an enhanced image.
[0068] In the present disclosure, the denoised image can be sharpened to achieve grayscale enhancement. In a possible implementation, the denoised image can be sharpened by USM (image sharpening). Specifically, the area to be sharpened can be specified in the denoised image according to the actual application requirements, or the denoised image can be sharpened as a whole. By setting a pixel difference threshold, the pixels in the denoised image whose differences are greater than the pixel difference threshold can be sharpened. The pixel difference threshold can be set according to the actual application requirements and is not specifically limited here. For example, the denoised image can be sharpened using the formula Iusm=Isrc-w*IGauss / (1-w), where Iusm is the pixel value of the sharpened pixel, IGauss is the pixel value of the pixel in the denoised image, Isrc is the sharpening parameter, w represents the weight, and the range of w can be set between (0.1-0.99), and usually w takes a value of 0.56.
[0069] S103: extracting gradient features of the enhanced image.
[0070] In the present disclosure, an edge detection model or a feature analysis model may be used to extract the gradient features of the enhanced image. In a possible implementation, the Prewitt (edge detection algorithm) gradient edge extraction algorithm may be used to extract the gradient features of the enhanced image. Specifically, the gradient features of the enhanced image may be extracted based on the horizontal gradient kernel and the vertical gradient kernel calculated by the first-order gradient difference calculation method, wherein the horizontal gradient kernel G x for: Vertical gradient kernel G y for For each pixel (i, j) in the enhanced image, the horizontal gradient kernel G x and the vertical gradient kernel G y , use the following formula to calculate the horizontal gradient feature G corresponding to the pixel point (i, j) x (i, j) and vertical gradient feature G y (i,j):
[0071] G x (i,j)=-I(i-1,j-1)-I(i,j-1)-I(i+1,j-1)+I(i-1,j-1)
[0072] +I(i,j+1)+I(i+1,j+1)
[0073] G y (i,j)=-I(i-1,j-1)-I(i-1,j)-I(i-1,j+1)+I(i+1,j-1)
[0074] +I(i+1,j)+I(i+1,j+1)
[0075] S104: Determine a plurality of edge contour line segments in the enhanced image based on the gradient feature.
[0076] In the present disclosure, the edge extraction model can be trained by combining the gradient feature, and the trained edge extraction model can be used to enhance the multiple edge contour line segments in the image. Alternatively, an image segmentation algorithm can be used to set the image segmentation threshold in combination with the gradient feature, and the enhanced image can be divided into the foreground and the background, thereby extracting the multiple edge contour line segments in the enhanced image. Among them, the segmentation threshold can be set according to the gradient feature.
[0077] In a possible implementation manner, determining a plurality of edge contour segments in the enhanced image based on the gradient feature may include steps B1-B2:
[0078] Step B1, for each pixel in the enhanced image, determine whether the gradient amplitude of the pixel is greater than the gradient amplitude of the adjacent pixel in the specified gradient direction according to the gradient feature; if so, determine that the pixel is the target pixel; if not, set the pixel value of the pixel to 0.
[0079] In the present disclosure, the specified gradient direction can be the gradient direction of 0°, 45°, 90° and 135° of the pixel point. For each pixel point in the enhanced image, it can be calculated whether the gradient amplitude of the pixel point is greater than the gradient amplitude of the adjacent pixel points in all the specified gradient directions of the pixel point. If the gradient amplitude of the pixel point is greater than the gradient amplitude of the adjacent pixel points in all the specified gradient directions of the pixel point, it indicates that the pixel point is most likely a pixel point on the edge contour line segment, so the pixel point can be retained as the target pixel point. If the gradient amplitude of the pixel point does not meet the condition of being greater than the gradient amplitude of the adjacent pixel points in all the specified gradient directions of the pixel point, it indicates that the pixel point is not a pixel point on the edge contour line segment, and the pixel point can be not retained, and the pixel value of the pixel point is suppressed to 0.
[0080] Step B2: determining a plurality of line segments formed by the target pixel points as edge contour line segments, wherein adjacent pixel points in each edge contour line segment are adjacent target pixel points.
[0081] After obtaining multiple target pixel points, the line segment formed by the target pixel points on a straight line can be determined as an edge contour line segment, and the adjacent pixel points in each edge contour line segment are adjacent target pixel points. For example, target pixel point a1 is adjacent to target pixel point a2, target pixel point a2 is adjacent to target pixel point a3, target pixel point a3 is adjacent to target pixel point a4, target pixel point a4 is not adjacent to target pixel point a5, and target pixel point a4 is adjacent to target pixel point b4, wherein target pixel point a1, target pixel point a2, target pixel point a3, target pixel point a4 and target pixel point a5 are on a straight line, and target pixel point a1, target pixel point a2 and target pixel point a3 are not on a straight line with target pixel point b4. It can be seen that although the target pixel point a5 is on the same straight line as the target pixel point a1, the target pixel point a2, the target pixel point a3 and the target pixel point a4, the target pixel point a5 is not adjacent to the target pixel point a4; although the target pixel point b4 is adjacent to the target pixel point a4, the target pixel point b4 is not on the same straight line as the target pixel point a1, the target pixel point a2 and the target pixel point a3. Therefore, the line segment formed by the target pixel point a1, the target pixel point a2, the target pixel point a3 and the target pixel point a4 can be determined as an edge contour line segment.
[0082] S105, fitting a screw hole edge quasi-circle based on the plurality of edge contour line segments to obtain screw hole position information.
[0083] In the present disclosure, a quasi-circle refers to an image whose boundary or outline is similar to a circle but has a certain degree of deformation, such as an ellipse.
[0084] By adopting this method, an image to be processed is obtained, the image to be processed is an image of a shell of a target device, and the shell of the target device includes screw holes. Feature enhancement processing is performed on the image to be processed to obtain an enhanced image, and the gradient features of the enhanced image are extracted. Based on the gradient features, multiple edge contour segments in the enhanced image are determined, and the edge-like circles of the screw holes are fitted based on the multiple edge contour segments to obtain the position information of the screw holes. That is, for images with characteristics such as uneven grayscale, low contrast, and blurred edges, the edge contour segments can be determined by the gradient features of the enhanced image, so that the gradient edge contour information of the image can be effectively extracted while retaining the contour geometric features to a large extent, and then the edge-like circles of the screw holes are determined based on the edge contour segments to obtain the accurate screw hole positions. The screw hole positioning method disclosed in the present invention realizes the precise positioning of screw holes of different models, shapes, and colors.
[0085] In a possible implementation manner, fitting the screw hole edge quasi-circle based on the plurality of edge contour line segments to obtain the screw hole position information may include steps C1-C4:
[0086] Step C1, based on the length of each edge contour line segment, determining the number of target pixel points corresponding to each edge contour line segment.
[0087] In the present disclosure, the edge contour line segment is composed of a plurality of target pixel points, and the distance between adjacent target pixel points is fixed. The number of target pixel points constituting the edge contour line segment can be determined according to the length of the edge contour line segment, or the length of the edge contour line can be associated with the number of target pixel points constituting the edge contour line segment while determining the edge contour line, so as to obtain the number of target pixel points constituting the edge contour line segment according to the length of the edge contour line segment, and then the number of pixel points equal to the preset ratio of the number of target pixel points constituting the edge contour line segment can be selected as the number of target pixel points corresponding to the edge contour line segment, and the maximum integer is taken if it is a decimal. The preset ratio can be set to 0.3 or 0.4, etc. For example, if the number of target pixel points constituting the edge contour line segment x is 10, and the preset ratio is set to 0.4, it can be determined that the number of target pixel points corresponding to the edge contour line segment x is 4. Generally, the number of target pixel points corresponding to each edge contour line segment is greater than or equal to 3 and less than or equal to 10.
[0088] Step C2: selecting pixel points corresponding to the target pixel points of each edge contour line segment from the edge contour line segment to obtain a plurality of pixel points to be fitted.
[0089] For example, if the number of target pixels corresponding to the edge contour segment x is 4, and the number of target pixels corresponding to the edge contour segment y is 5, then 4 target pixels can be arbitrarily extracted from the edge contour segment x, and 5 target pixels can be arbitrarily extracted from the edge contour segment y, and 9 target pixels are obtained as the pixels to be fitted, and the 9 pixels to be fitted are used to fit a quasi-circle as the edge quasi-circle of the screw hole.
[0090] Step C3, fitting the multiple pixel points to be fitted to obtain a fitted quasi-circle, and using the fitted quasi-circle as the edge quasi-circle of the screw hole.
[0091] In the present disclosure, the fitted quasi-circle refers to an image whose boundary or outline is similar to a circle but has a certain deformation, for example, an ellipse is a quasi-circle.
[0092] In the present disclosure, if the total number of pixel points to be fitted selected from each edge contour line segment is not greater than a preset number threshold, a quasi-circle can be fitted based on multiple pixel points to be fitted as a screw hole edge quasi-circle, and the position corresponding to the screw hole edge quasi-circle is used as the screw hole position. If the total number of pixel points to be fitted selected from each edge contour line segment is greater than a preset number threshold, two or more quasi-circles can be fitted based on multiple pixel points to be fitted, and then the screw hole edge quasi-circle is determined based on the multiple quasi-circles. The preset number threshold can be set according to the actual application situation. For example, the preset number threshold can be set to 15 or 16.
[0093] In a possible implementation, the step of fitting the plurality of pixel points to be fitted to obtain a fitted quasi-circle as a screw hole edge quasi-circle may include steps D1-D2:
[0094] Step D1, fitting the multiple pixel points to be fitted.
[0095] In the present disclosure, a nonlinear curve fitting algorithm, such as an exponential curve fitting algorithm, a logarithmic curve fitting algorithm, or a sinusoidal curve fitting algorithm, may be used to fit a plurality of pixel points to be fitted.
[0096] Step D2: if two fitted quasi-circles are obtained, determine whether the two fitted quasi-circles are in a completely nested relationship.
[0097] In the present disclosure, when the total number of pixel points to be fitted selected from each edge contour line segment is greater than a preset number threshold, two fitted quasi-circles may be obtained. For the two fitted quasi-circles, if one of the two fitted quasi-circles completely contains the other quasi-circle, it can be determined that the two fitted quasi-circles are in a completely nested relationship, otherwise, it can be determined that the two fitted quasi-circles are not in a completely nested relationship.
[0098] Step D4: if yes, determine the fitted quasi-circle with a smaller area among the two fitted quasi-circles as the screw hole edge quasi-circle.
[0099] If the two fitted quasi-circles are in a completely nested relationship, the included quasi-circle is most likely the location of the screw hole, so the fitted quasi-circle with a smaller area can be selected as the quasi-circle at the edge of the screw hole.
[0100] Step D5: if not, the fitted quasi-circle with the larger area among the two fitted quasi-circles is determined as the screw hole edge quasi-circle.
[0101] If the two fitted quasi-circles are not completely nested, the quasi-circle with a larger area is most likely the location of the screw hole, so the fitted quasi-circle with a smaller area can be selected as the quasi-circle at the edge of the screw hole.
[0102] In another possible implementation, fitting the multiple pixel points to be fitted to obtain a fitted quasi-circular shape may include steps E1-E5:
[0103] Step E1, fitting the multiple pixel points to be fitted.
[0104] In the present disclosure, a nonlinear curve fitting algorithm, such as an exponential curve fitting algorithm, a logarithmic curve fitting algorithm, or a sinusoidal curve fitting algorithm, may be used to fit a plurality of pixel points to be fitted.
[0105] Step E2: if at least three fitted quasi-circles are obtained, the fitted quasi-circles are sorted according to their radius, and the fitted quasi-circle with the smallest radius is used as the detection circle.
[0106] In the present disclosure, when the total number of pixel points to be fitted selected from each edge contour line segment is greater than a preset number threshold, at least three fitted quasi-circles may be obtained. For the at least three fitted quasi-circles, the fitted quasi-circles may be sorted in order of radius from large to small, and the fitted quasi-circle with the smallest radius is used as the detection circle.
[0107] Step E3, calculating the intersection-over-union ratio between each fitted quasi-circular shape and the detection circle.
[0108] The intersection-to-union ratio between each fitted quasi-circle and the detection circle refers to the ratio of the area of the intersecting portion between the fitted quasi-circle and the detection circle to the area of the union formed by the fitted quasi-circle and the detection circle.
[0109] Step E4, determining the number of times each fitted quasi-circle is nested according to the intersection-to-union ratio.
[0110] In the present disclosure, for each fitted quasi-circle, if the intersection-and-union ratio between the fitted quasi-circle and the detection circle is greater than a preset intersection-and-union ratio threshold, the quasi-circle is removed. The preset intersection-and-union ratio threshold can be set to 0.8 or 0.85, and the counter of the current detection circle is increased by 1. Then, for the quasi-circles that have not been removed, return to execute step E2, and redetermine a new detection circle according to the radius. This cycle is repeated until there are no quasi-circles that can be removed. Then, the counts of the counters corresponding to each quasi-circle are determined, and the counts of the counters corresponding to each quasi-circle are used as the number of times the fitted quasi-circle is nested.
[0111] Step E5, obtaining the fitted quasi-circular shape with the largest number of nesting times.
[0112] In summary, the fitted quasi-circle with the largest number of nesting times is most likely the quasi-circle corresponding to the screw hole, and the corresponding fitted quasi-circle with the largest number of nesting times can be determined as the quasi-circle at the edge of the screw hole.
[0113] Step C5, determining the position information corresponding to the circle-like edge of the screw hole as the screw hole position information.
[0114] In the present disclosure, the area encircled by the circle-like edge of the screw hole in the image is the position of the screw hole.
[0115] In the present disclosure, the fitted quasi-circle can solve the problem of false detection caused by the inability to fit into a single circle, and the screw hole is obtained in combination with the fitted quasi-circle, which can make up for the problem of incorrect screw hole positioning caused by inaccurate texture information.
[0116] Figure 3 FIG. 1 shows a schematic diagram of a screw hole positioning method provided by an embodiment of the present disclosure, such as Figure 3 As shown, Figure 3 (a) is the grayscale image of the collected original image, i.e., the image to be processed 301, Figure 3 (b) is a gradient image 302 obtained after feature enhancement and gradient feature extraction of the image to be processed 301. Figure 3 (c) is an image 303 obtained by processing the gradient image 302 based on the gradient feature. The image 303 includes a plurality of edge contour line segments 306. Figure 3 (d) is an image 304 of a plurality of quasi-circular shapes 307 obtained by fitting a plurality of edge contour line segments 306 included in the image 303, Figure 3 (e) is an image 305 in which a final screw hole edge class circle 308 is determined after screening multiple screw hole edge class circles 307 in the image 304.
[0117] Based on the same inventive concept, according to the screw hole positioning method provided in the above embodiment of the present disclosure, correspondingly, another embodiment of the present disclosure further provides a screw hole positioning device, whose structural schematic diagram is shown in FIG. Figure 4 As shown, specifically including:
[0118] An image acquisition module 401 is used to acquire an image to be processed, where the image to be processed is an image of a housing of a target device, and the housing of the target device includes screw holes;
[0119] The image enhancement module 402 is used to perform feature enhancement processing on the image to be processed to obtain an enhanced image;
[0120] A gradient extraction module 403, used to extract the gradient features of the enhanced image;
[0121] A contour determination module 404, configured to determine a plurality of edge contour segments in the enhanced image based on the gradient feature;
[0122] The positioning module 405 is used to fit the edge circle of the screw hole based on the plurality of edge contour line segments to obtain the position information of the screw hole.
[0123] The device is used to obtain an image to be processed, which is an image of a shell of a target device, and the shell of the target device includes screw holes. Feature enhancement processing is performed on the image to be processed to obtain an enhanced image, and the gradient features of the enhanced image are extracted. Based on the gradient features, multiple edge contour segments in the enhanced image are determined, and the edge-like circles of the screw holes are fitted based on the multiple edge contour segments to obtain the position information of the screw holes. That is, for images with characteristics such as uneven grayscale, low contrast, and blurred edges, the edge contour segments can be determined by the gradient features of the enhanced image, so that the gradient edge contour information of the image can be effectively extracted while retaining the contour geometric features to a large extent, and then the edge-like circles of the screw holes are determined based on the edge contour segments to obtain the accurate screw hole positions. The screw hole positioning device disclosed in the present invention realizes the precise positioning of screw holes of different models, shapes, and colors.
[0124] In one possible implementation, the image enhancement module 402 is specifically configured to perform denoising on the image to be processed using a plurality of preset Gaussian filter kernels to obtain a denoised image; and perform grayscale enhancement on the denoised image to obtain an enhanced image.
[0125] In one possible implementation, the contour determination module 404 is specifically used to determine, for each pixel point in the enhanced image, whether the gradient amplitude of the pixel point is greater than the gradient amplitude of the adjacent pixel points in the specified gradient direction according to the gradient feature; if so, determine that the pixel point is a target pixel point; if not, set the pixel value of the pixel point to 0; determine multiple line segments formed by the target pixel points as edge contour segments, wherein adjacent pixel points in each edge contour segment are adjacent target pixel points.
[0126] In one possible implementation, the positioning module 405 is specifically used to determine the number of target pixel points corresponding to each edge contour line segment based on the length of each edge contour line segment; select the target pixel point number pixel points corresponding to the edge contour line segment in each edge contour line segment to obtain a plurality of pixel points to be fitted; fit the plurality of pixel points to be fitted to obtain a fitted quasi-circle; use the fitted quasi-circle as the edge quasi-circle of the screw hole; and determine the position information corresponding to the edge quasi-circle of the screw hole as the screw hole position information.
[0127] In one possible implementation, the positioning module 405 is specifically used to fit the multiple pixel points to be fitted; if two fitted quasi-circles are obtained, determine whether the two fitted quasi-circles are in a completely nested relationship; if so, determine the fitted quasi-circle with a smaller area among the two fitted quasi-circles as the screw hole edge quasi-circle; if not, determine the fitted quasi-circle with a larger area among the two fitted quasi-circles as the screw hole edge quasi-circle.
[0128] In one possible implementation, the positioning module 405 is specifically used to fit the multiple pixel points to be fitted; if at least three fitted quasi-circles are obtained, the fitted quasi-circles are sorted according to the radius, and the fitted quasi-circle with the smallest radius is used as the detection circle; the intersection-and-union ratio between each fitted quasi-circle and the detection circle is calculated; the number of times each fitted quasi-circle is nested is determined according to the intersection-and-union ratio; and the fitted quasi-circle with the largest number of nesting is obtained.
[0129] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device and a readable storage medium.
[0130] Figure 5A schematic block diagram of an example electronic device 500 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0131] like Figure 5 As shown, the device 500 includes a computing unit 501, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 502 or a computer program loaded from a storage unit 508 into a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the device 500 can also be stored. The computing unit 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.
[0132] A number of components in the device 500 are connected to the I / O interface 505, including: an input unit 506, such as a keyboard, a mouse, etc.; an output unit 507, such as various types of displays, speakers, etc.; a storage unit 508, such as a disk, an optical disk, etc.; and a communication unit 509, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 509 allows the device 500 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0133] The computing unit 501 may be a variety of general and / or special processing development components with processing and computing capabilities. Some examples of the computing unit 501 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 501 performs the various methods and processes described above, such as the screw hole positioning method. For example, in some embodiments, the screw hole positioning method may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 508. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 500 via the ROM 502 and / or the communication unit 509. When the computer program is loaded into the RAM 503 and executed by the computing unit 501, one or more steps of the screw hole positioning method described above may be performed. Alternatively, in other embodiments, the computing unit 501 may be configured to perform the screw hole positioning method in any other appropriate manner (e.g., by means of firmware).
[0134] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0135] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0136] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0137] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0138] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0139] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.
[0140] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0141] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of the present disclosure, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.
[0142] The above is only a specific embodiment of the present disclosure, but the protection scope of the present disclosure is not limited thereto. Any person skilled in the art who is familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present disclosure, which should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.
Claims
1. A screw hole positioning method, characterized in that: The method comprises: Acquire an image to be processed, where the image to be processed is a shell image of a target device, and the shell of the target device includes screw holes; Performing feature enhancement processing on the image to be processed to obtain an enhanced image; Extracting gradient features of the enhanced image; Determine a plurality of edge contour line segments in the enhanced image based on the gradient feature; The screw hole edge quasi-circle is fitted based on a plurality of edge contour line segments to obtain the screw hole position information.
2. The method according to claim 1, characterized in that The step of performing feature enhancement processing on the image to be processed to obtain an enhanced image includes: Using multiple preset Gaussian filter kernels to perform denoising on the image to be processed to obtain a denoised image; Grayscale enhancement processing is performed on the denoised image to obtain an enhanced image.
3. The method according to claim 1, characterized in that The step of determining a plurality of edge contour line segments in the enhanced image based on the gradient feature comprises: For each pixel in the enhanced image, determine, according to the gradient feature, whether the gradient amplitude of the pixel is greater than the gradient amplitude of the adjacent pixel in the specified gradient direction; if so, determine that the pixel is a target pixel; if not, set the pixel value of the pixel to 0; A plurality of line segments formed by the target pixel points are determined as edge contour line segments, wherein adjacent pixel points in each edge contour line segment are adjacent target pixel points.
4. The method according to claim 1, characterized in that: The step of fitting the screw hole edge quasi-circle based on the plurality of edge contour line segments to obtain the screw hole position information comprises: Based on the length of each edge contour line segment, determining the number of target pixel points corresponding to each edge contour line segment; Selecting pixel points corresponding to the target pixel points of each edge contour line segment in order to obtain a plurality of pixel points to be fitted; Fitting the plurality of pixel points to be fitted to obtain a fitted quasi-circular shape; The fitted quasi-circular shape is used as the quasi-circular shape of the screw hole edge; The position information corresponding to the circle-like edge of the screw hole is determined as the screw hole position information.
5. The method according to claim 4, characterized in that The step of fitting the plurality of pixel points to be fitted to obtain a fitted quasi-circle as a quasi-circle at the edge of the screw hole comprises: Fitting the multiple pixel points to be fitted; If two fitted quasi-circles are obtained, determine whether the two fitted quasi-circles are in a completely nested relationship; If yes, the fitted quasi-circle with the smaller area among the two fitted quasi-circles is determined as the screw hole edge quasi-circle; If not, the fitted quasi-circle with the larger area among the two fitted quasi-circles is determined as the screw hole edge quasi-circle.
6. The method according to claim 4, characterized in that The fitting of the plurality of pixels to be fitted to obtain a fitted quasi-circular shape comprises: Fitting the multiple pixel points to be fitted; If at least three fitted quasi-circles are obtained, the fitted quasi-circles are sorted according to their radius, and the fitted quasi-circle with the smallest radius is used as the detection circle; Calculating the intersection-over-union ratio between each fitted quasi-circle and the detection circle; Determine the number of times each fitted quasi-circle is nested according to the intersection-union ratio; Obtain the fitted quasi-circle with the largest number of nestings.
7. A screw hole positioning device, characterized in that: The device comprises: An image acquisition module, used for acquiring an image to be processed, wherein the image to be processed is an image of a housing of a target device, and the housing of the target device includes screw holes; An image enhancement module is used to perform feature enhancement processing on the image to be processed to obtain an enhanced image; A gradient extraction module, used to extract the gradient features of the enhanced image; A contour determination module, used for determining a plurality of edge contour segments in the enhanced image based on the gradient feature; The positioning module is used to fit the edge circle of the screw hole based on the plurality of edge contour line segments to obtain the position information of the screw hole.
8. The device according to claim 7, characterized in that The image enhancement module is specifically used to use multiple preset Gaussian filter kernels to perform denoising on the image to be processed to obtain a denoised image; and perform grayscale enhancement on the denoised image to obtain an enhanced image.
9. An electronic device, characterized in that: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 6.
10. A non-transitory computer-readable storage medium storing computer instructions, characterized in that: The computer instructions are used to make a computer execute the method according to any one of claims 1-6.
Citation Information
Cited By
Cabinet type integral hardware mounting hole site automatic positioning method based on image recognition
CN121982100A