Abnormal target detection method, device, electronic device and storage medium
Through image processing technology, the distance change parameters of the target are calculated, and the problem of detecting abnormal characters in crowded areas is solved, and fast and accurate abnormal target detection and early warning are achieved.
Patent Information
- Application Number
- CN202210089909.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-25
- Publication Date
- 2025-07-11
- Estimated Expiration
- 2042-01-25
AI Technical Summary
The prior art is difficult to detect abnormal characters in densely populated areas, and it is impossible to effectively monitor and warning for abnormal events.
Through image processing technology, the world coordinate value and historical coordinate value of the target are obtained, the world coordinate value set of the target is constructed, the distance change parameters between the targets are calculated, and whether the target is abnormal.
It achieves rapid and accurate detection of abnormal targets, prevents the occurrence of abnormal events, and improves the security of the monitoring area.
Smart Images

Figure CN114495005B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to an abnormal target detection method, device, electronic device and storage medium. Background Art
[0002] At large supermarket entrances and exits, tourist attractions, key traffic intersections and other places where people are densely moving, it is easy to have abnormal events such as theft, driving in the wrong direction, abnormal stopping and running, which may lead to the risk of illegal events and traffic accidents, so it is very necessary to monitor such events. At present, the monitoring area is generally analyzed intelligently based on the crowd situation, such as the number of people and whether the crowd is dense, which makes it impossible to detect abnormal people. Summary of the invention
[0003] In view of this, an object of the present invention is to provide a method, device, electronic device and storage medium for detecting abnormal targets.
[0004] In order to achieve the above purpose, the technical solution adopted by the embodiment of the present invention is as follows:
[0005] In a first aspect, the present invention provides a method for detecting an abnormal target, the method comprising:
[0006] According to the image to be processed, obtaining identifications of multiple targets and a first world coordinate value of each target in a preset world coordinate system;
[0007] According to the identifiers of the multiple targets and N frames of historical images before the image to be processed, obtain N historical world coordinate values of each target in the preset world coordinate system; one historical world coordinate value corresponds to one frame of the historical image; N is a positive integer;
[0008] Constructing a world coordinate value set for each of the multiple targets according to the first world coordinate value and the N historical world coordinate values of each of the multiple targets;
[0009] Taking each of the targets as a target to be detected one by one, obtaining a distance change parameter of the target to be detected relative to all other targets according to a world coordinate value set of the target to be detected and a world coordinate value set of all other targets among the multiple targets except the target to be detected, thereby obtaining a distance change parameter of each target;
[0010] Whether each of the targets is abnormal is determined based on the distance change parameter of each of the targets.
[0011] In an optional implementation, the step of obtaining the identifiers of multiple targets and the first world coordinate value of each target in a preset world coordinate system according to the image to be processed includes:
[0012] Detect the image to be processed, and obtain the identifiers of the multiple targets and the first pixel coordinate values of each target in a preset image coordinate system;
[0013] According to the first pixel coordinate value of each target and a preset conversion relationship, obtain the first world coordinate value of each target in the preset world coordinate system; the preset conversion relationship represents the conversion relationship between the preset image coordinate system and the preset world coordinate system.
[0014] In an alternative embodiment, the step of obtaining the distance change parameter of the target to be detected relative to all other targets according to the set of world coordinate values of the target to be detected and the set of world coordinate values of all other targets except the target to be detected among the multiple targets includes:
[0015] According to the set of world coordinate values of the target to be detected and the set of world coordinate values of each other target, obtain a distance array of the target to be detected and each other target;
[0016] Obtain an effective distance array from all the distance arrays, where the effective distance array represents the distance array of the target to be detected and the effective targets, and the effective targets represent those whose distance change degree from the target to be detected meets a preset condition;
[0017] Take the ratio of the number of the effective distance arrays to the number of all the distance arrays as the distance change parameter of the target to be detected.
[0018] In an alternative embodiment, the set of world coordinate values includes M world coordinate values; M is equal to N + 1;
[0019] The step of obtaining a distance array of the target to be detected and each other target according to the set of world coordinate values of the target to be detected and the set of world coordinate values of each other target includes:
[0020] For any one of the other targets, obtain the m-th distance parameter according to the m-th world coordinate value of the other target and the m-th world coordinate value of the target to be detected, and obtain M distance parameters; m is a positive integer not greater than M;
[0021] Take the M distance parameters as the distance array of the target to be detected and the other target;
[0022] Traverse each of the other targets to obtain the distance array of the target to be detected and each other target.
[0023] In an alternative embodiment, the world coordinate values include an abscissa value and an ordinate value;
[0024] The step of obtaining the m-th distance parameter according to the m-th world coordinate value of the other target and the m-th world coordinate value of the target to be detected includes:
[0025] Calculating the square of the difference between the m-th abscissa value of the other target and the m-th abscissa value of the target to be detected to obtain the m-th first sub-distance parameter;
[0026] Calculating the square of the difference between the m-th ordinate value of the other target and the m-th ordinate value of the target to be detected to obtain the m-th second sub-distance parameter;
[0027] Adding the m-th first sub-distance parameter and the m-th second sub-distance parameter to obtain the m-th distance parameter.
[0028] In an alternative embodiment, the step of obtaining the effective distance array from all the distance arrays includes:
[0029] Obtaining a to-be-determined distance array from all the distance arrays, where each distance parameter in the to-be-determined distance array belongs to the preset range;
[0030] For each to-be-determined distance array, calculating the average value of the absolute differences between any two adjacent distance parameters in the to-be-determined distance array to obtain the change parameter of the to-be-determined distance array;
[0031] Taking the to-be-determined distance array with the change parameter equal to or greater than the preset threshold as the effective distance array.
[0032] In an alternative embodiment, the step of determining whether each target is abnormal according to the distance change parameter of each target includes:
[0033] For each target, if the distance change parameter of the target is equal to or greater than the preset parameter, it is determined that the target is abnormal;
[0034] If the distance change parameter of the target is less than the preset parameter, it is determined that the target is normal.
[0035] In a second aspect, the present invention provides an abnormal target detection device, and the device includes:
[0036] A first acquisition module, configured to obtain the identifiers of multiple targets and the first world coordinate values of each target in a preset world coordinate system according to a to-be-processed image;
[0037] A second acquisition module, configured to obtain N historical world coordinate values of each of the targets in the preset world coordinate system according to the identifiers of the multiple targets and N historical images before the image to be processed; one historical world coordinate value corresponds to one frame of the historical image; N is a positive integer;
[0038] A calculation module, configured to construct a set of world coordinate values of each of the targets according to the first world coordinate value and the N historical world coordinate values of each of the targets in the multiple targets;
[0039] Taking each of the targets as a target to be detected one by one, and obtaining a distance change parameter of the target to be detected relative to all other targets according to the set of world coordinate values of the target to be detected and the set of world coordinate values of all other targets except the target to be detected in the multiple targets, so as to obtain a distance change parameter of each of the targets;
[0040] A determination module, configured to determine whether each of the targets is abnormal according to the distance change parameter of each of the targets.
[0041] In a third aspect, the present invention provides an electronic device, including a processor and a memory, where the memory stores a computer program, and when the processor executes the computer program, the method described in any one of the foregoing embodiments is implemented.
[0042] In a fourth aspect, the present invention provides a storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the method described in any one of the foregoing embodiments is implemented.
[0043] The abnormal target detection method, device, electronic device and storage medium provided by the embodiments of the present invention obtain the identifiers of multiple targets and the first world coordinate value of each target in the preset world coordinate system through the image to be processed; then, according to the identifiers of the multiple targets and N historical images before the image to be processed, obtain N historical world coordinate values of each target in the preset world coordinate system, one historical world coordinate value corresponds to one frame of historical image, and N is a positive integer; then, according to the first world coordinate value and the N historical world coordinate values of each target in the multiple targets, construct a set of world coordinate values of each target; then, take each target as a target to be detected one by one, and obtain a distance change parameter of the target to be detected relative to all other targets according to the set of world coordinate values of the target to be detected and the set of world coordinate values of all other targets except the target to be detected in the multiple targets, so as to obtain a distance change parameter of each target; finally, determine whether each target is abnormal according to the distance change parameter of each target. By obtaining multiple positions of the target in the actual world through the image and obtaining the distance change of the target relative to other targets to determine whether the target is abnormal, the target can be detected quickly and accurately, which is beneficial to preventing the occurrence of abnormal events and achieving the effect of monitoring and early warning.
[0044] In order to make the above objects, features and advantages of the present invention more obvious and understandable, the following specifically gives preferred embodiments and, in conjunction with the accompanying drawings, the detailed description is as follows. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following will briefly introduce the accompanying drawings required for use in the embodiments. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as limiting the scope. For those of ordinary skill in the art, without creative efforts, other related drawings can also be obtained based on these drawings.
[0046] Figure 1 Shows a schematic block diagram of an electronic device provided by an embodiment of the present invention;
[0047] Figure 2 Shows a schematic flow diagram of an abnormal target detection method provided by an embodiment of the present invention;
[0048] Figure 3 Shows another schematic flow diagram of an abnormal target detection method provided by an embodiment of the present invention;
[0049] Figure 4 Shows another schematic flow diagram of an abnormal target detection method provided by an embodiment of the present invention;
[0050] Figure 5 Shows another schematic flow diagram of an abnormal target detection method provided by an embodiment of the present invention;
[0051] Figure 6 Shows an example diagram of an abnormal target detection method provided by an embodiment of the present invention;
[0052] Figure 7 Shows another schematic flow diagram of an abnormal target detection method provided by an embodiment of the present invention;
[0053] Figure 8 Shows a functional module diagram of an abnormal target detection device provided by an embodiment of the present invention.
[0054] Icons: 110 - Bus; 120 - Processor; 130 - Memory; 170 - Communication Interface; 300 - Abnormal Target Detection Device; 310 - First Acquisition Module; 330 - Second Acquisition Module; 350 - Calculation Module; 370 - Determination Module. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0055] The following will be combined with the accompanying drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.
[0056] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of the present invention.
[0057] It should be noted that relational terms such as "first" and "second" are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0058] In places where there is a dense flow of people, such as entrances and exits of large supermarkets, tourist attractions, and key traffic intersections, abnormal events such as theft, driving in the wrong direction, abnormal stops, and running are prone to occur, which poses a risk of illegal incidents and traffic accidents, so it is very necessary to monitor such events. At present, the monitoring area is generally intelligently analyzed based on the situation of the crowd, such as the number of people and whether the crowd is dense, which has the problem of being unable to detect abnormal people. For example, in the case of a large crowd density, it is impossible to track and monitor everyone, and the probability of preparatory tracking and capturing of abnormal people is low. Furthermore, an embodiment of the present invention provides an abnormal target detection method, which can analyze the movement trend of each target and other targets based on the image, and accurately judge the abnormally moving targets, which can achieve the effect of rapid early warning and improved regional security.
[0059] Please refer to Figure 1 , is a block diagram of an electronic device provided by an embodiment of the present invention. The electronic device includes a bus 110 , a processor 120 , a memory 130 , and a communication interface 170 .
[0060] The bus 110 can be a circuit that interconnects the above-mentioned components and transmits communications (such as control messages) between the above-mentioned components.
[0061] The processor 120 can receive commands from the above-mentioned other components (such as the memory 130, communication interface 170, etc.) via the bus 110, can interpret the received commands, and can perform calculations or data processing according to the interpreted commands.
[0062] The processor 120 may be an integrated circuit chip with signal processing capabilities. The processor 120 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0063] The memory 130 can store commands or data received from the processor 120 or other components (such as the communication interface 170, etc.) or commands or data generated by the processor 120 or other components.
[0064] The memory 130 can be, but is not limited to, a random access memory (RAM), a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), etc.
[0065] The communication interface 170 can be used for signaling or data communication with other node devices.
[0066] It can be understood that Figure 1 The structure shown is only a schematic diagram of the structure of the electronic device, and the electronic device may also include more or fewer components than those Figure 1 shown, or have a configuration different from that Figure 1 shown. Figure 1 Each of the components shown can be implemented using hardware, software, or a combination thereof.
[0067] It can be understood that the electronic device can be communicatively connected to the imaging device. The electronic device can obtain the images of the monitoring area collected by the imaging device, and the electronic device can also send instructions to control the imaging device to track and monitor a certain target.
[0068] The following will take the above-mentioned electronic device as the execution subject to execute each step in the various methods provided by the embodiments of the present invention and achieve the corresponding technical effects.
[0069] Please refer to Figure 2 , Figure 2 which is a schematic flowchart of an abnormal target detection method provided by an embodiment of the present invention.
[0070] Step S202: Obtain the identifiers of multiple targets and the first world coordinate values of each target in a preset world coordinate system according to the image to be processed;
[0071] It can be understood that the Soc chip of the imaging device can read the RAW image data from the CMOS image sensor in the imaging device, convert it into YUV data, and the electronic device can obtain the image in the YUV data format from the imaging device, that is, obtain the image to be processed.
[0072] In this embodiment, the image to be processed can be detected to obtain multiple targets in the image, and each target can be configured with a unique identifier to obtain the identifiers of multiple targets; then, according to the position of each target in the image to be processed, the first world coordinate value of each target in the preset world coordinate system can be obtained.
[0073] The first world coordinate value can be understood as the position in the actual world corresponding to the position of the target in the image to be processed.
[0074] Step S204: Obtain N historical world coordinate values of each target in the preset world coordinate system according to the identifiers of multiple targets and the N frame historical images before the image to be processed;
[0075] Wherein, one historical world coordinate value corresponds to one frame of historical image; N is a positive integer.
[0076] In this embodiment, each historical image has been detected, and the N frame historical images before the image to be processed can be obtained; then, according to the identifiers of multiple targets, the position of each target in each frame of historical image can be obtained, and through coordinate conversion, the historical coordinate value of the target in the preset world coordinate system can be obtained, that is, one target can obtain N historical world coordinate values.
[0077] The historical coordinate value of the target can be understood as the position in the actual world corresponding to the position of the target in the historical image.
[0078] Step S206: Construct a set of world coordinate values for each target based on the first world coordinate value of each target among the multiple targets and the N historical world coordinate values.
[0079] In this embodiment, the first world coordinate value of each target and the N historical world coordinate values are used as the set of world coordinate values for each target. The set of world coordinate values includes N + 1 world coordinate values of the target.
[0080] The N + 1 world coordinate values can be understood as N + 1 position points of the target in the real world obtained through the image to be processed and N frames of historical images.
[0081] Step S208: Take each target as the target to be detected one by one. According to the set of world coordinate values of the target to be detected and the sets of world coordinate values of all other targets among the multiple targets except the target to be detected, obtain the distance change parameter of the target to be detected relative to all other targets, and obtain the distance change parameter of each target.
[0082] In this embodiment, each target in the image to be processed is detected for abnormality. Each target can be taken as the target to be detected one by one, and then all other targets among the multiple targets except the target to be detected can be obtained. Based on the set of world coordinate values of the target to be detected and the sets of world coordinate values of all other targets, the distance change parameter of the target to be detected can be obtained, that is, the distance change parameter of each target can be obtained.
[0083] For example, there are 5 targets in the image to be processed, such as T1, T2, T3, T4, and T5. Take these 5 targets as the target to be detected one by one. For example, when T1 is taken as the target to be detected, T2, T3, T4, and T5 are all other targets among the 5 targets except T1. Then, according to the set of world coordinate values of T1 and the sets of world coordinate values of T2, T3, T4, and T5, the distance change parameter of T1 is obtained. It can be understood that the method for obtaining the distance change parameters of T2, T3, T4, and T5 is similar to that for obtaining the distance change parameter of T1. The distance change parameter of a target can be understood as a parameter used to evaluate the distance change of the target relative to all other targets, and the distance change situation can reflect the movement trend of the target.
[0084] Step S210: Determine whether each target is abnormal according to the distance change parameter of each target.
[0085] In this embodiment, the distance change parameter of each target is obtained, and then it can be determined whether each target is abnormal.
[0086] It can be seen that based on the above steps, the identifiers of multiple targets and the first world coordinate values of each target in the preset world coordinate system are obtained from the image to be processed; then, according to the identifiers of the multiple targets and the N historical images before the image to be processed, N historical world coordinate values of each target in the preset world coordinate system are obtained, where one historical world coordinate value corresponds to one frame of historical image, and N is a positive integer; then, according to the first world coordinate value and the N historical world coordinate values of each target among the multiple targets, a set of world coordinate values of each target is constructed; then, each target is taken as the target to be detected one by one, and according to the set of world coordinate values of the target to be detected and the set of world coordinate values of all other targets except the target to be detected among the multiple targets, the distance change parameter of the target to be detected relative to all other targets is obtained, and the distance change parameter of each target is obtained; finally, whether each target is abnormal is determined according to the distance change parameter of each target. By obtaining multiple positions of the target in the real world through the image and obtaining the distance change of the target relative to other targets to determine whether the target is abnormal, the target can be detected quickly and accurately, which is beneficial to preventing the occurrence of abnormal events and achieving the effect of monitoring and early warning.
[0087] Optionally, in the above step S202, the first world coordinate value of each target in the preset world coordinate system can be obtained according to the positions of the multiple targets in the image to be processed. Furthermore, an embodiment of the present invention provides a possible implementation manner. Please refer to Figure 3 , where step S202 includes the following steps:
[0088] Step 202-1: Detect the image to be processed, and obtain the identifiers of multiple targets and the first pixel coordinate values of each target in the preset image coordinate system;
[0089] In this embodiment, the image to be processed can be detected using a detection algorithm, which can be full-screen detection or specific areas can be set to detect only specific areas, so as to obtain the identifiers of all targets in the image to be processed and the positions of each target in the image to be processed, and the position can be represented by the first pixel coordinate value of the target in the preset image coordinate system.
[0090] Step 202-3: According to the first pixel coordinate value of each target and the preset conversion relationship, obtain the first world coordinate value of each target in the preset world coordinate system;
[0091] Among them, the preset conversion relationship represents the conversion relationship between the preset image coordinate system and the preset world coordinate system.
[0092] Optionally, the conversion relationship between the preset image coordinate system and the preset world coordinate system, that is, the preset conversion relationship, can be obtained in advance.
[0093] In this embodiment, after obtaining the first pixel coordinate values of each target, coordinate conversion can be performed based on a preset conversion relationship to obtain the first world coordinate values of each target in the preset coordinate system.
[0094] It can be understood that the method for obtaining the historical world coordinate values of the target according to the historical images is the same as the principle of the above steps. The N historical world coordinate values of each target can be obtained through the N second pixel coordinate values of each target in N historical images and the preset conversion relationship.
[0095] It can be seen that through the preset conversion relationship, the position of the target in the image can be converted into the position of the target in the actual world, which is convenient for obtaining the actual distance between each target and other targets in the subsequent steps, thereby further improving the accuracy of determining the abnormal target.
[0096] Optionally, for the above step S208, an embodiment of the present invention provides a possible implementation manner. Please refer to Figure 4 where step S208 includes the following steps:
[0097] Step S208-1: Obtain the distance array between the target to be detected and each other target according to the world coordinate value set of the target to be detected and the world coordinate value set of each other target;
[0098] The world coordinate value set of the target to be detected can be understood as multiple position points of the target to be detected in the actual world. The world coordinate value set of other targets can be understood as multiple position points of other targets in the actual world.
[0099] In this embodiment, for the target to be detected and any one other target, a distance data can be obtained by calculating the two position points obtained from the same image of these two targets. Multiple distance data can be obtained according to multiple images, and these multiple distance data form the distance array between the target to be detected and other targets. Based on each other target, the distance array between the target to be detected and each other target can be obtained.
[0100] The distance array is used to represent the degree of distance change between the target to be detected and other targets.
[0101] Step S208-3: Obtain the effective distance array from all the distance arrays. The effective distance array represents the distance array between the target to be detected and the effective target, and the effective target represents that the degree of distance change between it and the target to be detected meets the preset conditions;
[0102] It can be understood that whether the target to be detected is abnormal can be determined by the distance change between the target to be detected and other targets. In order to improve the detection accuracy, it is necessary to select effective targets from all other targets to exclude the interference of invalid targets.
[0103] For example, if the target to be detected is moving in the same row as one of the other targets, the change in the distance between this other target and the target to be detected is relatively small, which is not conducive to determining the moving trend of the target to be detected. Then this other target is an invalid target and needs to be excluded.
[0104] In this embodiment, valid targets can be selected from all the other targets, and the change in the distance between the valid target and the target to be detected meets a preset condition. The preset condition can be within a preset range, a preset threshold, or a combination of a preset range and a preset threshold. Then, by obtaining the distance data between the valid target and the target to be detected, a valid distance array is obtained.
[0105] Step S208-5: Use the ratio of the number of the valid distance arrays to the number of all the distance arrays as the distance change parameter of the target to be detected.
[0106] In this embodiment, after obtaining the valid distance array, count the number of the valid distance array and the number of all the distance arrays, and use the ratio of the number of the valid distance arrays to the number of all the distance arrays as the distance change parameter of the target to be detected. The distance change parameter can reflect the change in the distance of the target to be detected relative to all the other targets, that is, obtain the moving trend of the target to be detected.
[0107] It can be seen that through the world coordinate value sets of the target to be detected and each other target, the distance arrays between the target to be detected and each other target are obtained, and based on the preset condition, valid targets are obtained and valid distance arrays are obtained. The ratio of the number of the valid distance arrays to the number of all the distance arrays is used as the distance change parameter of the target to be detected. By screening out valid targets through the preset condition and obtaining valid distance arrays, the interference of invalid targets is excluded, and the accuracy of detecting abnormal targets is further improved.
[0108] Optionally, based on the fact that each target has a world coordinate value set, which includes N + 1, that is, M world coordinate values. The distance arrays between the target to be detected and each target can be obtained according to the M world coordinate values of the target to be detected and the M world coordinate values of each target. Furthermore, for the above step S208-1, an embodiment of the present invention provides a possible implementation manner. Please refer to Figure 5 , where step S208-1 includes the following steps:
[0109] It should be noted that the methods for obtaining the distance arrays of the target to be detected and each other target are similar. For the sake of brevity, the following will describe the steps for obtaining the distance between the target to be detected and one other target.
[0110] Step S208-1-2: For any other target, obtain the m-th distance parameter based on the m-th world coordinate value of the other target and the m-th world coordinate value of the target to be detected, and obtain M distance parameters;
[0111] where m is a positive integer not greater than M.
[0112] In this embodiment, the square of the distance between the m-th world coordinate value of the other target and the m-th world coordinate value of the target to be detected can be calculated as the m-th distance parameter. Based on the M world coordinate values, M distance parameters can be obtained.
[0113] Step S208-1-4: Use the M distance parameters as the distance array between the target to be detected and the other targets;
[0114] In this embodiment, the obtained M distance parameters are used as the distance array between the target to be detected and the other targets.
[0115] Step S208-1-6: Traverse each other target to obtain the distance array between the target to be detected and each other target.
[0116] For each other target, steps S208-1-2 and S208-1-4 can be executed to obtain the distance array between the target to be detected and each other target.
[0117] In this embodiment, the world coordinate value of the target includes the abscissa value and the ordinate value. For the above step S208-1-2, the present invention provides a possible implementation manner. Among them, step S208-1-2 includes the following steps:
[0118] Step S208-1-2-1: Calculate the square of the difference between the m-th abscissa value of the other target and the m-th abscissa value of the target to be detected to obtain the m-th first sub-distance parameter;
[0119] Step S208-1-2-3: Calculate the square of the difference between the m-th ordinate value of the other target and the m-th ordinate value of the target to be detected to obtain the m-th second sub-distance parameter;
[0120] Step S208-1-2-5: Add the m-th first sub-distance parameter and the m-th second sub-distance parameter to obtain the m-th distance parameter.
[0121] For ease of understanding, in the embodiment of the present invention, taking N as 3, that is, obtaining the previous 3 frame historical images before the image to be processed, the above steps are introduced.
[0122] Please refer to Figure 6, where (a1) represents the third historical image P1 before the image to be processed, (a2) represents the second historical image P2 before the image to be processed, (a3) represents the first historical image P3 before the image to be processed, and (a4) represents the image to be processed P4.
[0123] The image to be processed P4 includes five targets, namely Target A to Target E, and Target E is the target to be detected.
[0124] According to the positions of each target in the image to be processed and the three historical images, the first world coordinate value and three historical world coordinate values of each target are obtained, and the data is shown in the following table.
[0125]
[0126] Among them, the historical coordinate value 1 represents the historical world coordinate value obtained according to the position of the target in the historical image P1; the historical coordinate value 2 represents the historical world coordinate value obtained according to the position of the target in the historical image P2; the historical coordinate value 3 represents the historical world coordinate value obtained according to the position of the target in the historical image P3; the first world coordinate value represents the first world coordinate value obtained according to the position of the target in the image to be processed P4. The set of world coordinate values of each target includes four world coordinate values.
[0127] For each of the other targets, namely Target A to Target D, a distance array between each other target and the target to be detected E is obtained. For the sake of brevity, an example of obtaining the distance array between the target to be detected E and Target A is used for illustration.
[0128] When m = 1, based on the first world coordinate value (x54, y54) of the target to be detected E and the first world coordinate value (x14, y14) of Target A, the first distance parameter (x54 - x14) 2 +(y54 - y14) 2 ;
[0129] When m = 2, based on the second world coordinate value (x53, y53) of the target to be detected E and the second world coordinate value (x13, y13) of Target A, the second distance parameter (x53 - x13) 2 +(y53 - y13) 2 ;
[0130] When m = 3, based on the third world coordinate value (x52, y52) of the target to be detected E and the third world coordinate value (x12, y12) of Target A, the third distance parameter (x52 - x12) 2 +(y52 - y12) 2 ;
[0131] m = 4, based on the 4th world coordinate value (x51, y51) of the target E to be detected and the 4th world coordinate value (x11, y11) of the target A, the 4th distance parameter (x51 - x11) is obtained 2 +(y51 - y11) 2 ;
[0132] Obtain the distance array EA between the target E to be detected and the target A = [(x54 - x14) 2 +(y54 - y14) 2 , (x53 - x13) 2 +(y53 - y13) 2 , (x52 - x12) 2 +(y52 - y12) 2 , (x52 - x12) 2 +(y52 - y12) 2 .
[0133] According to the target E to be detected and the targets B, C, and D respectively, the distance arrays EB, EC, and ED can be obtained
[0134] It can be seen that by calculating the mth world coordinate value of each other target and the target E to be detected, the distance array between each other target and the target E to be detected can be obtained. This distance array includes multiple distance parameters, that is, the actual distance between the target E to be detected and other targets. According to the actual distance, the distance change of the target E to be detected relative to other targets can be obtained more accurately to determine whether the movement of the target E to be detected is abnormal
[0135] Optionally, according to the obtained distance array, an effective distance array that meets the preset conditions can be obtained from all the distance arrays according to the preset range and the preset threshold. Furthermore, for the above step S208 - 3, an embodiment of the present invention provides a possible implementation manner. Please refer to Figure 7 , where step S208 - 3 includes the following steps
[0136] Step S208 - 3 - 2, obtain a pending distance array from all the distance arrays, and each distance parameter in the pending distance array belongs to the preset range
[0137] In order to reduce the fluctuation of abnormal distance parameters and prevent abnormal distance parameters from affecting the detection result, the range of normal distance parameters, that is, the preset range, can be preset. This preset range includes the upper threshold TOP and the lower threshold BOTTOM
[0138] For example, in the above embodiments, the distance arrays EA, EB, EC, and ED are obtained. A to-be-determined distance array is selected from these four distance arrays. If each distance parameter in each of these four distance arrays belongs to a preset range, the to-be-determined distance arrays EA, EB, EC, and ED are obtained.
[0139] Step S208-3-4: For each to-be-determined distance array, calculate the average value of the absolute differences between any two adjacent distance parameters in the to-be-determined distance array to obtain the change parameter of the to-be-determined distance array.
[0140] In this embodiment, for each to-be-determined distance array, the absolute difference between any two adjacent distance parameters in the to-be-determined distance array can be calculated, and then the average value of all the absolute differences is calculated to obtain the change parameter of the to-be-determined distance array.
[0141] The absolute difference between two adjacent distance parameters can be understood as the distance change between the target to be detected and other targets reflected by two consecutive frames of images.
[0142] For example, for the to-be-determined distance arrays EA, EB, EC, and ED obtained in the above steps, calculate the change parameter of each to-be-determined distance array, and obtain the change parameters k1, k2, k3, and k4 respectively.
[0143] Step S208-3-6: Use the to-be-determined distance array with the change parameter equal to or greater than the preset threshold as the valid distance array.
[0144] In this embodiment, if the change parameter of the to-be-determined distance array is equal to or greater than the preset threshold, it means that the distance change between the target to be detected and the other target is relatively large, that is, the preset condition is satisfied, and the other target is a valid target, then the to-be-determined distance array is a valid distance array.
[0145] For example, for the four change parameters k1, k2, k3, and k4 obtained in the above steps, if the change parameters k1, k2, and k3 are greater than the preset threshold, then use the to-be-determined distance arrays EA, EB, and EC as the valid distance arrays.
[0146] It can be seen that by using the preset range and the preset threshold, the valid distance array is selected from all the distance arrays, the interference of abnormal distance parameters is excluded, the validity of each distance parameter in the valid distance array is ensured, and thus the distance change between the target and other targets can be accurately obtained.
[0147] Optionally, for the above step S210, an embodiment of the present invention provides a possible implementation manner, where step S210 may include the following steps:
[0148] Step S210A, if the distance change parameter of the target is equal to or greater than the preset parameter, it is determined that the target is abnormal;
[0149] Step S210B, if the distance change parameter of the target is less than the preset parameter, it is determined that the target is normal.
[0150] Optionally, the preset parameter can belong to a set range such as [0, 1].
[0151] The distance change parameter of the target can be understood as the proportion of other targets with a relatively large distance change from this target among all targets. If the distance change parameter is equal to or greater than the preset parameter, it means that the distance of this target changes greatly from a relatively large number of other targets, and the movement of this target is abnormal. If the distance change parameter is less than the preset parameter, it means that the distance of this target changes greatly from a relatively small number of other targets, and the movement of this target is normal.
[0152] For example, taking the preset threshold as 0.7 as an example, in the above embodiment, three effective distance arrays, namely EA, EB, and ED, are obtained. According to the number of effective distance arrays and the number of all distance arrays, the distance change parameter of the target E to be detected, that is, 0.75, is obtained. The distance change parameter of the target E to be detected is greater than the preset threshold, indicating that the movement of the target E to be detected is abnormal, so the target E is abnormal.
[0153] Optionally, after step S210A, step S212 may further be included. If it is determined that the target is abnormal, the target is tracked and monitored according to the identifier of the target and the first world coordinate value of the target.
[0154] For example, in the above example, if it is determined that the target E is abnormal, the identifier and the first world coordinate value of the target E can be sent to the shooting device to enable the shooting device to track and monitor the target E.
[0155] It can be seen that by comparing the size of the distance change parameter of the target with the preset parameter, it is determined whether the target is abnormal. If the target is abnormal, the target is tracked and monitored according to the target identifier and the first world coordinate value. Thus, abnormal targets can be monitored to prevent the occurrence of abnormal events, achieving the effects of monitoring and early warning and improving safety.
[0156] To execute the corresponding steps in the above embodiments and various possible ways, an implementation manner of an abnormal target detection device is given below. Please refer to Figure 8 , Figure 8 This is a functional module diagram of an abnormal target detection device 300 provided by an embodiment of the present invention. It should be noted that the basic principle and the technical effects generated by the abnormal target detection device 300 provided in this embodiment are the same as those in the above embodiments. For the sake of brief description, for the parts not mentioned in this embodiment, reference may be made to the corresponding contents in the above embodiments.
[0157] The abnormal target detection device 300 includes:
[0158] A first acquisition module 310, configured to obtain the identifiers of multiple targets and the first world coordinate values of each target in a preset world coordinate system according to the image to be processed;
[0159] A second acquisition module 330, configured to obtain N historical world coordinate values of each target in a preset world coordinate system according to the identifiers of the multiple targets and N frame historical images before the image to be processed; one historical world coordinate value corresponds to one frame of historical image; N is a positive integer;
[0160] A calculation module 350, configured to use the first world coordinate values and the N historical world coordinate values of each target among the multiple targets as the world coordinate value set of each target;
[0161] Taking each target as the target to be detected one by one, according to the world coordinate value set of the target to be detected and the world coordinate value sets of all other targets except the target to be detected among the multiple targets, obtaining the distance change parameter of the target to be detected relative to all other targets, and obtaining the distance change parameter of each target;
[0162] A determination module 370, configured to determine whether each target is abnormal according to the distance change parameter of each target.
[0163] Optionally, the first acquisition module 310 is specifically configured to: detect the image to be processed, and obtain the identifiers of multiple targets and the first pixel coordinate values of each target in a preset image coordinate system;
[0164] According to the first pixel coordinate value of each target and a preset conversion relationship, obtaining the first world coordinate value of each target in a preset world coordinate system; the preset conversion relationship represents the conversion relationship between the preset image coordinate system and the preset world coordinate system.
[0165] Optionally, the calculation module 350 is specifically configured to: obtain a distance array of the target to be detected and each other target according to the world coordinate value set of the target to be detected and the world coordinate value sets of each other target;
[0166] Obtaining an effective distance array from all the distance arrays, where the effective distance array represents the distance array of the target to be detected and the effective targets, and the effective targets represent those whose distance change degree from the target to be detected meets a preset condition;
[0167] Taking the ratio of the number of the effective distance arrays to the number of all the distance arrays as the distance change parameter of the target to be detected.
[0168] Optionally, the calculation module 350 is specifically configured to: for any other target, obtain the m-th distance parameter according to the m-th world coordinate value of the other target and the m-th world coordinate value of the target to be detected, and obtain M distance parameters; m is a positive integer not greater than M;
[0169] Use the M distance parameters as the distance array between the target to be detected and the other target;
[0170] Traverse each other target to obtain the distance array between the target to be detected and each other target.
[0171] Optionally, the calculation module 350 is specifically configured to: calculate the square of the difference between the m-th abscissa value of the other target and the m-th abscissa value of the target to be detected to obtain the m-th first sub-distance parameter;
[0172] Calculate the square of the difference between the m-th ordinate value of the other target and the m-th ordinate value of the target to be detected to obtain the m-th second sub-distance parameter;
[0173] Add the m-th first sub-distance parameter and the m-th second sub-distance parameter to obtain the m-th distance parameter.
[0174] Optionally, the calculation module 350 is specifically configured to: obtain a to-be-determined distance array from all the distance arrays, and each distance parameter in the to-be-determined distance array belongs to a preset range;
[0175] For each to-be-determined distance array, calculate the average value of the absolute differences between any two adjacent distance parameters in the to-be-determined distance array to obtain the change parameter of the to-be-determined distance array;
[0176] Use the to-be-determined distance array with the change parameter equal to or greater than the preset threshold as the valid distance array.
[0177] Optionally, the determination module 370 is specifically configured to: for each of the targets, if the distance change parameter of the target is equal to or greater than the preset parameter, determine that the target is abnormal; if the distance change parameter of the target is less than the preset parameter, determine that the target is normal.
[0178] Optionally, the determination module 370 is further configured to: if it is determined that the target is abnormal, perform tracking and monitoring on the target according to the identifier of the target and the first world coordinate value of the target.
[0179] An embodiment of the present invention further provides an electronic device, including a processor 120 and a memory 130. The memory 130 stores a computer program. When the processor executes the computer program, the abnormal target detection method disclosed in the above embodiment is implemented.
[0180] An embodiment of the present invention also provides a storage medium, on which a computer program is stored. When the computer program is executed by a processor 120, the abnormal target detection method disclosed in the embodiment of the present invention is implemented.
[0181] In summary, for the abnormal target detection method, device, electronic device and storage medium provided by the embodiments of the present invention, the identifiers of multiple targets and the first world coordinate values of each target in a preset world coordinate system are obtained from a to-be-processed image; then, according to the identifiers of the multiple targets and the N frame historical images before the to-be-processed image, N historical world coordinate values of each target in the preset world coordinate system are obtained, where one historical world coordinate value corresponds to one frame of historical image, and N is a positive integer; then, according to the first world coordinate value and the N historical world coordinate values of each target among the multiple targets, a world coordinate value set of each target is constructed; then, each target is taken as a to-be-detected target one by one, and according to the world coordinate value set of the to-be-detected target and the world coordinate value sets of all other targets except the to-be-detected target among the multiple targets, a distance change parameter of the to-be-detected target relative to all other targets is obtained, so as to obtain the distance change parameter of each target; finally, whether each target is abnormal is determined according to the distance change parameter of each target. By obtaining multiple positions of a target in the real world from an image and obtaining its distance change relative to other targets to determine whether the target is abnormal, the target can be detected quickly and accurately, which is beneficial to preventing the occurrence of abnormal events and achieving the effect of monitoring and early warning.
[0182] In several embodiments provided by the present invention, it should be understood that the disclosed device and method can also be implemented in other ways. The device embodiments described above are merely illustrative. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architectures, functions and operations of devices, methods and computer program products according to multiple embodiments of the present invention. In this regard, each block in the flowchart or block diagram may represent a module, a program segment or a part of code, and the module, program segment or part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order from that marked in the accompanying drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and the combination of blocks in the block diagram and / or flowchart, can be implemented by a dedicated hardware-based system for performing the specified functions or actions, or can be implemented by a combination of dedicated hardware and computer instructions.
[0183] In addition, in each embodiment of the present invention, each functional module can be integrated together to form an independent part, or each module can exist alone, or two or more modules can be integrated to form an independent part.
[0184] If the above-mentioned function is implemented in the form of a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), magnetic disks, or optical discs that can store program codes.
[0185] The above are only the preferred embodiments of the present invention and are not used to limit the present invention. For those skilled in the art, the present invention can have various changes and modifications. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.
Claims
1. An abnormal target detection method, characterized in that, The method includes: Obtaining the identifiers of multiple targets and the first world coordinate values of each target in a preset world coordinate system according to the image to be processed; Obtaining N historical world coordinate values of each target in the preset world coordinate system according to the identifiers of the multiple targets and N frame historical images before the image to be processed; one of the historical world coordinate values corresponds to one frame of the historical image; N is a positive integer; Constructing a set of world coordinate values for each target according to the first world coordinate value and N historical world coordinate values of each target in the multiple targets; the set of world coordinate values includes M world coordinate values; M is equal to N plus 1; Taking each target as a target to be detected one by one. For any other target except the target to be detected, obtaining the m-th distance parameter according to the m-th world coordinate value of the other target and the m-th world coordinate value of the target to be detected, and obtaining M distance parameters; m is a positive integer not greater than M; taking the M distance parameters as the distance array between the target to be detected and the other target; traversing each other target to obtain the distance array between the target to be detected and each other target; Obtaining a to-be-determined distance array from all the distance arrays, and each distance parameter in the to-be-determined distance array belongs to a preset range; for each to-be-determined distance array, calculating the average value of the absolute differences between any two adjacent distance parameters in the to-be-determined distance array to obtain the change parameter of the to-be-determined distance array; Taking the to-be-determined distance array with the change parameter equal to or greater than the preset threshold as an effective distance array, and taking the ratio of the number of effective distance arrays to the number of all distance arrays as the distance change parameter of the target to be detected, and obtaining the distance change parameter of each target; For each target, if the distance change parameter of the target is equal to or greater than the preset parameter, determining that the target is abnormal; if the distance change parameter of the target is less than the preset parameter, determining that the target is normal.
2. The method according to claim 1, wherein The step of obtaining the identifiers of multiple targets and the first world coordinate values of each target in a preset world coordinate system according to the image to be processed includes: Detecting the image to be processed to obtain the identifiers of the multiple targets and the first pixel coordinate values of each target in a preset image coordinate system; Obtaining the first world coordinate values of each target in the preset world coordinate system according to the first pixel coordinate values of each target and a preset conversion relationship; the preset conversion relationship represents the conversion relationship between the preset image coordinate system and the preset world coordinate system.
3. The method according to claim 1, wherein The world coordinate values include abscissa values and ordinate values; The step of obtaining the m-th distance parameter according to the m-th world coordinate value of the other target and the m-th world coordinate value of the target to be detected includes: Calculating the square of the difference between the m-th abscissa value of the other target and the m-th abscissa value of the target to be detected to obtain the m-th first sub-distance parameter; Calculating the square of the difference between the m-th ordinate value of the other target and the m-th ordinate value of the target to be detected to obtain the m-th second sub-distance parameter; Adding the m-th first sub-distance parameter and the m-th second sub-distance parameter to obtain the m-th distance parameter.
4. An abnormal target detection device, characterized in that, The device includes: A first acquisition module, configured to obtain identifiers of multiple targets and first world coordinate values of each target in a preset world coordinate system according to a to-be-processed image; A second acquisition module, configured to obtain N historical world coordinate values of each target in the preset world coordinate system according to the identifiers of the multiple targets and N frame historical images before the to-be-processed image; one historical world coordinate value corresponds to one frame of the historical image; N is a positive integer; A calculation module, configured to construct a world coordinate value set of each target according to the first world coordinate value and the N historical world coordinate values of each target in the multiple targets; the world coordinate value set includes M world coordinate values; M is equal to N + 1; Taking each target as a to-be-detected target one by one, for any other target except the to-be-detected target, obtaining an m-th distance parameter according to the m-th world coordinate value of the other target and the m-th world coordinate value of the to-be-detected target, to obtain M distance parameters; m is a positive integer not greater than M; taking the M distance parameters as a distance array between the to-be-detected target and the other target; traversing each other target to obtain a distance array between the to-be-detected target and each other target; obtaining a to-be-determined distance array from all the distance arrays, where each distance parameter in the to-be-determined distance array belongs to a preset range; for each to-be-determined distance array, calculating an average value of absolute differences between any two adjacent distance parameters in the to-be-determined distance array to obtain a change parameter of the to-be-determined distance array; taking the to-be-determined distance array with the change parameter being equal to or greater than a preset threshold as a valid distance array, and taking a ratio of the number of valid distance arrays to the number of all distance arrays as a distance change parameter of the to-be-detected target, to obtain a distance change parameter of each target; A determination module, configured to, for each target, determine that the target is abnormal if the distance change parameter of the target is equal to or greater than a preset parameter; and determine that the target is normal if the distance change parameter of the target is less than the preset parameter.
5. An electronic device, characterized in that, It includes a processor and a memory, the memory stores a computer program, and when the processor executes the computer program, the method according to any one of claims 1 to 3 is implemented.
6. A storage medium, characterized in that, A computer program is stored on the storage medium, and when the computer program is executed by a processor, the method according to any one of claims 1 to 3 is implemented.
Citation Information
Patent Citations
Personnel distance detection method and device
CN112232279A
Abnormal behavior supervision method and device based on action recognition and storage medium
CN113052029A