Line segment detection method, electronic equipment and computer readable storage medium
By constructing the tensor space in the parallel processing unit and performing parallel processing, filtering and clustering linear information, the problem of difficulty in detecting slender and narrow target objects in the lidar point cloud data is solved, and detection accuracy and efficiency are improved.
Patent Information
- Application Number
- CN202411979609.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-05-13
AI Technical Summary
The existing line segment detection methods have difficulties in detecting lidar point cloud data, especially in detecting slender and narrow target objects, resulting in difficulty in feature extraction and low detection accuracy.
By obtaining laser point cloud data, a tensor space in the parallel processing unit is constructed, the points to be processed are allocated to the processing thread for parallel processing, the tensor space with the number of straight lines greater than the preset threshold value, the straight line information of the straight line to be detected is calculated, and clustered based on the effective points to identify the target object with line segment characteristics.
Linear detection in three-dimensional space is realized, the accuracy of detection of line segment feature target objects is improved, the real-time nature of the detection system is maintained, and the solution speed of tensor space and the efficiency of line segment detection is significantly improved.
Smart Images

Figure CN119986596A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of autonomous driving technology, and in particular to a line segment detection method, an electronic device, and a computer-readable storage medium. Background Art
[0002] Target detection technology based on LiDAR (Light Detection and Ranging) plays a vital role in the field of autonomous driving. LiDAR measures distance by emitting laser beams and receiving beams reflected from objects, and uses this information to build an accurate three-dimensional environment model. When object detection is performed based on point cloud data transmitted by LiDAR, for example, when detecting target objects with slender line features such as warning lines, automatic barriers in parking lots or toll booths, and parking space lines, the distribution of laser point cloud data on the target objects is extremely sparse due to the slenderness and narrowness of the target objects, making feature extraction difficult.
[0003] Existing line segment detection methods usually require projecting three-dimensional laser point cloud data onto a two-dimensional plane for detection in order to reduce the search range of the solution space in the Hough transform. At the same time, in order to avoid detection failures caused by point cloud overlap during the projection process, the point cloud needs to be cropped according to the prior position. It is usually necessary to use a high-precision map system to record in advance where the target object may appear, resulting in greater limitations for line segment detection methods. In addition, the detection method based on two-dimensional projection only has the ability to detect angle changes within the plane on the projection plane, but cannot detect straight objects at any angle in three-dimensional space, resulting in low accuracy in detecting target objects. Summary of the invention
[0004] To solve the above technical problems, the present application provides a line segment detection method, an electronic device and a computer-readable storage medium.
[0005] To solve the above problems, the present application provides a first technical solution: a line segment detection method is provided, comprising: obtaining laser point cloud data, the laser point cloud data including coordinate data of a number of points to be processed, and storing the coordinate data of the number of points to be processed in a parallel processing unit; respectively allocating the number of points to be processed to the processing threads of the parallel processing unit to calculate the first tensor space corresponding to the straight lines to be detected of the points to be processed; screening the corresponding first tensor space through the processing thread to obtain a second tensor space in which the number of straight lines is greater than a first preset threshold, and calculating the straight line information of the straight lines to be detected in the second tensor space; clustering the valid points on the straight line information to obtain the line segments composed of the valid points, so as to identify the target object with line segment features based on the line segments.
[0006] Optionally, before the step of acquiring laser point cloud data, wherein the laser point cloud data includes coordinate data of a number of points to be processed, and storing the coordinate data of the number of points to be processed in a parallel processing unit, the line segment detection method further includes: constructing a third tensor space based on the description features of the straight line to be detected, and storing the third tensor space in the parallel processing unit; and assigning the number of points to be processed to the processing threads of the parallel processing unit respectively to calculate the first tensor space corresponding to the straight line to be detected of the points to be processed, including: mapping the corresponding points to be processed to the third tensor space through the processing threads to calculate the first tensor space corresponding to the straight line to be detected.
[0007] Optionally, the above-mentioned processing thread maps the corresponding above-mentioned points to be processed to the above-mentioned third tensor space to calculate the above-mentioned first tensor space corresponding to the straight line of the above-mentioned points to be processed, including: based on the above-mentioned third tensor space, calculating the normal vector subspace corresponding to the above-mentioned points to be processed of the current above-mentioned processing thread; based on the above-mentioned normal vector subspace, calculating the first vertical point coordinate of the above-mentioned points to be processed of the current above-mentioned processing thread on the corresponding vertical point subspace; based on the above-mentioned normal vector subspace, the above-mentioned vertical point subspace and the above-mentioned first vertical point coordinate corresponding to the above-mentioned points to be processed, constructing the above-mentioned first tensor space.
[0008] Optionally, after the step of acquiring laser point cloud data, wherein the laser point cloud data includes coordinate data of a plurality of points to be processed, and storing the coordinate data of the plurality of points to be processed in a parallel processing unit, the line segment detection method includes: establishing a data index of the data processed by each of the processing threads of the parallel processing unit in the parallel processing unit; calculating the first vertical point coordinate of the point to be processed of the current processing thread in the corresponding vertical point subspace based on the normal vector subspace, including: calculating the first vertical point coordinate of the point to be processed of the current processing thread in the parallel processing unit based on the data index. number information; based on the above-mentioned number information and the above-mentioned normal vector subspace, calculate the first vertical point coordinate of the above-mentioned point to be processed of the current processing thread in the corresponding above-mentioned vertical point subspace; after the step of constructing the above-mentioned first tensor space based on the above-mentioned normal vector subspace, the above-mentioned vertical point subspace and the above-mentioned first vertical point coordinate corresponding to the above-mentioned point to be processed, the above-mentioned line segment detection method also includes: based on the above-mentioned normal vector subspace, the above-mentioned vertical point subspace and the above-mentioned first vertical point coordinate corresponding to the above-mentioned point to be processed, calculate the index information between the position of the above-mentioned straight line to be detected in the above-mentioned first tensor space and its position in the above-mentioned parallel processing unit.
[0009] Optionally, the above-mentioned first tensor space corresponding to all the above-mentioned processing threads is screened to obtain a second tensor space in which the number of straight lines is greater than a first preset threshold, and the straight line information of the above-mentioned straight line to be detected in the above-mentioned second tensor space is calculated, including: obtaining the number of straight lines in the above-mentioned first tensor space corresponding to all the above-mentioned processing threads; when the number of straight lines is greater than the first preset threshold, adding the corresponding straight lines to be detected to the above-mentioned second tensor space; based on the above-mentioned data index, calculating the straight line information of the above-mentioned straight line to be detected in the above-mentioned second tensor space to obtain the straight line information of the above-mentioned straight line to be detected.
[0010] Optionally, the above-mentioned construction of a third tensor space based on the descriptive features of the straight line to be detected, and storing the above-mentioned third tensor space on the above-mentioned parallel processing unit, includes: constructing the above-mentioned third tensor space based on the descriptive features of the above-mentioned straight line to be detected, the above-mentioned third tensor space including a vertical point subspace and a normal vector subspace; defining the distance resolution of the concerned straight line and the second vertical point coordinates of the concerned vertical point of the above-mentioned vertical point subspace, so as to discretize the above-mentioned vertical point subspace based on the above-mentioned second vertical point coordinates and the above-mentioned distance resolution; defining the first parameter and the second parameter of the above-mentioned normal vector subspace, and calculating the polar angle of the above-mentioned normal vector subspace based on the above-mentioned first parameter, the above-mentioned second parameter and the azimuth angle of the above-mentioned normal vector subspace; discretizing the above-mentioned normal vector subspace based on the above-mentioned polar angle; and storing the discretized above-mentioned normal vector subspace in the above-mentioned parallel processing unit.
[0011] Optionally, the above-mentioned straight line information includes the straight line information of the above-mentioned straight line to be detected in the above-mentioned second tensor space; before the above-mentioned step of clustering the valid points based on the above-mentioned straight line information to obtain the line segments composed of the above-mentioned valid points, so as to identify the target object with line segment characteristics based on the above-mentioned line segments, the above-mentioned line segment detection method also includes: based on the coordinate data of the above-mentioned point to be processed and the straight line information of the above-mentioned straight line to be detected, calculating the distance between the above-mentioned point to be processed and the corresponding straight line to be detected; when the above-mentioned distance is less than the second preset threshold value, determining the above-mentioned point to be processed as a valid point; when the above-mentioned distance is greater than or equal to the above-mentioned second preset threshold value, determining the above-mentioned point to be processed as an invalid point.
[0012] Optionally, the above-mentioned clustering is based on the valid points on the above-mentioned straight line information to obtain line segments composed of the above-mentioned valid points, so as to identify the target object with line segment characteristics based on the above-mentioned line segments, including: clustering based on the distances between the valid points on the above-mentioned straight line information to obtain a number of line segments composed of the above-mentioned valid points; based on the distance between the starting point and the ending point of each of the above-mentioned line segments, filtering out line segments within a preset length range; and identifying the above-mentioned filtered line segments to obtain the above-mentioned target object with the above-mentioned line segment characteristics.
[0013] Optionally, before the step of respectively allocating the above-mentioned points to be processed to the processing threads of the above-mentioned parallel processing units to calculate the first tensor space corresponding to the above-mentioned straight line to be detected of the above-mentioned points to be processed, the above-mentioned line segment detection method also includes: allocating a first video memory to the above-mentioned first tensor space corresponding to the above-mentioned points to be processed in the above-mentioned parallel processing unit; initializing the above-mentioned first video memory; and / or, before the step of clustering the valid points on the above-mentioned straight line information to obtain the line segments composed of the above-mentioned valid points to identify the target objects with line segment features based on the above-mentioned line segments, the above-mentioned line segment detection method also includes: allocating a second video memory to the points on the above-mentioned straight line to be detected in the above-mentioned parallel processing unit, the above-mentioned second video memory being used to store the number of points and point indexes on the above-mentioned straight line to be detected; initializing the above-mentioned second video memory.
[0014] To solve the above problems, the present application provides a second technical solution: an electronic device is provided, comprising a processor and a memory, wherein the processor is connected to the memory, wherein the memory stores program instructions; the processor is used to execute the program instructions stored in the memory to implement the above method.
[0015] To solve the above problem, the present application provides a third technical solution: providing a computer-readable storage medium, wherein the computer-readable storage medium stores program instructions, and the program instructions can be executed by a processor to implement the above method.
[0016] The present application provides a line segment detection method, an electronic device and a computer-readable storage medium. The line segment detection method acquires laser point cloud data, which includes coordinate data of several points to be processed, so as to store the coordinate data of several points to be processed in a parallel processing unit; the several points to be processed are respectively assigned to the processing threads of the parallel processing unit to calculate the first tensor space corresponding to the straight line to be detected of the points to be processed; the corresponding first tensor space is screened by the processing thread to obtain a second tensor space with a number of straight lines greater than a first preset threshold, and the straight line information of the straight line to be detected in the second tensor space is calculated; based on the effective points on the straight line information, clustering is performed to obtain line segments composed of effective points, so as to identify the target object with line segment characteristics based on the line segment. In the above manner, the method of the present application can realize straight line detection in three-dimensional space by constructing tensor space, and improve the detection accuracy of target objects with line segment characteristics; and by using several processing threads of the parallel processing unit for parallel processing, the huge solution amount in three-dimensional space can be processed in parallel, the real-time performance of the detection system is maintained, and the solution speed of the tensor space is significantly improved, thereby improving the efficiency of line segment detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. Among them:
[0018] Figure 1 is a flow chart of a first embodiment of a line segment detection method provided by the present application;
[0019] Figure 2 is a flow chart of a second embodiment of the line segment detection method provided by the present application;
[0020] Figure 3 is a flow chart of a third embodiment of the line segment detection method provided by the present application;
[0021] Figure 4 is a flow chart of a fourth embodiment of the line segment detection method provided by the present application;
[0022] Figure 5 is a flowchart of a fifth embodiment of the line segment detection method provided by the present application;
[0023] Figure 6 is a flow chart of a sixth embodiment of the line segment detection method provided by the present application;
[0024] Figure 7 is a structural schematic diagram of an embodiment of an electronic device provided by the present application;
[0025] Figure 8 It is a structural schematic diagram of an embodiment of a computer-readable storage medium provided by the present application. DETAILED DESCRIPTION
[0026] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0027] It should be noted that if the embodiments of the present application involve directional indications (such as up, down, left, right, front, back...), the directional indications are only used to explain the relative position relationship, movement status, etc. between the components under a certain specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indication will also change accordingly.
[0028] In addition, if there are descriptions involving "first", "second", etc. in the embodiments of the present application, the descriptions of "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or suggesting their relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in the field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such combination of technical solutions does not exist and is not within the scope of protection required by this application.
[0029] The embodiment of the present application first provides a line segment detection method, which is used to detect slender target objects with line segment features through the laser point cloud data of the laser radar, so as to identify objects such as warning lines, automatic barriers, parking space lines, etc. during the vehicle driving process through the laser radar. When entering or leaving a parking lot, toll station or other controlled entrances, accurate detection of the above-mentioned target objects can ensure the safe operation of the autonomous driving vehicle, help the vehicle decide when it can pass safely, and avoid collision accidents.
[0030] See also Figure 1 , Figure 1 FIG. 1 is a flow chart of the first embodiment of the line segment detection method provided by the present application. Figure 1 As shown, in this embodiment, the line segment detection method includes the following steps:
[0031] Step S11: acquiring laser point cloud data, the laser point cloud data including coordinate data of a plurality of points to be processed, so as to store the coordinate data of the plurality of points to be processed in a parallel processing unit.
[0032] Specifically, during the driving process of the vehicle, the laser radar measures the distance by emitting a laser beam and receiving the beam reflected from the object, so as to reflect the position of the object in the three-dimensional coordinate system through the distance. Therefore, this embodiment first obtains the laser point cloud data of the laser radar during operation. The laser point cloud data may include the data obtained after a frame of the laser radar point cloud is subjected to basic filtering processing. The laser point cloud data may be reflected by the coordinate data of several points to be processed. For example, the laser point cloud data may be defined as P raw ={p0,p1,p2,…,p k}, where k is the number of points to be processed, p k The coordinate data used to represent the three-dimensional position of the kth point to be processed in the laser radar coordinate system. For any point to be processed, p can be defined i ={x i ,y i ,z i}, i can be 0, 1, 2, ..., or k.
[0033] Furthermore, the above-mentioned basic filtering processing may include but is not limited to reducing the point cloud range to the area of interest through straight-through filtering, filtering of ground point clouds, and other processing methods to reduce the number of point clouds, so as to filter out stray points to be processed and improve the accuracy of subsequent line segment detection. After acquiring laser point cloud data including coordinate data of several points to be processed, this embodiment stores the coordinate data of several points to be processed in a parallel processing unit, so as to facilitate the subsequent use of the parallel processing capability of the parallel processing unit to solve the coordinate data of the points to be processed for straight line detection. Among them, the parallel processing unit includes but is not limited to a graphics processing unit (GPU), a field programmable gate array (FPGA), a tensor processing unit (TPU), an application-specific integrated circuit (ASIC) and other processors with parallel processing capabilities.
[0034] Step S12: assigning a number of points to be processed to processing threads of the parallel processing unit respectively, so as to calculate and obtain a first tensor space corresponding to the straight lines to be detected of the points to be processed.
[0035] After the coordinate data of the plurality of points to be processed are stored in the parallel processing unit, the plurality of points to be processed are respectively assigned to the plurality of processing threads of the parallel processing unit for processing. In a possible implementation, the parallel processing unit can assign labels to the plurality of processing threads, and when the plurality of points to be processed are respectively assigned to the processing threads of the parallel processing unit, an index can be established between each processing thread and the data of the points to be processed that it needs to process, so that the position of the data that each processing thread needs to process in the video memory of the parallel processing unit can be located later.
[0036] After a number of points to be processed are respectively assigned to the processing threads of the parallel processing unit, the feature vector of the corresponding point to be processed can be calculated by each processing thread, and voting is performed in the feature space corresponding to the calculated feature vector to calculate the tensor space of the line corresponding to the point to be processed. It can be understood that in this embodiment, by constructing the relevant parameters describing the features of the line corresponding to the point to be processed in the three-dimensional space, and constructing the tensor space with the relevant parameters describing the features, the first tensor space is the solution space of all possible lines to be detected to which the point to be processed processed by a certain processing thread may belong.
[0037] Step S13: Screening the corresponding first tensor space through the processing thread to obtain a second tensor space in which the number of straight lines is greater than a first preset threshold, and calculating the straight line information of the straight line to be detected in the second tensor space.
[0038] Specifically, after obtaining the first position information of the straight line to be detected corresponding to the point to be processed in the first tensor space, the first tensor space corresponding to all processing threads is screened to obtain a second tensor space in which the number of straight lines is greater than the first preset threshold. It can be understood that the purpose of screening the first tensor space is to filter out the tensor space of the points to be processed whose number of straight lines is greater than the first preset threshold to obtain the second tensor space. Each second tensor space is used to describe the solution space formed when the number of straight lines to be detected to which the point to be processed may belong is greater than the first preset threshold. After obtaining the second tensor space, the straight line information of the straight line to be detected in the second tensor space is calculated, and the straight line information is used to describe the characteristics of a straight line to be detected in the second tensor space.
[0039] Step S14: clustering is performed based on the valid points on the straight line information to obtain line segments composed of the valid points, so as to identify target objects with line segment features based on the line segments.
[0040] After obtaining the straight line information of the straight line to be detected in the second tensor space, the points constituting the straight line to be detected are screened to obtain valid points on the straight line information. Clustering based on the positions of the valid points can obtain line segments composed of valid points, so as to identify target objects with line segment features based on the line segments. It can be understood that the target object of the embodiment of the present application can be an object with elongated line segment features. For example, when the line segment detection method of the embodiment of the present application is applied to the field of autonomous driving, the target object detected by the line segment detection method can be a road surface object during driving, and the target object includes but is not limited to objects with line segment features such as warning lines, automatic railings, and parking lines.
[0041] In the embodiment of the present application, the line segment detection method acquires laser point cloud data, the laser point cloud data includes coordinate data of several points to be processed, and stores the coordinate data of several points to be processed in a parallel processing unit; distributes several points to be processed to the processing threads of the parallel processing unit respectively, so as to calculate the first position information of the first tensor space corresponding to the points to be processed, and the first tensor space has at least one straight line to be detected corresponding to the points to be processed; the first tensor space corresponding to all processing threads is screened to obtain a second tensor space with a straight line number greater than a first preset threshold, and calculates the straight line information of the straight line to be detected in the second tensor space; clusters the valid points on the straight line information, obtains the line segments composed of the valid points, and identifies the target object with the line segment feature based on the line segment. Therefore, the method of the present embodiment can realize the straight line detection in the three-dimensional space by constructing the tensor space, and improve the detection accuracy of the target object with the line segment feature; and by using the several processing threads of the parallel processing unit for parallel processing, the huge solution amount in the three-dimensional space can be processed in parallel, the real-time performance of the detection system is maintained, and the solution speed of the tensor space is significantly improved, thereby improving the efficiency of the line segment detection.
[0042] In one embodiment, see Figure 2 , Figure 2 2 is a flow chart of the second embodiment of the line segment detection method provided by the present application. Figure 2 As shown, in this embodiment, the line segment detection method further includes the following steps:
[0043] Step S21: construct a third tensor space based on the description features of the straight line to be detected, and store the third tensor space on the parallel processing unit.
[0044] Specifically, when processing a line segment composed of points to be processed in three-dimensional space, a set description feature can be used to describe the straight line in the three-dimensional space, so as to find a candidate solution that meets the requirements in the tensor space composed of the straight line solution space of the points to be processed, so as to detect the line segment that meets the requirements from the straight line to be detected. Exemplarily, in this embodiment, a straight line in three-dimensional space can be described by parameter l={x, y, z, n, m, p}, so the third tensor space composed of the six-dimensional parameters of the straight line can be defined as {x, y, z, n, m, p}. The line segment detection method of this embodiment can discretize the third tensor space to convert the continuous vector space into a discrete representation, so that the processing threads of the subsequent parallel processing units can process and calculate the discretized third tensor space.
[0045] Step S22: Acquire laser point cloud data, where the laser point cloud data includes coordinate data of a plurality of points to be processed, so as to store the coordinate data of the plurality of points to be processed in a parallel processing unit.
[0046] Step S22 is similar to the above step S11 and will not be described again.
[0047] Step S23: Mapping the corresponding points to be processed to the third tensor space through the processing thread to calculate the first tensor space corresponding to the straight line to be detected.
[0048] After constructing a third vector space that can describe the characteristics of a straight line, when solving a straight line for a processing point through a processing thread of a parallel processing unit, this embodiment can map the corresponding processing point into the third tensor space through the processing thread to obtain a solution space of a straight line that may be composed of a certain processing point, that is, the first tensor space.
[0049] Step S24: screening the corresponding first tensor space through the processing thread to obtain a second tensor space in which the number of straight lines is greater than the first preset threshold, and calculating the straight line information of the straight line to be detected in the second tensor space.
[0050] Step S25: clustering is performed based on the valid points on the straight line information to obtain line segments composed of the valid points, so as to identify target objects with line segment features based on the line segments.
[0051] Steps S24-S25 are similar to the above steps S13-S14 and will not be described in detail here.
[0052] Therefore, the line segment detection method of this embodiment can construct a third tensor space based on the descriptive features of the straight line to be detected, and store the third tensor space on the parallel processing unit, so that the position data of the points to be processed can be subsequently mapped to the third tensor space to obtain the first tensor space composed of the straight lines to be detected corresponding to the points to be processed, so that the straight line information of the straight line to be detected can be calculated based on the first tensor space.
[0053] Optionally, see Figure 3 , Figure 3 FIG. 1 is a flow chart of the third embodiment of the line segment detection method provided by the present application. Figure 3 As shown, in this embodiment, step S23 further includes:
[0054] Step S31: Based on the third tensor space, the normal vector subspace corresponding to the to-be-processed point of the current processing thread is calculated.
[0055] Specifically, the third tensor space can be described by a normal vector subspace and a perpendicular subspace. The perpendicular subspace can refer to a subspace composed of all vectors orthogonal to the vectors in a given subspace, and the normal vector subspace can refer to a quantum state space orthogonal to a given state or subsystem. For example, when the third tensor space can be described as {x, y, z, n, m, p}, the space composed of {x, y, z} in the parameters is the perpendicular subspace, and the eigenvector space composed of {n, m, p} in the parameters is the normal vector subspace. When the third tensor space is stored in a parallel processing unit, the position of the normal vector subspace of the third tensor space on the parallel processing unit can be defined as:
[0056] normalSpaceGpu[n s2 ];(1)
[0057] Among them, n s2 A subspace of normal vectors used to represent the third tensor space.
[0058] When the normal vector subspace corresponding to the point to be processed of the current processing thread is calculated based on the third tensor space, the processing thread can map the position of the point to be processed on the parallel processing unit to the third tensor space to calculate the normal vector subspace corresponding to the point to be processed of the current processing thread. Exemplarily, the normal vector subspace corresponding to the point to be processed of the current processing thread can be defined as:
[0059] n j =normalSpaceGpu[threadIdx.x]; (2)
[0060] Among them, threadIdx.x is used to indicate the position of the current processing thread.
[0061] Step S32: Based on the normal vector subspace, calculate the first vertical point coordinate of the to-be-processed point of the current processing thread in the corresponding vertical point subspace.
[0062] Specifically, when the processing point is processed by the current processing thread, the current processing point needs to be converted into corresponding label information to identify its position in the thread. Exemplarily, the formula for calculating the label information processed by the processing thread is as follows:
[0063] p i =P raw_tpu [blockIdx.x]; (3)
[0064] Among them, P raw_gpu is the coordinate data of the to-be-processed point stored in the video memory of the parallel processing unit, and blockIdx.x is the first thread label assigned to each processing thread.
[0065] In this embodiment, based on the normal vector subspace corresponding to the point to be processed and the label information of the point to be processed, the first vertical point coordinate of the point to be processed of the current processing thread on the corresponding vertical point subspace is further calculated. The formula of the first vertical point coordinate is as follows:
[0066] p1=p i -p i ·n j ×n j ; (4)
[0067] Among them, p i is the label information of the point to be processed, n j is the normal vector subspace corresponding to the point to be processed, and p1 is the coordinate of the first vertical point.
[0068] Furthermore, after obtaining the first vertical point coordinate, the first vertical point coordinate still needs to be discretized so that the discretized first vertical point coordinate can be further used by the processing thread. The specific formula of the discretization process is as follows:
[0069]
[0070] Among them, p1.x is the position parameter of the first vertical point coordinate on the X axis, p1.y is the position parameter of the first vertical point coordinate on the Y axis, and p1.z is the position parameter of the first vertical point coordinate on the Z axis. The vertical point subspace is defined with a vertical point of interest and a straight line of interest. The straight line of interest is a vector orthogonal to the vector in the vertical point subspace. The vertical point of interest is the orthogonal projection of a specific vector on the vertical point subspace. The three-dimensional spatial distribution of the vertical point of interest is [{0,x max},{-y max ,y max},{-z max ,z max}],l res To care about the distance resolution of the straight line, the distance resolution is the minimum distance between the straight lines during the discretization process.
[0071] It can be understood that after defining the concerned vertical point and the concerned line, the discretized vertical point subspace can also be calculated by the concerned vertical point and the concerned line. The calculation formula is as follows:
[0072]
[0073] Step S33: construct a first tensor space based on the normal vector subspace, the vertical point subspace and the first vertical point coordinates corresponding to the point to be processed.
[0074] Specifically, since the normal vector subspace, vertical point subspace and first vertical point coordinates of the point to be processed can be used to form six-dimensional parameters for a straight line, after determining the normal vector subspace, vertical point subspace and first vertical point coordinates of the point to be processed, the corresponding first tensor space can be constructed based on the normal vector subspace, vertical point subspace and first vertical point coordinates corresponding to the point to be processed. The first tensor space can be constructed based on the normal vector subspace, vertical point subspace and first vertical point coordinates corresponding to the point to be processed, so that the line information of several lines to be detected corresponding to the point to be processed on the first tensor space can be obtained later by decoding the first tensor space.
[0075] Furthermore, after step S33, the line segment detection method may also include: calculating the index information between the position of the straight line to be detected in the first tensor space and its position in the parallel processing unit based on the normal vector subspace, the vertical point subspace and the first vertical point coordinate corresponding to the point to be processed.
[0076] Specifically, when calculating the coordinates of the first vertical point, the point to be processed needs to be converted into corresponding label information first, and the label information and the data in the normal vector subspace correspond to the position of the processing thread in the parallel processing unit. Therefore, after obtaining the normal vector subspace, vertical point subspace and the first vertical point coordinates corresponding to the point to be processed, the index information between the position of the straight line to be detected in the first tensor space and its position in the parallel processing unit can be calculated. The specific calculation formula is as follows:
[0077] ind=p v .x×n s1 .y×n s1 .z+p v .y×n s1 .z+p v .z; (7)
[0078] Among them, ind is the index information corresponding to the point to be processed; p v .x is the position parameter of the discretized first vertical point coordinate on the X-axis, p v .y is the position parameter on the Y axis of the discretized first vertical point coordinate, p v .z is the position parameter of the discretized first vertical point coordinate on the Z axis; n s1 .y is the parameter of the discretized vertical point subspace on the Y axis, n s1 .z is the parameter of the discretized vertical point subspace on the z-axis,
[0079] After calculating the index information between the position of the line to be detected in the first tensor space and its position in the parallel processing unit, the index information of the corresponding position in the first tensor space is defined as count gpu [ind], and count gpu The element value of [ind] is updated. The specific update method is as follows:
[0080] count gpu [ind] = count gpu [ind]+1; (8)
[0081] That is, after each calculation is completed, the element value at the corresponding position is added to 1 to avoid the potential risk of different processing threads reading and writing the same address. In addition, the above update operation should be protected by atomic operations.
[0082] It can be understood that the third tensor space of this embodiment is a six-dimensional tensor space constructed based on straight line features, and the first tensor space is a six-dimensional tensor space composed of several straight lines to be detected corresponding to the points to be processed, which is obtained by projecting the points to be processed into the third tensor space. In a possible implementation, at least one of the above formulas (1)-(8) can be encapsulated in the kernel function 1, so that the processing thread of the parallel processing unit can execute at least one of the above steps S31-S33 by executing the kernel function 1. Among them, when the parallel processing unit starts the kernel function 5 through the processing thread, it specifically adjusts the settings in the parallel parameters of the kernel function to a Grid size of k and a Block size of n. s2 .
[0083] In an embodiment of the present application, the line segment detection method calculates the normal vector subspace corresponding to the point to be processed of the current processing thread based on the third tensor space, calculates the first vertical point coordinate of the point to be processed of the current processing thread on the corresponding vertical point subspace based on the normal vector subspace, and constructs the first tensor space based on the normal vector subspace, the vertical point subspace and the first vertical point coordinate corresponding to the point to be processed, so that the line information of the straight line to be detected can be calculated based on the first tensor space.
[0084] Further, after step S11 or step S22, the line segment detection method of this embodiment includes: establishing a data index in the parallel processing unit for data processed by each processing thread of the parallel processing unit.
[0085] Specifically, after the coordinate data of several points to be processed are stored in the parallel processing unit, since different points to be processed are assigned to corresponding processing threads for processing, in order to facilitate each subsequent processing thread to directly locate the position of the data to be processed in the parallel processing video memory, the line segment detection method of this embodiment needs to establish the data index of the data processed by each processing thread of the parallel processing unit in the parallel processing unit. Specifically, the data index to be processed by the current processing thread can be calculated by the following formula:
[0086] idx=blockIdx.x×blockDim.x+threadIdx.x; (9)
[0087] Among them, idx is the data index of the current processing thread, blockIdx.x is the first thread label assigned to each processing thread, blockDim.x is the second thread label assigned to each processing thread, and threadIdx.x is used to indicate the position of the current processing thread.
[0088] Step S32 further includes: calculating the label information of the pending point of the current processing thread in the parallel processing unit based on the data index; calculating the first vertical point coordinate of the pending point of the current processing thread in the corresponding vertical point subspace based on the label information and the normal vector subspace.
[0089] Specifically, after establishing the data index of the data processed by each processing thread of the parallel processing unit in the parallel processing unit, the label information of the to-be-processed point of the current processing thread in the parallel processing unit can be calculated based on the data index. After obtaining the label information, the corresponding first vertical point coordinate can be calculated based on the label information and the normal vector subspace. The specific calculation process can refer to the above formulas (3), (4) and corresponding contents.
[0090] Among them, step S13 or step S24 includes: obtaining the number of straight lines in the first tensor space corresponding to all processing threads; when the number of straight lines is greater than a first preset threshold, adding the corresponding straight lines to be detected to the second tensor space; based on the data index, calculating the straight line information of the straight line to be detected in the second tensor space to obtain the straight line information of the straight line to be detected.
[0091] Specifically, after obtaining the first tensor space of the points to be processed corresponding to all processing threads, the first tensor space can be understood as a solution space for describing the lines to be detected that may be composed of the points to be processed processed by a certain processing thread. When the number of lines to be detected in a certain first tensor space is less than or equal to the first preset threshold, it can be considered that the validity of the corresponding solution space is low. Therefore, this embodiment screens out the first tensor space with the number of lines less than or equal to the first preset threshold to reduce the amount of calculation when solving the lines to be detected later, thereby improving the calculation speed of line segment detection.
[0092] All first tensor spaces are screened according to the number of lines in the first tensor space. Before screening, a third video memory needs to be allocated in the parallel processing unit for the screened lines to be detected, so that the tensor space composed of the lines to be detected stored in the third video memory is the second tensor space mentioned above. The method of screening according to the number of lines in the first tensor space can be expressed by the following formula:
[0093] seletedLine[MAXNUM][MINNUM];(10)
[0094] Among them, MAXNUM is the preset maximum number of straight line detections. In this embodiment, MAXNUM can be set to a number much larger than the actual straight line detection to ensure that most of the straight lines to be detected in the first tensor space can be below the maximum number of straight line detections, for example, it can be set to 500; MINNUM is the preset minimum number of straight line detections, for example, it can be set to 7; the straight lines to be detected in the second tensor space can be represented by seven dimensions, the first six dimensions of the straight line to be detected separatedLine are used to represent the eigenvalues {x, y, z, n, m, p} in the corresponding straight line information, and the seventh dimension of the straight line to be detected separatedLine represents the total number of points to be processed passing through the straight line, which is recorded as num, that is, separatedLine can be represented by {x, y, z, n, m, p, num}.
[0095] After the first tensor space is screened to obtain the straight line to be detected in the second tensor space, the straight line information of the straight line to be detected in the second tensor space is calculated based on the data index to obtain the straight line information of the straight line to be detected. Specifically, the calculation formula can be referred to as follows:
[0096]
[0097]
[0098] seletedLine[numCurr].n=normalSpaceGpu[mod(idx,n s2 )].n
[0099] seletedLine[numCurr].m=normalSpaceGpu[mod(idx,n s2 )].m
[0100] seletedLine[numCurr].p=normalSpaceGpu[mod(idx,n s2 )].p
[0101] seletedLine[numCurr].num=0; (11)
[0102] Among them, numCurr is used to indicate the number of lines to be detected in the second tensor space; separatedLine[numCurr].x is the feature of the line to be detected in the x dimension, idx is the data index of the second tensor space corresponding to the current thread; separatedLine[numCurr].y is the feature of the line to be detected in the y dimension; separatedLine[numCurr].z is the feature of the line to be detected in the z dimension; separatedLine[numCurr].n is the feature of the line to be detected in the n dimension, mod(idx,n s2 ) indicates that between idx and n s2 The expression is divided and the remainder is taken, normalSpaceGpu[mod(idx,n s2 )].n represents the feature of the normal vector subspace of the remainder in n dimensions; separatedLine[numCurr].m represents the feature of the line to be detected in m dimensions, normalSpaceGpu[mod(idx,n s2 )].m represents the feature of the normal vector subspace of the remainder in m dimensions; separatedLine[numCurr].p represents the feature of the line to be detected in p dimensions, normalSpaceGpu[mod(idx,n s2 )].p is represented as the characteristic of the normal vector subspace of the remainder in dimension p.
[0103] Furthermore, when calculating each line to be detected in the second tensor space, it is necessary to add the corresponding quantity index to 1 after calculating each line to be detected, so as to avoid the potential risk of different processing threads reading and writing the same address. In addition, the above operations should be protected by atomic operations.
[0104] In a possible implementation, at least one of the above formulas (10) and (11) can be encapsulated in kernel function 2, so that the processing thread of the parallel processing unit can perform the above corresponding steps to perform data calculation and processing by executing kernel function 2. When the parallel processing unit starts kernel function 3 through the processing thread, the setting in the parallel parameters of the kernel function is specifically adjusted to a Grid size of 1024 and a Block size of
[0105] Optionally, see Figure 4 , Figure 4 FIG. 4 is a flow chart of the fourth embodiment of the line segment detection method provided by the present application. Figure 4 As shown, step S21 includes:
[0106] Step S41: Based on the description features of the straight line to be detected, a third tensor space is constructed, where the third tensor space includes a vertical point subspace and a normal vector subspace.
[0107] Specifically, the descriptive features of the straight line to be detected can be understood as the above-mentioned l = {x, y, z, n, m, p} used to describe the straight line. After constructing the third tensor space, the third tensor space includes the vertical point subspace {x, y, z} and the normal vector subspace {n, m, p}, which will not be repeated here.
[0108] Step S42: define the distance resolution of the concerned straight line of the vertical point subspace and the second vertical point coordinate of the concerned vertical point, so as to discretize the vertical point subspace based on the second vertical point coordinate and the distance resolution.
[0109] Specifically, the distance resolution of the concerned line in the vertical point subspace is defined as l res The distance resolution can be understood as the minimum distance between straight lines in the process of discretizing the vertical point subspace. res , the distance accuracy of the detection line can be adjusted. The vertical point of interest is the orthogonal projection of a specific vector on the vertical point subspace. The second vertical point coordinate p2 of the vertical point of interest can be defined as [{0,x max},{-y max ,y max},{-z max ,z max}], based on the second vertical point coordinate and distance resolution, the discretized vertical point subspace n can be calculated s1 , as shown in formula (6), which will not be repeated here.
[0110] Step S43: define a first parameter and a second parameter of the normal vector subspace, and calculate the polar angle of the normal vector subspace based on the first parameter, the second parameter and the azimuth angle of the normal vector subspace.
[0111] When discretizing the normal vector subspace, it is necessary to define the first parameter α1 and the second parameter α2. The first parameter α1 is the first angular resolution, and the second parameter α2 is the parameter that determines the line sampling density. By adjusting the first parameter α1 and the second parameter α2, the angle accuracy of the detected line can be adjusted. After obtaining the first parameter and the second parameter, the polar angle of the normal vector subspace is calculated based on the first parameter, the second parameter and the azimuth of the normal vector subspace.
[0112] Step S44: discretize the normal vector subspace based on the polar angle.
[0113] After obtaining the polar angle and azimuth angle, since the azimuth angle provides the rotation information of the normal vector subspace relative to a certain coordinate axis or reference direction, and the polar angle provides the angle information between the normal vector subspace and a specific axis, the eigenvector of the normal vector subspace can be determined and the discretized normal vector subspace can be obtained.
[0114] Specifically, when calculating the discretized normal vector subspace, the azimuth angle and polar angle can be iterated based on the first parameter and the second parameter. For the polar angle θ, in the interval Iterate the calculation with the first angular resolution α1, and define the current iteration value as θ i ; For azimuth In the interval Iterate the calculation with the second angular resolution α2′, and define the current iteration value as The specific process is as follows:
[0115] Step 441: For the polar angle θ, starting from the minimum value in the interval, iterate with the first angle resolution α1 as the step size (i.e., iteration interval); when the current iteration value is θ i When , the horizontal resolution is calculated as follows:
[0116]
[0117] Step 442: For the azimuth Starting from the minimum value in the interval, iterate with the second angular resolution α2′ as the step size; when the current iteration value is When a direction vector {x ij ,y ij ,z ij}, and its calculation formula is as follows:
[0118]
[0119] In the iterative process, after calculating the horizontal resolution α2′ in step 441, the process proceeds to step 442.
[0120] Step 442 adds the direction vector {x ij ,y ij ,z ij} and then jump to step 441 for calculation.
[0121] Step 443: After the iteration is completed, the size of the discretized normal vector subspace is recorded as n s2 .
[0122] When the iteration of step 442 ends, the process returns to step 441 , and when the iteration of step 441 ends, the process returns to step 443 .
[0123] Step S45: storing the discretized normal vector subspace in the parallel processing unit.
[0124] After the normal vector subspace is discretized, the discretized normal vector subspace is stored in the fourth video memory of the parallel processing unit. The discretized normal vector subspace can be represented as a float array. For details, refer to the above formula (1), which will not be repeated here.
[0125] In one embodiment, see Figure 5 , Figure 5 FIG. 5 is a flow chart of the fifth embodiment of the line segment detection method provided by the present application. Figure 5 As shown, the straight line information includes the straight line information of the straight line to be detected in the second tensor space. Before step S14, the line segment detection method of this embodiment also includes:
[0126] Step S51: Based on the coordinate data of the point to be processed and the line information of the line to be detected, the distance between the point to be processed and the corresponding line to be detected is calculated.
[0127] Specifically, based on the data index of the current processing thread, the coordinate data p of the current processing point to be processed calculated by the current processing thread can be defined as:
[0128] p=P raw_gpu [idx]; (14)
[0129] Among them, P raw_gpu is the coordinate data of the point to be processed stored in the video memory of the parallel processing unit, and idx is the data index of the current processing thread.
[0130] Furthermore, the current straight line p to be detected whose distance needs to be calculated is line (15) is defined as: p line ={seletedLine[blockDim.y].x,seletedLine[blockDim.y].y,seletedLine[blockDim.y].z};
[0131] Among them, blockDim.y is the third thread label assigned to each processing thread, separatedLine[blockDim.y].x is the feature of the straight line separatedLine in the second tensor space corresponding to the third thread label in the x dimension, separatedLine[blockDim.y].y is the feature of the straight line separatedLine in the second tensor space corresponding to the third thread label in the y dimension, and separatedLine[blockDim.y].z is the feature of the straight line separatedLine in the second tensor space corresponding to the third thread label in the z dimension.
[0132] The formula for calculating the distance between the point to be processed and the corresponding straight line to be detected is as follows:
[0133] dis=‖(p line -p)×p line ‖; (16)
[0134] Where dis is the distance between the point to be processed and the corresponding straight line to be detected, and dis is the distance between the point to be processed and the straight line to be detected. lune The norm obtained by operating on two vectors a and p.
[0135] Step S52: when the distance is less than a second preset threshold, determining the point to be processed as a valid point.
[0136] After obtaining the distance between the point to be processed and the corresponding straight line to be detected, it is determined whether the distance between the point to be processed and the corresponding straight line to be detected is less than a second preset threshold. If the distance is less than the second preset threshold, it can be determined that the point to be processed is on the corresponding straight line to be detected and the point to be processed is a valid point.
[0137] Step S53: when the distance is greater than or equal to the second preset threshold, the point to be processed is determined to be an invalid point.
[0138] Specifically, if the distance is greater than or equal to the second preset threshold, it can be determined that the point to be processed is not on the corresponding straight line to be detected, that is, the point to be processed is a discontinuous point discrete outside the straight line to be detected. At this time, the point to be processed is determined to be an invalid point.
[0139] The line segment detection method of this embodiment calculates the distance between the point to be processed and the corresponding straight line to be detected based on the coordinate data of the point to be processed and the straight line information of the straight line to be detected. When the distance is less than a second preset threshold, the point to be processed is determined to be a valid point. When the distance is greater than or equal to the second preset threshold, the point to be processed is determined to be an invalid point. This allows this embodiment to screen out discontinuous points that are discrete outside the straight line to be detected, so that a corresponding line segment can be formed by clustering several valid points to achieve line segment detection.
[0140] In a possible implementation, at least one of the above formulas (14), (15) and (16) can be encapsulated in kernel function 3, so that the processing thread of the parallel processing unit can execute the above steps S51-S53 by executing kernel function 3 to achieve the screening of effective points. When the parallel processing unit starts kernel function 3 through the processing thread, it specifically adjusts the setting in the kernel function parallel parameter to a Grid size of Block size is (8, lineNum).
[0141] Optionally, see Figure 6 , Figure 6 FIG. 6 is a flow chart of the sixth embodiment of the line segment detection method provided by the present application. Figure 6 As shown, step S14 or step S25 further includes:
[0142] Step S61: clustering is performed based on the distances between valid points on the straight line information to obtain a number of line segments composed of valid points.
[0143] Specifically, after the invalid points on the line to be detected are screened out, clustering can be performed based on the distance between the valid points on the line information, and the clustering methods include but are not limited to Euclidean clustering, K-means, Agglomerative Clustering, etc. After clustering the valid points, the valid points with close distances can be grouped into a line segment to obtain several line segments composed of laser point cloud data.
[0144] Step S62: based on the distance between the starting point and the ending point of each line segment, filter out line segments within a preset length range.
[0145] After obtaining a number of line segments, the distance between the starting point and the end point of each line segment can be further obtained to use the distance as the length of the corresponding line segment, and the line segments can be screened based on the length to obtain line segments that meet the preset length range. The preset length range of this embodiment can be selected based on the selection of the target object, the distance between the laser radar and the target object, the application scenario of the line segment detection, etc., and is not specifically limited here.
[0146] Step S63: Identify the filtered line segments to obtain target objects with line segment features.
[0147] After obtaining the screened line segments within a preset length range, the object corresponding to the line segment can be further identified by clustering, determining the bounding box, direction and posture of the object, so as to obtain the target object with line segment features. Exemplarily, when the line segment detection method of this embodiment is applied to the field of autonomous driving, the target object with line segment features can be, but is not limited to, objects such as lifting poles, warning lines, and parking space lines.
[0148] In one embodiment, before step S12, the line segment detection method of this embodiment further includes: allocating a first video memory to a first tensor space corresponding to the point to be processed in the parallel processing unit; and initializing the first video memory.
[0149] When allocating the first video memory for the first tensor space corresponding to the point to be processed, the first video memory may be defined as:
[0150] n space =n s1 ×n s2 ×4; (17)
[0151] Among them, n s1 is the vertical point subspace of the discretized third tensor space, n s2 is the normal vector subspace of the discretized third tensor space, n space Represented as an n stored in the first video memory s1 ×n s2 int array of size count gpu .
[0152] In order to prepare the memory of the parallel processing unit and facilitate the parallel calculation of the subsequent parallel processing unit, it is necessary to initialize the first video memory. Specifically, the data index idx of the current processing thread can be calculated first. The calculation process can refer to the above formula (9). When the idx of the current processing thread is less than the first video memory n space , execute the following formula:
[0153] count gpu =0; (18)
[0154] count gpu It is represented as an element of the int array corresponding to the current processing thread. Setting the corresponding element to 0 can realize the clearing operation of the first video memory to complete the initialization.
[0155] In a possible implementation, at least one of the above formulas (7) and (18) can be encapsulated in kernel function 4, so that the processing thread of the parallel processing unit can perform the above-mentioned initialization operation of the first video memory by executing kernel function 4. When the parallel processing unit starts kernel function 5 through the processing thread, the setting in the parallel parameters of the kernel function is specifically adjusted to a Grid size of 1024 and a Block size of
[0156] And / or, before step S14, the line segment detection method of this embodiment also includes: allocating a second video memory in the parallel processing unit for the points on the straight line to be detected, the second video memory being used to store the number and index of valid points on the straight line to be detected; and initializing the second video memory.
[0157] Specifically, before screening valid points on the line to be detected in the second tensor space, the corresponding data of the points on the line to be detected needs to be cached. Specifically, the second video memory should be allocated to the points on the line to be detected in the parallel processing unit, and the second video memory is used to store the number of points and point indexes on the line to be detected. In order to facilitate the parallel calculation of subsequent processing threads, the second video memory also needs to be initialized.
[0158] The number of points can be understood as the points included in the line, as well as the corresponding number and number; the point index is the position index of the corresponding point in the line. Exemplarily, the second video memory may include a first array and a second array, the first array is used to store the point index on the line to be detected, and the second array is used to store the data of the valid points on the line to be detected. The first array is an int array, and the first array is defined as pointInLine gpu [lineNum]
[1000] , you can use the following formula to initialize the first array:
[0159] pointInLine[blockIdx.x][threadIdx.x]=0(19)
[0160] Wherein, blockIdx.x is the first thread label of the current processing thread, and threadIdx.x is used to indicate the position of the current processing thread.
[0161] The second array can be defined as valid gpu [lineNum], when threadIdx.x is 0, the second array can be initialized using the following formula:
[0162] valid gpu [blockIdx.x] = 0; (20)
[0163] Wherein, blockIdx.x is the first thread label of the current processing thread.
[0164] In a possible implementation, at least one of the above formulas (19) and (20) can be encapsulated in the kernel function 5, so that the processing thread of the parallel processing unit can perform the initialization operation of the above first video memory by executing the kernel function 5. When the parallel processing unit starts the kernel function 5 through the processing thread, the setting in the parallel parameters of the kernel function is specifically adjusted to the Grid size of lineNum and the Block size of 1000. Furthermore, the above kernel function 4 and kernel function 5 can be integrated into one kernel function for operation, or separated into different kernel functions for operation, which is not specifically limited here.
[0165] In one embodiment, the specific configuration method of the parallel parameters of the above-mentioned kernel function, that is, the thread number configuration of Grid and Block can be adjusted according to the actual hardware performance of the parallel processing unit, the magnitude of the laser point cloud data, etc., to ensure the best system performance scheduling. The configuration of the above-mentioned parallel parameters is only an exemplary description and is not specifically limited here.
[0166] Different from the prior art, the line segment detection method of the embodiment of the present application can perform parallel processing on each to-be-processed point in the laser point cloud data based on multiple processing threads of the parallel processing unit, and perform parallel updating on the solution space corresponding to each to-be-processed point, so that a straight line to be detected that meets the requirements can be obtained by solving and screening the first tensor space and the second tensor space, and line segment detection can be performed based on the valid points of the straight line to be detected to obtain a target object with line segment features in three-dimensional space that is combined by point cloud data. The line segment detection method of the embodiment of the present application can achieve efficient detection of line segments while meeting the detection of straight lines in three-dimensional space, thereby enabling efficient detection of slender strip-shaped objects such as warning lines and lifting poles in three-dimensional space.
[0167] See also Figure 7 , Figure 7 Schematic diagram of the structure of an embodiment of the electronic device provided by the present application. Figure 7 As shown, the electronic device 50 of this embodiment includes a memory 52 and a processor 51, and the processor 51 is connected to the memory 52. The memory 52 is used to store program instructions. The processor 51 is used to execute the program instructions stored in the memory 52 to implement the method described in any of the above embodiments.
[0168] The processor 51 may also be referred to as a CPU (Central Processing Unit). The processor 51 may be an integrated circuit chip having the ability to process signals. The processor 51 may also be a general-purpose processor, a digital signaling processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0169] The memory 52 can be a memory stick, a TF card, etc., which can store all the information in the electronic device 50, including the input raw data, computer programs, intermediate operation results and final operation results are all stored in the memory. It stores and retrieves information according to the location specified by the controller. With the memory, the string matching prediction device has a memory function and can ensure normal operation. The memory of the string matching prediction device can be divided into main memory (internal memory) and auxiliary memory (external memory) according to the purpose. There is also a classification method of dividing it into external memory and internal memory. External memory is usually a magnetic medium or an optical disk, etc., which can store information for a long time. Memory refers to the storage component on the motherboard, which is used to store the data and programs currently being executed, but is only used to temporarily store programs and data. If the power is turned off or the power is cut off, the data will be lost.
[0170] In the several embodiments provided in the present application, it should be understood that the disclosed methods and devices can be implemented in other ways. For example, the inverter control method described above is only schematic. For example, the division of modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0171] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0172] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0173] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a system server, or a network device, etc.) or a processor to execute all or part of the steps of the various implementation methods of the present application.
[0174] See also Figure 8 , Figure 8 Schematic diagram of the structure of an embodiment of the computer-readable storage medium provided by the present application. Figure 8As shown, the computer-readable storage medium of the present application stores program instructions 61 that can implement all the above methods, wherein the program instructions 61 can be stored in the above storage medium in the form of a software product, including several instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) or a processor to execute all or part of the steps of each implementation method of the present application. The aforementioned storage device includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes, or electronic devices such as computers, servers, mobile phones, tablets, etc.
[0175] The above description is only an implementation method of the present application, and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly used in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A line segment detection method, characterized in that: include: Acquire laser point cloud data, wherein the laser point cloud data includes coordinate data of a plurality of points to be processed, and store the coordinate data of the plurality of points to be processed in a parallel processing unit; Allocating a plurality of the to-be-processed points to the processing threads of the parallel processing unit respectively, so as to calculate and obtain a first tensor space corresponding to the to-be-processed straight line to be detected of the to-be-processed points; Screening the corresponding first tensor space by the processing thread to obtain a second tensor space in which the number of straight lines is greater than a first preset threshold, and calculating the straight line information of the straight line to be detected in the second tensor space; Clustering is performed based on the valid points on the straight line information to obtain line segments composed of the valid points, so as to identify target objects with line segment features based on the line segments.
2. The line segment detection method according to claim 1, characterized in that: Before the step of acquiring laser point cloud data, wherein the laser point cloud data includes coordinate data of a plurality of points to be processed, and storing the coordinate data of the plurality of points to be processed in the parallel processing unit, the line segment detection method further includes: Based on the description features of the straight line to be detected, construct a third tensor space, and store the third tensor space on the parallel processing unit; The step of respectively allocating the plurality of points to be processed to the processing threads of the parallel processing unit to calculate and obtain the first tensor space corresponding to the straight lines to be detected of the points to be processed includes: The corresponding points to be processed are mapped to the third tensor space through the processing thread to calculate the first tensor space corresponding to the straight line to be detected.
3. The line segment detection method according to claim 2, characterized in that: Mapping the corresponding to-be-processed point to the third tensor space by the processing thread to calculate the first tensor space corresponding to the straight line of the to-be-processed point includes: Based on the third tensor space, calculating the normal vector subspace corresponding to the to-be-processed point of the current processing thread; Based on the normal vector subspace, calculating the first vertical point coordinate of the to-be-processed point of the current processing thread on the corresponding vertical point subspace; The first tensor space is constructed based on the normal vector subspace, the vertical point subspace and the first vertical point coordinates corresponding to the point to be processed.
4. The line segment detection method according to claim 3, characterized in that: After the step of acquiring laser point cloud data, wherein the laser point cloud data includes coordinate data of a plurality of points to be processed, and storing the coordinate data of the plurality of points to be processed in a parallel processing unit, the line segment detection method includes: Establishing a data index in the parallel processing unit for data processed by each processing thread of the parallel processing unit; The calculating, based on the normal vector subspace, the first vertical point coordinate of the to-be-processed point of the current processing thread on the corresponding vertical point subspace comprises: Based on the data index, calculating the label information of the to-be-processed point of the current processing thread in the parallel processing unit; Based on the label information and the normal vector subspace, calculating the first vertical point coordinate of the to-be-processed point of the current processing thread on the corresponding vertical point subspace; After the step of constructing the first tensor space based on the normal vector subspace, the vertical point subspace and the first vertical point coordinates corresponding to the point to be processed, the line segment detection method further includes: Based on the normal vector subspace, the vertical point subspace and the first vertical point coordinate corresponding to the point to be processed, index information between the position of the straight line to be detected in the first tensor space and its position in the parallel processing unit is calculated.
5. The line segment detection method according to claim 4, characterized in that: The screening of the first tensor spaces corresponding to all the processing threads to obtain a second tensor space in which the number of straight lines is greater than a first preset threshold, and calculating the straight line information of the straight line to be detected in the second tensor space, includes: Obtaining the number of lines in the first tensor space corresponding to all the processing threads; When the number of the straight lines is greater than a first preset threshold, adding the corresponding straight lines to be detected to the second tensor space; Based on the data index, the line information of the line to be detected in the second tensor space is calculated to obtain the line information of the line to be detected.
6. The line segment detection method according to claim 2, characterized in that: The constructing a third tensor space based on the description features of the straight line to be detected, and storing the third tensor space on the parallel processing unit, comprises: Based on the description features of the straight line to be detected, construct the third tensor space, wherein the third tensor space includes a vertical point subspace and a normal vector subspace; defining a distance resolution of a straight line of interest in the vertical point subspace and a second vertical point coordinate of a vertical point of interest, so as to discretize the vertical point subspace based on the second vertical point coordinate and the distance resolution; defining a first parameter and a second parameter of the normal vector subspace, and calculating a polar angle of the normal vector subspace based on the first parameter, the second parameter and the azimuth angle of the normal vector subspace; Discretizing the normal vector subspace based on the polar angle; The discretized normal vector subspace is stored in the parallel processing unit.
7. The line segment detection method according to claim 1, characterized in that: The straight line information includes straight line information of the straight line to be detected in the second tensor space; before the step of clustering valid points on the straight line information to obtain line segments composed of the valid points, and identifying target objects with line segment features based on the line segments, the line segment detection method further includes: Calculating the distance between the point to be processed and the corresponding straight line to be detected based on the coordinate data of the point to be processed and the straight line information of the straight line to be detected; When the distance is less than a second preset threshold, determining the point to be processed as a valid point; When the distance is greater than or equal to the second preset threshold, the point to be processed is determined to be an invalid point.
8. The line segment detection method according to claim 7, characterized in that: The clustering of valid points on the straight line information to obtain line segments composed of the valid points, so as to identify target objects with line segment features based on the line segments, includes: Clustering is performed based on the distances between the valid points on the straight line information to obtain a number of line segments composed of the valid points; Based on the distance between the starting point and the ending point of each line segment, filter out line segments within a preset length range; The screened line segments are identified to obtain the target object having the line segment features.
9. The line segment detection method according to claim 1, characterized in that: Before the step of respectively allocating the plurality of points to be processed to the processing threads of the parallel processing unit to calculate and obtain the first tensor space corresponding to the straight lines to be detected of the points to be processed, the line segment detection method further includes: Allocating a first video memory in the parallel processing unit to the first tensor space corresponding to the point to be processed; Initializing the first video memory; And / or, before the step of clustering the valid points on the straight line information to obtain line segments composed of the valid points, and identifying target objects with line segment features based on the line segments, the line segment detection method further includes: Allocating a second video memory in the parallel processing unit for the points on the straight line to be detected, the second video memory being used to store the number of points and point indexes on the straight line to be detected; Perform an initialization operation on the second video memory.
10. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the processor is connected to the memory, wherein: The memory stores program instructions; The processor is configured to execute program instructions stored in the memory to implement the method according to any one of claims 1 to 9.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores program instructions, and the program instructions can be executed by a processor to implement the method according to any one of claims 1 to 9.