An image segmentation method for student safety behavior analysis

The method improves student safety behavior analysis by accurately segmenting student areas using pixel grayscale values and motion vectors, correcting danger levels, and determining activity risks, thus enhancing the precision of student safety evaluation.

CN118918129BActive Publication Date: 2024-12-10CHENGDU BORUI DIGITAL PLUS TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411398192.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-09
Publication Date
2024-12-10
Estimated Expiration
2044-10-09

AI Technical Summary

Technical Problem

Existing image segmentation methods for student safety behavior analysis suffer from over-segmentation due to complex student behavior patterns, leading to inaccurate results.

Method used

An image segmentation method that divides student gathering and individual areas based on pixel grayscale values and motion vectors, determines activity change degrees, and corrects danger levels using Euclidean distances and interaction degrees to improve segmentation accuracy.

Benefits of technology

Accurately evaluates student activity levels and safety risks by distinguishing between gathering and individual areas, enhancing the precision of student safety behavior analysis.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118918129B_ABST
    Figure CN118918129B_ABST
Patent Text Reader

Abstract

The present invention relates to the technical field of image segmentation, and proposes an image segmentation method for student safety behavior analysis, including: collecting a video at a location where student safety behavior analysis is required, dividing a student gathering area and a student individual area in an image grayscale frame of the video; obtaining the activity change degree and danger of the student gathering area, and dividing the activity risk area; obtaining the corrected danger and adjusted edge retention of the student gathering area, and assigning a value to the adjusted edge retention of the student individual area; according to the values ​​of the adjusted edge retention of the student gathering area and the student individual area, determining the edges within the student gathering area and the student individual area, and obtaining an image segmentation result for student safety behavior analysis. The present invention aims to solve the problem of inaccurate image segmentation for student safety behavior analysis caused by complex student behavior patterns.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image segmentation, and in particular to an image segmentation method for analyzing student safety behaviors. Background Art

[0002] In order to ensure the safety of students on campus, image segmentation technology is generally used in combination with computer vision and deep learning methods to conduct real-time monitoring and analysis of image frames contained in videos collected on campus, to assess students’ safety in real time and to improve the overall security level of the campus.

[0003] In the process of real-time monitoring and analysis of image frames contained in videos collected on campus, it is necessary to first extract the areas corresponding to students in the image frames. However, due to the complex behavior patterns of students and the possible overlap between the areas corresponding to different students in the image frames, the segmentation of the areas corresponding to students in the image frames often results in over-segmentation, resulting in inaccurate results of student safety behavior analysis based on over-segmented student areas. Summary of the invention

[0004] The present invention provides an image segmentation method for student safety behavior analysis to solve the problem of inaccurate image segmentation for student safety behavior analysis caused by complex student behavior patterns. The technical solution adopted is as follows:

[0005] An embodiment of the present invention provides an image segmentation method for analyzing student safety behavior, the method comprising the following steps:

[0006] Collect videos at locations where student safety behavior analysis is required, obtain image grayscale frames based on image frames of the video, and divide student gathering areas and student individual areas in the image grayscale frames based on the grayscale values ​​of pixels and the position distribution of pixels in the image grayscale frames;

[0007] According to the difference between the edge of the student gathering area contained in the circumscribed rectangle of the corresponding student gathering area in the image grayscale frame and the previous frame of the image grayscale frame, the activity change degree of the student gathering area is obtained, and according to the image grayscale frame and the adjacent frame before the image grayscale frame, the motion direction vector of each student gathering area contained in the image grayscale frame is determined, and according to the activity change degree of the student gathering area and the difference between the directions corresponding to the motion direction vectors of the student gathering area and different student gathering areas in the same image grayscale frame, the danger of the student gathering area is obtained, and the activity risk area is divided according to the danger;

[0008] According to the distance between the student gathering area and the activity risk area, the danger of the activity risk area, and the Euclidean distance between all student gathering areas in the same image grayscale frame, the corrected danger of the target student gathering area is obtained; according to the corrected danger of the student gathering area in the image grayscale frame, the adjusted edge retention degree of the student gathering area is determined, and the adjusted edge retention degree of the student individual area is assigned to a fifth preset parameter;

[0009] According to the values ​​of the adjusted edge retention degrees within the student gathering area and the student individual area, the edges within the student gathering area and the student individual area are determined, and the image segmentation results for student safety behavior analysis are obtained.

[0010] Furthermore, the method for obtaining the student gathering area and the student individual area in the image grayscale frame is:

[0011] Divide the student area according to the gray value of the pixel in the gray frame of the image;

[0012] The product of the first preset parameter and the average number of pixels in all student areas contained in the grayscale frame of the image where the student area is located is recorded as the first product of the student area, the ratio of the number of pixels in the student area to the first product of the student area is recorded as the first ratio of the student area, and the function value of the logarithmic function with 2 as the base, which takes the first ratio of the student area as the independent variable, is recorded as the relative area of ​​the student area;

[0013] When the relative area of ​​the student area is greater than the second preset parameter, the student area is recorded as a student gathering area; when the relative area of ​​the student area is less than or equal to the second preset parameter, the student area is recorded as an individual student area.

