Method, system and program product for entry and exit statistics based on three-region state machine of acupuncture points

By using a three-region state machine approach, the problems of duplicate and missed counts in the entry and exit statistics of personnel in industrial gate areas were solved, enabling accurate headcount statistics under complex conditions and improving the reliability and accuracy of the statistics.

CN123182273APending Publication Date: 2026-11-27HUA DATA TECH (SHANGHAI) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611686853.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-10-28
Publication Date
2026-11-27

AI Technical Summary

Technical Problem

In the statistics of personnel entering and exiting industrial areas, existing technologies are unable to accurately distinguish between complete passage, turning back, and missing initial trajectories under conditions of repeated personnel targets, short-term interruption of trajectories, and complex movements at the entrance, resulting in double counting or undercounting.

Method used

A three-region state machine based on foot points is adopted. By acquiring video of the industrial gate area, candidate bounding boxes of personnel are detected and duplicate bounding boxes are fused. Trajectory association is performed by combining speed prediction and foot point distance to determine the region to which the personnel's foot points belong, generating a stable region time series, and performing constraint compensation and delay confirmation. Finally, entry and exit events are calculated.

Benefits of technology

It improves the reliability of regional population statistics, reduces miscounting and undercounting of entry and exit caused by obstruction, short-term obstruction and missing trajectory, reduces the impact of trajectory interruption on passage judgment, and reduces misjudgment and duplicate counting of entry and exit directions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123182273A_ABST
    Figure CN123182273A_ABST
Patent Text Reader

Abstract

The application provides a kind of based on foot point three area state machine's in-out statistics method, system and program product, method includes: obtaining industrial gate area video and camera configuration, uniform gate area coordinate, personnel candidate target is labeled mapping and repeated frame fusion, combine speed prediction, foot point distance and frame height similarity form continuous personnel trajectory;According to the region to which personnel foot point belongs and the stable region timing formed by continuous frame confirmation result, the complete in-out candidate is identified by three area state machine, the departure trajectory missing in the starting region is compensated according to the motion direction, scale trend and trajectory quality, and the target side delay confirmation is executed;According to the reliability determination of candidate source and motion characteristics, the idempotent submission is carried out for the qualified traffic event, and the current number of people in the region is updated. It can reduce the in-out miscount and missing caused by gate turn-back, short-time shielding and trajectory loss, and improve the reliability of personnel in-out statistics.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer vision technology, and in particular to an entry / exit statistics method, system, and program product based on a three-region state machine for foot points. Background Technology

[0002] Equipment rooms, maintenance corridors, and confined spaces in industrial production are typically equipped with personnel access doors. Safety management requires tracking personnel entry and exit, as well as the current number of people in the area. To utilize existing video surveillance equipment, fixed monocular cameras are usually installed at the access points. Personnel detection models identify personnel targets in video frames, and the overlapping relationships of bounding boxes are used to correlate the positions of personnel in adjacent frames. Some personnel entry and exit statistics methods use the center of the human body, head and shoulder positions, or the bottom edge of the bounding box as judgment points. The direction of passage is determined by detecting whether personnel cross a preset virtual line, and the number of people in the area is calculated based on entry and exit events.

[0003] However, industrial doorways often present challenges such as door frame obstruction, changes in perspective scale, and multiple people passing through simultaneously. The size and position of the bounding box change as people approach or move away from the camera; short-term missed detections may occur when people pass through door frames or are obstructed by other people, disrupting the trajectory correlation between adjacent frames. Some detection models may also output multiple internal labels, each representing a person. If trajectories are directly established based on these different labels, it can easily lead to duplicate targets for the same person. Furthermore, when people linger at doorways, repeatedly cross virtual lines, or turn back after entering a doorway, a single line-crossing result may not accurately reflect whether they have truly completed the door-passing process, potentially resulting in duplicate counting or misjudgments of the passage direction.

[0004] When a person is obstructed inside a doorway and is only detected upon reaching the door, their trajectory may lack a starting position record, causing statistical methods relying on complete trajectories to miss departure events. If short trajectories appearing at the doorway are directly considered passage, lingering or turning back at the doorway may be mistakenly identified as departure. Therefore, accurately distinguishing between complete passage, turning back, and departure with missing starting trajectories based on the actual passage process under conditions of repeated personnel targets, short-term trajectory interruptions, and complex doorway movements, while avoiding duplicate submissions of passage events, is a technical problem that needs to be solved in the personnel entry and exit statistics of industrial gate areas. Summary of the Invention

[0005] The purpose of this invention is to address the shortcomings of existing technologies by providing an entry / exit statistics method, system, and program product based on a three-region state machine for foot points, thereby solving the technical problems mentioned in the background section.

[0006] To achieve the above objectives, the present invention provides the following technical solution:

[0007] The entry and exit statistics method based on the three-region state machine of foot points includes the following steps:

[0008] S1. Obtain video and camera configuration of the industrial gate area, unify the polygon coordinates of the area outside the gate, the transition area at the gate, and the area inside the gate to the current video frame, and detect and obtain personnel candidate boxes, detection scores, and internal labels.

[0009] S2. Unify the internal labels with personnel meaning to the personnel target, and merge the repeated boxes according to the degree of intersection or the proportion of smaller boxes; combine velocity prediction, prediction box overlap, foot distance and box height similarity to perform gating and one-to-one trajectory association to form continuous personnel trajectory;

[0010] S3. Construct personnel foot points based on personnel frames in continuous personnel trajectories, determine the region to which the foot points belong, confirm stable regions through continuous frames and compress repetitive stable states to form stable region time sequences.

[0011] S4. Generate complete entry / exit candidates based on the stable state sequence of outside the door, doorway transition, inside the door, or inside the door, doorway transition, outside the door; for trajectories that first stabilize in the doorway transition area, then stabilize outside the door and lack an initial state inside the door, perform restricted compensation based on the direction of movement, scale trend, longitudinal displacement ratio, and effective hit quality to generate missing segment departure candidates; perform target-side delayed confirmation, foldback cancellation, and timeout elimination on passage candidates.

[0012] S5. Select different basic credibility levels based on complete or incomplete candidate sources, calculate the final credibility level by combining motion characteristics and trajectory quality, and submit the formal entry / exit event when the corresponding threshold is reached; perform idempotency verification and cooling of the same trajectory and direction on the event, and update the current number of people in the area based on the valid entry / exit events.

[0013] S1 specifically includes: acquiring video of the industrial gate area captured by a fixed monocular camera, recording the camera identification, physical gate number, frame number, frame time, and current image resolution; based on the threshold, door frame, passable ground area, and perspective direction in the camera's captured image, marking the polygons of the outer area, doorway transition area, and inner area, and configuring the symbol of the entry direction on the vertical axis of the image and the expected scale change symbol; based on the ratio of the current image width and height to the reference image width and height, calculating the coordinates of each polygon vertex to obtain the boundaries of the three regions corresponding to the current video frame; inputting the current video frame into the personnel detection model to obtain candidate bounding boxes, detection scores, and internal labels, retaining candidate targets whose detection scores reach a preset threshold, and forming a candidate target record containing bounding box coordinates and corresponding video frame information.

