Vehicle alarm methods, electronic devices and vehicles

By acquiring images from the vehicle and detecting the relative motion of target objects, combined with facial recognition and age verification, alarm information is output, solving the problem of traffic accidents caused by driver inattention and improving vehicle safety.

CN114299463BActive Publication Date: 2025-10-31BOZHOU KAIYUAN ELECTRONIC TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111671418.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-31
Publication Date
2025-10-31
Estimated Expiration
2041-12-31

AI Technical Summary

Technical Problem

When a vehicle is traveling on the road, a driver’s lack of attention can lead to a traffic accident involving a pedestrian or other vehicle.

Method used

By acquiring images of the area in front of the vehicle, detecting target objects and calculating their relative motion with the vehicle, an alarm message is output when preset conditions are met. Combined with facial recognition and age verification systems, this ensures that legitimate users can unlock the vehicle.

Benefits of technology

Effectively reduce traffic accidents and ensure safe vehicle operation, especially in scenarios such as shared bicycles, reminding users to maintain good traffic behavior.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114299463B_ABST
    Figure CN114299463B_ABST
Patent Text Reader

Abstract

This application discloses a vehicle alarm method, electronic device, and vehicle. The vehicle alarm method includes: acquiring a first image of the area in front of the vehicle; detecting whether the first image contains a target object; when the first image contains a target object, extracting a first region containing the target object in the first image; obtaining the area ratio between the first region and the first image; when the area ratio is greater than or equal to a preset area ratio threshold, determining the relative motion state between the target object and the vehicle based on the first region; when the relative motion state is a preset motion state, outputting alarm information. This application helps reduce the occurrence of traffic accidents.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image processing technology, specifically to a vehicle alarm method, electronic device, and vehicle. Background Technology

[0002] Vehicles are a means of transportation that provides convenience for people's travel. However, while vehicles are driving on the road, some drivers are inattentive and fail to pay attention to pedestrians or other vehicles, causing traffic accidents. Summary of the Invention

[0003] Based on this, in order to solve or improve the problems of the prior art, this application provides a vehicle alarm method, electronic device and vehicle, which is beneficial to reducing the occurrence of traffic accidents.

[0004] Firstly, a vehicle alarm method is provided, including:

[0005] Acquire the first image of the area in front of the vehicle;

[0006] Detect whether the first image contains a target object;

[0007] When the first image contains the target object, extract the first region in the first image that contains the target object;

[0008] Obtain the area ratio between the first region and the first image. When the area ratio is greater than or equal to a preset area ratio threshold, determine the relative motion state between the target object and the vehicle based on the first region.

[0009] When the relative motion state is a preset motion state, an alarm message is output.

[0010] In one embodiment, before acquiring the first image of the area in front of the vehicle, the method further includes:

[0011] Establish a user facial database;

[0012] The vehicle is unlocked when the first facial image matches a facial image in the facial database.

[0013] In one embodiment, establishing the user face database includes:

[0014] Obtain the second face image;

[0015] Obtain a face age classification model, and use the face age classification model to obtain the confidence level that the age corresponding to the second face image is greater than or equal to a preset age value;

[0016] When the confidence level is greater than or equal to the preset confidence level, the second facial features are extracted from the second facial image and added to the preset user facial database to obtain the user facial database;

[0017] The step of unlocking the vehicle when the first facial image matches a facial image in the facial database includes:

[0018] Acquire the first facial image captured by the camera;

[0019] Obtain a face recognition model, and use the face recognition model to determine whether the first face image is a face image in the user's face database;

[0020] When the first face image is a face image in the user's face database, the vehicle is unlocked.

[0021] In one embodiment, obtaining the facial age classification model includes:

[0022] Obtain the first set of training images, which contains a preset number of training images;

[0023] The first set of training images is used to train the preset face age classification model to obtain the face age classification model;

[0024] The first loss function used in training the preset face age classification model using the first set of training images is:

[0025] L=L1+αL2+βL3

[0026] Where L is the first loss function, L1 is the additive angular interval loss function, L2 is the triplet loss function, L3 is the tail data loss function, α is the first preset coefficient, and β is the second preset coefficient.

[0027] The process of obtaining the triplet loss function includes:

[0028] Obtain the first set of training images, which includes multiple training images of the third face and multiple training images of the fourth face;

[0029] A first training image is obtained from multiple training images of the third face, and a second training image is obtained from multiple training images of the fourth face. The first training image and the second training image are two training images with the highest similarity that belong to different faces in the first set of training images.

[0030] A third training image and a fourth training image are obtained from multiple training images of the third face. The third training image and the fourth training image are the two training images with the lowest similarity among the multiple training images of the third face. A fifth training image and a sixth training image are obtained from multiple face images of the fourth face. The fifth training image and the sixth training image are the two training images with the lowest similarity among the multiple training images of the fourth face.

[0031] The triplet loss function is obtained based on the first training image, the second training image, the third training image, the fourth training image, the fifth training image, and the sixth training image;

[0032] The formula for calculating the triplet loss function is as follows:

[0033] L2 = 2 × S1 - S2 - S3

[0034] Wherein, L2 is the triplet loss function, S1 is the cosine similarity between the first training image and the second training image, S2 is the cosine similarity between the third training image and the fourth training image, and S3 is the cosine similarity between the fifth training image and the sixth training image.

[0035] The process of obtaining the tail data loss function includes:

[0036] Obtain the seventh training image of the fifth face and the eighth training image of the sixth face from the first set of training images. The number of training images corresponding to the fifth face and the number of training images corresponding to the sixth face are both one.

[0037] The cosine similarity between the seventh training image and the eighth training image is calculated to obtain the tail data loss function.

[0038] In one embodiment, detecting whether the first image contains a target object includes:

[0039] The first image is converted into a grayscale image, and the grayscale image is then subjected to global contrast normalization to obtain a normalized grayscale image.

[0040] The grayscale image is input into the target detection model to identify whether the grayscale image contains a target object;

[0041] When the first image contains the target object, extracting the first region containing the target object in the first image includes:

[0042] When a target object is detected in the grayscale image, the coordinates of the target object in the first image are output.

[0043] Based on the coordinates, a first region containing the target object is obtained.

[0044] In one embodiment, determining the relative motion state between the target object and the vehicle based on the first region includes:

[0045] A second region is obtained, which is the region in the second image of the area in front of the vehicle that corresponds to the first region. The time interval between the capture of the second image and the first image is a preset time.

[0046] The first region and the second region are input into the motion state detection model to detect the motion state of the target object.

