A method and system for detecting circular contour of display screen
By performing contour tracking, analysis, filtering and merging in display circular contour detection, combined with ellipse fitting and circumscribed rectangle filtering, the problem of image binary noise interference and unclear edge extraction thresholds is solved, achieving high accuracy. and high-reliability contour detection.
Patent Information
- Application Number
- CN202410367688.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-28
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2044-03-28
AI Technical Summary
In the existing display circular contour detection technology, the lack of preprocessing during image binarization leads to noise interference, the strong and weak edge threshold settings are unclear during edge extraction, and the segmentation edge points are not accurately determined, which affects the accuracy and reliability of contour extraction. .
Acquire images by setting the detection area, perform contour tracking and analysis, filter and merge contours, calculate attribute parameters, and use ellipse fitting and circumscribed rectangle filtering to determine the authenticity and closure of the contour.
It improves the accuracy and reliability of contour extraction, reduces misjudgments, enhances the sealing of the contour, improves the accuracy and speed of detection, and ensures the reliability of detection.
Smart Images

Figure CN117994248B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of computer vision detection, and in particular relates to a method and system for detecting the circular contour of a display screen. Background Art
[0002] Computer vision detection has been widely used in the field of object detection. Because computer vision detection technology has the advantages of fast, efficient, high precision and integration, it has gradually become the main method of detection in various industries. It has been widely used in display screen defect detection, circuit board defect detection, workpiece defect detection and other fields. Invention patent application number CN202011127328.1 discloses a minimum independent contour segmentation and extraction method, device and computer equipment in an image. By analyzing the image to be processed, a binary image containing edge information is obtained, and then the edge lines in the binary image are closed to link the broken edge lines, and finally the processed binary image is obtained. The processed binary image is traversed in turn to find the segmentation edge points and the segmentation starting direction in the processed binary image. The minimum independent contour is extracted from the processed binary image with the segmentation edge points found as the starting point and according to the segmentation starting direction.
[0003] The shortcomings of the above invention patent are: first, when the image is binarized, the image is not preprocessed, and noise will cause interference, affecting the accuracy of contour extraction. Secondly, the method of extracting edges using the Canny method does not mention how to set the thresholds for the strong and weak edges of the extracted edges, and the accuracy of the implementation plan results is questionable. Then, after the edge is extracted, the extracted edge image is binarized. The focus of binarization is how to determine the set threshold for binarization. The above invention patent does not mention it, and the reliability of the implementation plan is unclear. Finally, the patent for segmenting edge points only mentions an example of a situation, that is, when there is a maximum value node on each side of the current point, the current point is the segmentation point. If one of the maximum points is on the left or right side, and the other maximum point is above or below, how to determine the segmentation point is not explained in the above invention patent. Summary of the invention
[0004] Based on the shortcomings of the current circular contour detection of display screens, the present invention proposes a method for circular contour detection of display screens. The present invention first obtains an image of the contour area according to the set detection area; then extracts the contour of the contour detection area through contour tracking and analysis; filters the extracted contour to retain the valid contour; finally, merges the filtered contours and calculates the attribute parameters of the new contour.
[0005] Specifically, the present invention provides a method for detecting a circular contour of a display screen, comprising the following steps:
[0006] Acquire an image of the contour detection area according to the set detection area;
[0007] Extracting the contour of the contour detection area through contour tracking and analysis;
[0008] Filter the extracted contours and retain the valid contours;
[0009] Merge the filtered contours and calculate the attribute parameters of the merged contours.
[0010] Furthermore, the process of obtaining an image of the contour detection area according to the set detection area is as follows:
[0011] The display screen is divided into a visible area and a non-visible area. The middle part of the display screen is the visible area, and the rest is the non-visible area. The non-visible area is in the top, bottom, left and right areas of the visible area. The circular hole is in the bottom non-visible area. The circular hole is a circular button of the display screen. After the camera collects the image, the detection image of the bottom non-visible area, the top non-visible area image, the left non-visible area image, and the right non-visible area image are obtained according to the set detection area range.
[0012] Furthermore, the process of extracting the contour of the contour detection area by contour tracking and analysis is as follows:
[0013] C) Contour tracking: Start the search from the last line of the image in the bottom non-visible area, take the current point as the starting point, search for adjacent points near the starting point, and search for adjacent points in two cases according to the size relationship between the current pixel gray value and the set threshold;
[0014] During the search process, the searched pixels are recorded, and the searched pixels are no longer searched. When the first row is searched, the search is stopped.
[0015] D) Contour analysis: The extracted contours are classified. If the number of extracted contour pixels is less than the set number of pixels, all contours that meet the condition are recorded.
[0016] Furthermore, in the first case of the contour tracking, under the condition that the grayscale value of the current pixel is less than the set threshold, the search is divided into two conditions, A and B; the A condition is that the grayscale value of the pixel in the previous row and next column of the current pixel is less than the set threshold, and the B condition is that the grayscale value of the pixel in the previous row and next column of the current pixel is greater than or equal to the set threshold;
[0017] Under condition A, if the grayscale value of the pixel in the previous row and the next column of the current pixel is less than the set threshold, two cases are considered: first, if the grayscale value of the pixel in the previous row and the current column is less than the set threshold, the left boundary is found, the search position is updated, and the search starts from the previous row and the next column; second, if the grayscale value of the pixel in the previous row and the current column is greater than or equal to the set threshold, the equivalent point is calculated, that is, the ratio relationship between the grayscale values of the current pixel and its adjacent pixels is obtained; two vertical equivalent points are calculated, and the two equivalent points are compared, and the search position is determined by the value relationship of the two equivalent points; the first equivalent point calculation process is: the difference between the set threshold and the current pixel grayscale value is calculated as M1, and the difference between the grayscale value of the pixel in the previous row and the current pixel grayscale value is N1, and the ratio of the two is M1 / N1, and the ratio is recorded as T1; the second equivalent point calculation process is: the difference between the set threshold and the current row and the next column is calculated as M1 / N1. The difference in the grayscale value of the column pixel is M2, the difference in the grayscale value of the pixel in the next column of the previous row and the grayscale value of the pixel in the next column of the current row is N2, the ratio of the two is M2 / N2, and the ratio is recorded as T2; after calculating the two equivalent points, compare them. If T1 is less than T2, find the right boundary and start searching from the previous row; if T1 is greater than T2, find the left boundary and start searching from the next column of the previous row; if T1 is equal to T2, it is necessary to calculate another vertical equivalent point, and the calculation process is: calculate the difference between the set threshold and the current pixel grayscale value M3, the difference between the grayscale value of the pixel in the next column of the current row and the current pixel grayscale value N3, the ratio of the two is M3 / N3, and the ratio is recorded as T3, and the search position is determined according to the value of T3; if T3 is greater than 0.5, find the left boundary and start searching from the next column of the previous row; if T3 is less than or equal to 0.5, find the right boundary and start searching from the current column of the previous row;
[0018] Under the condition B that the grayscale value of the pixel in the previous row and the next column of the current pixel is greater than or equal to the set threshold, if the grayscale value of the pixel in the previous row and the current column of the current pixel is less than the set threshold, the bottom boundary is found and the search starts from the previous row; if the grayscale value of the pixel in the previous row and the current column of the current pixel is greater than or equal to the set threshold, the right boundary is found and the search starts from the previous row.
[0019] Furthermore, in the second case of the contour tracking, if the current pixel grayscale value is greater than or equal to the set threshold, the search is divided into two conditions, C and D; the C condition is that the grayscale value of the pixel in the previous row and current column is less than the set threshold, and the D condition is that the grayscale value of the pixel in the previous row and current column is greater than or equal to the set threshold;
[0020] When the C condition is that the grayscale value of the pixel in the current column of the previous row is less than the set threshold, if the grayscale value of the pixel in the next column of the previous row is less than the set threshold, find the right boundary and start searching from the previous row; if the grayscale value of the pixel in the next column of the previous row is greater than or equal to the set threshold, determine the search position according to the equivalent points; calculate two longitudinal equivalent points, the first equivalent point calculation method is: calculate the grayscale value difference M4 between the set threshold and the current pixel, the grayscale value difference N4 between the grayscale value of the pixel in the current column of the previous row and the current pixel, the ratio of the two is M4 / N4, and the ratio is recorded as T4; the second equivalent point calculation method is: calculate the grayscale value difference M5 between the set threshold and the grayscale value of the pixel in the next column of the current row, the grayscale value of the pixel in the next column of the previous row and the current row The grayscale value difference of the next column of pixels is N5, and the ratio of the two is M5 / N5, recorded as T5; when T4 is less than T5, the right boundary is found and the search starts from the previous row; when T4 is greater than T5, the left boundary is found and the search starts from the previous row and the next column; when T4 is equal to T5, a new equivalent point is calculated, and the calculation method of the new equivalent point is: calculate the difference M6 between the set threshold and the current pixel grayscale value, and the difference N6 between the grayscale value of the pixel in the next column of the current row and the current pixel grayscale value, and the ratio M6 / N6 is recorded as T6; when T6 is greater than 0.5, the left boundary is found and the search starts from the previous row and the next column; when T6 is less than or equal to 0.5, the right boundary is found and the search starts from the previous row and the current column;
[0021] When the D condition is that the grayscale value of the pixel in the current column of the previous row is greater than or equal to the set threshold, if the grayscale value of the pixel in the next column of the previous row is less than the set threshold, the bottom boundary is found and the search starts from the previous row; if the grayscale value of the pixel in the next column of the previous row is greater than or equal to the set threshold, the left boundary is found and the search starts from the next column of the previous row.
[0022] Furthermore, the method of filtering the extracted contours and retaining valid contours is as follows:
[0023] C) Based on the recorded contours, perform ellipse fitting on the pixel positions obtained for each contour, and calculate the area and center of gravity of each contour, the attribute parameters of the major axis and minor axis, and the circumscribed rectangle of the contour area, that is, the minimum rectangle that can contain all contour pixels in the horizontal and vertical directions;
[0024] D) Filter false contours according to attribute parameters; for the detection of circular holes, the length and width of the circumscribed rectangle of the contour are used for filtering. If the larger of the length and width of the circumscribed rectangle of the contour is less than the set number of pixels, it is judged as a false contour, otherwise it is a true contour; the false contour is deleted and the true contour information is retained.
[0025] Furthermore, the method of merging the filtered contours and calculating the attribute parameters of the new contours is as follows:
[0026] Take the first contour as the starting contour for merging, and merge it with the adjacent contours; when one of the four conditions is met, the two contours are judged to meet the merging rules: Condition 1, if the difference between the distance from the left boundary point of the starting contour to the center of gravity of the current contour and the sum of the major axis of the starting contour and the major axis of the current contour is less than the set distance value d; Condition 2, the difference between the distance from the right boundary point of the starting contour to the center of gravity of the current contour and the sum of the major axis of the starting contour and the major axis of the current contour is less than the set distance value d; Condition 3, the difference between the distance from the top boundary point of the starting contour to the center of gravity of the current contour and the sum of the major axis of the starting contour and the major axis of the current contour is less than the set distance value d; Condition 4, the difference between the distance from the bottom boundary point of the starting contour to the center of gravity of the current contour and the sum of the major axis of the starting contour and the major axis of the current contour is less than the set distance value d. to the set distance value d; if one of the conditions is met, the boundary of the merged contour is updated. If the left boundary of the current contour is smaller than the left boundary of the starting contour, the left boundary of the current contour is changed to the left boundary of the starting contour; if the right boundary of the current contour is larger than the right boundary of the starting contour, the right boundary of the current contour is changed to the right boundary of the starting contour; if the top boundary of the current contour is smaller than the top boundary of the starting contour, the top boundary of the current contour is changed to the top boundary of the starting contour; if the bottom boundary of the current contour is larger than the bottom boundary of the starting contour, the bottom boundary of the current contour is changed to the bottom boundary of the starting contour; the current contour point is added to the new contour; the attribute parameters of the new contour are recalculated, and the current contour point is deleted from the contour list; the above contour merging steps are repeated until the contour merging is completed.
[0027] According to another aspect of the present invention, the present invention also provides an electronic device, including a memory, a processor, and a computer program stored in and executable on the memory, wherein the processor executes the program to implement the method for detecting a circular contour of a display screen as described above.
[0028] According to another aspect of the present invention, a non-transitory computer-readable storage medium stores a computer program, which is executed by a processor to implement the method for detecting a circular contour of a display screen as described above.
[0029] Compared with the prior art, the invention has the following beneficial effects: first, when extracting contours, the complex contour distribution is fully considered, the extracted contours are filtered, misjudgment is reduced, and the accuracy of contour extraction is ensured. Second, the real contours are merged to enhance the closedness of the contours. Third, the various possibilities of contours are fully considered, and the accuracy of contour extraction and detection is improved at the same time, and the implementation plan is reliable and clear.
[0030] The detection system of the present invention has the characteristics of high precision, high speed and good stability. The result of adopting such a processing method is relatively reliable, and the present invention is applicable to similar circular contour detection of display screens. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present invention. Moreover, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:
[0032] Figure 1 A flowchart of a method for detecting a circular contour of a display screen according to the present invention;
[0033] Figure 2 A schematic diagram of a display screen detection area of a display screen circular contour detection area of the present invention;
[0034] Figure 3 An example of an image to be detected in the circular contour detection area of a display screen of the present invention;
[0035] Figure 4 This is an extraction contour effect diagram of the circular contour detection of the display screen of the present invention;
[0036] Figure 5 This is an effect diagram of the contour filtering of the circular contour detection of the display screen of the present invention;
[0037] Figure 6 A system structure diagram of circular contour detection of a display screen according to the present invention;
[0038] Figure 7 A schematic diagram showing the structure of an electronic device provided by an embodiment of the present invention is shown;
[0039] Figure 8 A schematic diagram of a storage medium provided by an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0040] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments described herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art. Example 1
[0041] like Figure 1 As shown, the object of the present invention is to detect the circular contour of a display screen. The detection process is as follows:
[0042] 1.Acquire the image of the contour detection area according to the set detection area, such as Figure 2 and Figure 3 shown.
[0043] According to the characteristics of the display screen, the display screen can be divided into a visible area and a non-visible area. The display screen is rectangular, the middle part is the visible area, and the rest is the non-visible area. The non-visible area is at the top and bottom of the visible area and the four areas on the left and right. The round hole is at the bottom non-visible area. The round hole is a round button on the display screen. After the camera collects the image, according to the set detection area range, the detection image of the bottom non-visible area, the top non-visible area image, the left non-visible area image, and the right non-visible area image are obtained. Because the bottom non-visible area image is too large, Figure 3 It is just the bottom non-visible area of the image.
[0044] 2. Extract the contour of the contour detection area through contour tracking and analysis, such as Figure 4 shown.
[0045] A) Contour tracking. Start the search from the last line of the bottom non-visible area image, that is, search from bottom to top in the bottom image, take the current point as the starting point of the search, and search for adjacent points near the starting point. There are two cases for searching adjacent points.
[0046] In the first case, when the grayscale value of the current pixel is less than the set threshold, the search can be divided into two conditions, A and B. Condition A is that the grayscale value of the pixel in the previous row and next column of the current pixel is less than the set threshold, and condition B is that the grayscale value of the pixel in the previous row and next column of the current pixel is greater than or equal to the set threshold. Under condition A, when the grayscale value of the pixel in the previous row and next column of the current pixel is less than the set threshold, two more cases are considered. First, if the grayscale value of the pixel in the previous row and current column is less than the set threshold, the left boundary is found, and the search position is updated, and the search starts from the previous row and next column; second, if the grayscale value of the pixel in the previous row and current column is greater than or equal to the set threshold, in order to improve the accuracy of the search, it is necessary to calculate the equivalent points, that is, to obtain the ratio relationship between the grayscale values of the current pixel and its adjacent pixels. At this time, two equal points are calculated vertically, and the two equal points are compared, and the search position is determined by their value size relationship. The calculation process of the first equivalent point is: the difference between the set threshold and the current pixel grayscale value is calculated as M1, the difference between the grayscale value of the pixel in the previous row and the current column is calculated as N1, and the ratio between the two is M1 / N1, and the ratio is recorded as T1. The calculation process of the second equivalent point is: the difference between the set threshold and the grayscale value of the pixel in the next column of the current row is calculated as M2, the difference between the grayscale value of the pixel in the next column of the previous row and the grayscale value of the pixel in the next column of the current row is calculated as N2, and the ratio between the two is M2 / N2, and the ratio is recorded as T2. After calculating the two equal value points, start to compare their values. If T1 is less than T2, find the right boundary and start searching from the previous row; if T1 is greater than T2, find the left boundary and start searching from the previous row and next column; if T1 is equal to T2, you need to calculate another vertical equal value point. The calculation process is: calculate the difference between the set threshold and the current pixel gray value M3, the difference between the pixel gray value of the next column of the current row and the current pixel gray value N3, the ratio of the two is M3 / N3, the ratio is recorded as T3, and the search position is determined according to the value of T3. If T3 is greater than 0.5, find the left boundary and start searching from the previous row and next column; if T3 is less than or equal to 0.5, find the right boundary and start searching from the previous row and current column. Under the condition B that the grayscale value of the pixel in the previous row and the next column of the current pixel is greater than or equal to the set threshold, if the grayscale value of the pixel in the previous row and the current column of the current pixel is less than the set threshold, the bottom boundary is found and the search starts from the previous row; if the grayscale value of the pixel in the previous row and the current column of the current pixel is greater than or equal to the set threshold, the right boundary is found and the search starts from the previous row.
[0047] In the second case, if the grayscale value of the current pixel is greater than or equal to the set threshold, it can be divided into two conditions, C and D. The C condition is that the grayscale value of the pixel in the current column of the previous row is less than the set threshold, and the D condition is that the grayscale value of the pixel in the current column of the previous row is greater than or equal to the set threshold. When the C condition is that the grayscale value of the pixel in the current column of the previous row is less than the set threshold, if the grayscale value of the pixel in the next column of the previous row is less than the set threshold, find the right boundary and start searching from the previous row. If the grayscale value of the pixel in the next column of the previous row is greater than or equal to the set threshold, the search position is determined based on the equal value points. At this time, two longitudinal equivalent points need to be calculated. The calculation method of the first equivalent point is: calculate the gray value difference between the set threshold and the current pixel M4, the gray value difference between the current pixel in the previous row and the current pixel N4, the ratio of the two is M4 / N4, and the ratio is recorded as T4; the calculation method of the second equivalent point is: calculate the gray value difference between the set threshold and the next column of the current row M5, the gray value difference between the previous row and the next column of the current row N5, the ratio of the two is M5 / N5, recorded as T5. When T4 is less than T5, find the right boundary and start searching from the previous row; when T4 is greater than T5, find the left boundary and start searching from the previous row and the next column; when T4 is equal to T5, a new equivalent point needs to be calculated at this time. The calculation method of the equivalent point is: calculate the gray value difference between the set threshold and the current pixel M6, the gray value difference between the current pixel in the next column of the current row and the current pixel N6, the ratio of the two is M6 / N6, recorded as T6. When T6 is greater than 0.5, the left boundary is found and the search starts from the previous row and the next column; when T6 is less than or equal to 0.5, the right boundary is found and the search starts from the previous row and the current column. When the D condition is that the grayscale value of the pixel in the previous row and the current column is greater than or equal to the set threshold, if the grayscale value of the pixel in the previous row and the next column is less than the set threshold, the bottom boundary is found and the search starts from the previous row; if the grayscale value of the pixel in the previous row and the next column is greater than or equal to the set threshold, the left boundary is found and the search starts from the previous row and the next column.
[0048] During the search process, the searched pixels are recorded, and the searched pixels are no longer performed. When the first row is searched, the search is stopped.
[0049] B) Contour analysis: The extracted contours are classified. If the number of pixels of the extracted contour is less than the set number of pixels, the set number of pixels is set to 500. All contours that meet this condition are recorded.
[0050] 3. Filter the extracted contours and retain valid contours, such as Figure 5 shown.
[0051] A) Based on the recorded contours, the pixel positions of each contour are fitted with an ellipse to calculate the area and center of gravity of each contour, the major axis and minor axis and other attribute parameters, as well as the circumscribed rectangle of the contour area, that is, the minimum rectangle that can contain all contour pixels in the horizontal and vertical directions.
[0052] B) Filter false contours according to attribute parameters. For the detection of circular holes, the length and width of the circumscribed rectangle of the contour are used for filtering. If the length and width of the circumscribed rectangle of the contour are larger than the set number of pixels, it is judged as a false contour, otherwise it is a true contour. Delete the false contour and retain the true contour information.
[0053] 4. Merge the filtered contours and calculate the attribute parameters of the merged contours.
[0054] Take the first contour as the starting contour for merging, and merge it with the adjacent contours. When one of the four conditions is met, it is determined that the two contours meet the merging rules. Condition 1: If the difference between the distance from the left boundary point of the starting contour to the center of gravity of the current contour and the sum of the long axis of the starting contour and the long axis of the current contour is less than the set distance value, the set distance value is 50 pixels; Condition 2: If the difference between the distance from the right boundary point of the starting contour to the center of gravity of the current contour and the sum of the long axis of the starting contour and the long axis of the current contour is less than the set distance value, the set distance value is 50 pixels; Condition 3: If the difference between the distance from the top boundary point of the starting contour to the center of gravity of the current contour and the sum of the long axis of the starting contour and the long axis of the current contour is less than the set distance value, the set distance value is 50 pixels; Condition 4: If the difference between the distance from the bottom boundary point of the starting contour to the center of gravity of the current contour and the sum of the long axis of the starting contour and the long axis of the current contour is less than the set distance value, the set distance value is 50 pixels. If one of the conditions is met, the boundary of the merged contour is updated. If the left boundary of the current contour is less than the left boundary of the starting contour, the left boundary of the current contour is changed to the left boundary of the starting contour; if the right boundary of the current contour is greater than the right boundary of the starting contour, the right boundary of the current contour is changed to the right boundary of the starting contour; if the top boundary of the current contour is less than the top boundary of the starting contour, the top boundary of the current contour is changed to the top boundary of the starting contour; if the bottom boundary of the current contour is greater than the bottom boundary of the starting contour, the bottom boundary of the current contour is changed to the bottom boundary of the starting contour; the current contour point is added to the new contour. The attribute parameters of the new contour are recalculated, and the current contour point is deleted from the contour list. Repeat the above contour merging steps until the contour merging is completed. Example 2
[0055] This embodiment provides a system for detecting circular contours of a display screen. Figure 6 As shown, including:
[0056] The module 100 for acquiring an image of the contour detection area is used to acquire an image of the contour detection area;
[0057] The contour module 200 for extracting the contour detection area is used to extract the contour of the area to be detected;
[0058] A filtering module 300 is used to filter out false contours and retain true contours.
[0059] The filtered contours are merged by a module 400, which is used to merge adjacent contours into a whole.
[0060] According to another aspect of the present invention, the present invention further provides a computer program including a memory, a processor, and a computer program stored in the memory and executable on the memory, wherein the processor executes the program to implement the circular contour detection method for a display screen as described above.
[0061] According to another aspect of the present invention, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, the program being executed by a processor to implement the display screen circular contour detection method as described above.
[0062] Compared with the prior art, the invention has the following beneficial effects: the invention first obtains an image of the contour area according to the set detection area; then extracts the contour of the contour detection area by contour tracking and analysis; filters the extracted contours and retains the valid contours; finally merges the filtered contours and calculates the attribute parameters of the new contours. The result of such a processing method is relatively reliable, and the invention is applicable to circular contour detection of similar display screens.
[0063] The embodiment of the present invention further provides an electronic device corresponding to the method for detecting a circular outline of a display screen provided in the above embodiment, so as to execute the method for detecting a circular outline of an upper display screen. The embodiment of the present invention is not limited thereto.
[0064] Please refer to Figure 7 , which shows a schematic diagram of an electronic device provided by some embodiments of the present invention. Figure 7 As shown, the electronic device 20 includes: a processor 200, a memory 201, a bus 202 and a communication interface 203, and the processor 200, the communication interface 203 and the memory 201 are connected via the bus 202; the memory 201 stores a computer program that can be run on the processor 200, and when the processor 200 runs the computer program, the method for detecting the circular contour of a display screen provided in any of the aforementioned embodiments of the present invention is executed.
[0065] The memory 201 may include a high-speed random access memory (RAM), and may also include a non-volatile memory, such as at least one disk memory. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 203 (which may be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. may be used.
[0066] The bus 202 may be an ISA bus, a PCI bus, or an EISA bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. The memory 201 is used to store programs, and the processor 200 executes the programs after receiving the execution instruction. The method for detecting the circular contour of a display screen disclosed in any implementation of the above-mentioned embodiment of the present invention may be applied to the processor 200, or implemented by the processor 200.
[0067] The processor 200 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit in the processor 200 or the instruction in the form of software. The above processor 200 may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present invention can be implemented or executed. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. The steps of the method disclosed in the embodiments of the present invention may be directly embodied as being executed by a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software module may be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 201, and the processor 200 reads the information in the memory 201 and completes the steps of the above method in combination with its hardware.
[0068] The electronic device provided by the embodiment of the present invention and the method for detecting the circular contour of a display screen provided by the embodiment of the present invention are based on the same inventive concept and have the same beneficial effects as the methods adopted, run or implemented by them.
[0069] The embodiment of the present invention further provides a computer-readable storage medium corresponding to the method for detecting a circular contour of a display screen provided in the aforementioned embodiment. Figure 8 The computer-readable storage medium shown is a CD 30 on which a computer program (ie, a program product) is stored. When the computer program is executed by a processor, the method for detecting a circular contour of a display screen provided in any of the aforementioned embodiments will be executed.
[0070] It should be noted that examples of the computer-readable storage medium may also include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other optical or magnetic storage media, which are not listed here one by one.
[0071] The computer-readable storage medium provided by the above-mentioned embodiment of the present invention and the method for detecting circular contour of a display screen provided by the embodiment of the present invention are based on the same inventive concept and have the same beneficial effects as the method adopted, run or implemented by the application program stored therein.
[0072] It should be noted that:
[0073] The algorithm and display provided herein are not inherently related to any particular computer, virtual device or other equipment. Various general-purpose devices can also be used together with the teachings based on this. According to the above description, it is obvious to construct the structure required for this type of device. In addition, the present invention is not directed to any specific programming language either. It should be understood that various programming languages can be utilized to realize the content of the present invention described herein, and the description of the above specific language is for the purpose of disclosing the best mode of the present invention.
[0074] In the description provided herein, a large number of specific details are described. However, it is understood that embodiments of the present invention can be practiced without these specific details. In some instances, well-known methods, structures and techniques are not shown in detail so as not to obscure the understanding of this description.
[0075] Similarly, it should be understood that in order to streamline the present disclosure and aid in understanding one or more of the various inventive aspects, in the above description of exemplary embodiments of the present invention, various features of the present invention are sometimes grouped together into a single embodiment, figure, or description thereof. However, this disclosed method should not be interpreted as reflecting the intention that the claimed invention requires more features than those explicitly recited in each claim. More specifically, as reflected in the claims below, inventive aspects lie in less than all the features of the individual embodiments disclosed above. Therefore, the claims that follow the specific embodiment are hereby expressly incorporated into the specific embodiment, with each claim itself serving as a separate embodiment of the present invention.
[0076] Those skilled in the art will appreciate that the modules in the devices in the embodiments may be adaptively changed and arranged in one or more devices different from the embodiments. The modules or units or components in the embodiments may be combined into one module or unit or component, and in addition they may be divided into a plurality of submodules or subunits or subcomponents. Except that at least some of such features and / or processes or units are mutually exclusive, all features disclosed in this specification (including the accompanying claims, abstracts and drawings) and all processes or units of any method or device disclosed in this manner may be combined in any combination. Unless otherwise expressly stated, each feature disclosed in this specification (including the accompanying claims, abstracts and drawings) may be replaced by an alternative feature providing the same, equivalent or similar purpose.
[0077] In addition, those skilled in the art will appreciate that, although some embodiments described herein include certain features included in other embodiments but not other features, the combination of features of different embodiments is meant to be within the scope of the present invention and form different embodiments. For example, in the claims below, any one of the claimed embodiments may be used in any combination.
[0078] The various component embodiments of the present invention can be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. It should be understood by those skilled in the art that a microprocessor or digital signal processor (DSP) can be used in practice to implement some or all functions of some or all components in the creation device of the virtual machine according to an embodiment of the present invention. The present invention can also be implemented as a device or device program (e.g., a computer program and a computer program product) for executing part or all of the methods described herein. Such a program implementing the present invention can be stored on a computer-readable medium, or can have the form of one or more signals. Such a signal can be downloaded from an Internet website, or provided on a carrier signal, or provided in any other form.
[0079] It should be noted that the above embodiments illustrate the present invention rather than limit it, and that those skilled in the art may devise alternative embodiments without departing from the scope of the appended claims. In the claims, any reference symbol between brackets shall not be construed as a limitation on the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "one" or "an" preceding an element does not exclude the presence of a plurality of such elements. The present invention may be implemented by means of hardware comprising a number of different elements and by means of a suitably programmed computer. In a unit claim enumerating a number of devices, several of these devices may be embodied by the same hardware item. The use of the words first, second, and third, etc., does not indicate any order. These words may be interpreted as names.
[0080] The above is only a preferred specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.
Claims
1. A method for detecting a circular contour of a display screen, characterized in that: The following steps are involved: Acquire an image of the contour detection area according to the set detection area; The contour of the contour detection area is extracted through contour tracking and analysis. The process is as follows: Contour tracking: Start the search from the last line of the image in the bottom non-visible area, take the current point as the starting point, search for adjacent points near the starting point, and search for adjacent points in two cases according to the size relationship between the current pixel gray value and the set threshold; During the search process, the searched pixels are recorded, and the searched pixels are no longer searched. When the first row is searched, the search is stopped. Contour analysis: Classify the extracted contours. If the number of pixels of the extracted contour is less than the set number of pixels, then record all contours that meet the requirement that the number of pixels of the extracted contour is less than the set number of pixels. In the first case of the contour tracking, when the gray value of the current pixel is less than the set threshold, the search is divided into two conditions, A and B; the A condition is that the gray value of the pixel in the previous row and next column of the current pixel is less than the set threshold, and the B condition is that the gray value of the pixel in the previous row and next column of the current pixel is greater than or equal to the set threshold; Under condition A, if the grayscale value of the pixel in the previous row and the next column of the current pixel is less than the set threshold, two cases are considered: first, if the grayscale value of the pixel in the previous row and the current column is less than the set threshold, the left boundary is found, the search position is updated, and the search starts from the previous row and the next column; second, if the grayscale value of the pixel in the previous row and the current column is greater than or equal to the set threshold, the equivalent point is calculated, that is, the ratio relationship between the grayscale values of the current pixel and its adjacent pixels is obtained; two vertical equivalent points are calculated, and the two equivalent points are compared, and the search position is determined by the value relationship of the two equivalent points; the first equivalent point calculation process is: the difference between the set threshold and the current pixel grayscale value is calculated as M1, and the difference between the grayscale value of the pixel in the previous row and the current pixel grayscale value is N1, and the ratio of the two is M1 / N1, and the ratio is recorded as T1; the second equivalent point calculation process is: the difference between the set threshold and the current row and the next column is calculated as M1 / N1. The difference in the grayscale value of the column pixel is M2, the difference in the grayscale value of the pixel in the next column of the previous row and the grayscale value of the pixel in the next column of the current row is N2, the ratio of the two is M2 / N2, and the ratio is recorded as T2; after calculating the two equivalent points, compare them. If T1 is less than T2, find the right boundary and start searching from the previous row; if T1 is greater than T2, find the left boundary and start searching from the next column of the previous row; if T1 is equal to T2, it is necessary to calculate another vertical equivalent point, and the calculation process is: calculate the difference between the set threshold and the current pixel grayscale value M3, the difference between the grayscale value of the pixel in the next column of the current row and the current pixel grayscale value N3, the ratio of the two is M3 / N3, and the ratio is recorded as T3, and the search position is determined according to the value of T3; if T3 is greater than 0.5, find the left boundary and start searching from the next column of the previous row; if T3 is less than or equal to 0.5, find the right boundary and start searching from the current column of the previous row; Under the condition B that the grayscale value of the pixel in the previous row and the next column of the current pixel is greater than or equal to the set threshold, if the grayscale value of the pixel in the previous row and the current column of the current pixel is less than the set threshold, the bottom boundary is found and the search starts from the previous row; if the grayscale value of the pixel in the previous row and the current column of the current pixel is greater than or equal to the set threshold, the right boundary is found and the search starts from the previous row; Filter the extracted contours and retain the valid contours; Merge the filtered contours and calculate the attribute parameters of the merged contours.
2. The method for detecting a circular contour of a display screen according to claim 1, characterized in that: The process of obtaining an image of the contour detection area according to the set detection area is as follows: The display screen is divided into a visible area and a non-visible area. The middle part of the display screen is the visible area, and the rest is the non-visible area. The non-visible area is in the top, bottom, left and right areas of the visible area. The circular hole is in the bottom non-visible area. The circular hole is a circular button of the display screen. After the camera collects the image, the detection image of the bottom non-visible area, the top non-visible area image, the left non-visible area image, and the right non-visible area image are obtained according to the set detection area range.
3. The method for detecting a circular contour of a display screen according to claim 1, characterized in that: In the second case of the contour tracking, if the current pixel grayscale value is greater than or equal to the set threshold, it is divided into two conditions, C and D. The C condition is that the grayscale value of the pixel in the previous row and current column is less than the set threshold, and the D condition is that the grayscale value of the pixel in the previous row and current column is greater than or equal to the set threshold. When the C condition is that the grayscale value of the pixel in the current column of the previous row is less than the set threshold, if the grayscale value of the pixel in the next column of the previous row is less than the set threshold, find the right boundary and start searching from the previous row; if the grayscale value of the pixel in the next column of the previous row is greater than or equal to the set threshold, determine the search position according to the equivalent points; calculate two longitudinal equivalent points, the first equivalent point calculation method is: calculate the grayscale value difference M4 between the set threshold and the current pixel, the grayscale value difference N4 between the grayscale value of the pixel in the current column of the previous row and the current pixel, the ratio of the two is M4 / N4, and the ratio is recorded as T4; the second equivalent point calculation method is: calculate the grayscale value difference M5 between the set threshold and the grayscale value of the pixel in the next column of the current row, the grayscale value of the pixel in the next column of the previous row and the current row The grayscale value difference of the next column of pixels is N5, and the ratio of the two is M5 / N5, recorded as T5; when T4 is less than T5, the right boundary is found and the search starts from the previous row; when T4 is greater than T5, the left boundary is found and the search starts from the previous row and the next column; when T4 is equal to T5, a new equivalent point is calculated, and the calculation method of the new equivalent point is: calculate the difference M6 between the set threshold and the current pixel grayscale value, and the difference N6 between the grayscale value of the pixel in the next column of the current row and the current pixel grayscale value, and the ratio M6 / N6 is recorded as T6; when T6 is greater than 0.5, the left boundary is found and the search starts from the previous row and the next column; when T6 is less than or equal to 0.5, the right boundary is found and the search starts from the previous row and the current column; When the D condition is that the grayscale value of the pixel in the current column of the previous row is greater than or equal to the set threshold, if the grayscale value of the pixel in the next column of the previous row is less than the set threshold, the bottom boundary is found and the search starts from the previous row; if the grayscale value of the pixel in the next column of the previous row is greater than or equal to the set threshold, the left boundary is found and the search starts from the next column of the previous row.
4. The method for detecting a circular contour of a display screen according to claim 3, characterized in that: The method of filtering the extracted contours and retaining the valid contours is as follows: A) Based on the recorded contours, perform ellipse fitting on the pixel positions obtained for each contour, and calculate the area and center of gravity of each contour, the attribute parameters of the major axis and minor axis, and the circumscribed rectangle of the contour area, that is, the minimum rectangle that can contain all contour pixels in the horizontal and vertical directions; B) Filter false contours according to attribute parameters; for the detection of circular holes, the length and width of the circumscribed rectangle of the contour are used for filtering. If the larger of the length and width of the circumscribed rectangle of the contour is less than the set number of pixels, it is judged as a false contour, otherwise it is a true contour; the false contour is deleted and the true contour information is retained.
5. The method for detecting a circular contour of a display screen according to claim 4, characterized in that: The method for merging the filtered contours and calculating the attribute parameters of the new contours is as follows: Take the first contour as the starting contour for merging, and merge it with the adjacent contours; when one of the four conditions is met, the two contours are judged to meet the merging rules: Condition 1, if the difference between the distance from the left boundary point of the starting contour to the center of gravity of the current contour and the sum of the major axis of the starting contour and the major axis of the current contour is less than the set distance value d; Condition 2, the difference between the distance from the right boundary point of the starting contour to the center of gravity of the current contour and the sum of the major axis of the starting contour and the major axis of the current contour is less than the set distance value d; Condition 3, the difference between the distance from the top boundary point of the starting contour to the center of gravity of the current contour and the sum of the major axis of the starting contour and the major axis of the current contour is less than the set distance value d; Condition 4, the difference between the distance from the bottom boundary point of the starting contour to the center of gravity of the current contour and the sum of the major axis of the starting contour and the major axis of the current contour is less than the set distance value d; if one of the conditions is met, the boundary of the merged contour is updated. If the left boundary of the current contour is less than the left boundary of the starting contour, the left boundary of the current contour is changed to the left boundary of the starting contour; if the right boundary of the current contour is greater than the right boundary of the starting contour, the right boundary of the current contour is changed to the right boundary of the starting contour; if the top boundary of the current contour is less than the top boundary of the starting contour, the top boundary of the current contour is changed to the top boundary of the starting contour; if the bottom boundary of the current contour is greater than the bottom boundary of the starting contour, the bottom boundary of the current contour is changed to the bottom boundary of the starting contour; the current contour point is added to the new contour; the attribute parameters of the new contour are recalculated, and the current contour point is deleted from the contour list; the contour merging steps are repeated until the contour merging is completed.
6. A system for detecting circular contours of a display screen, using the method according to any one of claims 1 to 5, characterized in that: include: A module for acquiring an image of a contour detection area is used to acquire an image of the contour detection area; A contour module for extracting contour detection areas is used to extract the contour of the area to be detected; A filtering module is used to filter out false contours and retain true contours. The filtered contours are merged into a whole by a merging module.
7. An electronic device, characterized in that: The invention comprises a memory, a processor and a computer program stored in the memory and executable on the memory, wherein the processor executes the program to implement the method for detecting the circular contour of a display screen as claimed in any one of claims 1 to 5.
8. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: The program is executed by a processor to implement the method for detecting a circular contour of a display screen as described in any one of claims 1 to 5.