[0014] S2 specifically includes: mapping internal labels with personnel meaning to personnel targets uniformly according to the personnel label mapping table; calculating the intersection degree of candidate boxes of personnel in the same video frame and the proportion of the intersection part to the area of ​​the smaller candidate box. When any of these proportions reaches the corresponding threshold, the duplicate candidate boxes are fused and the boxes with more complete spatial range, higher detection scores, and original label sets are retained; predicting the personnel boxes of the current frame according to the historical position and smoothing speed of the existing trajectory, and calculating the overlap degree of the predicted boxes, the normalized proximity of the foot point distance, and the similarity of the box height respectively; when the predicted box meets the minimum overlap condition or the foot point distance meets the dynamic distance condition determined by the target height and the number of consecutive loss, and the box height ratio is within the allowable range, performing one-to-one association according to the joint matching score; updating the observation history and motion state of the matched trajectory, and retaining the unmatched trajectory within the preset short-term loss window.

[0015] S3 specifically includes: based on the actual detected bounding boxes of people in the continuous personnel trajectory, taking the midpoint of the bottom edge of the bounding box as the personnel foot point, comparing the position of the personnel foot point with the three-region polygon corresponding to the current video frame to determine its region, and prioritizing the positions of adjacent polygons sharing the same edge or overlapping with the doorway transition area as the doorway transition area, so that each valid foot point corresponds to a unique region result; saving the candidate region, consecutive frame count, stable region state, and region state sequence for each personnel trajectory, accumulating the consecutive frame count when the current frame region is the same as the previous candidate region, otherwise restarting the count; when the consecutive frame count reaches the preset stability threshold, confirming the corresponding stable region state, and comparing it with the end of the region state sequence, only adding a new stable region state in chronological order when the two are different, forming a compressed region sequence.

[0016] S4 specifically includes: generating complete entry candidates when the outside area, doorway transition area, and inside area are formed sequentially according to the stable area time sequence; generating complete exit candidates when the inside area, doorway transition area, and outside area are formed sequentially; for trajectories that first stabilize in the doorway transition area, then stabilize in the outside area, and lack an initial state inside the door, extracting the midpoint position of the foot points and the height of the personnel frame from the effective observations at the beginning and end, and determining the overall displacement direction, total displacement, longitudinal displacement ratio, and scale change trend; when the motion direction and scale trend are consistent with the camera configuration, and the total displacement, longitudinal displacement ratio, and effective hit count meet the corresponding requirements, generating a missing segment exit candidate; continuing to observe the target side foot point status for the passage candidate, completing the confirmation after reaching a preset number of consecutive confirmation frames, and canceling the corresponding candidate when returning to the starting area or exceeding the maximum passage time during the candidate period.

[0017] S5 specifically includes: selecting the corresponding basic credibility and feature weights based on the complete route or missing source of the candidate's starting area; weighting and correcting the basic credibility based on the consistency of movement direction, scale trend consistency, longitudinal displacement ratio, and trajectory hit quality to obtain the final credibility; for candidates that reach the corresponding credibility threshold and have been confirmed by the target side, performing idempotent verification based on trajectory identifier, passage number, direction, and time window; submitting the formal entry / exit event after passing the verification; setting a cooldown time for the same trajectory in the same direction; restarting the trajectory area path from the target area; updating the cumulative number of entries and exits based on valid entry and exit events; determining the current number of people in the area by adding the initial number of people to the cumulative number of entries and subtracting the cumulative number of exits; not recording abnormal exits that exceed the current number of people who can leave, and recording the reason.

[0018] An entry / exit statistics system based on a three-region footpoint state machine includes:

[0019] The module includes video acquisition and gate configuration, personnel target fusion and trajectory association, foothold area determination and stable state generation, passage status recognition and segment compensation, and event credibility determination and number of people update.

[0020] The beneficial effects of this invention are as follows:

[0021] This invention integrates personnel target fusion and continuous trajectory association, combined with the stable state recognition of personnel footpoints in three regions to identify the passage process. It also compensates for and delays the confirmation of missing trajectories in the initial region, reducing false alarms and omissions caused by doorway backtracking, short-term occlusion, and missing trajectories, thus improving the reliability of area-wide personnel statistics. Internal labels with personnel connotations are uniformly mapped to personnel targets. Before trajectory establishment, duplicate boxes are fused based on the intersection degree of candidate boxes or the proportion of smaller boxes, merging duplicate detection results for the same person into a single personnel target, reducing duplicate trajectory establishment and counts caused by differences in internal labels and duplicate candidate boxes.

[0022] This invention associates trajectories by combining speed prediction, predicted frame overlap, foot point distance, and frame height similarity. During short-term loss of detection, unmatched trajectories are retained, allowing for continued association based on existing trajectory states even when personnel reappear due to changes in perspective scale or short-term occlusion. This reduces the impact of trajectory interruptions and trajectory identifier switching on passage judgment. A three-region stable state sequence is constructed using personnel foot points. Region boundary jitter is suppressed through continuous frame confirmation and repetitive state compression. Combined with target-side delayed confirmation, backtracking cancellation, and timeout elimination, trajectories of stopping at doorways, turning back, and incomplete passage are not directly recognized as formal passage events, reducing misjudgments of entry / exit directions and duplicate counting.

[0023] This invention compensates for the limited departure trajectory lacking an initial state within a gate by combining the direction of movement, scale change trend, longitudinal displacement ratio, and trajectory hit quality. It employs a different foundational confidence level and judgment criteria than the complete route, enabling missing trajectory segments with sufficient motion evidence to form departure events, thus reducing missed departures caused by occlusion. Through event idempotency verification and cooling of the same trajectory in the same direction, it limits duplicate formal events generated from the same passage and updates the current number of people in the area based on valid entry and exit events. Abnormal departures exceeding the current allowable number are not recorded, preventing duplicate deductions or negative current numbers due to repeated events and abnormal departure records. Attached Figure Description

[0024] Figure 1 This is a flowchart of the entry and exit statistics method based on the three-region state machine of the foot point according to the present invention;

[0025] Figure 2 This is a framework diagram of the entry and exit statistics system based on the footpoint three-region state machine of this invention. Detailed Implementation

[0026] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. 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.

[0027] Example 1: As Figure 1 As shown, this embodiment provides an entry / exit statistics method based on a three-region state machine for foot points, including the following steps:

[0028] S1. Obtain video and camera configuration of the industrial gate area, unify the polygon coordinates of the area outside the gate, the transition area at the gate, and the area inside the gate to the current video frame, and detect and obtain personnel candidate boxes, detection scores, and internal labels.

[0029] S2. Unify the internal labels with personnel meaning to the personnel target, and merge the repeated boxes according to the degree of intersection or the proportion of smaller boxes; combine velocity prediction, prediction box overlap, foot distance and box height similarity to perform gating and one-to-one trajectory association to form continuous personnel trajectory;