[0047] In one embodiment, the motion state detection model includes at least one preset network. The preset network includes a first branch and a second branch. The input ends of the first branch and the second branch are connected. The output ends of the first branch and the second branch are connected through a first splicing module. The first branch includes a time shifting module, a second channel splicing module connected to the time shifting module, a channel compression module connected to the second channel splicing module, and a time difference extraction module connected to the time shifting module. The time difference extraction module is connected to the second channel splicing module.

[0048] The time shifting module is used to reorganize some channels in the input feature map so that some channels in the second type of channel group replace the corresponding channels in the first type of channel group, resulting in a reorganized channel group. The first type of channel group is the channel group in the feature map obtained after convolving the first region, and the second type of channel group is the channel group in the feature map obtained after convolving the second region.

[0049] The time difference extraction module is used to calculate the difference values ​​between different categories of channels in the recombined channel group, and to form difference channels based on the difference values;

[0050] The second channel splicing module is used to add the difference channels to the recombined channels to obtain a channel group with difference processing;

[0051] The channel compression module is used to compress the channel group of the difference processing, reducing the number of channels in the channel group of the difference processing to a preset number, thereby obtaining a compressed channel group;

[0052] The first splicing module is used to splice the compressed channel group with the channel group in the feature map output by the first branch to obtain a spliced ​​feature map.

[0053] The step of calculating the difference between different categories of channels in the recombined channel group includes: calculating the difference between the channel values ​​of different categories of channels in the recombined first category of channels, squaring the difference and calculating the square root to obtain the difference value.

[0054] In one embodiment, when the relative motion state is a preset motion state, the alarm information is output, including:

[0055] When the motion state is a stationary state, a first area ratio threshold corresponding to the stationary state is obtained; when the area ratio of the target object to the first image is greater than the first area ratio threshold, an alarm message is output; or,

[0056] When the motion state is a first motion state in which the vehicle is moving toward the target object at a first speed, a second area ratio threshold is obtained. When the area ratio of the target object to the first image is greater than the second area ratio threshold, an alarm message is output, wherein the first area ratio threshold is greater than the second area ratio threshold.

[0057] In a second aspect, an electronic device is provided, including a memory and a processor, the memory storing a computer program that can be executed by the processor to implement the steps of the vehicle alarm method as described above.

[0058] Thirdly, a vehicle is provided, including a vehicle body, an alarm component, a processor, and at least one camera; the camera is mounted on the vehicle body, and the processor is connected to the camera and the alarm component respectively.

[0059] The camera is used to acquire a first image of the area in front of the vehicle;

[0060] The processor is used to detect whether the first image contains a target object; when the first image contains the target object, it extracts a first region containing the target object in the first image; it obtains the area ratio between the first region and the first image; when the area ratio is greater than or equal to a preset area ratio threshold, it determines the relative motion state between the target object and the vehicle based on the first region; when the relative motion state is a preset motion state, it outputs an alarm signal.

[0061] The alarm component is used to trigger an alarm in response to the alarm signal.

[0062] The aforementioned vehicle alarm method detects a first image of the area in front of the vehicle. When a target object is detected in the first image, a first region containing the target object is extracted from the first image. The area ratio between the first region and the first image is calculated. When the area ratio is greater than or equal to a preset area ratio threshold, the relative motion state between the target object and the vehicle is determined based on the first region. When the relative motion state is a preset motion state, an alarm message is output to remind the user, which helps to reduce the occurrence of vehicle traffic accidents. Attached Figure Description

[0063] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. It should be understood that the accompanying drawings in the following description are merely for explaining the present invention and are not intended to limit the present invention.

[0064] Figure 1 This is a schematic flowchart of a vehicle alarm method according to an embodiment of this application;

[0065] Figure 2 This is a schematic diagram illustrating an application scenario of an embodiment of this application;

[0066] Figure 3 This is a schematic diagram of the structure of a preset network in a motion state detection model according to an embodiment of this application;

[0067] Figure 4 This is a schematic diagram of the channel relationships in the reorganized channel group according to an embodiment of this application;

[0068] Figure 5 This is a schematic diagram of the structure of an electronic device according to an embodiment of this application;

[0069] Figure 6 This is a schematic diagram showing the connection relationship of a camera, processor, and alarm component in a vehicle according to an embodiment of this application. Detailed Implementation

[0070] The technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. It should be understood that the specific embodiments described herein are merely used to explain the present invention and are not intended to limit the present invention.

[0071] Please see Figure 1 This application provides a vehicle alarm method, including:

[0072] Step 10: Obtain the first image of the area in front of the vehicle;

[0073] Step 20: Detect whether the first image contains a target object;

[0074] Step 30: When the first image contains a target object, extract the first region in the first image that contains the target object;

[0075] Step 40: Obtain the area ratio between the first region and the first image. When the area ratio is greater than or equal to a preset area ratio threshold, determine the relative motion state between the target object and the vehicle based on the first region.

[0076] Step 50: When the relative motion state is the preset motion state, output alarm information.

[0077] In this embodiment, vehicles include motor vehicles and non-motor vehicles. For example, a vehicle can be a car or a bicycle.

[0078] In one application scenario, the vehicle is a shared bicycle. Currently, shared bicycles have a large user base; however, some traffic accidents are caused by users riding them too fast or failing to notice pedestrians and other vehicles. This embodiment can remind users when the relative motion state of the shared bicycle is in a preset state, encouraging users to maintain good traffic behavior and reducing the occurrence of traffic accidents.

[0079] In step 10, the area in front of the vehicle is a preset area located in front of the vehicle in the direction of travel. The first image can be obtained by capturing it with a camera. Specifically, the camera can be positioned at the front of the vehicle to capture the area in front of the vehicle and obtain the first image.

[0080] In one embodiment, the method further includes steps 110 to 120 before acquiring a first image of the area in front of the vehicle.

[0081] Step 110: Establish a user face database. The face database stores a list of facial features, which are used to compare facial features with the stored features to achieve face recognition.

[0082] Step 120: When the first face image matches a face image in the face database, the vehicle is unlocked. That is, when the first face image matches a face image in the face database, the first face is determined to be a face in the face database, and the vehicle is unlocked by face recognition.

[0083] In one embodiment, establishing a user face database includes steps 111 to 113.

[0084] Step 111: Obtain the second face image. Specifically, the second face image can be an image captured in real time by a camera.

[0085] Step 112: Obtain the face age classification model, and use the face age classification model to obtain the confidence level that the age corresponding to the second face image is greater than or equal to the preset age value.

[0086] A face age classification model is a neural network model that can classify a second face image based on a preset age value. Optionally, the face age classification model includes a sigmoid module. It is understood that, because age has a certain degree of ambiguity, the sigmoid module can extract the probability value that the age corresponding to the second face image is greater than or equal to the preset age value during classification, and then use the extracted probability value as the confidence level.

