CN111141208B - Parallel line detection method and device - Google Patents

Parallel line detection method and device Download PDF

Info

Publication number
CN111141208B
CN111141208B CN201910021206.5A CN201910021206A CN111141208B CN 111141208 B CN111141208 B CN 111141208B CN 201910021206 A CN201910021206 A CN 201910021206A CN 111141208 B CN111141208 B CN 111141208B
Authority
CN
China
Prior art keywords
gradient value
gradient
determining
preset
pixel point
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910021206.5A
Other languages
Chinese (zh)
Other versions
CN111141208A (en
Inventor
黄永祯
于仕琪
徐栋
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhongke Shuidi Technology Shenzhen Co ltd
Watrix Technology Beijing Co Ltd
Original Assignee
Zhongke Shuidi Technology Shenzhen Co ltd
Watrix Technology Beijing Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhongke Shuidi Technology Shenzhen Co ltd, Watrix Technology Beijing Co Ltd filed Critical Zhongke Shuidi Technology Shenzhen Co ltd
Priority to CN201910021206.5A priority Critical patent/CN111141208B/en
Publication of CN111141208A publication Critical patent/CN111141208A/en
Application granted granted Critical
Publication of CN111141208B publication Critical patent/CN111141208B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G01MEASURING; TESTING
    • G01BMEASURING LENGTH, THICKNESS OR SIMILAR LINEAR DIMENSIONS; MEASURING ANGLES; MEASURING AREAS; MEASURING IRREGULARITIES OF SURFACES OR CONTOURS
    • G01B11/00Measuring arrangements characterised by the use of optical techniques
    • G01B11/002Measuring arrangements characterised by the use of optical techniques for measuring two or more coordinates

Landscapes

  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Image Analysis (AREA)

Abstract

The application provides a parallel line detection method and a device, comprising the following steps: acquiring an image to be detected; determining the gradient value of each pixel point according to the horizontal gradient in the horizontal direction and the vertical gradient in the vertical direction of each pixel point in the image to be detected; mapping the position coordinates of each pixel point to a polar coordinate system to obtain a mapping straight line corresponding to each pixel point, and determining the intersecting characteristic point of at least two mapping straight lines in the polar coordinate system; determining two characteristic points with the distance between the characteristic points being a preset distance as a characteristic point pair; and determining parallel lines in the image to be detected according to the characteristic point pairs meeting preset conditions. By the method, the parallel lines in the image to be detected can be directly determined according to the selected characteristic point pairs, and the parallel lines do not need to be determined after the straight lines are determined, so that the parallel line detection efficiency is improved.

Description

Parallel line detection method and device
Technical Field
The application relates to the technical field of image detection, in particular to a parallel line detection method and device.
Background
When detecting components, for example, whether the sizes of the components meet the requirements, a parallel line detection algorithm is generally used.
At present, in the method for determining parallel lines with a preset distance in an image to be detected, all straight lines in the image to be detected are detected first, and then parallel lines meeting the preset distance condition are screened from the obtained straight lines, so that the problem of low detection speed exists.
Disclosure of Invention
In view of the above, an object of the present invention is to provide a parallel line detection method and apparatus, so as to improve the efficiency of parallel line detection in image detection.
In a first aspect, an embodiment of the present application provides a parallel line detection method, including:
acquiring an image to be detected;
determining the gradient value of each pixel point according to the horizontal gradient in the horizontal direction and the vertical gradient in the vertical direction of each pixel point in the image to be detected;
mapping the position coordinates of each pixel point to a polar coordinate system to obtain a mapping curve corresponding to each pixel point, and determining the intersecting characteristic point of at least two mapping curves in the polar coordinate system;
determining two characteristic points with the distance between the characteristic points being a preset distance as a characteristic point pair;
and determining parallel lines in the image to be detected according to the characteristic point pairs meeting preset conditions.
With reference to the first aspect, an embodiment of the present application provides a first possible implementation manner of the first aspect, where determining parallel lines in the image to be detected according to the feature point pairs meeting preset conditions includes:
determining a pixel point corresponding to a mapping curve of the characteristic points included in each pair of characteristic points as a first selected pixel point;
calculating the sum of the gradient values of the first selected pixel points;
determining the characteristic point pairs with the sum of the gradient values meeting a preset gradient condition as selected characteristic point pairs;
determining pixel points corresponding to each mapping curve of the feature points included by the selected feature point pair as second selected pixel points;
and determining parallel lines in the image to be detected according to the second selected pixel points.
With reference to the first possible implementation manner of the first aspect, this example provides a second possible implementation manner of the first aspect, where the determining, as the selected characteristic point pair, the characteristic point pair whose sum of the gradient values satisfies a preset gradient condition includes:
determining the characteristic point pairs with the sum of the gradient values larger than a preset threshold value as selected characteristic point pairs; or,
and sequencing the sum of the gradient values corresponding to each characteristic point pair from large to small, and determining the characteristic point pairs arranged at the front M positions as selected characteristic point pairs, wherein M is a positive integer.
With reference to the first aspect, an embodiment of the present application provides a third possible implementation manner of the first aspect, where determining a gradient value of each pixel point according to a horizontal gradient in a horizontal direction and a vertical gradient in a vertical direction of each pixel point in the to-be-detected image includes:
aiming at the ith pixel point in the image to be detected, the following operations are executed:
respectively calculating a first gradient value in the horizontal direction and a second gradient value in the vertical direction of the ith pixel point;
determining a third gradient value of the ith pixel point according to the first gradient value and the second gradient value;
judging whether the third gradient value is within a preset gradient value range, and if so, determining the third gradient value as the gradient value of the ith pixel point; and if the judgment result is negative, adjusting the third gradient value, and determining the adjusted third gradient value as the gradient value of the ith pixel point.
With reference to the third possible implementation manner of the first aspect, this application example provides a fourth possible implementation manner of the first aspect, where, when the third gradient value is not within the preset gradient value range, adjusting the third gradient value includes:
when the third gradient value is smaller than the minimum value of the preset gradient value range, adjusting the third gradient value to be the minimum value of the preset gradient value range;
and when the third gradient value is larger than the maximum value of the preset gradient value range, adjusting the third gradient value to be the maximum value of the preset gradient value range.
In a second aspect, an embodiment of the present application further provides a parallel line detection apparatus, including:
the acquisition module is used for acquiring an image to be detected;
the first determining module is used for determining the gradient value of each pixel point according to the horizontal gradient in the horizontal direction and the vertical gradient in the vertical direction of each pixel point in the image to be detected;
the second determining module is used for mapping the position coordinates of each pixel point to a polar coordinate system to obtain a mapping curve corresponding to each pixel point, and determining the intersecting characteristic point of at least two mapping curves in the polar coordinate system;
a third determining module, configured to determine two feature points with a preset distance between the feature points as a feature point pair;
and the fourth determining module is used for determining parallel lines in the image to be detected according to the characteristic point pairs meeting the preset conditions.
With reference to the second aspect, an embodiment of the present application provides a first possible implementation manner of the second aspect, where the fourth determining module, when determining parallel lines in the image to be detected according to the feature point pairs meeting preset conditions, is specifically configured to:
determining a pixel point corresponding to a mapping curve of the characteristic points included in each pair of characteristic points as a first selected pixel point;
calculating the sum of the gradient values of the first selected pixel points;
determining the characteristic point pairs with the sum of the gradient values meeting a preset gradient condition as selected characteristic point pairs;
determining pixel points corresponding to each mapping curve of the feature points included by the selected feature point pair as second selected pixel points;
and determining parallel lines in the image to be detected according to the second selected pixel points.
With reference to the first possible implementation manner of the second aspect, this embodiment provides a second possible implementation manner of the second aspect, where the fourth determining module, when determining, as the selected feature point pair, the feature point pair whose sum of the gradient values satisfies the preset gradient condition, is specifically configured to:
determining the characteristic point pairs with the sum of the gradient values larger than a preset threshold value as selected characteristic point pairs; or,
and sequencing the sum of the gradient values corresponding to each characteristic point pair from large to small, and determining the characteristic point pairs arranged at the front M positions as selected characteristic point pairs, wherein M is a positive integer.
In combination with the second aspect, an embodiment of the present application provides a third possible implementation manner of the second aspect, wherein the first determining module is specifically configured to, when determining the gradient value of each pixel point according to the horizontal gradient in the horizontal direction and the vertical gradient in the vertical direction of each pixel point in the to-be-detected image:
aiming at the ith pixel point in the image to be detected, the following operations are executed:
respectively calculating a first gradient value in the horizontal direction and a second gradient value in the vertical direction of the ith pixel point;
determining a third gradient value of the ith pixel point according to the first gradient value and the second gradient value;
judging whether the third gradient value is within a preset gradient value range, and if so, determining the third gradient value as the gradient value of the ith pixel point; and if the judgment result is negative, adjusting the third gradient value, and determining the adjusted third gradient value as the gradient value of the ith pixel point.
With reference to the third possible implementation manner of the second aspect, this embodiment provides a fourth possible implementation manner of the second aspect, where the first determining module, when the third gradient value is not within the preset gradient value range, is specifically configured to:
when the third gradient value is smaller than the minimum value of the preset gradient value range, adjusting the third gradient value to be the minimum value of the preset gradient value range;
and when the third gradient value is larger than the maximum value of the preset gradient value range, adjusting the third gradient value to be the maximum value of the preset gradient value range.
In a third aspect, an embodiment of the present application further provides an electronic device, including: a processor, a memory and a bus, the memory storing machine-readable instructions executable by the processor, the processor and the memory communicating via the bus when the electronic device is running, the machine-readable instructions when executed by the processor performing the steps of the first aspect described above, or any possible implementation of the first aspect.
In a fourth aspect, this application further provides a computer-readable storage medium, on which a computer program is stored, where the computer program is executed by a processor to perform the steps in the first aspect or any one of the possible implementation manners of the first aspect.
According to the method and the device for detecting the straight line, the gradient value of each pixel point is determined through the horizontal gradient in the horizontal direction and the vertical gradient in the vertical direction of each pixel point in the image to be detected; and then mapping the position coordinates of each pixel point into a polar coordinate system to obtain a mapping curve corresponding to each pixel point, determining intersecting characteristic points of the mapping curve in the polar coordinate system, screening at least one pair of characteristic point pairs with a preset distance from the characteristic points, and determining parallel lines in the image to be detected according to the characteristic point pairs meeting preset conditions. By the method, the parallel lines in the image to be detected can be directly determined according to the selected characteristic point pairs, and the parallel lines do not need to be determined after the straight lines are determined, so that the parallel line detection efficiency is improved.
In order to make the aforementioned objects, features and advantages of the present application more comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are required to be used in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present application and therefore should not be considered as limiting the scope, and for those skilled in the art, other related drawings can be obtained from the drawings without inventive effort.
FIG. 1 is a schematic flow chart illustrating a parallel line detection method provided by an embodiment of the present application;
FIG. 2 is a flow chart illustrating a method for determining gradient values of pixel points according to an embodiment of the present disclosure;
FIG. 3 illustrates a vector summation method provided by an embodiment of the present application;
FIG. 4 is a schematic flowchart illustrating a method for determining parallel lines in an image to be detected according to pairs of feature points meeting a preset condition according to an embodiment of the present application;
fig. 5 is a schematic diagram illustrating an architecture of a parallel line detection apparatus 600 according to an embodiment of the present application;
fig. 6 shows an architecture diagram of an electronic device 700 provided in an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all the embodiments. The components of the embodiments of the present application, generally described and illustrated in the figures herein, can be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present application, presented in the accompanying drawings, is not intended to limit the scope of the claimed application, but is merely representative of selected embodiments of the application. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the present application without making any creative effort, shall fall within the protection scope of the present application.
First, an application scenario to which the method provided in the present application is applicable is described. The method provided by the application can be applied to the detection of parallel lines at a fixed distance, for example, a rectangular object with a known width is positioned in an image. In the prior art, the detection of the parallel lines at the fixed distance is realized by detecting straight lines firstly, then detecting the parallel lines according to the detected straight lines and determining the parallel lines at the fixed distance according to the distance between the detected parallel lines, and the detection efficiency of the method is lower.
In the method provided by the application, every pixel point of an image to be detected is mapped to a polar coordinate system, and the characteristic points are determined according to the mapping curve corresponding to the pixel points in the polar coordinate system, then the characteristic point pairs are selected according to the distance between the characteristic points, and finally the parallel lines in the image to be detected are determined according to the characteristic point pairs meeting the preset conditions.
For the understanding of the present embodiment, a detailed description will be given to a parallel line detection method disclosed in the embodiments of the present application.
Example one
Referring to fig. 1, a schematic flow chart of a parallel line detection method provided in the embodiment of the present application is shown, including the following steps:
and S101, acquiring an image to be detected.
S102, determining the gradient value of each pixel point according to the horizontal gradient in the horizontal direction and the vertical gradient in the vertical direction of each pixel point in the image to be detected.
In specific implementation, for the ith pixel point in the image to be detected, the gradient value of the ith pixel point can be determined according to the method for determining the gradient value of the pixel point as shown in fig. 2, and the method comprises the following steps:
s201, respectively calculating a first gradient value in the horizontal direction and a second gradient value in the vertical direction of the ith pixel point.
In a possible implementation manner, if the position of the ith pixel point in the image to be detected is set as the jth row and the kth column, the first gradient value in the horizontal direction of the ith pixel point can be calculated according to the following formula:
i1=aj,k+1-aj,k-1
wherein i1Represents the ithFirst gradient value, a, of pixel points in horizontal directionj,k+1The pixel value, a, of the jth row and the (k + 1) th column pixelj,k-1And the pixel value of the pixel point of the (j) th row and the (k-1) th column is represented.
Similarly, the second gradient value in the vertical direction of the ith pixel point can be calculated according to the following formula:
i2=aj+1,k-aj-1,k
wherein i2A second gradient value, a, representing the horizontal direction of the ith pixel pointj+1,kThe pixel value of the pixel point of the kth column of the j +1 th row, aj-1,kAnd the pixel value of the pixel point of the kth column of the j-1 th row is represented.
S202, determining a third gradient value of the ith pixel point according to the first gradient value and the second gradient value.
In a possible implementation manner, the third gradient value of the i-th pixel point may be calculated according to a vector summation method, and as shown in fig. 3, if OA is the first gradient value and OB is the second gradient value, the magnitude and direction of the third gradient value OC may be calculated according to the vector summation method.
Specifically, the third gradient value may be calculated according to the following formula:
Figure GDA0003073119330000081
wherein i1A first gradient value i representing the horizontal direction of the ith pixel point2A second gradient value i representing the vertical direction of the ith pixel point3And a third gradient value representing the ith pixel point.
S203, judging whether the third gradient value is in a preset gradient value range.
If yes, executing step S204 in sequence;
if the determination result is negative, step S205 is executed.
In an example of the present application, the preset gradient value range may be [ -127,127], or the preset gradient value range may be set according to specific situations, which is not limited in the present application.
And S204, determining the third gradient value as the gradient value of the ith pixel point.
And S205, adjusting the third gradient value, and determining the adjusted third gradient value as the gradient value of the ith pixel point.
Under a possible scene, noise may occur in the image to be detected, which results in too large or too small third gradient value, and in order to prevent the detection error of parallel lines caused by too large or too small third gradient value, the pixel points which are not in the range of the preset gradient value can be adjusted to the range of the preset gradient value.
In specific implementation, when the third gradient value is smaller than the minimum value of the preset gradient value range, the third gradient value can be adjusted to the minimum value of the preset gradient value range; and when the third gradient value is larger than the maximum value of the preset gradient value range, adjusting the third gradient value to be the maximum value of the preset gradient value range.
S103, mapping the position coordinates of each pixel point to a polar coordinate system to obtain a mapping curve corresponding to each pixel point, and determining the intersecting characteristic point of at least two mapping curves in the polar coordinate system.
And the position coordinates of the determined pixel points in the image to be detected are two-dimensional rectangular coordinates, and the points in the two-dimensional rectangular coordinates are mapped to a polar coordinate system to obtain a corresponding mapping curve.
And mapping the position coordinates of each pixel point in the image to be detected into a polar coordinate system, wherein each pixel point corresponds to one mapping curve, and the intersection point of the mapping curves in the polar coordinate system possibly corresponds to a straight line in a two-dimensional rectangular coordinate system.
And S104, determining two characteristic points with the distance between the characteristic points as a preset distance as a characteristic point pair.
The feature points in the polar coordinate system may correspond to straight lines in the two-dimensional rectangular coordinate system, and then two feature points with a distance of L in the polar coordinate system may correspond to a group of parallel lines with a distance of L. Therefore, two characteristic points with the distance between the characteristic points being the preset distance are selected as the characteristic point pairs, and then parallel lines with the distance being the preset distance are selected according to the gradient values of the pixel points corresponding to the mapping curves of the characteristic points included in the characteristic point pairs.
For example, if the preset distance is W, five feature points a, B, C, D, and E are included in the polar coordinate system, the distance between a and B is W, and the distance between a and D is also W, a, B, A, and D are respectively determined as feature point pairs.
And S105, determining parallel lines in the image to be detected according to the characteristic point pairs meeting the preset conditions.
In a possible implementation, the method shown in fig. 4 may be implemented to determine parallel lines in the image to be detected according to the pairs of feature points meeting the preset condition, and includes the following steps:
s501, determining pixel points corresponding to the mapping curves of the feature points included in each pair of feature points as first selected pixel points.
S502, calculating the sum of the gradient values of the first selected pixel point.
And S503, determining the characteristic point pairs with the sum of the gradient values meeting the preset gradient condition as selected characteristic point pairs.
When the feature point pair with the gradient sum meeting the preset gradient condition is determined as the selected feature point pair, the feature point pair with the gradient value sum larger than the preset threshold value can be determined as the selected feature point pair; or, sorting the sum of the gradient values corresponding to each characteristic point pair from large to small, and determining the characteristic point pairs arranged at the top M as selected characteristic point pairs, wherein M is a positive integer.
S504, determining pixel points corresponding to each mapping curve of the feature points included by the selected feature point pair as second selected pixel points.
And S505, determining parallel lines in the image to be detected according to the second selected pixel points.
The second selected pixel points are pixel points on parallel lines in the image to be detected, so that the parallel lines in the image to be detected can be determined through the selected second selected pixel points.
In an example of the present application, if it is determined that more than one set of parallel lines in the image to be detected is present after the steps S101 to S105, the sum of the gradient values corresponding to each set of parallel lines may be output, and each set of parallel lines may be labeled in the image to be detected, for example, two straight lines of the same set of parallel lines may be labeled in the same color, different sets of parallel lines may be labeled in different colors, and the sum of the gradient values corresponding to each set of parallel lines may be output, and a user may determine a required parallel line according to the parallel lines labeled in the image to be detected and the sum of the gradient values corresponding to each set of parallel lines.
According to the straight line detection method provided by the embodiment of the application, the gradient value of each pixel point is determined through the horizontal gradient in the horizontal direction and the vertical gradient in the vertical direction of each pixel point in the image to be detected; and then mapping the position coordinates of each pixel point into a polar coordinate system to obtain a mapping curve corresponding to each pixel point, determining intersecting characteristic points of the mapping curve in the polar coordinate system, screening at least one pair of characteristic point pairs with a preset distance from the characteristic points, and determining parallel lines in the image to be detected according to the characteristic point pairs meeting preset conditions. By the method, the parallel lines in the image to be detected can be directly determined according to the selected characteristic point pairs, and the parallel lines do not need to be determined after the straight lines are determined, so that the parallel line detection efficiency is improved.
Example two
An embodiment of the present application provides a parallel line detection apparatus, and as shown in fig. 5, for an architectural schematic diagram of a parallel line detection apparatus 600 provided in an embodiment of the present application, the apparatus 600 includes: the obtaining module 601, the first determining module 602, the second determining module 603, the third determining module 604, and the fourth determining module 605 specifically:
an obtaining module 601, configured to obtain an image to be detected;
a first determining module 602, configured to determine a gradient value of each pixel according to a horizontal gradient in a horizontal direction and a vertical gradient in a vertical direction of each pixel in the image to be detected;
a second determining module 603, configured to map the position coordinates of each pixel point to a polar coordinate system to obtain a mapping curve corresponding to each pixel point, and determine a feature point where at least two mapping curves in the polar coordinate system intersect;
a third determining module 604, configured to determine two feature points with a preset distance between the feature points as a feature point pair;
a fourth determining module 605, configured to determine parallel lines in the image to be detected according to the feature point pairs meeting preset conditions.
In a possible implementation manner, the fourth determining module 605, when determining parallel lines in the image to be detected according to the feature point pairs meeting the preset condition, is specifically configured to:
determining a pixel point corresponding to a mapping curve of the characteristic points included in each pair of characteristic points as a first selected pixel point;
calculating the sum of the gradient values of the first selected pixel points;
determining the characteristic point pairs with the sum of the gradient values meeting a preset gradient condition as selected characteristic point pairs;
determining pixel points corresponding to each mapping curve of the feature points included by the selected feature point pair as second selected pixel points;
and determining parallel lines in the image to be detected according to the second selected pixel points.
In a possible implementation manner, the fourth determining module 605, when determining the feature point pair whose sum of the gradient values satisfies the preset gradient condition as the selected feature point pair, is specifically configured to:
determining the characteristic point pairs with the sum of the gradient values larger than a preset threshold value as selected characteristic point pairs; or,
and sequencing the sum of the gradient values corresponding to each characteristic point pair from large to small, and determining the characteristic point pairs arranged at the front M positions as selected characteristic point pairs, wherein M is a positive integer.
In a possible implementation manner, the first determining module 602 is specifically configured to, when determining the gradient value of each pixel according to the horizontal gradient in the horizontal direction and the vertical gradient in the vertical direction of each pixel in the image to be detected:
aiming at the ith pixel point in the image to be detected, the following operations are executed:
respectively calculating a first gradient value in the horizontal direction and a second gradient value in the vertical direction of the ith pixel point;
determining a third gradient value of the ith pixel point according to the first gradient value and the second gradient value;
judging whether the third gradient value is within a preset gradient value range, and if so, determining the third gradient value as the gradient value of the ith pixel point; and if the judgment result is negative, adjusting the third gradient value, and determining the adjusted third gradient value as the gradient value of the ith pixel point.
In a possible implementation manner, the first determining module 602, when adjusting the third gradient value when the third gradient value is not within the preset gradient value range, is specifically configured to:
when the third gradient value is smaller than the minimum value of the preset gradient value range, adjusting the third gradient value to be the minimum value of the preset gradient value range;
and when the third gradient value is larger than the maximum value of the preset gradient value range, adjusting the third gradient value to be the maximum value of the preset gradient value range.
The device provided by the embodiment can directly determine the parallel lines in the image to be detected according to the selected characteristic point pairs without determining straight lines and then determining the parallel lines, so that the parallel line detection efficiency is improved.
EXAMPLE III
Based on the same technical concept, the embodiment of the application also provides the electronic equipment. Referring to fig. 6, a schematic structural diagram of an electronic device 700 provided in the embodiment of the present application includes a processor 701, a memory 702, and a bus 703. The memory 702 is used for storing execution instructions and includes a memory 7021 and an external memory 7022; the memory 7021 is also referred to as an internal memory, and is used to temporarily store operation data in the processor 701 and data exchanged with an external memory 7022 such as a hard disk, the processor 701 exchanges data with the external memory 7022 through the memory 7021, and when the electronic device 700 is operated, the processor 701 and the memory 702 communicate with each other through the bus 703, so that the processor 701 executes the following instructions:
acquiring an image to be detected;
determining the gradient value of each pixel point according to the horizontal gradient in the horizontal direction and the vertical gradient in the vertical direction of each pixel point in the image to be detected;
mapping the position coordinates of each pixel point to a polar coordinate system to obtain a mapping curve corresponding to each pixel point, and determining the intersecting characteristic point of at least two mapping curves in the polar coordinate system;
determining two characteristic points with the distance between the characteristic points being a preset distance as a characteristic point pair;
and determining parallel lines in the image to be detected according to the characteristic point pairs meeting preset conditions.
In a possible design, in the processing executed by the processor 701, the determining parallel lines in the image to be detected according to the feature point pairs meeting the preset condition includes:
determining a pixel point corresponding to a mapping curve of the characteristic points included in each pair of characteristic points as a first selected pixel point;
calculating the sum of the gradient values of the first selected pixel points;
determining the characteristic point pairs with the sum of the gradient values meeting a preset gradient condition as selected characteristic point pairs;
determining pixel points corresponding to each mapping curve of the feature points included by the selected feature point pair as second selected pixel points;
and determining parallel lines in the image to be detected according to the second selected pixel points.
In one possible design, the processing performed by the processor 701, wherein the determining, as the selected characteristic point pair, the characteristic point pair whose sum of the gradient values satisfies the preset gradient condition includes:
determining the characteristic point pairs with the sum of the gradient values larger than a preset threshold value as selected characteristic point pairs; or,
and sequencing the sum of the gradient values corresponding to each characteristic point pair from large to small, and determining the characteristic point pairs arranged at the front M positions as selected characteristic point pairs, wherein M is a positive integer.
In a possible design, in the processing executed by the processor 701, determining a gradient value of each pixel point according to a horizontal gradient in a horizontal direction and a vertical gradient in a vertical direction of each pixel point in the image to be detected includes:
aiming at the ith pixel point in the image to be detected, the following operations are executed:
respectively calculating a first gradient value in the horizontal direction and a second gradient value in the vertical direction of the ith pixel point;
determining a third gradient value of the ith pixel point according to the first gradient value and the second gradient value;
judging whether the third gradient value is within a preset gradient value range, and if so, determining the third gradient value as the gradient value of the ith pixel point; and if the judgment result is negative, adjusting the third gradient value, and determining the adjusted third gradient value as the gradient value of the ith pixel point.
In one possible design, the processor 701 may perform a process of adjusting the third gradient value when the third gradient value is not within the preset gradient value range, including:
when the third gradient value is smaller than the minimum value of the preset gradient value range, adjusting the third gradient value to be the minimum value of the preset gradient value range;
and when the third gradient value is larger than the maximum value of the preset gradient value range, adjusting the third gradient value to be the maximum value of the preset gradient value range.
Example four
An embodiment of the present application further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the steps of the parallel line detection method described in any of the above embodiments are performed.
Specifically, the storage medium can be a general-purpose storage medium, such as a removable disk, a hard disk, or the like, and when a computer program on the storage medium is executed, the steps of the parallel line detection method can be executed, so that the efficiency of parallel line detection is improved.
The computer program product for performing the parallel line detection method provided in the embodiment of the present application includes a computer-readable storage medium storing a nonvolatile program code executable by a processor, where instructions included in the program code may be used to execute the method described in the foregoing method embodiment, and specific implementation may refer to the method embodiment, and is not described herein again.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the several embodiments provided in the present application, it should be understood that the disclosed system, apparatus and method may be implemented in other ways. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one logical division, and there may be other divisions when actually implemented, and for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of devices or units through some communication interfaces, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a non-volatile computer-readable storage medium executable by a processor. Based on such understanding, the technical solution of the present application or portions thereof that substantially contribute to the prior art may be embodied in the form of a software product stored in a storage medium and including instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
Finally, it should be noted that: the above-mentioned embodiments are only specific embodiments of the present application, and are used for illustrating the technical solutions of the present application, but not limiting the same, and the scope of the present application is not limited thereto, and although the present application is described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: any person skilled in the art can modify or easily conceive the technical solutions described in the foregoing embodiments or equivalent substitutes for some technical features within the technical scope disclosed in the present application; such modifications, changes or substitutions do not depart from the spirit and scope of the exemplary embodiments of the present application, and are intended to be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (10)

1. A method for parallel line detection, comprising:
acquiring an image to be detected;
determining the gradient value of each pixel point according to the horizontal gradient in the horizontal direction and the vertical gradient in the vertical direction of each pixel point in the image to be detected;
mapping the position coordinates of each pixel point to a polar coordinate system to obtain a mapping curve corresponding to each pixel point, and determining the intersecting characteristic point of at least two mapping curves in the polar coordinate system;
determining two characteristic points with the distance between the characteristic points being a preset distance as a characteristic point pair;
determining parallel lines in the image to be detected according to the characteristic point pairs meeting preset conditions;
the determining parallel lines in the image to be detected according to the characteristic point pairs meeting the preset conditions comprises the following steps:
determining a pixel point corresponding to a mapping curve of the characteristic points included in each pair of characteristic points as a first selected pixel point;
calculating the sum of the gradient values of the first selected pixel points;
determining the characteristic point pairs with the sum of the gradient values meeting a preset gradient condition as selected characteristic point pairs;
determining pixel points corresponding to each mapping curve of the feature points included by the selected feature point pair as second selected pixel points;
and determining parallel lines in the image to be detected according to the second selected pixel points.
2. The method according to claim 1, wherein the determining, as the selected pair of characteristic points, the pair of characteristic points whose sum of the gradient values satisfies a preset gradient condition comprises:
determining the characteristic point pairs with the sum of the gradient values larger than a preset threshold value as selected characteristic point pairs; or,
and sequencing the sum of the gradient values corresponding to each characteristic point pair from large to small, and determining the characteristic point pairs arranged at the front M positions as selected characteristic point pairs, wherein M is a positive integer.
3. The method according to claim 1, wherein determining the gradient value of each pixel point according to the horizontal gradient in the horizontal direction and the vertical gradient in the vertical direction of each pixel point in the image to be detected comprises:
aiming at the ith pixel point in the image to be detected, the following operations are executed:
respectively calculating a first gradient value in the horizontal direction and a second gradient value in the vertical direction of the ith pixel point;
determining a third gradient value of the ith pixel point according to the first gradient value and the second gradient value; wherein the third gradient value is generated by vector summing the first gradient value and the second gradient value;
judging whether the third gradient value is within a preset gradient value range, and if so, determining the third gradient value as the gradient value of the ith pixel point; and if the judgment result is negative, adjusting the third gradient value, and determining the adjusted third gradient value as the gradient value of the ith pixel point.
4. The method of claim 3, wherein adjusting the third gradient value when the third gradient value is not within the preset gradient value range comprises:
when the third gradient value is smaller than the minimum value of the preset gradient value range, adjusting the third gradient value to be the minimum value of the preset gradient value range;
and when the third gradient value is larger than the maximum value of the preset gradient value range, adjusting the third gradient value to be the maximum value of the preset gradient value range.
5. A parallel line detection apparatus, comprising:
the acquisition module is used for acquiring an image to be detected;
the first determining module is used for determining the gradient value of each pixel point according to the horizontal gradient in the horizontal direction and the vertical gradient in the vertical direction of each pixel point in the image to be detected;
the second determining module is used for mapping the position coordinates of each pixel point to a polar coordinate system to obtain a mapping curve corresponding to each pixel point, and determining the intersecting characteristic point of at least two mapping curves in the polar coordinate system;
a third determining module, configured to determine two feature points with a preset distance between the feature points as a feature point pair;
the fourth determining module is used for determining parallel lines in the image to be detected according to the characteristic point pairs meeting preset conditions;
the fourth determining module is specifically configured to, when determining parallel lines in the image to be detected according to the feature point pairs meeting preset conditions:
determining a pixel point corresponding to a mapping curve of the characteristic points included in each pair of characteristic points as a first selected pixel point;
calculating the sum of the gradient values of the first selected pixel points;
determining the characteristic point pairs with the sum of the gradient values meeting a preset gradient condition as selected characteristic point pairs;
determining pixel points corresponding to each mapping curve of the feature points included by the selected feature point pair as second selected pixel points;
and determining parallel lines in the image to be detected according to the second selected pixel points.
6. The apparatus according to claim 5, wherein the fourth determining module, when determining the pair of feature points whose sum of the gradient values satisfies a preset gradient condition as the selected pair of feature points, is specifically configured to:
determining the characteristic point pairs with the sum of the gradient values larger than a preset threshold value as selected characteristic point pairs; or,
and sequencing the sum of the gradient values corresponding to each characteristic point pair from large to small, and determining the characteristic point pairs arranged at the front M positions as selected characteristic point pairs, wherein M is a positive integer.
7. The apparatus according to claim 5, wherein the first determining module, when determining the gradient value of each pixel point according to the horizontal gradient in the horizontal direction and the vertical gradient in the vertical direction of each pixel point in the image to be detected, is specifically configured to:
aiming at the ith pixel point in the image to be detected, the following operations are executed:
respectively calculating a first gradient value in the horizontal direction and a second gradient value in the vertical direction of the ith pixel point;
determining a third gradient value of the ith pixel point according to the first gradient value and the second gradient value; wherein the third gradient value is generated by vector summing the first gradient value and the second gradient value;
judging whether the third gradient value is within a preset gradient value range, and if so, determining the third gradient value as the gradient value of the ith pixel point; and if the judgment result is negative, adjusting the third gradient value, and determining the adjusted third gradient value as the gradient value of the ith pixel point.
8. The apparatus of claim 7, wherein the first determining module, when adjusting the third gradient value when the third gradient value is not within the preset gradient value range, is specifically configured to:
when the third gradient value is smaller than the minimum value of the preset gradient value range, adjusting the third gradient value to be the minimum value of the preset gradient value range;
and when the third gradient value is larger than the maximum value of the preset gradient value range, adjusting the third gradient value to be the maximum value of the preset gradient value range.
9. An electronic device, comprising: a processor, a memory and a bus, the memory storing machine-readable instructions executable by the processor, the processor and the memory communicating over the bus when the electronic device is operating, the machine-readable instructions when executed by the processor performing the steps of the parallel line detection method of any one of claims 1 to 4.
10. A computer-readable storage medium, having stored thereon a computer program which, when being executed by a processor, carries out the steps of the parallel line detection method according to any one of claims 1 to 4.
CN201910021206.5A 2019-01-09 2019-01-09 Parallel line detection method and device Active CN111141208B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910021206.5A CN111141208B (en) 2019-01-09 2019-01-09 Parallel line detection method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910021206.5A CN111141208B (en) 2019-01-09 2019-01-09 Parallel line detection method and device

Publications (2)

Publication Number Publication Date
CN111141208A CN111141208A (en) 2020-05-12
CN111141208B true CN111141208B (en) 2021-08-27

Family

ID=70516571

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910021206.5A Active CN111141208B (en) 2019-01-09 2019-01-09 Parallel line detection method and device

Country Status (1)

Country Link
CN (1) CN111141208B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111709929B (en) * 2020-06-15 2023-01-20 北京航空航天大学 Lung canceration region segmentation and classification detection system
CN114972769B (en) * 2022-06-17 2023-07-28 北京百度网讯科技有限公司 Image processing method, three-dimensional map generation method, device, equipment and medium
CN116804532B (en) * 2023-08-24 2023-11-28 苏州中科行智智能科技有限公司 3D measurement method for distance between parallel line segments

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5901252A (en) * 1991-12-11 1999-05-04 Fujitsu Limited Process and apparatus for extracting and recognizing figure elements using division into receptive fields, polar transformation, application of one-dimensional filter, and correlation between plurality of images
CN1667351A (en) * 2005-04-06 2005-09-14 北京航空航天大学 Method for automatically extracting image feature points of workpiece with rough grain under the strong reflection background
JP2008003793A (en) * 2006-06-21 2008-01-10 Toyota Motor Corp Image processing apparatus and image processing program
CN103914830A (en) * 2014-02-22 2014-07-09 小米科技有限责任公司 Straight line detection method and device
CN104424475A (en) * 2013-09-10 2015-03-18 阿里巴巴集团控股有限公司 Method and device for identifying stripe region in image
CN105184830A (en) * 2015-08-28 2015-12-23 华中科技大学 Symmetry image symmetric axis detection positioning method
CN106251332A (en) * 2016-07-17 2016-12-21 西安电子科技大学 SAR image airport target detection method based on edge feature
CN107424160A (en) * 2015-11-02 2017-12-01 康耐视公司 The system and method that image center line is searched by vision system
CN108447016A (en) * 2018-02-05 2018-08-24 西安电子科技大学 The matching process of optical imagery and SAR image based on straight-line intersection
CN109034047A (en) * 2018-07-20 2018-12-18 京东方科技集团股份有限公司 A kind of method for detecting lane lines and device

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP4206723B2 (en) * 2002-10-11 2009-01-14 オムロン株式会社 Image processing method and image processing apparatus
CN102915640B (en) * 2012-10-30 2015-06-17 武汉烽火众智数字技术有限责任公司 Safety belt detecting method based on Hough transform
CN106529443B (en) * 2016-11-03 2019-09-06 温州大学 The method for improving Hough variation detection lane line

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5901252A (en) * 1991-12-11 1999-05-04 Fujitsu Limited Process and apparatus for extracting and recognizing figure elements using division into receptive fields, polar transformation, application of one-dimensional filter, and correlation between plurality of images
CN1667351A (en) * 2005-04-06 2005-09-14 北京航空航天大学 Method for automatically extracting image feature points of workpiece with rough grain under the strong reflection background
JP2008003793A (en) * 2006-06-21 2008-01-10 Toyota Motor Corp Image processing apparatus and image processing program
CN104424475A (en) * 2013-09-10 2015-03-18 阿里巴巴集团控股有限公司 Method and device for identifying stripe region in image
CN103914830A (en) * 2014-02-22 2014-07-09 小米科技有限责任公司 Straight line detection method and device
CN105184830A (en) * 2015-08-28 2015-12-23 华中科技大学 Symmetry image symmetric axis detection positioning method
CN107424160A (en) * 2015-11-02 2017-12-01 康耐视公司 The system and method that image center line is searched by vision system
CN106251332A (en) * 2016-07-17 2016-12-21 西安电子科技大学 SAR image airport target detection method based on edge feature
CN108447016A (en) * 2018-02-05 2018-08-24 西安电子科技大学 The matching process of optical imagery and SAR image based on straight-line intersection
CN109034047A (en) * 2018-07-20 2018-12-18 京东方科技集团股份有限公司 A kind of method for detecting lane lines and device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
对数极坐标系下尺度不变特征点的检测与描述;陶涛 等;《中国图象图形学报》;20151231;第20卷(第12期);第1639-1651页 *

Also Published As

Publication number Publication date
CN111141208A (en) 2020-05-12

Similar Documents

Publication Publication Date Title
CN111141208B (en) Parallel line detection method and device
CN109272016B (en) Target detection method, device, terminal equipment and computer readable storage medium
CN111860489A (en) Certificate image correction method, device, equipment and storage medium
CN110390306B (en) Method for detecting right-angle parking space, vehicle and computer readable storage medium
CN111738045B (en) Image detection method and device, electronic equipment and storage medium
CN113344910B (en) Defect labeling image generation method and device, computer equipment and storage medium
CN112534469B (en) Image detection method, image detection device, image detection apparatus, and medium
JP6937782B2 (en) Image processing method and device
EP2954457A1 (en) System and method for identifying similarities in different images
CN101727580A (en) Image processing apparatus, electronic medium, and image processing method
CN116071520B (en) Digital twin water affair simulation test method
JP2012053770A (en) Motion vector detection device
CN114387353A (en) Camera calibration method, calibration device and computer readable storage medium
CN109359542B (en) Vehicle damage level determining method based on neural network and terminal equipment
CN110880003B (en) Image matching method and device, storage medium and automobile
CN111429399B (en) Linear detection method and device
CN107067397A (en) A kind of image grading method based on infrared image complexity
CN113508395A (en) Method for detecting an object
CN113870190B (en) Vertical line detection method, device, equipment and storage medium
CN115690222A (en) Calibration pattern recognition method, calibration device and electronic equipment
CN111275693B (en) Counting method and counting device for objects in image and readable storage medium
CN111382834B (en) Confidence degree comparison method and device
CN109829968B (en) Method and device for generating normal texture map, storage medium and electronic equipment
CN111709955A (en) Image segmentation inspection method, device, terminal and storage medium
CN112200730B (en) Image filtering processing method, device, equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant