Home behavior identification method for old people

Through network cameras and computer vision technology, combined with face and target recognition, it solves the problem of difficult monitoring of the elderly's behavior at home, achieves detailed identification and recording of the elderly's behavior, and improves the safety of remote monitoring.

CN118692140APending Publication Date: 2024-09-24HARBIN INST OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410698098.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-31
Publication Date
2024-09-24

AI Technical Summary

Technical Problem

It is difficult to accurately monitor the daily behavior of the elderly in the home environment, resulting in health and safety risks. Existing technology cannot meet the needs of fine-grained behavior recognition, especially when the elderly are empty nesters or have no one to care for them.

Method used

Capture images of the elderly through web cameras, combine face recognition, target detection and action recognition technology, use MTCNN, FaceNet, YOLOv5, DeepSORT and SlowFast models to perform facial feature extraction, target tracking and action classification, combined with scene item coincidence calculation , to achieve more detailed behavior recognition and recording.

Benefits of technology

It realizes real-time monitoring and long-term recording of the elderly's home behavior, provides a basis for remote monitoring, improves the accuracy and fine-grainedness of identifying the elderly's behavior, and enhances safety and security.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118692140A
    Figure CN118692140A
Patent Text Reader

Abstract

The invention discloses a home behavior recognition method for old people. The method comprises the following steps: step 1, preparing a face database; 2, collecting video data; step 3, face recognition; step 4, target identification; 5, performing action recognition; 6, introducing a scene to obtain a specific behavior; 7, associating the identity with the behavior; and 8, storing the specific behavior information. According to the invention, image capture is carried out on behaviors of old people through a network camera by means of the Internet of Things technology, human face and behavior analysis is carried out by using the computer vision technology, and images possibly containing multiple persons are converted into behaviors of designated persons to be output. The determination of the identity of the person and the recording of the behavior lay a foundation for subsequent daily behavior process extraction, abnormal behavior detection and the like of the elderly, and a remote monitoring system for the elderly can be perfected.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of information technology and relates to a method for identifying the behavior of the elderly at home, and specifically to an identification method for capturing images of the elderly at home through a network camera to judge and record their behavior. Background Art

[0002] With the continuous improvement of medical technology and health level, the average life expectancy of the elderly has gradually increased. At the same time, the social fertility rate has been declining year by year, resulting in an increasingly serious aging population. At the same time, the number of empty-nest elderly people is also increasing. It is difficult for empty-nest elderly people or elderly people without anyone to take care of them at all times to accurately retell their daily behavior, which makes it difficult for their children or support groups to clearly understand the daily behavior of the elderly, which is prone to health and safety risks. At the same time, due to the fine-grained semantics of the elderly's daily behavior, simple action distinction records are also difficult to meet the needs of guardianship.

[0003] Home-based elderly care is a traditional elderly care model in my country. When the caregivers cannot always take care of the elderly due to work and other reasons, how to remotely monitor the elderly, especially the empty-nest elderly, is the key to further improving the elderly care system. By capturing images of the elderly at home through network cameras, identifying the images to determine the identity and behavior of the elderly, the elderly's home behavior can be monitored in real time and recorded for a long time, thus laying the foundation for subsequent process extraction or emergency warning, and helping to accelerate the realization of remote monitoring.

[0004] NumPy is an extension library for numerical computing in Python. It provides high-performance multidimensional array objects and a series of tools for operating these arrays. The npy format file is a binary file format used by the NumPy library to save array data. It can save the structure, data type, and data content of the NumPy array and support cross-system loading and use.

[0005] A webcam is a digital camera device that transmits video signals through a computer network. It can capture static images and dynamic videos and is commonly used in scenarios such as video conferencing, video chatting, real-time monitoring, and live video streaming.

[0006] With the development of image acquisition and processing technology, computer vision has gradually become an important research field. Computer vision aims to enable computer systems to obtain information from image or video data, understand scenes, and recognize objects and behaviors. It covers multiple subfields, including target detection, semantic segmentation, motion and tracking, 3D reconstruction, action recognition, etc.

[0007] Face recognition is a technology that uses individual facial features to confirm their identity. Face recognition systems can be used to identify people in photos, videos, or real-time scenes. MTCNN (Multi-task convolutional neural network) is a deep learning model for face detection. Its core structure includes three cascaded sub-networks: P-Net (Proposal Network), R-Net (Refinement Network) and O-Net (Output Network), which successively complete the initial screening of candidate face frames, fine classification and regression further screening, face detection and feature point positioning, and finally output face detection results. In Python, you can directly call the mtcnn library to perform face detection and feature point positioning.

[0008] FaceNet is a face recognition system based on deep learning, which maps facial images into a compact Euclidean space, where spatial distance corresponds to a measure of facial similarity. The key feature of FaceNet is that it uses a Siamese network to learn facial features. The Siamese network consists of two convolutional neural networks with shared weights, which map the two input images into the same high-dimensional feature space, where the representations of the face images of the same person in this feature space are close to each other. FaceNet uses Triplet Loss to optimize the training process of the Siamese network, making the feature vectors of the same person closer, while the feature vectors of different people are more dispersed.

[0009] Object detection is an important task in the field of computer vision, which aims to identify objects in images or videos and determine their locations and categories. Compared with simple object recognition, object detection can not only identify the existence of objects, but also accurately locate the bounding box of objects and determine the category to which the objects belong. YOLO (You Only Look Once) is a popular object detection and image segmentation model. The main idea of ​​its design is to regard the object detection task as an end-to-end regression problem, and directly predict the category and location of the object on the entire image through a single neural network model.

[0010] Object tracking is a technology that uses the contextual information of a video or image sequence to model the appearance and motion information of the target, thereby predicting the target's motion state and calibrating the target's position. DeepSORT (Deeplearning based SORT) is a visual target tracking algorithm based on deep learning, which combines deep learning with the traditional target tracking algorithm SORT (Simple Online and Realtime Tracking). By detecting the target in each frame of the image, and using multi-feature fusion technology to represent and describe the target, and then using the SORT algorithm to track the target, the Re-Identification (Re-ID) model is introduced to solve the problem of determining the target ID, which has the advantages of high accuracy and strong robustness.

[0011] Action recognition involves identifying human actions in videos or images. The goal is to classify and categorize the actions performed in the videos or images into a set of predefined action classes. Slowfast is a deep learning architecture for video classification and action recognition. It uses two branches, slow and fast, and combines slow and fast video frames to improve the accuracy and efficiency of the model. The slow branch takes sparsely sampled frames as input to capture the apparent information in the video. The fast branch takes high-frequency sampled frames as input to capture the motion information in the video. Finally, the features of the two branches are spliced ​​to obtain the prediction results.

[0012] OpenCV (Open Source Computer Vision Library) is a programming library mainly for real-time computer vision, suitable for various scenarios from research to industrial applications. The programming library contains a large number of algorithms including computer vision and machine learning. These algorithms can be used to detect and recognize faces, identify objects, classify human actions in videos, track camera motion, track moving objects, extract 3D models of objects, and other scenarios. Summary of the invention

[0013] In order to fully record the daily behavior of the elderly, the present invention proposes a method for identifying the behavior of the elderly at home, which is used to capture the action images of the elderly at home and judge and record their specific behavior based on them. The method is based on the image data captured in real time by the network camera, judges the identity of the person through the facial data features, obtains the person's action and coordinates and calculates the overlap with the coordinates of the specified scene objects to determine the specific behavior, and improves the granularity of the behavior semantics by introducing scene awareness to achieve more detailed behavior division.

[0014] The objective of the present invention is achieved through the following technical solutions:

[0015] A method for identifying home behavior of the elderly comprises the following steps:

[0016] Step 1: Face database preparation:

[0017] Collect the user's frontal face photos and save them in the specified folder, traverse the images in the folder, perform face detection through the MTCNN model, select the face with the largest target box area in the detection results for face alignment, and input the trained FaceNet model to complete feature extraction. All facial feature data and corresponding names are stored in the face_encoding.npy file and names.npy file in npy format respectively. The specific steps are as follows:

[0018] Step 1: Name all user's face images in the format of "name.jpg" and put them into the specified folder, where name is the specific name of the user corresponding to the current image;

[0019] Step 1 and 2: After storage, traverse all the pictures in the specified folder, input the MTCNN model in the mtcnn library for face detection, take the face with the largest area in the face target frame as the image recognition object, and rotate the image data in the target frame according to the angle between the eyes and the horizontal line to align the face;

[0020] Step 13: Input the processed face image into the trained FaceNet model for feature extraction, and store all face feature data and corresponding names in face_encoding.npy and names.npy respectively;

[0021] Step 2: Video data collection:

[0022] The network camera captures real-time images and collects images every minute. After the collection is completed, the collected image data is stitched into videos and stored in the queue Videos= <v1,v2,...,v i ,...,v f >, and concatenate the collection completion time into the queue according to the specified format Dates = <d1,d2,...,d i , ..., d f >, where v i is the i-th video in the queue Videos, d i is the i-th date and time in the queue Dates, and f is the length of the queue Videos and the queue Dates. The specific steps are as follows:

[0023] Step 21: Call the network camera to collect images once a minute. During the image collection process, the camera data is stored once every specified time interval t seconds. When the number of storage times reaches the required number of frames TimeFrames, the stored image set is converted into a video, and the video address is stored in the to-be-processed video queue Videos;

[0024] Step 22: At the same time, obtain the completion time of this round of collection, that is, the storage time of the last image, concatenate it into a string in the format of "date_hour:minute", and store it in the date queue Dates;

[0025] Step 3: Face recognition:

[0026] Get the head element video v1 in the video queue Videos, detect faces, align faces, extract face data features, match the face database, and get all the face target box sets {box1, box2, ..., box j , ..., box p} and the corresponding identity information set {name1, name2, ..., name j , ..., name p}, where box j The target frame information of the jth face detected in the middle frame and successfully matched with the database, name j For box j The identity information obtained by matching the face with the database, p is the total number of faces that successfully match the data, the specific steps are as follows:

[0027] Step 31: Read the image img at the TimeFrames / 2 position in v1, i.e. the middle frame position, through the OpenCV library;

[0028] Step 3.2: Face detection obtains the face target frame set and the left and right eye coordinate set:

[0029] Input img into the MTCNN model in the mtcnn library for face detection, and obtain the set of all face target boxes in the picture {box1, box2, ..., box i , ..., box z} and the face left and right eye coordinates set {eye1, eye2, ..., eye i ,...,eye z}, box i is the target frame information of the i-th face detected in the img, eye i , for box i The left and right eye coordinate information of the corresponding face, z is the total number of faces detected by img;

[0030] Step 3. Calculate the angles by using the left and right eye coordinates to perform face alignment:

[0031] Step 331: From the coordinate information of the left and right eyes of the i-th face, eye i Calculate the left eye i,left and right eye i,right The angle formed with the horizontal line i , put the img in the box i Rotate the image data within the range angle i The angle gets the aligned image data imgRot i ;

[0032] Step 332: Perform step 331 on the face target frame obtained in step 32 to obtain the aligned image data set {imgRot1, imgRot2, ..., imgRot i , ..., imgRot z}, imgRot i The image data after face alignment for the i-th face detected in img;

[0033] Step 3 and 4: Extract facial data features:

[0034] Step 341: Align the image data imgRot i Input the trained FaceNet model to get the face data feature face i ;

[0035] Step 342: Perform step 341 on the image data obtained in step 33 to obtain the data feature set {face1, face2, ..., face i ,...,face z}, face i is the data feature of the i-th face detected in img;

[0036] Step 35: Match the face database and obtain identity information:

[0037] Step 351: Calculate Face i The distance from all facial features in face_encoding.npy is selected, and the corresponding name in names.npy with the closest distance and less than the set threshold d is used as the identity information name i , if the minimum distance is still greater than the threshold, the identity information will not be stored and its face data features and face target frame coordinate information will be removed;

[0038] Step 352: Perform step 351 on the facial data features obtained in step 34 to obtain the identity information set {name1, name2, ..., name j , ..., name p} and the retained face target box set {box1, box2, ..., box j , ..., box p}, box j The coordinate information of the target frame of the jth face that successfully matches the database, name j For box j Corresponding to the identity information of the face, p is the total number of faces that successfully match the data, satisfying p≤z, z is the total number of faces detected;

[0039] Step 4: Target identification:

[0040] Perform frame segmentation on v1 to obtain the frame image set imgs, and then perform target detection and target filtering in sequence to obtain the person target detection result set {person1, person2, ..., person i , ..., person n} and the specified scene object target detection result set {item1, item2, ..., item i ,...,item n}, person i All the human target results detected in the i-th picture in imgs, item i For all the specified scene object target results detected in the i-th image in imgs, n is the total number of frames of v1. The specific steps are as follows:

[0041] Step 41: Get the video frame image collection:

[0042] Read all frames of the video through the OpenCV library and store each frame image in the frame image set imgs;

[0043] Step 42: Get all target detection result sets:

[0044] Input imgs into the trained YOLOv5 model to obtain the target detection result set {pred1, pred2, ..., pred i , ..., pred n}, where pred i is the target detection result of the i-th image in imgs, including the identification number corresponding to the target category, target coordinate box, confidence level, etc.;

[0045] Step 43: Target filtering retains the specified target detection set:

[0046] Step 431: If the j-th target detection result pred of the i-th frame ij If the identification number in the image is the same as the specified category number x, the detection result is retained. Repeat the above operation for all detection results of the i-th image in imgs to obtain the retained target detection result {keep i1 , keep i2 , ..., keep ij , ..., keep il}, keep ij is the detection result of the target with the jth identification number x in the i-th frame, and l is the total number of targets with the identification number x in the i-th frame detection result;

[0047] Step 432: Set x to the number corresponding to the person and the number of the specified scene object respectively, and perform step 431 on each image in imgs to obtain the person target detection result set {person1, person2, ..., person i , ..., person n} and multiple specified scene object target detection result sets {item1, item2, ..., item i ,...,item n}, person i All human target results in the i-th frame, including human target frame coordinates, confidence, etc., item i The target results of all specified scene items in the i-th frame;

[0048] Step 5: Action Recognition:

[0049] Track the target and assign an ID to the person to obtain the motion trajectory. After processing the v1 video data, perform uniform sub-sampling of the fast and slow channels and complete the motion trajectory update. According to the updated motion trajectory and sampling information of each ID, its action category is determined to obtain the action set {action1, action2, ..., action i ,...,action m}, action i is the action corresponding to the motion trajectory with id i, and m is the total number of ids assigned to target tracking. The specific steps are as follows:

[0050] Step 51: Target tracking to obtain number and motion trajectory:

[0051] The DeepSORT algorithm trained by the feature extraction model realizes the continuous positioning and tracking of human targets and assigns a separate ID to each target. The human target detection result set {person1, person2, ..., person i , ..., person n} is transformed into a set of motion tracks marked with ids {track1, track2, ..., track i , ..., track n}, person i For all the target results of the person in the i-th frame, track i are all the target frames with id tags in the i-th frame, and n is the total number of frames of v1;

[0052] Step 52: Fast and slow channel sampling and target frame scaling and cropping:

[0053] Convert v1 to a new format, normalize and standardize the pixel values, and then perform sub-sampling of the fast and slow channels according to the set number of fast and slow frames to obtain fast and slow motion information. Scale the motion track set according to the current pixel value and crop the overflow part to obtain the processed motion track set {up_track1, up_track2, ..., up_track i , ..., up_track n}, up_track i are all the trajectory target frames after processing the i-th frame;

[0054] Step 53: Identify target actions:

[0055] The fast and slow action information and the processed motion trajectory set are input into the trained SlowFast model to output the possible probability values ​​of all actions for each id, and the actions with the highest probability are selected one by one as the corresponding actions to obtain the action set {action1, action2, ..., action i ,...,action m}, action i It is the action corresponding to the motion trajectory marked with id i;

[0056] Step 6: Introduce the scene to obtain specific behaviors:

[0057] If the motion trajectory with id i corresponds to the action action i If it is a special action, the scene is analyzed and the updated behavior is obtained. i If it does not belong to, keep the original action as the behavior act i , the specific steps are as follows:

[0058] Step 61: Determine action i Is it a special action? If it is, enter the scene for judgment. If it is not, keep the original action as the behavior act i And skip step 62;

[0059] Step 62: Scenario analysis to determine specific behaviors:

[0060] Calculate the target frame set track of the unprocessed motion trajectory of the intermediate frame n / 2 The track target box trackBox with id j i And the target detection result item of the scene object required in the intermediate frame n / 2 The target box of the item with sequence number k in itemBox k The overlap degree is , where k is the serial number of the target item required for the current behavior. If the overlap degree is greater than the set threshold q, the action is updated to the specific behavior act i Otherwise, keep the original action as the behavior act i ;

[0061] Step 7: Associate identity with behavior:

[0062] Step 71. Repeat step 6 to get the behavior set {act1, act2, ..., act i , ..., act m}, act i is the behavior corresponding to the motion trajectory with id i, and m is the total number of ids assigned to target tracking;

[0063] Step 7.2: Calculate the identity information name obtained in step 3 i Corresponding face target box i The overlap area with all unprocessed track target boxes of all ids in the intermediate frame is in box i The area ratio is used as the overlap, and the behavior corresponding to the id with the largest overlap is selected as the matching behavior. It is the id with the largest overlap;

[0064] Step 73: Perform the operation of step 72 on the identity information obtained in step 3 to obtain a collection of associations of all identity information and behavior information. name i The i-th identity information, for name i The matching behavior, p is the total number of faces successfully matched with the database, satisfying p≤m, and m is the total number of IDs assigned by the target tracking;

[0065] Step 8: Store specific behavior information:

[0066] Take out the header string d1 of the date queue Dates, split it into "date" and "hour: minute", traverse the associated set, and save the behavior information in the format of "hour: minute-action" into a file named "date-identity information.cvs" for real-time behavior records of specified people.

[0067] Compared with the prior art, the present invention has the following advantages:

[0068] 1. The present invention provides a method for identifying the behavior of the elderly at home in accordance with the needs of remote monitoring of the elderly. The method uses the Internet of Things technology to capture the behavior of the elderly through a network camera, uses computer vision technology to perform face and behavior analysis, and converts images that may contain multiple people into behavior outputs of designated persons. The determination of personnel identity and the recording of behavior lay the foundation for the subsequent extraction of daily behavior processes of the elderly, abnormal behavior detection, etc., and help to improve the remote monitoring system for the elderly.

[0069] 2. When performing behavior recognition, the present invention adopts a method of integrating characteristic actions and characteristic scenes. On the basis of identifying conventional actions, it further improves the fine-grainedness of behavioral semantics to complete detailed behavior division, realizes action feature extraction, and improves the recognition ability for special behaviors of the elderly, which helps to more comprehensively capture the behavioral semantics of the elderly and thus achieve accurate recognition and recording. BRIEF DESCRIPTION OF THE DRAWINGS

[0070] Figure 1 Demonstrate application scenarios of home behavior recognition methods for the elderly;

[0071] Figure 2 Provide solutions for identifying behaviors of the elderly at home;

[0072] Figure 3 It is a part of the facial data features in the face database in the embodiment;

[0073] Figure 4 It is a part of the person target prediction result set in the embodiment;

[0074] Figure 5 is part of all association sets in the embodiments;

[0075] Figure 6 A visual display of scene analysis. DETAILED DESCRIPTION

[0076] The technical solution of the present invention is further described below in conjunction with the accompanying drawings, but is not limited thereto. Any modification or equivalent replacement of the technical solution of the present invention without departing from the spirit and scope of the technical solution of the present invention should be included in the protection scope of the present invention.

[0077] In order to more clearly demonstrate the specific implementation method of the present invention, some related concepts and calculation formulas are first described:

[0078] The identity information set is the information set obtained after face recognition in the intermediate frame is successfully matched with the face database. The behavior information set is the information set obtained after action recognition in the current video is fused with the scene. The association set is the set obtained by associating identity and behavior based on the tracking ID.

[0079] The camera collects image data once a minute, and splices the collected image data into a video and stores it in the video queue to be processed Videos. Each time, the Videos header element video v1 is obtained for subsequent recognition operations.

[0080] The angle that needs to be rotated for alignment of the i-th face detected in the middle frame Among them eye i,left,x ,eye i,left,y is the coordinates of the left eye of the face, eye i,right,x ,eye i,right,y The coordinates of the right eye of the face.

[0081] The Euclidean distance is used to calculate the difference in facial feature values, and the facial feature distance Among them, Face i is the i-th face in the middle frame, Face j is the jth face to be compared in the face database, face i,k For Face i The kth element of the facial feature, face j,k For Face j The kth element of the facial feature, s is the total number of facial features.

[0082] Video format conversion before fast and slow channel sampling: normalize pixel values Video i,j Represents the pixel value of the i-th row and j-th column in the pixel value matrix; standardizes the pixel value Where normVideo i,j is the pixel value of the i-th row and j-th column in the normalized pixel matrix, mean j To set the jth element in the mean vector, std j To set the jth element in the standard deviation vector, standVideo i,j is the pixel value of the i-th row and j-th column in the normalized pixel matrix.

[0083] The calculation of target frame overlap in scene analysis and associating identity and behavior is similar, the only difference is the final ratio calculation. start =max(Box i,x , Box j,x ), y start =max(Box i,y , Box j,y ), the lower right corner coordinate x end =max(Box i,x +Box i,width , Box j,x +Box j,width ), y end =max(Box i,y +Box i,height , Box j,y +Box j,height ), where Box i,x 、Box i,y and Box i,width 、Box i,height Box is the coordinates, width and height of the unprocessed motion trajectory target box with id i in the middle frame. j,x 、Box j,y and Box j,width 、Box j,height The coordinates, width, and height of the target box for the jth specific object or the coordinates, width, and height of the target box for the jth face in the intermediate frame that completes the database match. i , Box j )=max(0,x end -x start )×max(0,y end -y start ), target frame overlap in scene analysis The overlap between the target frame and the associated identity