[0030] S3. Construct personnel foot points based on the personnel frames in the continuous personnel trajectory, determine the region to which the foot points belong, confirm stable regions through continuous frames and compress repeated stable states to form stable region time sequences.

[0031] S4. Generate complete entry / exit candidates based on the stable state sequence of outside the door, doorway transition, inside the door, or inside the door, doorway transition, outside the door; for trajectories that first stabilize in the doorway transition area, then stabilize outside the door and lack an initial state inside the door, perform restricted compensation based on the direction of movement, scale trend, longitudinal displacement ratio, and effective hit quality to generate missing segment departure candidates; perform target-side delayed confirmation, foldback cancellation, and timeout elimination on passage candidates.

[0032] S5. Select different basic credibility levels based on complete or incomplete candidate sources, calculate the final credibility level by combining motion characteristics and trajectory quality, and submit the formal entry / exit event when the corresponding threshold is reached; perform idempotency verification and cooling of the same trajectory and direction on the event, and update the current number of people in the area based on the valid entry / exit events.

[0033] S1. Obtain video data of the industrial gate area and the corresponding camera configuration, unify the gate area coordinates, and form candidate targets for personnel in the current video frame.

[0034] A fixed monocular camera is installed at the industrial gate area, with its shooting range covering the entrance and the normal passage positions of people on both sides of the gate. The video input consists of real-time network video streams output by the camera, video streams output by video forwarding services, or recorded files; the system decodes the video in chronological order, obtains the image frames to be processed, and records the camera identification, physical gate number, frame sequence number, frame time, current image width, and height.

[0035] Camera identifiers are used to locate video inputs and their configurations, while physical gate numbers are used to assign passage events to the corresponding actual gates. When extracting video frames at a preset processing frame rate, subsequent consecutive frame counting only applies to the frames actually involved in the processing, while loss time, passage duration, and cooldown time are calculated based on the corresponding frame times. For frames that are not successfully decoded, no detection results are generated, nor are they considered valid frames indicating that a person has been observed to be in a certain area.

[0036] Each camera stores its own gate configuration, which includes the baseline image resolution, the polygon vertices of the OUTSIDE region, the DOOR transition zone, and the INNER region, the sign of the entry direction on the vertical axis of the image, the sign of the expected scale change, and the thresholds required for detection and passage determination.

[0037] The three zones are defined by the installers based on the threshold, door frame, and passable ground area and perspective direction in the fixed image: OUTSIDE covers the passable ground outside the doorway, DOOR covers the transition area where people actually pass through the doorway, and INNER covers the passable ground inside the doorway; the polygons should exclude the left and right edges of the image, black borders, fixed equipment, and non-passable areas as much as possible. All vertices are stored according to the same image coordinate system, with the upper left corner of the image as the origin, the horizontal axis to the right, and the vertical axis downwards.

[0038] The camera can be installed either outside the door facing inward or inside the door facing outward. The direction of entry is determined by the expected increase or decrease of the vertical coordinate of the foot point when a person walks from OUTSIDE through DOOR to INNER, and the direction of departure is the opposite direction. The expected scale change symbol is determined by the expected increase or decrease of the height of the bounding box of the person in the corresponding direction of passage, and entry is not always interpreted as approaching the camera.

[0039] The vertices of the three regions can use pixel coordinates at the reference resolution or normalized coordinates. When using pixel coordinates, let the width and height of the reference image be W and H, respectively, and the width and height of the current image be... , The vertices of the base polygon are The corresponding vertices in the current image are converted according to the following relationship:

[0040] ;

[0041] Among them, W, H, and the reference vertex are taken from the camera configuration. , Taken from the current video frame.

[0042] When using normalized coordinates, the normalized horizontal and vertical coordinates are multiplied by the current image width and height, respectively. All vertices of the three polygons are calculated one by one to ensure that personnel footholds and area boundaries always use the same coordinate system as the current image. The reference image can be 2560×1440 resolution; after switching the main stream, sub-stream, or transcoding the video, it is recalculated according to the actual width and height. If the image width and height are invalid or the corresponding camera's gate configuration is not available, passage is not determined based on the uncalibrated area boundaries.

[0043] Input the current image frame into the configured person detection model, and read the candidate bounding boxes, detection scores, and internal labels provided by the model. The model can be a YOLO series detector, a Transformer detector, or other detection methods that can provide person location and category information. For consistent processing, the bounding box is recorded as the top left corner. and bottom right corner Only candidate boxes with both width and height greater than zero and within the valid range of the current image are retained.

[0044] The detection score is compared with the current camera's detection threshold. Candidates with scores below the threshold are not included in subsequent processing of the current frame. For example, when the detection threshold is configured to 0.50, candidates with scores not lower than 0.50 are retained. The remaining bounding box coordinates, detection score, internal label, frame number, frame time, and camera identifier are combined to form a candidate target record, which is then fed into the personnel label mapping and duplicate box fusion processing.

[0045] S2. Unify personnel targets, merge duplicate candidate boxes, and associate continuous personnel trajectories based on speed prediction, foot distance, and scale changes.

[0046] Read the candidate target records and the personnel tag mapping table corresponding to the detection model. The mapping table lists the internal tags configured as personnel meanings. Candidates matching these tags are uniformly assigned the business category PERSON; candidates not mapped to PERSON do not participate in personnel entry and exit statistics. The mapping table is saved in correspondence with the current detection model version; when changing the detection model, first verify the correspondence between internal tags and personnel meanings, and then process the model output to avoid directly using inapplicable old tag tables. The original tags are only retained with the records for debugging purposes and do not indicate clothing category, personnel identity, or entry / exit direction.

[0047] For candidates that have already been mapped to PERSON, regardless of whether their original labels are the same or different, the same spatial overlap condition is used to determine whether they are duplicates, so as to avoid the creation of multiple trajectories for the same person due to different labels within the model.

[0048] Before establishing the trajectory, compare any two candidate person bounding boxes in the same frame. Calculate the area A1, A2 of each bounding box and the intersection area A' based on the left, right, top, and bottom boundaries of each bounding box. i When the intersection is empty, A i Take zero; union area A u =A1+A2-A i The degree of overlap and the proportion of smaller boxes contained are calculated according to the following relationships:

[0049] ;

[0050] Division is performed only on boxes with valid areas. If the Intersection over Union (IoU) reaches a first threshold, or the proportion K of the smaller box being contained reaches a second threshold, the two candidate boxes are considered to have a duplicate relationship; otherwise, they are retained separately. In the example, the first threshold is set to 0.55 and the second threshold is set to 0.82.

[0051] When fusing duplicate candidates, retain the candidate bounding boxes with more complete spatial ranges, the higher detection scores of the boxes involved in the fusion, and the original label set, and output a PERSON target. When the more complete bounding box and the highest score come from different candidates, obtain the box coordinates and scores from the corresponding candidates respectively. When multiple candidates have overlapping relationships, continue to use the same decision condition for processing, and do not merge adjacent people that do not meet the spatial overlap condition just because they belong to the same PERSON.