[0087] The preset age value can be the minimum age at which a user can use the vehicle. For example, the preset age value for some motor vehicles is set to 18 years old, and for shared bicycles it is set to 12 years old. When the confidence level is greater than or equal to the preset confidence level, it indicates that the age of the user corresponding to the second image is greater than or equal to the preset age value. This allows the user's facial features to be added to the user facial database, which helps prevent people below the preset age value from becoming vehicle users and reduces the occurrence of traffic accidents.

[0088] Optionally, the face age classification model can classify the gender and age of a second face image. This model is a multi-label classification model, including a gender label to determine whether the person is male (or female) and an age label to determine whether the age is greater than or equal to a preset age value. The face age classification model can use gender information as auxiliary information, helping it to classify age more accurately.

[0089] Step 113: When the confidence level is greater than or equal to the preset confidence level, extract the second face features from the second face image and add them to the preset user face database to obtain the user face database.

[0090] The preset confidence level is a threshold used to determine whether the facial features corresponding to the second image can be added to the user's facial database. For example, if the confidence level is less than the preset confidence level, it indicates that the user is likely not yet of the preset age, and the user needs to undergo other age verification methods, such as SMS verification; otherwise, registration is not allowed, meaning that the facial features in the first image will not be extracted and added to the user's facial database. Optionally, the preset confidence level is 0.5.

[0091] In one embodiment, establishing a user face database further includes step 114.

[0092] Step 114: When the confidence level is less than the preset confidence level, verify the ID card information or record and report it. Optionally, ID card information verification can be achieved by taking a picture of the ID card information with a mobile phone and comparing it with the information of the backend server.

[0093] In one embodiment, a facial age classification model is obtained, including steps 115 and 116.

[0094] Step 115: Obtain the first set of training images, which contains a preset number of training images.

[0095] Optionally, the first set of training images includes training images corresponding to ages greater than or equal to a preset age value, and training images corresponding to ages less than a preset age value. The age-gender distribution ratio of the training images corresponding to ages greater than or equal to the preset age value can be consistent with the age-gender distribution ratio of drivers (cyclists) statistically analyzed in actual application scenarios. The ratio of the number of training images corresponding to ages greater than or equal to the preset age value to the number of training images corresponding to ages less than the preset age value can be between 5% and 30%, such as 20%.

[0096] Step 116: Use the first set of training images to train the preset face age classification model to obtain the face age classification model.

[0097] In one embodiment, during the training of the preset face age classification model using the first set of training images, the first loss function used is:

[0098] L=L1+αL2+βL3

[0099] Where L is the first loss function, L1 is the additive angular interval loss function, L2 is the triplet loss function, L3 is the tail data loss function, α is the first preset coefficient, and β is the second preset coefficient.

[0100] The additive angular margin loss function maximizes the classification boundary in angular space by reducing intra-class distance and increasing inter-class distance. Optionally, the additive angular margin loss function is the arcface loss function. Specifically, during training, when the number of training images in the first group is 64, these 64 training images are input into a preset face age classification model, and the arcface loss values ​​between the 64 training images are calculated according to the arcface formula to obtain the arcface loss function.

[0101] In one embodiment, the process of obtaining the triple loss function includes steps 601 to 604.

[0102] Step 601: Obtain the first set of training images, which includes multiple training images of the third face and multiple training images of the fourth face.

[0103] In the first set of training images, the same face corresponds to one or more training images. Specifically, in the first set of training images, each face is assigned an ID, meaning that the same ID corresponds to one or more training images.

[0104] Step 602: Obtain the first training image from multiple training images of the third face, and obtain the second training image from multiple training images of the fourth face. The first training image and the second training image are two training images that belong to different faces but have the highest similarity.

[0105] The first training image and the second training image can be two training images from the first set of training images that belong to different faces but have the highest similarity. For example, if the first set of training images includes 64 training images, then from these 64 training images, select the two training images that do not belong to the same face but have the highest similarity, namely the first training image and the second training image.

[0106] Step 603: Obtain the third and fourth training images from the multiple training images of the third face. The third and fourth training images are the two training images with the lowest similarity among the multiple training images of the third face. Obtain the fifth and sixth training images from the multiple face images of the fourth face. The fifth and sixth training images are the two training images with the lowest similarity among the multiple training images of the fourth face.

[0107] Based on the two faces corresponding to the first and second training images respectively, two training images with the lowest similarity to the same face are obtained for each of these two faces. That is, the third and fourth training images are obtained from multiple training images of the third face, and the fifth and sixth training images are obtained from multiple face images of the fourth face.

[0108] Step 604: Obtain the triplet loss function based on the first training image, the second training image, the third training image, the fourth training image, the fifth training image, and the sixth training image;

[0109] The formula for calculating the triplet loss function is:

[0110] L2 = 2 × S1 - S2 - S3

[0111] Where L2 is the triplet loss function, S1 is the cosine similarity between the first and second training images, S2 is the cosine similarity between the third and fourth training images, and S3 is the cosine similarity between the fifth and sixth training images.

[0112] As can be seen, the triplet loss function is calculated by subtracting the cosine similarity of the third and fourth training images from twice the cosine similarity of the first and second training images, and then subtracting the cosine similarity of the fifth and sixth training images.

[0113] In one embodiment, the process of obtaining the triple loss function includes steps 605 to 607.

[0114] Step 605: Obtain the recorded value of the triplet loss function (revised_triplet_loss).

[0115] Step 606: Obtain the triplet loss function between all different faces in the first set of training images to obtain multiple current triplet loss functions.

[0116] Step 607: Compare the triplet loss function record value with multiple current triplet loss functions in turn. When the current triplet loss function is less than the triplet loss function record value, update the triplet loss function record value according to the current triplet loss function.

[0117] The process of obtaining the triplet loss function among all different faces in the first set of training images specifically involves selecting multiple training images of two faces from the first set of training images, and from these two training images, selecting the two training images with the highest similarity despite being different faces, and selecting the two training images of the same face with the lowest similarity. Based on the positive correlation of cosine similarity between the two training images with the highest similarity but belonging to different faces, and the negative correlation of cosine similarity between the two training images with the lowest similarity but belonging to the same face, the current triplet loss function between these two faces is obtained. This process is repeated to calculate the current triplet loss function between other different faces. The third and fourth faces can be the two faces that minimize the recorded value of the triplet loss function; the final recorded value of the triplet loss function is the triplet loss function in the first loss function.

[0118] At the start of training, an initial value needs to be assigned to the triplet loss function record value. Then, by continuously updating the triplet loss function record value, the minimum value of the triplet loss function corresponding to all different faces in the first set of training images is used as the triplet loss function record value. Optionally, the initial value of the triplet loss function record value can be 1.

