Method and device for detecting target object
By using different confidence thresholds in object detection technology to detect sample picture sets and determine invalid areas, the problem of missed detection and false detection caused by the difficulty in determining the confidence threshold in the existing technology is solved, and higher detection accuracy is achieved. Spend.
Patent Information
- Application Number
- CN201810031047.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2018-01-12
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2038-01-12
AI Technical Summary
The confidence threshold in existing object detection technology is difficult to determine, resulting in inaccurate detection results and possible missed or false detections.
By extracting sample picture sets from historical video files, target objects are detected on the sample picture sets based on confidence thresholds of different sizes, the invalid areas are determined, and target objects in the invalid areas are excluded during actual detection.
It improves detection accuracy, prevents missed detections and false detections, and ensures the accuracy of detection results.
Smart Images

Figure CN110032916B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method and device for detecting a target object. Background Art
[0002] "Object detection" is a technical means of using computer vision technology to determine whether there is a target object in an image or video sequence and to locate it; among them, "pedestrian detection" is the most widely used, and plays an important role in artificial intelligence systems, vehicle assisted driving systems, intelligent robots, intelligent video surveillance, human behavior analysis, and intelligent transportation.
[0003] There are many different object detection algorithms, but the methods for outputting results are basically the same: the detected object is located using a detection box, and the probability of the object belonging to each of the preset multiple categories is calculated respectively, and the maximum probability is taken as the confidence that the object in the detection box is a specific category. In the actual detection process, if a target object of a specific category needs to be detected, an additional confidence threshold is set, and the detection box in the specific category with a confidence greater than the confidence threshold is retained as the final detection result.
[0004] In the process of implementing the present invention, the inventors found that there are at least the following problems in the prior art: in the detection method of the prior art, the confidence threshold is difficult to determine; if the confidence threshold is too small, other objects may be mistakenly detected in the detection result, resulting in inaccurate results; if the confidence threshold is too large, the number of detection results will be greatly reduced, and some real target objects will be missed, and there is also the problem of inaccurate results. Summary of the invention
[0005] In view of this, an embodiment of the present invention provides a method and device for detecting a target object, which can improve the accuracy of detecting the target object.
[0006] To achieve the above object, according to one aspect of an embodiment of the present invention, a method for detecting a target object is provided, comprising:
[0007] Extracting a sample picture set from the historical video files recorded in the area to be detected;
[0008] Performing target object detection on the sample image set based on a first confidence threshold and a second confidence threshold of different sizes, respectively, to obtain sample data sets under two confidence thresholds;
[0009] Determine the invalid area by comparing the sample data set under the first confidence threshold and the second confidence threshold;
[0010] When detecting the currently acquired image data, the target object in the invalid area is excluded.
[0011] Optionally, the step of performing target object detection on the sample image set based on a first confidence threshold and a second confidence threshold of different sizes to obtain sample data sets under two confidence thresholds respectively includes:
[0012] Performing target object detection on each frame of the sample picture set to obtain a detection result; wherein the detection result includes a detection frame of the target object and a confidence level corresponding to the detection frame;
[0013] If it is determined that the confidence of the detection result is not less than the confidence threshold, the detection result is added to the sample data set;
[0014] The above steps are repeated based on the first confidence threshold and the second confidence threshold respectively, so as to obtain sample data sets under the first confidence threshold and the second confidence threshold respectively.
[0015] Optionally, before the step of determining the invalid area by comparing the sample data set under the first confidence threshold and the sample data set under the second confidence threshold, the method further includes:
[0016] Dividing the area to be detected into a plurality of sub-areas;
[0017] The step of determining the invalid area by comparing the sample data set under the first confidence threshold and the second confidence threshold comprises:
[0018] Acquire a detection frame set corresponding to the sub-region from the sample data set under the first confidence threshold and the second confidence threshold respectively;
[0019] Calculating the overlap ratio between the detection frames in the detection frame set under the first confidence threshold and the second confidence threshold, and judging whether the sub-region is a valid region according to the overlap ratio;
[0020] The above process is repeated until all sub-areas are traversed, and other areas in the area to be detected except the valid area are regarded as invalid areas.
[0021] Optionally, the second confidence threshold is greater than the first confidence threshold, and the step of acquiring the detection frame set corresponding to the sub-region from the sample data sets under the first confidence threshold and the second confidence threshold respectively includes:
[0022] Acquire all detection frames corresponding to the sub-region from the sample data set under the first confidence threshold to obtain a first detection frame set, and acquire all detection frames corresponding to the sub-region from the sample data set under the second confidence threshold to obtain a second detection frame set;
[0023] The step of calculating the overlap rate between the detection frames in the detection frame set under different confidence thresholds, and judging whether the sub-region is a valid region according to the overlap rate comprises:
[0024] Acquire a first detection frame from the first detection frame set, and calculate the ratio of the number of detection frames in the second detection frame set whose overlap rate with the first detection frame is greater than a preset overlap rate threshold to the total number of detection frames in the second detection frame set;
[0025] Repeat the above steps until all detection frames in the first detection frame set are traversed;
[0026] If it is determined that the maximum value of the calculated ratios is greater than a preset ratio threshold, the sub-region is determined to be a valid region.
[0027] Optionally, the difference between the first confidence threshold and the second confidence threshold is not less than 20% of the first confidence threshold.
[0028] Optionally, the value range of the first confidence threshold is [0.3, 0.5]; the value range of the second confidence threshold is [0.6, 0.7].
[0029] Optionally, the overlap rate between the first detection frame and the second detection frame is a calculation result of dividing the intersection of the first detection frame and the second detection frame by the union of the first detection frame and the second detection frame.
[0030] Optionally, the step of acquiring a detection frame set corresponding to the sub-region from the sample data sets under the first confidence threshold and the second confidence threshold respectively further includes:
[0031] If it is determined that the bottom midpoint of a detection frame falls within the sub-region, it is determined that the detection frame corresponds to the sub-region.
[0032] Optionally, the step of extracting a sample picture set from a historical video file recorded for the area to be detected includes:
[0033] Pictures are extracted from the historical video files recorded for the area to be detected at uniform time intervals to obtain the sample picture set.
[0034] To achieve the above object, according to another aspect of an embodiment of the present invention, there is provided a device for detecting a target object, comprising:
[0035] A sample extraction module is used to extract a sample picture set from the historical video files recorded for the area to be detected;
[0036] A result generation module, used to perform target object detection on the sample image set based on a first confidence threshold and a second confidence threshold of different sizes, so as to obtain sample data sets under two confidence thresholds respectively;
[0037] An invalid region determination module, used to determine the invalid region by comparing the sample data set under the first confidence threshold and the sample data set under the second confidence threshold;
[0038] The detection module is used to exclude the target object in the invalid area when detecting the currently acquired image data.
[0039] Optionally, the result generation module is further used for:
[0040] Performing target object detection on each frame of the sample picture set to obtain a detection result; wherein the detection result includes a detection frame of the target object and a confidence level corresponding to the detection frame;
[0041] If it is determined that the confidence of the detection result is not less than the confidence threshold, the detection result is added to the sample data set;
[0042] The above steps are repeated based on the first confidence threshold and the second confidence threshold respectively, so as to obtain sample data sets under the first confidence threshold and the second confidence threshold respectively.
[0043] Optionally, the device further comprises:
[0044] An area division module, used for dividing the area to be detected into multiple sub-areas;
[0045] The invalid area determination module is also used for:
[0046] Acquire a detection frame set corresponding to the sub-region from the sample data set under the first confidence threshold and the second confidence threshold respectively;
[0047] Calculating the overlap ratio between the detection frames in the detection frame set under the first confidence threshold and the second confidence threshold, and judging whether the sub-region is a valid region according to the overlap ratio;
[0048] The above process is repeated until all sub-areas are traversed, and other areas in the area to be detected except the valid area are regarded as invalid areas.
[0049] Optionally, the second confidence threshold is greater than the first confidence threshold, and the invalid area determination module is further used to:
[0050] Acquire all detection frames corresponding to the sub-region from the sample data set under the first confidence threshold to obtain a first detection frame set, and acquire all detection frames corresponding to the sub-region from the sample data set under the second confidence threshold to obtain a second detection frame set;
[0051] Acquire a first detection frame from the first detection frame set, and calculate the ratio of the number of detection frames in the second detection frame set whose overlap rate with the first detection frame is greater than a preset overlap rate threshold to the total number of detection frames in the second detection frame set;
[0052] Repeat the above steps until all detection frames in the first detection frame set are traversed;
[0053] If it is determined that the maximum value of the calculated ratios is greater than a preset ratio threshold, the sub-region is determined to be a valid region.
[0054] Optionally, the difference between the first confidence threshold and the second confidence threshold is not less than 20% of the first confidence threshold.
[0055] Optionally, the value range of the first confidence threshold is [0.3, 0.5]; the value range of the second confidence threshold is [0.6, 0.7].
[0056] Optionally, the overlap rate between the first detection frame and the second detection frame is a calculation result of dividing the intersection of the first detection frame and the second detection frame by the union of the first detection frame and the second detection frame.
[0057] Optionally, the invalid area determination module is further used for:
[0058] If it is determined that the bottom midpoint of a detection frame falls within the sub-region, it is determined that the detection frame corresponds to the sub-region.
[0059] Optionally, the sample extraction module is further used for:
[0060] Pictures are extracted from the historical video files recorded for the area to be detected at uniform time intervals to obtain the sample picture set.
[0061] To achieve the above object, according to another aspect of an embodiment of the present invention, there is provided an electronic device for detecting a target object, comprising:
[0062] one or more processors;
[0063] a storage device for storing one or more programs,
[0064] When the one or more programs are executed by the one or more processors, the one or more processors at least implement:
[0065] Extracting a sample picture set from the historical video files recorded in the area to be detected;
[0066] Performing target object detection on the sample image set based on a first confidence threshold and a second confidence threshold of different sizes, respectively, to obtain sample data sets under two confidence thresholds;
[0067] Determine the invalid area by comparing the sample data set under the first confidence threshold and the second confidence threshold;
[0068] When detecting the currently acquired image data, the target object in the invalid area is excluded.
[0069] To achieve the above object, according to another aspect of an embodiment of the present invention, a computer readable medium is provided, on which a computer program is stored, and when the program is executed by a processor, at least the following is implemented:
[0070] Extracting a sample picture set from the historical video files recorded in the area to be detected;
[0071] Performing target object detection on the sample image set based on a first confidence threshold and a second confidence threshold of different sizes, respectively, to obtain sample data sets under two confidence thresholds;
[0072] Determine the invalid area by comparing the sample data set under the first confidence threshold and the second confidence threshold;
[0073] When detecting the currently acquired image data, the target object in the invalid area is excluded.
[0074] An embodiment of the above invention has the following advantages or beneficial effects: because target object detection is performed based on different confidence thresholds, and invalid areas are determined by comparing detection results, a technical means of excluding detection results appearing in invalid areas during detection is used. In this way, the actual detection process can be run at a lower confidence threshold, which can prevent missed detections and avoid false detections of objects in invalid areas at low confidence thresholds, thereby solving the problems of missed detections and false detections that may occur in existing target detection technologies and achieving the technical effect of improving detection accuracy.
[0075] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0076] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0077] Figure 1 is a schematic diagram of main steps of a method for detecting a target object according to an embodiment of the present invention;
[0078] Figure 2 It is a schematic diagram of the detection result based on the detection method in the prior art when the confidence threshold is 0.5;
[0079] Figure 3It is a schematic diagram of the detection result based on the detection method in the prior art when the confidence threshold is 0.7;
[0080] Figure 4 is a schematic diagram of the detection result when the confidence threshold is 0.5 based on the method in the embodiment of the present invention;
[0081] Figure 5 is a schematic diagram of main modules of an apparatus for detecting a target object according to an embodiment of the present invention;
[0082] Figure 6 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;
[0083] Figure 7 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0084] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0085] Figure 1 is a schematic diagram of main steps of a method for detecting a target object according to an embodiment of the present invention.
[0086] like Figure 1 As shown, a method for detecting a target object provided according to this embodiment includes:
[0087] S10, extracting a sample picture set from the historical video file recorded for the area to be detected. The preferred application scenario of this embodiment is target object detection in a fixed camera. Under normal monitoring conditions, the camera has a certain field of view. A historical monitoring video file of a certain length is obtained, and frame pictures are extracted from the monitoring video file to obtain a sample picture set. Of course, in addition to being applicable to scenarios with fixed monitoring cameras, this embodiment is also applicable to other usage environments where the area to be detected is fixed or changes regularly.
[0088] It should be noted that when extracting a sample picture set from a video file, frame pictures should be extracted at uniform time intervals. For example, 5 frames of pictures can be taken at equal intervals from the frame pictures of each second, and the extracted frame picture set is used as the sample picture set.
[0089] S11, performing target object detection on the sample picture set based on different confidence thresholds to obtain a sample data set. In this embodiment, at least two different confidence thresholds are used to perform target object detection on each frame of the sample picture set, including a first confidence threshold and a second confidence threshold greater than the first confidence threshold.
[0090] S12, determining the invalid area in the area to be detected by comparing the sample data sets under different confidence thresholds. The implementation principle of this embodiment is to compare at least two groups of sample data sets obtained under different confidence thresholds. If a detection box appears in both groups of sample data sets, it means that the area corresponding to the detection box has good credibility, that is, it is valid; if a detection box only appears in the sample data set under a low confidence threshold, it means that the area corresponding to the detection box may not be able to obtain accurate detection results at a low confidence threshold, that is, it is an invalid area. The specific comparison method is described in detail in the subsequent embodiments.
[0091] S13, when detecting the currently acquired image data, excluding the target object in the invalid area. After determining the invalid area, a lower confidence threshold can be used to detect the target object, and when performing the current actual detection process, the detection results in the invalid area are excluded, thereby ensuring that there is no problem of missed detection and reducing the false detection rate as much as possible.
[0092] From the above, it can be seen that the method provided in this embodiment adopts different confidence thresholds to detect target objects, and determines the invalid area by comparing the detection results, and excludes the detection results appearing in the invalid area during detection; in this way, the subsequent detection process can be run at a lower confidence threshold, which can prevent missed detection and avoid false detection of objects in the invalid area under the low confidence threshold, thereby solving the problems of missed detection and false detection that may occur in the existing target detection technology, and achieving the technical effect of improving detection accuracy.
[0093] In some optional embodiments, S11, the step of performing target object detection on the sample image set based on different confidence thresholds to obtain a sample data set includes:
[0094] Performing target object detection on each frame of the sample picture set to obtain a detection result; wherein the detection result includes a detection frame of the target object and a confidence level corresponding to the detection frame;
[0095] If it is determined that the confidence of the detection result is not less than the confidence threshold, the detection result is added to the sample data set;
[0096] The above steps are repeated based on different confidence thresholds to obtain sample data sets under different confidence thresholds.
[0097] In this embodiment, two different confidence thresholds are preferably used for detection; the lower confidence threshold should be equal to or close to the confidence threshold desired to be used in the current detection work, and the higher confidence threshold can be determined as needed.
[0098] In some optional embodiments, before the step of determining the invalid area in the to-be-detected area by comparing the sample data sets under different confidence thresholds in S12, the method further includes:
[0099] The area to be detected is divided into multiple sub-areas. The purpose of the sub-area division is to more conveniently determine the valid area and the invalid area; a better implementation method is to divide the rectangular area to be detected into, for example, M*N grid-type sub-areas, and judge whether each sub-area is valid or invalid, so as to finally determine the valid area or invalid area of the entire area to be detected.
[0100] After dividing the sub-regions, S12, the step of determining the invalid region in the region to be detected by comparing the sample data sets under different confidence thresholds includes:
[0101] For a certain sub-region, a detection frame set corresponding to the sub-region is obtained from sample data sets under different confidence thresholds. For the case of two different confidence thresholds, such as a first confidence threshold and a second confidence threshold, the second confidence threshold is greater than the first confidence threshold; all detection frames corresponding to the sub-region are obtained from the sample data set under the first confidence threshold to obtain a first detection frame set, and all detection frames corresponding to the sub-region are obtained from the sample data set under the second confidence threshold to obtain a second detection frame set. Among them, "a detection frame corresponding to the sub-region" means that the detection center of the detection frame falls within the sub-region. The position of the detection center in the detection frame depends on the detection scene; for example, in pedestrian detection in a store, the position where pedestrians can walk should be the main effective detection area, then the midpoint of the lower edge of the rectangular detection frame can be used as the detection center of the detection frame to locate the pedestrian's feet, thereby improving the accuracy of the effective area division and the detection accuracy of the pedestrian detection system.
[0102] Calculate the overlap rate between each detection frame in the detection frame set under different confidence thresholds, and determine whether the sub-region is a valid region based on the overlap rate. Specifically, this step obtains the first detection frame from the first detection frame set, calculates the ratio of the number of detection frames in the second detection frame set whose overlap rate with the first detection frame is greater than the preset overlap rate threshold to the total number of detection frames in the second detection frame set; repeats the above steps until all detection frames in the first detection frame set are traversed; if it is determined that the maximum value of the calculated ratio is greater than the preset ratio threshold, the sub-region is determined to be a valid region. The overlap rate threshold and the ratio threshold in this embodiment can be determined based on the algorithm, scene, personnel complexity, etc.
[0103] The above process is repeated until all sub-regions are traversed, and other regions in the area to be detected except the valid region are regarded as invalid regions. In addition, in some other optional embodiments, if the number of detection frames in a sub-region is determined to be less than a preset number threshold, the sub-region will be determined to be an invalid region; that is, when a target object hardly appears in a detection frame after a large number of sample detections, it is considered that the detection frame has little effect on the overall data, and in order to avoid false detection problems, these detection frames can be excluded.
[0104] The "overlap rate" in the steps of this embodiment is used to indicate the degree of overlap between two detection frames. The more overlapped parts there are, the closer the detection results identified by the two detection frames are. When the overlap rate reaches a preset overlap rate threshold, it can be approximately considered that the objects identified by the two detection frames are the same. In this embodiment, the "intersection-over-union ratio" is used to indicate the overlap rate between two detection frames. For example, if there is a first detection frame and a second detection frame, the intersection-over-union ratio is used to indicate the overlap rate between the two:
[0105]
[0106] At the end of the steps of this embodiment, the invalid area is divided according to the valid area, and the detection frame is screened by the invalid area. This is because it is easier to represent using the invalid area in the algorithm, and in addition to the invalid area obtained by the method of this embodiment, the boundary of the invalid area can also be manually optimized according to the actual area to be detected. For example, the boundary of the invalid area can be adjusted according to the actual layout of the scene, etc.
[0107] The following describes another embodiment of the application of the method provided by the present invention in pedestrian detection in a store.
[0108] Step 1: For a specific camera, select a time period with a large passenger flow in the monitoring area of the camera (i.e., the area to be detected), and obtain monitoring videos of about 8 hours in this time period.
[0109] Step 2: Extract video frame images from the surveillance video file, specifically extract 5 frame images from all frame images per second.
[0110] Step 3: Before executing the detection, divide each frame of the image into regions; for example, for a video file with a resolution of 1280*720 pixels, its frame image can be divided into a 16*9 distributed sub-region grid with a specification of 80*80 pixels per sub-region. It should be noted that this step does not divide each image separately, but divides the area of the image size, and classifies the sample data set obtained in the subsequent steps according to the sub-region, so as to determine whether each sub-region belongs to a valid area or an invalid area. The longer the video file is and the more detailed the sub-region division is, the more accurate the final invalid area result will be, but it will take longer to calculate. In actual engineering, it can be adjusted according to the performance of the equipment.
[0111] Step 4: Under the first confidence threshold and the second confidence threshold (the second confidence threshold is greater than the first confidence threshold), the extracted frame image is detected by the pedestrian detection algorithm to obtain the sample data sets under the first confidence threshold and the second confidence threshold respectively. The pedestrian detection algorithm adopted in this embodiment is the YOLO (You only lookonce) algorithm. Based on this algorithm, the preferred value range of the first confidence threshold is 0.3-0.5. If it is lower than this range, the probability of false detection and misdetection of objects will be greatly increased; the preferred value range of the second confidence threshold is 0.6-0.7. If it is higher than this range, too few pedestrians will be detected and the real pedestrian data cannot be obtained. When other pedestrian detection algorithms are adopted, the first confidence threshold and the second confidence threshold can be adjusted according to the accuracy of the confidence output by the algorithm, and the difference between the first confidence threshold and the second confidence threshold should be ensured to be large. It is recommended to set the difference to more than 20% of the value of the first confidence threshold so as to obtain more accurate results in the comparison of the subsequent steps.
[0112] Step 5: For a certain sub-region, search for a detection box whose detection center falls in the sub-region from the sample data set corresponding to the first confidence threshold to obtain a first detection box set; similarly, search for a detection box whose detection center falls in the second sub-region to obtain a second detection box set (it should be noted that the concepts of the first detection box set and the second detection box set are only for the convenience of expression, and the entity does not necessarily exist in the actual algorithm program).
[0113] Step 6: Obtain the first detection frame from the first detection frame set, and calculate the ratio of the number of detection frames in the second detection frame set whose overlap rate with the first detection frame is greater than a preset overlap rate threshold to the total number of detection frames in the second detection frame set.
[0114] The overlap rate in this step is expressed as Intersection-over-Union (IoU). For example, if there is a first detection box and a second detection box, the overlap rate between the two is expressed as:
[0115]
[0116] For a store scene, a video file with a resolution of 720 pixels, divided into sub-regions of 80*80 pixels, a first confidence threshold of 0.3-0.5, and a second confidence threshold of 0.6-0.7, the optimal value of the overlap rate threshold is 80%. For other scenes, the overlap rate threshold can be adaptively adjusted according to changes in parameters and scenes.
[0117] Step 7: Repeat step 6 until all detection frames in the first detection frame set are traversed; determine whether the maximum value of all the obtained ratios is greater than a preset ratio threshold. If so, determine that the sub-region is a valid region.
[0118] Based on the scenario and parameters described in step 6, the ratio threshold in this step is preferably set to 86%. The ratio threshold can also be adaptively adjusted according to changes in parameters and scenarios.
[0119] Step 8: Repeat step 7 until all sub-areas are traversed to obtain all valid areas of the area to be detected; and take other areas of the area to be detected except the valid area as invalid areas.
[0120] In addition to determining the invalid area based on the valid area, when executing step 5, if it is determined that the number of detection frames in the second detection frame set is too small (which can be determined by setting a threshold), the sub-area can be set as an invalid area. This is because if there are too few detection frames, it means that the area is not an area where pedestrians often pass by, and most of the people who occasionally appear in the area are not pedestrians, but for example, workers who use ladders to load goods, electrician repairmen, etc. When the number of detection frames in the second detection frame set is too small, even if the number of detection frames in the first detection frame set of the sub-area is large, it should not be taken into consideration, because this situation indicates that human-like objects often exist in the sub-area, such as advertising billboards, large anthropomorphic toys, etc. In any case, it will interfere with the pedestrian data, so it should be excluded.
[0121] Step 9: During real-time pedestrian detection, exclude results where the detection center falls in an invalid area.
[0122] The purpose of steps 1-8 is to determine the invalid area based on a large number of pedestrian samples in the monitoring area. For the same camera, the scene in the area it monitors is usually fixed, such as the location of the shelf, the location of the wall, etc. Of course, there may be a problem of scene changes in the monitoring area. At this time, the above steps 1-8 can be repeated to re-divide the invalid area. Step 9 is the current real-time detection process. By acquiring real-time image data and performing detection, the detected pedestrian data is obtained, so that the pedestrian popularity in the store can be counted based on the pedestrian data to facilitate sales planning.
[0123] Figure 2 It is a schematic diagram of the detection result based on the detection method in the prior art when the confidence threshold is 0.5; Figure 3 It is a schematic diagram of the detection result based on the detection method in the prior art when the confidence threshold is 0.7; Figure 4 This is a schematic diagram of the detection results based on the method in the embodiment of the present invention when the confidence threshold is 0.5. Figure 2-Figure 4 In the figure, the dotted frame represents the detection box, and the number next to the detection box represents the confidence of the detection box.
[0124] like Figure 2 As shown in FIG. 1 , a certain detection area in a store scene includes three rows of shelves. When the confidence threshold is 0.5, pedestrian detection algorithms in the prior art can detect pedestrians 21, 22, 23, 24, and 25. However, due to the low confidence threshold, the teddy bear 26 placed on the shelf is also identified as a pedestrian, resulting in a false detection. Figure 3 As shown, when the confidence threshold is increased to 0.7, although the teddy bear 26 is excluded from the result, pedestrians 24 and 25 are also excluded from the result because they are far away from the camera and their features are not obvious enough, resulting in inaccurate results.
[0125] like Figure 4 As shown, after the area to be detected is processed based on the method in the embodiment of the present invention, an invalid area is marked (the area covered with diagonal lines in the figure is not covered according to the sub-area in order to make the image clear, and is only schematically marked). It can be seen that the area where the teddy bear 26 is located has been set as an invalid area, so the teddy bear 26 will not be included in the detection result; and the walkway where pedestrians 24 and pedestrians 25 are located meets the conditions of the valid area due to the frequent pedestrians passing by with the support of a large amount of data. At this time, the confidence threshold is set to 0.5 for detection, all pedestrians are accurately detected, and the teddy bear is excluded from the detection result.
[0126] Figure 5 is a schematic diagram of main modules of an apparatus for detecting a target object according to an embodiment of the present invention.
[0127] like Figure 5 As shown, the embodiment of the present invention also embodies a device 500 for detecting a target object, including:
[0128] The sample extraction module 501 is used to extract a sample picture set from the historical video file recorded for the area to be detected;
[0129] A result generation module 502 is used to perform target object detection on the sample image set based on different confidence thresholds to obtain a sample data set;
[0130] An invalid region determination module 503, configured to determine an invalid region by comparing the sample data sets under different confidence thresholds;
[0131] The detection module 504 is used to exclude the target object in the invalid area when detecting the currently acquired image data.
[0132] From the above, it can be seen that the device provided in this embodiment adopts different confidence thresholds to detect target objects, and determines the invalid area by comparing the detection results, and excludes the detection results appearing in the invalid area during detection; in this way, the subsequent detection process can be operated at a lower confidence threshold, which can prevent missed detection and avoid false detection of objects in the invalid area under the low confidence threshold, thereby solving the problems of missed detection and false detection that may occur in the existing target detection technology, and achieving the technical effect of improving the detection accuracy.
[0133] In some optional embodiments, the result generation module 502 is further configured to:
[0134] Performing target object detection on each frame of the sample picture set to obtain a detection result; wherein the detection result includes a detection frame of the target object and a confidence level corresponding to the detection frame;
[0135] If it is determined that the confidence of the detection result is not less than the confidence threshold, the detection result is added to the sample data set;
[0136] The above steps are repeated based on different confidence thresholds to obtain sample data sets under different confidence thresholds.
[0137] In some optional embodiments, the apparatus 500 further includes:
[0138] The region division module 505 is used to divide the region to be detected into multiple sub-regions;
[0139] The invalid area determination module 503 is also used for:
[0140] Obtain detection frame sets corresponding to sub-regions from sample data sets under different confidence thresholds respectively;
[0141] Calculate the overlap ratio between the detection frames in the detection frame set under different confidence thresholds, and determine whether the sub-region is a valid region according to the overlap ratio;
[0142] The above process is repeated until all sub-areas are traversed, and other areas in the area to be detected except the valid area are regarded as invalid areas.
[0143] In some optional embodiments, the different confidence thresholds include a first confidence threshold and a second confidence threshold, and the second confidence threshold is greater than the first confidence threshold; the invalid area determination module 503 is further used to:
[0144] Acquire all detection frames corresponding to the sub-region from the sample data set under the first confidence threshold to obtain a first detection frame set, and acquire all detection frames corresponding to the sub-region from the sample data set under the second confidence threshold to obtain a second detection frame set;
[0145] Obtain a certain detection frame from the first detection frame set, and calculate the ratio of the number of detection frames in the second detection frame set whose overlap rate with the certain detection frame is greater than a preset overlap rate threshold to the total number of detection frames in the second detection frame set;
[0146] Repeat the above steps until all detection frames in the first detection frame set are traversed;
[0147] If it is determined that the maximum value of the calculated ratios is greater than a preset ratio threshold, the sub-region is determined to be a valid region.
[0148] In some optional embodiments, the formula for calculating the overlap rate between two detection frames is:
[0149]
[0150] In some optional embodiments, the invalid area determination module 503 is further configured to:
[0151] If it is determined that the bottom midpoint of a detection frame falls within the sub-region, it is determined that the detection frame corresponds to the sub-region.
[0152] In some optional embodiments, the sample extraction module 501 is further used to:
[0153] Pictures are extracted from the historical video files at uniform time intervals to obtain the sample picture set.
[0154] Figure 6 An exemplary system architecture 600 is shown to which the method for detecting a target object or the apparatus for detecting a target object according to the embodiments of the present invention can be applied.
[0155] like Figure 6 As shown, system architecture 600 may include terminal devices 601, 602, 603, network 604 and server 605. Network 604 is used to provide a medium for communication links between terminal devices 601, 602, 603 and server 605. Network 604 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0156] Users can use terminal devices 601, 602, 603 to interact with server 605 through network 604 to receive or send messages, etc.
[0157] The terminal devices 601 , 602 , and 603 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers, etc.
[0158] The server 605 may be a server that provides various services, such as a background server that collects and processes video data collected by users using the terminal devices 601 , 602 , and 603 .
[0159] It should be noted that the method for detecting a target object provided in the embodiment of the present invention is generally executed by the server 605 , and accordingly, the device for detecting a target object is generally disposed in the server 605 .
[0160] It should be understood that Figure 6 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0161] According to an embodiment of the present invention, the present invention also provides an electronic device and a readable storage medium.
[0162] Figure 7 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention.
[0163] Reference below Figure 7 , which shows a schematic diagram of the structure of a computer system 700 of a terminal device suitable for implementing an embodiment of the present invention. Figure 7 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0164] like Figure 7As shown, the computer system 700 includes a central processing unit (CPU) 701, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage part 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the system 700 are also stored. The CPU 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0165] The following components are connected to the I / O interface 705: an input section 706 including a keyboard, a mouse, etc.; an output section 707 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 708 including a hard disk, etc.; and a communication section 709 including a network interface card such as a LAN card, a modem, etc. The communication section 709 performs communication processing via a network such as the Internet. A drive 710 is also connected to the I / O interface 705 as needed. A removable medium 711, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 710 as needed, so that a computer program read therefrom is installed into the storage section 708 as needed.
[0166] In particular, according to an embodiment of the present invention, the process described in the schematic diagram of the main steps above can be implemented as a computer software program. For example, an embodiment of the present invention includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program code for executing the method shown in the schematic diagram of the main steps. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 709, and / or installed from the removable medium 711. When the computer program is executed by the central processing unit (CPU) 701, the above-mentioned functions defined in the system of the present invention are executed.
[0167] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0168] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0169] The modules involved in the embodiments of the present invention may be implemented in software or hardware. The modules described may also be set in a processor. For example, they may be described as: a processor including a sample extraction module, a result generation module, an invalid region determination module, a detection module, and a region division module. The names of these modules do not, in some cases, constitute limitations on the modules themselves. For example, the result generation module may also be described as "a module for performing target object detection on the sample image set based on different confidence thresholds to obtain a sample data set".
[0170] As another aspect, the present invention further provides a computer-readable medium, which may be included in the device described in the above embodiment; or may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes:
[0171] Extract sample image sets from historical video files;
[0172] Performing target object detection on the sample image set based on different confidence thresholds to obtain a sample data set;
[0173] Determine the invalid area by comparing the sample data sets under different confidence thresholds;
[0174] When detecting the currently acquired image data, the target object in the invalid area is excluded.
[0175] The solution provided in this implementation adopts different confidence thresholds to detect target objects, determines invalid areas by comparing the detection results, and excludes the detection results appearing in the invalid areas during detection; in this way, the subsequent detection process can be run at a lower confidence threshold, which can prevent missed detections and avoid false detections of objects in invalid areas at low confidence thresholds, thereby solving the problems of missed detections and false detections that may occur in existing target detection technologies and achieving the technical effect of improving detection accuracy.
[0176] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for detecting a target object, characterized in that: include: Extracting a sample picture set from a historical video file recorded for the area to be detected; wherein the area to be detected is divided into a plurality of sub-areas; Performing target object detection on the sample image set based on a first confidence threshold and a second confidence threshold of different sizes, respectively, to obtain sample data sets under two confidence thresholds, respectively; wherein the second confidence threshold is greater than the first confidence threshold; Determining an invalid area by comparing a sample data set under a first confidence threshold and a sample data set under a second confidence threshold, including: obtaining all detection frames corresponding to the sub-area from the sample data set under the first confidence threshold to obtain a first detection frame set, and obtaining all detection frames corresponding to the sub-area from the sample data set under the second confidence threshold to obtain a second detection frame set; obtaining a first detection frame from the first detection frame set, and calculating the ratio of the number of detection frames in the second detection frame set whose overlap rate with the first detection frame is greater than a preset overlap rate threshold to the number of all detection frames in the second detection frame set; repeating the above steps until all detection frames in the first detection frame set are traversed; if it is determined that the maximum value of the calculated ratio is greater than a preset ratio threshold, determining that the sub-area is a valid area, and treating other areas in the area to be detected except the valid area as invalid areas; When detecting the currently acquired image data, the target object in the invalid area is excluded.
2. The method according to claim 1, characterized in that The step of performing target object detection on the sample image set based on the first confidence threshold and the second confidence threshold of different sizes to obtain sample data sets under two confidence thresholds respectively includes: Performing target object detection on each frame of the sample picture set to obtain a detection result; wherein the detection result includes a detection frame of the target object and a confidence level corresponding to the detection frame; If it is determined that the confidence of the detection result is not less than the confidence threshold, the detection result is added to the sample data set; The above steps are repeated based on the first confidence threshold and the second confidence threshold respectively, so as to obtain sample data sets under the first confidence threshold and the second confidence threshold respectively.
3. The method according to claim 2, characterized in that Before the step of determining the invalid area by comparing the sample data set under the first confidence threshold and the second confidence threshold, the method further includes: Dividing the area to be detected into a plurality of sub-areas; The step of determining the invalid area by comparing the sample data set under the first confidence threshold and the second confidence threshold comprises: Acquire a detection frame set corresponding to the sub-region from the sample data set under the first confidence threshold and the second confidence threshold respectively; Calculating the overlap ratio between the detection frames in the detection frame set under the first confidence threshold and the second confidence threshold, and judging whether the sub-region is a valid region according to the overlap ratio; The above process is repeated until all sub-areas are traversed, and other areas in the area to be detected except the valid area are regarded as invalid areas.
4. The method according to claim 1, characterized in that: The difference between the first confidence threshold and the second confidence threshold is not less than 20% of the first confidence threshold.
5. The method according to claim 1, characterized in that The value range of the first confidence threshold is [0.3, 0.5]; the value range of the second confidence threshold is [0.6, 0.7].
6. The method according to claim 3, characterized in that The overlap rate between the first detection frame and the second detection frame is a calculation result of dividing the intersection of the first detection frame and the second detection frame by the union of the first detection frame and the second detection frame.
7. The method according to claim 3, characterized in that The step of acquiring a detection frame set corresponding to the sub-region from the sample data sets under the first confidence threshold and the second confidence threshold respectively further includes: If it is determined that the bottom midpoint of a detection frame falls within the sub-region, it is determined that the detection frame corresponds to the sub-region.
8. The method according to claim 1, characterized in that The step of extracting a sample picture set from a historical video file recorded in the area to be detected comprises: Pictures are extracted from the historical video files recorded for the area to be detected at uniform time intervals to obtain the sample picture set.
9. A device for detecting a target object, characterized in that: include: A sample extraction module is used to extract a sample picture set from a historical video file recorded for the area to be detected; wherein the area to be detected is divided into a plurality of sub-areas; A result generation module, used to perform target object detection on the sample image set based on a first confidence threshold and a second confidence threshold of different sizes, respectively, to obtain sample data sets under two confidence thresholds; wherein the second confidence threshold is greater than the first confidence threshold; The invalid region determination module is used to determine the invalid region by comparing the sample data sets under the first confidence threshold and the second confidence threshold, including: obtaining all detection frames corresponding to the sub-region from the sample data set under the first confidence threshold to obtain a first detection frame set, and obtaining all detection frames corresponding to the sub-region from the sample data set under the second confidence threshold to obtain a second detection frame set; obtaining the first detection frame from the first detection frame set, and calculating the ratio of the number of detection frames in the second detection frame set whose overlap rate with the first detection frame is greater than a preset overlap rate threshold to the total number of detection frames in the second detection frame set; repeating the above steps until all detection frames in the first detection frame set are traversed; if it is determined that the maximum value of the calculated ratio is greater than a preset ratio threshold, the sub-region is determined to be a valid region, and the other regions in the region to be detected except the valid region are regarded as invalid regions; The detection module is used to exclude the target object in the invalid area when detecting the currently acquired image data.
10. The device according to claim 9, characterized in that The result generation module is also used for: Performing target object detection on each frame of the sample picture set to obtain a detection result; wherein the detection result includes a detection frame of the target object and a confidence level corresponding to the detection frame; If it is determined that the confidence of the detection result is not less than the confidence threshold, the detection result is added to the sample data set; The above steps are repeated based on the first confidence threshold and the second confidence threshold respectively, so as to obtain sample data sets under the first confidence threshold and the second confidence threshold respectively.
11. The device according to claim 10, characterized in that The device also includes: An area division module, used for dividing the area to be detected into a plurality of sub-areas; The invalid area determination module is also used for: Acquire a detection frame set corresponding to the sub-region from the sample data set under the first confidence threshold and the second confidence threshold respectively; Calculating the overlap ratio between the detection frames in the detection frame set under the first confidence threshold and the second confidence threshold, and judging whether the sub-region is a valid region according to the overlap ratio; The above process is repeated until all sub-areas are traversed, and other areas in the area to be detected except the valid area are regarded as invalid areas.
12. The device according to claim 9, characterized in that The difference between the first confidence threshold and the second confidence threshold is not less than 20% of the first confidence threshold.
13. The device according to claim 9, characterized in that The value range of the first confidence threshold is [0.3, 0.5]; the value range of the second confidence threshold is [0.6, 0.7].
14. The device according to claim 11, characterized in that The overlap rate between the first detection frame and the second detection frame is a calculation result of dividing the intersection of the first detection frame and the second detection frame by the union of the first detection frame and the second detection frame.
15. The device according to claim 11, characterized in that The invalid area determination module is also used for: If it is determined that the bottom midpoint of a detection frame falls within the sub-region, it is determined that the detection frame corresponds to the sub-region.
16. The device according to claim 9, characterized in that The sample extraction module is also used for: Pictures are extracted from the historical video files recorded for the area to be detected at uniform time intervals to obtain the sample picture set.
17. An electronic device for detecting a target object, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 8.
18. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.
