A real-time query method for massive moving targets based on CUDA
By adopting a CUDA-based method in massive motion target scenarios and using GPU for parallel computing, a real-time query method for massive motion targets is designed, which solves the problems of low query efficiency and insufficient conditional flexibility in the existing technology, and realizes efficient and flexible real-time query capabilities.
Patent Information
- Application Number
- CN202211155878.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-22
- Publication Date
- 2025-05-16
- Estimated Expiration
- 2042-09-22
AI Technical Summary
In the massive motion target scenario, it is difficult for the existing technology to realize efficient multi-region topological relationship query and distance relationship query, and the query conditions are insufficient flexibility.
Using a CUDA-based method, GPU performs parallel computing, a real-time query method for massive motion targets is designed. This method includes external data reception and management, target life cycle management and dynamic target real-time query, improve query efficiency through CUDA kernel function calculation, and supports the combination of multiple query conditions.
It realizes efficient real-time query in massive motion target scenarios, improves the efficiency of multi-region topological relationship and distance relationship query, supports flexible combination of query conditions, and significantly improves query speed and flexibility.
Smart Images

Figure CN115563152B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of target query, and in particular relates to a real-time query method for massive moving targets based on CUDA. Background Art
[0002] With the development and popularization of various sensor technologies such as GPS, AIS, and radar, we have accumulated a large amount of information on real-time moving targets. Real-time queries based on massive target trajectory information are widely used in basic technical fields such as LBS (Location Based Service) and battlefield situation analysis, such as real-time queries for targets in a certain area, and queries for targets outside a certain area within a certain range from the area. This kind of real-time query based on dynamic targets has several characteristics: first, the amount of data on dynamic targets is huge; second, there is a strong requirement for the real-time nature of the query results, which often requires real-time and multiple outputs in the form of data streams; third, the query combination conditions are diverse, which may be a joint query of multiple areas or a joint query under multiple conditions.
[0003] The above-mentioned characteristics require: fast query algorithm and flexible query conditions. In response to the above requirements, we use the mainstream parallel computing method based on GPU (GPGPU, General Purpose GPU) to solve the efficient query problem in the scenario of massive moving targets. The above are the application requirements of the present invention. Summary of the invention
[0004] The main task of the present invention is to design a real-time query method for massive moving targets based on CUDA, which has the following subtasks:
[0005] 1) Solve the problem of multi-region topological relationship query in massive target scenarios based on CUDA architecture, specifically, improve the efficiency of real-time query of targets in multiple regions in massive target scenarios;
[0006] 2) Solve the distance relationship query problem in massive target scenarios based on CUDA architecture, specifically, improve the efficiency of real-time query of the shortest distance from target to region in massive target scenarios;
[0007] 3) Solve the problem of combined query, improve the flexibility of query, and support three query methods: intra-area query, regional shortest distance query, and combination query of the first two.
[0008] The present invention provides a real-time query method for massive moving targets based on CUDA, and the method comprises the following steps:
[0009] Step 1: External data reception and management.
[0010] It includes three parts: external data reception, target data management, and regional data management. The received external data includes real-time target data and query regional data; after receiving the target data Track, update its life state lifeState, position information pos, distance state distState, and latest update time updateTime, and add or update the target data according to the target batch number ph; for the regional data Area, calculate its circumscribed rectangle to reduce the amount of calculation when querying the target.
[0011] Step 2: Target lifecycle management.
[0012] It includes three parts: lifecycle management data parameter setting, lifecycle management kernel function calculation, and expired target deletion. The lifecycle management data parameters mainly include the current total number of targets trackNum, the current time curTime, and the target data d_trackVec; after preparing the parameters required for lifecycle calculation, start the lifecycle management kernel function to calculate the life status of each target; for expired targets, delete them from d_trackVec.
[0013] Step 3: Real-time query of dynamic targets.
[0014] It includes four parts: target query data parameter setting, target query kernel function calculation in the region, real-time distance relationship query calculation, and target query result output. The target query data parameters mainly include d_trackVec, trackNum, area data d_areaVec, area number areaNum, area circumscribed rectangle data d_areaRecVec, distance threshold T Dist , target query mode inquireMode; after preparing the data parameters required for target query, start the target query kernel function in the area to calculate the position relationship between each target and the area; for targets outside the area, calculate the shortest distance minDist between it and the area area ; After completing the target query, the target data results of the query are output to the external server through the network for display.
[0015] Step 1, external data reception and management, mainly includes the following steps:
[0016] Step 1.1, external data reception. Create a data receiving sub-thread on the CPU side, and receive the target data and area data continuously transmitted by the network in real time in the sub-thread.
[0017] Step 1.2, Target Data Management. Upon receiving a new batch of target data, parse information such as the batch number, longitude, latitude, and altitude of the target, convert it to an internal structure, and assign initial values to the four attributes of the target: lifeState, pos, distState, and updateTime. Then, perform target data management based on the ph information of the target. If the ph already exists, update the original storage of the target; if the ph does not exist, insert the target data at the end of the d_trackVec. After the target life cycle management in Step 2, delete the targets that have passed the life cycle from the d_trackVec.
[0018] Step 1.3, Area Data Management. Perform area data management based on the id information. When receiving new area data, check if the id exists. If it already exists, update the original storage of the area; otherwise, insert the area data at the end of the d_areaVec. Then, calculate the circumscribed rectangle of each area based on the inflection point information of the area and store it in the d_areaRecVec.
[0019] Among them, Step 2, Target Life Cycle Management, mainly includes the following steps:
[0020] Step 2.1, Life Cycle Management Data Parameter Setting. To perform target life cycle management, three pieces of data are required as input: the entire target data d_trackVec, the number of targets trackNum, and the current time curTime. After copying these three pieces of data from the CPU side to the GPU side, they are passed into the video memory in the form of kernel function data parameters for parallel calculation.
[0021] Step 2.2, Life Cycle Management Kernel Function Calculation. When trackNum is greater than 0, start the target life cycle management CUDA kernel function kernel_ProcVanishTrack, and design the one-dimensional kernel function thread parameters according to trackNum: the thread grid GridSize and the thread block BlockSize. Pass the data parameters in Step 2.1 to the GPU for processing. In kernel_ProcVanishTrack, first define the thread index idx, which represents the index value of the target list; secondly, when idx < trackNum, check if the latest update time of the target under the idx index of this thread exceeds the life cycle of the target; finally, for the expired targets, update their lifeState attribute.
[0022] Step 2.3, Deletion of Expired Targets. After the life cycle management kernel function calculation is completed, delete the expired targets in the d_trackVec according to the lifeState attribute of each target.
[0023] Among them, step 3, dynamic target real-time query, mainly includes the following steps:
[0024] Step 3.1, target query data parameter setting. For real-time target query, seven pieces of data including all target data d_trackVec, the number of targets trackNum, area data d_areaVec, the number of areas areaNum, area circumscribed rectangle data d_areaRecVec, distance threshold T Dist and the target query mode inquireMode are used as inputs. After copying these seven pieces of data from the CPU side to the GPU side, they are passed into the video memory in the form of kernel function data parameters for parallel calculation.
[0025] Step 3.2, calculation of the target query kernel function within the area. When trackNum is greater than 0 and areaNum is greater than 0, start the real-time query CUDA kernel function kernel_InquireTrack, calculate the two-dimensional kernel function thread parameters according to trackNum and areaNum, and pass the data parameters in step 3.1 to the GPU for processing. In kernel_InquireTrack, first define the thread indices idx and idy, which represent the index values of the target list and the area list respectively; secondly, when idx < trackNum and idy < areaNum, obtain the target data and area data under the current idx and idy indices, and calculate whether the current target is within the circumscribed rectangle corresponding to the current area. For targets not within the circumscribed rectangle, judge the value of inquireMode. If inquireMode = 2 or 3, that is, it represents the distance relationship query mode, then go to step 3.3, otherwise, go to step 3.4; for targets within the circumscribed rectangle, continue to calculate whether the current target is within the irregular area. If it is within the area, update the pos information of the target. If it is not within the area, first update the pos information of the target, then judge the value of inquireMode. If inquireMode = 2 or 3, then go to step 3.3 for distance relationship query, otherwise, go to step 3.4.
[0026] Step 3.3, real-time distance relationship query calculation. The distance relationship calculation is also executed in the kernel_InquireTrack kernel function. Calculate the perpendicular distance dist⊥ from the target point to each boundary line of the area and the straight-line distance dist pt1 、dist pt2 between the target point and the two endpoints of the boundary, and take the minimum value as the shortest distance from the target point to the area boundary line; take the minimum value among the shortest distances from the target point to each boundary line of the area as the shortest distance minDist area from the target to the area. For minDistarea Less than T Dist The target is updated with its distState attribute.
[0027] Step 3.4: Output the target query result. According to the query conditions, the targets in the area and those outside the area with minDist area <T Dist The target is selectively transmitted from the GPU to the CPU, and then a data sending sub-thread is created on the CPU to output the two types of data through the network to the external server for query result display.
[0028] The beneficial effects of the present invention are:
[0029] The present invention proposes a real-time query method for massive moving targets based on CUDA, which has the following characteristics and advantages:
[0030] (1) High efficiency of real-time query. In the scenario of massive moving target data, the present invention comprehensively and collaboratively utilizes CPU and GPU resources, wherein network transmission is performed in the CPU, and modules with high computational load such as moving target lifecycle management and dynamic target real-time query are performed in the GPU, making full use of the GPU multi-threading advantage. The experimental computer environment is: the CPU model is Intel (R) Xeon (R) W-2145, and the GPU model is NVIDIA Quadro P4000 (including 1792 cores). According to the experimental data, under the conditions of 30,000 batches of targets and 80 regions, the GPU-based algorithm used in the present invention is about 76 times more efficient than the corresponding CPU-based algorithm.
[0031] (2) Query conditions can be combined. You can pass in the query mode parameter settings to achieve a combination of multiple query conditions, including within-area query, area shortest distance query, and a combination of the first two. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 This is a flow chart of a real-time query method for massive moving targets based on CUDA in the present invention. DETAILED DESCRIPTION
[0033] The technical solution provided by the present invention will be described in detail below in conjunction with specific embodiments. It should be understood that the following specific implementation methods are only used to illustrate the present invention and are not used to limit the scope of the present invention.
[0034] Depend on Figure 1 It is given that the present invention consists of three steps: external data reception and management, target life cycle management, and dynamic target real-time query.
[0035] The present invention provides a real-time query method for massive moving targets based on CUDA, and the method comprises the following steps:
[0036] Step 1: External data reception and management
[0037] It mainly includes three parts: external data reception, target data management, and regional data management. The received external data includes real-time target data and query regional data; after receiving the target data Track, update its life state lifeState, target position information pos, distance state distState, and latest update time updateTime, and add or update the target data according to the target batch number ph; for the regional data Area, calculate its circumscribed rectangle to reduce the amount of calculation when querying the target.
[0038] Step 1.1: External data reception
[0039] Create a data receiving sub-thread on the CPU side to receive external network data, including real-time transmission target data and regional data.
[0040] Step 1.2: Target data management
[0041] Define the target data structure running inside the software, namely TrackInfo. This structure contains seven attributes: target batch number ph, longitude lon, latitude lat, latest update time updateTime, lifeState, target position information pos, and distance state distState. After receiving the target data from the network, parse the ph, lon, and lat information contained in the data and assign them to TrackInfo, and assign initial values to the updateTime, lifeState, pos, and distState attributes as follows:
[0042]
[0043] Among them, updateTime is assigned to the current time curTime; lifeState is assigned to 1, indicating that the target is within the life cycle, and 0 indicates that it is outside the life cycle; pos is assigned to 0, indicating that the target is not in any area, and 1 indicates that the target is in one or more areas; distState is assigned to 0, indicating that the shortest distance from the target to any area is greater than or equal to the distance threshold T Dist , 1 means the shortest distance from the target to one or more regions is less than T Dist .
[0044] Use thrust::device_vector container in CUDA to manage target data and store them uniformly in target data d_trackVec. The elements stored in d_trackVec are of TrackInfo type. Every time a new batch of target data is received, after the above data preprocessing operation, it is determined whether the current target already exists in d_trackVec according to ph. If it does exist, the data of the corresponding batch number is updated in d_trackVec. Otherwise, it means that the batch of targets is new, and the batch of target data items are directly added to the end of d_trackVec. After the target lifecycle management is executed, the expired targets are deleted in d_trackVec.
[0045] Step 1.3: Regional data management
[0046] The thrust::device_vector container in CUDA is also used to manage the regional data, which is uniformly stored in the regional data d_areaVec. The element data type stored in d_areaVec is AreaInfo, which contains the latitude and longitude of each turning point of the region, and is also a custom data structure within the software. Using the above target data management method, the update and deletion of the regional data are managed according to the id information of the region.
[0047] Calculate the maximum longitude and latitude values of all inflection points in each region: maximum longitude maxLon, minimum longitude minLon, maximum latitude maxLat, minimum latitude minLat. The position information of the four inflection points that make up the circumscribed rectangle of the region is as follows:
[0048]
[0049] Among them, leftUp, rightUp, leftBottom, and rightBottom represent the position coordinates of the upper left corner, upper right corner, lower left corner, and lower right corner of the bounding rectangle respectively. This information is stored in the custom data structure AreaRec inside the software, and the bounding rectangle information of all areas is uniformly stored in the area bounding rectangle data d_areaRecVec.
[0050] Step 2: Target lifecycle management
[0051] It mainly includes three parts: lifecycle management data parameter setting, lifecycle management kernel function calculation, and expired target deletion. The lifecycle management data parameters mainly include the current total number of targets trackNum, the current time curTime, and the target data d_trackVec; after preparing the parameters required for lifecycle calculation, start the lifecycle management kernel function to calculate the life status of each target; for expired targets, delete them from the target data d_trackVec.
[0052] Step 2.1: Lifecycle management data parameter settings
[0053] The data parameters required by the lifecycle calculation kernel function include: all target data d_trackVec, target number trackNum and current time curTime. The target number trackNum is used to protect the target array index in the GPU thread to avoid out-of-bounds access. The current time curTime is used to compare with the latest update time of the target to determine whether the target is expired.
[0054] Step 2.2: Calculation of lifecycle management kernel function
[0055] Execute target lifecycle management periodically in the timer. When the target number trackNum is greater than 0, start the target lifecycle management CUDA kernel function kernel_ProcVanishTrack. Design the thread parameters of this kernel function as follows:
[0056]
[0057] BlockSize represents the thread block parameter, GridSize represents the thread grid parameter, and dim3 represents the three-dimensional data structure definition. In order to make each stream processor SM of the experimental GPU reach 100% occupancy and maximize the use of GPU resources, the following principles should be followed:
[0058]
[0059] Where threadNum block is a positive integer, indicating the number of threads in each thread block, that is, the product of the three dimensions in BlockSize; N indicates the maximum number of threads that can be concurrently supported by each SM in the GPU; m indicates the maximum number of thread blocks that can be stored in each SM. N and m may be different for different graphics cards; k1 and k2 are integer multiples. According to the graphics card parameters of this experiment, BlockSize.x = 1024 can maximize the computing power of the GPU.
[0060] In the kernel function, define the thread index idx as follows:
[0061] idx = blockIdx.x * blockDim.x + threadIdx.x
[0062] Among them, blockIdx.x represents the horizontal index of the thread block in the thread grid, blockDim.x represents the horizontal dimension of each thread block in the thread grid, and threadIdx.x represents the horizontal thread index in the current thread block.
[0063] When idx < trackNum, using idx as the array subscript of the target data, determine whether the current target has expired:
[0064]
[0065] Among them, track[idx].time represents the last update time of the idx-th target, and Tlife represents the longest survival time in the case of no update of the target.
[0066] Step 2.3, Deleting expired targets
[0067] After the execution of the kernel_ProcVanishTrack kernel function ends, delete the targets that have passed the life cycle in d_trackVec according to the returned lifeState. The deletion of expired targets in d_trackVec and the previous data update operations need to be protected by a multi-threaded mutex on the CPU side, otherwise software exception problems will occur.
[0068] Step 3, Real-time query of dynamic targets
[0069] It mainly includes four parts: setting target query data parameters, calculating the kernel function for querying targets within the region, calculating the real-time distance relationship query, and outputting the target query results. The data parameters for target query mainly include target data d_trackVec, the number of targets trackNum, region data d_areaVec, the number of regions areaNum, region circumscribed rectangle data d_areaRecVec, distance threshold T Dist , target query method inquireMode; after preparing the data parameters required for target query, start the kernel function for querying targets within the region to calculate the position relationship between each target and the region; for targets outside the region, calculate their shortest distance minDist area ; after completing the target query, display the query result data of the target to an external server through network output.
[0070] Step 3.1, Setting target query data parameters
[0071] The data parameters required by the target query calculation kernel function include: target data d_trackVec, number of targets trackNum, number of areas areaNum, area data d_areaVec, area circumscribed rectangle data d_areaRecVec, and distance threshold T Dist , target query method inquireMode, where areaNum is used to protect the area array index in the GPU thread, and T Dist is the danger threshold range used to judge whether a target outside the area reaches the area, and inquireMode is used to switch different query modes.
[0072] Step 3.2, calculation of the target query kernel function within the area
[0073] Perform real-time target queries periodically in the timer. When the number of targets trackNum is greater than 0 and the number of areas areaNum is greater than 0, start the real-time query CUDA kernel function kernel_InquireTrack. Design the thread parameters of this kernel function as follows:
[0074]
[0075] In the kernel function, define the thread indices idx and idy as follows:
[0076]
[0077] Among them, blockIdx.x represents the horizontal index of the thread block in the thread grid, blockDim.x represents the horizontal dimension of each thread block in the thread grid, threadIdx.x represents the horizontal thread index in the current thread block, blockIdx.y represents the vertical index of the thread block in the thread grid, blockDim.y represents the vertical dimension of each thread block in the thread grid, and threadIdx.y represents the vertical thread index in the current thread block.
[0078] When idx < trackNum and idy < areaNum, use idx as the array subscript of the target data and idy as the array subscript of the area data. First, initialize the target position information pos and the distance status distState to 0 to avoid the influence of the target's attributes during the previous refresh on the current calculation.
[0079] Then judge whether the current target point is within the circumscribed rectangle of the current area for rough screening to improve the calculation efficiency:
[0080]
[0081] Among them, track[idx].lon represents the longitude of the idx-th target, and track[idx].lat represents the latitude of the idx-th target.
[0082] ptInRec indicates whether the target is within the bounding rectangle. For targets that are not within the bounding rectangle, that is, ptInRec = 0, the target's pos is updated to 0, and the value of the target query mode inquireMode is determined. If inquireMode = 2 or 3, then go to step 3.3, otherwise, go to step 3.4. For targets within the bounding rectangle, that is, ptInRec = 1, continue to calculate whether the current target is within the irregular area. By using the ray method, calculate the parity of the intersection of the ray drawn from the target point and the polygon to determine the positional relationship between the target point and the area, as shown in the following formula:
[0083] cenFlag=(x0≥x i &&x0 <x i+1 )||(x0 <x i &&x0≥x i+1 )
[0084] cross=(x0-x i )×(y i+1 -y i )-(y0-y i )×(x i+1 -x i )
[0085] Among them, cenFlag indicates whether the coordinates of the target point are between the first and last points of the region boundary; cross indicates the cross product of the two vectors connecting the first and last points of the boundary; x0 and y0 indicate the longitude and latitude of the target, and x i and i 、x i+1 and i+1 Represents the latitude and longitude of the first and last points of the boundary. When cenFlag = true, count the number of cross<0 of all boundaries of the region Inters. When Inters is an odd number, it means the target is in the region. When Inters is an even number, it means the target is outside the region. Update the position relationship between the target and the region as follows:
[0086]
[0087] Since multiple threads in the GPU may operate on the pos attribute of the same target at the same time, in order to avoid calculation errors caused by thread synchronization problems, the atomicOr function in CUDA is used to update the data of the pos attribute. When the target is in one or more areas, pos=1, and go to step 3.4; when the target is not in any area, pos=0, and the value of the target query mode inquireMode is determined. If inquireMode=2 or 3, go to step 3.3, otherwise, go to step 3.4.
[0088] Step 3.3: Real-time distance relationship query calculation
[0089] This part is also performed in the kernel_InquireTrack kernel function. When the target point is not in any area, the shortest distance from the point to the area is calculated. The shortest distance dist from the target point to each boundary line of the area is calculated by the vector method. min , the specific process is as follows:
[0090] Step 3.3.1: Set the i-th boundary of the region to be composed of boundary point Pt i and Pt i+1 The position coordinates are (x i ,y i )、(x i+1 ,y i+1 ).
[0091] Step 3.3.2, calculate the projection point P of the target point Pt0(x0,y0) on the boundary line ⊥ With Pt i The squared distance between them is as follows:
[0092] proj=(x0-x i )×(y i+1 -y i )-(y0-y i )×(x i+1 -x i )
[0093] Step 3.3.3, determine whether proj is greater than 0
[0094] If proj≤0, it means P ⊥ In Pt i The extension line of the side, then dist min Equal to Pt0 and Pt i The Euclidean distance between them is as follows:
[0095]
[0096] Go to step 3.3.4;
[0097] If proj>0, calculate Pt i and Pt i+1 The squared Euclidean distance between them is as follows:
[0098] dist i =(x i+1 -x i ) 2 +(y i+1 -y i ) 2
[0099] Then determine whether proj is greater than or equal to dist i ;
[0100] If proj ≥ dist i , indicating that P⊥ in Pt i+1 The extension line of the side, then dist min Equal to Pt0 and Pt i+1 The Euclidean distance between them is as follows:
[0101]
[0102] Go to step 3.3.4;
[0103] If proj <dist i , indicating that P ⊥ In Pt i and Pt i+1 Connect the lines and calculate P ⊥ (x ⊥ ,y ⊥ ) coordinates are as follows:
[0104]
[0105] dist min Equal to Pt0 and P ⊥ The Euclidean distance between them is as follows:
[0106]
[0107] Go to step 3.3.4;
[0108] Step 3.3.4: Calculate the shortest distance from the target point to all boundaries of the region, and take the minimum value of all the shortest distance values as the shortest distance minDist from the target point to the region. area When minDist area <T Dist , it means that the target is not in the area, but has reached the dangerous distance threshold of the area. The distance status of the target is updated as follows:
[0109]
[0110] Step 3.4: Output of target query results
[0111] The kernel_InquireTrack kernel function updates the target position information pos and distance state distState information of all targets under various regional conditions. These information are stored in the GPU memory. After the target data is transferred from the GPU to the CPU, a data sending subthread is created on the CPU. According to the attribute values of pos and distState of each target, the query target data is output to the external server through the network. When the target query mode inquireMode=1, only the target data in the region is output; when inquireMode=2, the target data and minDist in the region are output. area <T Dist The target data is output at the same time; when inquireMode = 3, only minDist area <T Dist Target data output. Finally, the target query results are displayed on the server display screen.
[0112] The above description is only the best specific implementation mode of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by any technician familiar with the technical field within the technical scope disclosed by the present invention should be covered within the protection scope of the present invention.
[0113] The contents not described in detail in the specification of the present invention belong to the common knowledge of the professionals in this field.
Claims
1. A real-time query method for massive moving targets based on CUDA, characterized in that: The steps of this method are as follows: Step 1: External data reception and management; It includes three parts: external data reception, target data management, and regional data management. The received external data includes real-time target data and query regional data. After receiving the target data Track, its life state lifeState, position information pos, distance state distState, and latest update time updateTime are updated. The target data is added or updated according to the target batch number ph. For the regional data Area, its circumscribed rectangle is calculated to reduce the amount of calculation during target query. Step 2: Target lifecycle management; It includes three parts: lifecycle management data parameter setting, lifecycle management kernel function calculation, and expired target deletion. The lifecycle management data parameters mainly include the current total number of targets trackNum, the current time curTime, and the target data d_trackVec. After preparing the parameters required for lifecycle calculation, start the lifecycle management kernel function to calculate the life status of each target. For expired targets, delete them from d_trackVec. Step 3: Real-time query of dynamic targets; It includes four parts: target query data parameter setting, target query kernel function calculation within the region, real-time distance relationship query calculation, and target query result output; The data parameters of the target query mainly include d_trackVec, trackNum, area data d_areaVec, area number areaNum, area circumscribed rectangle data d_areaRecVec, distance threshold T Dist , target query mode inquireMode; After preparing the data parameters required for target query, start the target query kernel function in the region to calculate the position relationship between each target and the region; for targets outside the region, calculate the shortest distance minDist between them and the region area ; After completing the target query, the target data results of the query are output to the external server through the network for display.
2. The method according to claim 1, characterized in that Step 1, external data reception and management, mainly includes the following steps: Step 1.1, external data reception: create a data receiving sub-thread on the CPU side, and receive the target data and area data continuously transmitted by the network in real time in the sub-thread; Step 1.2, target data management; each time a new batch of target data is received, the batch number and latitude and longitude information of the target are parsed, converted into an internal structure, and the four attributes of the target, lifeState, pos, distState, and updateTime, are assigned initial values; then the target data is managed according to the ph information of the target. If ph already exists, the original storage of the target is updated. If ph does not exist, the target data is inserted at the end of d_trackVec; after the target life cycle management is performed in step 2, the target whose life cycle has expired should be deleted in d_trackVec; Step 1.3, regional data management; regional data management is performed according to the number id information. Every time new regional data is received, it is determined whether the id exists. If it exists, the original storage of the region is updated, otherwise the regional data is inserted at the end of d_areaVec; then the circumscribed rectangle of each region is calculated based on the inflection point information of the region and stored in d_areaRecVec.
3. The method according to claim 1, characterized in that: Step 2, target lifecycle management, mainly includes the following steps: Step 2.1, lifecycle management data parameter setting; To perform target lifecycle management, all target data d_trackVec, target number trackNum and current time curTime are required as input. The three data are copied from the CPU to the GPU and then transferred to the video memory in the form of kernel function data parameters for parallel calculation; Step 2.2, calculation of the lifecycle management kernel function; when trackNum is greater than 0, start the target lifecycle management CUDA kernel function kernel_ProcVanishTrack, and design one-dimensional kernel function thread parameters according to trackNum: thread grid GridSize and thread block BlockSize; transfer the data parameters in Step 2.1 to the GPU for processing; in kernel_ProcVanishTrack, first define the thread index idx, representing the index value of the target list; secondly, when idx < trackNum, judge whether the latest update time of the target under the current thread idx index exceeds the lifecycle of the target; finally, for the expired targets, update their lifeState attributes. Step 2.3, deletion of expired targets; after the calculation of the lifecycle management kernel function, delete the expired targets in d_trackVec according to the lifeState attribute of each target.
4. The method according to claim 1, characterized in that: Among them, Step 3, real-time query of dynamic targets, mainly includes the following steps: Step 3.1, target query data parameter setting; for real-time target query, all target data d_trackVec, target number trackNum, area data d_areaVec, area number areaNum, area circumscribed rectangle data d_areaRecVec, distance threshold T are required. Dist The seven data items of the target query mode inquireMode are used as input, and the seven data items are copied from the CPU to the GPU and then transferred to the video memory in the form of kernel function data parameters for parallel calculation; Step 3.2, calculation of the kernel function for querying targets within a region; when trackNum is greater than 0 and areaNum is greater than 0, start the real-time query CUDA kernel function kernel_InquireTrack, calculate two-dimensional kernel function thread parameters according to trackNum and areaNum, and transfer the data parameters in Step 3.1 to the GPU for processing; in kernel_InquireTrack, first define the thread indices idx and idy, representing the index value of the target list and the index value of the region list respectively; secondly, when idx < trackNum and idy < areaNum, obtain the target data and region data under the current idx and idy indices, and calculate whether the current target is within the circumscribed rectangle corresponding to the current region; for the targets not within the circumscribed rectangle, judge the value of inquireMode. If inquireMode = 2 or 3, that is, it represents the distance relationship query mode, then go to Step 3.3, otherwise, go to Step 3.4; for the targets within the circumscribed rectangle, continue to calculate whether the current target is within the irregular region. If it is within the region, update the pos information of the target. If it is not within the region, first update the pos information of the target, and then judge the value of inquireMode. If inquireMode = 2 or 3, then go to Step 3.3 for distance relationship query, otherwise, go to Step 3.
4. Step 3.3, real-time distance relationship query calculation; distance relationship calculation is performed in the kernel_InquireTrack kernel function; calculate the vertical distance dist⊥ from the target point to each boundary line of the region and the straight-line distance dist between the target point and the two endpoints of the boundary pt1 、dist pt2 The minimum value between the target point and the boundary line of the region is taken as the shortest distance from the target point to the boundary line of the region; the minimum value of the shortest distance from the target point to each boundary line of the region is taken as the shortest distance minDist from the target to the region area ; For minDist area Less than T Dist The target is updated with its distState attribute; Step 3.4, output of the target query result. According to the query conditions, the targets in the area and those outside the area with minDist area <T Dist The target is selectively transmitted from the GPU to the CPU, and then a data sending sub-thread is created on the CPU to output the two types of data through the network to the external server for query result display.
Citation Information
Patent Citations
Dynamic object detection method and system under motion visual angle based on light projection principle
CN114613002A
Attack path parallel planning system and method for large-scale industrial control scene
CN115061434A