[0119] Understandably, since the current triplet loss function is related to the cosine similarity of the training images that have the highest similarity but belong to different faces, the higher the similarity, the larger the triplet loss function is, based on increasing the distance between training images of different faces. Similarly, for two training images of the same face, the distance between the two training images of the same face needs to be reduced. In this case, the smaller the cosine similarity (taking the negative number) of the two training images of the same face, the larger the triplet loss function is.

[0120] If a face is encountered where there is only one training image, making it impossible to calculate the current triplet loss function, the triplet loss function record value remains unchanged, or the face with only one training image is directly excluded (skipped) when calculating the current triplet loss function.

[0121] In one embodiment, the process of obtaining the tail data loss function includes:

[0122] Step 611: Obtain the seventh training image of the fifth face and the eighth training image of the sixth face from the first set of training images. The number of training images corresponding to the fifth face and the sixth face is one each.

[0123] The tail data loss function is used during training when there is only one training image corresponding to a single face. Data points where a face corresponds to only one training image are called tail data, such as the seventh training image for the fifth face and the eighth training image for the sixth face. Tail data requires separate optimization using the tail data loss function.

[0124] Step 612: Calculate the cosine similarity between the seventh and eighth training images to obtain the tail data loss function.

[0125] Specifically, if at least two faces in the first set of training images correspond to only one training image, then the cosine similarity between the training images corresponding to these two faces is calculated, resulting in multiple tail data loss functions. Tail data record values ​​are obtained, and the multiple current tail data loss functions are compared sequentially with these tail data record values. During the comparison, when the current tail data loss function is less than the tail data record value, the tail data record value is updated according to the current tail data loss function. After the comparison is complete, the final tail data record value is the tail data loss function in the first loss function. The fifth and sixth faces can be the two faces in the first set of training images that minimize the tail data loss function record value.

[0126] At the start of training, an initial value needs to be assigned to the tail data loss function records, for example, 0.5. During the training process, if there are no two images in the first group of training images that have only one training image corresponding to one ID, then the initial value of the tail data loss function is used as the final tail data loss function.

[0127] Furthermore, during training, the changes in L1, αL2, and βL3 are monitored, and βL3 is controlled to not frequently exceed 1 / 4 of αL2, and the sum of αL2 and βL3 is controlled to not frequently exceed 1 / 10 of L1. Based on this, the coefficients α and β can be determined. Here, "not frequent" means less than a preset frequent value.

[0128] In one embodiment, the vehicle is unlocked when the first face image matches a face image in the face database, including steps 121 to 123.

[0129] Step 121: Obtain the first face image captured by the camera.

[0130] For example, the first face image is an image of the user's face taken in front of the camera when the user unlocks the vehicle.

[0131] Step 122: Obtain the face recognition model and use the face recognition model to determine whether the first face image is a face image in the user's face database.

[0132] A face recognition model is a neural network-based face recognition model used to extract facial features and compare them with the features of faces in the user's face database to determine whether the face in the first face image is a face in the user's face database.

[0133] Step 123: When the first face image is a face image in the user's face database, unlock the vehicle.

[0134] If the features of the face corresponding to the first face image match the features of a face in the user's face database, the face corresponding to the first face image can be identified as a face in the user's face database, and the vehicle can be unlocked. Conversely, if the features of the face corresponding to the first face image do not match the features of any face in the user's face database, the face corresponding to the first face image can be identified as not a face in the user's face database.

[0135] In step 20, the target object is a pre-defined obstacle that may affect the vehicle's movement. For example, the target object is a pedestrian, a vehicle, etc.

[0136] In one embodiment, detecting whether the first image contains a target object includes steps 201 to 202.

[0137] Step 201: Convert the first image into a grayscale image and perform global contrast normalization on the grayscale image to obtain a normalized grayscale image.

[0138] By performing grayscale and normalization processing on the first image, a normalized grayscale image is obtained. Compared with color images, grayscale images are beneficial for improving detection speed.

[0139] Step 202: Input the grayscale image into the target detection model to identify whether the grayscale image contains a target object.

[0140] Optionally, the object detection model is a YOLOv4-based object detection model. YOLOv4 is a deep learning algorithm that, upon receiving a first image, identifies the objects present in the first image.

[0141] This YOLOv4-based object detection model uses 19×19 and 38×38 feature maps. Research has found that small-sized feature maps have fewer pixels and generally cannot describe detailed features; therefore, the coordinates obtained from regression on small-sized feature maps are usually for large-scale objects. This embodiment needs to describe large-area target objects in the first image using feature maps; therefore, it does not use 76×76 feature maps, but instead uses 19×19 and 38×38 feature maps.

[0142] It should be noted that the YOLOv4 object detection model is obtained by training YOLOv4 with images of target objects. Optionally, the target object training images can be labeled with only two classification labels: "with target object" or "without target object." Furthermore, classification loss does not need to be calculated when training the object detection model.

[0143] In one embodiment, when the first image contains a target object, the first region containing the target object in the first image is extracted, including steps 301 to 302.

[0144] Step 301: When a target object is detected in the grayscale image, output the coordinates of the target object in the first image. For example, the coordinates of the target object's edge in the first image can be obtained through feedback from a YOLOv4-based target detection model, where the coordinates are the positions of pixels in the first image.

[0145] Step 302: Obtain the first region containing the target object based on the coordinates. Specifically, the first region can be obtained based on the position of the target object in the first image and preset rules. For example, an initial target box can be obtained based on the edge coordinates of the target object, and then the length and width of the initial target box can be expanded outward by 5%-90% (e.g., 30%). The area covered by the obtained target box is the first region. Optionally, the initial target box is a rectangular box, and the edge of the initial target box is tangent to the edge of the target object.

[0146] In this process, the length and width of the initial target bounding box are expanded outwards to ensure that even if the target object moves, it will not move into the area covered by the target bounding box within a certain time interval.

[0147] In step 40, the area ratio between the first region and the first image can be understood as the ratio of the number of pixels in the first region to the total number of pixels in the first image. When the area ratio is greater than or equal to a preset area ratio threshold, the relative motion state between the target object and the vehicle is determined based on the first region. The motion state includes a stationary state, a first motion state, a second motion state, etc. The difference between the first motion state and the second motion state can be a difference in speed.

[0148] Understandably, for the same target object, the larger the area ratio between the first region and the first image, the closer the target object is to the vehicle. Based on this, the relative motion state between the target object and the vehicle can be determined only when the distance between them is relatively short, effectively reducing the computational load of the method.