[0084] The present invention mainly considers five actions of walking, standing, lying, eating and sitting for the elderly's home behaviors, and introduces four scene objects of bed, sofa, water cup and bowl in combination with two specific scenes of bedroom and living room. After combining the actions with the scene objects, the behaviors are subdivided into nine types: walking, standing, lying, sleeping, taking a nap, eating, drinking water, dining and sitting. The specific home behaviors are determined according to the overlap between the actions and the scene objects and compared with the threshold value to complete the recognition.

[0085] The method for identifying home behaviors of the elderly provided by the present invention takes the semantics of daily behaviors of the elderly as the background with fine granularity, takes the video data acquired in real time by the network camera as the basis, expresses the semantic vector of the video image data, matches the facial data features recognized by FaceNet with the facial database to determine the identity of the person, adopts YOLOv5 target detection to obtain the target prediction results of the specified scene objects and the target prediction results of the person, performs DeepSORT target tracking and SlowFast behavior recognition on the target prediction results of the person to obtain the person ID and the corresponding action, then fuses the scene objects and actions to obtain the segmented behaviors, and finally completes the identification of the home behaviors of the elderly by associating the identities with the behaviors. The specific implementation steps are as follows:

[0086] Step 1: Face database preparation: Name all user face images in the format of "name.jpg" and put them under "faces", where name is the specific name of the user corresponding to the current image. Traverse all images under "faces", input the MTCNN model in the mtcnn library for face detection, rotate the image data in the face target frame with the largest area according to the angle between the eyes and the horizontal line to align the face; finally, input the processed face image into the trained FaceNet model for feature extraction, and store the feature data and corresponding names of all faces in face_encoding.npy and names.npy respectively.

[0087] Step 2, video data collection: call the network camera to collect images once a minute, and store the camera data in the picture collection every 2 / 60 seconds. When the picture collection length reaches 60 frames, convert all the pictures into videos and sleep for 58 seconds until the next image collection. The converted video address is stored in the queue of videos to be processed, and the storage time of the last image of this round is concatenated into a string in the format of "date hour: minute" and stored in the date queue Dates.

[0088] Step 3: Face recognition: Get the header video v1 of the current video queue Videos to be processed, use the OpenCV library to read the image at position 30 as the intermediate frame img, perform face detection, and input img into the MTCNN model in the mtcnn library to obtain the corresponding face target box set {box1, box2, ..., box z} and the left and right eye set of the face {eye1, eye2, ..., eye z}, where z is the total number of faces in img. In order to avoid the interference of face inclination on feature extraction, the data of each face in the target frame in img is rotated according to the calculated angle between the left and right eyes to achieve face alignment, and the aligned image data set {imgRot1, imgRot2, ..., imgRot z}, map the pixel values ​​of the face image into a compact and discriminable feature vector, input the aligned image data into the trained FaceNet model to obtain the face feature data set {face1, face2, ..., face z}, and perform distance calculations on the data in the set and the information in the face database to achieve matching, and finally obtain the identity information set {name1, name2, ..., name p}, p is the total number of faces that successfully match the data.

[0089] Step 4: Target recognition: Use the OpenCV library to read all frames of v1 and store them in the image set imgs. To achieve image segmentation based on target features, input imgs into the trained YOLOv5 model to obtain the target detection result set {pred1, pred2, ..., pred 60}, where 60 is the total number of frames currently set. To extract the results related to the specified target, target filtering is performed to retain only the detection results with the same set category number, and the human target detection result set {person1, person2, ..., person 60} and multiple scene object target detection result sets {item i , item2, ..., item 60}.

