Image detection method, device and computer equipment
The generation of the difference graph by depth estimation and normal vector estimation models solves the problem of insufficient accuracy in the detection of safe channel occupancy, and achieves higher detection accuracy.
Patent Information
- Application Number
- CN202410921630.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-10
- Publication Date
- 2025-08-19
- Estimated Expiration
- 2044-07-10
AI Technical Summary
In the safe channel occupation detection, traditional target detection models are difficult to fully cover the actual occupied objects, resulting in low detection accuracy.
The depth estimation model and the normal vector estimation model are used to analyze the detection image and the template image, and the first normal vector map and the second normal vector map are generated. The difference map is obtained through pixel difference calculation, and the detection result is determined based on the difference map.
The accuracy of the detection results is improved, the influence of factors such as light and shadow is reduced, and the detection results are directly determined based on the image differences, without determining the type of occupancy object.
Smart Images

Figure CN118822991B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer vision technology, and in particular to an image detection method, apparatus, and computer equipment. Background Art
[0002] With the development of computer vision technology, target detection and object recognition technologies can be applied to various fields. For example, in the identification of safety channel occupancy, detection and discrimination can be performed automatically.
[0003] In traditional technology, target detection and identification are performed on the safe passage area through a target detection model, wherein the target detection model is trained with sample images of objects that may exist in the safe passage. During application, the image to be detected is input into the target detection model. Whether the safe passage is occupied is determined based on whether the target detection model identifies the object contained in the sample image in the target area of the image to be detected.
[0004] However, in traditional technologies, due to the uncertainty of objects occupying the safe passage, in the target detection operation of the target detection model, the occupied objects that can be detected are difficult to fully cover the actual occupied objects in the safe passage, resulting in certain limitations in the types of occupied objects targeted by the sample images, and thus resulting in low accuracy in determining whether the safe passage is occupied. Summary of the Invention
[0005] Based on this, it is necessary to provide an image detection method, apparatus, computer equipment, computer-readable storage medium and computer program product to address the above technical problems.
[0006] In a first aspect, the present application provides an image detection method, comprising:
[0007] Obtaining an image to be detected and a template image corresponding to the image to be detected; the template image is a standard image used for comparison and detection;
[0008] Performing image analysis processing on the image to be detected and the template image according to a depth estimation model and a normal vector estimation model to obtain a first normal vector map and a second normal vector map;
[0009] Calculating pixel differences based on the first normal vector map and the second normal vector map to obtain a difference map; the difference map is used to represent the difference between the elements contained in the image to be detected and the template image;
[0010] A detection result is determined based on the difference map.
[0011] In one embodiment, performing image analysis processing on the image to be detected and the template image according to the depth estimation model and the normal vector estimation model to obtain the first normal vector map and the second normal vector map includes:
[0012] Cropping the image to be detected and the template image according to a preset calibration area to obtain an initial image to be detected and an initial template image;
[0013] Image analysis processing is performed on the initial image to be detected and the initial template image according to a depth estimation model and a normal vector estimation model to obtain a first normal vector map and a second normal vector map.
[0014] In one embodiment, performing image analysis processing on the initial image to be detected and the initial template image according to the depth estimation model and the normal vector estimation model to obtain the first normal vector map and the second normal vector map includes:
[0015] Performing depth estimation on the initial image to be detected and the initial template image according to a depth estimation model to obtain a first target depth map and a second target depth map;
[0016] Normal vector calculation is performed on the first target depth map and the second target depth map based on a normal vector estimation model to obtain a first normal vector map and a second normal vector map.
[0017] In one embodiment, performing depth estimation on the initial image to be detected and the initial template image according to a depth estimation model to obtain a first target depth map and a second target depth map includes:
[0018] Performing depth estimation on the initial image to be detected and the initial template image according to a depth estimation model to obtain a first initial depth map and a second initial depth map;
[0019] Performing a mask operation on the image to be detected and the template image based on the preset calibration area to obtain a first initial mask image and a second initial mask image;
[0020] Cropping the first initial mask image and the second initial mask image according to the preset calibration area to obtain a first mask image and a second mask image;
[0021] performing a mask operation on the first initial depth map based on the first mask map to obtain a first target depth map;
[0022] A mask operation is performed on the second initial depth map according to the second mask map to obtain a second target depth map.
[0023] In one embodiment, determining the detection result based on the difference map includes:
[0024] Performing grayscale processing on the difference map to obtain a grayscale difference map;
[0025] Binarizing the grayscale difference map based on a preset binarization threshold to obtain a binarized difference map;
[0026] A detection result is determined according to a ratio of a first number of pixels containing a target pixel value in the binarized difference map to a second number of pixels containing the target pixel value in the second mask map of the template image.
[0027] In one embodiment, binarizing the grayscale difference map based on a preset binarization threshold to obtain a binarized difference map includes:
[0028] Binarizing the grayscale difference map based on a preset binarization threshold to obtain a binarized difference map;
[0029] Detect the target object in the initial image to be detected according to the target detection model to obtain the target object calibration frame;
[0030] A mask operation is performed on the binary difference map based on the target object calibration frame, and the binary values of corresponding pixels in the target object calibration frame are reset to zero to obtain a binary difference map after the mask operation.
[0031] In one embodiment, before obtaining the image to be detected and the template image corresponding to the image to be detected, the method further includes:
[0032] Acquire multiple template images that do not contain occupied objects and a preset calibration area corresponding to each of the template images;
[0033] A template library is constructed according to the preset calibration area, the template image, and the correspondence between the template image and the preset calibration area; the template library is used to determine the template image corresponding to the image to be detected and the preset calibration area corresponding to the image to be detected.
[0034] In a second aspect, the present application further provides an image detection device, comprising:
[0035] A first acquisition module is used to acquire an image to be detected and a template image corresponding to the image to be detected; the template image is a standard image used for comparison detection;
[0036] a normal vector estimation module, configured to perform image analysis processing on the image to be detected and the template image according to a depth estimation model and a normal vector estimation model to obtain a first normal vector map and a second normal vector map;
[0037] a difference map calculation module, configured to calculate pixel differences based on the first normal vector map and the second normal vector map to obtain a difference map; the difference map is used to represent the differences between the elements contained in the image to be detected and the template image;
[0038] A determination module is used to determine a detection result based on the difference map.
[0039] In one embodiment, the normal vector estimation module is specifically used to crop the image to be detected and the template image according to a preset calibration area to obtain an initial image to be detected and an initial template image;
[0040] Image analysis processing is performed on the initial image to be detected and the initial template image according to a depth estimation model and a normal vector estimation model to obtain a first normal vector map and a second normal vector map.
[0041] In one embodiment, the normal vector estimation module is specifically used to perform depth estimation on the initial image to be detected and the initial template image according to a depth estimation model to obtain a first target depth map and a second target depth map;
[0042] Normal vector calculation is performed on the first target depth map and the second target depth map based on a normal vector estimation model to obtain a first normal vector map and a second normal vector map.
[0043] In one embodiment, the normal vector estimation module is specifically used to perform depth estimation on the initial image to be detected and the initial template image according to a depth estimation model to obtain a first initial depth map and a second initial depth map;
[0044] Performing a mask operation on the image to be detected and the template image based on the preset calibration area to obtain a first initial mask image and a second initial mask image;
[0045] Cropping the first initial mask image and the second initial mask image according to the preset calibration area to obtain a first mask image and a second mask image;
[0046] performing a mask operation on the first initial depth map based on the first mask map to obtain a first target depth map;
[0047] A mask operation is performed on the second initial depth map according to the second mask map to obtain a second target depth map.
[0048] In one embodiment, the determining module is specifically configured to perform grayscale processing on the difference map to obtain a grayscale difference map;
[0049] Binarizing the grayscale difference map based on a preset binarization threshold to obtain a binarized difference map;
[0050] A detection result is determined according to a ratio of a first number of pixels containing a target pixel value in the binarized difference map to a second number of pixels containing the target pixel value in the second mask map of the template image.
[0051] In one embodiment, the determining module is specifically configured to perform binarization processing on the grayscale difference map based on a preset binarization threshold to obtain a binarized difference map;
[0052] Detect the target object in the initial image to be detected according to the target detection model to obtain the target object calibration frame;
[0053] A mask operation is performed on the binary difference map based on the target object calibration frame, and the binary values of corresponding pixels in the target object calibration frame are reset to zero to obtain a binary difference map after the mask operation.
[0054] In one embodiment, the apparatus further comprises:
[0055] A second acquisition module is used to acquire a plurality of template images that do not contain occupied objects and a preset calibration area corresponding to each of the template images;
[0056] A construction module is used to construct a template library based on the preset calibration area, the template image, and the correspondence between the template image and the preset calibration area; the template library is used to determine the template image corresponding to the image to be detected and the preset calibration area corresponding to the image to be detected.
[0057] In a third aspect, the present application further provides a computer device comprising a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0058] Obtaining an image to be detected and a template image corresponding to the image to be detected; the template image is a standard image used for comparison and detection;
[0059] Performing image analysis processing on the image to be detected and the template image according to a depth estimation model and a normal vector estimation model to obtain a first normal vector map and a second normal vector map;
[0060] Calculating pixel differences based on the first normal vector map and the second normal vector map to obtain a difference map; the difference map is used to represent the difference between the elements contained in the image to be detected and the template image;
[0061] A detection result is determined based on the difference map.
[0062] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the following steps are implemented:
[0063] Obtaining an image to be detected and a template image corresponding to the image to be detected; the template image is a standard image used for comparison and detection;
[0064] Performing image analysis processing on the image to be detected and the template image according to a depth estimation model and a normal vector estimation model to obtain a first normal vector map and a second normal vector map;
[0065] Calculating pixel differences based on the first normal vector map and the second normal vector map to obtain a difference map; the difference map is used to represent the difference between the elements contained in the image to be detected and the template image;
[0066] A detection result is determined based on the difference map.
[0067] In a fifth aspect, the present application further provides a computer program product, comprising a computer program, which, when executed by a processor, implements the following steps:
[0068] Obtaining an image to be detected and a template image corresponding to the image to be detected; the template image is a standard image used for comparison and detection;
[0069] Performing image analysis processing on the image to be detected and the template image according to a depth estimation model and a normal vector estimation model to obtain a first normal vector map and a second normal vector map;
[0070] Calculating pixel differences based on the first normal vector map and the second normal vector map to obtain a difference map; the difference map is used to represent the difference between the elements contained in the image to be detected and the template image;
[0071] A detection result is determined based on the difference map.
[0072] The above-mentioned image detection method, apparatus, computer device, computer-readable storage medium and computer program product obtain an image to be detected and a template image corresponding to the image to be detected; the template image is a standard image used for comparison detection; the image to be detected and the template image are subjected to image analysis processing according to a depth estimation model and a normal vector estimation model to obtain a first normal vector map and a second normal vector map; pixel difference calculation is performed based on the first normal vector map and the second normal vector map to obtain a difference map; the difference map is used to characterize the difference between the elements contained in the image to be detected and the template image; and a detection result of the image to be detected is determined based on the difference map. Using this method, depth information and normal vector information of the image to be detected can be obtained through the depth estimation model and normal vector calculation, thereby obtaining multi-dimensional information data. The difference map generated can clearly show the difference in image elements between the image to be detected and the template image. The difference map is obtained by combining the depth information and normal vector information to determine the detection result of the image to be detected. There is no need to determine the type of occupied object, and the influence of factors such as lighting and shadows is reduced. The detection result is determined directly based on the difference between the image to be detected and the template image, thereby improving the accuracy of the detection result. BRIEF DESCRIPTION OF THE DRAWINGS
[0073] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the following briefly introduces the drawings required for use in the embodiments of the present application or related technical descriptions. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying any creative work.
[0074] Figure 1 1 is a flow chart of an image detection method according to an embodiment;
[0075] Figure 2 Schematic diagram of a process for cropping an image to be detected and a template image in one embodiment;
[0076] Figure 3 A schematic diagram of cropping an image to be detected and a template image in one embodiment;
[0077] Figure 4 1 is a schematic diagram of a process for determining a first normal vector map and a second normal vector map in one embodiment;
[0078] Figure 5 FIG. 1 is a flow chart of a step of masking a depth map in one embodiment;
[0079] Figure 6 FIG. 1 is a schematic diagram of masking a depth map to obtain a mask matrix in one embodiment;
[0080] Figure 7 FIG1 is a flow chart of masking a cropped image and estimating a depth map in one embodiment;
[0081] Figure 8 FIG1 is a schematic diagram of estimating a normal vector map based on a masked depth map in one embodiment;
[0082] Figure 9 Schematic diagram of a process for determining a detection result based on a difference map in one embodiment;
[0083] Figure 10 is a schematic diagram of a process for determining a detection result based on a difference map in a specific embodiment;
[0084] Figure 11 1 is a flow chart of post-processing steps for a binarized difference map in one embodiment;
[0085] Figure 12 A schematic diagram of a post-processing step in one embodiment;
[0086] Figure 13 A schematic diagram of a process for constructing a template library in one embodiment;
[0087] Figure 14 A schematic diagram of an image detection system executing an image detection method according to an embodiment;
[0088] Figure 15 is a structural block diagram of an image detection device in one embodiment;
[0089] Figure 16 FIG. 1 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0090] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.
[0091] In one embodiment, Figure 1 As shown, an image detection method is provided. This embodiment uses the method applied to a terminal as an example for illustration. It is understandable that the method can also be applied to a server, or to a system including a terminal and a server, and implemented through interaction between the terminal and the server. In this embodiment, the method includes the following steps:
[0092] Step 102: Obtain the image to be detected and the template image corresponding to the image to be detected.
[0093] The template image is a standard image used for comparison and detection. The safety passage in the template image does not contain any occupied objects, that is, the safety passage is not blocked.
[0094] In an embodiment of the present application, the image detection method can be used to detect the occupancy status of safety passages or fire passages within a factory or park. In this scenario, each safety passage within the factory or park has corresponding monitoring equipment, and the terminal can obtain the image to be detected by extracting frames from the monitoring video taken by the monitoring equipment.
[0095] After obtaining the image to be detected, the terminal obtains the template image of the corresponding monitoring device from the template library according to the number of the monitoring device corresponding to the image to be detected.
[0096] Step 104 : performing image analysis processing on the image to be detected and the template image according to the depth estimation model and the normal vector estimation model to obtain a first normal vector map and a second normal vector map.
[0097] The depth estimation model may be a depth anything depth estimation model, and the normal vector estimation model may be a D2NT (Depth-to-Normal Translator, a normal vector estimation algorithm) normal vector estimation model.
[0098] In an embodiment of the present application, the terminal inputs the template image and the image to be detected into the depth estimation model respectively. The depth estimation model can be a deep learning model based on a convolutional neural network. The depth information of the pixels is calculated for the feature information extracted from the image to be detected and the template image through a depth estimation algorithm. The depth estimation algorithm can be a stereo matching, structured light or time-of-flight technology to generate a depth map of the image to be detected and the template image. Each pixel value in the depth map represents the distance of the position relative to the camera, which is used to reflect the spatial position relationship of each object in the safety passage of the factory or park scene, and provide basic data for subsequent analysis and processing.
[0099] After obtaining the depth map of the image to be detected and the template image, the terminal inputs it into the normal vector estimation model. The normal vector estimation model analyzes and predicts the depth map to obtain the normal vector direction of each pixel on the image to be detected and the template image, and obtains the first normal vector map corresponding to the image to be detected and the second normal vector map corresponding to the template image. The normal vector information represents the orientation of the pixel points on the surface of each object contained in the image to be detected or the template image, such as the orientation of each surface of the ground and objects in the image to be detected or the template image. Among them, the surface normal vector of each object may be different due to its position and direction, so the normal vector map can be used to distinguish different objects or parts of objects. On this basis, the normal vector map can also analyze the spatial structure and object layout in the scene contained in the image to be detected, so as to evaluate the use of the safe channel for subsequent difference calculation and detection result determination.
[0100] Step 106 : Calculate pixel differences based on the first normal vector map and the second normal vector map to obtain a difference map.
[0101] The difference map is used to represent the differences between the elements contained in the image to be detected and the template image.
[0102] In an embodiment of the present application, the terminal performs a pixel-by-pixel difference operation on the first normal vector map corresponding to the image to be detected and the second normal vector map corresponding to the template image, and performs an absolute value operation on the calculation result to obtain a difference map between the image to be detected and the template image. By analyzing the difference between the normal vectors, the safe channel for the template image that does not contain occupied objects can be detected. The object changes that may exist in the safe channel of the image to be detected can be detected. That is, by performing a difference calculation on the first normal vector map and the second normal vector map, the pixel values representing the safe channel area in the image to be detected that are the same as those in the template image can be eliminated (pixel value is 0, pixel value is black). It can be understood that if the image to be detected contains occupied objects, the difference operation between the normal vectors can only convert the pixel values of the safe channel to black. Since the pixel values of the occupied object and the safe channel itself are significantly different, the result is not 0. Optionally, the terminal can perform a binarization process on the difference map to divide the safe channel area and the occupied object area, thereby obtaining a clearly demarcated safe channel pixel area and occupied object pixel area.
[0103] Step 108: Determine the detection result based on the difference map.
[0104] In an embodiment of the present application, the terminal can determine the detection result for the safe area by calculating the ratio of the area representing the safe channel area in the difference map to the area representing the safe channel area in the mask image of the template image based on the pixel area representing the safe channel area in the image to be detected and the template image. Optionally, the terminal can also classify the detection results of the difference map according to a classification model, for example, mapping the detection results of the difference map to whether the current safe channel is occupied based on a support vector machine model.
[0105] In the above-mentioned image detection method, the depth information and normal vector information of the image to be detected can be obtained through the depth estimation model and normal vector calculation, and multi-dimensional information data can be obtained. The difference map generated can clearly show the difference in image elements between the image to be detected and the template image. The difference map is obtained by combining the depth information and normal vector information to determine the detection result of the image to be detected. There is no need to determine the type of occupied object, and the influence of factors such as lighting and shadows is reduced. The detection result is determined directly based on the difference between the image to be detected and the template image, thereby improving the accuracy of the detection result.
[0106] In an exemplary embodiment, Figure 2 As shown, step 104 includes steps 202 to 204. Among them:
[0107] Step 202 : cropping the image to be detected and the template image according to a preset calibration area to obtain an initial image to be detected and an initial template image.
[0108] In the embodiment of the present application, the preset calibration area can be the area marking of the safe passage made manually on the monitoring screen of the monitoring device when building the template library or adding a new template image, that is, the safe area in the target image is used as the region of interest (ROI). The region coordinates of the region of interest are marked as , the region of interest can be a polygon consisting of multiple region coordinates.
[0109] like Figure 3 As shown, the terminal converts the preset calibration area (ROI area coordinates) of the image to be detected into the external matrix coordinates to obtain the coordinates of the four boundaries of the circumscribed rectangle corresponding to the preset calibration area, which is recorded as The terminal crops the image to be detected and the template image based on the four boundary coordinates to obtain the cropped initial image to be detected and the initial template image.
[0110] Step 204 : performing image analysis processing on the initial image to be detected and the initial template image according to the depth estimation model and the normal vector estimation model to obtain a first normal vector map and a second normal vector map.
[0111] In an embodiment of the present application, the terminal performs image analysis and processing on the initial image to be detected and the initial template image obtained after cropping according to the depth estimation model and the normal vector model in accordance with the same principle as in step 104 to obtain a first normal vector map and a second normal vector map. The image analysis and processing principles of the depth estimation model and the normal vector estimation model are not further described in this example.
[0112] In this embodiment, by cropping the image to be detected and the template image, the background parts outside the area of interest in the image to be detected and the template image can be preliminarily eliminated, thereby avoiding excessive errors in image analysis by the depth estimation model and the normal vector estimation model, improving the quality of generating the first normal vector map and the second normal vector map, and thereby improving the accuracy of safety channel occupancy detection for the image to be detected.
[0113] In an exemplary embodiment, the process of generating the first normal vector map and the second normal vector map according to the image to be detected and the template image requires generating a depth map first, such as Figure 4 As shown, step 204 includes steps 402 to 404. Among them:
[0114] Step 402 : performing depth estimation on the initial image to be detected and the initial template image according to a depth estimation model to obtain a first target depth map and a second target depth map.
[0115] In an embodiment of the present application, the terminal inputs the initial image to be detected and the initial template image obtained after cropping into the depth estimation model respectively. The depth estimation model is trained to output a first target depth map corresponding to the initial image to be detected and a second target depth map corresponding to the template image, wherein the first target depth map and the initial image to be detected, as well as the second target depth map and the initial template image have the same image size, and in the first target depth map and the second target depth map, each pixel value represents the pixel-level depth estimation value, and the depth estimation value is the distance between each pixel in the initial image to be detected and the monitoring device, and the distance between each pixel in the initial template image and the monitoring device.
[0116] In an optional embodiment, the terminal may not crop the image to be detected and the template image after obtaining the image to be detected and the template image corresponding to the image to be detected, that is, after step 102, the terminal performs image analysis processing on the image to be detected and the template image according to the depth estimation model and the normal vector estimation model to obtain a first normal vector map and a second normal vector map.
[0117] Step 404 : performing normal vector calculation on the first target depth map and the second target depth map based on the normal vector estimation model to obtain a first normal vector map and a second normal vector map.
[0118] In an embodiment of the present application, the terminal inputs the first target depth map and the second target depth map into the normal vector estimation model respectively, and first calculates the gradient of the depth information based on the depth information in the first target depth map and the second target depth map, and obtains the normal vector based on the vertical direction of the gradient, and then obtains the first target depth map corresponding to the image to be detected and the second target depth map corresponding to the template image.
[0119] In this embodiment, the depth information and normal vector information of the image to be detected can be obtained through the depth estimation model and normal vector calculation, and multi-dimensional information data can be obtained to provide basic data for subsequent image detection of the area occupied by the object.
[0120] In an exemplary embodiment, after the depth estimation model is used to perform depth estimation on the initial image to be detected and the initial template image, the initial depth map needs to be preprocessed, such as Figure 5 As shown, step 402 includes steps 502 to 510. Among them:
[0121] Step 502 : performing depth estimation on the initial image to be detected and the initial template image according to a depth estimation model to obtain a first initial depth map and a second initial depth map.
[0122] In an embodiment of the present application, the terminal performs depth estimation on the initial image to be detected and the initial template image according to the same principle as the depth estimation model in step 402, and obtains a first initial depth map corresponding to the initial image to be detected and a second initial depth map corresponding to the initial template image. The calculation process of the depth estimation model will not be repeated in this example.
[0123] Step 504 : performing a mask operation on the image to be detected and the template image based on the preset calibration area to obtain a first initial mask image and a second initial mask image.
[0124] In the embodiment of this application, Figure 6 As shown, based on a preset calibration region (ROI region coordinates, region of interest), the terminal uses the fillPoly function (a polygon-filling function) of OpenCV (an open-source computer vision library) to mask the image to be detected and the template image, retaining the preset calibration region and masking out the background outside the preset calibration region. This results in a first initial mask image for the image to be detected and a second initial mask image for the template image. The mask image can be binary, with the region of interest (preset calibration region) represented by white pixels (pixel value 1) and non-regions of interest represented by black pixels (pixel value 0). For example, the terminal uses the fillPoly function to set the pixel values of the background portion outside the preset calibration region to 0, converting the background portion to black to cover the background portion, while retaining the preset calibration region representing the safe area.
[0125] In an optional embodiment, the terminal may not crop the image to be detected and the template image, and use the original image to be detected and the template image to perform a mask operation, that is, before step 102, the terminal performs a mask operation on the image to be detected and the template image according to a preset calibration area to obtain a first mask image and a second mask map. On this basis, the input of the depth estimation model is also the uncropped image to be detected and the template image, and the first initial depth map and the second initial depth map output by the depth estimation model are masked according to the first mask image and the second mask map to obtain a first target depth map and a second target depth map.
[0126] Step 506 : cropping the first initial mask image and the second initial mask image according to the preset calibration area to obtain a first mask image and a second mask image.
[0127] In the embodiment of the present application, the terminal crops the first initial mask image and the second initial mask image based on the preset calibration area according to the same principle as in step 202, such as Figure 6 As shown, the terminal constructs the external matrix coordinates for cropping based on the original image to be detected, the template image and the roi area coordinates (preset calibration area). Then, the terminal crops the first initial mask image and the second initial mask image after masking with the fillPoly function according to the external matrix coordinates to obtain the first mask image and the second mask image that eliminate the background area.
[0128] Step 508 : Perform a mask operation on the first initial depth map based on the first mask map to obtain a first target depth map.
[0129] In the embodiment of this application, Figure 7 As shown, the terminal applies the first mask map to the first initial depth map. Specifically, the terminal performs an element-by-element multiplication operation on the first initial depth map and the first mask map, and the result is a new depth map, namely, the first target depth map ( Figure 7 ), wherein, in the first target depth map, only the pixels corresponding to the white area (preset calibration area, area of interest, pixel value 1) in the first mask map retain their depth values, while the black area (non-area of interest, pixel value 0) is set to zero or an invalid value.
[0130] Step 510: Perform a mask operation on the second initial depth map according to the second mask map to obtain a second target depth map.
[0131] In the embodiment of the present application, the terminal performs a mask operation on the second initial depth map corresponding to the initial template image according to the second mask map in the same way as the first initial depth map is masked using the first mask map to obtain a second target depth map. The specific mask operation process will not be repeated in the embodiment of the present application.
[0132] In an optional embodiment, if Figure 8 As shown, after the terminal obtains the first target depth map and the second target depth map, the terminal estimates the first target depth map and the second target depth map based on the normal vector estimation model ( Figure 8 The normal vector is estimated by using the masked depth map (denoted as the masked depth map) to obtain the first normal vector map and the second normal vector map.
[0133] In this embodiment, the first target depth map and the second target depth map obtained by mask operation and pruning can further eliminate non-interest areas in the initial image to be detected and the initial template image, avoid the influence of non-interest areas on the normal vector calculation of the normal vector estimation model in subsequent processes, improve the accuracy of the first normal vector map and the second normal vector map, and thereby improve the accuracy of image detection.
[0134] In an exemplary embodiment, Figure 9 As shown, step 108 includes steps 902 to 906. Among them:
[0135] Step 902: grayscale processing is performed on the difference map to obtain a grayscale difference map.
[0136] In the embodiment of the present application, the terminal can convert the pixel values in the difference map according to the grayscale conversion formula to obtain a grayscale difference map after grayscale processing.
[0137] Step 904 : Binarize the grayscale difference map based on a preset binarization threshold to obtain a binarized difference map.
[0138] In the embodiment of the present application, the terminal compares each pixel value in the grayscale difference map with a preset binarization threshold, sets pixel values greater than the preset binarization threshold as target pixel values, where the target pixel value can be white, and sets pixel values less than or equal to the preset binarization threshold as black (non-target pixels). In this case, the target pixel value in the binarized difference map represents a significant difference between the elements contained in the image to be detected and the elements contained in the template image, that is, the pixel with the target pixel value in the binarized difference map is the outline of an occupied object.
[0139] Step 906 : Determine a detection result based on a ratio of the number of first pixels containing the target pixel value in the binarized difference image to the number of second pixels containing the target pixel value in the second mask image of the template image.
[0140] The target pixel value may be 1, indicating a white pixel, representing the number of visible pixels in the binary difference image and the number of visible pixels in the second mask image.
[0141] In the embodiment of this application, Figure 10 As shown, the terminal counts the number of first pixels of the target pixel value in the binarized difference image to obtain the number of pixels of the occupied object, that is, the area of the occupied object. It also counts the number of target pixel values in the second mask image of the template image (the number of visible pixels in the second mask image) to obtain the number of pixels of the safe passage, that is, the area of the safe passage. Furthermore, the terminal calculates the ratio of the first number of pixels to the second number of pixels to represent the proportion of the occupied object in the safe passage. Based on the relationship between this ratio and a ratio threshold, the terminal determines whether the safe passage in the image to be detected is occupied.
[0142] In this embodiment, the first number of pixels is obtained by graying and binarizing the difference image, and the detection result of the image to be detected is determined based on the ratio of the first number of pixels to the second number of pixels in the second mask image. There is no need to determine the type of occupied object, but the area ratio of the occupied object in the safe passage is directly obtained, and the influence of factors such as lighting is eliminated, which can improve the accuracy of the detection result.
[0143] In an exemplary embodiment, Figure 11 As shown, step 904 includes steps 1102 to 1106. Among them:
[0144] Step 1102 : Binarize the grayscale difference map based on a preset binarization threshold to obtain a binarized difference map.
[0145] In this embodiment of the present application, the terminal binarizes the grayscale difference map according to the same principle as in step 904 to obtain a binarized difference map. The binarization process is not further described in this example. However, the occupied objects in the image to be detected may be pedestrians or other moving objects, so further exclusion of special objects is required.
[0146] Step 1104 : Detect the target object on the initial image to be detected according to the target detection model to obtain a target object calibration frame.
[0147] In the embodiment of the present application, the target detection model can be a YOLOv8 (You Only Look Once, a target detection model) model trained for pedestrians or other special moving objects. The terminal inputs the initial image to be detected into the target detection model, and the target detection result and the target object calibration frame are output by the target detection model. The target object calibration frame can be recorded as ,in, are the coordinates of the four boundaries of the ROI region, p is the confidence level of the prediction for a certain category, and l is the predicted category within the preset calibration area. The target object calibration box represents a special object that needs to be further excluded and is not an illegally occupied object.
[0148] Step 1106 , performing a mask operation on the binary difference map based on the target object calibration frame, returning the binary values of the corresponding pixels in the target object calibration frame to zero, and obtaining a binary difference map after the mask operation.
[0149] In the embodiment of this application, Figure 12 As shown, the terminal is based on the output result of the target detection model, that is, the target object area in the binary difference map is binarized and zeroed according to the target object calibration frame, that is, the white area originally used as the occupied object in the binary difference map is excluded and converted into a black area with a pixel value of 0.
[0150] In this embodiment, the binary difference map is post-processed by the target object calibration frame output by the target detection model to exclude special objects as occupied objects, thereby avoiding the influence of special objects on the detection results and further improving the accuracy of the detection results.
[0151] In an exemplary embodiment, Figure 13 As shown, before step 102, the method further includes steps 1302 to 1304. Among them:
[0152] Step 1302 : Acquire multiple template images that do not contain occupied objects and a preset calibration area corresponding to each template image.
[0153] In an embodiment of the present application, the terminal obtains a pre-selected surveillance image that does not contain occupied objects as a template image, and obtains a pre-set preset calibration area, which represents the entire safety passage area when there is no occupied object in the surveillance image.
[0154] Step 1304 : constructing a template library according to the preset calibration area, the template image, and the correspondence between the template image and the preset calibration area.
[0155] The template library is used to determine the template image corresponding to the image to be detected and the preset calibration area corresponding to the image to be detected.
[0156] In an embodiment of the present application, the terminal constructs a correspondence between a preset calibration area and a template image according to the number of the monitoring device, stores the template image and the preset calibration area corresponding to the template image in a database, and obtains a template library.
[0157] In an optional embodiment, after completing the construction of the template library, the terminal can perform cropping, masking and normal vector estimation on the template image according to the same logic as in the above embodiment to obtain the second mask map and second normal vector map corresponding to each template image, and store the second mask map and second normal vector map in the template library. When the template library is subsequently called, the second normal vector map of the template image is directly used to calculate the pixel difference to obtain a difference map, and the ratio between the first number of pixels and the second number of pixels is calculated based on the second mask map, thereby improving the computational efficiency of the image detection method during application.
[0158] In this embodiment, by pre-building a template library, a template image data basis is provided for image detection, and image detection is performed based on the template image corresponding to the image to be detected. This can adapt to the detection needs in different scenarios, cover a wider range of situations, and improve the applicability of the image detection method.
[0159] In an exemplary embodiment, an example of an image detection system using an image detection method is provided, such as Figure 14 As shown, the image detection system includes: a cropping module, a mask module, a depth estimation module, a normal vector estimation module and a post-processing module; wherein:
[0160] A cropping module, used to obtain an image to be detected and a template image corresponding to the image to be detected;
[0161] The image to be detected and the template image are cropped according to the preset calibration area to obtain the initial image to be detected and the initial template image.
[0162] A mask module, configured to perform a mask operation on the image to be detected and the template image based on a preset calibration area to obtain a first initial mask image and a second initial mask image;
[0163] The first initial mask image and the second initial mask image are cropped according to the preset calibration area to obtain a first mask image and a second mask image.
[0164] The depth estimation module is used to perform depth estimation on the initial image to be detected and the initial template image according to the depth estimation model to obtain a first initial depth map and a second initial depth map.
[0165] A mask operation is performed on the first initial depth map based on the first mask map to obtain a first target depth map, and a mask operation is performed on the second initial depth map based on the second mask map to obtain a second target depth map.
[0166] The normal vector estimation module is used to calculate the normal vectors of the first target depth map and the second target depth map based on the normal vector estimation model to obtain a first normal vector map and a second normal vector map.
[0167] The post-processing module is used to calculate the pixel difference based on the first normal vector map and the second normal vector map to obtain a difference map;
[0168] Performing grayscale processing on the difference map to obtain a grayscale difference map, and binarizing the grayscale difference map based on a preset binarization threshold to obtain a binarized difference map;
[0169] Detect the target object in the initial image to be detected according to the target detection model to obtain the target object calibration frame;
[0170] Performing a mask operation on the binary difference map based on the target object calibration frame, returning the binary values of the corresponding pixels in the target object calibration frame to zero, and obtaining a binary difference map after the mask operation;
[0171] The detection result is determined according to a ratio of a first number of pixels containing the target pixel value in the binary difference image after the mask operation to a second number of pixels containing the target pixel value in the second mask image of the template image.
[0172] It should be understood that, although the various steps in the flowcharts involved in the various embodiments described above are displayed in sequence according to the instructions of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the flowcharts involved in the various embodiments described above can include multiple steps or multiple stages, and these steps or stages are not necessarily executed and completed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of steps or stages in other steps.
[0173] Based on the same inventive concept, the present application also provides an image detection device for implementing the aforementioned image detection method. The solution provided by this device is similar to the solution described in the aforementioned method. Therefore, the specific limitations in one or more of the following embodiments of the image detection device can be found in the above-mentioned limitations on the image detection method and will not be further elaborated here.
[0174] In an exemplary embodiment, Figure 15 As shown, an image detection device 1500 is provided, comprising: a first acquisition module 1501, a normal vector estimation module 1502, a difference map calculation 1503 and a determination module 1504, wherein:
[0175] The first acquisition module 1501 is used to obtain the image to be detected and the template image corresponding to the image to be detected; the template image is a standard image used for comparison and detection;
[0176] A normal vector estimation module 1502 is configured to perform image analysis processing on the image to be detected and the template image according to the depth estimation model and the normal vector estimation model to obtain a first normal vector map and a second normal vector map;
[0177] A difference map calculation module 1503 is configured to calculate pixel differences based on the first normal vector map and the second normal vector map to obtain a difference map; the difference map is used to represent the differences between the elements contained in the image to be detected and the template image;
[0178] The determination module 1504 is configured to determine a detection result based on the difference map.
[0179] In one embodiment, the normal vector estimation module 1502 is specifically configured to crop the image to be detected and the template image according to a preset calibration area to obtain an initial image to be detected and an initial template image;
[0180] Image analysis processing is performed on the initial image to be detected and the initial template image according to the depth estimation model and the normal vector estimation model to obtain a first normal vector map and a second normal vector map.
[0181] In one embodiment, the normal vector estimation module 1502 is specifically configured to perform depth estimation on the initial image to be detected and the initial template image according to the depth estimation model to obtain a first target depth map and a second target depth map;
[0182] Normal vectors are calculated for the first target depth map and the second target depth map based on a normal vector estimation model to obtain a first normal vector map and a second normal vector map.
[0183] In one embodiment, the normal vector estimation module 1502 is specifically configured to perform depth estimation on the initial image to be detected and the initial template image according to the depth estimation model to obtain a first initial depth map and a second initial depth map;
[0184] Performing a mask operation on the image to be detected and the template image based on the preset calibration area to obtain a first initial mask image and a second initial mask image;
[0185] Cropping the first initial mask image and the second initial mask image according to a preset calibration area to obtain a first mask image and a second mask image;
[0186] Performing a mask operation on the first initial depth map based on the first mask map to obtain a first target depth map;
[0187] A mask operation is performed on the second initial depth map according to the second mask map to obtain a second target depth map.
[0188] In one embodiment, the determining module 1504 is specifically configured to perform grayscale processing on the difference map to obtain a grayscale difference map;
[0189] Binarize the grayscale difference map based on a preset binarization threshold to obtain a binarized difference map;
[0190] The detection result is determined according to a ratio of a first number of pixels including the target pixel value in the binarized difference image to a second number of pixels including the target pixel value in the second mask image of the template image.
[0191] In one embodiment, the determining module 1504 is specifically configured to perform binarization processing on the grayscale difference map based on a preset binarization threshold to obtain a binarized difference map;
[0192] Detect the target object in the initial image to be detected according to the target detection model to obtain the target object calibration frame;
[0193] A mask operation is performed on the binary difference map based on the target object calibration frame, and the binary values of the corresponding pixels in the target object calibration frame are reset to zero to obtain the binary difference map after the mask operation.
[0194] In one embodiment, the apparatus 1500 further includes:
[0195] A second acquisition module is used to acquire a plurality of template images that do not contain occupied objects and a preset calibration area corresponding to each template image;
[0196] The construction module is used to construct a template library based on the preset calibration area, the template image and the correspondence between the template image and the preset calibration area; the template library is used to determine the template image corresponding to the image to be detected and the preset calibration area corresponding to the image to be detected.
[0197] Each module in the above-mentioned image detection device can be implemented in whole or in part through software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in the computer device in the form of software, so that the processor can call and execute the corresponding operations of each module.
[0198] In an exemplary embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as shown in FIG. Figure 16As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, abbreviated as I / O) and a communication interface. The processor, memory and input / output interface are connected via a system bus, and the communication interface is connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium. The database of the computer device is used to store images to be detected and template images. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, an image detection method is implemented.
[0199] Those skilled in the art will understand that Figure 16 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.
[0200] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:
[0201] Obtaining the image to be detected and the template image corresponding to the image to be detected; the template image is a standard image used for comparison and detection;
[0202] Performing image analysis processing on the image to be detected and the template image according to the depth estimation model and the normal vector estimation model to obtain a first normal vector map and a second normal vector map;
[0203] Calculating pixel differences based on the first normal vector map and the second normal vector map to obtain a difference map; the difference map is used to represent the differences between the elements contained in the image to be detected and the template image;
[0204] The detection result is determined based on the difference map.
[0205] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0206] The image to be detected and the template image are cropped according to the preset calibration area to obtain the initial image to be detected and the initial template image;
[0207] Image analysis processing is performed on the initial image to be detected and the initial template image according to the depth estimation model and the normal vector estimation model to obtain a first normal vector map and a second normal vector map.
[0208] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0209] Performing depth estimation on the initial image to be detected and the initial template image according to the depth estimation model to obtain a first target depth map and a second target depth map;
[0210] Normal vectors are calculated for the first target depth map and the second target depth map based on a normal vector estimation model to obtain a first normal vector map and a second normal vector map.
[0211] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0212] Performing depth estimation on the initial image to be detected and the initial template image according to the depth estimation model to obtain a first initial depth map and a second initial depth map;
[0213] Performing a mask operation on the image to be detected and the template image based on the preset calibration area to obtain a first initial mask image and a second initial mask image;
[0214] Cropping the first initial mask image and the second initial mask image according to a preset calibration area to obtain a first mask image and a second mask image;
[0215] Performing a mask operation on the first initial depth map based on the first mask map to obtain a first target depth map;
[0216] A mask operation is performed on the second initial depth map according to the second mask map to obtain a second target depth map.
[0217] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0218] Perform grayscale processing on the difference map to obtain a grayscale difference map;
[0219] Binarize the grayscale difference map based on a preset binarization threshold to obtain a binarized difference map;
[0220] The detection result is determined according to a ratio of a first number of pixels including the target pixel value in the binarized difference image to a second number of pixels including the target pixel value in the second mask image of the template image.
[0221] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0222] Binarize the grayscale difference map based on a preset binarization threshold to obtain a binarized difference map;
[0223] Detect the target object in the initial image to be detected according to the target detection model to obtain the target object calibration frame;
[0224] A mask operation is performed on the binary difference map based on the target object calibration frame, and the binary values of the corresponding pixels in the target object calibration frame are reset to zero to obtain the binary difference map after the mask operation.
[0225] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0226] Acquire multiple template images without occupied objects and a preset calibration area corresponding to each template image;
[0227] A template library is constructed based on the preset calibration area, the template image, and the correspondence between the template image and the preset calibration area; the template library is used to determine the template image corresponding to the image to be detected and the preset calibration area corresponding to the image to be detected.
[0228] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.
[0229] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.
[0230] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.
[0231] Those skilled in the art will understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. In particular, any reference to memory, database, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The databases involved in the various embodiments provided herein may include at least one of a relational database and a non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the various embodiments provided herein may be, but are not limited to, general-purpose processors, central processing units (CPUs), graphics processing units (GPUs), digital signal processors (DSPs), programmable logic devices (PLDs), quantum computing-based data processing logic devices, artificial intelligence (AI) processors, and the like.
[0232] The technical features of the above embodiments can be combined arbitrarily. In order to make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0233] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present application. It should be noted that a person of ordinary skill in the art may make various modifications and improvements without departing from the spirit of the present application, and these modifications and improvements fall within the scope of protection of the present application. Therefore, the scope of protection of the present application shall be determined by the appended claims.
Claims
1. An image detection method, characterized in that: The method comprises: Obtaining an image to be detected and a template image corresponding to the image to be detected; the template image is a standard image used for comparison and detection; Performing image analysis processing on the image to be detected and the template image according to a depth estimation model and a normal vector estimation model to obtain a first normal vector map and a second normal vector map; Calculating pixel differences based on the first normal vector map and the second normal vector map to obtain a difference map; the difference map is used to represent the difference between the elements contained in the image to be detected and the template image; determining a detection result based on the difference map; Performing image analysis processing on the image to be detected and the template image according to the depth estimation model and the normal vector estimation model to obtain a first normal vector map and a second normal vector map, including: Performing depth estimation on the image to be detected and the template image according to a depth estimation model to obtain a first initial depth map and a second initial depth map; Performing a mask operation on the image to be detected and the template image based on a preset calibration area to obtain a first initial mask image and a second initial mask image; Cropping the first initial mask image and the second initial mask image according to the preset calibration area to obtain a first mask image and a second mask image; performing a mask operation on the first initial depth map based on the first mask map to obtain a first target depth map; performing a mask operation on the second initial depth map according to the second mask map to obtain a second target depth map; Performing normal vector calculation on the first target depth map and the second target depth map based on a normal vector estimation model to obtain a first normal vector map and a second normal vector map; Determining the detection result based on the difference map includes: Performing grayscale processing on the difference map to obtain a grayscale difference map; Binarizing the grayscale difference map based on a preset binarization threshold to obtain a binarized difference map; Detect the target object in the initial image to be detected according to the target detection model to obtain the target object calibration frame; performing a mask operation on the binary difference map based on the target object calibration frame, returning the binary values of corresponding pixels in the target object calibration frame to zero, and obtaining a binary difference map after the mask operation; A detection result is determined according to a ratio of a first number of pixels containing a target pixel value in the binarized difference map to a second number of pixels containing the target pixel value in the second mask map of the template image.
2. The method according to claim 1, characterized in that The method further comprises: The image to be detected and the template image are cropped according to a preset calibration area to obtain an initial image to be detected and an initial template image.
3. The method according to claim 1, characterized in that The binarization processing is performed on the grayscale difference map based on a preset binarization threshold to obtain a binarized difference map, including: Binarizing the grayscale difference map based on a preset binarization threshold to obtain a binarized difference map; Detect the target object in the initial image to be detected according to the target detection model to obtain the target object calibration frame; A mask operation is performed on the binary difference map based on the target object calibration frame, and the binary values of corresponding pixels in the target object calibration frame are reset to zero to obtain a binary difference map after the mask operation.
4. The method according to claim 1, wherein Before obtaining the image to be detected and the template image corresponding to the image to be detected, the method further includes: Acquire multiple template images that do not contain occupied objects and a preset calibration area corresponding to each of the template images; A template library is constructed according to the preset calibration area, the template image, and the correspondence between the template image and the preset calibration area; the template library is used to determine the template image corresponding to the image to be detected and the preset calibration area corresponding to the image to be detected.
5. The method according to claim 1, wherein The step of obtaining an image to be detected includes: The image to be detected is obtained by extracting frames from the surveillance video captured by the surveillance equipment; According to the serial number of the monitoring device corresponding to the image to be detected, a template image corresponding to the monitoring device is obtained from a template library.
6. The method according to claim 1, characterized in that The depth estimation model is a depth anything model, and the normal vector estimation model is a D2NT model.
7. An image detection device, characterized in that: The device comprises: A first acquisition module is used to acquire an image to be detected and a template image corresponding to the image to be detected; the template image is a standard image used for comparison detection; a normal vector estimation module, configured to perform image analysis processing on the image to be detected and the template image according to a depth estimation model and a normal vector estimation model to obtain a first normal vector map and a second normal vector map; a difference map calculation module, configured to calculate pixel differences based on the first normal vector map and the second normal vector map to obtain a difference map; the difference map is used to represent the differences between the elements contained in the image to be detected and the template image; a determination module, configured to determine a detection result based on the difference map; The normal vector estimation module is specifically used to perform depth estimation on the image to be detected and the template image according to the depth estimation model to obtain a first initial depth map and a second initial depth map; perform a mask operation on the image to be detected and the template image based on a preset calibration area to obtain a first initial mask map and a second initial mask map; crop the first initial mask map and the second initial mask map according to the preset calibration area to obtain a first mask map and a second mask map; perform a mask operation on the first initial depth map based on the first mask map to obtain a first target depth map; perform a mask operation on the second initial depth map based on the second mask map to obtain a second target depth map; perform a normal vector calculation on the first target depth map and the second target depth map based on the normal vector estimation model to obtain a first normal vector map and a second normal vector map; The determination module is specifically used to perform grayscale processing on the difference map to obtain a grayscale difference map; perform binarization processing on the grayscale difference map based on a preset binarization threshold to obtain a binarized difference map; detect the target object on the initial image to be detected according to the target detection model to obtain a target object calibration frame; perform a mask operation on the binarized difference map based on the target object calibration frame, reset the binarized values of the corresponding pixels in the target object calibration frame to zero, and obtain a binarized difference map after the mask operation; determine the detection result according to the ratio of the number of first pixels containing the target pixel value in the binarized difference map to the number of second pixels containing the target pixel value in the second mask map of the template image.
8. The device according to claim 7, characterized in that The device further comprises: The cropping module is used to crop the image to be detected and the template image according to a preset calibration area to obtain an initial image to be detected and an initial template image.
9. The device according to claim 7, characterized in that The device further comprises: A second acquisition module is used to acquire a plurality of template images that do not contain occupied objects and a preset calibration area corresponding to each of the template images; A construction module is used to construct a template library based on the preset calibration area, the template image, and the correspondence between the template image and the preset calibration area; the template library is used to determine the template image corresponding to the image to be detected and the preset calibration area corresponding to the image to be detected.
10. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
Method and device for identifying targets on basis of geometric features of three-dimensional curved surfaces of depth images
CN103544492A
Depth map optimization method and device, electronic device and storage medium
CN113850858A