[0149] In one application scenario, please refer to Figure 2 The closer a target object 91 (such as a pedestrian or vehicle) is to vehicle 90, the larger the area occupied by the target object 91 in the first image captured by the camera; that is, the larger the area ratio of the corresponding first region to the first image. Based on this, the distance between the target object and vehicle 90 can be determined by the area of ​​the target object 91 in the first image. Camera 901 is mounted on the vehicle body 900, and its shooting range is the area in front of vehicle 90. This front area includes the area directly in front and areas extending a certain distance to both sides in the direction of direct frontal movement, ensuring that the shooting range of camera 901 is large enough to facilitate driving safety.

[0150] Optionally, when determining the area ratio threshold, the area ratio threshold can be set according to the type of target object, which is helpful for judging the distance between the target object and the vehicle, thereby reducing the occurrence of traffic accidents.

[0151] In one embodiment, the relative motion state between the target object and the vehicle is determined based on the first region, including steps 401 and 402.

[0152] Step 401: Obtain the second region. The second region is the region in the second image of the area in front of the vehicle that corresponds to the first region. The time interval between the capture of the second image and the first image is a preset time.

[0153] In application, multiple images can be captured continuously, with each image spaced at a preset time interval. When a target object is detected in the first image of the multiple images, the first region is determined and its coordinates are recorded. Then, the second image after the preset time interval and the third image before the preset time interval are captured. Based on the coordinates of the first region, the second region of the second image and the third region of the third image are determined respectively.

[0154] Step 402: Input the first region and the second region into the motion state detection model to detect the motion state of the target object.

[0155] It is understandable that the areas of the first and second regions are smaller than those of the first and second images. Compared to directly inputting the first and second images into the motion detection model, inputting the first and second regions into the motion detection model can reduce the area of ​​the image input to the motion detection model, which is beneficial to improving the judgment speed and accuracy of the TSM model.

[0156] Optionally, the motion state detection model is the TSM (Temporal Shift Module) model. The TSM model is a video understanding model capable of determining the motion state of a target object based on feature analysis of a first region.

[0157] It should be noted that the regions input into the motion state detection model are not limited to the first and second regions. For example, the number of regions input into the motion state detection model can be 2, 3, 4, or 5. Specifically, the first, second, and third regions are fed into the TSM. Optionally, the number of regions input into the motion state detection model can be determined based on the type of target object.

[0158] In one embodiment, please refer to Figure 3 The motion state detection model includes at least one preset network 70. The preset network 70 includes a first branch and a second branch. The input ends of the first branch and the second branch are connected. The output ends of the first branch and the second branch are connected through a first splicing module 714. The first branch includes a time shifting module 711, a second channel splicing module 712 connected to the time shifting module 711, a channel compression module 713 connected to the second channel splicing module 712, and a time difference extraction module 715 connected to the time shifting module 711. The time difference extraction module 715 is connected to the second channel splicing module 712.

[0159] Please see Figure 4The time-shifting module is used to reorganize some channels in the input feature map so that some channels in the second type channel group 820 replace the corresponding channels in the first type channel group 810, resulting in a reorganized channel group. The first type channel group 810 is the channel group in the feature map obtained after convolution of the first region, and the second type channel group 820 is the channel group in the feature map obtained after convolution of the second region.

[0160] The first type of channel group 810 includes multiple first-type channels, such as the first channel 811 and the third channel 812. The second type of channel group includes multiple second-type channels, such as the second channel 821 and the fifth channel 822. Figure 4 As shown, the second channel 821 in the second type channel group 820 replaces the first channel 811 in the first type channel group 810 to obtain the recombined channel group.

[0161] Because the first and second images were captured at different times, the first region of the first image corresponds to the first type of channel group 810, and the second region of the second image corresponds to the second type of channel group 820, resulting in a certain time difference between the first type of channel group 810 and the second type of channel group 820. Based on this, by replacing some corresponding channels in the first type of channel group 810 with some channels from the second type of channel group 820, the recombined channel group includes some channels from the first type of channel group 810 and some channels from the second type of channel group 820. This achieves a certain temporal correlation between the channels in the recombined channel group, which is beneficial for the motion state detection model to extract feature information related to the time dimension.

[0162] Optionally, when recombining some channels in the input feature map, channels of more categories can replace some channels in the first channel group, so that the recombined channel group contains channels of more categories. For example, when recombining some channels in the input feature map, some channels of the second channel group 820 and some channels of the third channel group 830 can replace the corresponding channels in the first channel group 810 to obtain the recombined channel group. The third channel group 830 is the channel group in the feature map corresponding to the third region. The third region is the region in the third image corresponding to the first region. The shooting time of the first image is between the shooting time of the third image and the shooting time of the second image, and the time intervals between the three can be equal.

[0163] like Figure 4 As shown, the recombined channel group includes the first channel 811 of the first channel group 810, the second channel 821 of the second channel group 820, and the fourth channel 831 of the third channel group 830. This allows some channels from the channel group corresponding to the later time and the channel group corresponding to the previous time to be integrated into the channel group corresponding to the current time, which is beneficial to obtaining more difference information in the time dimension.

[0164] In one embodiment, during the reorganization of multiple channel groups in the time dimension, the channel dimensions of each reorganized channel group can be kept aligned. Specifically, the channel groups are arranged sequentially according to the time dimension, and some channels in each channel group are shifted in a staggered manner in the time dimension to reorganize the multiple channel groups in the time dimension. After the shift, the channel dimensions of the channel group in the middle of the time dimension are aligned, while those in the channel groups at both ends of the time dimension are not aligned. When there is a channel gap in one end of the channel group, the corresponding channel in the channel group at the other end needs to be used to fill the channel gap to maintain the alignment of the channel dimensions in each reorganized channel group. For example, the first type of channel group 810 is the channel group in the middle of the time dimension, and the second type of channel group 820 and the third type of channel group 830 are the channel groups at both ends of the time dimension. It is necessary to splice the sixth channel 832 of the third type of channel group 830 into the second type of channel group 820, and splice the fifth channel 822 of the second type of channel group 820 into the third type of channel group 830.

[0165] The time difference extraction module calculates the difference values ​​between different categories of channels in the recombined channel group and assembles difference channels based on these difference values. The difference values ​​reflect the differences between different categories of channels. Specifically, the difference values ​​are related to the subtraction between two different types of channels.

[0166] Optionally, calculating the difference between different categories of channels in the recombined channel group includes: calculating the difference between the channel values ​​of different categories of channels in the recombined first category of channels, squaring the difference, and then calculating the square root to obtain the difference value. For example, subtracting the third channel 812 from the second channel 821 in the recombined channel group to obtain the difference, and then squaring the difference and calculating the square root to obtain the difference value.

[0167] Optionally, the number of second-type channels in the recombined channel group can be multiple. Multiple first-type channels in the recombined channel group are subtracted from multiple second-type channels to obtain multiple differences. These differences are then squared and their square roots are calculated to obtain multiple difference values, and correspondingly, multiple difference channels are formed. When multiple first-type channels are subtracted from multiple second-type channels, the number of first-type channels is equal to the number of second-type channels.