[0052] For the merged target, construct personnel footpoints for association. When using a rectangular frame, the footpoint is taken as the midpoint of the bottom edge:

[0053] ;

[0054] Here, p represents the approximate landing position of the person in the image. If foot keypoints, the lowest stable point of the human body segmentation contour, or a weighted sum of these points are used, a consistent footpoint construction method should be applied to the current candidate and the corresponding historical trajectory. The bounding box height h = y2 - y1, obtained from the current fused bounding box. The current person's footpoints and bounding box height are saved with the target record, used both for association in this step and for subsequent region determination and motion feature calculation, avoiding the creation of a separate, inconsistent set of position data in later steps.

[0055] For each established personnel trajectory, the system saves the trajectory identifier, the most recent valid bounding box and footpoint, the number of hits, the number of consecutive misses, the smoothing speed, and a finite length of actual observation history. The observation history records the footpoint, box height, frame number, and actual detection matching status by frame time; the number of hits only increases when the trajectory successfully matches the current actual detection target, and the predicted position during a short period of missed detection is not counted as a hit.

[0056] A new trajectory is created for the current target that is not associated with an existing trajectory. This trajectory is written to the first valid observation, and the hit count is set to 1 and the consecutive miss count is set to 0. If the current position is insufficient to calculate the velocity, the current foothold and bounding box are used as the initial position, and the velocity is updated by subsequent valid observations. The trajectory identifier within the same camera is not reused for other simultaneously valid trajectories.

[0057] The velocity of the existing trajectory is updated based on the previously saved smoothed velocity and the foot point displacement between the two most recent valid observations. The horizontal and vertical displacements of adjacent valid observations are divided by the positive time difference between the two observations to obtain the velocity of that segment, which is then combined with the original smoothed velocity according to a preset smoothing weight to form the updated velocity; if the time difference is invalid, the velocity of that segment of observation is not used to update the velocity.

[0058] When predicting the current frame position, the predicted footpoint is calculated by combining the saved footpoints and velocities of the trajectory with the time difference between the current frame and the corresponding historical frames. The nearest valid bounding box is then translated into the predicted bounding box by the predicted displacement. The width and height of the bounding box use the dimensions of the valid bounding boxes saved for the corresponding trajectory. During short-term trajectory loss, existing velocity predictions continue to be used, and the prediction results are not written as new actual detection observations. The smoothing weights and maximum loss duration are configured by the camera or tracker; the example maximum loss duration is approximately 1.2 seconds.

[0059] For a predicted trajectory and a current person target, calculate the degree of intersection between the predicted bounding box and the current bounding box, calculate the Euclidean distance d between the predicted foot point and the current foot point, and compare the height h of the predicted bounding box. p and the current frame height h c Joint matching uses three metrics: predicted bounding box overlap, normalized proximity of foot points, and height ratio similarity; among them, the predicted bounding box overlap is calculated using the same method as the intersection-merge degree mentioned above.

[0060] To ensure that the other two quantities can participate in the same weighted score, distance normalization scale and height ratio mapping rules are specified in the corresponding camera association configuration. Following the principle that smaller distances indicate higher similarity and height ratios closer to 1 indicate higher similarity, the results are transformed to a unified value range. The corresponding specific mapping functions and parameters should be consistent with the actual operating configuration; a function or fixed coefficient that is not yet determined should not be considered the only existing implementation. For candidates for which valid footpoints or frame heights cannot be obtained, invalid distances or height ratios should not be used to generate association scores.

[0061] The overlap of the predicted bounding boxes, the normalized proximity of the foot points, and the height ratio similarity are denoted as I, D, and R, respectively. The joint matching score is calculated according to the following relationship:

[0062] ;

[0063] Where M represents the joint matching score, , , These represent the weights of the three matching values, all read from the associated configuration; in the example, they are 0.62, 0.28, and 0.10 respectively.

[0064] First, dynamic gating is performed, and then joint scores are calculated or used for candidates that pass the gating. During gating, the position condition is met when the overlap of the predicted bounding boxes reaches the minimum overlap threshold, or when the distance d between the foot points is less than the dynamic distance threshold determined by the target height and the number of consecutive losses of the trajectory. If the height ratio between the current bounding box and the predicted bounding box exceeds the configured allowable range, the match is excluded even if the position condition is met.

[0065] The dynamic distance threshold is obtained according to the preset height and loss count rules of the current camera, so that the gating uses the actual image scale of the target and the short-term loss state, instead of using the same unconfigured absolute pixel distance for all trajectories. The minimum overlap threshold, distance threshold rules, and height ratio range are all stored as associated parameters; for parameters that do not specify a unique value or function form, unverified fixed values ​​are not used to replace the actual configuration.

[0066] Candidate matches meeting the gating criteria are sorted from highest to lowest according to M. An unused trajectory is then sequentially associated one-to-one with an unused detected target. Associated trajectories and targets do not participate in the remaining matches of the current frame. After successful association, the trajectory position and observation history are updated with the actual detection box and footpoints, the hit count is increased, the smoothing speed is updated, and the consecutive loss count is reset to zero.

[0067] For a current target that does not match an existing trajectory, a new trajectory is established; for an existing trajectory that does not match a current target, the consecutive loss count is increased, and the identifier and prediction status are retained within a preset short window so that the association can continue when the person reappears from the occlusion. Once the consecutive loss duration calculated according to frame time exceeds the maximum loss duration, the effective tracking state of that trajectory ends. The trajectory identifier, valid detection boxes and foot points, valid observation history, and current motion status of each person are output for use in the three-region determination.

[0068] S3. Determine the gate area affiliation based on personnel footpoints, stabilize the frame-by-frame region results, and form a compressed region sequence.

[0069] For the current valid personnel trajectory, read the personnel's foot points, frame number, frame time, and the three-region polygon converted to the current resolution, corresponding to the latest actual detection frame of the trajectory. Preferably, the midpoint of the bottom edge of the aforementioned rectangular frame is used directly; for cameras using foot keypoints, the lowest stable point of the segmented contour, or their weighted results, the foot point construction method already selected for the current trajectory is used. Different foot point schemes are used to approximate the contact position between the person and the ground; subsequent judgments will no longer use the head, head shoulder, or body center crossing a single virtual line to replace the three-region timing of the foot points.

[0070] Based on the horizontal and vertical coordinates of the footpoint, determine whether it is located inside or on the boundary of the OUTSIDE, DOOR, and INNER polygons, respectively. Only one region result is assigned per frame: when a footpoint falls on a DOOR location that shares an edge with or slightly overlaps with an adjacent polygon, it is assigned to DOOR; for other locations, OUTSIDE or INNER is determined based on the polygon it is located in. The coordinates of all three regions have been converted to pixel coordinates for the current video frame; therefore, the original vertices at the reference resolution cannot be directly compared to the footpoints at the current resolution.