[0014] Further, the activity change degree of the student gathering area is obtained according to the difference between the edge of the student gathering area contained in the circumscribed rectangle of the corresponding student gathering area in the image grayscale frame and the previous frame of the image grayscale frame, including the specific method of:

[0015] The sum of the number of pixel points contained in the edges of all student gathering areas contained in the circumscribed rectangle of the student gathering area is recorded as the edge perimeter of the student gathering area;

[0016] Track each student gathering area in the image grayscale frame corresponding to the image frame of the video, obtain the student gathering area corresponding to the image grayscale frame and the previous frame of the image grayscale frame, and record the mean square error of the edge perimeter between the student gathering area and the student gathering area corresponding to the previous frame of the image grayscale frame where the student gathering area is located as the active edge change degree;

[0017] The activity change degree of the student gathering area is obtained according to the activity edge change degree and the edge perimeter of the student gathering area.

[0018] Furthermore, the specific method of obtaining the activity change degree of the student gathering area according to the edge perimeter and the activity edge change degree of the student gathering area is as follows:

[0019] The ratio of the edge perimeter of the student gathering area to the corresponding student gathering area in the previous frame of the image grayscale frame where the student gathering area is located is recorded as the second ratio of the student gathering area, and the product of the second ratio of the student gathering area and the activity edge change degree is recorded as the activity change degree of the student gathering area.

[0020] Furthermore, the specific method of determining the motion direction vector of each student gathering area contained in the image grayscale frame includes:

[0021] According to the image grayscale frame and the adjacent frame before the image grayscale frame, the optical flow vectors of all the student gathering areas in the image grayscale frame are obtained, and the optical flow vectors of the student gathering areas are recorded as the movement direction vectors of the student gathering areas.

[0022] Furthermore, the method of obtaining the danger of the student gathering area according to the activity change degree of the student gathering area and the difference between the directions corresponding to the motion direction vectors of the student gathering area and different student gathering areas in the same image grayscale frame, and dividing the activity risk area according to the danger includes the following specific methods:

[0023] Any student gathering area in the image grayscale frame is recorded as the target student gathering area, and any student gathering area in the same image grayscale frame as the target student gathering area but different from the target student gathering area is recorded as the comparison student gathering area;

[0024] The centroid of the target student gathering area is taken as the center of the circle, and the length of the line connecting the centroid of the target student gathering area and the centroid of the comparison student gathering area is used as the radius to draw a circle. The area determined by the circle is recorded as the interaction range of the target student gathering area and the comparison student gathering area, and the vector with the centroid of the target student gathering area and the centroid of the comparison student gathering area as the head and tail is recorded as the standard vector of the interaction range; any student gathering area within the interaction range between the target student gathering area and the comparison student gathering area is recorded as the student gathering area to be analyzed in the interaction range, and the angle between the motion direction vector of the student gathering area to be analyzed in the interaction range and the standard vector of the interaction range is recorded as the motion change direction of the student gathering area to be analyzed; the opposite number of the cosine value of the motion change direction of the student gathering area to be analyzed is recorded as the motion change similarity of the student gathering area to be analyzed; the average of the motion change similarities of all student gathering areas within the interaction range between the target student gathering area and the comparison student gathering area is recorded as the interaction range similarity between the target student gathering area and the comparison student gathering area; the average of the interaction range similarities between the target student gathering area and all different target student gathering areas in the same image grayscale frame is recorded as the interaction degree of the target student gathering area;

[0025] According to the activity variability and interaction degree in the student gathering area, the dangerousness of the student gathering area is obtained, and the activity risk area is divided according to the dangerousness.

[0026] Furthermore, the method of obtaining the danger of the student gathering area according to the activity change degree and interaction degree of the student gathering area and dividing the activity risk area according to the danger includes the following specific methods:

[0027] The product of the activity change degree and the interaction degree in the student gathering area is recorded as the danger of the student gathering area;

[0028] When the danger level of the student gathering area is greater than the third preset parameter, the student gathering area is marked as an activity risk area.

[0029] Furthermore, the corrected risk of the target student gathering area is obtained by:

[0030] The average of the Euclidean distances between every two student gathering areas in the image grayscale frame is recorded as the standard distance of the image grayscale frame; the fourth preset parameter activity risk area with the closest Euclidean distance to the target student gathering area is recorded as the neighboring activity risk area of ​​the target student gathering area;

[0031] The Euclidean distance between the target student gathering area and the neighboring activity risk area is used as the denominator, the standard distance of the image grayscale frame where the target student gathering area is located is used as the numerator, and the value of the fraction is recorded as the relative distance between the target student gathering area and the neighboring activity risk area;

[0032] Taking the relative distance between the target student gathering area and the neighboring activity risk area as the weight, the danger of the neighboring activity risk area of ​​the target student gathering area is weighted summed to obtain the corrected danger of the target student gathering area.

[0033] Furthermore, the adjustment edge retention degree of the student gathering area is obtained by:

[0034] The sum of the corrected danger of the student gathering area and the number 1 is recorded as the first sum value of the student gathering area, and the percentage of the product of the first sum value of the student gathering area and the fifth preset parameter is expressed as the adjusted edge retention degree of the student gathering area.