[0168] Specifically, the recombined channel group includes a first type channel, a second type channel, and a third type channel. The difference between the second type channel and the third type channel is calculated by subtracting the corresponding channel pixels, squaring the result, and taking the square root, to form a difference channel D(t-1,t+1). The difference between the first type channel and the third type channel is calculated by subtracting the corresponding channel pixels, squaring the result, and taking the square root, to form a difference channel D(t,t-1). The difference between the first type channel and the second type channel is calculated by subtracting the corresponding channel pixels, squaring the result, and taking the square root, to form a difference channel D(t,t+1).

[0169] For example, in the recombined channels, there are 2 second-class channels and 2 third-class channels, and 4 first-class channels. Subtracting the 2 first-class channels from the 2 second-class channels yields 2 difference values ​​D(t,t-1), and subtracting the remaining 2 first-class channels from the 2 third-class channels yields 2 difference values ​​D(t,t+1).

[0170] The second channel stitching module 712 is used to add the difference channels to the recombined channels to obtain a channel group with difference processing. By stitching the difference channels with the recombined channels, it is beneficial for the motion state detection model to extract sufficient temporal difference information during training.

[0171] The channel compression module 713 is used to compress the channel group of differential processing, reducing the number of channels in the differential processing channel group to a preset number, thus obtaining a compressed channel group.

[0172] As can be seen, after concatenating the channels, the number of channels in the differential processing channel group will be greater than the number of channels in the first channel group. Therefore, the channel compression module 713 needs to reduce the number of channels in the differential processing channel group so that the resulting compressed channel group has the same number of channels as the first channel group. For example, when the differential processing channel group has 14 channels and the first channel group has 8 channels, compression using an 8-channel convolution will result in a compressed channel group with 8 channels.

[0173] The first concatenation module concatenates the compressed channel group with the channel group in the feature map output from the first branch to obtain a concatenated feature map. Since the concatenated feature map contains difference channels, it helps the motion state detection model extract sufficient temporal difference information during training.

[0174] In step 50, the preset motion state can be a state where the vehicle is moving towards the target object at a speed greater than a preset speed, at which point an alarm message is output. For example, the alarm message can be output by vibrating the handlebars of the shared bicycle to remind the user to pay attention to traffic conditions.

[0175] In one embodiment, when the relative motion state is a preset motion state, an alarm message is output, including:

[0176] Step 501: When the motion state is a stationary state, obtain the first area ratio threshold corresponding to the stationary state. When the area ratio of the target object to the first image is greater than the first area ratio threshold, output an alarm message; or,

[0177] Step 502: When the motion state is the first motion state in which the vehicle is moving toward the target object at a first speed, obtain the second area ratio threshold. When the area ratio of the target object to the first image is greater than the second area ratio threshold, output alarm information. The first area ratio threshold is greater than the second area ratio threshold.

[0178] In other words, after the relative motion state is set to a preset motion state, an area ratio threshold corresponding to each preset motion state is obtained. When the area ratio of the target object to the first image is greater than the area ratio threshold corresponding to the preset motion state, an alarm message is output. In a stationary state, although the distance between the target object and the vehicle is relatively close, the probability of a traffic accident is also low, so no alarm is needed. Based on this, the first area ratio threshold corresponding to the stationary state is larger than the area ratio thresholds corresponding to other motion states.

[0179] The vehicle alarm method detects a first image of the area in front of the vehicle. When a target object is detected in the first image, a first region containing the target object is extracted from the first image. The area ratio between the first region and the first image is calculated. When the area ratio is greater than or equal to a preset area ratio threshold, the relative motion state between the target object and the vehicle is determined based on the first region. When the relative motion state is a preset motion state, an alarm message is output to remind the user, which helps to reduce the occurrence of traffic accidents.

[0180] Although Figure 1 The steps in the flowchart are shown sequentially as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order in which these steps are executed, and they can be performed in other orders. Figure 1 At least some of the steps in the process may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least some of the sub-steps or stages of other steps.

[0181] This application provides an electronic device, including a memory and a processor. The memory stores a computer program, which can be executed by the processor to implement the steps of the vehicle alarm method described above.

[0182] Electronic devices can be implemented in various forms. For example, the electronic devices described in this application may include mobile terminals such as mobile phones, tablets, laptops, handheld computers, personal digital assistants (PDAs), portable media players (PMPs), navigation devices, wearable devices, smart bracelets, pedometers, etc., as well as fixed terminals such as digital TVs and desktop computers.

[0183] like Figure 5 As shown, the electronic device includes a processor, a memory, and a network interface connected via a system bus. The processor provides computing and control capabilities to support the operation of the entire electronic device. The memory stores data, programs, etc., and at least one computer program is stored in the memory. This computer program can be executed by the processor to implement the wireless network communication method for electronic devices provided in this embodiment. The memory may include a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system and a computer program. This computer program can be executed by the processor to implement a face recognition-based passenger flow analysis method provided in various embodiments. The internal memory provides a cached operating environment for the operating system computer program in the non-volatile storage medium. The network interface may be an Ethernet card or a wireless network card, etc., for communicating with external electronic devices.

[0184] like Figure 2 and Figure 6 As shown, this application embodiment provides a vehicle, including a vehicle body 900, an alarm component 903, a processor 902, and at least one camera 901; the camera 901 is disposed on the vehicle body 900, and the processor 902 is connected to the camera 901 and the alarm component 903 respectively.

[0185] Camera 901 is used to acquire a first image of the area in front of the vehicle;

[0186] The processor 902 is used to detect whether the first image contains a target object; when the first image contains a target object, it extracts a first region containing the target object in the first image; it obtains the area ratio between the first region and the first image; when the area ratio is greater than or equal to a preset area ratio threshold, it determines the relative motion state between the target object and the vehicle based on the first region; when the relative motion state is a preset motion state, it outputs an alarm signal.

[0187] Alarm component 903 is used to trigger an alarm in response to an alarm signal.

[0188] In one embodiment, the processor 902 is also configured to establish a user face database; and to unlock the vehicle when the first face image matches a face image in the face database.

[0189] In one embodiment, the processor 902 is further configured to acquire a second face image; acquire a face age classification model, and obtain a confidence level that the age corresponding to the second face image is greater than or equal to a preset age value through the face age classification model; when the confidence level is greater than or equal to the preset confidence level, extract the second face features from the second face image and add them to a preset user face database to obtain a user face database.

