Circle detection method, device, electronic device and storage medium
The method simplifies circle detection by using edge points near the circular pattern to fit a circle, reducing user input complexity and errors in the detection process.
Patent Information
- Application Number
- JP2024539659
- Authority / Receiving Office
- JP · JP
- Patent Type
- Patents
- Current Assignee / Owner
- Priority Date
- 2021-12-31
- Filing Date
- 2022-09-13
- Publication Date
- 2025-11-26
- Estimated Expiration
- 2042-09-13
AI Technical Summary
Conventional methods for recognizing circular patterns require multiple user inputs, such as placing reference points on the circle center and circumference, leading to complex and error-prone operations.
A method involving obtaining a target reference point near the edge of a circular pattern, performing edge extraction to get at least three edge points, and fitting a circle based on these points to simplify the detection process.
Simplifies the user operation by allowing circle detection through inputting points near the edge of a circular pattern, reducing errors and operational complexity.
Smart Images

Figure 0007776654000001 
Figure 0007776654000002 
Figure 0007776654000003
Abstract
Description
[Technical Field]
[0001] (CROSS-REFERENCE TO RELATED APPLICATIONS) This application claims priority to a Chinese patent application bearing application number 202111683480.2 and entitled "Circle detection method, device, electronic device and storage medium," filed with the State Intellectual Property Office of the People's Republic of China on December 31, 2021, the entire contents of which are incorporated herein by reference.
[0002] The present application relates to the field of information technology, and in particular to a circle detection method, device, electronic device and storage medium. [Background technology]
[0003] In the field of machine vision, by recognizing circular patterns, it is possible to perform positioning, measurement, etc. based on the recognition results. For example, the coordinate position of the recognized object is determined using the center of the circular pattern on the recognized object as a reference point.
[0004] However, conventional methods for recognizing circular patterns often require multiple user inputs, such as inputting the position of the circle center and inputting the radius of the circular pattern by dragging a mouse, to calculate the circular recognition target area, and then recognizing the circular pattern in the recognition target area, which results in complex operations. Summary of the Invention
[0005] The present embodiment aims to provide a circle detection method, device, electronic device, and storage medium to solve the problem of complicated operations in the circular pattern recognition process. The specific technical solutions are as follows:
[0006] As a first aspect of the present embodiment, Obtaining a target reference point in a recognition target image, wherein the recognition target image includes a circular pattern, and the target reference point is located within a preset range of an edge of the circular pattern; Performing edge extraction based on the target reference point to obtain at least three target edge points; and fitting a circle based on the at least three target edge points to obtain a fitted circle. A circle detection method is provided.
[0007] As a second aspect of the present embodiment, a reference point acquisition module for acquiring a target reference point in a recognition target image, the recognition target image including a circular pattern, and the target reference point being located within a preset range of an edge of the circular pattern; an edge point selection module for performing edge extraction based on the target reference point to obtain at least three target edge points; a circle fitting module that performs circle fitting based on the at least three target edge points to obtain a fitted circle. A circle detection device is provided.
[0008] As another aspect of the present embodiment, An electronic device including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other via the communication bus; The memory is used to store computer programs. The present invention further provides an electronic device that can be used to implement the steps of any of the above circle detection methods when the processor executes a program stored in the memory.
[0009] As another aspect of the present embodiment, There is further provided a computer-readable storage medium having a computer program stored thereon, the computer program implementing the steps of any of the circle detection methods described above when executed by a processor.
[0010] As another aspect of the present embodiment, There is further provided a computer program product comprising commands which, when executed on a computer, cause the computer to perform the steps of any of the circle detection methods described above.
[0011] The beneficial effects of the embodiments of the present application are as follows:
[0012] The circle detection method, device, electronic device, and storage medium provided in the present embodiment include: obtaining a target reference point in an image to be recognized, the image to be recognized including a circular pattern, the target reference point being located within a preset range of an edge of the circular pattern; performing edge extraction based on the target reference point to obtain at least three target edge points; and fitting a circle based on the at least three target edge points to obtain a fitted circle. In this way, the user only needs to input points near the edge of one circular pattern to achieve circle detection, simplifying the user's operation process.
[0013] Of course, it is not necessary for any product or method herein to be implemented to simultaneously achieve all of the above benefits. [Brief explanation of the drawings]
[0014] In order to more clearly explain the technical solutions of the embodiments of the present application and the prior art, the drawings necessary for the following embodiments and the prior art will be briefly described. Of course, the drawings described below are only a part of the embodiments of the present application, and those skilled in the art can obtain other embodiments based on these drawings without any creative work. [Figure 1] FIG. 1 is a process diagram of the circle detection method provided in the present embodiment. [Figure 2] FIG. 2 is a process diagram of the circle detection method provided in the present embodiment. [Figure 3] FIG. 3 is an example diagram of the circle detection method provided by the present embodiment. [Figure 4]FIG. 4 is a process diagram for generating a recognition target region provided in the present embodiment. [Figure 5] FIG. 5 is another example diagram of the circle detection method provided by the embodiment of the present application. [Figure 6] FIG. 6 is a schematic diagram of the configuration of a circle detection device provided in the present embodiment. [Figure 7] FIG. 7 is a schematic diagram showing the configuration of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION OF THE INVENTION
[0015] In order to clarify the objectives, technical solutions and advantages of the present invention, the present invention will be described in more detail below with reference to the drawings and examples. It is clear that the described examples are only some of the examples of the present invention, and do not represent all of the examples. Based on the examples of the present invention, all other examples that can be obtained by those skilled in the art without any creative effort are all included in the protection scope of the present invention.
[0016] First, the terms used in the examples of the present application will be explained. Single point: A single point in pixel coordinates. Circle detection: The specific position of a circle is determined, and the center position and radius length of the circle are displayed. ROI (region of interest): A defined area in which an algorithm performs operations. Detection points: points around the circumference provided by the user, used to detect the circle. Chessboard distance: The maximum value of the absolute difference between the abscissa and ordinate of two pixel points. RANSAC (Random Sample Consensus Algorithm): Iteratively estimates the parameters of a mathematical model from a set of observed data that may contain outliers.
[0017] In order to solve the problem of the conventional technology that the user needs to input multiple times when recognizing a circular pattern, and the operation is complicated, As a first aspect of the present embodiment, Obtaining a target reference point in a recognition target image, where the recognition target image includes a circular pattern, and the target reference point is located within a preset range of an edge of the circular pattern (i.e., a circumference of the circular pattern); Performing edge extraction based on the target reference point to obtain at least three target edge points; fitting a circle based on the at least three target edge points to obtain a fitted circle. A circle detection method is provided.
[0018] As can be seen, the method of the present embodiment allows the user to realize circle detection by simply inputting points near the edge of one circular pattern, which simplifies the user's operation process.
[0019] Specifically, referring to FIG. 1, FIG. 1 is a process diagram of a circle detection method provided in an embodiment of the present application, and the circle detection method includes the following steps:
[0020] Step S11: obtain a target reference point in the recognition target image.
[0021] In the present embodiment, the image to be recognized includes a circular pattern, and the target reference point may be a single point, input by a user. Specifically, a point may be added as a reference point on the image to be recognized by touch operation or a mouse, or the coordinate position of the reference point may be input by a keyboard. When the method of the present embodiment is applied to a device such as a smartphone, the target reference point may be selected by a user's touch operation, etc. In practical use, the user may input a point near the edge of a circular pattern as the target reference point. Specifically, this point may be on the edge, or may not be on the edge. In practical use, the target reference point may be located on the edge of the circular pattern to be recognized, or may be located within a preset range of the edge of the circular pattern to be recognized. This preset range may be preset, and specifically, this preset range may include both the target reference point and a point on the edge of the circular pattern.
[0022] In conventional methods, the process of detecting a circle typically requires placing reference points on the circle center and circumference, determining the circle center coordinates and radius, and then detecting the circle based on the determined circle center and radius. However, users often fail to accurately place the reference point on the circle center due to operational errors, which often requires multiple operations, resulting in complex operations and errors. The method of the present embodiment simplifies the operation process and improves the user experience by simply placing the reference point within a preset range on the circumference.
[0023] The method of the present embodiment can be applied to and implemented by an intelligent terminal, which can be a computer, a mobile phone, a server, an intelligent camera, etc.
[0024] Step S12: Extracting edges based on the target reference points to obtain at least three target edge points.
[0025] The image to be recognized includes a circular pattern, and the target reference point is located within a preset range of the edge of the circular pattern (i.e., the circumference of the circular pattern). Specifically, this preset range may be a first preset range. Preferably, performing edge extraction based on the target reference point to obtain at least three target edge points includes: performing pixel gradient recognition on each pixel point within a first preset range around the target reference point in the image to be recognized to obtain a first edge point, where the pixel gradient of the first edge point is greater than a preset gradient threshold; performing pixel gradient recognition on each pixel point within a second preset range around the first edge point to obtain a plurality of second edge points; and obtaining at least three target edge points from the first edge point and the plurality of second edge points. Preferably, performing edge extraction based on the target reference point to obtain at least three target edge points includes receiving target area information from a user, where the target area information includes the size and position of the target area input by the user; and performing edge extraction in the target area based on the target reference point to obtain at least three target edge points.
[0026] A first edge point is obtained by performing pixel gradient recognition on each pixel point within a first preset range around the target reference point in the recognition target image. The pixel gradient of the first edge point is greater than a preset gradient threshold. In this embodiment, performing pixel gradient recognition on each pixel point within the first preset range around the target reference point in the recognition target image can involve using a preset detection algorithm to recognize pixel values for each pixel point within the first preset range around the target reference point in the recognition target image, and then calculating pixel gradients corresponding to these pixel points based on the recognized pixel values. In practical use, the pixel gradient of each pixel point can be calculated by calculating a Sobel operator. Specifically, this preset detection algorithm can be any edge point detection algorithm, such as the Canny algorithm (edge detection algorithm). In one example, performing pixel gradient recognition on each pixel point within the first preset range around the target reference point in the recognition target image can involve sequentially searching for pixel points with checkerboard distances of 0, 1, 2, etc. from the target reference point until a first edge point is obtained, and determining whether they are edge points. The first edge point may include multiple pixel points.
[0027] The size of the first preset range may be set according to actual circumstances. In one example, the smaller the range of the circle to be recognized, the smaller the first preset range should be, and the larger the range of the circle to be recognized, the larger the first preset range should be. For example, if the range of the image to be recognized is large but the range of the circular pattern to be recognized is small, the first preset range can be set to recognize points within a small range around the target reference point. This not only allows edge points to be detected quickly, but also reduces the amount of working memory and calculation. If the range of the circular pattern to be recognized is large, a larger range around the target reference point should be recognized.
[0028] Preferably, performing pixel gradient recognition on each pixel point within a first preset range around the target reference point in the recognition-target image to obtain the first edge point comprises performing pixel gradient recognition on each pixel point in a plurality of preset directions within the first preset range around the target reference point in the recognition-target image to obtain the first edge point. Preferably, performing pixel gradient recognition on each pixel point in a plurality of preset directions within the first preset range around the target reference point in the recognition-target image to obtain the first edge point comprises selecting a direction every preset angle based on the preset reference direction within the first preset range around the target reference point in the recognition-target image to obtain a plurality of target directions, and performing pixel gradient recognition on each pixel point in the preset reference direction and the plurality of target directions to obtain the first edge point. In one example, the preset directions may refer to one or more of four directions, namely, up, down, left, and right of the target reference point, and four directions at 45° intervals from the above four directions, for a total of eight directions.
[0029] A plurality of second edge points are obtained by performing pixel gradient recognition on each pixel point within a second preset range around the first edge point. The size of the second preset range may be the same as or different from the size of the first preset range. When detecting the plurality of second edge points within the second preset range around the first edge point, other edge points on the circumferential contour may be searched starting from the first edge point. When searching, all edge points may be searched so that the edge points are evenly distributed at each position on the circumference. The pixel gradient recognition on each pixel point within the second preset range around the first edge point may be performed using any of the above edge point detection algorithms, such as the Canny algorithm.
[0030] Preferably, performing pixel gradient recognition on each pixel point within a second preset range around the first edge point to obtain a plurality of second edge points includes performing pixel gradient recognition on each pixel point in a clockwise direction and a counterclockwise direction around the first edge point within the second preset range around the first edge point to obtain a plurality of second edge points. When the radius of the circular pattern is large, sampling these edge points and only retaining the sampled edge points can reduce memory consumption and subsequent calculations.
[0031] At least three target edge points are selected from the first edge point and the plurality of second edge points. When fitting a circle, at least three edge points are required to fit the circle. Therefore, after obtaining the first edge point and the plurality of edge points, it is necessary to select three edge points to fit the circle. The selected at least three target edge points may be the first edge point and the plurality of second edge points, or may be at least three edge points among the second edge points. Selecting the at least three target edge points from the first edge point and the plurality of second edge points may involve randomly selecting three edge points from the first edge point and the plurality of second edge points as the target edge points.
[0032] Step S13: fitting a circle based on at least three target edge points to obtain a fitted circle.
[0033] The fitting of a circle based on at least three target edge points can be performed using a plurality of preset circle fitting methods, such as the least squares method or the least squares method based on RANSAC, to obtain the fitted circle and circle fitting parameters, such as the radius and circle center coordinates, which are used as parameters of the circular pattern in the image to be recognized.
[0034] When selecting at least three edge points from the first edge points and the plurality of second edge points as target edge points, the at least three edge points may be selected from the first edge points and the plurality of second edge points using a downsampling method. Preferably, selecting at least three target edge points from the first edge points and the plurality of second edge points includes downsampling the plurality of second edge points to obtain at least three third sampled edge points, and fitting a circle based on the at least three target edge points to obtain the fitted circle includes fitting a circle based on the at least three third sampled edge points to obtain the fitted circle. Because the number of downsampled third edge points is smaller than the number of second edge points, downsampling may be performed based on the distance between the third edge points so that the sampled third edge points are distributed as evenly as possible on the fitted circle. Therefore, downsampling can reduce the number of second edge points to be calculated and stored, thereby reducing memory consumption and the amount of subsequent calculations and improving fitting efficiency.
[0035] As can be seen, the method of the present embodiment allows the user to automatically recognize a first edge point and multiple second edge points by simply inputting one target reference point. By recognizing the first edge point and the second edge point, a circle is fitted and the parameters of the circle in the image to be recognized are obtained, which simplifies the user's operation process.
[0036] Preferably, referring to FIG. 2 , the parameters of the fitted circle include the position coordinates of the fitted circle, and after fitting the circle based on at least three target edge points to obtain the fitted circle, the method further includes the following steps:
[0037] In step S21, a recognition target area is generated based on the position coordinates of the fitted circle. Step S22: Recognizing a circle in the recognition target area to obtain a recognition result, which includes parameters of the recognized circle.
[0038] Preferably, the position coordinates of the fitted circle include the coordinates of the center of the fitted circle and the radius of the fitted circle, and generating the recognition target area based on the position coordinates of the fitted circle includes calculating and acquiring feature parameters of the recognition target area of the preset shape to be generated based on the radius of the fitted circle, where the preset shape is circular or rectangular and the feature parameters are the radius of the circle or the length and width of the rectangle, and generating the recognition target area using the coordinates of the center of the fitted circle as the center of the recognition target area to be generated. When calculating and acquiring the feature parameters of the recognition target area of the preset shape to be generated based on the radius of the fitted circle, the recognition target area of the preset shape to be generated may include the entire fitted circle. For example, if the preset shape is circular, the radius of the circle corresponding to the recognition target area of the preset shape may be larger than the radius of the fitted circle. For example, if the radius of the fitting circle is 4, the radius of the circle corresponding to the recognition target area of the calculated and acquired preset shape may be 5. For example, if the radius of the fitting circle is 4, the length and width of the rectangle corresponding to the recognition target area of the preset shape calculated and obtained may both be greater than twice the radius of this fitting circle; for example, if the radius of the fitting circle is 4, the length and width of the rectangle corresponding to the recognition target area of the preset shape may be 9 and 10.
[0039] The target region may be a region of various shapes, for example, the target region may be a circle, annulus, square, rectangle, etc. When generating the target region, the range of the target region should include the range of the circular pattern in the target image.
[0040] Preferably, performing circle recognition in the recognition target area to obtain a recognition result includes comparing the area of the recognition target area with that of the fitted circle; generating an updated recognition target area based on the target reference point and the size of the preset area if the ratio of the area of the recognition target area to that of the fitted circle is greater than a preset threshold; and performing circle recognition in the updated recognition target area to obtain a recognition result. In one example, the smaller the area of the circle to be recognized, the smaller the first preset range should be; and the larger the area of the circle to be recognized, the larger the first preset range should be. For example, if the area of the recognition target image is large but the area of the circular pattern to be recognized is small, setting the first preset range only allows points within a small range around the target reference point to be recognized. This allows for quick detection of edge points and reduces working memory and calculation load. If the area of the circular pattern to be recognized is large, a larger range around the target reference point should be recognized.
[0041] In the present embodiment, when a circular pattern is recognized in a recognition target area by a preset recognition method, the preset recognition method may be a method for performing multiple types of image recognition, such as RANSAC, etc. In the present embodiment, referring to FIG. 3, after an ROI is generated based on parameters of the circular pattern, more accurate circle detection may be performed in the ROI.
[0042] As can be seen from this, the method of the present embodiment generates a recognition target area based on the position coordinates of the fitted circle, and then recognizes the circle in the recognition target area to obtain a recognition result. This not only allows the recognition of a circular pattern in the recognition target area to obtain a recognition result and improve the accuracy of the parameters of the recognized circle, but also allows the circle to be detected in the recognition target area by selecting the recognition area, eliminating the need to perform detection in the entire image, thereby reducing the amount of calculation and improving calculation efficiency.
[0043] Preferably, referring to FIG. 4 , the position coordinates of the fitted circle include the center coordinates of the fitted circle and the radius of the fitted circle, and generating the recognition target area based on the position coordinates of the fitted circle includes the following steps: In step S211, the inner and outer diameters of the annular recognition target region are calculated and acquired based on the coordinates of the center of the fitted circle and the radius of the fitted circle. In step S212, a circular recognition target area is generated based on the feature parameters, with the center coordinate of the fitted circle as the center, and based on the inner and outer diameters of the circular recognition target area.
[0044] In step S22, performing circle recognition in the recognition target area and obtaining a recognition result includes the following steps. In step S221, a circle is recognized in a circular recognition target area, and a recognition result is obtained.
[0045] Preferably, calculating and obtaining the inner and outer diameters of the annular recognition target area based on the coordinates of the center of the fitted circle and the radius of the fitted circle includes calculating the sum of the radius of the fitted circle and the width of the preset annular area to obtain the outer diameter of the recognition target area, and calculating the difference between the radius of the fitted circle and the width of the preset annular area to obtain the inner diameter of the recognition target area.
[0046] Calculating and obtaining the inner and outer diameters of the toroidal region to be generated based on the radius of the circular pattern and the preset length can be done by subtracting a preset value from the radius of the circular pattern to obtain the inner diameter of the toroidal region to be generated, and adding this preset value to the radius of the circular pattern to obtain the outer diameter of the toroidal region to be generated. Specifically, this preset value can be set according to actual conditions. In one example, the magnitude of this preset value corresponds to the radius of the circle, and the larger the radius of the circle, the larger this preset value can be, and the smaller the radius of the circle, the smaller this preset value can be. Then, a toroidal region to be recognized is generated based on the inner and outer diameters of the toroidal region to be recognized, with the center coordinates of the fitted circle as the center. In this embodiment, the generated toroidal region includes all edge points of the circular pattern.
[0047] Recognizing a circle in a circular target area and obtaining a recognition result may be performed by using the preset recognition method described above to recognize a circular pattern in a circular target area and obtaining a recognition result. Specifically, the circular pattern may be recognized in a circular target area using an image recognition method such as the RANSAC method described above. In the present embodiment, the recognition result may include parameters such as the radius of the circle and the coordinates of the circle center. The circular target area includes all edge points of the circular pattern, and since the area of the circular target area is small and the area to be recognized is small, recognition efficiency is improved.
[0048] As can be seen, the method of the present embodiment can calculate and obtain the inner and outer diameters of a circular recognition target area based on the coordinates of the center of the fitted circle and the radius of the fitted circle, generate a circular recognition target area based on the inner and outer diameters of the circular recognition target area with the coordinates of the center of the fitted circle as the center, and recognize a circle in the circular recognition target area to obtain a recognition result, thereby reducing the area to be recognized and improving recognition efficiency.
[0049] Referring to FIG. 5, FIG. 5 is another example diagram of a circle detection method provided in an embodiment of the present application, which includes the following steps: 1. Setting up detection points near the circumference: In this application, the detection points are located near the circumference of the circular pattern. 2. Perform edge extraction on the image. If the image to be detected is large, but the diameter of the circle to be detected is small and occupies only a small part of the entire image area, it is possible to extract only the area around the detection point set by the user to reduce the working memory and calculation amount. 3. Search for the nearest edge point. Specifically, search for points whose checkerboard distance from the detected point is 0, 1, 2, etc. sequentially, or search along eight fixed directions (the interval between two adjacent directions is 45°) to obtain points on the circumference. 4. Search for other edge points along the edge. Search in two directions, clockwise and counterclockwise, and save the found edge points. Preferably, if the radius of the circle being searched is large, these edge points can be sampled and only the sampled edge points can be saved, which can reduce memory consumption and subsequent calculations. 5. Circle fitting is performed on the edge points. Circle fitting is performed on the reserved edge points. During circle fitting, several different methods may be adopted, such as least squares or least squares based on RANSAC, and finally, a circle is detected by this single point.
[0050] As a second embodiment of the present invention, referring to FIG. a reference point acquisition module 601 for acquiring a target reference point in a recognition target image, wherein the recognition target image includes a circular pattern, and the target reference point is located within a preset range of an edge of the circular pattern; an edge point selection module 602 for performing edge extraction based on the target reference point to obtain at least three target edge points; a circle fitting module 603 for fitting a circle based on the at least three target edge points to obtain a fitted circle. A circle detection device is provided.
[0051] Preferably, the edge point selection module 602: a first edge point detection module for performing pixel gradient recognition on each pixel point within a first preset range around a target reference point in the recognition target image to obtain a first edge point, where the pixel gradient of the first edge point is greater than a preset gradient threshold; a second edge point detection module for performing pixel gradient recognition on each pixel point within a second preset range around the first edge point to obtain a plurality of second edge points; a target edge point acquisition module that selects at least three target edge points from the first edge point and the plurality of second edge points.
[0052] Preferably, the parameters of the fitted circle include position coordinates of the fitted circle, and the circle detection device a recognition target area generation module that generates a recognition target area based on the position coordinates of the fitted circle; The recognition target area recognition module further includes a recognition target area recognition module that recognizes a circle in the recognition target area and obtains a recognition result, the recognition result including parameters of the recognized circle.
[0053] Preferably, the position coordinates of the fitted circle include the coordinates of the center of the fitted circle and the radius of the fitted circle, and the recognition target region generation module: a feature parameter calculation module that calculates and obtains feature parameters of a recognition target region of a preset shape to be generated based on the radius of the fitted circle, the preset shape being a circle or a rectangle, and the feature parameters being the radius of the circle or the length and width of the rectangle; The recognition target region generating system includes a feature parameter generating module that generates a recognition target region based on the feature parameters, with the coordinates of the center of the fitted circle set as the center of the recognition target region to be generated.
[0054] Preferably, the position coordinates of the fitted circle include the coordinates of the center of the fitted circle and the radius of the fitted circle, and the recognition target region generation module: an inner / outer diameter calculation submodule that calculates and obtains inner and outer diameters of the annular recognition target region based on the center coordinates of the fitted circle and the radius of the fitted circle; a circular region generation submodule that generates a circular recognition target region based on an inner radius and an outer radius of the circular recognition target region, with the center coordinate of the fitted circle as the center; and a recognition target area recognition module that recognizes a circle in the annular recognition target area and obtains a recognition result.
[0055] Preferably, the inner / outer diameter calculation submodule is used to calculate the sum of the radius of the fitted circle and the width of the preset annular region to obtain the outer diameter of the recognition target region, and to calculate the difference between the radius of the fitted circle and the width of the preset annular region to obtain the inner diameter of the recognition target region.
[0056] Preferably, the second edge point detection module is used to perform pixel gradient recognition for each pixel point in a clockwise direction and a counterclockwise direction of the first edge point within a second preset range around the first edge point to obtain a plurality of second edge points.
[0057] Preferably, the first edge point detection module is used to perform pixel gradient recognition on each pixel point in a plurality of preset directions within a first preset range around the target reference point in the recognition target image to obtain a first edge point.
[0058] Preferably, the first edge point detection module: a direction selection submodule for selecting one direction at every preset angle based on the preset reference direction within a first preset range around a target reference point in the recognition target image, thereby obtaining a plurality of target directions; and a pixel recognition sub-module for performing pixel gradient recognition on each pixel point in the preset reference direction and the plurality of target directions to obtain a first edge point.
[0059] Preferably, the target edge point acquisition module is used for down-sampling the plurality of second edge points to obtain at least three third sampled edge points; The circle fitting module is used for fitting a circle based on at least three third sampling edge points to obtain a fitted circle.
[0060] Preferably, the recognition target area recognition module an area comparison submodule that compares the area of the recognition target region with the fitted circle; a region update submodule for generating an updated recognition target region based on the target reference point and the preset region size when the area ratio between the recognition target region and the fitted circle is greater than a preset threshold; and an updated region recognition sub-module for performing circle recognition in the updated recognition target region to obtain a recognition result.
[0061] Preferably, the edge point selection module 602: an area information receiving sub-module for receiving user recognition target area information, the recognition target area information including the size and position of the recognition target area input by the user; and a region edge extraction sub-module for performing edge extraction in the recognition target region based on the target reference point to obtain at least three target edge points.
[0062] As can be seen from this, the circle detection device of the embodiment of the present application can achieve circle detection by the user simply inputting a point near the edge of one circular pattern, which simplifies the user's operation process.
[0063] 7, an embodiment of the present application further provides an electronic device, the electronic device including a processor 701, a communication interface 702, a memory 703, and a communication bus 704, the processor 701, the communication interface 702, and the memory 703 communicating with each other via the communication bus 704; The memory 703 is used to store computer programs. When the processor 701 executes a program stored in the memory 703, Obtaining a target reference point in a recognition target image, the recognition target image including a circular pattern, the target reference point being a point whose distance from an edge of the circular pattern is less than a preset distance threshold; Performing edge extraction based on the target reference point to obtain at least three target edge points; and performing circle fitting based on at least three target edge points to obtain a fitted circle.
[0064] The communication bus mentioned in the above electronic device may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus is divided into an address bus, a data bus, a control bus, etc. For convenience of illustration, only one thick line is shown in the drawing, but this does not mean that there is only one bus or only one type of bus.
[0065] The communication interface is used for communication between the electronic device and other devices.
[0066] The memory may include random access memory (RAM) or non-volatile memory (NVM), such as at least one magnetic disk memory. Preferably, the memory may also be at least one storage device remote from the processor.
[0067] The processors described above may be general-purpose processors including a central processing unit (CPU), a network processor (NP), etc., or may be general-purpose processors including a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic device, a discrete gate or transistor logic device, or a discrete hardware assembly.
[0068] In a further embodiment of the present application, there is further provided a computer-readable storage medium having a computer program stored therein, the computer program causing, when executed by a processor, the computer program to perform the steps of any one of the circle detection methods described above.
[0069] In a further embodiment of the present application, there is further provided a computer program product including commands, which, when executed on a computer, cause the computer to implement any of the circle detection methods in the above embodiments.
[0070] The above embodiments can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, they can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer commands. When the computer program commands are loaded into a computer and executed, the flow or function described in the embodiments of the present application can be implemented in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other rewritable device. The computer commands can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer commands can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wire (e.g., coaxial cable, fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, radio, microwave, etc.). The computer-readable storage medium can be any available medium that a computer can read and write, or it can be a data storage device, including a server, data center, etc., that integrates one or more available media. The available media may be magnetic media (e.g., floppy disks, hard disks, tapes), optical media (e.g., DVDs), or semiconductor media (e.g., solid state disks (SSDs)).
[0071] It should be noted that, in this context, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another and do not require or imply any actual relationship or order between those entities or operations. Furthermore, the terms "comprise," "include," "includes," or any other variant thereof, mean a non-exclusive "comprise." Thus, a process, method, product, or device comprising a set of elements does not include only those elements, but also other elements not expressly listed, or elements inherent in such process, method, product, or device. Absent further limitations, an element limited by a phrase "comprising ..." does not exclude the presence of other identical elements in a process, method, product, or device that includes the recited element.
[0072] The embodiments in this specification are described in a related manner, and identical or similar parts between the embodiments may be cross-referenced. The emphasis in each embodiment is on the differences from other embodiments. In particular, the embodiments of the device, electronic device, storage medium, and computer program product are basically similar to the method embodiments, and therefore only briefly described. For related parts, please refer to the description of the method embodiments.
[0073] The above description is merely a preferred embodiment of the present application, and is not intended to limit the scope of protection of the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present application shall be included in the scope of protection of the present application.
Claims
1. A method for obtaining a target reference point in a recognition target image input by a user, wherein the recognition target image includes a circular pattern, and the target reference point is located within a preset range of an edge of the circular pattern; performing edge extraction based on the target reference point to obtain at least three target edge points; fitting a circle based on the at least three target edge points to obtain a fitted circle; performing edge extraction based on the target reference point to obtain at least three target edge points; Performing pixel gradient recognition on each pixel point within a first preset range around the target reference point in the recognition target image to obtain a first edge point, where the pixel gradient of the first edge point is greater than a preset gradient threshold; performing pixel gradient recognition on each pixel point within a second preset range around the first edge point to obtain a plurality of second edge points; selecting at least three target edge points from the first edge point and the plurality of second edge points. Circle detection method.
2. 2. The circle detection method according to claim 1, the parameters of the fitted circle include position coordinates of the fitted circle; After performing circle fitting based on the at least three target edge points to obtain a fitted circle, the circle detection method includes: generating a recognition target area based on the position coordinates of the fitted circle; performing circle recognition in the recognition target area to obtain a recognition result, the recognition result including parameters of the recognized circle. Circle detection method.
3. 3. The circle detection method according to claim 2, further comprising: the position coordinates of the fitted circle include the coordinates of the center of the fitted circle and the radius of the fitted circle; generating a recognition target region based on the position coordinates of the fitted circle, Calculating and acquiring feature parameters of a recognition target area of a preset shape to be generated based on the radius of the fitted circle, the preset shape being a circle or a rectangle, and the feature parameters being the radius of the circle or the length and width of the rectangle; and generating a recognition target area based on the feature parameters, with the coordinates of the center of the fitted circle set as the center of the recognition target area to be generated. Circle detection method.
4. 3. The circle detection method according to claim 2, further comprising: the position coordinates of the fitted circle include the coordinates of the center of the fitted circle and the radius of the fitted circle; generating a recognition target region based on the position coordinates of the fitted circle, calculating and acquiring an inner radius and an outer radius of a circular recognition target area based on the coordinates of the center of the fitted circle and the radius of the fitted circle; generating a circular recognition target region based on an inner diameter and an outer diameter of the circular recognition target region, with the center coordinate of the fitted circle as the center. Recognizing a circle in the recognition target area and obtaining a recognition result includes: and performing circle recognition in the annular recognition target area to obtain a recognition result. Circle detection method.
5. 5. The circle detection method according to claim 4, further comprising: Calculating and acquiring an inner radius and an outer radius of a circular recognition target region based on the coordinates of the center of the fitted circle and the radius of the fitted circle, Calculating the sum of the radius of the fitted circle and the width of a preset annular region to obtain the outer diameter of the recognition target region, and calculating the difference between the radius of the fitted circle and the width of the preset annular region to obtain the inner diameter of the recognition target region. Circle detection method.
6. 2. The circle detection method according to claim 1, performing pixel gradient recognition on each pixel point within a second preset range around the first edge point to obtain a plurality of second edge points; and performing pixel gradient recognition on each pixel point in a clockwise direction and a counterclockwise direction of the first edge point within a second preset range around the first edge point to obtain the plurality of second edge points. Circle detection method.
7. 2. The circle detection method according to claim 1, performing pixel gradient recognition on each pixel point within a first preset range around a target reference point in the recognition target image to obtain a first edge point; and performing pixel gradient recognition on each pixel point in a plurality of preset directions within a first preset range around the target reference point in the recognition target image to obtain a first edge point. Circle detection method.
8. 8. The circle detection method according to claim 7, further comprising: performing pixel gradient recognition on each pixel point in a plurality of preset directions within a first preset range around a target reference point in the recognition target image to obtain a first edge point; Selecting a direction every preset angle based on a preset reference direction within a first preset range around a target reference point in the recognition target image to obtain a plurality of target directions; performing pixel gradient recognition for each pixel point in the preset reference direction and the plurality of target directions to obtain a first edge point. Circle detection method.
9. 2. The circle detection method according to claim 1, Selecting at least three target edge points from the first edge point and the plurality of second edge points includes: downsampling the plurality of second edge points to obtain at least three third sampled edge points; Fitting a circle based on the at least three target edge points to obtain a fitted circle includes: and fitting a circle based on the at least three third sampled edge points to obtain the fitted circle. Circle detection method.
10. 3. The circle detection method according to claim 2, further comprising: Recognizing a circle in the recognition target area and obtaining a recognition result includes: comparing the area of the recognition target region with the area of the fitted circle; If the ratio of the area of the recognition target region to the fitted circle is greater than a preset threshold, generating an updated recognition target region based on the target reference point and a preset region size; and performing circle recognition in the updated recognition target area to obtain a recognition result. Circle detection method.
11. 2. The circle detection method according to claim 1, performing edge extraction based on the target reference point to obtain at least three target edge points; receiving user recognition target area information, the recognition target area information including the size and position of the recognition target area input by the user; and performing edge extraction in the recognition target area using the target reference point as a reference to obtain at least three target edge points. Circle detection method.
12. A reference point acquisition module that acquires a target reference point in a recognition target image input by a user, wherein the recognition target image includes a circular pattern, and the target reference point is located within a preset range of an edge of the circular pattern; a first edge point detection module for performing pixel gradient recognition on each pixel point within a first preset range around a target reference point in the recognition target image to obtain a first edge point, where the pixel gradient of the first edge point is greater than a preset gradient threshold; a second edge point detection module for performing pixel gradient recognition on each pixel point within a second preset range around the first edge point to obtain a plurality of second edge points; a target edge point acquisition module that selects at least three target edge points from the first edge point and the plurality of second edge points; a circle fitting module that performs circle fitting based on the at least three target edge points to obtain a fitted circle. Circle detector.
13. An electronic device including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other via the communication bus; The memory is used to store computer programs. An electronic device, wherein a processor is used to implement the steps of the circle detection method according to any one of claims 1 to 11 when the processor executes a program stored in a memory.
14. A computer-readable storage medium having stored thereon a computer program, the computer program implementing the steps of the circle detection method according to any one of claims 1 to 11 when executed by a processor.
Citation Information
Patent Citations
Circle detection method and device
CN102236894A
Cover defect detection method based on image processing
CN106251352A
Image processing apparatus, image processing method, image processing program, and defect detection apparatus
JP2011227748A
Image identification device, method, and program
JP2021096652A