A method, device, equipment, medium and product for detecting tangent points of linear and circular arc images
By performing binarization processing and linear fitting of product images, the tangent pixel coordinates are determined, which solves the visual positioning error problem caused by fixed position Mark points in the prior art, and improves the accuracy and applicability of tangent point detection.
Patent Information
- Application Number
- CN202411783857.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-06
- Publication Date
- 2025-04-15
- Estimated Expiration
- 2044-12-06
AI Technical Summary
In the prior art, the use of fixed positions as mark points leads to visual positioning errors, which cannot effectively solve the problem of point tangent detection accuracy on images of different products.
By obtaining the original image of the product to be tangently detected, performing binarization processing to obtain the target image, determining the linear arc segments and pixel coordinates of the linear and arc contours and fitting the linear equation to determine the pixel coordinates of the tangent point as the reference point of the product.
The accuracy of image tangent point detection for each product is improved, the error problem caused by fixed position Mark points is solved, and the visual positioning needs of different products are met.
Smart Images

Figure CN119295538B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of automated dispensing equipment industry, and in particular to a tangent point detection method, device, equipment, medium and product with a straight line and circular arc image. Background Art
[0002] In the prior art, for product images with straight line and circular arc geometric features and no obvious mark points on them for visual positioning, one can only manually select a fixed position on the initial product image as the mark point for visual positioning. Subsequent products will use this fixed position as the visual positioning point by default, which will cause the following problems: Due to the processing error of the product itself, a fixed position is manually selected in an initial product image, but it is not the same position in the true sense in other product images, resulting in visual positioning errors. Therefore, a tangent point detection method with straight line and circular arc images is urgently needed to solve the above technical problems. Summary of the invention
[0003] In view of this, the present invention provides a method, device, equipment, medium and product for detecting intersection points with straight line and circular arc images, which can solve the error problem caused by using fixed positions as mark points in the prior art, and improve the accuracy of intersection point detection for each product image, thereby meeting the needs of visual positioning of different products.
[0004] According to one aspect of the present invention, an embodiment of the present invention provides a method for detecting tangent points with a straight line and circular arc image, the method comprising:
[0005] Acquire an original image of the product to be cut-point detected, and perform binarization processing on the original image to obtain a processed target image; wherein both the original image and the target image are characterized as the product to be cut-point detected having straight line and circular arc contour features;
[0006] Determine the straight line and circular arc segments composed of the straight line and circular arc contours corresponding to the product to be cut-point detected, and the first pixel coordinates corresponding to each pixel in the straight line and circular arc segments based on the grayscale value of each pixel in the target image;
[0007] Determine second pixel coordinates having the same horizontal coordinate or the same vertical coordinate in each of the first pixel coordinates, the proportion of which reaches a preset proportion threshold, and obtain a corresponding straight line equation based on the second pixel coordinates;
[0008] Determine a third pixel coordinate associated with the second pixel coordinate, and remove the third pixel coordinate and the second pixel coordinate from the first pixel coordinate to obtain a remaining target pixel coordinate;
[0009] The pixel coordinates of the tangent point are determined based on the target pixel coordinates and the straight line equation, and the pixel coordinates of the tangent point are used as the reference point of the product to be inspected at the tangent point.
[0010] According to another aspect of the present invention, an embodiment of the present invention further provides a tangent point detection device with a straight line and circular arc image, the device comprising:
[0011] An acquisition module is used to acquire an original image of the product to be cut-point detected, and to perform binarization processing on the original image to obtain a processed target image; wherein the original image is characterized as a product to be cut-point detected having straight line and circular arc contour features;
[0012] A first coordinate determination module, used to determine the straight line and circular arc segments composed of the straight line and circular arc contours corresponding to the product to be cut-point detected, and the first pixel coordinates corresponding to each pixel in the straight line and circular arc segments based on the gray value of each pixel in the target image;
[0013] A fitting module, used to determine second pixel coordinates having the same horizontal coordinate or the same vertical coordinate in each of the first pixel coordinates, the proportion of which reaches a preset proportion threshold, and obtain a corresponding straight line equation based on the second pixel coordinates;
[0014] a target coordinate determination module, configured to determine a third pixel coordinate associated with the second pixel coordinate, and remove the third pixel coordinate and the second pixel coordinate from the first pixel coordinate to obtain a remaining target pixel coordinate;
[0015] The tangent point determination module is used to determine the tangent point pixel coordinates based on the target pixel coordinates and the straight line equation, and use the tangent point pixel coordinates as the reference point of the product to be inspected at the tangent point.
[0016] According to another aspect of the present invention, an embodiment of the present invention further provides an electronic device, the electronic device comprising:
[0017] at least one processor; and
[0018] a memory communicatively connected to the at least one processor; wherein,
[0019] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the tangent point detection method with straight line and circular arc images described in any embodiment of the present invention.
[0020] According to another aspect of the present invention, an embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the method for detecting tangent points of an image with straight lines and circular arcs as described in any embodiment of the present invention when executed.
[0021] According to another aspect of the present invention, an embodiment of the present invention further provides a computer program product, characterized in that the computer program product includes a computer program, and when the computer program is executed by a processor, it implements the tangent point detection method for an image with straight lines and circular arcs described in any embodiment of the present invention.
[0022] The technical effect of the present invention is to determine the straight line and arc segment composed of the straight line and arc contour corresponding to the product to be detected at the tangent point and the corresponding first pixel coordinates through the grayscale value of each pixel point in the target image, and then determine the second pixel coordinates in each first pixel coordinates with the same horizontal coordinate or the same vertical coordinate The number of coordinates reaches a preset proportion threshold, and obtain the corresponding straight line equation based on the second pixel coordinates. On this basis, determine the third pixel coordinates associated with the second pixel coordinates and remove the third pixel coordinates and the second pixel coordinates from the first pixel coordinates to obtain the remaining target pixel coordinates. Finally, determine the reference point of the product to be detected at the tangent point based on the target pixel coordinates and the straight line equation, which solves the error problem caused by using a fixed position as a mark point in the prior art, improves the accuracy of tangent point detection for each product image, and thus meets the needs of visual positioning of different products.
[0023] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0025] Figure 1 A flow chart of a method for detecting tangent points of a linear arc image provided by an embodiment of the present invention;
[0026] Figure 2 A flow chart of another method for detecting tangent points of an image with straight lines and circular arcs provided by an embodiment of the present invention;
[0027] Figure 3A first position relationship diagram corresponding to an original image of a product to be cut point detected provided by an embodiment of the present invention;
[0028] Figure 4 A second position relationship diagram corresponding to an original image of a product to be cut point detected provided by an embodiment of the present invention;
[0029] Figure 5 A method provided by an embodiment of the present invention Figure 3 Corresponding product monitoring effect diagram;
[0030] Figure 6 A method provided by an embodiment of the present invention Figure 4 Corresponding product monitoring effect diagram;
[0031] Figure 7 A structural block diagram of a tangent point detection device with a straight line and circular arc image provided by an embodiment of the present invention;
[0032] Figure 8 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0033] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0034] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0035] In one embodiment, Figure 1A flow chart of a method for detecting intersection points of a linear arc image provided by an embodiment of the present invention. This embodiment is applicable to the case of detecting intersection points of a product image with a linear arc image. The method can be executed by a device for detecting intersection points of a linear arc image. The device for detecting intersection points of a linear arc image can be implemented in the form of hardware and / or software. The device for detecting intersection points of a linear arc image can be configured in an electronic device.
[0036] like Figure 1 As shown, the tangent point detection method with a straight line and circular arc image in this embodiment specifically comprises the following steps:
[0037] S110, obtaining an original image of the product to be inspected at the cutting point, and performing binarization processing on the original image to obtain a processed target image; wherein both the original image and the target image are characterized as the product to be inspected at the cutting point having straight line and circular arc contour features.
[0038] Among them, the products to be inspected at the cutting point can be understood as products that need to be inspected at the cutting point in various industries. The cutting point detection in this embodiment can be called Mark point detection or reference point detection, that is, the optical positioning point in the printed circuit board (Printed Circuit Board, PCB). The machine can use the cutting point for positioning, and then perform glue dispensing processing, etc.
[0039] In this embodiment, the product to be detected at the cutting point may include but is not limited to electronic products such as mobile phones and iPads. The original image of the product to be detected at the cutting point is the original product image, and the original image has straight line and arc contour features. In this embodiment, the target image can be obtained after the original product image is binarized. Of course, the target image obtained by binarizing the original image also has straight line and arc contour features. For example, the product to be detected at the cutting point is a mobile phone device. At the edge of the right angle side of the shape of the device, the four corners are arc corners. There will be a cutting point from the straight line to the arc. It is necessary to find the cutting point (Mark point) of the right angle side and the arc side, that is, the automatic dispensing device needs to find the Mark point for dispensing during the formation of the mobile phone device. Since each product image is different, the corresponding cutting point position is also different. The cutting point is found as the product image Mark point, which is used for dispensing positioning later.
[0040] In this embodiment, after the original image of the product to be detected at the cutting point is captured by the image acquisition device, the original image of the product to be detected at the cutting point having the straight line and arc contour features is binarized to obtain the processed target image. In this embodiment, since there is a lot of noise in the original image of the product to be detected at the cutting point, it is necessary to first binarize the original image and change it into two grayscale values. It can be understood that the grayscale value of the pixel point on the original image is set to 0 or 255, that is, the entire image presents an obvious visual effect of only black and white, so as to improve the accuracy and efficiency of subsequent processing. In some embodiments, a threshold value can be set. When the image pixel value exceeds the set threshold value, it is assigned a value of 255, and when the image pixel value does not exceed the set threshold value, it is assigned a value of 0.
[0041] S120, based on the grayscale value of each pixel point in the target image, determine the straight line and circular arc segments composed of the straight line and circular arc contours corresponding to the product to be cut-point detected, and the first pixel coordinates corresponding to each pixel point in the straight line and circular arc segments.
[0042] The straight line and circular arc segments are composed of straight line segments and circular arc segments contained in the target image, and the straight line and circular arc segments include multiple pixel points, each pixel point corresponds to a pixel coordinate, and the pixel coordinate can be called a first pixel coordinate, which can be understood as the straight line and circular arc segments are composed of multiple first pixel coordinates. The first pixel coordinate includes an x-axis coordinate and a y-axis coordinate in a rectangular coordinate system.
[0043] In this embodiment, the target image includes multiple pixel points, and the grayscale values corresponding to the pixel points can be used to determine the straight line and circular arc segments composed of the straight line and circular arc contours corresponding to the product to be cut-off point detected, as well as the first pixel coordinates corresponding to each pixel point in the straight line and circular arc segments. In some embodiments, each pixel point in the target image can be traversed first. In the process of traversing the pixel points, the pixel scanning order is compared with the positional relationship of the straight line and arc contours corresponding to the product to be cut-off point detection, and it is determined whether the grayscale value of each pixel point is a transition pixel point from the first grayscale value to the second grayscale value. If it is a transition pixel point from the first grayscale value to the second grayscale value, the transition pixel points from the first grayscale value to the second grayscale value can be composed of the straight line and arc segment pixel coordinates of the product to be cut-off point detection, and the straight line and arc segment pixel coordinates are used as the first pixel coordinates; in other embodiments, the screen image and the preset template can be downsampled and then a coarse positioning matching calculation can be performed, and then the position deviation between the Mark points of each screen image after coarse positioning can be used as a test condition for judgment, and the Mark points that meet the preset position deviation can be added to the coarse positioning candidate point sequence, and the coordinates of each positioning point in the coarse positioning candidate point sequence can be used as the first pixel coordinates; of course, the first pixel coordinates can also be determined in other ways in this embodiment, and this embodiment is not limited here.
[0044] S130, determining second pixel coordinates in each first pixel coordinate having the same horizontal coordinate or the same vertical coordinate whose number of coordinates reaches a preset proportion threshold, and fitting based on the second pixel coordinates to obtain a corresponding straight line equation.
[0045] Among them, the preset proportion threshold is a proportion threshold set in advance according to the needs. In this embodiment, the pixel coordinates exceeding the preset proportion threshold can be defined as pixel coordinates with a high proportion. The pixel coordinates with a high proportion can be one pixel coordinate or two or more pixel coordinates. This embodiment does not limit this.
[0046] In this embodiment, the second pixel coordinates are pixel coordinates whose number of coordinates with the same horizontal coordinate in the first pixel coordinates reaches a preset proportion threshold, or are pixel coordinates whose number of coordinates with the same vertical coordinate in the first pixel coordinates reaches a preset proportion threshold. Exemplarily, the horizontal coordinates x1, x2, x3, x4 and x5 corresponding to all pixels are extracted, where x1=(1, 2), x2=(1, 3), x3=(2, 1), x4=(2, 3), and x5=(2, 2). It can be seen that there are two places with the same horizontal coordinate, x1 and x2 have the same horizontal coordinate, and the corresponding number of the same horizontal coordinate, that is, the number of coordinates with the horizontal coordinate of 1 is 2; one is that x3, x4, and x5 have the same horizontal coordinate, and the corresponding number of the same horizontal coordinate, that is, the number of coordinates with the horizontal coordinate of 2 is 3; assuming that the total number of pixels is 5, at this time, 2 / 5 is the proportion of the first number of the same horizontal coordinate, and 3 / 5 is the proportion of the second number of the same horizontal coordinate. The group with the highest proportion and the largest number of the same horizontal coordinates is taken as the second pixel coordinate that reaches the preset proportion threshold.
[0047] In the present embodiment, the first pixel coordinates include a horizontal coordinate and a vertical coordinate. Therefore, based on the first positional relationship between the straight line and the arc contour corresponding to the product to be detected at the tangent point, the second pixel coordinate in which the proportion of the number of coordinates with the same horizontal coordinate in each first pixel coordinate reaches a preset proportion threshold can be determined, and the corresponding straight line equation is obtained by fitting based on the second pixel coordinate; or, based on the second positional relationship between the straight line and the arc contour corresponding to the product to be detected at the tangent point, the second pixel coordinate in which the proportion of the number of coordinates with the same vertical coordinate in each first pixel coordinate reaches a preset proportion threshold can be determined, and the corresponding straight line equation is obtained by fitting based on the second pixel coordinate; in some embodiments, the total number of pixel coordinates of each first pixel coordinate is counted, and if the positional relationship is the first positional relationship, the vertical coordinates corresponding to each first pixel coordinate are extracted, and the pixel coordinates with the same vertical coordinate are divided into the same first coordinate combination, and the number of first coordinates with the same vertical coordinate corresponding to each first coordinate combination is counted. , according to the number of each first coordinate and the total number of pixel coordinates, a first ratio of each first coordinate number to the total number of pixel coordinates is determined, and the pixel coordinates whose first ratio reaches a preset ratio threshold are used as second pixel coordinates; wherein, the first coordinate combination includes at least two coordinate combinations, and each coordinate combination contains first pixel coordinates with the same vertical coordinate; in other embodiments, if the positional relationship is the second positional relationship, the horizontal coordinates corresponding to each first pixel coordinate are extracted, and the pixel coordinates with the same horizontal coordinate are divided into the same second coordinate combination, and the number of second coordinates with the same horizontal coordinate corresponding to each first coordinate combination is counted, and the second ratio of each first coordinate number to the total number of pixel coordinates is determined according to the number of each second coordinate and the total number of pixel coordinates, and the pixel coordinates whose second ratio reaches a preset ratio threshold are used as second pixel coordinates; wherein, the second coordinate combination includes at least two coordinate combinations, and each coordinate combination contains second pixel coordinates with the same horizontal coordinate.
[0048] In this embodiment, the second pixel coordinates are fitted to obtain the corresponding straight line equation, and the fitting method may include but is not limited to the least squares method, polynomial function fitting, Hough transform, and first performing Hough transform to screen out candidate points and then performing straight line fitting on the candidate points to obtain a more detailed straight line description.
[0049] S140 , determining a third pixel coordinate associated with the second pixel coordinate, and removing the third pixel coordinate and the second pixel coordinate from the first pixel coordinate to obtain the remaining target pixel coordinate.
[0050] The third pixel coordinate is a pixel coordinate associated with the second pixel coordinate, and the associated pixel coordinate may be a pixel coordinate smaller than the ordinate or abscissa in the second pixel coordinate. The target pixel coordinate may be understood as the remaining pixel coordinate obtained after removing the third pixel coordinate and the second pixel coordinate from the first pixel coordinate.
[0051] In this embodiment, based on the positional relationship between the straight line and the arc contour corresponding to the product to be detected at the tangent point, the third pixel coordinate associated with the second pixel coordinate can be determined, and the third pixel coordinate and the second pixel coordinate are removed from the first pixel coordinate to obtain the remaining target pixel coordinate; in some embodiments, if the positional relationship between the straight line and the arc contour corresponding to the product to be detected at the tangent point is the first positional relationship, the first target pixel coordinate whose ordinate is less than the second pixel coordinate is traversed in each first pixel coordinate, and the first target pixel coordinate is used as the associated third pixel coordinate; if the positional relationship between the straight line and the arc contour corresponding to the product to be detected at the tangent point is the second positional relationship, the second target pixel coordinate whose ordinate is less than the second pixel coordinate is traversed in each first pixel coordinate, and the second target pixel coordinate is used as the associated third pixel coordinate; in other embodiments, an area can also be established based on the Mark point that meets the preset position deviation and the prior positional relationship between each screen image, multiple coarse positioning is performed within the area according to the preset template, and the Mark point that meets the preset position deviation is also added to the coarse positioning candidate point sequence as the associated third pixel coordinate.
[0052] S150, determining the pixel coordinates of the tangent point based on the target pixel coordinates and the straight line equation, and using the pixel coordinates of the tangent point as the reference point of the product to be inspected at the tangent point.
[0053] In this embodiment, the pixel coordinates of the cutting point are the reference points of the product to be detected at the cutting point. The reference points can also be called optical positioning points, which can be used for product dispensing positioning.
[0054] In this embodiment, based on the target pixel coordinates and the straight line equation, the tangent point pixel coordinates can be determined. Specifically, the tangent point pixel coordinates can be determined by the distance from each target pixel coordinate to the straight line equation. It is also possible to calculate the matching score of each mark point to be measured based on the coarse positioning results and the fine positioning results, and sort the matching scores to select the mark point to be measured with the highest score as the target mark point for accurate positioning. It is also possible to extract all contours in the grayscale image by using a contour extraction algorithm, and to locate the target point by screening the contours. This embodiment is not limited here.
[0055] The technical solution of the embodiment of the present invention determines the straight line and circular arc segments composed of the straight line and circular arc contour corresponding to the product to be detected at the tangent point and the corresponding first pixel coordinates through the grayscale value of each pixel point in the target image, and then determines the second pixel coordinates in each first pixel coordinate with the same horizontal coordinate, or the number of coordinates with the same vertical coordinate reaches a preset proportion threshold, and obtains the corresponding straight line equation based on the second pixel coordinate fitting, and on this basis, determines the third pixel coordinate associated with the second pixel coordinate and removes the third pixel coordinate and the second pixel coordinate from the first pixel coordinate to obtain the remaining target pixel coordinates, and finally, determines the reference point of the product to be detected at the tangent point based on the target pixel coordinates and the straight line equation, which solves the error problem caused by using a fixed position as a mark point in the prior art, improves the accuracy of tangent point detection for each product image, and thus meets the needs of visual positioning of different products.
[0056] In one embodiment, Figure 2 A flowchart of another method for tangent point detection with a straight line and circular arc image provided for an embodiment of the present invention. Based on the above embodiments, this embodiment determines the straight line and circular arc segments composed of the straight line and circular arc contour corresponding to the product to be detected at the tangent point based on the grayscale value of each pixel point in the target image, and the first pixel coordinates corresponding to each pixel point in the straight line and circular arc segment; determines the second pixel coordinates in each first pixel coordinate having the same horizontal coordinate or the same vertical coordinate, the proportion of which reaches a preset proportion threshold, and obtains the corresponding straight line equation based on the second pixel coordinates; determines the third pixel coordinate associated with the second pixel coordinate; and determines the tangent point pixel coordinates based on the target pixel coordinates and the straight line equation, and further refines the tangent point pixel coordinates as the reference point of the product to be detected at the tangent point.
[0057] like Figure 2 As shown, the tangent point detection method with a straight line and circular arc image in this embodiment may specifically include the following steps:
[0058] S210, obtaining an original image of the product to be inspected at the cutting point, and performing binarization processing on the original image to obtain a processed target image; wherein both the original image and the target image are characterized as the product to be inspected at the cutting point having straight line and circular arc contour features.
[0059] S220 , establishing a rectangular coordinate system with the upper left corner of the target image as the origin, and traversing each pixel point in the target image according to a preset pixel scanning order.
[0060] Among them, the preset pixel scanning order is related to the positional relationship between the straight line and the circular arc contour corresponding to the product to be detected at the tangent point; the positional relationship includes: a first positional relationship and a second positional relationship; the first positional relationship includes that the straight line contour of the product to be detected at the tangent point is below the circular arc contour, which can be understood as establishing a rectangular coordinate system with the upper left corner of the target image as the origin, and from left to right there are straight line segments first and then curve segments, and the curve segments are higher than the straight line segments; the second positional relationship includes: the straight line contour of the product to be detected at the tangent point is above the circular arc contour, which can be understood as establishing a rectangular coordinate system with the upper left corner of the target image as the origin, and from left to right there are curve segments first and then straight line segments, and the straight line segments are higher than the curve segments. Exemplary, to facilitate a better understanding of the positional relationship, Figure 3 A first position relationship diagram corresponding to an original image of a product to be cut point detected provided by an embodiment of the present invention; Figure 4 An embodiment of the present invention provides a second position relationship diagram corresponding to an original image of a product to be cut point detected. Figure 3 As shown in the figure, the straight line contour of the product to be cut is below the arc contour. Figure 4 As shown, the straight line contour of the product to be detected at the cutting point is above the arc contour.
[0061] In this embodiment, a rectangular coordinate system is established with the upper left corner of the target image as the origin, and each pixel in the target image is traversed in a preset pixel scanning order. According to different positional relationships, different pixel scanning orders are selected to traverse each pixel in the target image. For example, in the case of the first positional relationship, each pixel of the image is traversed in a "from bottom to top, from right to left" manner.
[0062] S230, determining whether the grayscale value of each pixel is a transition pixel from a first grayscale value to a second grayscale value; if not, executing S240; if yes, executing S250.
[0063] The first grayscale value is 0, and the second grayscale value is 255. The transition pixel point is a pixel point that transitions from 0 to 255.
[0064] In this embodiment, it is determined whether the grayscale value of each pixel point is a transition pixel point from the first grayscale value to the second grayscale value. If it is a transition pixel point from the first grayscale value to the second grayscale value, the transition pixel points from the first grayscale value to the second grayscale value are combined to form the straight line arc segment pixel coordinates of the product to be inspected at the tangent point, and the straight line arc segment pixel coordinates are used as the first pixel coordinates.
[0065] S240: Determine whether the pixel point is not a transition pixel point.
[0066] In this embodiment, when the grayscale value of each pixel point is not a transition pixel point from the first grayscale value to the second grayscale value, it is determined that the pixel point is not a transition pixel point.
[0067] S250, forming pixel coordinates of a straight line and circular arc segment of the product to be inspected at a tangent point by pixel points transitioning from the first grayscale value to the second grayscale value, and using the pixel coordinates of the straight line and circular arc segment as the first pixel coordinates.
[0068] In this embodiment, when the grayscale value of each pixel point is a transition pixel point from a first grayscale value to a second grayscale value, the transition pixel points from the first grayscale value to the second grayscale value are composed of the straight line arc segment pixel coordinates of the product to be detected at the tangent point, and the straight line arc segment pixel coordinates are used as the first pixel coordinates, and each first pixel coordinate line is a straight line arc segment curve of the product to be detected at the tangent point.
[0069] S260: Count the total number of pixel coordinates of each first pixel coordinate.
[0070] In this embodiment, the total number of pixel coordinates of each first pixel coordinate is counted, that is, the number of each pixel coordinate on the entire straight line arc segment curve is counted as the total number of pixel coordinates.
[0071] S270. When the positional relationship between the straight line and the arc contour corresponding to the product to be cut-off point detected is a first positional relationship, extract the vertical coordinates corresponding to each first pixel coordinate, and divide the pixel coordinates with the same vertical coordinate into the same first coordinate combination, and count the number of first coordinates with the same vertical coordinate corresponding to each first coordinate combination, and determine the first ratio of each first coordinate number to the total pixel coordinate number according to the number of each first coordinate and the total number of pixel coordinates, and use the pixel coordinates whose first ratio reaches a preset ratio threshold as the second pixel coordinate; wherein the first coordinate combination includes at least two coordinate combinations, and each coordinate combination contains pixel coordinates with the same vertical coordinate.
[0072] Wherein, each coordinate combination in the first coordinate combination is a different pixel coordinate with the same ordinate. Exemplarily, the first coordinate combination includes a coordinate combination with a ordinate of 2, a coordinate combination with a ordinate of 3, a coordinate combination with a ordinate of 5, and so on. The total number of coordinates corresponding to each coordinate combination is, for example, 3 coordinates corresponding to the coordinate combination with a ordinate of 2, 4 coordinates corresponding to the coordinate combination with a ordinate of 5, and so on, which is not limited in this embodiment.
[0073] In this embodiment, when the positional relationship between the straight line and the circular arc contour corresponding to the product to be detected at the tangent point is a first positional relationship, the vertical coordinates corresponding to each first pixel coordinate are extracted, and the pixel coordinates with the same vertical coordinate are divided into the same first coordinate combination, and the number of first coordinates with the same vertical coordinate corresponding to each first coordinate combination is counted, and the first ratio of each first coordinate number to the total pixel coordinate number is determined according to the number of each first coordinate and the total number of pixel coordinates, and the pixel coordinates whose first ratio reaches a preset ratio threshold are used as the second pixel coordinates; wherein the first coordinate combination includes at least two coordinate combinations, and each coordinate combination contains first pixel coordinates with the same vertical coordinate. It can be understood that the number of pixels with the same ordinate is counted. Since the number of pixel coordinates is large, the pixel coordinates with the same ordinate correspond to multiple types. For example, the ordinate of 1 is recorded as count1, the ordinate of 2 is recorded as count2, the ordinate of 3 is recorded as count3, and so on. The total number of pixel coordinates is recorded as count Total. Then, the ratio of the number of pixels with the same ordinate to the total number of pixels is calculated as: count1 / count Total, count2 / count Total, count3 / count Total.
[0074] In one embodiment, a first ratio of each first coordinate number to the total pixel coordinate number is determined based on each first coordinate number and the total pixel coordinate number, including: calculating the ratio of each first coordinate number to the total pixel coordinate number, and using each ratio as the first ratio of each first coordinate number to the total pixel coordinate number.
[0075] S280. When the positional relationship between the straight line and the arc contour corresponding to the product to be cut-off point detected is a second positional relationship, extract the horizontal coordinates corresponding to each first pixel coordinate, and divide the pixel coordinates with the same horizontal coordinate into the same second coordinate combination, and count the number of second coordinates with the same horizontal coordinate corresponding to each second coordinate combination, and determine the second ratio of each first coordinate number to the total pixel coordinate number according to the number of each second coordinate and the total number of pixel coordinates, and use the pixel coordinates whose second ratio reaches a preset ratio threshold as the second pixel coordinate; wherein the second coordinate combination includes at least two coordinate combinations, and each coordinate combination contains pixel coordinates with the same horizontal coordinate.
[0076] Each coordinate combination in the second coordinate combination is a different pixel coordinate with the same horizontal coordinate. For example, the first coordinate combination includes a coordinate combination with a horizontal coordinate of 3, a coordinate combination with a horizontal coordinate of 1, and so on.
[0077] In this embodiment, when the positional relationship between the straight line and the circular arc contour corresponding to the product to be detected at the tangent point is the second positional relationship, the horizontal coordinates corresponding to each first pixel coordinate are extracted, and the pixel coordinates with the same horizontal coordinate are divided into the same second coordinate combination, and the number of second coordinates with the same horizontal coordinate corresponding to each first coordinate combination is counted, and the second ratio of each first coordinate number to the total pixel coordinate number is determined according to the number of each second coordinate and the total number of pixel coordinates, and the pixel coordinates whose second ratio reaches a preset proportion threshold are used as the second pixel coordinates; wherein the second coordinate combination includes at least two coordinate combinations, and each coordinate combination contains pixel coordinates with the same horizontal coordinate. For example, (1, 2), (1, 3), (2, 1); there are two places with the same horizontal coordinate, one is (1, 2), (1, 3), the number of the same horizontal coordinate is 2 when x=1, and the other is (2, 1), the number of the same horizontal coordinate is 1 when x=2; then, count1 is 2, count2 is 1, and the total number is count Total, then, the proportion of the first number of the same horizontal coordinate is 2 / count Total, and the proportion of the second number of the same horizontal coordinate is 1 / count Total; the highest proportion is the group with the largest number of the same horizontal coordinates; the purpose of counting the number is that the more the number of horizontal coordinates, it means that the same horizontal coordinates are on the same straight line.
[0078] In one embodiment, a second ratio of each first coordinate number to the total pixel coordinate number is determined based on each second coordinate number and the total pixel coordinate number, including: calculating the ratio of each second coordinate number to the total pixel coordinate number, and using each ratio as the second ratio of each second coordinate number to the total pixel coordinate number.
[0079] S290, using a preset least square method and each second pixel coordinate to fit a straight line equation.
[0080] In this embodiment, the preset least square method is a straight line fitting method commonly used in the prior art, that is, fitting n points.
[0081] In this embodiment, the preset least squares method and each second pixel coordinate are used to fit the straight line equation. A more specific implementation method is: (1) First, establish the straight line model to be fitted: , where m and c are the parameters to be solved; (2) Establish an error model: the sum of the squares of the vertical distances from n points to the straight line model is the smallest, which can be recorded as: ; (3) Calculate the partial derivatives of s with respect to m and c respectively, recorded as and ; (4) Then let and , and obtain a system of equations about m and c; (5) Solve the system of equations to obtain the unknowns m and c; illustratively, (1, 2), (1, 3) are the two coordinates with the highest proportion of the same horizontal coordinates, and the preset least squares method is used to fit these two coordinates into the straight line equation.
[0082] S2100. When the positional relationship between the straight line and the arc contour corresponding to the product to be detected at the tangent point is a first positional relationship, traverse each first pixel coordinate to find the first target pixel coordinate whose vertical coordinate is smaller than the second pixel coordinate, and use the first target pixel coordinate as the associated third pixel coordinate.
[0083] In this embodiment, when the positional relationship between the straight line and the circular arc contour corresponding to the product to be detected at the tangent point is a first positional relationship, the first target pixel coordinate whose vertical coordinate is smaller than the second pixel coordinate is traversed in each first pixel coordinate, and the first target pixel coordinate is used as the associated third pixel coordinate.
[0084] S2110. When the positional relationship between the straight line and the arc contour corresponding to the product to be detected at the tangent point is the second positional relationship, traverse each first pixel coordinate to find the second target pixel coordinate whose horizontal coordinate is smaller than the second pixel coordinate, and use the second target pixel coordinate as the associated third pixel coordinate.
[0085] In this embodiment, when the positional relationship between the straight line and the circular arc contour corresponding to the product to be detected at the tangent point is the second positional relationship, the second target pixel coordinate whose horizontal coordinate is smaller than the second pixel coordinate is traversed in each first pixel coordinate, and the second target pixel coordinate is used as the associated third pixel coordinate.
[0086] S2120: Subtract the third pixel coordinate and the second pixel coordinate from the first pixel coordinate to obtain the remaining target pixel coordinate.
[0087] In this embodiment, the third pixel coordinate and the second pixel coordinate are removed from the first pixel coordinate to obtain the remaining target pixel coordinate. In this embodiment, the third pixel coordinate and the second pixel coordinate are removed from the first pixel coordinate to obtain the remaining target pixel coordinate, which may include but is not limited to directly deleting one by one after finding the associated coordinates, and storing and then deleting them together after finding the associated left side.
[0088] S2130, determine the distances from each target pixel coordinate to the straight line equation, and obtain the pixel coordinates closest to the straight line equation from each distance, use the pixel coordinates closest to the straight line equation as the tangent point coordinates, and use the tangent point pixel coordinates as the reference point of the product to be inspected at the tangent point.
[0089] In this embodiment, the distance from each target pixel coordinate to the straight line equation is determined, and the distances are compared to obtain the pixel coordinates closest to the straight line equation from each distance. The pixel coordinates closest to the straight line equation are used as the tangent point coordinates, and the tangent point pixel coordinates are used as the reference point of the product to be inspected at the tangent point.
[0090] The technical solution of the embodiment of the present invention traverses each pixel point in the target image according to a preset pixel scanning order, searches for whether the grayscale value of each pixel point is a transition pixel point from a first grayscale value to a second grayscale value, forms a first pixel coordinate, and then extracts the ordinate / abscissa corresponding to each first pixel coordinate through a positional relationship, and divides the pixel coordinates with the same ordinate / abscissa into the same coordinate combination, and counts the number of coordinates with the same ordinate / abscissa corresponding to each coordinate combination, and determines the ratio of each coordinate number to the total pixel coordinate number according to the number of each coordinate and the total number of pixel coordinates, and sets the ratio to the preset proportion threshold. The pixel coordinates are used as the second pixel coordinates, based on which, the preset least squares method and each second pixel coordinate are used to fit the straight line equation, and finally based on the different positional relationships, the vertical coordinates / horizontal coordinates that are smaller than the second pixel coordinates are traversed in each first pixel coordinate as the associated third pixel coordinates, and the target pixel coordinates are obtained after eliminating the second pixel coordinates and the third pixel coordinates, so as to determine the tangent point coordinates based on the target pixel coordinates and the straight line equation, further solving the error problem caused by using a fixed position as a Mark point in the prior art, and improving the accuracy of tangent point detection for each product image, thereby meeting the needs of visual positioning of different products.
[0091] In one embodiment, in order to better understand the tangent point detection method with a straight line arc image, in the above embodiment, Figure 3 A first position relationship diagram corresponding to an original image of a product to be cut point detected provided by an embodiment of the present invention is given. Figure 4 A second position relationship diagram corresponding to an original image of a product to be cut point detected provided by an embodiment of the present invention is given; thus, for Figure 3 and Figure 4 In two different position relationships, Figure 5 A method provided by an embodiment of the present invention Figure 3 Corresponding product monitoring effect diagram, Figure 6 A method provided by an embodiment of the present invention Figure 4 Corresponding product monitoring effect diagram. In this embodiment, Figure 3 and Figure 5 The positional relationship between the straight line and the arc contour corresponding to the product to be cut-off point detection is the first positional relationship. Figure 4 and Figure 6 The positional relationship between the straight line and the arc contour corresponding to the product to be cut-off point detection is the second positional relationship.
[0092] In this embodiment, for Figure 3 The corresponding original image of the product to be cut-off point detected and the cut-off point detection method with the straight line and arc image specifically include the following steps:
[0093] a1. Binarize the input original product image to obtain the binarized image.
[0094] a2. Traverse each pixel of the image in a1 from bottom to top and from right to left to determine whether the grayscale of the pixel transitions from 0 to 255, thereby obtaining the pixel coordinates of the straight line and arc segment, such as Figure 5 The product detection effect is shown in the edge points in the figure.
[0095] a3. Based on the straight line and arc segment pixel coordinates obtained in a2, extract the ordinates y1, y2, y3, ... of all pixels, and then count the number of pixels with the same ordinate, recorded as count1, count2, count3, ..., let the number of all "straight line and arc segment pixel coordinates" in (2) be count Total, and calculate the ratio of the number of pixels with the same ordinate to the total number of pixels as: count1 / count Total, count2 / count Total, count3 / count Total.
[0096] a4. Select the pixel coordinates with the highest proportion in a3, and then fit the straight line equation based on these pixel coordinates.
[0097] a5. Remove the pixel coordinates with the highest percentage in a4 and the pixel coordinates to the "left" of these pixel coordinates with the highest percentage from the pixel coordinates of all straight lines and arc segments obtained in a2, and then traverse the distances from the remaining pixel coordinates to the fitted straight line equation in a4 to obtain the coordinates of the nearest pixel point. The coordinates of the nearest pixel point are the tangent point coordinates, such as Figure 5 The coordinate point marked in the product inspection effect diagram is represented as (395, 444).
[0098] In this embodiment, for Figure 4 The corresponding original image of the product to be cut-off point detected and the cut-off point detection method with the straight line and arc image specifically include the following steps:
[0099] b1. Binarize the input original product image to obtain the binarized image.
[0100] b2. Traverse each pixel of the image in b1 from right to left to determine whether the grayscale of the pixel transitions from 0 to 255, thereby obtaining the pixel coordinates of the straight line and arc segment, such as Figure 6 The product detection effect is shown in the edge points in the figure.
[0101] b3. Based on the pixel coordinates of the straight lines and arc segments obtained in b2, extract the horizontal coordinates x1, x2, x3... of all the pixels corresponding to them, and then count the number of pixels with the same horizontal coordinates, recorded as count1, count2, count3..., let the number of pixel coordinates of all straight lines and arc segments in b2 be count Total, and calculate the ratio of the number of pixels with the same horizontal coordinate to the total number of pixels: count1 / count Total, count2 / count Total, count3 / count Total.
[0102] b4. Select the pixel coordinates with the highest proportion in b3, and then fit the straight line equation based on these pixel coordinates.
[0103] b5. Remove the pixel coordinates with the highest percentage in b4 and the pixel coordinates to the "left" of these pixel coordinates with the highest percentage from the pixel coordinates of all straight lines and arc segments obtained in b2, and then traverse the distances from the remaining pixel coordinates to the fitted straight line equation in b4 to obtain the coordinates of the nearest pixel point. The coordinates of the nearest pixel point are the tangent point coordinates, such as Figure 6 The coordinate point marked in the product inspection effect diagram is represented as (777, 303).
[0104] In the embodiment of the present invention, since each product image is different, the corresponding tangent point position is also different, which solves the error problem caused by using a fixed position as a mark point in the original method, thereby meeting the visual positioning requirements of different products.
[0105] In one embodiment, Figure 7 This is a structural block diagram of a device for detecting the tangent point of a straight line arc image provided by an embodiment of the present invention. The device is suitable for detecting the tangent point of a product image with a straight line arc image. The device can be implemented by hardware / software. It can be configured in an electronic device to implement a method for detecting the tangent point of a straight line arc image in an embodiment of the present invention.
[0106] like Figure 7 As shown, the device includes: an acquisition module 710, a first coordinate determination module 720, a fitting module 730, a target coordinate determination module 740 and a tangent point determination module 750;
[0107] The acquisition module 710 is used to acquire an original image of the product to be cut-point detected, and to perform binarization processing on the original image to obtain a processed target image; wherein both the original image and the target image are characterized as the product to be cut-point detected having straight line and circular arc contour features;
[0108] A first coordinate determination module 720 is used to determine the straight line and circular arc segments corresponding to the straight line and circular arc contour of the product to be cut-off point detection, and the first pixel coordinates corresponding to each pixel in the straight line and circular arc segments based on the gray value of each pixel in the target image;
[0109] A fitting module 730 is used to determine second pixel coordinates having the same horizontal coordinate or the same vertical coordinate in each of the first pixel coordinates, the proportion of which reaches a preset proportion threshold, and obtain a corresponding straight line equation based on the second pixel coordinates;
[0110] a target coordinate determination module 740, configured to determine a third pixel coordinate associated with the second pixel coordinate, and remove the third pixel coordinate and the second pixel coordinate from the first pixel coordinate to obtain the remaining target pixel coordinate;
[0111] The tangent point determination module 750 is used to determine the tangent point pixel coordinates based on the target pixel coordinates and the straight line equation, and use the tangent point pixel coordinates as the reference point of the product to be inspected at the tangent point.
[0112] In an embodiment of the present invention, a first coordinate determination module determines the straight line and arc segment composed of the straight line and arc contour corresponding to the product to be detected at the tangent point and the corresponding first pixel coordinates through the grayscale value of each pixel point in the target image, and then a fitting module determines the second pixel coordinates in each first pixel coordinate having the same horizontal coordinate or the same vertical coordinate whose number of coordinates reaches a preset proportion threshold, and obtains the corresponding straight line equation based on the second pixel coordinate fitting. On this basis, a target coordinate determination module determines the third pixel coordinate associated with the second pixel coordinate and removes the third pixel coordinate and the second pixel coordinate from the first pixel coordinate to obtain the remaining target pixel coordinates. Finally, a tangent point determination module determines the reference point of the product to be detected at the tangent point based on the target pixel coordinates and the straight line equation, which solves the error problem caused by using a fixed position as a mark point in the prior art, improves the accuracy of tangent point detection for each product image, and thus meets the needs of visual positioning of different products.
[0113] In one embodiment, the first coordinate determination module 720 includes:
[0114] A pixel traversal unit, used to establish a rectangular coordinate system with the upper left corner of the target image as the origin, and traverse each pixel in the target image according to a preset pixel scanning order; wherein the preset pixel scanning order is related to the positional relationship between the straight line and the circular arc contour corresponding to the product to be detected at the tangent point; the positional relationship includes: a first positional relationship and a second positional relationship; the first positional relationship includes: the straight line contour of the product to be detected at the tangent point is below the circular arc contour; the second positional relationship includes: the straight line contour of the product to be detected at the tangent point is above the circular arc contour;
[0115] A judging unit, used to judge whether the grayscale value of each pixel point is a transition pixel point from the first grayscale value to the second grayscale value;
[0116] A pixel coordinate determination unit, for forming pixel coordinates of a straight line arc segment of the product to be cut-off point detected from transition pixel points of the first grayscale value to the second grayscale value, and using the pixel coordinates of the straight line arc segment as the first pixel coordinates;
[0117] The non-transition pixel point determining unit is used to determine that the pixel point is not a transition pixel point if no.
[0118] In one embodiment, the fitting module 730 includes:
[0119] A counting unit, used for counting the total number of pixel coordinates of each of the first pixel coordinates;
[0120] A first determination unit is used to extract the vertical coordinates corresponding to each of the first pixel coordinates when the positional relationship between the straight line and the arc contour corresponding to the product to be cut-off point detection is a first positional relationship, and divide the pixel coordinates with the same vertical coordinate into the same first coordinate combination, and count the number of first coordinates with the same vertical coordinate corresponding to each of the first coordinate combinations, and determine a first ratio of each of the first coordinate numbers to the total number of pixel coordinates according to the first coordinate numbers and the total number of pixel coordinates, and use the pixel coordinates whose first ratio reaches the preset proportion threshold as the second pixel coordinate; wherein the first coordinate combination includes at least two coordinate combinations, and each coordinate combination contains pixel coordinates with the same vertical coordinate;
[0121] A second determination unit is used to extract the horizontal coordinates corresponding to each of the first pixel coordinates when the positional relationship between the straight line and the circular arc contour corresponding to the product to be detected at the tangent point is a second positional relationship, and divide the pixel coordinates with the same horizontal coordinate into the same second coordinate combination, and count the number of second coordinates with the same horizontal coordinate corresponding to each of the second coordinate combinations, and determine the second ratio of each of the first coordinate numbers to the total number of pixel coordinates according to the number of each of the second coordinates and the total number of pixel coordinates, and use the pixel coordinates whose second ratio reaches the preset proportion threshold as the second pixel coordinate; wherein the second coordinate combination includes at least two coordinate combinations, and each coordinate combination contains pixel coordinates with the same horizontal coordinate.
[0122] In one embodiment, the first determining unit includes:
[0123] The first ratio determination subunit is used to calculate the ratios of each of the first coordinate numbers to the total number of pixel coordinates, and use each of the ratios as a first ratio of each of the first coordinate numbers to the total number of pixel coordinates.
[0124] In one embodiment, the second determining unit includes:
[0125] The second ratio determination subunit is used to calculate the ratios of each second coordinate number to the total pixel coordinate number, and use each ratio as a second ratio of each second coordinate number to the total pixel coordinate number.
[0126] In one embodiment, the fitting module 730 includes:
[0127] A fitting unit is used to fit a straight line equation using a preset least square method and each of the second pixel coordinates.
[0128] In one embodiment, the target coordinate determination module 740 includes:
[0129] A first target coordinate determination unit is used to traverse and search for a first target pixel coordinate whose ordinate is smaller than the second pixel coordinate in each of the first pixel coordinates when the positional relationship between the straight line and the circular arc contour corresponding to the product to be tangent point detected is a first positional relationship, and use the first target pixel coordinate as an associated third pixel coordinate;
[0130] The second target coordinate determination unit is used to traverse and search for the second target pixel coordinate whose horizontal coordinate is smaller than the second pixel coordinate in each of the first pixel coordinates when the positional relationship between the straight line and the circular arc contour corresponding to the product to be detected at the tangent point is a second positional relationship, and use the second target pixel coordinate as the associated third pixel coordinate.
[0131] In one embodiment, the cut point determination module 750 includes:
[0132] A required coordinate determination subunit, used to determine the distances from each of the target pixel coordinates to the straight line equation, and obtain the pixel coordinates closest to the straight line equation from each of the distances;
[0133] The tangent point coordinate determination subunit is used to take the pixel coordinates closest to the straight line equation as the tangent point coordinates.
[0134] The tangent point detection device for straight line and circular arc images provided by the embodiment of the present invention can execute the tangent point detection method for straight line and circular arc images provided by any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0135] In one embodiment, Figure 8 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. The electronic device 10 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 may also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) 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 invention described and / or required herein.
[0136] like Figure 8 As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. The input / output (I / O) interface 15 is also connected to the bus 14.
[0137] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0138] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as a tangent point detection method with a straight line arc image.
[0139] In some embodiments, the tangent point detection method with straight line arc images can be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the tangent point detection method with straight line arc images described above can be performed. Alternatively, in other embodiments, the processor 11 can be configured to perform the tangent point detection method with straight line arc images in any other appropriate manner (for example, by means of firmware).
[0140] 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), load 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.
[0141] The computer program for implementing the method of the present invention can be written in any combination of one or more programming languages. These computer programs can be provided to a general-purpose computer, a special-purpose computer or other programmable processor of a tangent point detection device with a straight line and circular arc image, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program can be executed completely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or completely on a remote machine or server.
[0142] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, device, or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. 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.
[0143] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device 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 a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0144] The systems and techniques described herein may be implemented in a computing system that includes backend 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 frontend 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 backend components, middleware components, or frontend 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), a blockchain network, and the Internet.
[0145] A computing 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 client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0146] 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 described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0147] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for detecting tangent points of an image with straight lines and circular arcs, characterized in that: include: Acquire an original image of the product to be cut-point detected, and perform binarization processing on the original image to obtain a processed target image; wherein both the original image and the target image are characterized as the product to be cut-point detected having straight line and circular arc contour features; Determine the straight line and circular arc segments composed of the straight line and circular arc contours corresponding to the product to be cut-point detected, and the first pixel coordinates corresponding to each pixel in the straight line and circular arc segments based on the grayscale value of each pixel in the target image; Determine second pixel coordinates having the same horizontal coordinate or the same vertical coordinate in each of the first pixel coordinates, the proportion of which reaches a preset proportion threshold, and obtain a corresponding straight line equation based on the second pixel coordinates; Determine a third pixel coordinate associated with the second pixel coordinate, and remove the third pixel coordinate and the second pixel coordinate from the first pixel coordinate to obtain a remaining target pixel coordinate; Determine the pixel coordinates of the tangent point based on the target pixel coordinates and the straight line equation, and use the pixel coordinates of the tangent point as the reference point of the product to be inspected at the tangent point; The method of determining the straight line and circular arc segments composed of the straight line and circular arc contours corresponding to the product to be cut-off point detected based on the grayscale value of each pixel point in the target image, and the first pixel coordinates corresponding to each pixel point in the straight line and circular arc segments, includes: A rectangular coordinate system is established with the upper left corner of the target image as the origin, and each pixel point in the target image is traversed in a preset pixel scanning order; wherein the preset pixel scanning order is related to the positional relationship between the straight line and the circular arc contour corresponding to the product to be detected at the point of tangency; the positional relationship includes: a first positional relationship and a second positional relationship; the first positional relationship includes: the straight line contour of the product to be detected at the point of tangency is below the circular arc contour; the second positional relationship includes: the straight line contour of the product to be detected at the point of tangency is above the circular arc contour; Determine whether the grayscale value of each pixel is a transition pixel from the first grayscale value to the second grayscale value; If so, the transition pixel points from the first grayscale value to the second grayscale value are used to form the straight line arc segment pixel coordinates of the product to be cut, and the straight line arc segment pixel coordinates are used as the first pixel coordinates; If not, it is determined that the pixel point is not a transition pixel point.
2. The method according to claim 1, characterized in that: The determining of the second pixel coordinates having the same horizontal coordinate or the same vertical coordinate in the first pixel coordinates, the number of which reaches a preset proportion threshold, includes: Counting the total number of pixel coordinates of each of the first pixel coordinates; In the case where the positional relationship between the straight line and the arc contour corresponding to the product to be cut-off point detected is a first positional relationship, extract the ordinates corresponding to each of the first pixel coordinates, and divide the pixel coordinates with the same ordinate into the same first coordinate combination, and count the number of first coordinates with the same ordinate corresponding to each of the first coordinate combinations, and determine a first ratio of each of the first coordinate numbers to the total number of pixel coordinates according to the number of the first coordinates and the total number of pixel coordinates, and use the pixel coordinates whose first ratio reaches the preset proportion threshold as the second pixel coordinate; wherein the first coordinate combination includes at least two coordinate combinations, and each coordinate combination contains pixel coordinates with the same ordinate; When the positional relationship between the straight line and circular arc contour corresponding to the product to be detected at the tangent point is a second positional relationship, the horizontal coordinates corresponding to each of the first pixel coordinates are extracted, and the pixel coordinates with the same horizontal coordinate are divided into the same second coordinate combination, and the number of second coordinates with the same horizontal coordinate corresponding to each of the second coordinate combinations is counted, and the second ratio of each of the first coordinate numbers to the total number of pixel coordinates is determined according to the number of each of the second coordinates and the total number of pixel coordinates, and the pixel coordinates whose second ratio reaches the preset proportion threshold are used as the second pixel coordinates; wherein, the second coordinate combination includes at least two coordinate combinations, and each coordinate combination contains pixel coordinates with the same horizontal coordinate.
3. The method according to claim 2, characterized in that Determining a first ratio of each of the first coordinate numbers to the total pixel coordinate number according to each of the first coordinate numbers and the total pixel coordinate number includes: The ratios of the first coordinate numbers to the total pixel coordinate number are calculated, and the ratios are used as first ratios of the first coordinate numbers to the total pixel coordinate number.
4. The method according to claim 2, characterized in that Determining a second ratio of each of the first coordinate numbers to the total number of pixel coordinates according to each of the second coordinate numbers and the total number of pixel coordinates includes: The ratios of the numbers of the second coordinates to the total number of pixel coordinates are calculated, and the ratios are used as second ratios of the numbers of the second coordinates to the total number of pixel coordinates.
5. The method according to claim 1, characterized in that The step of obtaining a corresponding straight line equation based on the second pixel coordinate fitting includes: A preset least square method and each of the second pixel coordinates are used to fit a straight line equation.
6. The method according to claim 1, characterized in that The determining a third pixel coordinate associated with the second pixel coordinate comprises: When the positional relationship between the straight line and the arc contour corresponding to the product to be tangent point detected is a first positional relationship, traverse and search for a first target pixel coordinate whose ordinate is smaller than the second pixel coordinate in each of the first pixel coordinates, and use the first target pixel coordinate as the associated third pixel coordinate; When the positional relationship between the straight line and circular arc contour corresponding to the product to be detected at the tangent point is the second positional relationship, the second target pixel coordinate whose horizontal coordinate is smaller than the second pixel coordinate is traversed in each of the first pixel coordinates, and the second target pixel coordinate is used as the associated third pixel coordinate.
7. The method according to claim 1, characterized in that The determining of the tangent point coordinates based on the target pixel coordinates and the straight line equation includes: Determine the distances from each of the target pixel coordinates to the straight line equation, and obtain the pixel coordinates closest to the straight line equation from each of the distances; The pixel coordinates closest to the straight line equation are used as the tangent point coordinates.
8. A tangent point detection device with a straight line and arc image, characterized in that: include: An acquisition module is used to acquire an original image of the product to be cut-point detected, and to perform binarization processing on the original image to obtain a processed target image; wherein both the original image and the target image are characterized as the product to be cut-point detected having straight line and circular arc contour features; A first coordinate determination module, used to determine the straight line and circular arc segments composed of the straight line and circular arc contours corresponding to the product to be cut-point detected, and the first pixel coordinates corresponding to each pixel point in the straight line and circular arc segments based on the grayscale value of each pixel point in the target image; A fitting module, used to determine second pixel coordinates having the same horizontal coordinate or the same vertical coordinate in each of the first pixel coordinates, the proportion of which reaches a preset proportion threshold, and obtain a corresponding straight line equation based on the second pixel coordinates; a target coordinate determination module, configured to determine a third pixel coordinate associated with the second pixel coordinate, and remove the third pixel coordinate and the second pixel coordinate from the first pixel coordinate to obtain a remaining target pixel coordinate; A tangent point determination module, used to determine the tangent point pixel coordinates based on the target pixel coordinates and the straight line equation, and use the tangent point pixel coordinates as the reference point of the product to be inspected at the tangent point; Wherein, the first coordinate determination module includes: A pixel traversal unit, used to establish a rectangular coordinate system with the upper left corner of the target image as the origin, and traverse each pixel in the target image according to a preset pixel scanning order; wherein the preset pixel scanning order is related to the positional relationship between the straight line and the circular arc contour corresponding to the product to be detected at the tangent point; the positional relationship includes: a first positional relationship and a second positional relationship; the first positional relationship includes: the straight line contour of the product to be detected at the tangent point is below the circular arc contour; the second positional relationship includes: the straight line contour of the product to be detected at the tangent point is above the circular arc contour; A judging unit, used to judge whether the grayscale value of each pixel point is a transition pixel point from the first grayscale value to the second grayscale value; A pixel coordinate determination unit, for forming the pixel coordinates of the straight line and circular arc segment of the product to be cut-off point detected from the transition pixel points of the first grayscale value to the second grayscale value, and using the pixel coordinates of the straight line and circular arc segment as the first pixel coordinates; The non-transition pixel point determining unit is used to determine that the pixel point is not a transition pixel point if no.
9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the tangent point detection method for a straight line and circular arc image according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the tangent point detection method for an image with straight lines and circular arcs as described in any one of claims 1 to 7 when executed.
11. A computer program product, characterized in that The computer program product comprises a computer program, which, when executed by a processor, implements the method for detecting tangent points of an image with straight lines and circular arcs according to any one of claims 1 to 7.
Citation Information
Patent Citations
Follow-up grinding tool path with non-circular-profile curve revolution body, and smooth arc-shaped spliced numerical control program generating and processing method thereof
CN108445832A
Boundary detection method and related product
CN113034527A