[0035] Furthermore, the edges in the student gathering area and the student individual area are determined according to the values ​​of the adjusted edge retention degrees of the student gathering area and the student individual area, including the specific method of:

[0036] Use the Canny edge detection algorithm to obtain the strong edges, weak edges and non-edges of all student areas in the image grayscale frame, and record the strong edges and weak edges of all student areas in the image grayscale frame as initial strong edges and initial weak edges respectively;

[0037] The initial strong edges and initial weak edges whose edge retention is adjusted before the gradient value is taken as the gradient value of all the initial strong edges and initial weak edges in the student gathering area are all recorded as strong edges, and the initial strong edges and initial weak edges that are not strong edges are all recorded as weak edges;

[0038] Based on the strong edges and weak edges, the Canny edge detection algorithm is used to obtain the edges in the grayscale frame of the image.

[0039] The beneficial effects of the present invention are:

[0040] The present application first divides the student gathering area and the student individual area in the image grayscale frame of the video collected at the location where the student safety behavior analysis is required, and evaluates the activity level of the student activities corresponding to the student gathering area based on the characteristics that when different students gather in the same area to form a student gathering area, the activities are obviously more active and the possibility of unsafe behavior is greater. The activity change degree of the student gathering area is obtained, and further, combined with the overall behavior pattern between the students corresponding to the student gathering area, a more accurate evaluation of the activity level of the student activities is obtained, the danger of the student gathering area is obtained, and the activity risk area is divided according to the danger; considering that students near the area where safety risks occur may be affected by the behavior of students with safety risks around them, the danger of the student gathering area is further corrected according to the distance between the student gathering area and the surrounding activity risk area, the corrected danger of the target student gathering area is obtained, and the adjusted edge retention degree of the student gathering area and the student individual area is determined according to the corrected danger; finally, according to the values ​​of the adjusted edge retention degree of the student gathering area and the student individual area, the edges of the student gathering area and the student individual area are determined, and the image segmentation result for student safety behavior analysis is obtained, so as to solve the problem of inaccurate image segmentation for student safety behavior analysis caused by complex student behavior patterns. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0042] Figure 1 A schematic flow chart of an image segmentation method for analyzing student safety behavior provided by one embodiment of the present invention;

[0043] Figure 2 A flow chart for obtaining an activity risk area provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0044] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. 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.

[0045] See also Figure 1, which shows a flow chart of an image segmentation method for analyzing student safety behavior provided by an embodiment of the present invention, the method comprising the following steps:

[0046] Step S001, collect video at the location where student safety behavior analysis is required, obtain image grayscale frames based on the image frames of the video, and divide the student gathering area and student individual area in the image grayscale frame according to the grayscale value of the pixels in the image grayscale frame and the position distribution of the pixels.

[0047] Install high-resolution cameras at locations on campus where student safety behavior analysis is required, use the high-resolution cameras to collect videos of locations on campus that need real-time monitoring, and use the memory stick of the high-resolution cameras to store the collected videos.

[0048] Each image frame of the captured video is processed and analyzed separately.

[0049] The image frame is converted into a grayscale image, the image grayscale frame is obtained, and the image grayscale frame is subjected to image denoising using wavelet transform.

[0050] Preferably, in one embodiment of the present application, the locations on campus where student safety behavior analysis is required include classrooms, corridors and playgrounds. Using wavelet transform to perform image denoising on image grayscale frames is a well-known technology and will not be elaborated on. In actual application, as other implementation methods, implementers can decide on their own the locations on campus that require real-time monitoring and the method of performing image denoising on image grayscale frames based on actual conditions. This application does not impose any special restrictions.

[0051] The backgrounds of the tables, chairs, playgrounds, etc. in the locations that need to be monitored in real time on campus are quite different from the students. The OTSU maximum inter-class variance method is used to process the image grayscale frame to obtain the division threshold, and the connected domain analysis is performed on the pixels whose grayscale values ​​in the image grayscale frame are greater than the division threshold to obtain the connected domain. All connected domains are recorded as student areas.

[0052] The OTSU maximum inter-class variance method is used to obtain the division threshold and the known technology of connected domain analysis, which will not be elaborated here. As other implementation methods, on the basis of achieving the purpose of dividing the student area according to the grayscale value of the pixel points in the image grayscale frame, the implementer can use the existing technology such as convolutional neural network to divide the student area, and this application does not make any special restrictions.

[0053] The behavior patterns of students are complex, and the behavior patterns of different students in the same grayscale frame of the image are also different. When multiple students are active in the same area, the areas corresponding to different students may overlap in the grayscale frame of the image, presenting a whole area where students gather. When the areas corresponding to multiple students overlap, presenting a whole area where students gather, the number of pixels contained in the whole area where students gather is significantly greater than the student area corresponding to one student.

[0054] Get the relative area of ​​the student region based on the difference between the number of pixels contained in the student region and other student regions.

