Vehicle snapshot method, system, device and storage medium
By calculating the overlap ratio and number of intersections between the vehicle detection frame and the preset tripwire, the problems of false triggering and insufficient real-time performance in traditional vehicle capture methods are solved, achieving high-precision and high-speed real-time vehicle capture.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HUNAN NOVASKY ELECTRONICS TECH CO LTD
- Filing Date
- 2025-09-09
- Publication Date
- 2026-07-24
AI Technical Summary
Traditional vehicle capture methods, such as the geometric intersection method, have a high false trigger rate, while the trajectory tracking method lacks real-time performance and cannot achieve high-precision and high-speed real-time capture under complex road conditions.
By calculating the overlap ratio and the number of actual intersections between the vehicle detection frame and the preset tripwire, and combining the vector cross product formula to determine collinearity, a precise quantitative multi-level discrimination is achieved. This method abandons the absolute binary judgment of the geometric intersection method and uses single-frame geometric relationship analysis to make millisecond-level decisions.
It suppresses false triggers caused by vehicle detection frame offset, avoids missed shots due to lost trajectory tracking, and achieves high-precision and real-time vehicle capture.
Smart Images

Figure CN121171037B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of intelligent transportation technology, and in particular relates to a vehicle capture method, system, device and storage medium based on the overlap ratio between the visual detection frame and the tripwire. Background Technology
[0002] In the field of intelligent traffic monitoring, the accuracy and real-time performance of vehicle capture are core requirements, and tripwire triggering technology based on visual detection boxes is a key component. Traditional vehicle capture methods are mainly divided into two categories:
[0003] The first type is the geometric intersection method: this method triggers capture by real-time judgment of the geometric intersection state between the vehicle detection frame boundary and the preset tripwire. Its advantages are its simple principle and rapid response; however, the capture accuracy is easily affected by the positioning error of the visual detection frame, directly leading to false triggers. For example, an oversized or offset visual detection frame can cause false captures of vehicles that have not crossed the line. Furthermore, the geometric intersection method lacks the ability to discern the vehicle's behavioral intent, failing to distinguish between normal line crossing and illegal line crossing, resulting in a sharp increase in false alarms in dense traffic or complex road conditions. To improve the accuracy of vehicle capture, the trajectory tracking method has emerged.
[0004] The second type is the trajectory tracking method: by tracking the movement trajectory of the center point of the vehicle detection box over multiple frames, analyzing its continuous crossing of the trip line before triggering the capture, this significantly reduces false detection interference and enhances the ability to identify the true intention to cross the line. However, the performance of the trajectory tracking method is highly dependent on the robustness of the tracking algorithm. When the vehicle is obstructed, changes lanes quickly, or travels at high speed, the tracking trajectory is easily interrupted, leading to missed captures. Furthermore, the calculation process of trajectory accumulation and line crossing determination introduces significant delays, making it difficult to meet the millisecond-level real-time requirements of scenarios such as highway checkpoints and traffic violation capture. Summary of the Invention
[0005] The purpose of this invention is to provide a vehicle capture method, system, device, and storage medium to solve the problems of high false trigger rate of geometric intersection method and insufficient real-time performance of trajectory tracking method in traditional vehicle capture.
[0006] This invention solves the above-mentioned technical problems through the following technical solution: a vehicle capture method, comprising:
[0007] Obtain the vehicle inspection frame;
[0008] Determine whether the vehicle detection frame is collinear with the preset tripwire;
[0009] If the vehicle detection frame is collinear with the preset tripwire, the overlap ratio when collinear is calculated.
[0010] If the vehicle detection frame is not collinear with the preset trip line, then calculate the number of actual intersection points between the vehicle detection frame and the preset trip line, and calculate the overlap ratio under different numbers of actual intersection points;
[0011] Whether to capture a vehicle is determined by the overlap ratio when the vehicles are collinear or the overlap ratio under different numbers of actual intersections.
[0012] This invention analyzes the dynamic geometric relationship between the vehicle detection frame and the preset tripwire in real time. On the one hand, it abandons the absolute binary judgment of the geometric intersection method and performs multi-level discrimination to resist positioning jitter by accurately quantifying the overlap ratio between the vehicle detection frame and the preset tripwire, thereby suppressing false triggers caused by vehicle detection frame offset from the root. On the other hand, it gets rid of the path dependence of multi-frame trajectory tracking and uses the refined geometric relationship analysis of a single frame to achieve millisecond-level decision-making. This not only eliminates the calculation delay of trajectory accumulation and ensures real-time performance, but also avoids the risk of missed shots caused by tracking loss.
[0013] Further, determining whether the vehicle detection frame and the preset tripwire are collinear specifically includes:
[0014] Based on the vector cross product formula, determine whether the straight line containing any side line segment of the vehicle detection box is collinear with the straight line containing the preset trip line;
[0015] If they are collinear, then determine whether the projection areas of the edge segment on the X-axis and Y-axis of the rectangular coordinate system overlap with the projection areas of the preset trip line on the X-axis and Y-axis of the rectangular coordinate system, respectively.
[0016] If there is overlap, the vehicle detection frame is determined to be collinear with the preset tripwire.
[0017] Furthermore, the specific calculation process for the overlap ratio when collinear is as follows:
[0018] For the edge segment of the vehicle detection frame that is collinear with the preset trip line, calculate the overlap interval between the edge segment and the preset trip line on the X-axis and Y-axis of the rectangular coordinate system respectively.
[0019] If the overlap interval between the edge segment and the preset trip line on the X-axis of the rectangular coordinate system is 0, then the overlap ratio when collinear is equal to the ratio of the overlap interval between the edge segment and the preset trip line on the Y-axis of the rectangular coordinate system to the length of the edge segment.
[0020] If the overlap interval between the edge segment and the preset trip line on the Y-axis of the rectangular coordinate system is 0, then the overlap ratio when collinear is equal to the ratio of the overlap interval between the edge segment and the preset trip line on the X-axis of the rectangular coordinate system to the length of the edge segment.
[0021] Furthermore, when the number of actual intersection points is 0, it is determined whether the preset tripwire is completely contained within the vehicle detection frame based on the starting and ending coordinates of the preset tripwire and the boundary range of the vehicle detection frame.
[0022] If the preset tripwire is not included in the vehicle detection frame at all, the overlap ratio is 0.
[0023] If the preset tripwire is completely contained within the vehicle detection frame, then extend both ends of the preset tripwire to the boundary of the vehicle detection frame.
[0024] Determine whether the length of the extended preset tripwire is less than the length of the minimum side of the vehicle detection frame. If yes, the overlap ratio is equal to the ratio of the length of the preset tripwire to the length of the minimum side of the vehicle detection frame; otherwise, the overlap ratio is equal to the ratio of the length of the preset tripwire to the length of the extended preset tripwire.
[0025] Furthermore, when the number of actual intersections is 1, if the actual intersection is the endpoint of a preset tripwire and the other endpoint of the preset tripwire is not within the vehicle detection frame, then the overlap ratio is equal to 0.
[0026] If the actual intersection point is one end of a preset tripwire and the other end of the preset tripwire is within the vehicle detection frame, or if the actual intersection point is not the end of a preset tripwire, then the end of the preset tripwire located within the vehicle detection frame is taken as the measurement reference point. The measurement reference point is extended to intersect with the vehicle detection frame to obtain the intersection point of the extended line. The larger value between the distance from the actual intersection point to the intersection point of the extended line and the minimum side length of the vehicle detection frame is taken, and the ratio of the distance from the measurement reference point to the actual intersection point to the larger value is calculated to obtain the overlap ratio.
[0027] Furthermore, when the number of actual intersection points is 2, the distance between the two actual intersection points is calculated;
[0028] Determine whether the distance between two real intersection points is greater than or equal to the minimum side length of the vehicle detection box. If yes, the overlap ratio is 1; otherwise, the overlap ratio is equal to the ratio of the distance between the two real intersection points to the minimum side length of the vehicle detection box.
[0029] Based on the same concept, the present invention also provides a vehicle capture system, comprising:
[0030] The acquisition unit is used to acquire the vehicle detection frame;
[0031] The first judgment unit is used to determine whether the vehicle detection frame and the preset trip line are collinear;
[0032] The calculation unit is used to calculate the overlap ratio when the vehicle detection frame and the preset tripwire are collinear; and to calculate the number of actual intersection points between the vehicle detection frame and the preset tripwire when the vehicle detection frame and the preset tripwire are not collinear, and to calculate the overlap ratio under different numbers of actual intersection points.
[0033] The second judgment unit is used to determine whether to capture a vehicle based on the overlap ratio when the vehicle is collinear or the overlap ratio under different numbers of actual intersections.
[0034] Based on the same concept, the present invention also provides an electronic device, including a memory, a processor, and a computer program or instructions stored in the memory, wherein the processor executes the computer program or instructions to implement the vehicle capture method described above.
[0035] Based on the same concept, the present invention also provides a computer-readable storage medium having a computer program or instructions stored thereon, which, when executed by a processor, implements the vehicle capture method described above.
[0036] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0037] This invention analyzes the dynamic geometric relationship between the vehicle detection frame and the preset tripwire in real time. On the one hand, it abandons the absolute binary judgment of the geometric intersection method and performs multi-level discrimination to resist positioning jitter by accurately quantifying the overlap ratio between the vehicle detection frame and the preset tripwire, thereby suppressing false triggers caused by vehicle detection frame offset from the root. On the other hand, it gets rid of the path dependence of multi-frame trajectory tracking and uses the refined geometric relationship analysis of a single frame to achieve millisecond-level decision-making. This not only eliminates the calculation delay of trajectory accumulation and ensures real-time performance, but also avoids the risk of missed shots caused by tracking loss. Attached Figure Description
[0038] To more clearly illustrate the technical solution of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are only one embodiment of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0039] Figure 1 This is a flowchart of the vehicle capture method in an embodiment of the present invention;
[0040] Figure 2 This is a schematic diagram of the overlap ratio when collinear in an embodiment of the present invention; wherein, the horizontal axis is the X-axis of the image pixel coordinate system, and the unit is pixels; the vertical axis is the Y-axis of the image pixel coordinate system, and the unit is pixels;
[0041] Figure 3 This is a schematic diagram showing the overlap ratio of the preset tripwire completely contained within the vehicle detection frame in an embodiment of the present invention.
[0042] Figure 4 This is a schematic diagram of the overlapping proportions without intersections or inclusions in the embodiments of the present invention;
[0043] Figure 5This is a schematic diagram of the overlap ratio of single-point intersections in an embodiment of the present invention;
[0044] Figure 6 This is a schematic diagram showing the overlap ratio of two intersecting points in an embodiment of the present invention. Detailed Implementation
[0045] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0046] The technical solution of the present invention will be described in detail below with reference to specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments.
[0047] Example 1
[0048] In existing vehicle capture technologies, the high false trigger rate of the geometric intersection method stems from its reliance on an absolute, either-or intersection determination between the detection box and the preset trip line. This binary determination mechanism is extremely sensitive to the positioning error of the detection box: when the detection algorithm causes the visual detection box to expand or shift due to changes in lighting, target deformation, or background interference, the vehicle detection box, which was not originally crossing the line, may accidentally cover the preset trip line, thus triggering an incorrect capture. Furthermore, the geometric intersection method only captures the instantaneous geometric contact between the detection box boundary and the preset trip line, failing to quantify the degree of overlap and movement trends. This leads to the equating of brief compliance with line crossings with substantive violations, resulting in a significantly higher false capture rate at busy intersections or in scenarios with frequent lane changes.
[0049] The real-time limitations of trajectory tracking methods stem from their multi-frame dependency. To filter false detections and identify genuine intentions to cross the line, the algorithm must continuously track the trajectory of the center point of the vehicle detection box, accumulating data from multiple frames before analyzing behavioral patterns of crossing preset trip lines. This process not only introduces computational delays due to trajectory calculation and line-crossing verification, causing the capture response time to exceed the millisecond requirements of high-speed scenarios, but also introduces hidden dangers due to the instability of the tracking algorithm under target occlusion, high-speed movement, or complex road conditions. Once tracking is interrupted, even if the vehicle has indeed crossed the preset trip line, the system will still miss the capture due to the broken trajectory chain, creating a contradiction between accuracy and speed.
[0050] To address the aforementioned technical problems, this invention provides a vehicle capture method. By analyzing the spatial geometric relationship between the vehicle detection frame (rectangle) and the preset tripwire (line segment), a refined overlap ratio calculation method is constructed. On one hand, this method abandons the absolute binary judgment of the geometric intersection method and performs multi-level discrimination against positioning jitter by accurately quantifying the overlap ratio between the vehicle detection frame and the preset tripwire, thereby suppressing false triggers caused by vehicle detection frame offset from the root. On the other hand, it eliminates the path dependence of multi-frame trajectory tracking and uses the refined geometric relationship analysis of a single frame to achieve millisecond-level decision-making. This eliminates the calculation delay of trajectory accumulation, ensures real-time performance, and avoids the risk of missed captures due to tracking loss.
[0051] Figure 1 A flowchart of the vehicle capture method provided by this invention is shown. Figure 1 As shown, the vehicle capture method includes the following steps:
[0052] Step 1: Obtain the vehicle detection frame.
[0053] Scene images are acquired using an image acquisition unit and then input into the object detection model to obtain rectangular vehicle detection boxes, along with the coordinates of the corner points and center point of each box. The object detection model is trained using a deep learning model.
[0054] Step 2: Determine whether the vehicle detection frame and the preset trip line are collinear; if yes, proceed to step 3; otherwise, proceed to step 4.
[0055] In a specific embodiment of the present invention, determining whether the vehicle detection frame and the preset tripwire are collinear specifically includes:
[0056] Step 2.1: Based on the vector cross product formula, determine whether the straight line containing any side line segment of the vehicle detection box is collinear with the straight line containing the preset trip line; if so, proceed to step 2.2.
[0057] For the preset tripwire L1, let its starting coordinates be (x... s ,y s The endpoint coordinates are (x e ,y e For any side segment L2 of the vehicle detection frame, let its starting coordinates be (x1, y1) and its ending coordinates be (x2, y2). The coordinates of each corner point of the vehicle detection frame belong to the same rectangular coordinate system as the starting and ending coordinates of the preset tripwire, such as the image pixel coordinate system. If the following equation exists:
[0058] (y e -y s )×(x2-x1)=(y2-y1)×(x e -x s (1)
[0059] Then the line containing the edge segment L2 is collinear with the line containing the preset trip line L1, meaning the slopes of the two lines are the same.
[0060] Step 2.2: Determine whether the projection area of the edge segment L2 on the X-axis and Y-axis of the rectangular coordinate system overlaps with the projection area of the preset trip line L1 on the X-axis and Y-axis of the rectangular coordinate system, respectively; if so, proceed to step 2.3.
[0061] Projecting the edge segment L2 onto the X and Y axes of the Cartesian coordinate system respectively, we can obtain the projection regions of edge segment L2 onto the X and Y axes of the Cartesian coordinate system; similarly, we can obtain the projection regions of the preset tripwire L1 onto the X and Y axes of the Cartesian coordinate system. If the following inequalities are satisfied simultaneously:
[0062] max(min(x s ,x e ),min(x1,x2))≤min(max(x s ,x e ),max(x1,x2))(2)
[0063] max(min(y s ,y e ),min(y1,y2))≤min(max(y s ,y e ),max(y1,y2))(3)
[0064] If the preset tripwire overlaps with the vehicle detection frame, then the vehicle detection frame and the preset tripwire are collinear.
[0065] Step 2.3: Determine if the vehicle detection frame and the preset tripwire are collinear.
[0066] If any side line segment of the vehicle detection frame satisfies expressions (1) to (3), it is determined that the vehicle detection frame is collinear with the preset trip line (i.e., the side line segment L2 of the vehicle detection frame is collinear with the preset trip line); otherwise, it is determined that the vehicle detection frame is not collinear with the preset trip line.
[0067] To refine the determination of whether a vehicle is being captured, an overlap ratio between the vehicle detection frame and a preset tripwire is defined. The overlap ratio represents the degree of geometric overlap between the preset tripwire and the vehicle detection frame on a two-dimensional plane. Specifically, it is the ratio of the length of the overlapping portion to a selected baseline length, with a value ranging from [0,1]. The length of the overlapping portion refers to the length of the preset tripwire actually located within or on the boundary of the vehicle detection frame, and its value depends on the spatial geometric relationship between the preset tripwire and the vehicle detection frame.
[0068] Therefore, the spatial geometric positional relationship between the preset tripwire and the vehicle detection frame is different, and the calculation method for the overlap ratio is different.
[0069] The reference length is determined in several cases. If both endpoints of the preset tripwire are outside the vehicle detection frame, the minimum side length of the vehicle detection frame is used as the reference length. If neither endpoint of the preset tripwire is outside the vehicle detection frame, and the preset tripwire is parallel to a side of the vehicle detection frame, the length of that side is used as the reference length. If the preset tripwire is not parallel to any side of the vehicle detection frame, the reference length is the length between the intersection of the extension lines of the two endpoints of the preset tripwire and the boundary of the vehicle detection frame. If this length is less than the minimum side length of the vehicle detection frame, the minimum side length is used as the reference length.
[0070] Step 3: Calculate the overlap ratio when collinear, and then proceed to Step 5.
[0071] When determining that the vehicle detection frame is collinear with a preset tripwire, the edge segment L2 of the vehicle detection frame that is collinear with the preset tripwire L1 is determined. Therefore, in a specific embodiment of the present invention, the specific calculation process for the overlap ratio when collinear is as follows:
[0072] Step 3.1: Calculate the overlap between the edge segment L2 and the preset trip line L1 on the X and Y axes of the rectangular coordinate system.
[0073] After obtaining the projection regions of edge segment L2 on the X and Y axes of the rectangular coordinate system and the projection regions of the preset tripwire L1 on the X and Y axes of the rectangular coordinate system, the intersection of the projection regions of edge segment L2 on the X axis of the rectangular coordinate system and the projection regions of the preset tripwire L1 on the X axis of the rectangular coordinate system is calculated. This yields the overlapping interval [x] of edge segment L2 and the preset tripwire L1 on the X axis of the rectangular coordinate system. m ,x n Similarly, the overlap interval [y] between edge segment L2 and the preset tripwire L1 on the Y-axis of the rectangular coordinate system can be calculated. m ,y n ].
[0074] Step 3.2: Determine whether the overlap interval between edge segment L2 and the preset tripping line L1 on the X and Y axes of the rectangular coordinate system is zero. If the overlap interval between edge segment L2 and the preset tripping line L1 on the X axis of the rectangular coordinate system is [x m ,x n If the value is 0, proceed to step 3.3; if the overlap interval between the edge segment L2 and the preset tripwire L1 on the Y-axis of the rectangular coordinate system is [y m ,y n If the result is 0, proceed to step 3.4.
[0075] Step 3.3: Calculate the overlap ratio when collinear. The overlap ratio when collinear is equal to the ratio of the overlapping area of edge segment L2 and the preset tripwire L1 on the Y-axis of the rectangular coordinate system to the length of edge segment L2. That is, the overlap ratio is equal to (yn -y m The ratio of the length of line segment L2 to the length of line segment L2.
[0076] Step 3.4: Calculate the overlap ratio when collinear. The overlap ratio when collinear is equal to the ratio of the overlapping area of edge segment L2 and the preset tripwire L1 on the X-axis of the rectangular coordinate system to the length of edge segment L2, that is, the overlap ratio is equal to (x n -x m The ratio of the length of line segment L2 to the length of line segment L2.
[0077] Figure 2 This shows the overlap ratio when different edge segments of the preset tripwire and the vehicle detection frame are collinear. Figure 2 It can be seen that when the preset tripwire completely overlaps with a certain edge segment of the vehicle detection frame, the overlap ratio is 1.
[0078] Step 4: Calculate the number of actual intersections between the vehicle detection frame and the preset tripwire, and calculate the overlap ratio under different numbers of actual intersections.
[0079] The number of actual intersections between the vehicle detection frame and the preset tripwire is determined by calculating the actual intersections of each edge segment of the preset tripwire and the preset tripwire. Two actual intersections are considered as one if both their x-coordinate and y-coordinate are identical. The number of actual intersections between the vehicle detection frame and the preset tripwire is 0, 1, or 2.
[0080] When the vehicle detection frame and the preset tripwire are not collinear and the number of actual intersection points is 0, there are two geometric positional relationships between the vehicle detection frame and the preset tripwire: the preset tripwire is completely contained within the vehicle detection frame and the preset tripwire is not contained within the vehicle detection frame at all.
[0081] When the start and end coordinates of the preset tripwire are both within the vehicle detection frame, i.e., x s ,x e All in [x min ,x max ] inside and y s ,y e All in [y min ,y max ], x max x min The x-coordinates of the vehicle detection box are represented by y. max y min When indicating the maximum and minimum ordinates of vehicle detection, it is determined that the preset tripwire is completely contained within the vehicle detection frame, such as... Figure 3 As shown. When the start or end point of the preset tripwire is outside the boundary of the vehicle detection frame, it is determined that the preset tripwire is not included within the vehicle detection frame at all, as shown. Figure 4 As shown.
[0082] When the preset tripwire is not included within the vehicle detection frame, the overlap ratio is 0. When the preset tripwire is completely included within the vehicle detection frame, the overlap ratio is calculated as follows:
[0083] Extend the two ends (i.e., the start and end points) of the preset tripwire to the boundary of the vehicle detection frame;
[0084] Determine whether the length of the extended preset tripwire is less than the length of the minimum side of the vehicle detection frame. If yes, the overlap ratio is equal to the ratio of the length of the preset tripwire to the length of the minimum side of the vehicle detection frame, that is, the overlap ratio is equal to the ratio of the length of the preset tripwire to the length of the minimum side of the vehicle detection frame; if no, the overlap ratio is equal to the ratio of the length of the preset tripwire to the length of the extended preset tripwire, that is, the overlap ratio is equal to the ratio of the length of the preset tripwire to the length of the extended preset tripwire. Figure 3 The overlap ratio of fully contained areas is shown under preset tripods of different lengths.
[0085] When the number of actual intersection points is 1, the preset tripwire and the vehicle detection frame have only one actual intersection point (i.e., single-point intersection), such as... Figure 5 As shown. In a specific embodiment of the present invention, the specific calculation process for the overlap ratio when a single point intersects is as follows:
[0086] If the actual intersection point is one end of a preset tripwire and the other end of the preset tripwire is not within the vehicle detection frame, then there is no valid overlap, and the overlap ratio is equal to 0. Figure 5 The first image in the series;
[0087] If the actual intersection point is one end of the preset tripwire and the other end of the preset tripwire is within the vehicle detection frame, or if the actual intersection point is not an end of the preset tripwire (e.g. Figure 5 (Figures 2, 3, and 4 in the diagram) Then, the endpoint of the preset tripwire located within the vehicle detection frame is taken as the measurement reference point. The measurement reference point is extended to intersect with the vehicle detection frame to obtain the intersection of the extended lines. The larger value between the distance from the actual intersection point to the intersection of the extended lines and the minimum side length of the vehicle detection frame is taken, and the ratio of the distance from the measurement reference point to the actual intersection point to the larger value is calculated to obtain the overlap ratio.
[0088] When the number of actual intersections is 2, calculate the distance between the two actual intersections;
[0089] Determine if the distance between two true intersection points is greater than or equal to the minimum side length of the vehicle detection box. If yes, the overlap ratio is 1; otherwise, the overlap ratio is equal to the ratio of the distance between the two true intersection points to the minimum side length of the vehicle detection box. Figure 6 As shown.
[0090] Step 5: Determine whether to capture a vehicle based on the overlap ratio when the vehicle is collinear or the overlap ratio under different numbers of actual intersections.
[0091] If the overlap ratio is greater than the ratio threshold, the vehicle will be captured; if the overlap ratio is less than or equal to the ratio threshold, the vehicle will not be captured. In this embodiment, the ratio threshold is 0.5.
[0092] This invention decomposes the vehicle detection frame into four sides. When a preset tripwire is parallel to a certain side (the cross product of the direction vectors of the two line segments is zero), the overlap interval of the two line segments is further calculated to determine whether the vehicle detection frame and the preset tripwire are collinear, and the overlap ratio when they are collinear is calculated. When the vehicle detection frame and the preset tripwire are not collinear, the geometric spatial relationship between the vehicle detection frame and the preset tripwire is determined based on the number of actual intersection points between the edges of the preset tripwire and the vehicle detection frame. Then, the overlap ratio under different geometric spatial relationships is calculated. Through multi-level discrimination, the overlap ratio between the vehicle detection frame and the preset tripwire is accurately quantified, suppressing false triggering caused by vehicle detection frame offset from the root. This invention performs vehicle capture judgment based on a single frame of vehicle detection frame, achieving millisecond-level decision-making. It eliminates the calculation delay of trajectory accumulation, ensures real-time performance, and avoids the risk of missed capture caused by tracking loss, achieving synergistic optimization of high-precision capture and instantaneous response.
[0093] The overlap ratio calculated by this invention can be used not only for precise vehicle capture, but also for the determination of other events, such as the determination of events related to the intrusion of targets at the boundary of a specific area, and the precise determination of whether a special vehicle has passed through a preset tripwire.
[0094] Example 2
[0095] This invention also provides a vehicle capture system, which includes an acquisition unit, a first judgment unit, a calculation unit, and a second judgment unit.
[0096] The acquisition unit is used to acquire the vehicle detection frame;
[0097] The first judgment unit is used to determine whether the vehicle detection frame and the preset trip line are collinear;
[0098] The calculation unit is used to calculate the overlap ratio when the vehicle detection frame and the preset trip line are collinear; and to calculate the number of actual intersection points between the vehicle detection frame and the preset trip line when they are not collinear, and to calculate the overlap ratio under different numbers of actual intersection points.
[0099] The second judgment unit is used to determine whether to capture a vehicle based on the overlap ratio when the vehicle is collinear or the overlap ratio under different numbers of actual intersections.
[0100] In some specific embodiments of the present invention, the vehicle capture system may incorporate the features of the vehicle capture method in Embodiment 1 of the present invention, and vice versa.
[0101] Example 3
[0102] This invention also provides an electronic device, which includes a memory, a processor, and a computer program or instructions stored in the memory. The processor executes the computer program or instructions to implement the vehicle capture method of this invention.
[0103] Although not shown, the electronic device includes a processor that can perform various appropriate operations and processes based on programs and / or data stored in read-only memory (ROM) or loaded from a storage portion into random access memory (RAM). The processor can be a multi-core processor or may contain multiple processors. In some embodiments, the processor may include a general-purpose main processor and one or more specialized coprocessors, such as a central processing unit, graphics processing unit (GPU), neural network processor (NPU), digital signal processor (DSP), etc. Various programs and data required for device operation are also stored in RAM. The processor, ROM, and RAM are interconnected via a bus. Input / output (I / O) interfaces are also connected to the bus.
[0104] The processor and memory described above are used together to execute programs / instructions stored in the memory. When the program / instructions are executed by the computer, they can implement the methods, steps, or functions described in the above embodiments.
[0105] Although not shown, embodiments of the present invention also provide a computer-readable storage medium having a computer program or instructions stored thereon, which, when executed by a processor, implements the vehicle capture method of the present invention.
[0106] Readable storage media include both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient media, such as modulated data signals and carrier waves.
[0107] The above description only discloses specific embodiments of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or modifications that can be easily conceived by those skilled in the art within the scope of the technology disclosed in the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for capturing vehicle images, characterized in that, The capture method includes: Obtain the vehicle inspection frame; Determine whether the vehicle detection frame is collinear with the preset tripwire; If the vehicle detection frame is collinear with the preset tripwire, the overlap ratio when collinear is calculated. If the vehicle detection frame is not collinear with the preset trip line, then calculate the number of actual intersection points between the vehicle detection frame and the preset trip line, and calculate the overlap ratio under different numbers of actual intersection points; Whether to capture a vehicle is determined by the overlap ratio when the vehicle is collinear or the overlap ratio under different numbers of actual intersections. The specific calculation process for the overlap ratio when collinear is as follows: For the edge segment of the vehicle detection frame that is collinear with the preset trip line, calculate the overlap interval between the edge segment and the preset trip line on the X-axis and Y-axis of the rectangular coordinate system respectively. If the overlap interval between the edge segment and the preset trip line on the X-axis of the rectangular coordinate system is 0, then the overlap ratio when collinear is equal to the ratio of the overlap interval between the edge segment and the preset trip line on the Y-axis of the rectangular coordinate system to the length of the edge segment. If the overlap interval between the edge segment and the preset trip line on the Y-axis of the rectangular coordinate system is 0, then the overlap ratio when collinear is equal to the ratio of the overlap interval between the edge segment and the preset trip line on the X-axis of the rectangular coordinate system to the length of the edge segment. i. When the number of actual intersection points is 0, determine whether the preset tripwire is completely contained within the vehicle detection frame based on the starting point coordinates and ending point coordinates of the preset tripwire and the boundary range of the vehicle detection frame. If the preset tripwire is not included in the vehicle detection frame at all, the overlap ratio is 0. If the preset tripwire is completely contained within the vehicle detection frame, then extend both ends of the preset tripwire to the boundary of the vehicle detection frame. Determine whether the length of the extended preset tripwire is less than the length of the minimum side of the vehicle detection frame. If yes, the overlap ratio is equal to the ratio of the length of the preset tripwire to the length of the minimum side of the vehicle detection frame; otherwise, the overlap ratio is equal to the ratio of the length of the preset tripwire to the length of the extended preset tripwire. ii. When the number of actual intersection points is 1, if the actual intersection point is one end of a preset tripwire and the other end of the preset tripwire is not within the vehicle detection frame, then the overlap ratio is equal to 0; if the actual intersection point is one end of a preset tripwire and the other end of the preset tripwire is within the vehicle detection frame, or if the actual intersection point is not an end of a preset tripwire, then the end of the preset tripwire located within the vehicle detection frame is taken as the measurement reference point, and the measurement reference point is extended to intersect with the vehicle detection frame to obtain the extension line intersection point; the larger value between the distance from the actual intersection point to the extension line intersection point and the minimum side length of the vehicle detection frame is taken, and the ratio of the distance from the measurement reference point to the actual intersection point to the larger value is calculated to obtain the overlap ratio; iii. When the number of actual intersection points is 2, calculate the distance between the two actual intersection points; Determine whether the distance between two real intersection points is greater than or equal to the minimum side length of the vehicle detection box. If yes, the overlap ratio is 1; otherwise, the overlap ratio is equal to the ratio of the distance between the two real intersection points to the minimum side length of the vehicle detection box.
2. The vehicle capture method according to claim 1, characterized in that, Determining whether the vehicle detection frame is collinear with a preset tripwire specifically includes: Based on the vector cross product formula, determine whether the straight line containing any side line segment of the vehicle detection box is collinear with the straight line containing the preset trip line; If they are collinear, then determine whether the projection areas of the edge segment on the X-axis and Y-axis of the rectangular coordinate system overlap with the projection areas of the preset trip line on the X-axis and Y-axis of the rectangular coordinate system, respectively. If there is overlap, the vehicle detection frame is determined to be collinear with the preset tripwire.
3. A vehicle capture system, characterized in that, The image capture system includes: The acquisition unit is used to acquire the vehicle detection frame; The first judgment unit is used to determine whether the vehicle detection frame and the preset trip line are collinear; The calculation unit is used to calculate the overlap ratio when the vehicle detection frame and the preset tripwire are collinear; and to calculate the number of actual intersection points between the vehicle detection frame and the preset tripwire when the vehicle detection frame and the preset tripwire are not collinear, and to calculate the overlap ratio under different numbers of actual intersection points. The second judgment unit is used to determine whether to capture a vehicle based on the overlap ratio when collinear or the overlap ratio under different numbers of real intersections. The specific calculation process for the overlap ratio when collinear is as follows: For the edge segment of the vehicle detection frame that is collinear with the preset trip line, calculate the overlap interval between the edge segment and the preset trip line on the X-axis and Y-axis of the rectangular coordinate system respectively. If the overlap interval between the edge segment and the preset trip line on the X-axis of the rectangular coordinate system is 0, then the overlap ratio when collinear is equal to the ratio of the overlap interval between the edge segment and the preset trip line on the Y-axis of the rectangular coordinate system to the length of the edge segment. If the overlap interval between the edge segment and the preset trip line on the Y-axis of the rectangular coordinate system is 0, then the overlap ratio when collinear is equal to the ratio of the overlap interval between the edge segment and the preset trip line on the X-axis of the rectangular coordinate system to the length of the edge segment. i. When the number of actual intersection points is 0, determine whether the preset tripwire is completely contained within the vehicle detection frame based on the starting point coordinates and ending point coordinates of the preset tripwire and the boundary range of the vehicle detection frame. If the preset tripwire is not included in the vehicle detection frame at all, the overlap ratio is 0. If the preset tripwire is completely contained within the vehicle detection frame, then extend both ends of the preset tripwire to the boundary of the vehicle detection frame. Determine whether the length of the extended preset tripwire is less than the length of the minimum side of the vehicle detection frame. If yes, the overlap ratio is equal to the ratio of the length of the preset tripwire to the length of the minimum side of the vehicle detection frame; otherwise, the overlap ratio is equal to the ratio of the length of the preset tripwire to the length of the extended preset tripwire. ii. When the number of actual intersection points is 1, if the actual intersection point is one end of a preset tripwire and the other end of the preset tripwire is not within the vehicle detection frame, then the overlap ratio is equal to 0; if the actual intersection point is one end of a preset tripwire and the other end of the preset tripwire is within the vehicle detection frame, or if the actual intersection point is not an end of a preset tripwire, then the end of the preset tripwire located within the vehicle detection frame is taken as the measurement reference point, and the measurement reference point is extended to intersect with the vehicle detection frame to obtain the extension line intersection point; the larger value between the distance from the actual intersection point to the extension line intersection point and the minimum side length of the vehicle detection frame is taken, and the ratio of the distance from the measurement reference point to the actual intersection point to the larger value is calculated to obtain the overlap ratio; iii. When the number of actual intersection points is 2, calculate the distance between the two actual intersection points; Determine whether the distance between two real intersection points is greater than or equal to the minimum side length of the vehicle detection box. If yes, the overlap ratio is 1; otherwise, the overlap ratio is equal to the ratio of the distance between the two real intersection points to the minimum side length of the vehicle detection box.
4. An electronic device comprising a memory, a processor, and a computer program or instructions stored in the memory, characterized in that, The processor executes the computer program or instructions to implement the vehicle capture method as described in claim 1 or 2.
5. A computer-readable storage medium having a computer program or instructions stored thereon, characterized in that, When the computer program or instructions are executed by the processor, the vehicle capture method as described in claim 1 or 2 is implemented.