A Hough transform control method, chip and robot based on memory configuration
By rationally laying out memory in Hoff space and using the coordinate information of the preset parameter mapping space for angle iterative scanning, the problem of frequent CPU cache failure in Hoff transformation is solved, and the computing efficiency is improved.
Patent Information
- Application Number
- CN202111148843.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-29
- Publication Date
- 2025-03-11
- Estimated Expiration
- 2041-09-29
AI Technical Summary
During the Hough transformation, due to cross-row jumps of memory addresses, the CPU frequently cache failures, which reduces the computing speed.
By rationally laying out memory in Hough space, using the horizontal axis of the preset parameter mapping space to represent the rotation angle and the vertical axis to represent the dot and line distance, performing angle iterative scanning to reduce the phenomenon of cross-large memory segments when CPU reads.
The cache hit rate of the CPU to image information is improved, the frequency of cache failure is reduced, and the computing efficiency of Hoff transform is significantly improved.
Smart Images

Figure CN113886079B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computing memory management, and in particular to a Hough transform control method, a chip and a robot based on memory configuration. Background Art
[0002] The Hough transform of a line is a technology widely used to find lines based on binary images, but it does not consider the memory access method too much. The Hough space matrix configured in the computer memory sets the meaning of the horizontal axis to the point-line distance and the meaning of the vertical axis to the rotation angle. In this way, based on the trigonometric function relationship in the Hough transform, when a point-line distance is the result of a trigonometric function, there are multiple different rotation angles in the angle obtained by the inverse trigonometric function, which causes the vertical axis coordinate information indexed by the CPU in the memory corresponding to the Hough space matrix to have a large memory address change. For example, the memory addresses indexed twice adjacently need to span multiple rows of memory segments (memory areas). At this time, the address amount occupied by an index step has exceeded the carrying capacity of the cache space of general embedded devices and mobile devices.
[0003] Therefore, CPU read / cache failures often occur during the Hough space transformation process. Although the actual amount of computation of the Hough transform is not large, the frequent cache failures still cause the overall calculation speed to be very slow, thus reducing the performance of the Hough transform algorithm. Summary of the invention
[0004] To solve the above problems, the present invention aims to reasonably arrange the memory space of the Hough space used for linear transformation, so that the CPU or similar main control unit can hit the cached data multiple times, so as to reduce the number of times the CPU repeatedly reads data at continuous address segments from the low-speed memory after the cache fails. The specific technical solution of the present invention is as follows:
[0005] A Hough transform control method based on memory configuration, the Hough transform control method comprising the following steps: whenever an angle iteration scan of a preset number of iterations is performed on a valid point of a pre-acquired binary image, the ordinate of the corresponding point-line distance in the preset parameter mapping space is allowed to change once, so that the CPU continuously reads the image information in the memory address according to the coordinate information of the preset parameter mapping space; wherein the horizontal coordinate of the preset parameter mapping space is used to represent the rotation angle of the straight line, and the horizontal coordinate of the preset parameter mapping space is configured as a column address; the vertical coordinate of the preset parameter mapping space is used to represent the point-line distance of the straight line, and the vertical coordinate of the preset parameter mapping space is configured as a row address; wherein the preset parameter mapping space is a matrix space within the Hough space; and the Hough space is configured as a memory space.
[0006] Compared with the prior art, the technical solution designs the preset parameter mapping space as a Hough space storage method in which the horizontal axis represents the rotation angle and the vertical axis represents the point-line distance. In the Hough transform, the straight line is subjected to an angle iterative scanning for a preset number of times according to a certain iteration step, so that the numerical value of the point-line distance calculated corresponding to the continuously changing rotation angle of the straight line does not change much, and the phenomenon of crossing large memory segments (for example, crossing multiple rows of address segments) when the CPU reads the image information at the address composed of the rotation angle and the point-line distance is reduced, so that the CPU or a similar main control unit can hit the image data cached from the continuous memory multiple times, thereby improving the working efficiency of the Hough transform of the binary image.
[0007] Furthermore, the method allows the corresponding point-line distance to change once in the vertical coordinate in the preset parameter mapping space each time an angle iterative scan is performed for a preset number of iterations on a valid point of a pre-acquired binary image, and includes: step A, starting from an initial rotation angle, scanning the rotation angle of a valid point with the preset unit iteration angle as the iteration step; each time a rotation angle of the same valid point is scanned, calculating the point-line distance of the straight line of the currently scanned rotation angle passing through the valid point, and then processing the point-line distance into an intercept coordinate according to the preset point-line distance accuracy to determine that an angle iterative scan is performed on the valid point, wherein the intercept coordinate is the vertical coordinate of the corresponding point-line distance in the preset parameter mapping space; step B, each time the angle iterative scan is performed for the same valid point for the preset number of iterations, updating the rotation angle scanned by the latest iteration to the initial rotation angle, and repeating step A, so that the intercept coordinate obtained by the next execution of step A is different from the intercept coordinate obtained by the current execution.
[0008] Compared with the prior art, the preset unit iteration angle is used as the step iteration amount. During each angular iteration scanning of the preset number of iterations, each point-line distance obtained in sequence is converted into an equal intercept coordinate in the preset parameter mapping space, thereby obtaining index coordinates (rotation angle, intercept coordinates) that can describe continuous addresses, so that the CPU reads the image information in the continuous memory segment into the cache space according to the coordinate value of the preset parameter mapping space, avoiding that each iteration causes the corresponding vertical coordinate in the Hough space to change, and the CPU needs to jump a large memory segment (offset multiple whole rows of memory addresses) each time it reads the memory. This improves the hit probability in the high-precision straight line Hough space, thereby doubling the search speed of the straight line Hough transform result.
[0009] Furthermore, in step A, the method of scanning the rotation angle of a valid point with the preset unit iteration angle as the iteration step includes: in the process of executing the current angle iteration scan of a valid point, adding the preset unit iteration angle to the rotation angle scanned by the previous angle iteration scan to obtain the rotation angle scanned by the current iteration; wherein, before executing the next angle iteration scan of the same valid point, first update the rotation angle scanned by the current angle iteration scan to the rotation angle scanned by the previous angle iteration scan. The technical solution uses the rotation angle iterative rotation method to control the aforementioned angle iteration scan, and controls each valid point in the original image to iteratively scan the straight line at the corresponding rotation angle within a range of 360 degrees, and more comprehensively scans the straight lines to be Hough transformed in the original image.
[0010] Furthermore, the maximum number of times that the angle iterative scan is performed on each valid point is the ratio of 360 degrees to the preset unit iteration angle, which is used to be set as the number of times that the angle iterative scan is allowed to be performed for a corresponding valid point within a rotation angle range of 360 degrees; the Hough transform control method also includes: step C, whenever the number of times the angle iterative scan is performed on the same valid point reaches the ratio of 360 degrees to the preset unit iteration angle, start to repeat steps A to B for the new valid point until the angle iterative scan of each valid point in the binary image within the rotation angle range of 360 degrees is completed.
[0011] Furthermore, the number of rows of coordinate elements arranged in the preset parameter mapping space is the number of polar coordinate points with the same rotation angle but different point-line distances; the number of columns of coordinate elements arranged in the preset parameter mapping space is the number of polar coordinate points with the same point-line distances but different rotation angles; all straight lines passing through valid points in the binary image support being Hough transformed into polar coordinate points in the Hough space, wherein different polar coordinate points represent different straight lines, and one polar coordinate point represents at least one straight line passing through a valid point; wherein the polar coordinate point includes a rotation angle and a point-line distance, the rotation angle is the angle formed by the normal of the straight line represented by the polar coordinate point and the positive direction of the horizontal axis of the coordinate system of the binary image to which it belongs, and the point-line distance is the geometric perpendicular distance from the origin of the coordinate system of the binary image to the straight line represented by the polar coordinate point.
[0012] Under the guidance of this technical solution, the ratio of the number of times an effective point performs an iterative angle scan to the preset number of iterations is set to the maximum number of rows of coordinate elements arranged in the Hough space required for the effective point, and the preset number of iterations is set to the maximum number of columns of coordinate elements arranged in the Hough space required for the effective point, and the product of the aforementioned number of columns and the aforementioned number of rows is set to the number of effective addresses that the CPU is allowed to read.
[0013] Furthermore, the method for processing the point-line distance into intercept coordinates according to the preset point-line distance precision includes: according to the order of magnitude specified by the preset point-line distance precision, converting the point-line distance corresponding to each rotation angle scanned during a round of intercept precision iterative scanning operation into the same intercept coordinate, so as to convert it into a vertical coordinate of the same value in the preset parameter mapping space, wherein the order of magnitude of the intercept coordinate is equal to the order of magnitude specified by the preset point-line distance precision; wherein, starting from an initial rotation angle, with the preset unit iteration angle as the iteration step, whenever the number of angle iterative scanning performed on the same valid point is counted to be the preset number of iterations, it is recorded as a round of intercept precision iterative scanning operation performed on the same valid point; wherein the preset point-line distance precision is configured as follows: the point-line distance calculated corresponding to each round of intercept precision iterative scanning operation is within the corresponding intercept range, and the precision of the intercept range satisfies the preset point-line distance precision; two adjacent rounds of the intercept precision iterative scanning operation correspond to the calculation of two intercept coordinates with different values.
[0014] This technical solution sets the point-line distances that meet the same precision to the same intercept coordinate, and then sets the number of iterations required for each change of an intercept coordinate on this basis, that is, sets the preset number of iterations, and establishes the correspondence between multiple rotation angles and a point-line distance in the Hough transform. This technical solution is applied to the linear Hough transform of a binary image, which improves the success rate of the data stored in the Hough space being cached by the CPU, because it reduces the frequency of cross-line reading by the CPU, so the demand for cache is lower, which improves the efficiency of the Hough transform algorithm.
[0015] Furthermore, the method for calculating the point-to-line distance of the straight line at the rotation angle currently scanned through the effective point includes: multiplying the cosine function value of the rotation angle scanned by the current angle iteration scan by the horizontal coordinate of the effective point participating in the current angle iteration scan to obtain a first transformation value; multiplying the sine function value of the rotation angle scanned by the current angle iteration scan by the vertical coordinate of the effective point participating in the current angle iteration scan to obtain a second transformation value; then adding the first transformation value to the second transformation value to obtain the point-to-line distance of the straight line at the rotation angle currently scanned through the effective point; wherein the cosine function value and the sine function value of the rotation angle scanned by the current angle iteration scan are obtained from a pre-configured index table, and the index table is used to store the trigonometric function values corresponding to the rotation angles allowed to be scanned according to the preset unit iteration angle. This technical solution adopts a table lookup method to replace the calculation of trigonometric functions during each angle iteration scan, thereby increasing the speed of obtaining intercept coordinates and further increasing the speed of converting straight lines into Hough space.
[0016] Furthermore, the Hough transform control method also includes: configuring the latest set intercept coordinates and their corresponding rotation angles as the read addresses of the image information of the corresponding straight line, so that the image information of the binary image is configured to be read out from the corresponding memory address row by row by the CPU according to the coordinate information in the preset parameter mapping space; wherein the read address is a memory address belonging to the Hough space, and the read addresses set by successively executing the angle iteration scan are continuous to form a memory space with continuous addresses; wherein the coordinate information in the preset parameter mapping space includes the intercept coordinates and their corresponding rotation angles. It is ensured that the addresses established in the Hough space continuously store the straight line features stored in the binary image row by row, so that when the CPU caches the image information, it is continuously read from the preset parameter mapping space without reading across address segments, thereby reducing the pressure on the cache.
[0017] Furthermore, the Hough transform control method also includes: dividing a preset parameter mapping space into a plurality of block matrix spaces, wherein the memory addresses of two adjacent divided block matrix spaces are continuous; the coordinate information of each block matrix space is configured to cover the intercept coordinates and their corresponding rotation angles obtained by the angle iterative scan of a preset local number of times, so that the CPU at least indexes two groups of continuous read addresses with different intercept coordinates, wherein each group of continuous read addresses is configured each time the angle iterative scan is counted to execute the preset number of iterations on the same valid point, and the read addresses of two adjacent groups are continuous; the preset local number is greater than or equal to twice the preset number of iterations.
[0018] On the basis of the above-mentioned technical scheme, the present technical scheme adopts a block access method to control the changed intercept coordinates to be retained in the same block matrix space, and configures the same block matrix space to support the storage of continuous memory data, and supports continuous storage between two adjacent block matrix spaces. The memory size of a block matrix space set by the present technical scheme satisfies the CPU cache for at least two groups of data stored in the continuous memory area corresponding to the coordinate information of the Hough space obtained by the iterative scanning of the angle with the preset number of iterations, thereby significantly reducing the frequency of CPU access across large memory.
[0019] Furthermore, the CPU is configured to support parallel calculation of the point-to-line distances of the lines of the preset parallel number of rotation angles that are scanned successively through the effective points; wherein the CPU is provided with a preset parallel number of calculation units inside, each calculation unit being used to calculate the point-to-line distances of the lines of the rotation angles that are scanned through the effective points. This technical solution increases the speed of calculating the Hough space coordinates by the preset parallel number of times, balances the time for the CPU to cache data from the memory (the memory space constructed in the Hough space), and increases the overall transformation speed.
[0020] A chip is used to store program codes corresponding to the Hough transform control method. The program codes are used to control the chip to execute the Hough transform control method, so that the chip, as a memory control chip, cooperates with the CPU to access the memory space, so as to reduce the probability of failure of the CPU to cache the data of the preset parameter mapping space, and effectively solve the limitations of the slow processing speed and limited memory resources of the embedded platform, and provide a solution for the image recognition and positioning of the robot.
[0021] A robot equipped with the chip. The robot is also equipped with a laser sensor or a visual sensor for obtaining effective points from the collected image, and then using Hough transform to extract the features of the straight line passing through the effective points. On the one hand, this technical solution reduces the algorithm's demand for main control memory and improves the algorithm's efficiency; on the other hand, it improves the algorithm's efficiency in detecting straight lines in real-time collected images. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 A flowchart of a Hough transform control method based on memory configuration is disclosed as an embodiment of the present invention.
[0023] Figure 2 A flowchart of a Hough transform control method based on memory configuration is disclosed as another embodiment of the present invention.
[0024] Figure 3 A flowchart of a Hough transform control method based on memory configuration is disclosed as another embodiment of the present invention. DETAILED DESCRIPTION
[0025] In order to make the purpose, technical solutions and advantages of the present application more clearly understood, the present application is described and illustrated in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present application. Based on the embodiments provided in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.
[0026] Mentioning "embodiment" in this application means that the specific features, structures or characteristics described in conjunction with the embodiment may be included in at least one embodiment of the present application, and the appearance of the phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly or implicitly understood by those of ordinary skill in the art that the embodiments described in this application can be combined with other embodiments without conflict.
[0027] Hough transform can be used as a technology to search (detect) straight lines based on binary images. The straight line to be searched is represented in the Hough space using the polar coordinates of the mathematical straight line equation. The general straight line equations of all straight lines that may pass through valid points are converted into polar coordinates (straight line representation form) containing the point-line distance (polar coordinate parameters) and the rotation angle (polar coordinate parameters), and then stored in the Hough space represented by polar coordinates according to the positions corresponding to the point-line distance and the rotation angle. It should be noted that the straight line equation has the intercept form, slope-intercept form, general form, point-slope form, etc., but these forms have "singular" cases, one of which has an intercept of 0 and a slope of 0; in addition, the parameter space of some forms is not closed, such as the slope k of the slope-intercept form, which ranges from 0 to infinity.
[0028] It is worth noting that the reason why the Hough transform can process graphics of arbitrary shapes is not that an equation that can represent any graphics is found, but that a graphic is described in the form of a table and the coordinates of the edge points of the graphic are saved in a table. Then the graphic is determined. Therefore, whether it is a straight line (actually a line segment), a circle, an ellipse or other geometric shapes, the same method can be used to process them.
[0029] As an embodiment, a Hough transform control method based on memory configuration is disclosed. The Hough transform control method is suitable for transforming a straight line passing through a pixel point (a pixel coordinate) in an image into a Hough space set in this embodiment and storing it, so that the CPU can obtain image information of the straight line from the Hough space; Figure 1 As shown, the Hough transform control method comprises the following steps:
[0030] Step S1, using the horizontal coordinate of the preset parameter mapping space to represent the rotation angle of the straight line, and configuring the horizontal coordinate of the preset parameter mapping space as a column address; at the same time, using the vertical coordinate of the preset parameter mapping space to represent the point-line distance of the straight line, and configuring the vertical coordinate of the preset parameter mapping space as a row address; in this embodiment, the preset parameter mapping space is a matrix space belonging to the Hough space; the Hough space is set as a memory space, so the horizontal coordinate of the preset parameter mapping space is configured as the column address of the corresponding memory space, which can be used to represent the address segment of the corresponding column number; the vertical coordinate of the preset parameter mapping space is configured as the row address of the corresponding memory space, which can be used to represent the address segment of the corresponding row number; the rotation angle θ of the straight line and the point-line distance ρ constitute a specific memory address, which is specifically the position of the θth column of the ρth row of the preset parameter mapping space. Preferably, the preset parameter mapping space is a matrix space with a preset number of rows and a preset value divided from the Hough space, which can configure the polar coordinate points of all straight lines Hough transformed through the valid points of the binary image, so as to speed up the efficiency of the CPU reading the straight line through the valid points.
[0031] It should be noted that what is represented by the Hough space is the point-line distance (polar coordinate parameter) and rotation angle (polar coordinate parameter) in the polar coordinate formula of all straight lines passing through valid points, which are converted into polar coordinate points in the matrix space, and the image information at the coordinate position of the original binary image corresponding to the point-line distance and the rotation angle is stored in the Hough space represented by polar coordinates. Therefore, each non-zero point in the Hough space represents a straight line that passes through the valid points of the original binary image.
[0032] In this embodiment, the image convolution template (including but not limited to low-pass filter, high-pass filter, matched filter edge detection, edge detection, gradient direction edge detection, and translation and differential edge detection) is used in advance to process the currently collected image to obtain a binary image. Assuming that there are multiple valid points in the binary image, if a specific straight line passing through one of the valid points needs to be detected, the specific rotation angle θ and point-to-line distance ρ need to be found. In the Hough transform of this embodiment, the straight line representation form containing polar coordinate parameters is used, which is referred to as the polar coordinate expression as follows: xcosθ+ysinθ=ρ, where x is the horizontal coordinate of the aforementioned valid point, y is the vertical coordinate of the aforementioned valid point, the rotation angle θ refers to the angle formed by the normal of the transformed straight line and the positive direction of the x-axis, and the point-to-line distance ρ is the geometric vertical distance from the origin of the image coordinate system to the transformed straight line, forming two parameters of the Hough transform of the straight line, and these two parameters are associated through the polar coordinate expression. If the rotation angle θ and the point-to-line distance ρ are both constants, any point on the straight line can be expressed using the aforementioned polar coordinate expression.
[0033] In the prior art, for example, in the commonly used image processing public library Opencv, each valid point can pass through countless straight lines, and each straight line is associated with a pair of parameters (ρ, θ). The two-dimensional plane where the pair of parameters (ρ, θ) are located is defined as the Hough space, which is used to represent the storage space of the two-dimensional straight line. The Hough space is provided with a horizontal axis (abbreviated as the horizontal axis) and a vertical axis (abbreviated as the vertical axis), that is, in the Hough space designed by the image processing public library, the horizontal axis is used to represent the point-line distance ρ, and the vertical axis is used to represent the rotation angle θ. Therefore, the Hough transform can detect and obtain the output vector of the straight line. Each straight line is represented by a polar coordinate (ρ, θ) with two elements, and the same polar coordinate (ρ, θ) can represent multiple overlapping straight lines. At this time, if the horizontal coordinate is controlled to iteratively change (keep increasing or decreasing) according to a certain iteration step (pre-set), based on the inverse trigonometric function relationship, each iterative change according to a certain iteration step (regardless of size) always obtains multiple rotation angles with large angle differences as the vertical coordinates in the Hough space. In some embodiments, the angle difference is a multiple of 360 degrees and is manifested as a change in the vertical axis direction of the Hough space. On this basis, if the maximum address length of the horizontal axis of the matrix space to be read in the Hough space is C, then after the horizontal coordinate is iteratively changed according to a certain iteration step (regardless of size) each time, the target address newly read by the CPU is the sum of the last read address and an address length of C. At this time, the target address newly read by the CPU (P+C) often exceeds the address range accommodated by the cache (between the memory and the CPU, and its content is controlled by the CPU), especially in embedded devices and mobile devices with relatively small caches, which easily causes the CPU cache to fail. If the target address (P+C) most recently read by the CPU exists in the cache, the ordinate changed in each iteration will change significantly and the same abscissa will correspond to multiple ordinates. Since the matrix space stores data by row, the CPU must skip a large memory segment when reading multiple memory addresses of the latest iteration of the Hough space in sequence. Specifically, the CPU needs to read across row address segments multiple times, increasing the probability of CPU cache failure, and the efficiency of CPU reading after each iteration change is low, reducing the overall conversion efficiency of Hough transform of binary images.
[0034] In order to overcome the above technical defects, based on step S1, step S2 is disclosed, and step S2 includes: each time after performing the angle iteration scanning of the preset number of iterations on the valid points of the pre-obtained binary image, the ordinate of the corresponding point-line distance in the preset parameter mapping space is allowed to change once, that is, the ordinate of the point-line distance corresponding to the rotation angle converted in the preset parameter mapping space is adjusted to change once, so that the CPU can continuously read the image information in the memory address according to the coordinate information of the preset parameter mapping space. Wherein, the preset number of iterations is the result obtained through simulation experiments, which is used to express: under the premise that the polar coordinate formula xcosθ+ysinθ=ρ is fixed, when the rotation angle θ changes iteratively according to a certain angle step (preset, such as 0.4 degrees or 1 degree) (keeping the continuous preset number of iterations increasing or keeping the continuous preset number of iterations decreasing, it is regarded as iterative rotation), the point-line distance ρ calculated by the CPU at the corresponding rotation angle also changes accordingly, but within a smaller rotation angle change range, such as the angle range of 0.1 degrees to 1 degree, the change value between the point-line distances calculated corresponding to each rotation angle is not large, This embodiment takes advantage of this continuous value change feature, and sets the point-line distance calculated in the angle iteration scan of the preset number of iterations as the vertical coordinate of the same value in the preset parameter mapping space, that is, while the angle iteration scan of the preset number of iterations is performed, the point-line distance originally converted by the polar coordinate formula (each point-line distance corresponds to a rotation angle involved in the angle iteration scan) is converted into the same vertical coordinate adapted to the specific point-line distance precision, but when entering the angle iteration scan of the preset number of iterations included in the next round of iterative operation, the vertical coordinate adapted to the specific point-line distance precision is different from that in the angle iteration scan of the preset number of iterations in the current round. In this way, when the angle iteration scan of the preset number of iterations is performed on the valid points of the pre-obtained binary image, continuous address segments are configured in rows in the memory space with the rotation angle as the horizontal coordinate of the preset parameter mapping space and the point-line distance as the vertical coordinate of the preset parameter mapping space so that the CPU can sequentially obtain image information according to the continuous address segments configured in the corresponding cycle (in the angle iteration scan of the preset number of iterations). In summary, in the Hough transform, the straight line is scanned by an angle iteration for a preset number of times according to a certain iteration step, so that the value of the point-line distance calculated for the straight line corresponding to the continuously changing rotation angle does not change much, and the phenomenon of crossing large memory segments (such as crossing multi-row address segments) when the CPU reads the image information at the address composed of the rotation angle and the point-line distance is reduced, so that the CPU or a similar main control unit can hit the image data cached from the continuous memory multiple times, thereby improving the working efficiency of the Hough transform of the binary image, that is, improving the Hough transform efficiency of the straight line passing through the valid point within the limitation of hardware conditions.
[0035] Compared with the prior art, this embodiment designs the preset parameter mapping space as a Hough space storage method in which the horizontal axis represents the rotation angle and the vertical axis represents the point-line distance, so as to swap the meanings of the polar coordinates represented by the horizontal and vertical axes of the Hough space of the prior art. In some embodiments, five angular iteration scans are performed on a certain valid point, for example, in the process of iterative rotation from 1 degree to 2 degrees, the point-line distances of the straight line passing through the valid point are often similar (another way of saying it is that there are multiple very close straight lines passing through the point). If in the iterative process from 1 degree to 2 degrees, the point-line distances of the straight lines calculated are 0.01, 0.02, 0.03, 0.05, and 0.06 respectively, if the corresponding value precision is set to 0.1, then the vertical coordinates of the actual Hough transform to the preset parameter mapping space corresponding to these five angular iteration scans are all 0, and it is determined that these five point-line distances are in the same intercept segment and meet the same value precision. Then, according to the coordinate information of the set parameter mapping space, the addresses configured in the memory segment are continuous, and multiple horizontal coordinates (rotation angles) correspond to the vertical coordinates of the same intercept value, and the addresses at least at two adjacent memory units are configured to be continuous. In contrast, the aforementioned prior art discloses that the corresponding matrix is stored in a memory space with the rotation angle as the ordinate of the parameter mapping space and the point-line distance as the abscissa of the parameter mapping space, that is, it is stored in rows. Based on the periodicity of the inverse trigonometric function included in the aforementioned polar coordinate formula, it is easy for a person skilled in the art to know that: under the same abscissa, the address positions represented in the memory space between different ordinates are very different, and specifically, there must be a large cross-memory segment. Therefore, this embodiment significantly improves the hit probability in the high-precision linear Hough space by executing steps S1 and S2, thereby doubling the conversion speed of the linear Hough transform. Among them, this embodiment records all address units of each row of the preset parameter mapping space as a memory segment.
[0036] As another example, Figure 2 As shown, the method of allowing the corresponding point-line distance to change once in the vertical coordinate in the preset parameter mapping space after performing the angle iterative scanning for a preset number of iterations on the valid points of the pre-acquired binary image comprises:
[0037] Step S20, starting from an initial rotation angle, scanning the rotation angle of a valid point with the preset unit iteration angle as the iteration step; each time a rotation angle of the same valid point is scanned, the point-line distance of the straight line passing through the valid point at the currently scanned rotation angle is calculated, and then the point-line distance is processed as an intercept coordinate according to the preset point-line distance accuracy to determine that an angle iteration scan is performed on the valid point, and then enter step S21, wherein the aforementioned same valid point can be a valid point corresponding to multiple angle iteration scans, or any one of multiple valid points corresponding to multiple angle iteration scans, so that the representation of the same valid point is not from the beginning. Ultimately limited to the same valid point; the intercept coordinates set in this embodiment are the ordinates of the point-to-line distance of the straight line passing through the valid point in the preset parameter mapping space, that is, in step S20 disclosed in the aforementioned embodiment, the ordinate is allowed to change its value once every preset number of iterations of angle iteration scanning, forming a calculation result of a rotation angle corresponding to a preset number of iterations, and on this basis, the specific value of the preset unit iteration angle as the angle iteration step is set, so that the point-to-line distance converted from the corresponding straight line passing through the valid point does not change much during the preset number of iterations of angle iteration scanning, and can be configured to be equal under certain precision conditions. Thus, a row of continuous addresses is configured in the preset parameter mapping space, reducing the problem of reading across a large memory segment when the CPU caches image information from the preset parameter mapping space. Among them, the intercept coordinates set in this embodiment and the point-to-line distance of the straight line belong to the same type of ordinate quantity.
[0038] Step S21, judging whether the number of times the angle iterative scanning is performed on the effective point described in step S20 reaches the preset number of iterations, that is, judging whether the increment corresponding to the number of times the angle iterative scanning is performed on the effective point reaches the preset number of iterations (including but not limited to increasing from 1 to the preset number of iterations, or increasing from (preset number of iterations + 1) to (twice the preset number of iterations)), if yes, then proceed to step S22, otherwise return to step S20. It can be understood that in this embodiment, when the increment of the number of times the angle iterative scanning is performed on the effective point reaches the preset number of iterations, then proceed to step S22 and clear the increment of the counted number of times to avoid affecting the result of the next round of counting, otherwise return to step S20 and continue to use the preset unit iteration angle as the iteration step, and iteratively scan the straight line passing through the same effective point according to the preset unit iteration angle, but do not clear the increment of the counted number of times, but continue to count the number of times the angle iterative scanning is performed on this basis, until the number of times the straight line passing through the effective point is iteratively scanned reaches the preset number of iterations.
[0039] Step S22, update the rotation angle scanned by the latest iteration to the initial rotation angle, and determine that the point-line distance corresponding to the rotation angle of the preset number of iterations has been calculated. It can be that in the process of scanning the rotation angle of the preset number of iterations of the effective point, the CPU calculates multiple point-line distances in parallel; then return to execute step S20, so that the intercept coordinates obtained by returning to step S20 are different from the intercept coordinates currently obtained, that is, the intercept coordinates obtained by executing step S20 in two adjacent times are different, wherein each iteration process represents the angle iteration scanning of the preset number of iterations. Therefore, in this embodiment, every iteration process corresponding to the angle iteration scanning of the preset number of iterations, the value of the intercept coordinate processed by step S20 is changed once, and the next angle iteration scanning is continued for the effective point, which also satisfies the point-line distance processing as the intercept coordinate according to the preset point-line distance accuracy.
[0040] In some embodiments, the initial rotation angle is set to Y1, and the corresponding point-line distance is X1; if in the Hough space with the point-line distance as the horizontal axis coordinate and the rotation angle as the vertical axis coordinate, the preset unit iteration angle is used as the angle iteration step to scan the straight line passing through the same valid point, the coordinate positions of the storage addresses of the corresponding straight lines are sequentially configured as (X1, Y1), (X2, Y1+1), (X3, Y1+2), (X4, Y1+3) and (X5, Y1+4); however, in this embodiment, in the preset parameter mapping space with the vertical axis representing the intercept coordinate and the horizontal axis representing the rotation angle, the preset unit iteration angle is used as the angle iteration step to scan the straight line passing through the same valid point, and the coordinate positions of the storage addresses of the corresponding straight lines are sequentially configured as (Y1, X1), (Y1+1, X2+1, X3+2, X4+3, X4+4 ... 2), (Y1+2, X3), (Y1+3, X4) and (Y1+4, X5), where the intercept coordinates are the result of processing the point-line distance according to the preset point-line distance precision, so the storage mode of the X coordinate in the preset parameter mapping space is continuous Y1, Y1+1, Y1+2, Y1+3 and Y1+4, and the corresponding point-line distance X1, X2, X3, X4 and X5 coordinates are processed as intercept coordinates of the same value. Therefore, starting from an initial rotation angle, taking the preset unit iteration angle as the iteration step, performing the angle iteration scan of the preset number of iterations on the same valid point, the CPU can continuously access from the same row of memory addresses, discard the precision of part of the point-line distance in the local range to obtain continuous memory space, and speed up the CPU indexing speed and cache success probability. In this way, the CPU will read continuous memory data into the cache, reducing the number of times of repeatedly taking continuous segments of data from the low-speed memory.
[0041] In summary, compared with the prior art, this embodiment uses the preset unit iteration angle as the step iteration amount, and in each process of performing the angle iteration scanning of the preset number of iterations, each point-line distance obtained in sequence is converted into an equal intercept coordinate in the preset parameter mapping space, thereby obtaining index coordinates (rotation angle, intercept coordinates) that can describe continuous addresses, so that the CPU reads the image information in the continuous memory segment into the cache space according to the coordinate value of the preset parameter mapping space, avoiding each iteration causing the corresponding vertical coordinate in the Hough space to change, and the CPU needs to jump a large memory segment (offset one or more entire rows of memory addresses) each time it reads the memory. This further improves the hit probability in the high-precision straight line Hough space, thereby doubling the addressing speed of the straight line Hough transform result.
[0042] Preferably, in step S20, the method of scanning the rotation angle of a valid point with the preset unit iteration angle as the iteration step includes: in the process of executing the current angle iteration scan of a valid point, the preset unit iteration angle is added to the rotation angle scanned by the previous angle iteration scan to obtain the rotation angle scanned by the current iteration, which is equivalent to an iterative rotation of the aforementioned initial rotation angle, wherein, before executing the next angle iteration scan of the same valid point, the rotation angle scanned by the current angle iteration scan is first updated to the rotation angle scanned by the previous angle iteration scan. It is worth noting that when the angle iteration scan starts to be performed on a new valid point, it starts from the initial rotation angle that has not been updated, and scans the new valid point according to the iteration step. This embodiment uses the rotation angle iterative rotation method to control the aforementioned angle iteration scan, and controls each valid point in the original image to be able to iteratively scan the straight line at the corresponding rotation angle within a range of 360 degrees, and more comprehensively scans the straight line to be Hough transformed in the original image, where the original image is the binary image.
[0043] As another example, Figure 3 As shown, specifically comprising the following steps:
[0044] Step S301, starting from an initial rotation angle, using the preset unit iteration angle as the iteration step to scan the rotation angle of a valid point; each time a rotation angle of the same valid point is scanned, the point-line distance of the straight line of the currently scanned rotation angle passing through the valid point is calculated, and then the point-line distance is processed into an intercept coordinate according to the preset point-line distance accuracy to determine that an angle iteration scan is performed on the valid point, and then enter step S302; the intercept coordinate set in this embodiment is the ordinate of the point-line distance of the straight line passing through the valid point in the preset parameter mapping space, forming: the ordinate is allowed to change the value once every preset number of iterations of the angle iteration scan, so that the rotation angle of the consecutive preset number of iterations corresponds to the calculation result of an intercept coordinate, and on this basis, the specific value of the preset unit iteration angle as the angle iteration step is set, so that the point-line distance converted from the corresponding straight line passing through the valid point does not change much during the preset number of iterations of the angle iteration scan process, and can be configured to be equal under certain accuracy conditions. Thus, a row of continuous addresses is configured in the preset parameter mapping space, reducing the problem of CPU reading across a large memory segment when caching image information from the preset parameter mapping space. The intercept coordinates set in this embodiment and the point-to-line distance of the straight line are ordinate quantities belonging to the Hough space.
[0045] It is worth noting that the aforementioned same valid point can be a valid point corresponding to multiple angle iterative scans, or any one of multiple valid points corresponding to multiple angle iterative scans, so that the expression of the same valid point is not limited to the same valid point from beginning to end.
[0046] Step S302, judging whether the number of times the angle iterative scanning is performed on the effective point described in step S301 reaches the preset number of iterations, that is, judging whether the count increment corresponding to the number of times the angle iterative scanning is performed on the effective point reaches the preset number of iterations (including but not limited to increasing from 1 to the preset number of iterations, or increasing from (preset number of iterations + 1) to (twice the preset number of iterations)) in each iteration cycle, if yes, then proceed to step S303, otherwise, return to step S301. It can be understood that in this embodiment, when the increment of the number of times the angle iterative scanning is performed on the effective point reaches the preset number of iterations, then proceed to step S303 and clear the increment of the counted number of times, but keep the recorded number of times for the judgment of step S303, otherwise, return to step S301 and continue to use the preset unit iteration angle as the iteration step, and iteratively scan the straight line passing through the same effective point according to the preset unit iteration angle, but do not clear the increment of the counted number of times, but continue to count the number of times the angle iterative scanning is performed on this basis, until the number of times the straight line passing through the effective point is iteratively scanned reaches the preset number of iterations.
[0047] Step S303, determine whether the valid point in step S301 completes the aforementioned angular iteration scan within the range of 360 degrees, if yes, proceed to step S304, otherwise proceed to step S306. Specifically, whenever the number of angular iteration scans performed on the same valid point reaches the ratio of 360 degrees to the preset unit iteration angle, it is necessary to start repeating the aforementioned steps for the new valid point until the angular iteration scan of each valid point in the binary image within the 360-degree rotation angle range is completed; wherein the maximum number of angular iteration scans performed on each valid point is the ratio of 360 degrees to the preset unit iteration angle, which is used to set the number of angular iteration scans allowed to be performed for a corresponding valid point within the 360-degree rotation angle range, and preferably, the ratio is an integer.
[0048] Step S304, detect whether the angle iterative scanning of all valid points in the binary image is completed, if yes, stop the angle iterative scanning to wait for the straight line of the valid points of the new frame of binary image to be passed through by the Hough transform, otherwise, execute step S305. This makes the straight line parameters described in the preset parameter mapping space more comprehensive, and covers more and more comprehensive straight line segments passing through valid points in the corresponding image.
[0049] Step S305: Update the untraversed valid points of the binary image to the valid points described in step S301, and then execute step S306. An iterative control mechanism of the Hough transform of all straight lines passing through valid points in a frame of binary image is formed, where the valid points refer to all valid points in the current Hough transform of a frame of binary image.
[0050] Step S306, update the rotation angle scanned by the latest iteration to the initial rotation angle, and determine that the point-line distance corresponding to the rotation angle of the preset number of iterations has been calculated. It can be that in the process of scanning the rotation angle of the preset number of iterations of a corresponding valid point, the CPU calculates multiple point-line distances in parallel; then return to step S301 to start a new angle iteration scan for the valid point. In this way, the rotation angle scanned for the same valid point each time is different, the corresponding straight line is also different, and the image information arranged into the memory address is also different. It is worth noting that in this embodiment, every iterative process corresponding to the angle iteration scan of the preset number of iterations, the value of the intercept coordinate processed by step S301 is changed once, and the next angle iteration scan is continued for the valid point, which also satisfies the point-line distance processing as the intercept coordinate according to the preset point-line distance accuracy.
[0051] In the above embodiment, the number of rows of coordinate elements arranged in the preset parameter mapping space is the number of polar coordinate points with the same rotation angle but different point-line distances; the number of columns of coordinate elements arranged in the preset parameter mapping space is the number of polar coordinate points with the same point-line distances but different rotation angles; in this embodiment, all straight lines passing through valid points in the binary image support being Hough transformed into polar coordinate points in the Hough space, wherein different polar coordinate points represent different straight lines, and one polar coordinate point represents at least one straight line passing through a valid point; wherein the polar coordinate point includes a rotation angle and a point-line distance, the rotation angle is the angle formed by the normal of the straight line represented by the polar coordinate point and the positive direction of the horizontal axis of the coordinate system of the binary image to which it belongs, and the point-line distance is the geometric perpendicular distance from the origin of the coordinate system of the binary image to the straight line represented by the polar coordinate point. Therefore, in this embodiment, the ratio of the number of times an effective point performs angle iteration scanning to the preset number of iterations is set to the maximum number of rows of coordinate elements arranged in the Hough space required for the effective point, and the preset number of iterations is set to the maximum number of columns of coordinate elements arranged in the Hough space required for the effective point, and then the product of the aforementioned number of columns and the aforementioned number of rows is set to the number of effective addresses that the CPU is allowed to read, so that the size of the Hough space or the preset parameter mapping space is set accordingly on the basis of satisfying the preset unit iteration angle and the preset point line distance accuracy, so that the CPU can easily search for a row area with a continuous address segment in the memory through the horizontal coordinate and the vertical coordinate set in the Hough space, without storing the corresponding coordinates separately. It should be noted that the horizontal coordinate and the vertical coordinate are only for calculating the corresponding position in the memory, and then operating on the data at the corresponding position, which can also be regarded as matrix numbering in a two-dimensional matrix manner as the address coordinates of the corresponding stored data, including the coordinates of the row address (vertical coordinate) and the coordinates of the column address (horizontal coordinate).
[0052] As an embodiment, the method of processing the point-line distance into intercept coordinates according to the preset point-line distance accuracy includes:
[0053] According to the order of magnitude specified by the preset point-line distance precision, the point-line distance corresponding to each rotation angle scanned during a round of intercept precision iterative scanning operation is converted into the same intercept coordinate, so as to be converted into the ordinate of the same value in the preset parameter mapping space. In some implementation scenarios, the ordinates of the same value in the preset parameter mapping space may be successively converted. Wherein, the order of magnitude of the intercept coordinate is equal to the order of magnitude specified by the preset point-line distance precision; wherein, starting from an initial rotation angle, with the preset unit iteration angle as the iteration step, whenever the number of angle iterative scanning performed on the same valid point is counted to be the preset number of iterations, it is recorded as performing a round of intercept precision iterative scanning operation on the same valid point, that is, each round of intercept precision iterative scanning operation only performs the angle iterative scanning of the preset number of iterations; wherein, the preset point-line distance precision is configured as follows: the point-line distance calculated corresponding to each round of intercept precision iterative scanning operation is within the corresponding intercept range, and the accuracy of the intercept range meets the preset point-line distance precision; two adjacent rounds of intercept precision iterative scanning operations correspond to the calculation of two intercept coordinates with different values.
[0054] In this embodiment, the preset point-line distance precision is set unchanged. When the intercept coordinate calculated in a certain angle iterative scanning process is 1.5, if the preset point-line distance precision is set to 1, then the ordinate (the intercept coordinate) in the matrix space in the Hough space corresponding to this 1.5 is 1, corresponding to the row address position of 1; if the preset point-line distance precision is set to 0.5, then the ordinate (the intercept coordinate) in the matrix space in the Hough space corresponding to this 1.5 is 1.5, corresponding to the row address position of 1.5; in some embodiments, if the intercept coordinates calculated in each round of intercept precision iterative scanning operation are all floating point numbers, the decimal places of the preset point-line distance precision are adaptively adjusted according to the order of magnitude precision of the point-line distance (the position of the decimal point). Among them, the integer parts of a batch of point-line distances obtained in a round of intercept precision iterative scanning operation are equal, and are equal to the integer part of a corresponding intercept coordinate under the precision constraint of the preset point-line distance precision to ensure the accuracy of the integer part. Therefore, this embodiment sets the point-line distances that meet the same precision to the same intercept coordinate, and then sets the number of iterations required for each change of an intercept coordinate on this basis, that is, sets the preset number of iterations, and establishes a correspondence between multiple rotation angles and a point-line distance in the Hough transform. This embodiment, when applied to the linear Hough transform of a binary image, improves the success rate of the data stored in the Hough space being cached by the CPU, because it allows the CPU to reduce the frequency of cross-line reading, so the demand for cache is lower, and the efficiency of the Hough transform algorithm is improved.
[0055] Specifically, the method for calculating the point-to-line distance of a straight line at a rotation angle currently scanned through the effective point includes: multiplying the cosine function value of the rotation angle scanned by the current angle iteration scan by the horizontal coordinate of the effective point participating in the current angle iteration scan to obtain a first transformation value; at the same time, multiplying the sine function value of the rotation angle scanned by the current angle iteration scan by the vertical coordinate of the effective point participating in the current angle iteration scan to obtain a second transformation value; then adding the first transformation value to the second transformation value to obtain the point-to-line distance of a straight line at the rotation angle currently scanned through the effective point; wherein the cosine function value and the sine function value of the rotation angle scanned by the current angle iteration scan are both obtained from a pre-configured index table, and the index table is used to store the trigonometric function values corresponding to the rotation angles allowed to be scanned according to the preset unit iteration angle. Among them, the trigonometric function values filled in the index table are pre-set with the desired accuracy. It should be noted that the rotation angle is the angle between the normal of the straight line represented by the polar coordinate point and the positive direction of the horizontal axis of the coordinate system of the binary image to which it belongs, and the point-line distance is the geometric vertical distance from the origin of the coordinate system of the binary image to the straight line represented by the polar coordinate point. Therefore, compared with calculating the cosine function value and the sine function value once in each iteration, this embodiment uses a table lookup method to replace the calculation of trigonometric functions during each angle iteration scan, thereby improving the speed of obtaining the intercept coordinates using the aforementioned method of calculating the point-line distance, and further improving the speed of converting the straight line into the Hough space.
[0056] In the above-mentioned embodiment, the Hough transform control method further includes: configuring the latest set intercept coordinates and their corresponding rotation angles as the read addresses of the image information of the corresponding straight line, so that the image information of the binary image is configured to be read out from the corresponding memory address row by row by the CPU according to the coordinate information in the preset parameter mapping space; wherein the read address is a memory address belonging to the Hough space, supporting CPU read and write operations, and the read addresses set by successively executing the angle iteration scanning are continuous to form a memory space with continuous addresses; in this embodiment, the coordinate information in the preset parameter mapping space includes the intercept coordinates and their corresponding rotation angles, wherein the intercept coordinates are the point-line distances that have been reconfigured once, so that the intercept coordinates of the same value correspond to the rotation angles scanned successively by the number of the preset iterations, and each rotation angle scanned corresponds to a point-line distance, and each point-line distance corresponds to an intercept coordinate. It is ensured that the address established in the Hough space continuously stores the straight line features stored in the binary image row by row, so that the CPU can read continuously from the preset parameter mapping space when caching the image information, without reading across the address segment, thereby reducing the pressure of the cache. It should be noted that the cache is connected between the peripheral memory and the CPU, and its access is controlled by the CPU; in this embodiment, the CPU often reads the data stored at the continuous memory address (the coordinate position configured by the intercept coordinate and the corresponding rotation angle) into the cache to avoid repeatedly fetching continuous segments of data from the low-speed memory.
[0057] On the basis of the above embodiment, the Hough transform control method further includes: dividing the preset parameter mapping space into a plurality of block matrix spaces, wherein the memory addresses of the two adjacent block matrix spaces divided are continuous, and the CPU pre-stores the adjacent two row addresses between the two adjacent block matrix spaces, which may be the tail address of the current block matrix space and the head address of the next block matrix space are adjacent, then it is necessary to calculate and configure the block matrix index so that the CPU can continuously read the data at the corresponding address by row, wherein each block matrix space stores data by row. Specifically, the coordinate information of each block matrix space is configured to cover the intercept coordinates and the corresponding rotation angle obtained by the angle iteration scanning of the preset local number of times, and a block matrix space is represented as a matrix block with a length of K and a width of D, so that the CPU at least indexes two groups of continuous read addresses with different intercept coordinates, wherein each group of continuous read addresses is configured each time the angle iteration scanning of the preset number of iterations is performed on the same valid point, and the read addresses of the two adjacent groups are continuous; the preset local number is greater than or equal to twice the preset number of iterations. Therefore, this embodiment overcomes the problem of the CPU reading data across the entire row address segment due to the change in intercept coordinates generated during the process of the preset local number of angle iteration scanning. Because the memory is distributed in blocks, even if the vertical coordinate that the CPU currently wants to obtain changes in the Hough space, the configured read address remains in the original block matrix space, because the current block is stored continuously, and the two adjacent block matrix spaces are stored continuously. The continuous memory data stored in the current block matrix space (corresponding to a continuous memory area) can be read into the CPU cache, which will significantly reduce the access across the large memory; and based on the above embodiment, the probability of cache failure is once again reduced, and the conversion speed of the Hough transform of the straight line is further improved. In summary, the present embodiment adopts a block access method to control the changed intercept coordinates to be retained in the same block matrix space, and configures the same block matrix space to support the storage of continuous memory data, and supports continuous storage between two adjacent block matrix spaces. The memory size of a block matrix space set in the present embodiment satisfies the CPU cache for at least two groups of data stored in the continuous memory area corresponding to the coordinate information of the Hough space obtained by the angle iterative scanning of the preset number of iterations, which significantly reduces the frequency of CPU access across large memory.
[0058] Preferably, in the process of hardware implementation of the aforementioned embodiment, the CPU is configured to support parallel calculation of the point-line distance of the lines of the preset parallel number of rotation angles scanned through the effective point; wherein the preset parallel number of rotation angles scanned successively are known in advance, so that the CPU does not have to wait until a point-line distance or an intercept coordinate is calculated before starting the next angle iteration scan; the CPU is provided with a preset parallel number of calculation units inside, each of which is used to calculate the point-line distance of the lines of the rotation angles scanned through the effective point. It should be noted that the point-line distance of the preset parallel number of lines passing through an effective point corresponds to the preset parallel number of rotation angles scanned successively and iteratively; the aforementioned parallel execution is that the CPU calls the preset parallel number of calculation units to synchronously perform the calculation operation, preferably, the Neon parallelization (Neon: a SIMD instruction set in an embedded arm device, SIMD: Single Instruction Multiple Data) instruction can be used to configure the CPU to perform parallel calculation operations and determine the preset parallel number. Preferably, the preset parallel number is equal to the preset number of iterations. The technical solution of this embodiment increases the speed of calculating the Hough space coordinates by a preset number of parallel times, balances the time for the CPU to cache data from the memory (the memory space constructed in the Hough space), and increases the overall transformation speed.
[0059] The present invention also discloses a chip, which is used to store program codes corresponding to the Hough transform control method described in the aforementioned embodiment. The program codes are used to control the chip to execute the Hough transform control method, so that the chip acts as a memory control chip to cooperate with the CPU to access the memory space, so as to reduce the probability of failure of the CPU to cache the data in the preset parameter mapping space, and effectively solve the limitations of the slow processing speed and limited memory resources of the embedded platform, and provide a solution for the image recognition and positioning of the robot.
[0060] The present invention also discloses a robot equipped with the chip. The robot is also equipped with a laser sensor or a visual sensor for obtaining effective points from the collected image, and then using Hough transform to extract the features of the straight line passing through the effective point. On the one hand, the technical solution reduces the algorithm's demand for main control memory and improves the algorithm's efficiency; on the other hand, it improves the algorithm's efficiency in detecting straight lines in real-time collected images.
[0061] It will be understood by those skilled in the art that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the references to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory ROM, programmable memory PROM, electrically programmable memory EPROM, electrically erasable programmable memory EEPROM or flash memory. Volatile memory may include random access memory RAM or external cache memory.
[0062] The technical features of the above embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0063] The above embodiments only express several embodiments of the present invention, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for ordinary technicians in this field, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application.
Claims
1. A Hough transform control method based on memory configuration, characterized in that: The Hough transform control method comprises the following steps: Each time after performing an angle iterative scan for a preset number of iterations on a valid point of a pre-obtained binary image, the corresponding point-line distance is allowed to change once in the ordinate in the preset parameter mapping space; The horizontal coordinate of the preset parameter mapping space is used to represent the rotation angle of the straight line, and the horizontal coordinate of the preset parameter mapping space is configured as a column address; the vertical coordinate of the preset parameter mapping space is used to represent the point-line distance of the straight line, and the vertical coordinate of the preset parameter mapping space is configured as a row address; The preset parameter mapping space is a matrix space in the Hough space; the Hough space is set as a memory space; The method of allowing the corresponding point-line distance to change once in the vertical coordinate in the preset parameter mapping space after performing the angle iterative scanning for a preset number of iterations on the valid points of the pre-obtained binary image comprises: Step A, starting from an initial rotation angle, scanning the rotation angle of a valid point with a preset unit iteration angle as the iteration step; each time a rotation angle of the same valid point is scanned, calculating the point-line distance of the straight line of the currently scanned rotation angle passing through the valid point, and then processing the point-line distance into an intercept coordinate according to the preset point-line distance accuracy, so as to determine that an angle iteration scan is performed on the valid point, wherein the intercept coordinate is the ordinate of the corresponding point-line distance in the preset parameter mapping space; Step B: Whenever the number of angle iterative scans performed on the same valid point reaches the preset number of iterations, the rotation angle scanned by the latest iteration is updated to the initial rotation angle, and step A is repeated so that the intercept coordinates obtained by the next execution of step A are different from the intercept coordinates obtained currently.
2. The Hough transform control method according to claim 1, characterized in that: In the step A, the method of scanning the rotation angle of a valid point with the preset unit iteration angle as the iteration step includes: In the process of executing the current angle iteration scan of a valid point, the preset unit iteration angle is added to the rotation angle scanned by the previous angle iteration scan to obtain the rotation angle scanned by the current iteration; Before executing the next angle iteration scan of the same valid point, the rotation angle scanned by the current angle iteration scan is first updated to the rotation angle scanned by the previous angle iteration scan.
3. The Hough transform control method according to claim 2, characterized in that: The maximum number of times each valid point performs angle iteration scanning is the ratio of 360 degrees to the preset unit iteration angle, which is used to set the number of times the angle iteration scanning is allowed to be performed for a valid point within a rotation angle range of 360 degrees; The Hough transform control method further includes: Step C: Whenever the number of angle iterative scans performed on the same valid point reaches the ratio of 360 degrees to the preset unit iteration angle, start repeating steps A to B for a new valid point until the angle iterative scan of each valid point in the binary image within the rotation angle range of 360 degrees is completed.
4. The Hough transform control method according to claim 2, characterized in that: The number of rows of coordinate elements arranged in the preset parameter mapping space is the number of polar coordinate points with the same rotation angle but different point-line distances; the number of columns of coordinate elements arranged in the preset parameter mapping space is the number of polar coordinate points with the same point-line distance but different rotation angles; All straight lines passing through valid points in the binary image can be transformed into polar coordinate points in the Hough space by Hough transformation, where different polar coordinate points represent different straight lines, and one polar coordinate point represents at least one straight line passing through a valid point; Among them, the polar coordinate point includes a rotation angle and a point-line distance. The rotation angle is the angle between the normal of the straight line represented by the polar coordinate point and the positive direction of the horizontal axis of the coordinate system of the binary image to which it belongs. The point-line distance is the geometric perpendicular distance from the origin of the coordinate system of the binary image to the straight line represented by the polar coordinate point.
5. The Hough transform control method according to claim 1, characterized in that: The method for processing the point-line distance into intercept coordinates according to the preset point-line distance accuracy comprises: According to the order of magnitude of the preset point-line distance precision, the point-line distance corresponding to each rotation angle scanned during a round of intercept precision iterative scanning operation is converted into the same intercept coordinate, so as to be converted into the ordinate of the same value in the preset parameter mapping space, wherein the order of magnitude of the intercept coordinate is equal to the order of magnitude of the preset point-line distance precision; Wherein, starting from an initial rotation angle, taking the preset unit iteration angle as the iteration step, whenever the number of angle iteration scanning performed on the same valid point reaches the preset number of iterations, it is recorded as performing a round of intercept accuracy iteration scanning operation on the same valid point; Among them, the preset point-line distance accuracy is configured as follows: the point-line distance calculated corresponding to each round of intercept accuracy iterative scanning operation is within the corresponding intercept range, and the accuracy of the intercept range meets the preset point-line distance accuracy; two adjacent rounds of intercept accuracy iterative scanning operations correspond to the calculation of two intercept coordinates with different values.
6. The Hough transform control method according to claim 5, characterized in that: The method for calculating the point-to-line distance of a straight line of the currently scanned rotation angle passing through the effective point comprises: Multiplying the cosine function value of the rotation angle scanned by the current angle iteration scan by the horizontal coordinate of the valid point participating in the current angle iteration scan to obtain a first transformation value; Multiplying the sine function value of the rotation angle scanned by the current angle iteration scan by the ordinate of the valid point participating in the current angle iteration scan to obtain a second transformation value; Then the first transformation value is added to the second transformation value to obtain the point-to-line distance of the straight line at the currently scanned rotation angle passing through the effective point; Among them, the cosine function value and the sine function value of the rotation angle scanned by the current angle iteration scan are obtained from a pre-configured index table, and the index table is used to store the trigonometric function values corresponding to the rotation angle allowed to be scanned according to the preset unit iteration angle.
7. The Hough transform control method according to claim 1 or 5, characterized in that: The Hough transform control method further includes: configuring the most recently set intercept coordinates and their corresponding rotation angles as read addresses of image information of the corresponding straight line, so that the image information of the binary image is configured to be read out from the corresponding memory address row by row by the CPU according to the coordinate information in the preset parameter mapping space; The read address is a memory address belonging to the Hough space, and the read addresses set by successively executing the angle iteration scans are continuous, so as to form a memory space with continuous addresses; The coordinate information in the preset parameter mapping space includes the intercept coordinates and their corresponding rotation angles.
8. The Hough transform control method according to claim 7, characterized in that: The Hough transform control method further includes: Dividing the preset parameter mapping space into a plurality of block matrix spaces, wherein the memory addresses of two adjacent block matrix spaces are continuous; The coordinate information of each block matrix space is configured to cover the intercept coordinates and their corresponding rotation angles obtained by the angle iterative scan of a preset local number of times, so that the CPU can index at least two groups of consecutive read addresses with different intercept coordinates, wherein each group of consecutive read addresses is configured each time the angle iterative scan is counted to be performed on the same valid point for the preset number of iterations, and the read addresses of two adjacent groups are continuous; the preset local number of times is greater than or equal to twice the preset number of iterations.
9. The Hough transform control method according to claim 1, characterized in that: The CPU is configured to support parallel calculation of point-line distances of lines of a preset number of rotation angles that are scanned successively and pass through the effective points; A preset number of parallel computing units are arranged inside the CPU, and each computing unit is used to calculate the point-to-line distance of a straight line of a scanned rotation angle passing through a valid point.
10. A chip, characterized in that: The chip is used to store the program code corresponding to the Hough transform control method described in any one of claims 1 to 9.
11. A robot, characterized in that: The robot assembles the chip according to claim 10; The robot is also equipped with a laser sensor or a visual sensor for acquiring effective points from the collected image, and then using Hough transform to extract the features of the straight line passing through the effective points.
Citation Information
Patent Citations
Cavitation bubble image processing method based on multi-operator fusion edge detection technology
CN110766707A
Positioning control method based on map matching, chip and robot
CN113176783A