[0055] Preferably, as an embodiment of the present application, the product of the first preset parameter and the average number of pixels contained in all student areas contained in the image grayscale frame where the student area is located is recorded as the first product of the student area, the ratio of the number of pixels contained in the student area to the first product of the student area is recorded as the first ratio of the student area, and the function value of the logarithmic function with the first ratio of the student area as the independent variable and base 2 is recorded as the relative area of ​​the student area.

[0056] Specifically, the calculation formula for the relative area of ​​the student area is:

[0057] ,

[0058] In the formula, Indicates i the relative size of the student areas; Indicates i The number of pixels contained in the student area; S Indicates i The mean number of pixels contained in all student areas contained in the grayscale frame of the image where the student area is located; represents the first preset parameter. In this embodiment, the value of the first preset parameter is 10; Represents the base 2 logarithmic function.

[0059] Understandably, Indicates i The first ratio of student areas, Represents the first ratio of the student area.

[0060] When the number of pixels contained in the student area is greater than the number of pixels contained in other student areas, the student area is more likely to correspond to the overall area where students gather, and the number of different students contained in the student area is greater. At this time, the relative area of ​​the student area is larger.

[0061] A second preset parameter is set. In this embodiment, the value of the second preset parameter is 0.5. When the relative area of ​​the student area is greater than the second preset parameter, the student area is recorded as a student gathering area. When the relative area of ​​the student area is less than or equal to the second preset parameter, the student area is recorded as an individual student area.

[0062] At this point, the student gathering areas and student individual areas are obtained.

[0063] Step S002: Obtain the activity change degree of the student gathering area according to the difference between the edge of the student gathering area contained in the circumscribed rectangle of the corresponding student gathering area in the image grayscale frame and the previous frame of the image grayscale frame, determine the motion direction vector of each student gathering area contained in the image grayscale frame according to the image grayscale frame and the adjacent frames before the image grayscale frame, obtain the danger of the student gathering area according to the activity change degree of the student gathering area and the difference between the directions corresponding to the motion direction vectors of the student gathering area and different student gathering areas in the same image grayscale frame, and divide the activity risk area according to the danger.

[0064] When different students gather in the same area to form a student gathering area, the activities are obviously more active than those of a single student individual, and the possibility of unsafe behavior is greater. Furthermore, considering the different behaviors that occur when students gather, for example, students can gather together to chat or study, or they can gather together to play games and activities. When students gather together to play games and activities, the activity level of student activities in the student gathering area is obviously higher, and the possibility of unsafe behavior is higher. Therefore, the accuracy of image segmentation of the image grayscale frame where the student gathering area is located should be determined according to the activity level of student activities in the student gathering area.

[0065] Use the Soble edge detection algorithm on the grayscale frame of the image to obtain the edge in the grayscale frame of the image. Obtain the bounding rectangle of the student gathering area. The sum of the number of pixels contained in the edges of all student gathering areas contained in the bounding rectangle of the student gathering area is recorded as the edge perimeter of the student gathering area.

[0066] The YOLO target tracking algorithm is used to track each student gathering area in the image grayscale frame corresponding to the image frame of the video, and the student gathering area corresponding to the image grayscale frame and the previous frame of the image grayscale frame is obtained. When the student gathering area cannot obtain the corresponding student gathering area, it means that the student gathering area does not have significant student gathering characteristics, and the following analysis is no longer performed on the student gathering area. The mean square error of the edge perimeter of the student gathering area and the corresponding student gathering area in the previous frame of the image grayscale frame where the student gathering area is located is recorded as the active edge change degree.

[0067] When the degree of change of the activity edge is greater, the difference in the edge perimeter between the student gathering area and the corresponding student gathering area in the previous frame of the image grayscale frame where the student gathering area is located is greater, and the level of student activities corresponding to the student gathering area is more intense in the time period corresponding to adjacent image grayscale frames.

[0068] Among them, using the Soble edge detection algorithm to obtain the edge is a well-known technology, and using the YOLO target tracking algorithm to track the area and obtain the corresponding area is a well-known technology, which will not be repeated.

[0069] The activity change degree of the student gathering area is obtained according to the activity edge change degree and the edge perimeter of the student gathering area.

[0070] Preferably, as an embodiment of the present application, the ratio of the edge perimeter of the student gathering area to the corresponding student gathering area in the previous frame of the image grayscale frame where the student gathering area is located is recorded as the second ratio of the student gathering area, and the product of the second ratio of the student gathering area and the activity edge variation degree is recorded as the activity variation degree of the student gathering area.

[0071] Specifically, the calculation formula for the activity change degree of the student gathering area is:

[0072] ,

[0073] In the formula, Indicates the grayscale frame of the image j The degree of activity variability in student gathering areas; Indicates the grayscale frame of the image j The perimeter of the area where students gather; Indicates j The edge perimeter of the corresponding student gathering area in the previous frame of the image grayscale frame where the student gathering area is located; Indicates the grayscale frame of the image j The degree of activity edge variability of student gathering areas.

[0074] Understandably, Indicates the grayscale frame of the image j The second ratio of student gathering areas.

