Individual identification model construction method and moving individual trajectory tracking and calibration method
The method employs deep learning and real-time video processing to address the challenges of traditional surveillance, achieving accurate and efficient individual tracking and counting in complex environments.
Patent Information
- Application Number
- CN202410999196.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-24
- Publication Date
- 2024-12-10
AI Technical Summary
Traditional video surveillance methods struggle with high false alarm rates and poor real-time performance in accurately counting and tracking the movement of individuals in complex environments, such as construction sites and logistics parks.
A method involving deep learning technology using the PP-YOLOE pre-trained model for individual recognition, combined with data preprocessing and enhancement, and real-time video stream processing to track and calibrate individual trajectories, utilizing the Kalman filter and Hungarian algorithm for trajectory association.
Enables efficient and accurate real-time tracking and counting of individuals, reducing ID exchange errors in crowded environments, with an intuitive interface for security management.
Smart Images

Figure BDA0004961089800000021 
Figure BDA0004961089800000051 
Figure BDA0004961089800000071
Abstract
Description
Technical Field
[0001] The present invention relates to the fields of computer vision and artificial intelligence, and in particular to a method for identifying and tracing the trajectory of moving individuals in a region. Background Art
[0002] With the popularization of intelligent monitoring systems, accurately and efficiently identifying and counting the number and whereabouts of moving individuals such as people or vehicles in a specific area has become an important requirement in the fields of public safety, production management, etc. Traditional video surveillance analysis methods rely on manual viewing or simple motion detection technology, which has problems such as high false alarm rate and poor real-time performance.
[0003] In large open areas such as construction sites, logistics parks and other places, there is a high mobility of people and equipment, and traditional monitoring methods cannot accurately count the number and track individual movement trajectories in real time.
[0004] In recent years, the development of deep learning technology, especially the widespread application of YOLO series algorithm models in the field of target detection, has provided a new way to solve this problem. However, how to efficiently integrate these technologies, especially the trajectory tracking of moving individuals in complex environments, still faces challenges. Summary of the invention
[0005] Purpose of the invention: The purpose of the present invention is to address the deficiencies in the prior art and first provide a method for constructing an individual recognition model, using deep learning technology to achieve efficient and accurate automated recognition of individuals.
[0006] Another object of the present invention is to provide a method and system for tracking the trajectory of a moving individual using the individual recognition model constructed by the above method.
[0007] Another object of the present invention is to provide a method and system for calibrating the trajectory of a moving individual using the individual identification model constructed by the above method.
[0008] Technical solution: In order to solve the above technical problems, the present invention first provides a method for constructing an individual recognition model, comprising the following steps:
[0009] S1, collect clear static images of moving individuals in the area;
[0010] S2, performing data preprocessing and data enhancement on the collected static images to form an image data set;
[0011] S3. Use the acquired image dataset as the input of the PP-YOLOE pre-trained model to perform model training and obtain an individual recognition model.
[0012] A further preferred technical solution of the present invention is that the static image of the moving individual in the acquisition area in step S1 is specifically obtained by:
[0013] S11, using the on-site camera to collect images of each moving individual in the area, and cleaning the images by manual screening to ensure that the selected images are clear;
[0014] S12. Use the LabelImg image annotation tool to manually annotate the individual information in each image, mark it with a rectangular box, and record the coordinates of the four corners of each rectangular box, while adding label information to define the target area.
[0015] Preferably, the step S2 performs data preprocessing and data enhancement on the collected static image to form an image data set, including:
[0016] S21, performing data preprocessing on the collected static image, specifically:
[0017] S211, according to the system processing capacity and storage requirements, configure the image scaling ratio to 0.3-1, that is, the length and width of each frame of image obtained from the camera are reduced to 0.3-1 times, balancing the processing speed and image quality;
[0018] S212, Image Enhancement: Use the Laplace operator to enhance the image. Utilize the quadratic differential of the image to calculate the discrete form of the second-order derivative for each pixel in the image. For a two-dimensional image f(x,y), the formula for enhancing the image using the Laplace operator is expressed as:
[0019]
[0020] in, represents the Laplace transform of the image f(x,y), and Represent the second-order derivatives of the image in the x and y directions respectively;
[0021] For a two-dimensional image, in discrete form, the formula is further expressed as:
[0022]
[0023] This formula describes how the Laplacian value of a pixel (x, y) is calculated from the grayscale values of its four neighboring pixels;
[0024] Among them, f(x,y) represents the grayscale value of the image at point (x,y); f(x+1,y), f(x-1,y), f(x,y+1) and f(x,y-1) represent the grayscale values of the adjacent pixels of point (x,y) in the x direction and y direction respectively. These four points constitute the "four neighborhoods" of point (x,y); -4f(x,y) represents the quadruple inversion of the grayscale value of the current pixel (x,y), which is used to make the grayscale value of the central pixel dominate the sum when calculating the Laplace value, reflecting the grayscale difference between the central pixel and its surrounding pixels.
[0025] S22, performing data enhancement on the collected static image, specifically:
[0026] Write a Python script to perform a series of transformation operations on the filtered images, including rotation, scaling, cropping, and flipping, and form an image dataset together with the original images.
[0027] Preferably, the image dataset obtained in step S3 is used as the input of the PP-YOLOE pre-training model to perform model training to obtain an individual recognition model, and the specific method is as follows:
[0028] S31, dividing the enhanced data set into a training set, a validation set and a test set;
[0029] S32, loading the prepared image data set, including the processed images and the corresponding individual information annotated therein;
[0030] S33, carefully configure fine-tuning parameters, set learning rate, batch size, and number of training rounds;
[0031] S34. Import the PP-YOLOE pre-trained model and its weights as the starting point for fine-tuning, and use the Python training script to start the fine-tuning training process;
[0032] S35. After training, use the validation set to comprehensively evaluate the model performance, focusing on the accuracy AP and recall AR;
[0033] S36. According to the evaluation results, adjust the learning rate, increase the number of training rounds or supplement sample data, and repeat steps S33 to S35 until the model performance meets the preset standards and the training is completed.
[0034] Another aspect of the present invention provides a method for tracking a moving individual trajectory, comprising the following steps:
[0035] S4, using the camera in the area to obtain video stream data in real time, and decode the real-time video stream to obtain each frame of image data from the camera;
[0036] S5. Perform individual recognition detection on the current frame image according to the individual recognition model trained according to any one of claims 1 to 4, and obtain the position coordinates and confidence level of each detected individual;
[0037] S6, predicting the motion trajectory of the individual in the current frame according to the individual's position coordinates and confidence, and updating the state of the corresponding motion trajectory with the individual's new position information;
[0038] S7. Repeat the process of S4 to S6 to achieve real-time detection and trajectory tracking of all moving individuals in the area, and output individual trajectory data.
[0039] Preferably, the step S4 uses a camera in the area to obtain video stream data in real time, and decodes the real-time video stream to obtain each frame of image data from the camera, specifically:
[0040] S41, acquiring video stream data from various types of surveillance cameras (such as IP cameras, network cameras, etc.) in real time;
[0041] S42, receiving video streams through standard network protocols (RTSP, RTMP) and ensuring the continuity and real-time nature of data;
[0042] S43, using GPU to hard decode the real-time video stream of the camera to obtain each frame of image data of the camera;
[0043] S44, performing data preprocessing on each frame of image data.
[0044] Preferably, step S42 receives the video stream through a standard network protocol (RTSP, RTMP) and ensures the continuity and real-time nature of the data, specifically including, in the data acquisition module, a built-in network monitoring mechanism to automatically detect and handle abnormal situations such as network interruption and camera failure;
[0045] The network monitoring mechanism includes:
[0046] (1) Network status detection:
[0047] The mechanism will detect the network connection status in real time, including key indicators such as network bandwidth, latency, packet loss rate, etc. These detection results help to determine the stability and reliability of the network connection. If a network anomaly is found (such as network interruption, high latency, severe packet loss, etc.), the monitoring mechanism will immediately trigger the corresponding alarm to ensure the continuity of data collection.
[0048] (2) Camera status monitoring:
[0049] In addition to the network status, the mechanism also monitors the status of the surveillance cameras connected to the system, including the online status of the cameras, the quality of the video stream transmission, etc. If the camera fails or the video stream transmission is abnormal (such as video interruption, blurred picture, etc.), the monitoring mechanism will record it in time and notify the relevant personnel to handle it.
[0050] (3)Exception handling and recovery:
[0051] When a network or camera anomaly is detected, the built-in network monitoring mechanism will attempt to automatically restore the connection or switch to a backup camera to minimize the interruption time of data collection. If the automatic recovery fails, the mechanism will generate a detailed anomaly report and notify the system administrator or relevant technicians for manual intervention and processing.
[0052] (4) Log recording and analysis:
[0053] This mechanism will record all network activities related to data collection, camera status, and log information of exception handling. These log information are of great reference value for subsequent troubleshooting, performance analysis, and system optimization.
[0054] (5) Configurability and flexibility:
[0055] The built-in network monitoring mechanism supports flexible configuration options, allowing users to adjust monitoring parameters and exception handling strategies according to actual needs. This enables the mechanism to be applied to different network environments and monitoring scenarios, improving the adaptability and availability of the system.
[0056] Preferably, the step S44 performs data preprocessing on each frame of image data, specifically:
[0057] S441. According to the system processing capability and storage requirements, the image scaling ratio is configured to be 0.3 to 1, that is, the length and width of each frame of image obtained from the camera are reduced to 0.3 to 1 times to balance the processing speed and image quality;
[0058] S442, Image Enhancement: Use the Laplace operator to enhance the image. Utilize the quadratic differential of the image to calculate the discrete form of the second-order derivative for each pixel in the image. For a two-dimensional image f(x,y), the formula for enhancing the image using the Laplace operator is expressed as:
[0059]
[0060] in, represents the Laplace transform of the image f(x,y), and Represent the second-order derivatives of the image in the x and y directions respectively;
[0061] For a two-dimensional image, in discrete form, the formula is further expressed as:
[0062]
[0063] This formula describes how the Laplacian value of a pixel (x, y) is calculated from the grayscale values of its four neighboring pixels;
[0064] Among them, f(x,y) represents the grayscale value of the image at point (x,y); f(x+1,y), f(x-1,y), f(x,u+1) and f(x,y-1) represent the grayscale values of the adjacent pixels of point (x,y) in the x direction and y direction respectively. These four points constitute the "four neighborhoods" of point (x,y); -4f(x,y) represents the quadruple inversion of the grayscale value of the current pixel (x,y), which is used to make the grayscale value of the central pixel dominate the sum when calculating the Laplace value, reflecting the grayscale difference between the central pixel and its surrounding pixels.
[0065] Preferably, in step S6, the motion trajectory of the individual in the current frame is predicted based on the position coordinates and confidence of the individual, and the state of the corresponding motion trajectory is updated with the new position information of the individual; the specific method is:
[0066] S61, after obtaining the position coordinates and confidence of each detected individual, associate the targets. For each existing trajectory, use the Kalman filter to predict the position of the target in the current frame, and associate the detected target with the predicted trajectory by calculating the intersection over union (IoU) between the detected target and the predicted target. Use the Hungarian algorithm to assign a most likely trajectory to each detected target, or create a new trajectory for a new target.
[0067] S62. For the successfully associated individuals, the new position information detected by the individuals is used to update the status of the corresponding tracks, including the position, speed and acceleration. If a track is not successfully associated with the detected target in multiple consecutive frames, it is considered that the track has ended and the individual has left the current screen, and the track is removed from the tracker.
[0068] Another aspect of the present invention provides a system for tracking a moving individual trajectory, comprising:
[0069] The image acquisition module is used to acquire video stream data in real time using the camera in the area, and decode the real-time video stream to obtain each frame of image data from the camera;
[0070] An individual recognition module, used to perform individual recognition detection on the current frame image according to the individual recognition model trained according to any one of claims 1 to 4, and obtain the position coordinates and confidence level of each detected individual;
[0071] The trajectory calculation module is used to predict the motion trajectory of the individual in the current frame based on the individual's position coordinates and confidence, and update the state of the corresponding motion trajectory with the individual's new position information;
[0072] The trajectory output module is used to output the unique identification, current location and historical trajectory information of each individual's activity trajectory.
[0073] The present invention also provides a method for calibrating a moving individual trajectory, comprising the following steps:
[0074] S8. Calibrate the camera in the area and establish a mapping relationship between the camera coordinate system and the front-end canvas coordinate system;
[0075] S9. Map the individual trajectory data outputted in claim 5 to the front-end canvas according to the mapping relationship between the camera coordinate system and the front-end canvas coordinate system established in step S8.
[0076] Preferably, the camera in the area is calibrated in step S8 to establish a mapping relationship between the camera coordinate system and the front-end canvas coordinate system. The specific method is as follows:
[0077] S81. First, a quadrilateral area is selected in the camera image as the activity range of the moving individual. The quadrilateral area should clearly cover all areas where the moving individual may move, while avoiding unnecessary interference in the background. In the camera image, the pixel coordinates of the four vertices of the selected quadrilateral are accurately recorded;
[0078] S82. Design the layout inside the front-end canvas according to the display requirements, map the quadrilateral area in the camera image to the rectangular area on the front-end canvas, and record the coordinates of the four vertices of the selected rectangle;
[0079] S83, construct a perspective transformation matrix, using the four vertex pixel coordinates of the quadrilateral area of the camera screen and the four vertex coordinates of the corresponding rectangle on the front-end canvas, and construct a perspective transformation matrix through a perspective transformation algorithm:
[0080]
[0081] Where QX and QX represent the vertex coordinates in the front-end canvas coordinate system, PX and PY represent the pixel coordinates of the quadrilateral vertices in the camera image, and M 0 represents the required transformation matrix, and min represents the minimum value, that is, when the left side of the equation is derived to calculate the minimum value, the corresponding M 0 The value of is the required transformation matrix.
[0082] Preferably, in step S9, the individual trajectory data is mapped to the front-end canvas by:
[0083] S91, apply perspective transformation, for each detected trajectory point, use the perspective transformation matrix M calculated previously 0 Transform it from the pixel coordinate system of the camera image to the coordinate system of the front-end canvas using the formula:
[0084]
[0085] Among them, PX i , PY i Indicates the pixel coordinates of the person in the camera image, QX i , QY i Indicates the corresponding coordinates in the canvas;
[0086] S92, drawing trajectories, on the front-end canvas, drawing the trajectories of the moving individuals according to the mapped coordinate points, and using different colors and line types to distinguish the trajectories of different individuals;
[0087] S93, realizing the interaction function between the user and the track, including clicking the track to view detailed information and zooming the canvas to view the track in different areas;
[0088] S94. Perform dynamic update to update the trajectory information on the canvas in real time to reflect the latest position and movement of the person in the camera image.
[0089] Another aspect of the present invention provides a system for calibrating a moving individual trajectory, comprising:
[0090] Several cameras arranged in the area, a front-end canvas arranged in the monitoring room, and a trajectory calibration module;
[0091] The track marking module is used to calibrate the camera in the area and establish a mapping relationship between the camera coordinate system and the front-end canvas coordinate system;
[0092] And using the established coordinate system mapping relationship, the individual trajectory data output by claim 5 is mapped to the front-end canvas.
[0093] Beneficial effects: The present invention first obtains an individual recognition model by training the pre-trained PP-YOLOE algorithm model loaded through the PaddlePaddle framework, and uses deep learning technology to achieve efficient and accurate automatic recognition of individuals; then obtains real-time monitoring video from the camera in the designated area, performs target detection on the frame image of the real-time video, and identifies the location of all personnel. Subsequently, the algorithm is used to match the personnel targets between consecutive frames to generate accurate personnel trajectories. The system interface displays the number of personnel statistics and dynamic trajectory diagrams in real time, providing intuitive data support for security management.
[0094] This invention integrates the advanced technologies of PaddlePaddle and PP-YOLOE algorithms, and adjusts the PP-YOLOE algorithm model on the PaddlePaddle platform. For complex environments in open areas, such as lighting changes and occlusions, the versatility and accuracy of target detection are improved through model optimization and feature enhancement technology. This provides a comprehensive and efficient solution for monitoring personnel operations in open areas, which has important practical value and market potential.
[0095] The present invention develops an adaptive tracking algorithm to ensure accurate identification of individuals in crowded and frequently crossing situations, thus reducing ID exchange errors. The intuitive interactive interface is designed so that users can view the distribution heat map of personnel in the monitored area, the real-time number of personnel, and personnel trajectory animation in real time. It is suitable for personnel management and security monitoring in open areas such as construction sites, logistics parks, and large event venues, as well as any scenario that requires real-time monitoring and analysis of personnel dynamics. DETAILED DESCRIPTION
[0096] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings in the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments, and they should not be understood as limitations on the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention. In the description of the present invention, it should be understood that the terms used are only for descriptive purposes and cannot be understood as indicating or implying relative importance.
[0097] The following describes in detail the method for constructing an individual recognition model, and the method for tracking and calibrating the trajectory of a moving individual provided by the present invention in conjunction with specific embodiments.
[0098] First of all, it should be noted that the present invention is aimed at all moving individuals in a fixed area, including and limited to people, vehicles, equipment, etc. In order to explain the technical solution of the present invention in detail in the following embodiments, the number and whereabouts of people in a specific area are counted as an example. However, the implementation process of other moving individuals is basically the same as that of the following embodiments, and they all fall within the scope of protection of the present invention.
[0099] Embodiment 1: This embodiment provides a method for constructing an individual recognition model, comprising the following steps:
[0100] S1, collect clear static images of moving individuals in the area;
[0101] S2, performing data preprocessing and data enhancement on the collected static images to form an image data set;
[0102] S3. Use the acquired image dataset as the input of the PP-YOLOE pre-trained model to perform model training and obtain an individual recognition model.
[0103] It should be noted that the area in step S1 refers to a fixed activity place of the person to be identified, such as a construction site, a logistics park, etc.
[0104] Furthermore, the static image of the moving individual in the acquisition area in step S1 is specifically acquired by:
[0105] S11. Collect personnel images in jpg format from the on-site camera, and clean the images by manual screening to ensure that the selected images are clear;
[0106] S12. Use the LabelImg image annotation tool to manually annotate the person information in each image, mark it with a rectangular box, and record the four corner coordinates of each rectangular box (stored in json format), and attach label information to accurately define the target area.
[0107] Furthermore, step S2 performs data preprocessing and data enhancement on the collected static images to form an image data set, including:
[0108] S21, performing data preprocessing on the collected static image, specifically:
[0109] S211. According to the system processing capability and storage requirements, in the algorithm inference service, the image scaling ratio is configured to 0.5, that is, the length and width of each frame of image obtained from the camera are reduced to 0.5 times to balance the processing speed and image quality;
[0110] S212, Image Enhancement: Use the Laplace operator to enhance the image. This method mainly uses the second-order differential of the image to calculate the discrete form of the second-order derivative of each pixel in the image, so as to highlight the edges and details in the image and make the image clearer. For a two-dimensional image f(x,y), the formula for Laplace operator enhancement can be expressed as:
[0111]
[0112] in, represents the Laplace transform of the image f(x,y), and Represent the second-order derivatives of the image in the x and y directions respectively;
[0113] For a two-dimensional image, in discrete form, the formula is further expressed as:
[0114]
[0115] This formula describes how the Laplacian value of a pixel (x, y) is calculated from the grayscale values of its four neighboring pixels;
[0116] Among them, f(x,y) represents the grayscale value of the image at point (x,y); f(x+1,y), f(x-1,y), f(x,y+1) and f(x,y-1) represent the grayscale values of the adjacent pixels of point (x,y) in the x direction and y direction respectively. These four points constitute the "four neighborhoods" of point (x,y); -4f(x,y) represents the quadruple inversion of the grayscale value of the current pixel (x,y). It is used to make the grayscale value of the central pixel dominate the sum when calculating the Laplace value, reflecting the grayscale difference between the central pixel and its surrounding pixels;
[0117] Indicates the Laplace value at the point (x, y), which reflects the intensity of the grayscale change at that point. In the edge or detail area, the grayscale value changes sharply, so the Laplace value is larger; while in the smooth area, the grayscale value changes less, and the Laplace value is also smaller.
[0118] S22, performing data enhancement on the collected static image, specifically:
[0119] By writing Python scripts, a series of transformation operations are performed on the filtered image set, including rotation, scaling, cropping, and flipping, aiming to expand the diversity and coverage of the data set, thereby improving the model's adaptability to new samples.
[0120] Furthermore, the image dataset obtained in step S3 is used as the input of the PP-YOLOE pre-training model to perform model training to obtain an individual recognition model. The specific method is as follows:
[0121] S31, dividing the enhanced data set into a training set, a validation set, and a test set in a ratio of 6:2:2;
[0122] S32, load the prepared image dataset, including the processed jpg image and its corresponding json annotation file;
[0123] S33, carefully configure the fine-tuning parameters, set the learning rate to 0.00125, adjust the batch size to 4, and set the number of training rounds to 300 rounds to ensure that the training process is both efficient and stable;
[0124] S34. Import the PP-YOLOE pre-trained model and its weights as the starting point for fine-tuning. Use the Python training script to start the fine-tuning training process on a high-performance GPU server, making full use of hardware resources to accelerate the training process.
[0125] S35. After the training is completed, the validation set is used to comprehensively evaluate the model performance, focusing on the accuracy AP and recall AR. In this embodiment, the average mAP and mAR of the intersection over union (IoU) ratio of the target detection real box and the predicted box in the range of 0.50:0.95 are used as performance evaluation indicators;
[0126] S36. According to the evaluation results, flexibly adjust the learning rate, increase the number of training rounds or supplement sample data, and repeat steps S6 to S8 until the model performance (such as mAP and mAR both reach or exceed 0.85) meets the preset standards, indicating that the training is completed.
[0127] Embodiment 2: This embodiment provides a method for tracking the trajectory of a moving individual, comprising the following steps:
[0128] S4, using the camera in the area to obtain video stream data in real time, and decode the real-time video stream to obtain each frame of image data from the camera; specifically:
[0129] S41, acquiring video stream data from various types of surveillance cameras (such as IP cameras, network cameras, etc.) in real time;
[0130] S42, receiving video streams through standard network protocols (RTSP, RTMP) and ensuring the continuity and real-time nature of data;
[0131] S43, using GPU to hard decode the real-time video stream of the camera to obtain each frame of image data of the camera;
[0132] S44, performing data preprocessing on each frame of image data.
[0133] S5. Perform individual recognition detection on the current frame image using the individual recognition model trained by the individual recognition model construction method described above, and obtain the position coordinates and confidence level of each detected individual;
[0134] S6. Predict the motion trajectory of the individual in the current frame based on the individual's position coordinates and confidence, and update the state of the corresponding motion trajectory with the individual's new position information; the specific method is:
[0135] S61, after obtaining the position coordinates and confidence of each detected individual, associate the targets. For each existing trajectory, use the Kalman filter to predict the position of the target in the current frame, and associate the detected target with the predicted trajectory by calculating the intersection over union (IoU) between the detected target and the predicted target. Use the Hungarian algorithm to assign a most likely trajectory to each detected target, or create a new trajectory for a new target.
[0136] S62. For the successfully associated individuals, the new position information detected by the individuals is used to update the status of the corresponding tracks, including the position, speed and acceleration. If a track is not successfully associated with the detected target in multiple consecutive frames, it is considered that the track has ended and the individual has left the current screen, and the track is removed from the tracker.
[0137] S7. Repeat the process of S4 to S6 to achieve real-time detection and trajectory tracking of all moving individuals in the area, and output individual trajectory data.
[0138] Furthermore, in step S42, when collecting data, a network monitoring mechanism is built in to automatically detect and handle abnormal situations such as network interruption and camera failure; the network monitoring mechanism includes:
[0139] (1) Network status detection:
[0140] The mechanism will detect the network connection status in real time, including key indicators such as network bandwidth, latency, packet loss rate, etc. These detection results help to determine the stability and reliability of the network connection. If a network anomaly is found (such as network interruption, high latency, severe packet loss, etc.), the monitoring mechanism will immediately trigger the corresponding alarm to ensure the continuity of data collection.
[0141] (2) Camera status monitoring:
[0142] In addition to the network status, the mechanism also monitors the status of the surveillance cameras connected to the system, including the online status of the cameras, the quality of the video stream transmission, etc. If the camera fails or the video stream transmission is abnormal (such as video interruption, blurred picture, etc.), the monitoring mechanism will record it in time and notify the relevant personnel to handle it.
[0143] (3)Exception handling and recovery:
[0144] When a network or camera anomaly is detected, the built-in network monitoring mechanism will attempt to automatically restore the connection or switch to a backup camera to minimize the interruption time of data collection. If the automatic recovery fails, the mechanism will generate a detailed anomaly report and notify the system administrator or relevant technicians for manual intervention and processing.
[0145] (4) Log recording and analysis:
[0146] This mechanism will record all network activities related to data collection, camera status, and log information of exception handling. These log information are of great reference value for subsequent troubleshooting, performance analysis, and system optimization.
[0147] (5) Configurability and flexibility:
[0148] The built-in network monitoring mechanism supports flexible configuration options, allowing users to adjust monitoring parameters and exception handling strategies according to actual needs. This enables the mechanism to be applied to different network environments and monitoring scenarios, improving the adaptability and availability of the system.
[0149] Furthermore, step S44 performs data preprocessing on each frame of image data, specifically:
[0150] S441. According to the system processing capability and storage requirements, the image scaling ratio is configured to be 0.3 to 1, that is, the length and width of each frame of image obtained from the camera are reduced to 0.3 to 1 times to balance the processing speed and image quality;
[0151] S442, Image Enhancement: Use the Laplace operator to enhance the image. Utilize the quadratic differential of the image to calculate the discrete form of the second-order derivative for each pixel in the image. For a two-dimensional image f(x,y), the formula for enhancing the image using the Laplace operator is expressed as:
[0152]
[0153] in, represents the Laplace transform of the image f(x,y), and Represent the second-order derivatives of the image in the x and y directions respectively;
[0154] For a two-dimensional image, in discrete form, the formula is further expressed as:
[0155]
[0156] This formula describes how the Laplacian value of a pixel (x, y) is calculated from the grayscale values of its four neighboring pixels;
[0157] Among them, f(x,y) represents the grayscale value of the image at point (x,y); f(x+1,y), f(x-1,y), f(x,y+1) and f(x,y-1) represent the grayscale values of the adjacent pixels of point (x,y) in the x direction and y direction respectively. These four points constitute the "four neighborhoods" of point (x,y); -4f(x,y) represents the quadruple inversion of the grayscale value of the current pixel (x,y), which is used to make the grayscale value of the central pixel dominate the sum when calculating the Laplace value, reflecting the grayscale difference between the central pixel and its surrounding pixels.
[0158] Embodiment 3: This embodiment provides a system for tracking the trajectory of a moving individual, including:
[0159] The image acquisition module is used to acquire video stream data in real time using the camera in the area, and decode the real-time video stream to obtain each frame of image data from the camera;
[0160] An individual recognition module is used to perform individual recognition detection on the current frame image according to the individual recognition model trained by the individual recognition model construction method, and obtain the position coordinates and confidence level of each detected individual;
[0161] The trajectory calculation module is used to predict the motion trajectory of the individual in the current frame based on the individual's position coordinates and confidence, and update the state of the corresponding motion trajectory with the individual's new position information;
[0162] The trajectory output module is used to output the unique identification, current location and historical trajectory information of each individual's activity trajectory.
[0163] Embodiment 4: This embodiment provides a method for calibrating a moving individual trajectory, comprising the following steps:
[0164] S8. Calibrate the camera in the area and establish a mapping relationship between the camera coordinate system and the front-end canvas coordinate system. The specific method is as follows:
[0165] S81. First, a quadrilateral area is selected in the camera image as the activity range of the moving individual. The quadrilateral area should clearly cover all areas where the moving individual may move, while avoiding unnecessary interference in the background. In the camera image, the pixel coordinates of the four vertices of the selected quadrilateral are accurately recorded;
[0166] S82. Design the layout inside the front-end canvas according to the display requirements, map the quadrilateral area in the camera image to the rectangular area on the front-end canvas, and record the coordinates of the four vertices of the selected rectangle;
[0167] S83, construct a perspective transformation matrix, using the four vertex pixel coordinates of the quadrilateral area of the camera screen and the four vertex coordinates of the corresponding rectangle on the front-end canvas, and construct a perspective transformation matrix through a perspective transformation algorithm:
[0168]
[0169] Where QX and QX represent the vertex coordinates in the front-end canvas coordinate system, PX and PY represent the pixel coordinates of the quadrilateral vertices in the camera image, and M 0 represents the required transformation matrix, and min represents the minimum value, that is, when the left side of the equation is derived to calculate the minimum value, the corresponding M 0 The value of is the required transformation matrix.
[0170] S9, according to the mapping relationship between the camera coordinate system and the front-end canvas coordinate system established in step S8, the individual trajectory data output by the above-mentioned individual motion trajectory tracking method is mapped to the front-end canvas; the specific method is:
[0171] S91, apply perspective transformation, for each detected trajectory point, use the perspective transformation matrix M calculated previously 0 Transform it from the pixel coordinate system of the camera image to the coordinate system of the front-end canvas using the formula:
[0172]
[0173] Among them, PX i , PY i Indicates the pixel coordinates of the person in the camera image, QX i , QY i Indicates the corresponding coordinates in the canvas;
[0174] S92, drawing trajectories, on the front-end canvas, drawing the trajectories of the moving individuals according to the mapped coordinate points, and using different colors and line types to distinguish the trajectories of different individuals;
[0175] S93, realizing the interaction function between the user and the track, including clicking the track to view detailed information and zooming the canvas to view the track in different areas;
[0176] S94. Perform dynamic update to update the trajectory information on the canvas in real time to reflect the latest position and movement of the person in the camera image.
[0177] Embodiment 5: This embodiment provides a system for calibrating a moving individual trajectory, including:
[0178] Several cameras arranged in the area, a front-end canvas arranged in the monitoring room, and a trajectory calibration module;
[0179] The track marking module is used to calibrate the camera in the area and establish a mapping relationship between the camera coordinate system and the front-end canvas coordinate system;
[0180] And by using the established coordinate system mapping relationship, the individual trajectory data output by the above-mentioned motion individual trajectory tracking method is mapped to the front-end canvas.
[0181] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Those of ordinary skill in the art may understand and implement it without creative effort.
[0182] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0183] As described above, although the present invention has been shown and described with reference to specific preferred embodiments, it should not be construed as limiting the present invention itself. Various changes in form and details may be made without departing from the spirit and scope of the present invention as defined in the appended claims.
Claims
1. A method for constructing an individual identification model, characterized in that: The steps include: S1, collect clear static images of moving individuals in the area; S2, performing data preprocessing and data enhancement on the collected static images to form an image data set; S3. Use the acquired image dataset as the input of the PP-YOLOE pre-trained model to perform model training and obtain an individual recognition model.
2. The method for constructing an individual identification model according to claim 1, characterized in that: The specific method of collecting static images of moving individuals in the area in step S1 is as follows: S11, using the on-site camera to collect images of each moving individual in the area, and cleaning the images by manual screening to ensure that the selected images are clear; S12. Use the LabelImg image annotation tool to manually annotate the individual information in each image, mark it with a rectangular box, and record the coordinates of the four corners of each rectangular box, while adding label information to define the target area.
3. The method for constructing an individual identification model according to claim 2, characterized in that: Step S2 performs data preprocessing and data enhancement on the collected static images to form an image data set, including: S21, performing data preprocessing on the collected static image, specifically: S211. According to the system processing capability and storage requirements, the image scaling ratio is configured to be 0.3 to 1, that is, the length and width of each frame of image obtained from the camera are reduced to 0.3 to 1 times to balance the processing speed and image quality; S212, Image Enhancement: Use the Laplace operator to enhance the image. Utilize the quadratic differential of the image to calculate the discrete form of the second-order derivative for each pixel in the image. For a two-dimensional image f(x,y), the formula for enhancing the image using the Laplace operator is expressed as: in, represents the Laplace transform of the image f(x,y), and Represent the second-order derivatives of the image in the x and y directions respectively; For a two-dimensional image, in discrete form, the formula is further expressed as: This formula describes how the Laplacian value of a pixel (x, y) is calculated from the grayscale values of its four neighboring pixels; Among them, f(x,y) represents the grayscale value of the image at point (x,y); f(x+1,y), f(x-1,y), f(x,y+1) and f(x,y-1) represent the grayscale values of the adjacent pixels of point (x,y) in the x direction and y direction respectively. These four points constitute the "four neighborhoods" of point (x,y); -4f(x,y) represents the quadruple inversion of the grayscale value of the current pixel (x,y). It is used to calculate the Laplace value. The grayscale value of the central pixel occupies a dominant position in the sum, reflecting the grayscale difference between the central pixel and its surrounding pixels. S22, performing data enhancement on the collected static image, specifically: Write a Python script to perform a series of transformation operations on the filtered images, including rotation, scaling, cropping, and flipping, and form an image dataset together with the original images.
4. The method for constructing an individual identification model according to claim 1, characterized in that: The image dataset obtained in step S3 is used as the input of the PP-YOLOE pre-training model to perform model training to obtain an individual recognition model. The specific method is as follows: S31, dividing the enhanced data set into a training set, a validation set and a test set; S32, loading the prepared image data set, including the processed images and the corresponding individual information annotated therein; S33, carefully configure fine-tuning parameters, set learning rate, batch size, and number of training rounds; S34. Import the PP-YOLOE pre-trained model and its weights as the starting point for fine-tuning, and use the Python training script to start the fine-tuning training process; S35. After training, use the validation set to comprehensively evaluate the model performance, focusing on the accuracy AP and recall AR; S36. According to the evaluation results, adjust the learning rate, increase the number of training rounds or supplement sample data, and repeat steps S33 to S35 until the model performance meets the preset standards and the training is completed.
5. A method for tracking the trajectory of a moving individual, characterized in that: The steps include: S4, using the camera in the area to obtain video stream data in real time, and decode the real-time video stream to obtain each frame of image data from the camera; S5. Perform individual recognition detection on the current frame image according to the individual recognition model trained according to any one of claims 1 to 4, and obtain the position coordinates and confidence level of each detected individual; S6, predicting the motion trajectory of the individual in the current frame according to the individual's position coordinates and confidence, and updating the state of the corresponding motion trajectory with the individual's new position information; S7. Repeat the process of S4 to S6 to achieve real-time detection and trajectory tracking of all moving individuals in the area, and output individual trajectory data.
6. The method for tracking the trajectory of a moving individual according to claim 5, characterized in that: Step S6 predicts the motion trajectory of the individual in the current frame based on the individual's position coordinates and confidence, and updates the state of the corresponding motion trajectory with the individual's new position information; the specific method is: S61, after obtaining the position coordinates and confidence of each detected individual, associate the targets. For each existing trajectory, use the Kalman filter to predict the position of the target in the current frame, and associate the detected target with the predicted trajectory by calculating the intersection over union (IoU) between the detected target and the predicted target. Use the Hungarian algorithm to assign a most likely trajectory to each detected target, or create a new trajectory for a new target. S62. For the successfully associated individuals, the new position information detected by the individuals is used to update the status of the corresponding tracks, including the position, speed and acceleration. If a track is not successfully associated with the detected target in multiple consecutive frames, it is considered that the track has ended and the individual has left the current screen, and the track is removed from the tracker.
7. A system for tracking the trajectory of a moving individual, characterized in that: include: The image acquisition module is used to acquire video stream data in real time using the camera in the area, and decode the real-time video stream to obtain each frame of image data from the camera; An individual recognition module, used to perform individual recognition detection on the current frame image according to the individual recognition model trained according to any one of claims 1 to 4, and obtain the position coordinates and confidence level of each detected individual; The trajectory calculation module is used to predict the motion trajectory of the individual in the current frame based on the individual's position coordinates and confidence, and update the state of the corresponding motion trajectory with the individual's new position information; The trajectory output module is used to output the unique identification, current location and historical trajectory information of each individual's activity trajectory.
8. A method for calibrating a moving individual trajectory, characterized in that: The steps include: S8. Calibrate the camera in the area and establish a mapping relationship between the camera coordinate system and the front-end canvas coordinate system; S9. Map the individual trajectory data outputted in claim 5 to the front-end canvas according to the mapping relationship between the camera coordinate system and the front-end canvas coordinate system established in step S8.
9. The method for calibrating the trajectory of a moving individual according to claim 11, characterized in that: The camera calibration of the camera in the area described in step S8 is to establish a mapping relationship between the camera coordinate system and the front-end canvas coordinate system. The specific method is: S81. First, a quadrilateral area is selected in the camera image as the activity range of the moving individual. The quadrilateral area should clearly cover all areas where the moving individual may move, while avoiding unnecessary interference in the background. In the camera image, the pixel coordinates of the four vertices of the selected quadrilateral are accurately recorded; S82. Design the layout inside the front-end canvas according to the display requirements, map the quadrilateral area in the camera image to the rectangular area on the front-end canvas, and record the coordinates of the four vertices of the selected rectangle; S83, construct a perspective transformation matrix, using the four vertex pixel coordinates of the quadrilateral area of the camera screen and the four vertex coordinates of the corresponding rectangle on the front-end canvas, and construct a perspective transformation matrix through a perspective transformation algorithm: Where QX and QX represent the vertex coordinates in the front-end canvas coordinate system, PX and PY represent the pixel coordinates of the quadrilateral vertices in the camera image, M0 represents the required transformation matrix, and min represents the minimum value. That is, when the derivative on the left side of the equation calculates the minimum value, the corresponding M0 value is the required transformation matrix. In step S9, the individual trajectory data is mapped to the front-end canvas, and the specific method is as follows: S91, apply perspective transformation. For each detected trajectory point, use the perspective transformation matrix M0 calculated previously to transform it from the pixel coordinate system of the camera image to the coordinate system of the front-end canvas. The formula is: Among them, PX i , PY i Indicates the pixel coordinates of the person in the camera image, QX i , QY i Indicates the corresponding coordinates in the canvas; S92, drawing trajectories, on the front-end canvas, drawing the trajectories of the moving individuals according to the mapped coordinate points, and using different colors and line types to distinguish the trajectories of different individuals; S93, realizing the interaction function between the user and the track, including clicking the track to view detailed information and zooming the canvas to view the track in different areas; S94. Perform dynamic update to update the trajectory information on the canvas in real time to reflect the latest position and movement of the person in the camera image.
10. A system for calibrating a moving individual trajectory, characterized in that: include: Several cameras arranged in the area, a front-end canvas arranged in the monitoring room, and a trajectory calibration module; The track marking module is used to calibrate the camera in the area and establish a mapping relationship between the camera coordinate system and the front-end canvas coordinate system; And using the established coordinate system mapping relationship, the individual trajectory data output by claim 5 is mapped to the front-end canvas.
