Counting method and device for target objects in field
By setting rule boxes and rule lines within the fields, and combining the YOLOv12 and Borsort algorithms for target identification and tracking, the number of target objects is dynamically counted. This solves the practical limitations and accuracy problems of target counting within fields in existing technologies, and achieves efficient and accurate target object counting.
Patent Information
- Application Number
- CN202511098884.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-06
- Publication Date
- 2025-11-21
AI Technical Summary
Existing technologies have limitations in practicality, lack of intelligence, low inspection efficiency, and poor counting accuracy when counting targets within a field. They are particularly difficult to adapt to traditional scenarios with diverse specifications and significant differences in building height, and there are also natural monitoring blind spots that affect counting accuracy.
The system uses a video capture device to acquire the current video frame within the target field. By setting rule boxes and rule lines to provide a spatial reference, it identifies target objects and adds detection boxes and IDs. It uses the YOLOv12 target detection algorithm and the Borsort target tracking algorithm to identify and track targets. By combining the cross-judgment of rule boxes and rule lines, it dynamically counts the number of target objects, achieving accurate counting without customizing the field structure.
It improves scene adaptability, reduces manual intervention, enhances automation and counting accuracy, significantly improves inspection efficiency, and solves the practical limitations and counting accuracy defects of existing technologies.
Smart Images