[0075] When the activity change degree of the student gathering area is greater, the difference in the edge perimeter between the student gathering area and the corresponding student gathering area in the previous frame of the image grayscale frame where the student gathering area is located is greater, and the level of student activities corresponding to the student gathering area is more intense in the time period corresponding to adjacent image grayscale frames.

[0076] When students frequently move irregularly between the football field and the basketball court, the differences in the corresponding movement directions of the students are large, and there is a high degree of interactivity between the students. At this time, the possibility of unsafe behaviors and conflicts such as collisions between students is high. Therefore, the difference in movement directions corresponding to different student gathering areas can also characterize the activeness of student activities corresponding to the student gathering areas. The intensity of student activities can be more accurately evaluated based on the difference in movement directions corresponding to different student gathering areas. Therefore, on the basis of using the difference between the edges contained in the circumscribed rectangles of the corresponding student gathering areas in adjacent image grayscale frames to evaluate the activeness of student activities, it is necessary to combine the overall behavior patterns between students corresponding to the student gathering areas to obtain a more accurate evaluation of the activeness of student activities.

[0077] The Lucas-Kanade method is used to process the image grayscale frame and the adjacent frames before the image grayscale frame to obtain the optical flow vectors of all student gathering areas in the image grayscale frame, and the optical flow vectors of the student gathering areas are recorded as the movement direction vectors of the student gathering areas.

[0078] Preferably, this embodiment uses the Lucas-Kanade method to obtain the optical flow vectors of the student gathering area. As other implementation methods, on the basis of achieving the purpose of obtaining the optical flow vectors of the student gathering area, the implementer can adopt other methods in the prior art such as the Horn-Schunck method to obtain the optical flow vectors of the student gathering area. This application does not impose any special restrictions.

[0079] The interaction degree of the student gathering area is obtained according to the difference between the directions corresponding to the motion direction vectors of the student gathering area and different student gathering areas in the same image grayscale frame.

[0080] Any student gathering area in the image grayscale frame is recorded as the target student gathering area, and any student gathering area in the same image grayscale frame that is different from the target student gathering area is recorded as the comparison student gathering area.

[0081] The centroid of the target student gathering area is taken as the center of the circle, and the length of the line connecting the centroid of the target student gathering area and the centroid of the comparison student gathering area is taken as the radius to draw a circle. The area determined by the circle is recorded as the interaction range of the target student gathering area and the comparison student gathering area. The vectors with the centroid of the target student gathering area and the centroid of the comparison student gathering area as the head and tail are recorded as the standard vector of the interaction range. Any student gathering area with the centroid within the interaction range between the target student gathering area and the comparison student gathering area is recorded as the student gathering area to be analyzed in the interaction range. The angle between the motion direction vector of the student gathering area to be analyzed in the interaction range and the standard vector of the interaction range is recorded as the motion change direction of the student gathering area to be analyzed. The opposite of the cosine value of the motion change direction of the student gathering area to be analyzed is recorded as the motion change similarity of the student gathering area to be analyzed. The average of the motion change similarity of all student gathering areas within the interaction range between the target student gathering area and the comparison student gathering area is recorded as the interaction range similarity between the target student gathering area and the comparison student gathering area. The average of the similarities of the interaction ranges between the target student gathering area and all different target student gathering areas in the same image grayscale frame is recorded as the interaction degree of the target student gathering area.

[0082] The same method can be used to obtain the interaction degree of any student gathering area in the image grayscale frame. That is to say, for any student gathering area in the image grayscale frame, there is a corresponding interaction degree.

[0083] When the difference between the directions corresponding to the motion direction vectors of the student gathering area and different student gathering areas in the same image grayscale frame is greater, the movement between the students corresponding to the student gathering area and different student gathering areas in the same image grayscale frame is more disordered, and the possibility of unsafe behaviors and conflicts such as collisions between students is greater. At this time, the degree of interaction of the student gathering area is greater.

[0084] The danger level of student gathering areas is obtained based on the activity variability and interaction level in student gathering areas.

[0085] Preferably, as an embodiment of the present application, the product of the activity change degree and the interaction degree of the student gathering area is recorded as the dangerousness of the student gathering area.

[0086] Specifically, the calculation formula for the danger of student gathering areas is:

[0087] ,

[0088] In the formula, Indicates the grayscale frame of the image j the danger of areas where students gather; Indicates the grayscale frame of the image jThe degree of activity variability in student gathering areas; Indicates the grayscale frame of the image j The degree of interaction in student gathering areas.

[0089] A third preset parameter is set. In this embodiment, the value of the third preset parameter is 0.5. When the danger of the student gathering area is greater than the third preset parameter, the student gathering area is marked as an activity risk area. The activity risk area corresponds to the area where safety risks occur during student activities.

[0090] At this point, the activity risk area is obtained. The activity risk area acquisition flow chart is as follows: Figure 2 shown.

[0091] Step S003, obtain the corrected danger of the target student gathering area according to the distance between the student gathering area and the activity risk area, the danger of the activity risk area, and the Euclidean distance between all student gathering areas in the same image grayscale frame, determine the adjusted edge retention degree of the student gathering area according to the corrected danger of the student gathering area in the image grayscale frame, and assign the adjusted edge retention degree of the student individual area as the fifth preset parameter.