[0071] If a footpoint near the doorway is located at the intersection of the boundaries of OUTSIDE and INNER, its classification as a DOOR is determined by the priority rule for the current doorway transition area. For overlapping positions that are not marked as DOOR and cannot be uniquely assigned, the polygon boundaries should be adjusted during camera initialization to avoid the same footpoint corresponding to two conflicting stable states. If a footpoint falls outside all three regions, no new valid three-region result is generated in this frame. If the current actual detected footpoint cannot be obtained and only the predicted bounding box is available, a new stable region is not confirmed based on the predicted footpoint to avoid arbitrary doorway transitions during occlusion.

[0072] Each trajectory stores a candidate region, the number of consecutive valid frames for that candidate region, the confirmed stable region, and the compressed region sequence. When a valid region result is obtained for the first time, it is set as a candidate region and counting begins; if the valid region of a new frame is the same as the previous candidate region, the consecutive frame count is incremented by 1; if they are different, the current region is set as a new candidate region and the count restarts from 1.

[0073] If the current valid detection is missing or the foot point does not belong to the three regions, the frame is not regarded as a valid continuous frame located in the previous candidate region. In order to make the meaning of reaching the preset number of consecutive frames consistent, the continuous counting of candidate regions is interrupted here, but the stable region and compressed region sequence that has been confirmed in the trajectory history is retained for personnel to re-detect and continue processing.

[0074] When the number of consecutive valid frames for a candidate region reaches the stabilization threshold configured by the current camera, the region is confirmed as the current stable region. The example processing frame rate is 5-10 frames per second, and the stabilization threshold is two consecutive processing frames. When confirming a new stable region, it is compared with the last state in the compressed region sequence: if they are the same, it is not added again; if they are different, the new region name, confirmation frame number, and confirmation time are recorded and appended in chronological order.

[0075] Different regional results caused solely by momentary jitter of footpoints on either side of the gate boundary will not alter the stable region or repeatedly add sequence nodes unless the consecutive frame requirements are met. Before a stable region is formed, the regional results of a single frame are not considered part of the complete route. Continuous counting only serves the current candidate region, and confirmed stable regions remain unchanged until brief regional changes pass the stability threshold; once personnel actually move from one region to another, new continuous valid observations drive the update of stable regions. This distinguishes between temporary positions in the current frame and confirmed states already used for passage determination.

[0076] The compressed region sequence is associated with and saved with the corresponding trajectory identifier. Adjacent states in the sequence represent different regions confirmed successively by the trajectory, rather than the number of times a person stays in a certain region frame by frame. Personnel entering the door from outside through the doorway can sequentially form OUTSIDE, DOOR, INNER; personnel moving in the opposite direction can form INNER, DOOR, OUTSIDE; personnel turning back at the doorway may form OUTSIDE, DOOR, OUTSIDE or INNER, DOOR, INNER.

[0077] The sequence, the confirmation time of each state, the effective observation history of the trajectory, and the current stable region are all handed over to the passage state machine; the subsequent passage start time, candidate generation time, and duration are all obtained from the corresponding trajectory and state records, and no time quantity without a source is used in the timeout judgment.

[0078] S4. Based on the three-region state machine, identify the complete route, perform restricted compensation for the missing trajectory in the starting region, and perform delayed confirmation on the candidates.

[0079] For each personnel trajectory, a compressed region sequence saved in chronological order is read, and the starting side, transition side, target side, and candidate state of this passage are maintained. A complete entry candidate is formed when the sequence is confirmed as OUTSIDE, DOOR, and INNER in sequence, with the starting side being OUTSIDE and the target side being INNER; a complete departure candidate is formed when the sequence is confirmed as INNER, DOOR, and OUTSIDE in sequence, with the starting side being INNER and the target side being OUTSIDE. DOOR must appear as a transition state confirmed in chronological order; it cannot be determined solely by footsteps crossing from outside to inside the door, or by supplementing this state based on single-frame crossing results.

[0080] Candidate records include trajectory identifier, direction of travel, candidate source, complete stable area path, route start time, and candidate generation time. The source is recorded as the complete route.

[0081] When personnel enter the DOOR from the OUTSIDE and return to the OUTSIDE, or enter the DOOR from the INNER and return to the INNER, a complete path is not formed in the three regions mentioned above, and no complete passage candidate is generated. After returning to the original side, the stable state of that side is used as the starting point for the next passage judgment. The old DOOR state that has already been turned back cannot be spliced ​​with the state of the later arrival at the target side.

[0082] When personnel are stationary near the DOOR, the area boundary is fluctuating, or there is a lack of stable DOOR conditions, a complete candidate cannot be generated solely based on the states at the beginning and end. For candidates that have already been formed, subsequent area changes must be recorded, and before submitting a candidate, it is still necessary to check whether there has been a rollback, whether a timeout has occurred, and whether the target side's confirmation requirements have been met.

[0083] For situations where people inside the door are obstructed by the door frame, door leaf, or other people in the initial stage, or where the initial state is not observed due to the lack of video start, stream recovery, or short-term detection, a restricted departure compensation is adopted: when the first stable state of a trajectory is DOOR, and then stabilizes to OUTSIDE, and the trajectory lacks the INNER initial state, a departure candidate with a missing initial region is generated.

[0084] This candidate path differs from the complete route candidate path. Trajectories where the DOOR→OUTSIDE sequence is not observed, the initial stable state is not DOOR, or a complete INNER→DOOR→OUTSIDE sequence is already present will not be repeatedly generated as departure candidates based on this missing segment source. This compensation path targets departure trajectories lacking an INNER initial state and does not automatically recognize all short trajectories or DOOR→INNER entry trajectories as objects eligible for equivalent compensation.

[0085] From the finite-length actual observation history of the candidate trajectories with missing segments, several initial and final samples are extracted in chronological order after the start of the route. Each sample must have at least a frame time, the actual horizontal and vertical coordinates of the detected foot point, and the detection box height; frames that are only retained based on velocity prediction but not detected are not considered valid motion samples. The number of initial and final samples and the requirements for valid samples are saved as actual operation parameters; when the valid observations are insufficient to obtain two temporally separated sample windows, the motion evidence cannot be considered satisfied.

[0086] The median of the x-coordinate and y-coordinate of the starting window's foot point is obtained as the starting representative position. The last window uses the same method to obtain the last representative position. This reduces the impact of single-frame footpoint fluctuations on the overall orientation.

[0087] Calculate the lateral displacement based on two representative locations. and longitudinal displacement This leads to the total displacement L and the proportion of longitudinal displacement. :

[0088] ;

[0089] ;

[0090] The coordinates and displacements mentioned above all use the same current image coordinate reference. If the frame resolution used for the same trajectory changes, the coordinates are first unified according to the image aspect ratio. No division is performed when L is zero; this trajectory does not meet the minimum motion requirement and cannot be compensated for by missing segments. L is compared with the preset minimum displacement. Compare with the preset minimum longitudinal proportion; the minimum displacement and minimum longitudinal proportion are provided by the current camera configuration and cannot be replaced by obvious motion if the corresponding values ​​are not available.