Figure CN120996071A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of intelligent inspection, and in particular to a method and device for counting target objects in a field. BACKGROUND
[0002] In the field of target counting, although the existing technology can realize automatic identification of the number of target objects, it needs to customize a special counting device, and the boundary between adjacent fields needs to be solid and non-transparent. The design requirements for the size of the fence, the installation height of the camera and the structure of the fence are very strict, which leads to great difficulty in adaptation in traditional scenes with various specifications and significant differences in shed height. The fixed point collection mode needs to strictly control the field of view range or configure a dedicated rule frame for each field, which has high labor cost and low intelligence level. The mode of stopping and collecting in each field seriously restricts the inspection efficiency, and the target objects at the edge of the field are easily blocked when collecting at the center of the field, which affects the counting accuracy. Therefore, the existing technology has the technical problems of practical limitations, insufficient intelligence, low inspection efficiency and counting accuracy defects when counting target objects in a field. SUMMARY
[0003] The present application provides a method and device for counting target objects in a field, which solves the technical problems of practical limitations, insufficient intelligence, low inspection efficiency and counting accuracy defects when counting target objects in a field in the prior art.
[0004] To achieve the above-mentioned purpose, the present application adopts the following technical solutions:
[0005] In a first aspect, a method for counting target objects in a field is provided, comprising: acquiring a current video frame in a target field based on a video acquisition device, the current video frame including a rule frame and a rule line set at the center position of the current video frame; identifying target objects in the video frame and adding a detection frame and an ID to each target object; determining a first tracking frame located in the rule frame and recording a first position of the first tracking frame in the current video frame, the first tracking frame being any tracking frame located in the rule frame; determining whether a second position of the first tracking frame in a first video frame is recorded, the first video frame satisfying: the first video frame is before the current video frame, the first tracking frame is located in the rule frame between the first video frame and the current video frame, and the first tracking frame is not located in the rule frame before the first video frame; if so, determining whether a line connecting the first position and the second position intersects the rule line, if the line intersects the rule line and the first position is located on a first side of the rule line and the second position is located on a second side of the rule line, then the number of target objects is accumulated; if the line intersects the rule line and the first position is located on the second side of the rule line and the second position is located on the first side of the rule line, then the number of target objects is reduced.
[0006] In a possible implementation manner of the first aspect, the target objects in the video frame are identified, and a tracking box and an ID are added for each target object, including: identifying the target objects in the field based on the video frame by using a yolov12 target detection algorithm, and outputting a detection box of the target objects; continuously tracking the identified detection boxes by using a borsort target tracking algorithm, and assigning a tracking box and a corresponding unique ID for each target object.
[0007] In a possible implementation manner of the first aspect, the current video frame in the target field is obtained, including: if the target field is a first field for the first time, video frame data before the start of the video capture device is intercepted, the number of unique IDs of all target objects in the area above the regular line in the video frame is counted, and the number of target objects in the area above the regular line is calculated by using mode calculation; the target objects in the area below the regular line in the first field are counted by using a regular box regular line counting method, and the number of target objects in the area below the regular line is obtained; and the number of target objects in the area above the regular line and the number of target objects in the area below the regular line are added to obtain the total number of target objects in the first field.
[0008] In a possible implementation manner of the first aspect, after determining whether the first tracking box is recorded at the second position in the first video frame, the method further includes: starting the video capture device to perform inspection, obtaining a second video frame after the current video frame, the second video frame being all video frames in different fields after the current video frame; implementing field switching by using a field boundary; counting the number of target objects in each field based on the second video frame by using a regular box regular line counting method and a field boundary switching algorithm; and counting the number of target objects in a tail field.
[0009] In a possible implementation manner of the first aspect, the field switching is implemented by using a field boundary, including: when the inspection reaches the field boundary, a boundary box of the field boundary is obtained based on the second video frame, and a center point of the boundary box is determined; a field switching standard is determined based on the center point of the boundary box and the regular line; if the field switching standard is met, the current field is switched to a next field, and the number of target objects in the next field is counted.
[0010] In a possible implementation manner of the first aspect, the field switching standard meets the following formula:
[0011]
[0012] wherein, y dl is a vertical coordinate of the center point of the boundary box, y img is a vertical resolution of the first video data, and θ is a switching pixel threshold.
[0013] In a possible implementation of the first aspect, the counting the number of target objects in the tail column comprises: when the tail column is detected, counting the target objects in the area above the rule line of the rule box in the tail column by using the rule line counting method of the rule box, to obtain the number of target objects in the area above the rule line, and counting the number of target objects in the area below the rule line; and adding the number of target objects in the area above the rule line to the number of target objects in the area below the rule line, to obtain the total number of target objects in the tail column.
[0014] In a possible implementation of the first aspect, after the number of target objects in the tail column is counted, the method further comprises: triggering reverse detection when the video acquisition device is returning, and counting the number of target objects in the reverse detection by using the rule line counting method of the rule box and the column boundary after the acquired video frame is preprocessed by being mirrored vertically and horizontally.
[0015] In a possible implementation of the first aspect, after the number of target objects in the reverse detection is obtained, the method further comprises: obtaining the number of target objects in the forward detection and the reverse detection for multiple times, processing the reverse detection result in reverse order, obtaining the mode of the number of target objects in the same column, and determining the final number of target objects in each column.
[0016] In a second aspect, a device for counting target objects in a column is provided, comprising a communication unit and a processing unit. The communication unit is configured to acquire a current video frame in a target column based on a video acquisition device, and the current video frame comprises a rule box and a rule line arranged at a center position of the current video frame. The processing unit is configured to identify target objects in the video frame, and add a detection box and an ID to each target object. A first tracking box located in the rule box is determined, and a first position of the first tracking box in the current video frame is recorded. The first tracking box is any tracking box located in the rule box. It is determined whether a second position of the first tracking box in a first video frame is recorded. The first video frame satisfies that the first video frame is before the current video frame, the first tracking box is located in the rule box between the first video frame and the current video frame, and the first tracking box is not located in the rule box before the first video frame. If yes, it is determined whether a line connecting the first position and the second position intersects the rule line. If the line intersects the rule line, and the first position is located on a first side of the rule line and the second position is located on a second side of the rule line, the number of target objects is added. If the line intersects the rule line, and the first position is located on the second side of the rule line and the second position is located on the first side of the rule line, the number of target objects is subtracted.
[0017] In a third aspect, the present application provides a counting device for target objects in a field, comprising: a processor and a storage medium; the storage medium comprises instructions, and the processor is configured to execute the instructions to implement the method described in the first aspect and any possible implementation manner of the first aspect. The counting device for target objects in a field can be an electronic device, or a chip in an electronic device.
[0018] In a fourth aspect, the present application provides a counting system for target objects in a field, comprising: a video acquisition device and a counting device for target objects in a field; the video acquisition device is configured to acquire a current video frame in a target field based on the video acquisition device, the current video frame comprising a regular frame and a regular line arranged at a central position of the current video frame, and the counting device for target objects in a field is configured to identify target objects in the video frame and add a detection frame and an ID to each target object; determine a first tracking frame located in the regular frame, and record a first position of the first tracking frame in the current video frame, the first tracking frame being any tracking frame located in the regular frame; determine whether a second position of the first tracking frame in a first video frame is recorded, the first video frame satisfying: the first video frame is before the current video frame, the first tracking frame is located in the regular frame between the first video frame and the current video frame, and the first tracking frame is not located in the regular frame before the first video frame; if yes, determine whether a line connecting the first position and the second position intersects the regular line, if the line intersects the regular line and the first position is located on a first side of the regular line and the second position is located on a second side of the regular line, then the number of target objects is accumulated; if the line intersects the regular line and the first position is located on the second side of the regular line and the second position is located on the first side of the regular line, then the number of target objects is reduced.
[0019] In a fifth aspect, the present application provides a computer readable storage medium, which stores instructions, and when the instructions are executed on the counting device for target objects in a field, the counting device for target objects in a field executes the method described in the first aspect and any possible implementation manner of the first aspect.
[0020] In a sixth aspect, the present application provides a computer program product comprising instructions, and when the computer program product is executed on the counting device for target objects in a field, the counting device for target objects in a field executes the method described in the first aspect and any possible implementation manner of the first aspect.
[0021] The application provides a counting method and device for target objects in a field. Based on a video acquisition device, a current video frame in a target field is acquired, a spatial reference is provided through a unified rule box and rule line, without customizing the field structure, and the scene adaptability is improved. The target objects in the video frame are identified, and a detection box and an ID are added to each target object, so that accurate positioning and unique identification of the target are realized, manual intervention is reduced, and the automation level is improved. A first tracking box located in the rule box is determined, and a first position of the first tracking box in the current video frame is recorded. It is determined whether a second position of the first tracking box in the first video frame is recorded. If yes, it is judged whether the first and second positions are connected and intersected with the rule line. If yes, the first position is on the first side and the second position is on the second side, and the number is accumulated, otherwise, the number is reduced. The number is dynamically counted through the trajectory intersection direction, so that the missing counting or repeated counting is avoided, and the counting accuracy is improved. The method does not need to customize the equipment, is suitable for various fields, reduces manual intervention, and improves the inspection efficiency and the counting accuracy. Therefore, the technical problems of practicality limitation, insufficient intelligence, low inspection efficiency and counting accuracy defects in the prior art target counting in the field are solved.
[0022] It should be understood that the description of technical features, technical solutions, beneficial effects or similar language in the present application does not imply that all features and advantages can be achieved in any single embodiment. On the contrary, it can be understood that the description of a feature or beneficial effect means that the specific technical feature, technical solution or beneficial effect is included in at least one embodiment. Therefore, the description of technical features, technical solutions or beneficial effects in the specification does not necessarily refer to the same embodiment. Further, the technical features, technical solutions and beneficial effects described in the embodiments can be combined in any appropriate manner. Those skilled in the art will understand that the embodiments can be implemented without one or more specific technical features, technical solutions or beneficial effects of the specific embodiments. In other embodiments, additional technical features and beneficial effects can be identified in specific embodiments that do not embody all embodiments. BRIEF DESCRIPTION OF DRAWINGS
[0023] Figure 1 A system architecture diagram of a counting system for target objects in a field is provided for the embodiments of the present application.
[0024] Figure 2 A flowchart of a counting method for target objects in a field is provided for the embodiments of the present application.
[0025] Figure 3 A structure diagram of a rule box and a rule line is provided for the embodiments of the present application.
[0026] Figure 4 A flowchart of another counting method for target objects in a field is provided for the embodiments of the present application.
[0027] Figure 5 A flowchart of another column-in-target object counting method provided by an embodiment of the present application is shown in FIG. 6;
[0028] Figure 6 A flowchart of another column-in-target object counting method provided by an embodiment of the present application is shown in FIG. 6;
[0029] Figure 7 A column switching screen provided by an embodiment of the present application is shown in FIG. 7;
[0030] Figure 8 A column switching screen provided by an embodiment of the present application is shown in FIG. 7;
[0031] Figure 9 A column switching screen provided by an embodiment of the present application is shown in FIG. 7;
[0032] Figure 10 A column switching screen provided by an embodiment of the present application is shown in FIG. 7;
[0033] Figure 11 A column switching screen provided by an embodiment of the present application is shown in FIG. 7;
[0034] Figure 12 A column switching screen provided by an embodiment of the present application is shown in FIG. 7;
[0035] Figure 13 A flowchart of another column-in-target object counting method provided by an embodiment of the present application is shown in FIG. 6;
[0036] Figure 14 A structure diagram of a column-in-target object counting device provided by an embodiment of the present application is shown in FIG. 8;
[0037] Figure 15 A hardware structure diagram of a column-in-target object counting device provided by an embodiment of the present application is shown in FIG. 9. DETAILED DESCRIPTION
[0038] In the description of the present application, unless otherwise specified, " / " means "or", for example, A / B can mean A or B. "And / or" in this text is only a description of the relationship between the associated objects, which means that there can be three relationships, for example, A and / or B, which can mean that A exists alone, A and B exist together, and B exists alone. In addition, "at least one" means one or more, and "multiple" means two or more. "First", "second", and the like do not limit the quantity and execution order, and "first", "second", and the like do not necessarily mean different.
[0039] It should be noted that the terms "exemplary" and "for example" are used herein to mean "an example of" or "an example, only. Any embodiment or design solution described herein as "exemplary" or "for example" should not be construed as being more advantageous or superior than other embodiments or design solutions. Rather, the use of terms such as "exemplary" or "for example" is intended to present concepts in a particular manner.
[0040] The field-in-target object counting method provided by the embodiments of the present application can be applied to a system as shown in the figure, which comprises a video acquisition device 101 and a field-in-target object counting device 102. Figure 1
[0041] The video acquisition device 101 is configured to acquire a current video frame in a target field based on a video acquisition device, the current video frame comprising a regular box and a regular line arranged at a central position of the current video frame. The field-in-target object counting device 102 is configured to identify target objects in the video frame and add a tracking box and an ID to each target object; determine a first tracking box located in the regular box and record a first position of the first tracking box in the current video frame, the first tracking box being any tracking box located in the regular box; determine whether a second position of the first tracking box in a first video frame is recorded, the first video frame satisfying: the first video frame is before the current video frame, the first tracking box is located in the regular box between the first video frame and the current video frame, and the first tracking box is not located in the regular box before the first video frame; if yes, determine whether a line connecting the first position and the second position intersects the regular line, if the line intersects the regular line and the first position is located on a first side of the regular line and the second position is located on a second side of the regular line, then the number of target objects is accumulated; if the line intersects the regular line and the first position is located on the second side of the regular line and the second position is located on the first side of the regular line, then the number of target objects is reduced.
[0042] To solve the technical problems of practicality limitation, insufficient intelligence, low inspection efficiency and counting accuracy defects in the prior art of counting target objects in a column, the embodiment of the present application provides a counting method for target objects in a column. Based on a video acquisition device, a current video frame in a target column is obtained. The current video frame includes a regular box and a regular line set at the center position of the current video frame. Target objects in the video frame are identified, and a detection box and an ID are added to each target object. A first tracking box located in the regular box is determined, and a first position of the first tracking box in the current video frame is recorded. The first tracking box is any tracking box located in the regular box. It is determined whether the second position of the first tracking box in the first video frame is recorded. The first video frame satisfies: the first video frame is before the current video frame, the first tracking box is located in the regular box between the first video frame and the current video frame, and the first tracking box is not located in the regular box before the first video frame. If yes, it is determined whether the line connecting the first position and the second position intersects the regular line. If the line intersects the regular line and the first position is located on the first side of the regular line and the second position is located on the second side of the regular line, the number of target objects is accumulated. If the line intersects the regular line and the first position is located on the second side of the regular line and the second position is located on the first side of the regular line, the number of target objects is reduced. Based on this, the technical problems of practicality limitation, insufficient intelligence, low inspection efficiency and counting accuracy defects in the prior art of counting target objects in a column are solved.
[0043] Figure 2 The flowchart of the counting method for target objects in a column provided by the embodiment of the present application is shown in Figure 2 , which includes:
[0044] Step 201, the counting device for target objects in a column obtains a current video frame in a target column based on a video acquisition device.
[0045] Among them, the current video frame is an image frame collected by the video acquisition device in a video stream, which contains target objects in the target column and a regular box and a regular line set at the center position of the current video frame.
[0046] In the embodiment of the present application, the fisheye camera moves with the inspection robot installed above the column between columns to obtain the video stream of the target column in a continuous acquisition manner, and extracts the current video frame therefrom. As shown in Figure 3 , the center position of the current video frame is pre-set with a regular box and a regular line: the regular box is a limited area for screening target objects entering the counting judgment range, reducing the interference of image edges due to insufficient tracking accuracy on counting; the regular line is a horizontal reference line as a basis for judging the moving direction of the target object.
[0047] As an example, in the large pen pig inventory scene, the track robot carries a fisheye camera to move along the track on the roof of the pig house. When entering a certain finishing pen, the camera collects the video stream of the pen in real time. In the current video frame extracted, there is a rectangular regular box and a horizontal regular line in the center position. The regular box covers the middle area of the pen; the regular line divides the regular box into upper and lower parts.
[0048] Based on the above steps, by continuously acquiring the current video frame containing the regular box and the regular line, a stable image basis is provided for subsequent target object recognition, tracking and direction judgment. This method does not require customized equipment or pen structure, and is suitable for different specifications of pen scenes. At the same time, the continuous acquisition mode avoids waiting and staying, significantly improves the inspection efficiency, and lays a real-time and universal foundation for accurate counting.
[0049] Step 202, the counting device of the target object in the pen identifies the target object in the video frame and adds a tracking box and an ID for each target object.
[0050] Among them, the tracking box is a bounding box surrounding the target object, used to locate the position of the target in the video frame; the ID is a unique identifier assigned to each target object, used to distinguish and track the same object in continuous video frames.
[0051] In the embodiments of the present application, the process of identifying the target object and adding the detection box and the ID is divided into two core links: first, all target objects are identified from the current video frame by target detection technology, and detection boxes surrounding each object are generated; then the motion trajectory of the same object in the continuous video frame is associated by target tracking technology, and a tracking box and a corresponding unique ID are assigned.
[0052] As an example, in the large pen pig inventory scene, the video frame contains multiple moving pigs. The counting device of the target object in the pen first identifies the contour of each pig by target detection technology, generates a corresponding rectangular tracking box, and frames the overall range of the pig; then, by tracking technology, each pig is assigned a unique ID, such as ID001, ID002.
[0053] Based on the above steps, by automatically identifying the target object and assigning the tracking box and the ID, accurate positioning and continuous tracking of dynamic targets in the pen are realized, providing reliable basic data for subsequent counting logic based on position changes. This process eliminates the dependence on manual marking and improves the degree of automation of counting.
[0054] Step 203, the counting device of the target object in the pen determines the first tracking box located in the regular box and records the first position of the first tracking box in the current video frame.
[0055] The first tracking frame is any tracking frame located in the rule frame, and the first merely refers to the order and does not refer to the order.
[0056] In the embodiment of the present application, the counting device of the target object in the field first traverses all the tracking frames of the target objects in the current video frame, and determines whether each tracking frame is in the rule frame. The determination standard is whether the center point of the tracking frame falls in the rule frame, so as to ensure that the selected target object is in the middle region of the video frame, which is more stable in imaging and has higher tracking accuracy.
[0057] It should be noted that the tracking frame determined to be located in the rule frame is determined as the first tracking frame, and there can be multiple first tracking frames in the same video frame, which all need to be processed separately. The first position of the first tracking frame is recorded, and the pixel coordinates of the center point of the tracking frame are used as the position identifier. The center point is selected instead of the edge coordinates of the tracking frame, so as to reduce the influence of the size change of the tracking frame caused by the posture change (such as curling and stretching) of the target object on the position recording, and ensure the stability of the position data.
[0058] As an example, in the pig only inventory scene, the central rule frame of the current video frame is a rectangle with a length of 800 pixels and a width of 200 pixels, and the resolution of the video frame is 820*600 pixels. Taking the lower left corner of the rule frame as the coordinate origin, after traversing all the pig tracking frames, the center points (280, 150) and (620, 170) of the pig tracking frames with IDs 028 and 070 fall in the rule frame, and both of them are the first tracking frame.
[0059] Based on the above steps, the target object is selected by the rule frame, which effectively excludes the target object at the edge of the video frame due to imaging blur and low tracking accuracy, and improves the reliability of the counting determination.
[0060] Step 204, the counting device of the target object in the field determines whether the second position of the first tracking frame in the first video frame is recorded.
[0061] The first video frame satisfies that the first video frame is before the current video frame, the first tracking frame is located in the rule frame between the first video frame and the current video frame, and the first tracking frame is not located in the rule frame before the first video frame. If yes, it is determined whether the line connecting the first position and the second position intersects with the rule line, if the line intersects with the rule line and the first position is located on the first side of the rule line and the second position is located on the second side of the rule line, the number of target objects is accumulated; if the line intersects with the rule line and the first position is located on the second side of the rule line and the second position is located on the first side of the rule line, the number of target objects is reduced.
[0062] In the embodiment of the present application, the first video frame data is associated with the ID of the target object, and it is queried whether the first tracking frame and the second position record exist. The determination of the first video frame needs to meet three conditions: first, it is earlier than the current video frame in time; second, the first tracking frame is always located within the regular frame without leaving in all frames from the first video frame to the current video frame; third, the tracking frame has never entered the regular frame before the first video frame, that is, the first video frame is the first time when the tracking frame enters the regular frame. This determination process is realized by traversing the historical tracking record of the ID, filtering the frames meeting the conditions by time stamp sorting, and checking whether the position of the tracking frame in each frame is continuously within the regular frame. When it is confirmed that the first video frame and the second position exist, the coordinates of the first position (current frame) and the second position (first video frame) are extracted, and it is determined whether the coordinate line intersects with the regular line: whether there is an intersection point between the coordinate line and the regular line is determined through geometric calculation. If there is an intersection point, the position relationship is further analyzed: if the first position is located on the first side of the regular line, i.e., above, and the second position is located on the second side of the regular line, i.e., below, it indicates that the target object crosses from the second side to the first side, and at this time, the number of target objects is accumulated; if the first position is located on the second side and the second position is located on the first side, it indicates that the target object returns from the first side to the second side, and at this time, the number of target objects is decremented.
[0063] It should be noted that after the counting of the current ID is completed, the judgment of the next ID is entered; for the case where the first video frame and the second position are not recorded, such as the tracking frame is first entering the regular frame, a continuous staying track has not been formed, or the tracking frame has left the regular frame before, the counting adjustment is not triggered, and only the current position is recorded, waiting for further judgment in the subsequent frame.
[0064] As an example, in the pig only inventory scene of a large column, the tracking frame of a pig only enters the regular frame for the first time in the first video frame, the second position coordinate of which is (300, 50), the regular line is a horizontal straight line y = 100, the first side is 100 < y < 200, and the second side is 0 < y < 100. In the current video frame, the first position coordinate of the tracking frame is (310, 150), and it is always located within the regular frame from the first video frame to the current frame. The counting device calculates the line connecting the two points, finds that it crosses the regular line (y = 100), and the first position (310, 150) is located on the first side and the second position (300, 50) is located on the second side, so the accumulation operation is triggered, and the number of pigs in the column is increased by 1.
[0065] Based on the above steps, through the analysis of the continuous track of the target object after entering the regular frame and the judgment of the crossing direction of the regular line, the accurate capture of the moving trend of the target object is realized. This dynamic counting logic can not only adapt to the real-time motion of the target object, but also reduce the tracking error in the edge area through the spatial constraint of the regular frame and the regular line.
[0066] Based on the above technical solution, the target object counting method within a field provided in this application acquires the current video frame within the target field using a video acquisition device. A unified rule box and rule lines provide a spatial reference, eliminating the need for customized field structures and improving scene adaptability. The method identifies target objects within the video frame and adds a tracking box and ID to each target object, achieving precise target positioning and unique identification, reducing manual intervention and improving automation. It determines the first tracking box located within the rule box and records its first position in the current video frame. It then determines whether the second position of the first tracking box in the first video frame is recorded. If so, it checks whether the line connecting the first and second positions intersects with the rule lines. If they intersect and the first position is on the first side and the second on the second side, the number is added; otherwise, it is subtracted. The number is dynamically counted through the direction of trajectory intersection, avoiding omissions or duplicate counts and improving counting accuracy. This method requires no customized equipment, adapts to diverse field positions, reduces manual intervention, and improves inspection efficiency and counting accuracy. Therefore, it solves the technical problems of practical limitations, insufficient intelligence, low inspection efficiency, and counting accuracy defects in existing target counting methods within fields.
[0067] In one possible implementation, combining the above... Figure 2 ,like Figure 4 As shown, the process of identifying target objects within video frames and adding detection boxes and IDs to each target object in step 202 above can be specifically implemented through the following steps 401-402:
[0068] Step 401: The counting device for target objects within the field identifies target objects within the field based on the video frame using the YOLOv12 target detection algorithm and outputs the detection box of the target object.
[0069] Among them, the YOLOv12 object detection algorithm is a high-efficiency deep learning object detection model. It is an advanced version of the YOLO series of algorithms, characterized by strong real-time performance and high detection accuracy. It can quickly identify and locate multiple target objects from the current video frame.
[0070] In this embodiment, the current video frame acquired by the video acquisition device is input into the YOLOv12 target detection algorithm. The algorithm first preprocesses the video frame to make it meet the model input requirements; then, it extracts the target features in the video frame through the model's feature extraction network; and then it analyzes the features through the detection head to identify all target objects in the frame.
[0071] Based on the above steps, the YOLOv12 object detection algorithm, with its efficient feature extraction and object localization capabilities, provides accurate detection box outputs for the identification of target objects within the field, solving the problem of low recognition accuracy of traditional recognition methods in complex dynamic scenes.
[0072] Step 402: The counting device for target objects within the column continuously tracks the identified detection boxes using the borsort target tracking algorithm, and assigns the tracking box and a corresponding unique ID to each target object.
[0073] Among them, the borsort target tracking algorithm is an algorithm for multi-target tracking in video sequences. It can continuously track target objects by associating detection boxes in consecutive video frames, and has good stability, especially when dealing with target occlusion, brief disappearance and other scenarios. The unique ID is a unique identifier assigned to each target object to uniquely identify the same target in the entire video stream and ensure the consistency of tracking across frames.
[0074] In this embodiment, the detection box is the output object box of YOLOv12. The target tracking algorithm confirms the tracking box with ID data based on the detection box. After obtaining the target tracking box of the current video frame through the target detection algorithm, the tracking box information is input into the borsort target tracking algorithm. The tracking boxes in consecutive video frames are correlated to determine whether the tracking boxes in different frames belong to the same target object.
[0075] Based on the above steps, through continuous tracking and unique ID allocation using the borsort target tracking algorithm, consistent management of target object identities across video frames is achieved. This process effectively solves the identity confusion problem in scenarios such as multi-target occlusion and temporary disappearance.
[0076] In one possible implementation, combining the above... Figure 2 ,like Figure 5 As shown, the process of identifying the current video frame in the target field in step 201 above can be specifically implemented through the following steps 501-503:
[0077] Step 501: The counting device for target objects in the column determines that if the target column is the first column of the first inspection, it captures the video frame data before the video acquisition device is started, and calculates the number of target objects in the area above the rule line by counting the number of unique IDs of all target objects in the area above the rule line in the video frame and using the mode.
[0078] Among them, the first column of the first inspection refers to the first target column encountered by the inspection robot when performing its first inspection task; the video frame data before the video acquisition device starts refers to the first column video stream segment that has been pre-acquired and stored by the video acquisition device before the inspection robot starts moving, which usually contains multiple consecutive frames of images; the area above the rule line refers to the area above the rule line in the current video frame, which cannot be covered by subsequent dynamic counting logic due to the robot's initial position limitation.
[0079] In the embodiment of the present application, whether the current target column is the first column of the first inspection is determined by the initialization parameter of the inspection task. If it is determined to be yes, since the initial position of the inspection robot is usually located at the center of the first column, the field of view of the video acquisition device carried by the inspection robot has covered the complete area of the first column before starting, at this time, the video frame data pre-stored before starting is intercepted. For the intercepted multi-frame video data, the mode number calculation is used to determine the number of target objects in the upper half area of the first column.
[0080] It should be noted that if the target column is not the first column, the dynamic counting method of the rule line of the rule box is used for counting.
[0081] As an example, in the scene of counting pigs in a large column pig pen, before the inspection robot starts, the fisheye camera has pre-acquired 20 frames of first column video. The rule line is a horizontal straight line (y = 100), and the area above the rule line is the area of 100<y<200. The 20 frames of data are counted one by one, among the 20 frames, 18 frames are counted to 9 IDs, and 2 frames are counted to 8 IDs, the mode number is 9, so the number of pigs in the area above the rule line is determined to be 9.
[0082] Based on the above steps, by processing the special scene of the first inspection of the first column, the problem of the counting blind area of the rule box caused by the initial position of the robot is solved.
[0083] Step 502, the counting device of the target object in the column uses the rule box rule line counting method to count the target objects in the area below the rule line in the first column, and obtains the number of target objects in the area below the rule line.
[0084] In the embodiment of the present application, for the first inspection of the first column, the counting of the area below the rule line completely follows the rule box rule line counting process of steps 201 to 204.
[0085] As an example, in the scene of counting pigs in the first column, the rule line is a horizontal straight line of y = 100 pixels, and the area below is the area of 0<y<200. After the inspection robot starts to move, real-time video frames are collected: the pig with ID 103 enters the area below the rule line in the rule box from outside the rule box, the first entering position is (300, 50), and then moves to (310, 180), the connecting line of the trajectory intersects with the rule line, triggering the cumulative counting; finally, the area below accumulates 8 times and decreases 1 time, and the number of pigs in the lower half area is 7.
[0086] Step 503, the counting device of the target object in the column adds the number of target objects in the area above the rule line to the number of target objects in the area below the rule line, and obtains the total number of target objects in the first column.
[0087] In this embodiment, after the counting device completes the quantity statistics of the area above and below the rule line, it extracts the counting results of the two areas from the storage module, obtains the total number of target objects in the first column by summing them, and stores the results in the counting database of the corresponding column. At the same time, it associates the inspection timestamp and the first inspection identifier to provide basic data for comparison of subsequent reverse inspections or multiple rounds of inspections.
[0088] Based on the above technical solution, the area below the rule line of the first column is dynamically counted by the rule box rule line counting method. This forms a complementary first column counting scheme with the static mode statistics of the area above the rule line, which solves the problem of the counting blind spot caused by the robot's initial position in the first column.
[0089] In one possible implementation, combining Figure 2 ,like Figure 6 As shown, after step 204 above, the counting device for target objects within a field can inspect all target objects within a target field based on the rule box rule line counting method. This process can be specifically implemented through the following steps 601-606:
[0090] Step 601: The video acquisition device begins its inspection and acquires the second video frame following the current video frame.
[0091] The second video frame is all the video frames in different columns after the current video frame, covering all video stream segments from the second column after the first column to the last column.
[0092] In this embodiment, after the counting device for the target objects in the column completes the initial counting process of the first column, it controls the inspection robot to continue moving along the preset path. The video acquisition device starts the continuous acquisition mode synchronously with the robot to acquire the video stream of the subsequent columns in real time and extract the second video frame from it frame by frame.
[0093] Based on the above steps, by continuously acquiring the second video frame, full column video coverage from the first column to the last column is achieved, which gets rid of the limitation of stopping and collecting data column by column in the traditional counting scheme and significantly improves the inspection efficiency.
[0094] Step 602: The counting device for target objects within a field switches fields using a field boundary switching algorithm.
[0095] The field switching process includes: when the inspection reaches the field boundary, the bounding box of the field boundary is obtained based on the second video frame, and the center point of the bounding box is determined; the field switching criteria are determined based on the center point of the bounding box and the rule line; if the field switching criteria are met, the field is switched from the current field to the next field, and the number of target objects in the next field is counted.
[0096] In the embodiments of this application, such as Figures 7 to 12As shown, when the inspection robot approaches the boundary of the pen, the second video frame is analyzed by the yolov12 target detection algorithm to identify the contour of the pen boundary and generate a boundary box. The center point coordinates of the boundary box are calculated based on the pixel coordinates of the boundary box. The vertical coordinate of the center point of the boundary box is determined with the vertical resolution of the video frame. If the switching standard is met, the counting device stops counting the current pen, attributes the subsequent video frames to the next pen, initializes the counting parameters of the next pen, and starts independent counting of the next pen.
[0097] Alternatively, the pen switching standard satisfies the following formula:
[0098]
[0099] wherein y dl is the vertical coordinate of the center point of the boundary box, y img is the vertical resolution of the first video data, and θ is the switching pixel threshold.
[0100] It should be noted that in the process of determining the threshold value based on the center point of the boundary box and the rule line, when the switching standard is met, the target object in the specific area near the boundary in the current pen cannot be completely covered by the rule box because the inspection robot has started to enter the next pen. Therefore, after the pen switching, the number of target object IDs in the boundary area that do not trigger the rule line crossing is counted as a supplement to the current pen count to avoid the problem of missing counting caused by switching state triggering and to ensure the integrity of each pen count.
[0101] As an example, in the large pig only inventory scene, the boundary of adjacent pens is a concrete fence. When the inspection robot moves near the boundary, the boundary box is identified in the second video frame by yolov12, the vertical coordinate of the center point of the boundary box y dl = 120. Half of the vertical resolution of the first video data, i.e., the vertical coordinate of the rule line y_img / 2 = 100, and the switching threshold θ = 30. At this time, |120-100| = 20 < 30, which meets the switching standard, and the counting device switches from the current pen to the next pen.
[0102] Based on the above steps, the switching standard is automatically identified and quantified based on the pen boundary, realizing seamless and accurate switching between adjacent pens without the need for manual pre-labeling of pen boundaries or setting of switching points, significantly improving the automation and intelligence level of the counting process.
[0103] Step 603, the counting device of the target object in the pen uses the rule line counting method of the rule box and the pen boundary switching algorithm based on the second video frame to count the number of target objects in each pen.
[0104] In the embodiment of the present application, after the second video frame is acquired, the rule box rule line counting method and the field boundary switching algorithm are started synchronously: the target is identified by yolov12 to generate a detection box, borsort is used to assign a unique ID to track the trajectory, the first tracking box in the rule box is screened, the current and first entering position of the rule box is recorded, and the current field quantity is accumulated or decreased according to the intersection direction of the trajectory and the rule line; at the same time, the boundary switching algorithm monitors the boundary box, and whether the next field is entered is judged according to the position relationship between the center point and the rule line, if yes, the last column result is determined and the next column counting parameter is initialized. The whole video acquisition is continuous with the robot moving, without stopping, and dynamic statistics is realized.
[0105] It should be noted that the parameters of the rule box and the rule line remain the same in all fields, ensuring that the counting standard is unified; unlike the first field, the subsequent fields do not need to rely on the pre-acquisition video frames before starting, but can complete the counting through the second video frame in the inspection process.
[0106] Based on the above steps, the combination of the rule box rule line counting method and the field boundary switching algorithm realizes the automatic and independent statistics of the target objects in each field. The continuous video acquisition mode avoids stopping by column, significantly improving the inspection efficiency; the unified counting standard and dynamic trajectory analysis reduce the counting deviation caused by edge occlusion and cross-column movement, improving the accuracy; without manual intervention in field switching and parameter configuration, the adaptation threshold of the scene is reduced, effectively solving the problems of practicality limitation and low efficiency in the traditional counting method.
[0107] Step 604, the counting device of the target objects in the field counts the number of target objects in the last column.
[0108] The process of counting the number of target objects in the last column includes: when the last column is inspected, the rule box rule line counting method is used to count the target objects in the area above the rule line in the last column, and the number of target objects in the area above the rule line is obtained, and the number of target objects in the area below the rule line is also counted; the number of target objects in the area above the rule line and the number of target objects in the area below the rule line are added to obtain the total number of target objects in the last column.
[0109] In the embodiment of the present application, the last column counting adopts a similar partition logic as the first column, the number of target objects crossing the rule line in the area above the rule line is dynamically counted by the rule box rule line counting method, the continuous video frames before the robot leaves are intercepted in the area below the rule line, the number of unique IDs of the target objects is counted and the result is calculated by the mode, and the total number of the last column is obtained by adding the two after removing the duplicates.
[0110] Based on the above steps, by targeted processing of the edge blind area of the tail column, combined with dynamic counting and static mode statistics, the integrity and accuracy of the number of target objects in the tail column are ensured. The method echoes the processing logic of the head column, forming a closed-loop counting of the entire inspection path, avoiding the counting deviation caused by the position limitation of the starting point and the ending point, and improving the consistency and reliability of the entire column counting scheme.
[0111] Step 605, the video acquisition device triggers reverse inspection when returning, and the number of target objects in reverse inspection is obtained by using the rule box and rule line counting method and column boundary switching algorithm after the collected video frames are preprocessed by mirroring up and down.
[0112] Among them, the reverse inspection refers to the second inspection during the return process from the tail column to the head column after the inspection robot completes the forward inspection from the head column to the tail column.
[0113] In the embodiments of the present application, when the robot reaches the tail column, the reverse inspection mechanism is triggered, and the video acquisition device returns along the original path with the robot, and real-time video stream from the tail column to the head column is collected. Since the up and down directions of the video frames are opposite during reverse movement, each video frame is preprocessed by mirroring up and down, and the video frame is vertically flipped by image flipping, so that the relative positions of the rule box and the rule line remain consistent with the forward inspection, ensuring the compatibility of the counting logic.
[0114] It should be noted that the up and down mirroring preprocessing only adjusts the direction of the video frame, without changing the actual relative relationship of the target object motion track; the column order of the reverse inspection is opposite to that of the forward inspection, and therefore the number of target objects counted needs to be processed in reverse order according to the column number, so as to correspond to the column order of the forward inspection.
[0115] Based on the above steps, the reverse inspection realizes compatibility with the forward counting logic through up and down mirroring preprocessing, reuses the existing algorithm to reduce system complexity; the second inspection provides independent counting data, which can be compared and verified with the forward result to reduce the counting deviation of single inspection; unified parameter setting ensures the comparability of the two times of data, significantly improving the reliability and accuracy of counting.
[0116] Step 606, the counting device of the target object in the column obtains the number of target objects in multiple forward inspections and reverse inspections, processes the reverse inspection result in reverse order, calculates the mode of the number of target objects in the same column, and determines the final number of target objects in each column.
[0117] In the embodiment of the present application, first, the original data of multiple forward and reverse patrols is summarized, the forward patrol data records the number of each column in the order of the first column to the last column; the reverse patrol data records the number of each column in the order of the last column to the first column, which needs to be adjusted to the order of the first column to the last column through reverse processing to ensure consistency with the column order of the forward patrol; then the mode of all data of each column is calculated to determine the final target object quantity of each column.
[0118] It should be noted that the interval time of multiple patrols needs to be reasonably set to avoid high data correlation caused by short-term movement of target objects; the mode calculation is suitable for scenarios with small data fluctuations, and if the data dispersion of a column is large, an abnormality reminder is triggered and re-patrol verification is required.
[0119] As an example, the multiple patrol data of a column is 10, 10, 11, 10, 10, 10, among which "10" appears 5 times, which is the mode, so the final quantity of the column is determined to be 10.
[0120] Based on the above steps, through the fusion of multiple forward and reverse patrol data and the mode statistics, random deviations caused by shielding, tracking errors, and environmental interference in single patrol can be effectively offset, which can significantly improve the stability and reliability of the counting result.
[0121] Based on the above technical solution, the second video frame of each column after the first column is continuously acquired, and the column boundary switching algorithm based on the center point of the bounding box and the regular line is used to realize continuous patrol and automatic switching of columns without stopping, to break the dependence on customized equipment and manual intervention, and to adapt to various column scenarios; the reuse of the regular box and regular line counting method and the switching algorithm completes independent counting of each column under a unified standard, reduces errors caused by edge shielding, and improves logical consistency; the partition counting strategy is used for the last column to solve the problem of visual blind area at the end of the patrol, ensuring complete counting of the entire path; through the up-down mirror preprocessing of the video frame during reverse patrol, the forward counting logic is reused to realize secondary verification without reducing efficiency while increasing data redundancy; the mode of the multiple forward and reverse results is taken after being aligned in reverse order, and random errors are filtered using statistical characteristics, further improving the counting stability and accuracy. Therefore, the above technical solutions collectively realize efficient, accurate, and intelligent column counting, significantly improving the practicality and reliability of the scheme.
[0122] Figure 13 The flowchart of another column target object counting method provided by the embodiment of the present application is as follows: Figure 13As shown, the flow realizes accurate counting relying on the field coverage capability of the fisheye camera. When the target object enters the field range of the fisheye camera, the corresponding field entry state is entered, the counting device of the target object in the field starts the target detection and tracking program, and the regular frame rule line counting method is used to start counting the number of target objects. As the target object moves to the center of the field and reaches the center position, the corresponding field center state is reached, and the counting technology of the target object is continued. When the target object leaves the field area, the corresponding field exit state is entered, and the field switching algorithm is triggered to switch the field to start the next field target object counting.
[0123] The above describes the scheme of the embodiments of the present application mainly from the perspective of device implementation. It can be understood that each device, for example, the counting device of the target object in the field, includes at least one of the corresponding hardware structure and software module for implementing each function. Those skilled in the art should easily realize that, in combination with the units and algorithm steps of each example described in the embodiments disclosed herein, the present application can be realized in the form of hardware or a combination of hardware and computer software. Whether a certain function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical scheme. Professional technicians can use different methods for each specific application to implement the described functions, but such implementation should not be considered beyond the scope of the present application.
[0124] The embodiments of the present application can divide the functional units of the counting device of the target object in the field according to the above method examples. For example, each functional unit can be divided according to each function, or two or more functions can be integrated in one processing unit. The integrated unit can be realized in the form of hardware or software functional unit. It should be noted that the division of units in the embodiments of the present application is illustrative, and is only a logical functional division. Actual implementation can have another division method.
[0125] In the case of using integrated units, Figure 14 A possible structure schematic diagram of the counting device of the target object in the field (denoted as counting device of the target object in the field 140) involved in the above embodiments is shown. The counting device of the target object in the field 140 includes a processing unit 1401 and a communication unit 1402, and can also include a storage unit 1403. Figure 14 The structure schematic diagram shown can be used to illustrate the structure of the counting device of the target object in the field involved in the above embodiments.
[0126] When Figure 14The shown structural schematic is used to show the structure of the counting device of the target object in the field in the above-mentioned embodiment. The processing unit 1401 is used to control and manage the action of the counting device of the target object in the field. The communication unit 1402 is used for the counting device of the target object in the field to communicate with other devices. The storage unit 1403 is used to store the program code and data of the counting device of the target object in the field.
[0127] For example, the communication unit 1402 is used to acquire a current video frame in the target field based on a video acquisition device. The current video frame includes a regular box and a regular line arranged at the center position of the current video frame.
[0128] The processing unit 1401 is used to identify the target object in the video frame and add a tracking box and an ID for each target object. A first tracking box located in the regular box is determined, and a first position of the first tracking box in the current video frame is recorded. The first tracking box is any tracking box located in the regular box. It is determined whether a second position of the first tracking box in a first video frame is recorded. The first video frame satisfies that the first video frame is before the current video frame, the first tracking box is located in the regular box between the first video frame and the current video frame, and the first tracking box is not located in the regular box before the first video frame. If yes, it is determined whether a line connecting the first position and the second position intersects the regular line. If the line intersects the regular line and the first position is located on a first side of the regular line and the second position is located on a second side of the regular line, the number of target objects is accumulated. If the line intersects the regular line and the first position is located on the second side of the regular line and the second position is located on the first side of the regular line, the number of target objects is reduced.
[0129] In a possible implementation, the processing unit 1401 is further used to identify the target object in the video frame and add a tracking box and an ID for each target object, including: identifying the target object in the field based on the video frame by using a yolov12 target detection algorithm, and outputting a detection box of the target object; continuously tracking the identified detection box by using a borsort target tracking algorithm, and assigning a tracking box and a corresponding unique ID to each target object.
[0130] In a possible implementation, the processing unit 1401 is further used to acquire a current video frame in the target field, including: judging whether the target field is a first field for first inspection, intercepting video frame data before the video acquisition device is started, counting the number of unique IDs of all target objects in the region above the regular line in the video frame, and calculating the number of target objects in the region above the regular line by using mode calculation; counting the target objects in the region below the regular line in the first field by using a regular box and regular line counting method, and obtaining the number of target objects in the region below the regular line; and adding the number of target objects in the region above the regular line and the number of target objects in the region below the regular line to obtain the total number of target objects in the first field.
[0131] In a possible implementation, the processing unit 1401 is further configured to, after determining whether the first tracking frame is recorded at the second position in the first video frame, the method further includes: the video acquisition device starts to perform inspection to obtain a second video frame after the current video frame, the second video frame being all video frames in different lanes after the current video frame; performing lane switching through a lane boundary; counting the number of target objects in each lane based on the second video frame using the rule frame and rule line counting method and the lane boundary switching algorithm; and counting the number of target objects in the tail lane.
[0132] In a possible implementation, the processing unit 1401 is further configured to perform lane switching through a lane boundary, including: when the inspection reaches the lane boundary, obtaining a boundary frame of the lane boundary based on the second video frame, and determining a center point of the boundary frame; determining a lane switching standard based on the center point of the boundary frame and the rule line; if the lane switching standard is met, switching from the current lane to the next lane, and performing counting of the number of target objects in the next lane.
[0133] In a possible implementation, the lane switching standard satisfies the following formula:
[0134]
[0135] wherein y dl is a vertical coordinate of the center point of the boundary frame, y img is a vertical resolution of the first video data, and θ is a switching pixel threshold.
[0136] In a possible implementation, the processing unit 1401 is further configured to count the number of target objects in the tail lane, including: when the inspection reaches the tail lane, counting the target objects in the area above the rule line in the tail lane using the rule frame and rule line counting method to obtain the number of target objects in the area above the rule line, and simultaneously counting the number of target objects in the area below the rule line; and adding the number of target objects in the area above the rule line and the number of target objects in the area below the rule line to obtain the total number of target objects in the tail lane.
[0137] In a possible implementation, the processing unit 1401 is further configured to, after counting the number of target objects in the tail lane, the method further includes: triggering reverse inspection when the video acquisition device is backhauled, performing up-down mirror preprocessing on the acquired video frames, and obtaining the number of target objects in the reverse inspection using the rule frame and rule line counting method and the lane boundary.
[0138] In a possible implementation, the processing unit 1401 is further configured to, after obtaining the target object quantity of the reverse inspection, the method further includes: obtaining the target object quantity of the multiple forward inspections and the reverse inspection, processing the reverse inspection result in reverse order, obtaining the mode of the target object quantity of the same field, and determining the final target object quantity of each field.
[0139] The processing unit 1401 can be a processor or a controller, and the communication unit 1402 can be a communication interface, a transceiver, a transceiver, a transceiver circuit, a transceiver device, etc. The communication interface is a general term, which can include one or more interfaces. The storage unit 1403 can be a memory. When the target object quantity counting device 140 in the field is a chip, the processing unit 1401 can be a processor or a controller, the communication unit 1402 can be an input interface and / or an output interface, a pin or a circuit, etc. The storage unit 1403 can be a storage unit (for example, a register, a cache, etc.) in the chip, or a storage unit (for example, a read-only memory (ROM), a random access memory (RAM), etc.) located outside the chip.
[0140] The communication unit can also be referred to as a transceiving unit. The antenna and control circuit with transceiving function in the target object quantity counting device 140 in the field can be regarded as the communication unit 1402 of the target object quantity counting device 140 in the field, and the processor with processing function can be regarded as the processing unit 1401 of the target object quantity counting device 140 in the field. Optionally, the device for realizing the receiving function in the communication unit 1402 can be regarded as the communication unit, and the communication unit is configured to perform the receiving steps in the embodiments of the present application, and the communication unit can be a receiver, a receiver, a receiving circuit, etc. The device for realizing the sending function in the communication unit 1402 can be regarded as a sending unit, and the sending unit is configured to perform the sending steps in the embodiments of the present application, and the sending unit can be a transmitter, a sender, a sending circuit, etc.
[0141] Figure 14The integrated units in the above embodiments can be stored in a computer readable storage medium if the integrated units are implemented in the form of software function modules and sold or used as independent products. Based on such an understanding, the technical solutions of the embodiments of the present application essentially or partially contribute to the prior art, or the whole or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to perform all or part of the steps of the methods described in the embodiments of the present application. The storage medium storing the computer software product includes a U disk, a mobile hard disk, a read-only memory, a random access memory, a magnetic disk or an optical disk, and various media that can store program codes.
[0142] Figure 14 The units in the above embodiments can also be referred to as modules, for example, the processing unit can be referred to as a processing module.
[0143] The embodiments of the present application also provide a hardware structure schematic diagram of the column-in-target object counting device (denoted as column-in-target object counting device 150), which is shown in Figure 15 The column-in-target object counting device 150 includes a processor 1501, and optionally, a memory 1502 connected with the processor 1501.
[0144] In a first possible implementation, referring to Figure 15 The column-in-target object counting device 150 further includes a transceiver 1503. The processor 1501, the memory 1502 and the transceiver 1503 are connected through a bus. The transceiver 1503 is configured to communicate with other devices or communication networks. Optionally, the transceiver 1503 can include a transmitter and a receiver. The device for realizing the receiving function in the transceiver 1503 can be regarded as a receiver, and the receiver is configured to perform the steps of receiving in the embodiments of the present application. The device for realizing the sending function in the transceiver 1503 can be regarded as a transmitter, and the transmitter is configured to perform the steps of sending in the embodiments of the present application.
[0145] Based on the first possible implementation, Figure 15 The structure schematic diagram shown in the above can be used to show the structure of the column-in-target object counting device involved in the above embodiments.
[0146] Among them, Figure 15 The system chip in the column-in-target object counting device can also be shown. In this case, the actions performed by the above column-in-target object counting device can be realized by the system chip, and the specific actions performed can be referred to in the above, which will not be described here.
[0147] In the implementation process, each step in the method provided by the embodiment can be completed by the integrated logic circuit of hardware in the processor or the instruction in the form of software. The steps of the method disclosed by the embodiment of the present application can be directly embodied as hardware processor execution completion, or execution completion by hardware and software module combination in the processor.
[0148] The processor in the present application can include but is not limited to at least one of the following: a central processing unit (CPU), a microprocessor, a digital signal processor (DSP), a microcontroller unit (MCU), or various types of computing devices running software, each of which can include one or more cores for executing software instructions to perform operations or processing. The processor can be a separate semiconductor chip, or can be integrated with other circuits as a semiconductor chip, for example, it can form a SoC (system on chip) with other circuits such as coding and decoding circuits, hardware acceleration circuits or various bus and interface circuits, or it can be integrated as a built-in processor in the ASIC. The ASIC integrated with the processor can be packaged separately or packaged together with other circuits. In addition to including cores for executing software instructions to perform operations or processing, the processor can further include necessary hardware accelerators, such as field programmable gate arrays (FPGAs), PLDs (programmable logic devices), or logic circuits that implement special logic operations.
[0149] The memory in the embodiment of the present application can include at least one of the following types: read-only memory (ROM) or other types of static storage devices that can store static information and instructions, random access memory (RAM) or other types of dynamic storage devices that can store information and instructions, and electrically erasable programmable read-only memory (EEPROM). In some scenarios, the memory can also be a compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compact discs, laser discs, optical discs, digital versatile discs, Blu-ray discs, etc.), magnetic disk storage medium or other magnetic storage device, or any other medium capable of carrying or storing desired program code in the form of instructions or data structures and capable of being accessed by a computer, but not limited to this.
[0150] The embodiment of the present application further provides a computer readable storage medium comprising instructions which, when executed on a computer, cause the computer to perform any of the above methods.
[0151] The embodiment of the present application further provides a computer program product comprising instructions which, when executed on a computer, cause the computer to perform any of the above methods.
[0152] The embodiment of the present application further provides a chip comprising a processor and an interface circuit, wherein the interface circuit is coupled to the processor, the processor is configured to execute a computer program or instructions to implement the above method, and the interface circuit is configured to communicate with other modules outside the chip.
[0153] In the above embodiments, all or part of the embodiments can be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments can be implemented in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network or other programmable devices. The computer instructions can be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another computer readable storage medium, for example, the computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center through wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.) mode. The computer readable storage medium can be any available medium that can be accessed by a computer or include one or more data storage devices such as servers, data centers, etc. that can be integrated with the medium. The available medium can be a magnetic medium (such as a floppy disk, a hard disk, a magnetic tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid state disk (SSD)) and the like.
[0154] Although the present application is described herein in conjunction with various embodiments, other variations of the disclosed embodiments can be understood and implemented by those skilled in the art through viewing the drawings, the disclosure, and the appended claims. In the claims, the word "comprising" does not exclude other components or steps, and "a" or "one" does not exclude a plurality. A single processor or other unit can implement several functions listed in the claims. Some measures described in mutually different dependent claims can be combined and produce beneficial results.
[0155] Although the application has been described in conjunction with specific embodiments thereof, it is evident that many alternatives, modifications and variations will be apparent to those skilled in the art. Accordingly, it is intended to embrace all such alternatives, modifications and variations that fall within the scope of the application. Accordingly, although specific terms are employed, they are used in a generic and descriptive sense only and not for purposes of limitation, the scope of the application being set forth in the following claims.
Claims
1. A method for counting target objects within a field, characterized in that, include: Based on the video capture device, the current video frame in the target field is acquired, and the current video frame includes a rule box and a rule line set at the center position of the current video frame; Identify target objects within video frames and add a tracking box and ID to each target object; Determine the first tracking box located within the rule box and record the first position of the first tracking box in the current video frame. The first tracking box is any tracking box located within the rule box. Determine whether the second position of the first tracking box in the first video frame is recorded. The first video frame satisfies the following conditions: the first video frame is before the current video frame; the first tracking box is located within the rule box between the first video frame and the current video frame; and the first tracking box is not located within the rule box before the first video frame. If so, determine whether the line connecting the first position and the second position intersects the rule line. If the connecting line intersects the rule line, and the first position is located on the first side of the rule line, and the second position is located on the second side of the rule line, then the number of target objects is accumulated; If the connecting line intersects the rule line, and the first position is located on the second side of the rule line, and the second position is located on the first side of the rule line, then the number of target objects is reduced cumulatively.
2. The method according to claim 1, characterized in that, The process of identifying target objects within video frames and adding a tracking bounding box and ID to each target object includes: Based on the video frame, the target object in the field is identified by the YOLOv12 target detection algorithm, and the detection box of the target object is output. The borsort target tracking algorithm is used to continuously track the identified detection boxes, and each target object is assigned a tracking box and a corresponding unique ID.
3. The method according to claim 1, characterized in that, The step of obtaining the current video frame within the target field includes: If the target column is the first column of the first inspection, the video frame data before the video acquisition device is started is captured. The number of target objects in the area above the rule line in the video frame is calculated by counting the number of unique IDs of all target objects in the area above the rule line and using the mode. The target objects in the area below the rule lines in the first column are counted using the rule box rule line counting method to obtain the number of target objects in the area below the rule lines. The total number of target objects in the first column is obtained by adding the number of target objects in the area above the rule line to the number of target objects in the area below the rule line.
4. The method according to claim 1, characterized in that, After determining whether the second position of the first tracking box in the first video frame has been recorded, the method further includes: The video acquisition device begins inspection and acquires the second video frame after the current video frame. The second video frame consists of all video frames in different columns after the current video frame. Field switching is achieved through a field boundary switching algorithm; Based on the second video frame, the number of target objects in each column is counted using the rule box rule line counting method and the column boundary switching algorithm. Count the number of target objects mentioned in the last column.
5. The method according to claim 4, characterized in that, The column switching is achieved through a column boundary switching algorithm, including: When the inspection reaches the boundary of the field, the bounding box of the field boundary is obtained based on the second video frame, and the center point of the bounding box is determined. The criteria for switching fields are determined based on the center point of the bounding box and the rule lines. If the field switching criteria are met, the system switches from the current field to the next field and performs a count of the target objects in the next field.
6. The method according to claim 5, characterized in that, The field switching standard satisfies the following formula: Among them, y dl Let y be the ordinate of the center point of the bounding box. img θ represents the vertical resolution of the first video data, and θ represents the switching pixel threshold.
7. The method according to claim 4, characterized in that, The number of target objects mentioned in the statistics footer includes: When the inspection reaches the end column, the target objects in the area above the rule line in the end column are counted using the rule box rule line counting method to obtain the number of target objects in the area above the rule line, and the number of target objects in the area below the rule line is also counted. The total number of target objects in the tail column is obtained by adding the number of target objects in the area above the rule line to the number of target objects in the area below the rule line.
8. The method according to claim 4, characterized in that, After counting the number of target objects in the end column, the method further includes: When the video acquisition device returns, it triggers a reverse inspection. After performing up-and-down mirroring preprocessing on the acquired video frames, it uses the rule box rule line counting method and column boundary switching algorithm to obtain the number of target objects for the reverse inspection.
9. The method according to claim 8, characterized in that, After obtaining the number of target objects for reverse inspection, the method further includes: Obtain the number of target objects from multiple forward inspections and the reverse inspections. Process the reverse inspection results in reverse order, calculate the mode of the number of target objects in the same column, and determine the final number of target objects in each column.
10. A counting device for target objects within a field, characterized in that, include: Communication unit and processing unit; The communication unit is used to acquire the current video frame in the target field based on the video acquisition device, wherein the current video frame includes a rule box and a rule line set at the center position of the current video frame; The processing unit is configured to identify target objects within a video frame and add a tracking box and ID to each target object; determine a first tracking box located within the rule box and record the first position of the first tracking box in the current video frame, wherein the first tracking box is any tracking box located within the rule box; determine whether a second position of the first tracking box in the first video frame has been recorded, wherein the first video frame satisfies the following conditions: the first video frame is before the current video frame, the first tracking box is located within the rule box between the first video frame and the current video frame, and the first tracking box is not located within the rule box before the first video frame; if so, determine whether the line connecting the first position and the second position intersects the rule line; if the line intersects the rule line and the first position is located on the first side of the rule line and the second position is located on the second side of the rule line, then increment the number of target objects; if the line intersects the rule line and the first position is located on the second side of the rule line and the second position is located on the first side of the rule line, then decrement the number of target objects.