[0190] In one embodiment, the processor 902 is further configured to acquire a first face image captured by a camera; acquire a face recognition model, and determine whether the first face image is a face image in the user's face database using the face recognition model; and unlock the vehicle when the first face image is a face image in the user's face database.

[0191] In one embodiment, the processor 902 is further configured to acquire a first set of training images, the first set of training images containing a preset number of training images; train a preset face age classification model using the first set of training images to obtain a face age classification model; during the training of the preset face age classification model using the first set of training images, the first loss function used is:

[0192] L=L1+αL2+βL3

[0193] Where L is the first loss function, L1 is the additive angular interval loss function, L2 is the triplet loss function, L3 is the tail data loss function, α is the first preset coefficient, and β is the second preset coefficient.

[0194] In one embodiment, the processor 902 is further configured to acquire a first set of training images, the first set of training images including multiple training images of a third face and multiple training images of a fourth face; acquire a first training image from the multiple training images of the third face, acquire a second training image from the multiple training images of the fourth face, the first training image and the second training image being the two training images in the first set of training images that belong to different faces but have the highest similarity; acquire a third training image and a fourth training image from the multiple training images of the third face, the third training image and the fourth training image being the two training images in the multiple training images of the third face with the lowest similarity; acquire a fifth training image and a sixth training image from the multiple training images of the fourth face, the fifth training image and the sixth training image being the two training images in the multiple training images of the fourth face with the lowest similarity; and obtain a triplet loss function based on the first training image, the second training image, the third training image, the fourth training image, the fifth training image, and the sixth training image; the calculation formula for the triplet loss function is:

[0195] L2 = 2 × S1 - S2 - S3

[0196] Where L2 is the triplet loss function, S1 is the cosine similarity between the first and second training images, S2 is the cosine similarity between the third and fourth training images, and S3 is the cosine similarity between the fifth and sixth training images.

[0197] In one embodiment, the processor 902 is further configured to acquire a seventh training image of the fifth face and an eighth training image of the sixth face in the first set of training images, wherein the number of training images corresponding to the fifth face and the number of training images corresponding to the sixth face are both one; calculate the cosine similarity between the seventh training image and the eighth training image to obtain the tail data loss function.

[0198] In one embodiment, the processor 902 is further configured to convert the first image into a grayscale image, and perform global contrast normalization on the grayscale image to obtain a normalized grayscale image; input the grayscale image into a target detection model to identify whether the grayscale image contains a target object.

[0199] In one embodiment, the processor 902 is further configured to output the coordinates of the target object in the first image when the grayscale image is detected to contain the target object; and to obtain a first region containing the target object based on the coordinates.

[0200] In one embodiment, the processor 902 is further configured to acquire a second region, which is the region in a second image of the area in front of the vehicle that corresponds to the first region, and the time interval between the capture of the second image and the first image is a preset time; input the first region and the second region into a motion state detection model to detect the motion state of the target object.

[0201] In one embodiment, the processor 902 is further configured to calculate the difference between channel values ​​of different categories of channels in the recombined first category of channels, square the difference and calculate the square root to obtain the difference value.

[0202] In one embodiment, the processor 902 is further configured to acquire a first area ratio threshold corresponding to the stationary state when the motion state is stationary, and output alarm information when the area ratio of the target object to the first image is greater than the first area ratio threshold.

[0203] In one embodiment, the processor 902 is further configured to acquire a second area ratio threshold when the motion state is a first motion state in which the vehicle is moving toward the target object at a first speed, and output an alarm message when the area ratio of the target object to the first image is greater than the second area ratio threshold, wherein the first area ratio threshold is greater than the second area ratio threshold.

[0204] In this embodiment, the vehicle can detect a first image of the area in front of the vehicle. When a target object is detected in the first image, a first region containing the target object is extracted from the first image. The area ratio between the first region and the first image is calculated. When the area ratio is greater than or equal to a preset area ratio threshold, the relative motion state between the target object and the vehicle is determined based on the first region. When the relative motion state is a preset motion state, an alarm message is output to remind the user, which helps to reduce the occurrence of traffic accidents.

[0205] Regarding the specific limitations of the vehicles in the embodiments of this application, please refer to the aforementioned alarm method based on vehicle behavior recognition, which will not be repeated here. The aforementioned alarm method based on vehicle behavior recognition can also refer to the specific limitations of the vehicles in the embodiments of this application.

[0206] In a smart park application scenario, vehicles are specifically part of the park's traffic equipment, such as smart motorcycles used by traffic police. These smart motorcycles can detect a first image of the area in front of the vehicle. When a target object is detected in the first image, the system extracts the first region containing the target object. It then calculates the area ratio between the first region and the first image. If the area ratio is greater than or equal to a preset area ratio threshold, the system determines the relative motion state between the target object and the vehicle based on the first region. When the relative motion state matches a preset motion state, an alarm message is output to remind the user, which helps reduce traffic accidents in the smart park.

[0207] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0208] The above embodiments merely illustrate several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.

Claims

1. A vehicle alarm method, characterized in that, include: Acquire the first image of the area in front of the vehicle; The first image is converted into a grayscale image, and the grayscale image is then subjected to global contrast normalization to obtain a normalized grayscale image. The grayscale image is input into the target detection model to identify whether the grayscale image contains a target object; When a target object is detected in the grayscale image, the coordinates of the target object in the first image are output; based on the coordinates, a first region containing the target object is obtained; and a second region containing the target object is obtained in a second image taken at intervals, wherein the second region is the region in the second image of the area in front of the vehicle that corresponds to the first region, and the time interval between the second image and the first image is a preset time. The area ratio between the first region and the first image is obtained. When the area ratio is greater than or equal to a preset area ratio threshold, the first region and the second region are input into a motion state detection model to detect the relative motion state between the target object and the vehicle. The motion state detection model includes at least one preset network, which includes a first branch and a second branch. The inputs of the first branch and the second branch are connected, and their outputs are connected via a first splicing module. The first branch includes a time shifting module, a second channel splicing module connected to the time shifting module, a channel compression module connected to the second channel splicing module, and a time difference extraction module connected to the time shifting module. The time difference extraction module is connected to the second channel splicing module. The time shifting module is used to reassemble some channels in the input feature map so that some channels of the second type of channel group replace the corresponding channels in the first type of channel group, resulting in a reassembled channel group. The first type of channel group is the channel group in the feature map obtained after convolution of the first region. The second type of channel group is the channel group in the feature map obtained after convolution of the second region. The temporal difference extraction module is used to calculate the difference value between different categories of channels in the recombined channel group and form difference channels according to the difference value. The second channel splicing module is used to add the difference channels to the recombined channels to obtain the difference-processed channel group. The channel compression module is used to compress the difference-processed channel group and reduce the number of channels in the difference-processed channel group to a preset number to obtain a compressed channel group. The first splicing module is used to splice the compressed channel group with the channel group in the feature map output by the first branch to obtain a spliced ​​feature map. The calculation of the difference value between different categories of channels in the recombined channel group includes: calculating the difference between the channel values ​​of different categories of channels in the recombined first type of channel, squaring the difference and calculating the square root to obtain the difference value. When the relative motion state is a preset motion state, an alarm message is output.