[0091] The vertical axis of the image is downward. A positive value indicates that the entire foot point moves downwards, while a negative value indicates that it moves upwards. According to... The symbol determines the actual longitudinal direction of movement and is compared with the departure direction symbol configured for the current camera. Only when the two match can the direction condition be satisfied. If the value is zero or a valid direction cannot be formed, it is not considered as a consistent direction.

[0092] For the same group of valid starting and ending samples, the representative values corresponding to the heights of the detection frames are obtained respectively, and the increase or decrease of the ending height relative to the starting height is compared to obtain the actual scale change trend, which is then compared with the expected scale change sign corresponding to the leaving direction of the camera. The leaving personnel may approach or move away from the camera under different installation orientations, so the actual scale trend should be consistent with the configuration, rather than requiring the frame height to increase uniformly. When the height data is invalid or the trend does not meet the configuration requirements, the scale consistency is not judged as passed.

[0093] Read the actual valid hit count from the trajectory status and compare it with the preset trajectory quality requirements. Valid hits only include processed frames where actual detection and trajectory are successfully matched, excluding prediction retention frames; for example, when the minimum hit count is configured as 8 frames, trajectories with fewer than 8 valid hits do not meet the quality condition.

[0094] Missing segment candidates must simultaneously meet the requirements of consistent leaving direction, consistent scale change trend, total displacement reaching the minimum requirement, longitudinal displacement proportion reaching the requirement, and trajectory quality reaching the requirement before being marked as passing the restricted motion evidence judgment. Candidates that only meet one or several of the above requirements but still lack another necessary condition shall not use weighted credibility to offset the missing item. After passing, the candidate source, displacement, direction, scale trend, longitudinal proportion, hit quality and corresponding historical observations are retained for subsequent credibility calculation by source.

[0095] For complete entry candidates, complete exit candidates, and missing segment exit candidates that pass the above restricted evidence judgment, target side delay confirmation is continued. The target side of entry candidates is INNER, and the target side of exit candidates is OUTSIDE; candidates are not counted immediately when formed, but instead observe whether subsequent actual detection foot points are continuously located on the target side.

[0096] Each candidate saves the number of confirmed frames separately. In the valid processed frames after the candidate is formed, the count is accumulated when the foot point is located on the target side, and the current round of continuous confirmation is interrupted when the foot point leaves the target side or there is no valid detection foot point in this frame, and the count is restarted after the continuous condition is re-satisfied. The number of frames required for the stable area and the number of target side confirmation frames after candidate formation are maintained separately, and the number of frames already accumulated when the stable state is formed cannot be directly used to replace the delay confirmation. The example uses 4 consecutive frames of target side confirmation.

[0097] During the candidate period, continue to read the latest stable area and candidate duration. The candidate is canceled when the complete entry candidate returns to OUTSIDE or the complete exit candidate returns to INNER; if the missing segment exit candidate stably enters INNER before submission, the exit candidate is also canceled, and the count is not directly performed just because it once reached OUTSIDE. Other changes to missing segment candidates continue to comply with target side continuous confirmation and time limit requirements.

[0098] The maximum passage time is calculated from the corresponding frame time at the start of the current route; for example, if configured to be 8 seconds, candidates that have not formed a submittable event within 8 seconds will be eliminated. The reasons for turnaround cancellation, target-side confirmation interruption, and timeout elimination will be recorded respectively; candidates that have been cancelled or eliminated will no longer be included in the credibility determination based on the same old area sequence.

[0099] Candidates that have completed target-side confirmation, have not been cancelled or eliminated, and meet the corresponding route or missing segment compensation conditions are formed into a pending judgment record. This record includes camera identifier, gate number, trajectory identifier, direction of travel, source of complete or missing segment, stable area path, candidate time, target-side confirmation result, directional and scale characteristics, longitudinal displacement percentage, and effective hit quality.

[0100] The motion features required for the complete route are obtained from its existing actual observation history according to the same data definitions; features with insufficient samples are not falsified as calculated values. All quantities used for confidence correction are traceable to the historical observations of the trajectory or the current camera configuration, and historical data of the previous person's trajectory must not be used as evidence of passage for the next person.

[0101] S5. Determine the credibility of the candidate source and submit the formal event, and perform idempotency verification and update the number of people in the region.

[0102] Read the candidate routes that have passed the aforementioned necessary conditions and been confirmed by the target side, and select a base confidence level according to the candidate's source. Complete route candidates already have a stable three-region order of OUTSIDE→DOOR→INNER or INNER→DOOR→OUTSIDE, so a higher base confidence level is used; candidates with missing starting regions lacking an INNER starting state, so a lower base confidence level is used. In the example, these are set to 0.65 and 0.35 respectively.

[0103] The basic credibility and the corresponding judgment threshold are obtained from the camera configuration, and a candidate with a missing segment is not scored as a complete route simply because it has reached the OUTSIDE. For candidates with missing segments, the results in which all the aforementioned restricted compensation conditions have been met must also be retained.

[0104] Based on candidate records and the corresponding effective observation history of trajectories, consistency in motion direction, consistency in scale trend, proportion of longitudinal displacement, and trajectory hit quality are obtained. Indicative consistency is based on a comparison of the actual longitudinal motion symbol with the camera configuration in that direction of travel; consistency in scale trend is based on a comparison of the frame height change of the beginning and end samples with the corresponding expected symbol; the proportion of longitudinal displacement is calculated from the displacement of the same trajectory; and hit quality is derived from the actual detection hit records.

[0105] Each feature is configured with corresponding values ​​and normalization rules by the current camera to form feature values ​​used to correct the base score. These are then weighted and corrected according to the weights configured for the candidate source to obtain the final confidence level. Sources with missing segments have stricter requirements for direction, scale, and quality. Base scores, weights, and thresholds are not mixed between complete and missing segments. For cameras whose feature mapping functions and weights are not yet fixed, the corresponding configuration should be completed first, and then the final confidence level should be formed according to that configuration. Fixed formulas or weight combinations lacking a basis for calculation should not be used.

[0106] Each value used for correction and its weight should be recalculated from the configuration record and the current trajectory observation; when a necessary motion feature is missing, invalid, or not obtained as configured, it should not be set to be completely consistent by default and the candidate credibility should be increased accordingly. Instead, the candidate should be kept in a state of not passing the formal event judgment, and a review record should be left if necessary.

[0107] The final credibility score is compared with the threshold of the source. Only candidates that meet the threshold and are confirmed by the target side are submitted as formal events. For example, if the threshold is configured to be 0.70, the final credibility score must be no less than 0.70. Candidates that do not meet the threshold are rejected from submission or marked as UNKNOWN when the review mode is enabled. UNKNOWN is only used for review records and is not considered as formal entry or exit, nor does it update the number of participants. Candidates that are canceled, eliminated due to timeout, or fail to meet the necessary conditions for a missing segment will not become valid events again due to the final score calculation.