[0092] If the student's own activities do not pose a safety risk, but the student is near multiple areas with safety risks, the student may be affected by the behavior of students with safety risks around him. For example, when walking near students who are playing more violently, he may be accidentally injured by the students who are playing more violently. Therefore, it is necessary to further correct the danger of the student gathering area based on the distance between the student gathering area and the surrounding activity risk area.

[0093] The corrected danger of the target student gathering area is obtained according to the distance between the target student gathering area and the active risk area, the danger of the active risk area, and the Euclidean distance between all student gathering areas in the same image grayscale frame.

[0094] Preferably, as an embodiment of the present application, the mean of the Euclidean distances between every two student gathering areas in the image grayscale frame is recorded as the standard distance of the image grayscale frame. Among them, the Euclidean distance between the student gathering areas is the Euclidean distance between the centroids of the two student gathering areas. The fourth preset parameter activity risk area that is closest to the Euclidean distance between the target student gathering area is recorded as the neighboring activity risk area of ​​the target student gathering area, the Euclidean distance between the target student gathering area and the neighboring activity risk area is used as the denominator, the standard distance of the image grayscale frame where the target student gathering area is located is used as the numerator, and the value of the fraction is recorded as the relative distance between the target student gathering area and the neighboring activity risk area. The relative distance between the target student gathering area and the neighboring activity risk area is used as the weight, and the danger of the neighboring activity risk area of ​​the target student gathering area is weighted summed to obtain the corrected danger of the target student gathering area.

[0095] In this embodiment, the value of the fourth preset parameter is 8.

[0096] Specifically, the calculation formula for the corrected risk of the student gathering area is:

[0097] ,

[0098] In the formula, Indicates the grayscale frame of the image j Corrected hazard of student population areas; represents the fourth preset parameter. In this embodiment, the value of the fourth preset parameter is 8; Indicates j The standard distance of the grayscale frame of the image where the student gathering area is located; Indicates the grayscale frame of the image j The student gathering area and u The Euclidean distance between neighboring activity risk areas; Indicates the grayscale frame of the image j The student gathering area and u The danger of adjacent activity risk areas.

[0099] When the Euclidean distance between the target student gathering area and the neighboring activity risk area in the image grayscale frame is larger relative to the standard distance of the image grayscale frame, the target student gathering area is farther away from the neighboring activity risk area, and the target student gathering area is less likely to be affected by the behavior of students with safety risks around it. At this time, the correction risk of the target student gathering area is smaller.

[0100] According to the correction danger of the student gathering area in the image grayscale frame, the adjustment edge preservation degree of the student gathering area is determined.

[0101] Preferably, as an embodiment of the present application, the sum of the corrected dangerousness of the student gathering area and the number 1 is recorded as the first sum value of the student gathering area, and the percentage of the product of the first sum value of the student gathering area and the fifth preset parameter is expressed as the adjusted edge retention degree of the student gathering area.

[0102] Among them, the calculation formula for the adjusted edge retention degree of the student gathering area is:

[0103] ,

[0104] In the formula, Indicates the grayscale frame of the image j Adjust the edge preservation of each student gathering area; Indicates the grayscale frame of the image j Corrected hazard of student population areas; represents the fifth preset parameter. In this embodiment, the value of the fifth preset parameter is 0.4.

[0105] The adjustment edge preservation degree of the student individual area is assigned as the fifth preset parameter.

[0106] At this point, the adjusted edge retention degrees of the student gathering area and the student individual area are obtained.

[0107] Step S004: determine the edges in the student gathering area and the student individual area according to the values ​​of the adjusted edge retention degrees in the student gathering area and the student individual area, and obtain the image segmentation results for student safety behavior analysis.

[0108] The Canny edge detection algorithm can extract edge information from the grayscale frame of an image and obtain all strong edges, weak edges, and non-edges in the grayscale frame of the image. All strong edges, weak edges, and non-edges in the grayscale frame of the image are determined based on the preset low threshold and high threshold. Specifically: when the gradient value of a pixel is greater than the high threshold, the pixel is recorded as a strong edge and the pixel is directly determined as an edge pixel; when the gradient value of a pixel is less than or equal to the high threshold and greater than or equal to the low threshold, the pixel is recorded as a weak edge; when the gradient value of a pixel is less than the low threshold, the pixel is recorded as a non-edge, that is, the pixel is determined as a non-edge pixel.

[0109] According to the values ​​of the adjusted edge retention degrees within the student gathering area and the student individual area, the edges within the student gathering area and the student individual area are determined, and the image segmentation results for student safety behavior analysis are obtained.