[0090] Step 5: Action recognition: The DeepSORT algorithm trained by the feature extraction model is used to realize continuous positioning and tracking of human targets, and the human target detection result set is converted into a set of motion trajectories {track1, track2, ..., track 60}, 60 is the total number of frames. The video pixel values ​​of v1 are normalized and standardized, and 32 and 8 are used as the equidistant sample numbers of the fast channel and the slow channel respectively to perform fast and slow channel sub-sampling to obtain fast and slow motion information. In order to match the sampling information, the motion trajectory is scaled according to the current motion information pixel value and the overflow part is cropped. The updated motion trajectory set is {up_track1, up_track2, ..., up_track nThe fast and slow action information and the updated motion trajectory set are input into the trained SlowFast model to output the probability values ​​of all actions. The action with the largest rotation probability is taken as the corresponding action, and the action set {action1, action2, ..., action m}, m is the total number of ids.

[0091] Step 6: Introduce the scene to obtain specific behavior: take the action corresponding to id i in the action set i As a sample, if the action is a special action, it is necessary to enter the scene for judgment and extract the motion track in the middle frame. 30 The track target box trackBox with id i i , calculate the target detection result item between it and the required scene object in the middle frame 30 The item target box itemBox j The overlap CoTargetRatio(trackBox i , itemBox j ), where j is the serial number of the target item required for the current behavior. If the overlap is greater than the set threshold 0.8, the action is updated to a specific behavior, otherwise the original action is retained as the behavior. Repeat the above operation to the behavior information set {act1, act2, ..., act m}.

[0092] Step 7: Associate identity and behavior: with identity information name i For the sample, calculate its face target box i The overlap between the target frames of all IDs in the intermediate frame and the unprocessed motion trajectory is selected as the associated behavior. Repeat the above operation to obtain the associated set {name1: act1, name2: act2, ..., name p :act p}, p is the total number of faces successfully matched with the database.

[0093] Step 8. Store specific behavior information: Take out the header string d1 of the date queue Dates, split it into "date" and "hour: minute", traverse the associated set, and store the behavior information in the format of "hour: minute-action" in a file named "date-identity information.cvs" for real-time behavior records of specified people.

[0094] The specific description of the execution process algorithm of the whole method is shown in Table 1:

[0095] Table 1

[0096]

[0097] Example:

[0098] This embodiment simulates multiple behaviors of multiple elderly people within 1 hour as sample data, and verifies each step of the present invention. The data sample is shown in Table 2:

[0099] Table 2

[0100]

[0101]

[0102]

[0103] When analyzing the behavior of the elderly, it is necessary to consider that some actions have highly similar semantics. In order to refine the behavior of the same action, scene objects are introduced as auxiliary judgment factors. For example, if the action of lying down is highly overlapped with the object sofa, it will be refined into the behavior of taking a nap; if it is highly overlapped with the object bed, it will be refined into the behavior of sleeping.

[0104] The detailed steps are as follows:

[0105] The first step is to store the user's face image in a specified folder, traverse the images in the folder to perform face detection, face alignment of the largest face target frame, and face recognition, and store all the extracted facial feature data and corresponding names in face_encoding.npy and names.npy respectively. Figure 3 shown.

[0106] The second step is to use the network camera to collect images once a minute, convert them into videos and store them in the queue of videos to be processed. <v1,v2,...,v i , ..., v f >, and store the last image storage time in the format of "date_hour:minute" in the date queue Dates= <d1,d2,...,d i , ..., d f >, f is the length of the current video queue and date queue.

[0107] The third step is face recognition. Read the head element video v1 in the queue Videos, use the OpenCV library to get the intermediate frame, input it into the MTCNN model in the mtcnn library for face detection, and get the face target box set {box1, box2, ..., box z} and the left and right eye set {eye1, eye2, ..., eye zIn order to avoid the interference of face inclination on feature extraction, the data in the target frame is rotated according to the angle between the left and right eyes of the face and the horizontal line to achieve face alignment. The aligned face image is input into the trained FaceNet model to obtain the face data feature set {face1, face2, ..., face z}, and calculate the distance between the feature data in the set and the information in the face database to achieve matching, and obtain the identity information set {name1, name2, ..., name p}.

[0108] The fourth step is target recognition. Use the OpenCV library to process the video v1 into frames to obtain a set of images. To achieve image segmentation based on target features, input imgs into the trained YOLOv5 model to obtain a set of target detection results {pred1, pred2, ..., pred 60}, filter the result set by target and only retain the detection results with the same set category number, and obtain the person target detection result set {person1, person2, ..., person 60} and the scene object target detection result set {item1, item2, ..., item 60}, the character target prediction result set is as follows Figure 4 shown.

[0109] Step 5: Action recognition. Use the DeepSORT algorithm to track the target and obtain a set of motion trajectories {track1, track2, ..., track 60 The video v1 is normalized, standardized, and uniformly subsampled in the fast and slow channels in turn. In order to match the sampling information, the motion trajectory is scaled according to the current action information pixel value and the overflow part is cropped to obtain an updated motion trajectory set. The sampled fast and slow action information and the updated motion trajectory set are input into the trained SlowFast model to obtain all action probability values. The action with the largest probability is selected as the corresponding action to obtain the action set {action1, action2, ..., action m}.

[0110] Step 6: Introduce the scene to obtain specific behaviors. For each action in the action set, determine whether it is a special action. If it is, it is necessary to conduct scene analysis and calculate the overlap between the target frame of the unprocessed behavior trajectory of the action ID in the middle frame and the target frame of the required scene object target detection result, and compare it with the threshold value to complete the behavior update, and obtain the behavior set {act1, act2, ..., act m}.

[0111] Step 7: Associate identity with behavior. Traverse the identity information, calculate the overlap between the corresponding face target frame and all unprocessed motion trajectory target frames in the intermediate frame, select the behavior with the largest overlap in the behavior set as the associated behavior, and obtain the associated set {name1: act1, name2: act2, ..., name p :act p},like Figure 5 shown.

[0112] Step 8: Store specific behavior information. Take out the header string d1 of the date queue Dates, split it into "date" and "hour: minute", traverse the associated set, and store the behavior information in the format of "hour: minute-action" into a file named "date-identity information.cvs" for real-time behavior records of specified characters.

Claims

1. A method for identifying elderly people's home behavior, characterized in that The method comprises the following steps: Step 1: Face database preparation: Collect the user's frontal face photos and save them in the specified folder, traverse the images in the folder, perform face detection through the MTCNN model, select the face with the largest target box area in the detection results for face alignment, and input the trained FaceNet model to complete feature extraction, and store all facial feature data and corresponding names in the face_encoding.npy file and names.npy file in npy format respectively; Step 2: Video data collection: The network camera captures real-time images and collects images every minute. After the collection is completed, the collected image data is stitched into videos and stored in the queue Videos= <v1,v2,...,v i , ..., v f >, and concatenate the collection completion time into the queue Dates= according to the specified format. <d1,d2,...,d i , ..., d f >, where v i is the i-th video in the queue Videos, d i is the i-th date and time in the queue Dates, and f is the length of the queue Videos and the queue Dates; Step 3: Face recognition: Get the head element video v1 in the video queue Videos, detect faces, align faces, extract face data features, match the face database, and get all the face target box sets {box1, box2, ..., box j , ..., box p } and the corresponding identity information set {name1, name2, ..., name j , ..., name p }, where box j The target frame information of the jth face detected in the middle frame and successfully matched with the database, name j For box j The identity information obtained by matching the corresponding face with the database, p is the total number of faces that successfully match the data; Step 4: Target identification: Perform frame segmentation on v1 to obtain the frame image set imgs, and then perform target detection and target filtering in sequence to obtain the person target detection result set {person1, person2, ..., person i , ..., person n } and the specified scene object target detection result set {item i , item2, ..., item i ,...,item n }, person i All the human target results detected in the i-th picture in imgs, item i are all the specified scene object target results detected in the i-th image in imgs, and n is the total number of frames of v1; Step 5: Action Recognition: Track the target and assign an ID to the person to obtain the motion trajectory. After processing the v1 video data, perform uniform sub-sampling of the fast and slow channels and complete the motion trajectory update. According to the updated motion trajectory and sampling information of each ID, its action category is determined to obtain the action set {action1, action2, ..., action i ,...,action m }, action i is the action corresponding to the motion trajectory with id i, and m is the total number of ids assigned to target tracking; Step 6: Introduce the scene to obtain specific behaviors: If the motion trajectory with id i corresponds to the action action i If it is a special action, the scene is analyzed and the updated behavior is obtained. i If it does not belong to, keep the original action as the behavior act i ; Step 7: Associate identity with behavior: Step 71. Repeat step 6 to get the behavior set {act1, act2, ..., act i , ..., act m }, act i is the behavior corresponding to the motion trajectory with id i, and m is the total number of ids assigned to target tracking; Step 7.2: Calculate the identity information name obtained in step 3 i Corresponding face target box i The overlap area with all unprocessed track target boxes of all ids in the intermediate frame is in box i The area ratio is used as the overlap, and the behavior corresponding to the id with the largest overlap is selected as the matching behavior. It is the id with the largest overlap; Step 73: Perform the operation of step 72 on the identity information obtained in step 3 to obtain a collection of associations of all identity information and behavior information. name i The i-th identity information, for name i The matching behavior, p is the total number of faces successfully matched with the database, satisfying p≤m, and m is the total number of IDs assigned by the target tracking; Step 8: Store specific behavior information: Take out the header string d1 of the date queue Dates, split it into "date" and "hour: minute", traverse the associated set, and save the behavior information in the format of "hour: minute-action" into a file named "date-identity information.cvs" for real-time behavior records of designated people.

2. The method for identifying home behavior of the elderly according to claim 1, characterized in that The specific steps of step one are as follows: Step 11: Name all user's face images in the format of "name.jpg" and put them into the specified folder, where name is the specific name of the user corresponding to the current image; Step 1 and 2: After storage, traverse all the pictures in the specified folder, input the MTCNN model in the mtcnn library for face detection, take the face with the largest area in the face target frame as the image recognition object, and rotate the image data in the target frame according to the angle between the eyes and the horizontal line to align the face; Step 1: Input the processed face image into the trained FaceNet model for feature extraction, and store all face feature data and corresponding names in face_encoding.npy and names.npy respectively.

3. The method for identifying home behavior of the elderly according to claim 1, characterized in that The specific steps of step 2 are as follows: Step 21: Call the network camera to collect images once a minute. During the image collection process, the camera data is stored once every specified time interval t seconds. When the number of storage times reaches the required number of frames TimeFrames, the stored image set is converted into a video, and the video address is stored in the to-be-processed video queue Videos; Step 22: At the same time, obtain the completion time of this round of collection, that is, the storage time of the last image, concatenate it into a string in the format of "date_hour:minute", and store it in the date queue Dates.

4. The method for identifying home behavior of the elderly according to claim 1, characterized in that The specific steps of step three are as follows: Step 31: Read the image img at the TimeFrames / 2 position in v1, i.e. the middle frame position, through the OpenCV library; Step 3.2: Face detection obtains the face target frame set and the left and right eye coordinate set: Input img into the MTCNN model in the mtcnn library for face detection, and obtain the set of all face target boxes in the picture {box1, box2, ..., box i , ..., box z } and the face left and right eye coordinates set {eye1, eye2, ..., eye i ,...,eye z }, box i is the target frame information of the i-th face detected in the img, eye i , for box i The left and right eye coordinate information of the corresponding face, z is the total number of faces detected by img; Step 3. Calculate the angles by using the left and right eye coordinates to perform face alignment: Step 331: From the coordinate information of the left and right eyes of the i-th face, eye i Calculate the left eye i,left and right eye i,right The angle formed with the horizontal line i , put the img in the box i Rotate the image data within the range angle i The angle gets the aligned image data imgRot i ; Step 332: Perform step 331 on the face target frame obtained in step 32 to obtain the aligned image data set {imgRot1, imgRot2, ..., imgRot i , ..., imgRot z }, imgRot i The image data after face alignment for the i-th face detected in img; Step 3 and 4: Extract facial data features: Step 341: Align the image data imgRot i Input the trained FaceNet model to get the face data feature face i ; Step 342: Perform step 341 on the image data obtained in step 33 to obtain the data feature set {face1, face2, ..., face i ,...,face z }, face i is the data feature of the i-th face detected in img; Step 35: Match the face database and obtain identity information: Step 351: Calculate Face i The distance from all facial features in face_encoding.npy is selected, and the corresponding name in names.npy with the closest distance and less than the set threshold d is used as the identity information name i , if the minimum distance is still greater than the threshold, the identity information will not be stored and its face data features and face target frame coordinate information will be removed; Step 352: Perform step 351 on the facial data features obtained in step 34 to obtain the identity information set {name1, name2, ..., name j , ..., name p } and the retained face target box set {box1, box2, ..., box j , ..., box p }, box j The coordinate information of the target frame of the jth face that successfully matches the database, name j For box j Corresponding to the identity information of the face, p is the total number of faces that successfully match the data, satisfying p≤z, and z is the total number of faces detected.

5. The method for identifying home behavior of the elderly according to claim 4, characterized in that Said Among them eye i,left,x ,eye i,left,y is the coordinates of the left eye of the face, eye i,right,x ,eye i,right,y The coordinates of the right eye of the face.

6. The method for identifying home behavior of the elderly according to claim 1, characterized in that The specific steps of step 4 are as follows: Step 41: Get the video frame image collection: Read all frames of the video through the OpenCV library and store each frame image in the frame image set imgs; Step 42: Get all target detection result sets: Input imgs into the trained YOLOv5 model to obtain the target detection result set {pred1, pred2, ..., pred i , ..., pred n }, where pred i is the target detection result of the i-th image in imgs, including the identification number corresponding to the target category, the target coordinate box, and the confidence level; Step 43: Target filtering retains the specified target detection set: Step 431: If the j-th target detection result pred of the i-th frame ij If the identification number in the image is the same as the specified category number x, the detection result is retained. Repeat the above operation for all detection results of the i-th image in imgs to obtain the retained target detection result {keep i1 , keep i2 , ..., keep ij , ..., keep il }, keep ij is the detection result of the target with the jth identification number x in the i-th frame, and l is the total number of targets with the identification number x in the i-th frame detection result; Step 432: Set x to the number corresponding to the person and the number of the specified scene object respectively, and perform step 431 on each image in imgs to obtain the person target detection result set {person1, person2, ..., person i , ..., person n } and multiple specified scene object target detection result sets {item1, item2, ..., item i ,...,item n }, person i All human target results in the i-th frame, including human target frame coordinates, confidence, and item i The target results for all specified scene items in the i-th frame.

7. The method for identifying home behavior of the elderly according to claim 1, characterized in that The specific steps of step five are as follows: Step 51: Target tracking to obtain number and motion trajectory: The DeepSORT algorithm trained by the feature extraction model realizes the continuous positioning and tracking of human targets and assigns a separate ID to each target. The human target detection result set {person1, person2, ..., person i , ..., person n } is transformed into a set of motion tracks marked with ids {track1, track2, ..., track i , ..., track n }, person i For all the target results of the person in the i-th frame, track i are all the target frames with id tags in the i-th frame, and n is the total number of frames of v1; Step 52: Fast and slow channel sampling and target frame scaling and cropping: Convert v1 to a new format, normalize and standardize the pixel values, and then perform sub-sampling of the fast and slow channels according to the set number of fast and slow frames to obtain fast and slow motion information. Scale the motion track set according to the current pixel value and crop the overflow part to obtain the processed motion track set {up_track1, up_track2, ..., up_track i , ..., up_track n }, up_track i are all the trajectory target frames after processing the i-th frame; Step 53: Identify target actions: The fast and slow action information and the processed motion trajectory set are input into the trained SlowFast model to output the possible probability values ​​of all actions for each id, and the actions with the highest probability are selected one by one as the corresponding actions to obtain the action set {action1, action2, ..., action i ,...,action m }, action i It is the action corresponding to the motion trajectory marked with id i.

8. The method for identifying home behavior of the elderly according to claim 1, characterized in that The specific steps of step six are as follows: Step 61: Determine action i Is it a special action? If it is, enter the scene for judgment. If it is not, keep the original action as the behavior act i And skip step 62; Step 62: Scenario analysis to determine specific behaviors: Calculate the target frame set track of the unprocessed motion trajectory of the intermediate frame n / 2 The track target box trackBox with id j i And the target detection result item of the scene object required in the intermediate frame n / 2 The target box of the item with sequence number k in itemBox k The overlap degree is , where k is the serial number of the target item required for the current behavior. If the overlap degree is greater than the set threshold q, the action is updated to the specific behavior act i Otherwise, keep the original action as the behavior act i .

9. The method for identifying home behavior of the elderly according to claim 8, characterized in that The degree of overlap Overlap area CoArea(Box i , Box j )=max(0,x end -x start )×max(0,y end -y start ), the upper left corner coordinate x of the overlapping target box start =max(Box i,x , Box j,x ), y start =max(Box i,y , Box j,y ), the lower right corner coordinate x end =max(Box i,x +Box i,width , Box j,x +Box j,width ), y end =max(Box i,y +Box i,height , Box j,y +Box j,height ), where Box i,x 、Box i,y and Box i,width 、Box i,height Box is the coordinates, width and height of the unprocessed motion trajectory target box with id i in the middle frame. j,x 、Box j,y and Box j,width 、Box j,height Identify the target box coordinates, width, and height for the j-th specific item detected in the middle frame.

10. The method for identifying home behavior of the elderly according to claim 1, characterized in that In step 7, the overlap degree Overlap area CoArea(Box i , Box j )=max(0,x end -x start )×max(0,y end -y start ), the upper left corner coordinate x of the overlapping target box start =max(Box i,x , Box j,x ), y start =max(Box i,y , Box j,y ), the lower right corner coordinate x end =max(Box i,x +Box i,width , Box j,x +Box j,width ), y end =max(Box i,y +Box i,height , Box j,y +Box j,height ), where Box i,x 、Box i,y and Box i,width 、Box i,height Box is the coordinates, width and height of the unprocessed motion trajectory target box with id i in the middle frame. j,x 、Box j,y and Box j,width 、Box j,height The target box coordinates, width, and height of the jth face successfully matched in the database in the middle frame.