[0108] For candidates that meet the formal judgment criteria, a submission record is generated, containing an event identifier, camera identifier, physical gate number, entry or exit direction, frame sequence number, event time, trajectory identifier, passage number, candidate source, stable area path, final credibility, and motion characteristics. The camera identifier and gate number come from the corresponding configuration, the frame sequence number and time come from the video frame corresponding to the formal judgment, the trajectory identifier, stable path, and motion characteristics come from the same trajectory, and the passage number is used to distinguish the passage process of the trajectory at different time periods.

[0109] For the same track and the same passage, maintain the same passage number, and compare it with the submitted record using the track identifier, passage number, direction, and time window; if identified as a duplicate event, do not submit again, and do not repeatedly increase the entry or exit count. Only save the formal event after passing idempotency verification, and record the submitted status of this passage.

[0110] After submission, a preset cooldown time for events in the same direction is set for the same trajectory, approximately 0.8 seconds in the example. During the cooldown time, it is prohibited from forming a formal event in the same direction again, and this restriction is not applied to other trajectories. The area path of the submitted event is restarted from the target area: INNER after entry and OUTSIDE after exit as the starting side for the next passage. Subsequent passages must re-establish the corresponding state sequence and meet the confirmation conditions to identify true reverse passage. Formal events and cooldown states are associated with the trajectory identifier and the current passage number to prevent old sequences from being repeatedly submitted in adjacent frames.

[0111] Save the initial number of people by statistical region Cumulative number of entries Cumulative number of departures and the current number of people N, where:

[0112] ;

[0113] The initial number of participants is the number saved when this statistical period begins. The two cumulative numbers are only updated based on official events that have passed idempotency verification and have been accepted. For each entry event accepted and recorded, the cumulative entry count increases by 1. Before recording a departure event, the current number of participants is read. If the number of participants is allowed to be deducted, the cumulative departure count increases by 1 and the current number of participants is recalculated.

[0114] If the number of people eligible to leave is insufficient, the excess will not be recorded, and the reason for the exception will be recorded to prevent the current number of people from becoming negative. This exception departure record and the status of whether the count has been completed will be saved separately to avoid duplicate deductions during subsequent processing. For departure events that have been identified but not recorded, the original video judgment record and the reason for not recording will be retained; for events that have been recorded, the number of people in the area after recording will be saved. Neither type of record will repeatedly change the cumulative count by replaying the same frame or repeatedly receiving the same event. Candidates that have not been formally submitted, are UNKNOWN, or are judged as duplicates by idempotency checks will not have their number of people modified.

[0115] Each door is processed by its camera using an independent door zone polygon, installation direction, scale trend, and threshold. Formal events carry the camera identifier and physical door number. The cumulative number of entries and exits for each door is recorded separately. Then, all recorded events are aggregated according to the statistical area to which the physical door belongs. The current number of people is calculated based on the initial number of people and the cumulative number of entries and exits for the area. People entering and exiting from different doors are still included in the statistics of that area.

[0116] Formal events can be output as CSV, JSONL, database records, or business interface data, and a snapshot of the moment of judgment is saved. Person bounding boxes, footholds, three-region boundaries, trajectory numbers, travel directions, candidate sources, and credibility are overlaid on the corresponding video frames. Logs record detection, duplicate bounding box fusion, trajectory creation and loss, stable state changes, candidate generation and cancellation, timeouts, insufficient credibility, formal submissions, and minimum number of people protection. Structured event records the updated values ​​of the associated number of people for verification of travel evidence and statistical results.

[0117] Example 2: Figure 2 As shown, this embodiment provides an entry / exit statistics system based on a footpoint three-region state machine, including:

[0118] The video acquisition and door area configuration module is used to acquire industrial door area video and corresponding camera configuration captured by a fixed monocular camera. The camera configuration includes polygon coordinates, entry direction symbols and expected scale change symbols for the external area, doorway transition area and internal area. The polygon coordinates of each area are calculated according to the resolution ratio of the current video frame and the reference image. The personnel detection model is used to obtain the personnel candidate boxes, detection scores and internal labels in the current video frame to form a candidate target record.

[0119] The personnel target fusion and trajectory association module is used to receive the candidate target records, uniformly map the internal labels with personnel meaning to personnel targets, fuse duplicate candidate boxes according to the degree of intersection or the proportion of smaller boxes, predict the personnel boxes of the current frame according to the historical position and smoothing speed of the existing trajectory, perform matching gating and one-to-one trajectory association by combining the degree of overlap of the predicted boxes, the distance between foot points and the similarity of the box height, and retain unmatched trajectories within a preset short-term loss window to form a continuous personnel trajectory containing personnel foot points and historical observation records.

[0120] The foot point region determination and stable state generation module is used to receive the continuous personnel trajectory and the converted three-region polygon coordinates, determine the frame-by-frame region result according to the positional relationship between the personnel foot points and each polygon, confirm the stable region state for the same region that has reached a preset number of frames consecutively, and compress the continuously repeated stable region states to form a stable region time sequence associated with the personnel trajectory.

[0121] The passage status recognition and missing segment compensation module is used to receive the time sequence of the stable region and the corresponding historical observation records, and generate complete entry candidates or complete exit candidates according to the stable state sequence of the outside region, the doorway transition zone, and the inside region; for trajectories that first stabilize in the doorway transition zone, then stabilize in the outside region and lack the initial state inside the door, the module performs restricted compensation judgment based on the direction of movement, scale change trend, longitudinal displacement ratio, total displacement, and effective hit quality, and generates missing segment exit candidates; the module performs target-side delay confirmation, turnback cancellation, and timeout elimination on the passage candidates, and outputs passage candidates that meet the corresponding judgment conditions;

[0122] The event credibility determination and number of people update module is used to receive candidates that meet the corresponding judgment conditions. It selects different basic credibility based on the candidate source of the complete route or the missing starting area, and calculates the final credibility by combining the consistency of movement direction, scale trend consistency, longitudinal displacement ratio and trajectory hit quality. For candidates that reach the corresponding credibility threshold and are confirmed by the target side, it performs idempotency verification. After passing, it submits the formal entry and exit event, sets the same-direction event cooldown time for the corresponding trajectory, and restarts the trajectory area path from the target area. It updates the cumulative number of entries, cumulative number of exits and the current number of people in the area based on the valid entry and exit events. Abnormal exits that exceed the current number of people who can leave are not recorded and the reason is recorded. It outputs the formal passage event and the updated current number of people in the area.

[0123] Example 3: This example provides a computer program product, which includes computer program code. When the computer program code is run on a computer, the computer implements the entry and exit statistics method based on a three-region state machine of foot points as described in Example 1.

[0124] All the above formulas are performed using dimensionless numerical calculations; the relevant formulas are based on empirical models that approximate the real situation, obtained through extensive data collection and software simulation fitting. The preset parameters and thresholds involved in the formulas can be conventionally set and adjusted by those skilled in the art according to the physical constraints of the actual application scenario.

[0125] Those skilled in the art will recognize that the modules and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0126] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