[0110] Specifically, the Canny edge detection algorithm is used to obtain the strong edges, weak edges and non-edges of all student gathering areas and student individual areas in the image grayscale frame. The strong edges and weak edges of all student gathering areas and student individual areas in the image grayscale frame are respectively recorded as initial strong edges and initial weak edges, and the initial strong edges and initial weak edges are re-determined as strong edges and weak edges. Specifically, the adjusted edge retention degree of the student individual area is used as the threshold for determining all initial strong edges and initial weak edges in the student individual area as strong edges and weak edges. When the gradient value of the initial strong edge and the initial weak edge in the student individual area is the former gradient value of the gradient value of all pixels in the student individual area, the initial strong edge and the initial weak edge in the student individual area are All weak edges are recorded as strong edges, otherwise, the initial strong edges and initial weak edges in the student individual area are recorded as weak edges; the adjusted edge retention degree of the student gathering area is used as the threshold for judging all the initial strong edges and initial weak edges in the student gathering area as strong edges and weak edges, when the gradient value of the pixel point in the student gathering area is the first adjusted edge retention degree gradient value of the gradient value of all the initial strong edges and initial weak edges in the student gathering area, the initial strong edges and initial weak edges in the student gathering area are recorded as strong edges, otherwise, the initial strong edges and initial weak edges in the student gathering area are recorded as weak edges.

[0111] For example, when the adjusted edge retention degree of the student gathering area is 60%, the initial strong edges and initial weak edges whose gradient values ​​are the first 60% of the gradient values ​​of all the initial strong edges and initial weak edges in the student gathering area are recorded as strong edges, and the initial strong edges and initial weak edges whose gradient values ​​are the last 40% of the gradient values ​​of all the initial strong edges and initial weak edges in the student gathering area are recorded as weak edges.

[0112] According to the re-determination results of strong edges and weak edges, the Canny edge detection algorithm is used to obtain the edges in the grayscale frame of the image, and the areas divided by the edges are recorded as student areas.

[0113] At this point, the image segmentation results for student safety behavior analysis are obtained.

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

Claims

1. An image segmentation method for student safety behavior analysis, It is characterized in that The method comprises the following steps: Collect videos at locations where student safety behavior analysis is required, obtain image grayscale frames based on image frames of the video, and divide student gathering areas and student individual areas in the image grayscale frames based on the grayscale values ​​of pixels and the position distribution of pixels in the image grayscale frames; According to the difference between the edge of the student gathering area contained in the circumscribed rectangle of the corresponding student gathering area in the image grayscale frame and the previous frame of the image grayscale frame, the activity change degree of the student gathering area is obtained, and according to the image grayscale frame and the adjacent frame before the image grayscale frame, the motion direction vector of each student gathering area contained in the image grayscale frame is determined, and according to the activity change degree of the student gathering area and the difference between the directions corresponding to the motion direction vectors of the student gathering area and different student gathering areas in the same image grayscale frame, the danger of the student gathering area is obtained, and the activity risk area is divided according to the danger; According to the distance between the student gathering area and the activity risk area, the danger of the activity risk area, and the Euclidean distance between all student gathering areas in the same image grayscale frame, the corrected danger of the target student gathering area is obtained; according to the corrected danger of the student gathering area in the image grayscale frame, the adjusted edge retention degree of the student gathering area is determined, and the adjusted edge retention degree of the student individual area is assigned to a fifth preset parameter; According to the values ​​of the adjusted edge preservation degrees of the student gathering area and the student individual area, the edges in the student gathering area and the student individual area are determined to obtain the image segmentation results for the student safety behavior analysis; The method of determining the edges in the student gathering area and the student individual area according to the values ​​of the adjusted edge retention degrees of the student gathering area and the student individual area includes the following specific methods: According to the grayscale values ​​of the pixels in the grayscale frame of the image, the student area is divided, and the strong edges, weak edges and non-edges of all the student areas in the grayscale frame of the image are obtained by using the Canny edge detection algorithm. The strong edges and weak edges of all the student areas in the grayscale frame of the image are recorded as initial strong edges and initial weak edges respectively; The initial strong edges and initial weak edges whose edge retention is adjusted before the gradient value is taken as the gradient value of all the initial strong edges and initial weak edges in the student gathering area are all recorded as strong edges, and the initial strong edges and initial weak edges that are not strong edges are all recorded as weak edges; Based on the strong edges and weak edges, the Canny edge detection algorithm is used to obtain the edges in the grayscale frame of the image.

2. According to claim 1, an image segmentation method for analyzing student safety behavior, It is characterized in that The method for obtaining the student gathering area and the student individual area in the image grayscale frame is: The product of the first preset parameter and the average number of pixels in all student areas contained in the grayscale frame of the image where the student area is located is recorded as the first product of the student area, the ratio of the number of pixels in the student area to the first product of the student area is recorded as the first ratio of the student area, and the function value of the logarithmic function with 2 as the base, which takes the first ratio of the student area as the independent variable, is recorded as the relative area of ​​the student area; When the relative area of ​​the student area is greater than the second preset parameter, the student area is recorded as a student gathering area; when the relative area of ​​the student area is less than or equal to the second preset parameter, the student area is recorded as an individual student area.

