Disclosure of Invention
The object recognition method aims to solve the problems in the prior art and provides an object recognition method for dynamically setting a similarity threshold with high recognition accuracy and low false alarm rate.
The technical scheme of the invention is as follows: the object recognition method for dynamically setting the similarity threshold comprises the following steps: s1, formulating a similarity threshold according to a time period in a day; the relationship between time T and similarity threshold Y is: if 0 < T.ltoreq.5, Y=0.5+0.04T; if 5 < T.ltoreq.7, Y=0.5; if 7 < T is less than or equal to 17, Y=0.5+|T-12| 0.1; if 17 < T is less than or equal to 19, Y=0.5; if 19 < T is less than or equal to 24, y=0.5+0.04 (24-T); s2, acquiring a video frame of a video; s3, obtaining time T corresponding to the video frame, and calculating a similarity threshold Y at the moment according to the value of the time T and the relationship between the time T and the similarity threshold Y in the step S1; s4, carrying out image recognition on the video frame, obtaining the object category x, calculating the recognition similarity w, and comparing the recognition similarity w with a similarity threshold y to obtain an object recognition conclusion.
As a preferable technical solution, the time t in step S3 is a whole-point timing, that is, the number of hours of the time t corresponding to the video frame is taken.
In step S4, the method for performing image recognition on the frame of the video frame and calculating the recognition similarity w may be an SSIM method.
As a further preferable technical solution, the method for calculating the recognition similarity w includes the following steps:
a. obtaining a frame of base map containing comparison objects; b. and calculating the structural similarity of the video frame and the base map according to the SSIM formula, wherein the structural similarity is the identification similarity w.
As a further preferable technical solution, in the step a, the obtained base map is different according to the time t.
As a further preferable technical solution, the base map is divided into 5 types, the 5 types of base maps correspond to the 5 time periods of the time T in the step S1, and the corresponding base map is selected according to the time T corresponding to the video frame.
In step S4, if w is greater than y, determining that there is a detected object in the frame of the video frame, and storing the object type x and the similarity threshold y; if w is less than or equal to y, no treatment is carried out.
As a further preferable technical scheme, in step S4, if w is greater than y, after determining that there is a detected object in the video frame, an alarm is given and the object class x and the similarity threshold y information are uploaded.
According to the object recognition method for dynamically setting the similarity threshold, the object recognition similarity threshold in different time periods is set according to the light in one day and the change characteristics of the scene, so that the false alarm rate of object recognition in the intelligent community alarm event monitoring application scene is reduced. The object recognition method for dynamically setting the similarity threshold provided by the invention is used for solving the problems encountered in practical product application, and an object recognition optimization mechanism for dynamically setting the similarity threshold is provided, so that the false alarm rate of an intelligent recognition application system is reduced, and a better effect is achieved.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments of the present invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
The terminology used in the embodiments of the invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. As used in this application and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise, the "plurality" generally includes at least two, but does not exclude the case of at least one.
It should be understood that the term "and/or" as used herein is merely one relationship describing the association of the associated objects, meaning that there may be three relationships, e.g., a and/or B, may represent: a exists alone, A and B exist together, and B exists alone. In addition, the character "/" herein generally indicates that the front and rear associated objects are an "or" relationship.
The words "if", as used herein, may be interpreted as "at … …" or "at … …" or "in response to a determination" or "in response to a detection", depending on the context. Similarly, the phrase "if determined" or "if detected (stated condition or event)" may be interpreted as "when determined" or "in response to determination" or "when detected (stated condition or event)" or "in response to detection (stated condition or event), depending on the context.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a product or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such product or system. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a commodity or system comprising such elements.
As shown in fig. 1, the object recognition method for dynamically setting a similarity threshold according to the present invention includes the following steps:
s1, formulating a similarity threshold according to a time period in a day. According to statistics of the occurrence time period of the recognition false alarm in one day, a recognition similarity threshold is formulated, and the specific description is as follows:
also the relationship between time T and similarity threshold Y is: if 0 < T.ltoreq.5, Y=0.5+0.04T; if 5 < T.ltoreq.7, Y=0.5; if 7 < T is less than or equal to 17, Y=0.5+|T-12| 0.1; if 17 < T is less than or equal to 19, Y=0.5; if 19 < T.ltoreq.24, Y=0.5+0.04 (24-T).
S2, acquiring a video frame of the video.
S3, obtaining time T corresponding to the video frame, and calculating the similarity threshold Y at the moment according to the value of the time T and the relationship between the time T and the similarity threshold Y in the step S1. Judging the time T of the video frame and the time period of the time T in the step S1, obtaining a calculation formula of a similarity threshold Y corresponding to T, and obtaining the similarity threshold Y at the moment through the calculation formula.
S4, carrying out image recognition on the video frame, obtaining the object category x, calculating the recognition similarity w, and comparing the recognition similarity w with a similarity threshold y to obtain an object recognition conclusion.
According to the object recognition method for dynamically setting the similarity threshold, the object recognition similarity threshold in different time periods is set according to the light in one day and the change characteristics of the scene, so that the false alarm rate of object recognition in the intelligent community alarm event monitoring application scene is reduced.
As a preferred technical solution, in order to simplify the calculation, in this embodiment, the time t in step S3 is the whole-point time, i.e. the number of hours of the time t corresponding to the video frame is taken, for example, 17:35 is t=17.
In this embodiment, in step S4, image recognition is performed on the frame of the video frame, and the method for calculating the recognition similarity w may be an SSIM method. At this time, the method of calculating the recognition similarity w includes the steps of:
a. obtaining a frame of base map containing comparison objects;
b. and calculating the structural similarity of the video frame and the base map according to the SSIM formula, wherein the structural similarity is the identification similarity w.
Specifically, a modified SSIM formula may be employed: w=s (X, Y) = (δxy+c3)/(δxδy+c3) to calculate the structural similarity of the image X and the image Y; where s (X, Y) is the covariance of X and Y, δx, δy are the standard deviations of X, Y, respectively, and c3 is a constant. In this embodiment, the image X is a base image, and the image Y is a video frame. The conventional SSIM formula is w= [ l (X, Y)] α [c(X,Y)] β [s(X,Y)] θ Wherein alpha, beta, theta>0. Where l (x, y) is the luminance comparison, c (x, y) is the contrast comparison, and s (x, y) is the structure comparison. In order to adapt to the specific requirements of object recognition, only structural comparison is made here, i.e., α=β=0, θ=1, and the modified SSIM formula is w=s (X, Y) = (δxy+c3)/(δxδy+c3). The constant c3 is set to avoid systematic errors caused by a denominator of 0. w is a number between 0 and 1, and a larger number indicates a smaller structural gap between two frames of images to be compared.
In order to avoid the influence of light changes in different time periods on the base map, and improve the object recognition accuracy, in step a of the embodiment, the obtained base map is different according to different time t. As a preferred scheme, the base graphs are divided into 5 types, the 5 types of base graphs correspond to 5 time periods of the time T in the step S1, and the corresponding base graphs are selected according to the time T corresponding to the video frame.
In this embodiment, in step S4, the specific scheme of "comparing the recognition similarity w with the similarity threshold y to obtain the object recognition conclusion" is that if w is greater than y, it is determined that there is a detected object in the frame of the video frame, and the object class x and the similarity threshold y are synchronously stored; if w is less than or equal to y, the corresponding object is not recognized, and no treatment is performed.
And if w is larger than y, alarming and uploading information of the object type x and the similarity threshold y after judging that the detected object exists in the video frame. In practical application, the detection and operation of the follow-up intelligent alarm event can be performed.
The object recognition method for dynamically setting the similarity threshold can be applied to object recognition in a video segment, can be applied to object recognition of a real-time monitoring video, and can be applied to object recognition in a single image. In practical application, the steps S2 to S4 may be circularly processed until the object identification of the whole video is completed, or the real-time monitoring of the object identification is terminated.
According to the object recognition method for dynamically setting the similarity threshold, the object recognition similarity threshold in different time periods is set according to the light in one day and the change characteristics of the scene, so that the false alarm rate of object recognition in the intelligent community alarm event monitoring application scene is reduced. The object recognition method for dynamically setting the similarity threshold provided by the invention is used for solving the problems encountered in practical product application, and an object recognition optimization mechanism for dynamically setting the similarity threshold is provided, so that the false alarm rate of an intelligent recognition application system is reduced, and a better effect is achieved.
The foregoing description is only of the preferred embodiments of the present invention and is not intended to limit the scope of the present invention. Equivalent changes and modifications of the invention are intended to fall within the scope of the present invention.