[0127] In conclusion, the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A method for counting entries and exits based on a three-region state machine at the footpoint, characterized in that, Includes the following steps: S1. Obtain video and camera configuration of the industrial gate area, unify the polygon coordinates of the area outside the gate, the transition area at the gate, and the area inside the gate to the current video frame, and detect and obtain personnel candidate boxes, detection scores, and internal labels. S2. Unify the internal labels with personnel meaning to the personnel target, and merge the repeated boxes according to the degree of intersection or the proportion of smaller boxes; combine velocity prediction, prediction box overlap, foot distance and box height similarity to perform gating and one-to-one trajectory association to form continuous personnel trajectory; S3. Construct personnel foot points based on personnel frames in continuous personnel trajectories, determine the region to which the foot points belong, confirm stable regions through continuous frames and compress repetitive stable states to form stable region time sequences. S4. Generate complete entry and exit candidates based on the stable state sequence of outside the door, doorway transition, inside the door, or inside the door, doorway transition, outside the door; for trajectories that first stabilize in the doorway transition area, then stabilize outside the door and lack the initial state inside the door, perform restricted compensation based on the direction of movement, scale trend, longitudinal displacement ratio and effective hit quality to generate missing segment departure candidates. For candidates to pass through, implement target-side delayed confirmation, rollback cancellation, and timeout elimination; S5. Select different basic credibility levels based on complete or incomplete candidate sources, calculate the final credibility level by combining motion characteristics and trajectory quality, and submit the formal entry / exit event when the corresponding threshold is reached; perform idempotency verification and cooling of the same trajectory and direction on the event, and update the current number of people in the area based on the valid entry / exit events.

2. The entry / exit statistics method based on a three-region state machine at the footpoint according to claim 1, characterized in that, S1 specifically includes: Acquire video from an industrial gate area captured by a fixed monocular camera, and record the camera identification, physical gate number, frame number, frame time, and current image resolution; Based on the threshold, door frame, passable ground area and perspective direction in the camera's captured image, the polygons of the area outside the door, the transition area at the doorway, and the area inside the door are marked, and the symbols for the entry direction on the vertical axis of the image and the expected scale change symbols are configured. Based on the ratio of the current image width and height to the reference image width and height, the coordinates of each polygon vertex are converted to obtain the three region boundaries corresponding to the current video frame; Input the current video frame into the person detection model to obtain candidate bounding boxes, detection scores, and internal labels. Retain candidate targets whose detection scores reach a preset threshold to form a candidate target record containing bounding box coordinates and corresponding video frame information.

3. The entry / exit statistics method based on a three-region footpoint state machine according to claim 1, characterized in that, S2 specifically includes: Based on the personnel tag mapping table, internal tags with personnel connotations are uniformly mapped to personnel targets; Calculate the degree of intersection and union of candidate boxes of people in the same video frame and the proportion of the intersection part to the area of ​​the smaller candidate box. When either proportion reaches the corresponding threshold, merge the duplicate candidate boxes and retain the boxes with more complete spatial range, higher detection scores and original label set. Based on the historical position and smoothing speed of the existing trajectory, predict the person bounding box of the current frame, and calculate the overlap of the predicted bounding boxes, the normalized proximity of the foot point distance, and the similarity of the bounding box height.

4. The entry / exit statistics method based on a three-region footpoint state machine according to claim 3, characterized in that, S2 also includes: when the predicted bounding box meets the minimum overlap condition or the foot distance meets the dynamic distance condition determined by the target height and the number of consecutive losses, and the box height ratio is within the allowable range, perform a one-to-one association based on the joint matching score; update the observation history and motion status of the matching trajectory, and retain the unmatched trajectory within the preset short-term loss window.

5. The entry / exit statistics method based on a three-region footpoint state machine according to claim 1, characterized in that, S3 specifically includes: Based on the actual detected bounding boxes of people in the continuous trajectory, the midpoint of the bottom edge of the bounding box is taken as the foot point of the person. The position of the foot point is compared with the three-region polygon corresponding to the current video frame to determine its region. The positions of adjacent polygons that share the same edge or overlap with the doorway transition area are given priority to be determined as the doorway transition area, so that each valid foot point corresponds to a unique region result. For each person trajectory, save the candidate region, consecutive frame count, stable region status and region status sequence. If the current frame region is the same as the previous candidate region, accumulate the consecutive frame count; otherwise, start counting again. When the number of consecutive frames reaches the preset stability threshold, the corresponding stable region state is confirmed and compared with the end of the region state sequence. Only when the two are different, a new stable region state is added in chronological order to form a compressed region sequence.

6. The entry / exit statistics method based on a three-region footpoint state machine according to claim 1, characterized in that, S4 specifically includes: Complete entry candidates are generated when the outside area, the doorway transition area, and the inside area are formed sequentially according to the stable region time sequence; complete exit candidates are generated when the inside area, the doorway transition area, and the outside area are formed sequentially. For trajectories that initially stabilize in the transition zone at the doorway, then stabilize in the area outside the doorway, and lack an initial state inside the doorway, extract the midpoint of the foot points and the height of the personnel frame from the effective observations at the beginning and end, and determine the overall displacement direction, total displacement, longitudinal displacement ratio, and scale change trend. When the direction of motion and scale trend are consistent with the camera configuration, and the total displacement, longitudinal displacement ratio and effective hit count meet the corresponding requirements, a candidate for leaving the missing segment is generated. Continue to observe the target side foot point status for the candidate passage. Confirmation is completed after reaching the preset number of consecutive confirmation frames. Cancel the corresponding candidate if it returns to the starting area during the candidate period or exceeds the maximum passage time.

7. The entry / exit statistics method based on a three-region footpoint state machine according to claim 1, characterized in that, S5 specifically includes: Based on the complete route or missing starting area of ​​the candidate, the corresponding basic credibility and feature weight are selected. The basic credibility is then weighted and corrected according to the consistency of motion direction, scale trend consistency, longitudinal displacement ratio and trajectory hit quality to obtain the final credibility. For candidates that reach the corresponding credibility threshold and have been confirmed by the target side, idempotency verification is performed based on the trajectory identifier, access number, direction and time window. After passing the verification, a formal entry / exit event is submitted, and a cooldown time for the same trajectory in the same direction is set, and the trajectory area path is restarted from the target area.

8. The entry / exit statistics method based on a three-region footpoint state machine according to claim 7, characterized in that, S5 also includes: updating the cumulative number of entries and cumulative number of exits based on valid entry and exit events respectively; determining the current number of people in the area by adding the initial number of people to the cumulative number of entries and then subtracting the cumulative number of exits; and not recording abnormal exits that exceed the current number of people who can leave, and recording the reasons for such abnormal exits.

9. An entry / exit statistics system based on a three-region footpoint state machine, employing the entry / exit statistics method based on a three-region footpoint state machine as described in any one of claims 1 to 8, characterized in that, include: The module includes video acquisition and gate configuration, personnel target fusion and trajectory association, foothold area determination and stable state generation, passage status recognition and segment compensation, and event credibility determination and number of people update.

10. A computer program product, characterized in that, The computer program product includes computer program code, which, when run on a computer, enables the computer to implement the entry and exit statistics method based on a three-region state machine at a footpoint as described in any one of claims 1 to 8.