2. The vehicle alarm method according to claim 1, characterized in that, Before acquiring the first image of the area in front of the vehicle, the method further includes: Establish a user facial database; The vehicle is unlocked when the first facial image matches a facial image in the facial database.

3. The vehicle alarm method according to claim 2, characterized in that, The establishment of the user face database includes: Obtain the second face image; Obtain a face age classification model, and use the face age classification model to obtain the confidence level that the age corresponding to the second face image is greater than or equal to a preset age value; When the confidence level is greater than or equal to the preset confidence level, the second facial features are extracted from the second facial image and added to the preset user facial database to obtain the user facial database; The step of unlocking the vehicle when the first facial image matches a facial image in the facial database includes: Acquire the first facial image captured by the camera; Obtain a face recognition model, and use the face recognition model to determine whether the first face image is a face image in the user's face database; When the first face image is a face image in the user's face database, the vehicle is unlocked.

4. The vehicle alarm method according to claim 3, characterized in that, The facial age classification model includes: Obtain the first set of training images, which contains a preset number of training images; The first set of training images is used to train the preset face age classification model to obtain the face age classification model; The first loss function used in training the preset face age classification model using the first set of training images is: L = L1 + αL2 + βL3 Where L is the first loss function, L1 is the additive angular interval loss function, L2 is the triplet loss function, L3 is the tail data loss function, α is the first preset coefficient, and β is the second preset coefficient. The process of obtaining the triplet loss function includes: Obtain the first set of training images, which includes multiple training images of the third face and multiple training images of the fourth face; A first training image is obtained from multiple training images of the third face, and a second training image is obtained from multiple training images of the fourth face. The first training image and the second training image are two training images with the highest similarity that belong to different faces in the first set of training images. A third training image and a fourth training image are obtained from multiple training images of the third face. The third training image and the fourth training image are the two training images with the lowest similarity among the multiple training images of the third face. A fifth training image and a sixth training image are obtained from multiple face images of the fourth face. The fifth training image and the sixth training image are the two training images with the lowest similarity among the multiple training images of the fourth face. The triplet loss function is obtained based on the first training image, the second training image, the third training image, the fourth training image, the fifth training image, and the sixth training image; The formula for calculating the triplet loss function is as follows: L2 = 2 × S1 - S2 - S3 Wherein, L2 is the triplet loss function, S1 is the cosine similarity between the first training image and the second training image, S2 is the cosine similarity between the third training image and the fourth training image, and S3 is the cosine similarity between the fifth training image and the sixth training image. The process of obtaining the tail data loss function includes: Obtain the seventh training image of the fifth face and the eighth training image of the sixth face from the first set of training images. The number of training images corresponding to the fifth face and the number of training images corresponding to the sixth face are both one. The cosine similarity between the seventh training image and the eighth training image is calculated to obtain the tail data loss function.

5. The vehicle alarm method according to claim 1, characterized in that, When the relative motion state is a preset motion state, an alarm message is output, including: When the motion state is a stationary state, a first area ratio threshold corresponding to the stationary state is obtained; when the area ratio of the target object to the first image is greater than the first area ratio threshold, an alarm message is output; or, When the motion state is a first motion state in which the vehicle is moving toward the target object at a first speed, a second area ratio threshold is obtained. When the area ratio of the target object to the first image is greater than the second area ratio threshold, an alarm message is output, wherein the first area ratio threshold is greater than the second area ratio threshold.

6. An electronic device, characterized in that, It includes a memory and a processor, the memory storing a computer program that can be executed by the processor to implement the steps of the vehicle alarm method as described in any one of claims 1 to 5.

7. A vehicle, characterized in that, The system includes a vehicle body, an alarm component, a processor, and at least one camera; the camera is mounted on the vehicle body, and the processor is connected to both the camera and the alarm component. The camera is used to acquire a first image of the area in front of the vehicle; The processor is used to convert the first image into a grayscale image and perform global contrast normalization on the grayscale image to obtain a normalized grayscale image; input the grayscale image into a target detection model to identify whether the grayscale image contains a target object; when a target object is detected in the grayscale image, output the coordinates of the target object in the first image; obtain a first region containing the target object based on the coordinates; and obtain a second region containing the target object in a second image taken at intervals, the second region being the region in the second image of the area in front of the vehicle corresponding to the first region, the second image being taken at intervals from the first image being a preset time interval; and acquire the... The area ratio between the first region and the first image is used to detect the relative motion state between the target object and the vehicle. When the area ratio is greater than or equal to a preset area ratio threshold, the first region and the second region are input into a motion state detection model to detect the relative motion state between the target object and the vehicle. The motion state detection model includes at least one preset network, which includes a first branch and a second branch. The inputs of the first branch and the second branch are connected, and the outputs of the first branch and the second branch are connected through a first stitching module. The first branch includes a time-shifting module, a second-channel stitching module connected to the time-shifting module, and a channel compression module connected to the second-channel stitching module. The system includes a block and a time difference extraction module connected to the time shifting module. The time difference extraction module is connected to the second channel splicing module. The time shifting module reassembles some channels in the input feature map so that some channels of the second type of channel group replace corresponding channels in the first type of channel group, resulting in a reassembled channel group. The first type of channel group is the channel group in the feature map obtained after convolution of the first region, and the second type of channel group is the channel group in the feature map obtained after convolution of the second region. The time difference extraction module calculates the difference values ​​between different categories of channels in the reassembled channel group and forms difference channels based on these difference values. The second channel... The splicing module is used to add the difference channels to the recombined channels to obtain a channel group with difference processing. The channel compression module is used to compress the channel group with difference processing, reducing the number of channels in the channel group with difference processing to a preset number to obtain a compressed channel group. The first splicing module is used to splice the compressed channel group with the channel group in the feature map output by the first branch to obtain a spliced ​​feature map. The calculation of the difference value between different categories of channels in the recombined channel group includes: calculating the difference between the channel values ​​of different categories of channels in the recombined first category of channels, squaring the difference and calculating the square root to obtain the difference value; when the relative motion state is a preset motion state, an alarm signal is output. The alarm component is used to trigger an alarm in response to the alarm signal.

Citation Information

Patent Citations

  • Shared bicycle unlocking method and mobile terminal

    CN108171832A

  • Moving object detection method and system in vehicle-mounted environment

    CN109145805A