3. The image segmentation method for analyzing student safety behavior according to claim 1, It is characterized in that The specific method of obtaining the activity change degree of the student gathering area according to the difference between the edge of the student gathering area contained in the circumscribed rectangle of the corresponding student gathering area in the image grayscale frame and the previous frame of the image grayscale frame is as follows: The sum of the number of pixels contained in the edges of all student gathering areas contained in the circumscribed rectangle of the student gathering area is recorded as the edge perimeter of the student gathering area; Track each student gathering area in the image grayscale frame corresponding to the image frame of the video, obtain the student gathering area corresponding to the image grayscale frame and the previous frame of the image grayscale frame, and record the mean square error of the edge perimeter between the student gathering area and the student gathering area corresponding to the previous frame of the image grayscale frame where the student gathering area is located as the active edge change degree; The activity change degree of the student gathering area is obtained according to the activity edge change degree and the edge perimeter of the student gathering area.

4. The image segmentation method for analyzing student safety behavior according to claim 3, It is characterized in that The specific method of obtaining the activity change degree of the student gathering area according to the edge perimeter of the student gathering area and the activity edge change degree includes: The ratio of the edge perimeter of the student gathering area to the corresponding student gathering area in the previous frame of the image grayscale frame where the student gathering area is located is recorded as the second ratio of the student gathering area, and the product of the second ratio of the student gathering area and the activity edge change degree is recorded as the activity change degree of the student gathering area.

5. The image segmentation method for analyzing student safety behavior according to claim 1, It is characterized in that The specific method of determining the motion direction vector of each student gathering area contained in the image grayscale frame includes: According to the image grayscale frame and the adjacent frame before the image grayscale frame, the optical flow vectors of all the student gathering areas in the image grayscale frame are obtained, and the optical flow vectors of the student gathering areas are recorded as the movement direction vectors of the student gathering areas.

6. The image segmentation method for analyzing student safety behavior according to claim 1, It is characterized in that The method of obtaining the danger of the student gathering area according to the activity change degree of the student gathering area and the difference between the directions corresponding to the motion direction vectors of the student gathering area and different student gathering areas in the same image grayscale frame, and dividing the activity risk area according to the danger includes the following specific methods: Any student gathering area in the image grayscale frame is recorded as the target student gathering area, and any student gathering area in the same image grayscale frame as the target student gathering area but different from the target student gathering area is recorded as the comparison student gathering area; Take the centroid of the target student gathering area as the center of the circle, and the length of the line connecting the centroid of the target student gathering area and the centroid of the comparison student gathering area as the radius to draw a circle, record the area determined by the circle as the interaction range of the target student gathering area and the comparison student gathering area, and record the vector with the centroid of the target student gathering area and the centroid of the comparison student gathering area as the head and tail as the standard vector of the interaction range; record any student gathering area whose centroid is within the interaction range between the target student gathering area and the comparison student gathering area as the student gathering area to be analyzed in the interaction range, and compare the movement direction vector of the student gathering area to be analyzed in the interaction range with the standard vector of the interaction range. The angle between the standard vectors of the interaction range is recorded as the direction of motion change of the student gathering area to be analyzed; the opposite number of the cosine value of the motion change direction of the student gathering area to be analyzed is recorded as the motion change similarity of the student gathering area to be analyzed; the average of the motion change similarities of all student gathering areas within the interaction range between the target student gathering area and the comparison student gathering area is recorded as the interaction range similarity between the target student gathering area and the comparison student gathering area; the average of the interaction range similarities between the target student gathering area and all different target student gathering areas in the same image grayscale frame is recorded as the interaction degree of the target student gathering area; According to the activity variability and interaction degree in the student gathering area, the dangerousness of the student gathering area is obtained, and the activity risk area is divided according to the dangerousness.

7. The image segmentation method for analyzing student safety behavior according to claim 6, It is characterized in that The method of obtaining the danger of the student gathering area according to the activity change degree and interaction degree of the student gathering area and dividing the activity risk area according to the danger includes: The product of the activity change degree and the interaction degree in the student gathering area is recorded as the danger of the student gathering area; When the danger level of the student gathering area is greater than the third preset parameter, the student gathering area is marked as an activity risk area.

8. The image segmentation method for analyzing student safety behavior according to claim 1, It is characterized in that The specific method for obtaining the corrected risk of the target student gathering area is as follows: The average of the Euclidean distances between every two student gathering areas in the image grayscale frame is recorded as the standard distance of the image grayscale frame; the fourth preset parameter activity risk area with the closest Euclidean distance to the target student gathering area is recorded as the neighboring activity risk area of ​​the target student gathering area; The Euclidean distance between the target student gathering area and the neighboring activity risk area is used as the denominator, the standard distance of the image grayscale frame where the target student gathering area is located is used as the numerator, and the value of the fraction is recorded as the relative distance between the target student gathering area and the neighboring activity risk area; Taking the relative distance between the target student gathering area and the neighboring activity risk area as the weight, the danger of the neighboring activity risk area of ​​the target student gathering area is weighted summed to obtain the corrected danger of the target student gathering area.

9. The image segmentation method for analyzing student safety behavior according to claim 1, It is characterized in that The specific method for obtaining the adjusted edge retention degree of the student gathering area is as follows: The sum of the corrected danger of the student gathering area and the number 1 is recorded as the first sum value of the student gathering area, and the percentage of the product of the first sum value of the student gathering area and the fifth preset parameter is expressed as the adjusted edge retention degree of the student gathering area.