Package damage detection method, device, electronic equipment and storage medium

By identifying and clustering damaged areas in package area images, combined with deep learning models and clustering algorithms, the problem of low accuracy of package damage detection in the existing technology is solved, and higher detection accuracy and precision are achieved.

CN114663340BActive Publication Date: 2024-08-23SF TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202011543137.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-22
Publication Date
2024-08-23
Estimated Expiration
2040-12-22

Smart Images

  • Figure CN114663340B
    Figure CN114663340B
Patent Text Reader

Abstract

The present application provides a package damage detection method, device, electronic device and storage medium, the package damage detection method comprising: obtaining a package area image, wherein the package area image contains package features; identifying a first package damage area in the package area image; when at least two first package damage areas are identified on the package area image, clustering the at least two first package damage areas to obtain at least one second package damage area; and determining the damage state of the package in the package area image based on the at least one second package damage area. The present application can connect damaged areas that are close to each other into a whole area, avoiding the problem that a pure target detection method identifies a single damaged area as multiple damaged areas and that the multiple damaged areas are too dispersed, resulting in a reduced accuracy rate of package damage detection, and can improve the accuracy rate of package damage detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of logistics technology, and specifically to a method, device, electronic device and storage medium for detecting damaged packages. Background Art

[0002] Damaged parts detection has always been an important but difficult problem. Solving the problem of damaged outer packaging detection will greatly improve the quality of logistics. Traditional target detection methods use traditional image processing methods, such as feature extraction, edge detection, feature point pairing, and traditional machine learning methods, but they have great disadvantages for damaged parts detection: First, there are many damaged patterns, countless, and difficult to identify. Second, the amount of damaged data is very small, and it is difficult to train using machine learning methods.

[0003] Deep learning has developed rapidly in recent years, and it is easy to extract features and has good generalization performance. However, pure object detection is relatively rough in identifying damaged areas and cannot evaluate the damage from the overall picture. For example, when using object detection methods for damage detection, dozens of smaller damaged areas may be detected in one picture, making it difficult to evaluate the overall situation of the picture. In addition, one damaged area may be identified as multiple damaged areas by the object detection method, resulting in inaccurate results.

[0004] That is, the accuracy of package damage detection in the prior art is low. Summary of the invention

[0005] The present application aims to provide a package damage detection method, device, electronic device and storage medium, aiming to solve the problem of low accuracy of package damage detection in the prior art.

[0006] In one aspect, the present application provides a method for detecting a damaged package, the method comprising:

[0007] Acquire a package area image, wherein the package area image contains package features;

[0008] identifying a first package damaged region in the package region image;

[0009] When at least two first package damaged regions are identified on the package region image, clustering the at least two first package damaged regions to obtain at least one second package damaged region;

[0010] A damage state of the package in the package area image is determined based on the at least one second package damage area.

[0011] The step of clustering the at least two first package damaged regions to obtain at least one second package damaged region includes:

[0012] Obtaining at least two minimum circumscribed circles of damaged areas corresponding to the at least two first package damaged areas;

[0013] Obtaining the center position and radius length of the minimum circumscribed circle of the at least two damaged areas;

[0014] The at least two minimum circumscribed circles of the at least two damaged areas are clustered based on the center positions and radius lengths of the minimum circumscribed circles of the at least two damaged areas to obtain the at least one second package damaged area.

[0015] Wherein, determining the damage state of the package in the package area image based on the at least one second package damage area includes:

[0016] Calculate the area ratio of each damaged area of ​​the second package in the package area image to obtain the calculated area ratio of each damaged area of ​​the second package;

[0017] Based on the calculated area ratio and the preset area level correspondence relationship, the damaged areas of each second package are divided into damage levels to obtain the damage levels of the damaged areas of each second package;

[0018] Counting the number of damaged areas of the second packages at each damage level based on the damage levels of the damaged areas of the second packages;

[0019] Based on the number of damaged regions of the second parcel at each damage level in the parcel region image, a damage state of the parcel in the parcel region image is determined.

[0020] The step of identifying the first package damaged area in the package area image includes:

[0021] Call the trained damaged package segmentation model;

[0022] The package area image is instance segmented based on the damaged package segmentation model to obtain a first package damaged area in the package area image.

[0023] Before calling the trained damaged package segmentation model, the method further includes:

[0024] Acquire a damaged package image training set, wherein the images in the damaged package image training set are images of package areas with damaged areas marked;

[0025] Training a preset image segmentation network model based on the damaged package image training set to obtain a damaged package segmentation model;

[0026] The damaged package segmentation model is stored.

[0027] Wherein, the method for detecting package damage also includes:

[0028] When no first package damaged area is identified on the package area image, determining that the package in the package area image is not damaged,

[0029] And / or, when it is identified that there is only one first package damaged area on the package area image, the damage state of the package in the package area image is determined based on the area ratio of the first package damaged area on the package area image.

[0030] The step of clustering the at least two minimum circumscribed circles of the at least two damaged areas based on the center positions and radius lengths of the minimum circumscribed circles of the at least two damaged areas to obtain the at least one second package damaged area includes:

[0031] Acquire a preset damaged area minimum circumscribed circle sample set, wherein the damaged area minimum circumscribed circle sample set includes a plurality of classified minimum circumscribed circles;

[0032] Determine the minimum circumscribed circle with the largest radius among the at least two minimum circumscribed circles of the damaged areas as the target minimum circumscribed circle;

[0033] Taking the center position and radius length of the target minimum circumscribed circle as vectors for calculating the Euclidean distance, the Euclidean distance between the target minimum circumscribed circle and each of the classified minimum circumscribed circles is calculated;

[0034] sorting the multiple classified minimum circumscribed circles from large to small according to the Euclidean distance, and obtaining a preset number of classified minimum circumscribed circles with top Euclidean distance sorting;

[0035] Determine the category with the highest appearance frequency among the preset number of classified minimum circumscribed circles as the category of the target minimum circumscribed circle;

[0036] After obtaining the categories of the minimum circumscribed circles of the damaged areas, the minimum circumscribed circles of the damaged areas of the same category are determined as the damaged area of ​​the second package as a whole.

[0037] In one aspect, the present application provides a package damage detection device, the package damage detection device comprising:

[0038] An acquisition unit, used for acquiring a package area image, wherein the package area image contains package features;

[0039] an identification unit, configured to identify a first package damaged region in the package region image;

[0040] a clustering unit, configured to cluster the at least two first package damaged regions to obtain at least one second package damaged region when at least two first package damaged regions are identified on the package region image;

[0041] A determining unit is used to determine a damage state of the package in the package area image based on the at least one second package damage area.

[0042] The clustering unit is further used to obtain at least two minimum circumscribed circles of damaged areas corresponding to the at least two first package damaged areas;

[0043] Obtaining the center position and radius length of the minimum circumscribed circle of the at least two damaged areas;

[0044] The at least two minimum circumscribed circles of the at least two damaged areas are clustered based on the center positions and radius lengths of the minimum circumscribed circles of the at least two damaged areas to obtain the at least one second package damaged area.

[0045] The determining unit is further used to calculate the area ratio of each damaged area of ​​the second package in the package area image to obtain the calculated area ratio of each damaged area of ​​the second package;

[0046] Based on the calculated area ratio and the preset area level correspondence relationship, the damaged areas of each second package are divided into damage levels to obtain the damage levels of the damaged areas of each second package;

[0047] Counting the number of damaged areas of the second packages at each damage level based on the damage levels of the damaged areas of the second packages;

[0048] Based on the number of damaged regions of the second parcel at each damage level in the parcel region image, a damage state of the parcel in the parcel region image is determined.

[0049] The recognition unit is further used to call a trained damaged package segmentation model;

[0050] The package area image is instance segmented based on the damaged package segmentation model to obtain a first package damaged area in the package area image.

[0051] The acquisition unit is further used to acquire a damaged package image training set, wherein the images in the damaged package image training set are package area images with damaged areas marked;

[0052] Training a preset image segmentation network model based on the damaged package image training set to obtain a damaged package segmentation model;

[0053] The damaged package segmentation model is stored.

[0054] The determining unit is further configured to determine that the package in the package area image is not damaged when no first package damaged area is identified on the package area image.

[0055] And / or, when it is identified that there is only one first package damaged area on the package area image, the damage state of the package in the package area image is determined based on the area ratio of the first package damaged area on the package area image.

[0056] The clustering unit is further used to obtain a preset minimum circumscribed circle sample set of the damaged area, wherein the minimum circumscribed circle sample set of the damaged area includes a plurality of classified minimum circumscribed circles;

[0057] Determine the minimum circumscribed circle with the largest radius among the at least two minimum circumscribed circles of the damaged areas as the target minimum circumscribed circle;

[0058] Taking the center position and radius length of the target minimum circumscribed circle as vectors for calculating the Euclidean distance, the Euclidean distance between the target minimum circumscribed circle and each of the classified minimum circumscribed circles is calculated;

[0059] sorting the multiple classified minimum circumscribed circles from large to small according to the Euclidean distance, and obtaining a preset number of classified minimum circumscribed circles with top Euclidean distance sorting;

[0060] Determine the category with the highest appearance frequency among the preset number of classified minimum circumscribed circles as the category of the target minimum circumscribed circle;

[0061] After obtaining the categories of the minimum circumscribed circles of the damaged areas, the minimum circumscribed circles of the damaged areas of the same category are determined as the damaged area of ​​the second package as a whole.

[0062] In one aspect, the present application further provides an electronic device, the electronic device comprising:

[0063] one or more processors;

[0064] Memory; and

[0065] One or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the processor to implement the package damage detection method described in any one of the first aspects.

[0066] On the one hand, the present application also provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program is loaded by a processor to execute the steps in the method for detecting damaged packages as described in any one of the first aspects.

[0067] The present application provides a method for detecting a damaged package. After acquiring a package area image, firstly, a first damaged package area in the package area image is identified. When at least two first damaged package areas are identified on the package area image, it indicates that the damaged areas on the package are relatively scattered. At this time, the at least two first damaged package areas are clustered to obtain at least one second damaged package area. The second damaged package area is a clustered damaged area, and damaged areas that are closer to each other can be connected into a whole area. This avoids the problem that a pure target detection method identifies a single damaged area as multiple damaged areas and that the multiple damaged areas are too scattered, resulting in a reduced accuracy rate of package damaged detection. This can improve the accuracy rate of package damaged detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0068] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0069] Figure 1 A schematic diagram of a scenario of a package damage detection system provided in an embodiment of the present application;

[0070] Figure 2 It is a schematic diagram of a flow chart of an embodiment of a method for detecting damaged packages provided in an embodiment of the present application;

[0071] Figure 3 1 is a schematic diagram of the structure of an embodiment of a device for detecting damaged packages provided in an embodiment of the present application;

[0072] Figure 4 It is a schematic diagram of the structure of an embodiment of an electronic device provided in the embodiments of the present application. DETAILED DESCRIPTION

[0073] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.

[0074] In the description of the present application, it should be understood that the terms "center", "longitudinal", "lateral", "length", "width", "thickness", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside" and the like indicate positions or positional relationships based on the positions or positional relationships shown in the accompanying drawings, which are only for the convenience of describing the present application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present application. In addition, the terms "first" and "second" are used only for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more features. In the description of the present application, the meaning of "multiple" is two or more, unless otherwise clearly and specifically defined.

[0075] In this application, the word "exemplary" is used to mean "used as an example, illustration, or description." Any embodiment described in this application as "exemplary" is not necessarily to be construed as being preferred or advantageous over other embodiments. The following description is given to enable any technician in the field to implement and use the present application. In the following description, details are listed for the purpose of explanation. It should be understood that a person of ordinary skill in the art can recognize that the present application can be implemented without using these specific details. In other instances, well-known structures and processes will not be elaborated in detail to avoid obscuring the description of the present application with unnecessary details. Therefore, the present application is not intended to be limited to the embodiments shown, but is consistent with the widest scope consistent with the principles and features disclosed in the present application.

[0076] It should be noted that since the method of the embodiment of the present application is executed in an electronic device, the processing objects of each electronic device exist in the form of data or information. For example, time is actually time information. It can be understood that if size, quantity, position, etc. are mentioned in subsequent embodiments, they are all corresponding data for processing by the electronic device. The details will not be elaborated here.

[0077] The embodiments of the present application provide a method, device, electronic device, and storage medium for detecting damaged packages, which are described in detail below.

[0078] See also Figure 1 , Figure 1 Schematic diagram of a scenario of a package damage detection system provided in an embodiment of the present application. The package damage detection system may include an electronic device 100, in which a package damage detection device is integrated. Figure 1 Electronic devices in.

[0079] Furthermore, the package damage detection system is connected to multiple camera devices installed at the location where the packages are located, so as to obtain information sent by multiple camera devices over the network. The video, image, timestamp and other information collected by the camera devices are transmitted back to the package damage detection system in the form of messages. Each of the multiple camera devices has a number, and the package damage detection system monitors the location of each package according to the number of the camera device.

[0080] In the embodiment of the present application, the electronic device 100 may be an independent server, or a server network or server cluster composed of servers. For example, the electronic device 100 described in the embodiment of the present application includes but is not limited to a computer, a network host, a single network server, a plurality of network server sets or a cloud server composed of a plurality of servers. The cloud server is composed of a large number of computers or network servers based on cloud computing.

[0081] Those skilled in the art will understand that Figure 1 The application environment shown in the figure is only one application scenario of the present application solution and does not constitute a limitation on the application scenario of the present application solution. Other application environments may also include Figure 1 More or fewer electronic devices as shown in, e.g. Figure 1 Only one electronic device is shown. It can be understood that the package damage detection system can also include one or more other servers, which are not limited here.

[0082] In addition, if Figure 1 As shown, the package damage detection system may further include a memory 200 for storing data.

[0083] It should be noted that Figure 1 The scenario diagram of the damaged package detection system shown is only an example. The damaged package detection system and scenario described in the embodiment of the present application are intended to more clearly illustrate the technical solution of the embodiment of the present application, and do not constitute a limitation on the technical solution provided in the embodiment of the present application. It is known to those skilled in the art that with the evolution of the damaged package detection system and the emergence of new business scenarios, the technical solution provided in the embodiment of the present application is also applicable to similar technical problems.

[0084] First, a method for detecting a damaged package is provided in an embodiment of the present application. The execution subject of the method for detecting a damaged package is a device for detecting a damaged package. The device for detecting a damaged package is applied to an electronic device. The method for detecting a damaged package includes:

[0085] Acquire a package area image, wherein the package area image contains package features;

[0086] identifying a first package damaged region in the package region image;

[0087] When at least two first package damaged regions are identified on the package region image, clustering the at least two first package damaged regions to obtain at least one second package damaged region;

[0088] A damage state of the package in the package area image is determined based on at least one second package damage area.

[0089] See also Figure 2 , Figure 2 FIG. 1 is a flow chart of an embodiment of a method for detecting damaged packages provided in an embodiment of the present application. Figure 2 As shown, the package damage detection method includes:

[0090] S201. Acquire a package area image, wherein the package area image contains package features.

[0091] In the embodiment of the present application, the package area image refers to the image of the area where the package is located.

[0092] In a specific embodiment, a package image is obtained by photographing a location where the package is located; and package detection is performed on the package image to obtain a package area image. The package area image contains package features. The package image refers to an image containing the package obtained by photographing the location where the package is located using a camera or other photographing device installed at the location where the package is located. The location where the package is located may be a package sorting location, a package unloading location, a package loading location, a package packaging location, etc. For example, the location where the package is located is a package sorting location, and the package image is an image of the package moving on a sorting conveyor belt. The installation position of the photographing device is adjusted to ensure that the photographing device can capture the package.

[0093] Specifically, the trained package detection network model is used to perform package detection on the package image to obtain the package area image. The package detection network model can be obtained by training the preset image segmentation network model using the package image training set. Preferably, the preset image segmentation network model is MaskRCNN. The package detection network model is used to perform package detection on the package image to obtain multiple package masks on the package image, and the multiple package masks are respectively determined as package area images. Multiple package area images can be detected in sequence, or multiple package area images can be detected independently at the same time.

[0094] The detection process of MaskRCNN is as follows:

[0095] First, input an image you want to process, and then perform the corresponding preprocessing operations, or the preprocessed image; then, input it into a pre-trained neural network (ResNet, etc.) to obtain the corresponding feature map; then, set a predetermined number of ROIs for each point in the feature map to obtain multiple candidate ROIs; then, send these candidate ROIs to the RPN network for binary classification (foreground or background) and BB regression, and filter out some candidate ROIs; then, perform ROIAlign operation on these remaining ROIs (that is, first match the pixels of the original image and the feature map, and then match the feature map with the fixed feature); finally, classify these ROIs (N category classification), BB regression and mask (MASK) generation (FCN operation is performed in each ROI).

[0096] Of course, in other embodiments, the preset image segmentation network model may also be YOLACT, Faster-RCNN, etc., which can be selected according to the specific situation.

[0097] Furthermore, a package video obtained by shooting the location of the package is obtained, and the key frames in the package video are extracted after decoding the package video as the package image. A frame is a single image picture of the smallest unit in animation, which is equivalent to each frame of a film. On the timeline of the animation software, a frame is represented as a frame or a mark. A key frame is equivalent to the original painting in a two-dimensional animation. It refers to the frame where the key action of the character or object in motion or change is located. The animation between key frames can be created by software, which is called a transition frame or an intermediate frame.

[0098] Of course, in other embodiments, the photographing frequency of the photographing device may also be set to obtain the package image according to the photographing frequency. For example, the photographing frequency may be once every 0.5 seconds, once every 0.2 seconds, etc., which is determined according to actual conditions.

[0099] S202: Identify a first package damaged area in the package area image.

[0100] In the embodiment of the present application, a damaged package segmentation model is called; and instance segmentation is performed on the package area image based on the damaged package segmentation model to obtain a first package damaged area in the package area image.

[0101] Specifically, a damaged package image training set is obtained, wherein the images in the damaged package image training set are images of package areas with damaged areas marked. For example, the marked classes in the package area images in the damaged package image training set are divided into two categories: class 0 - damaged; class 1 - not damaged. A preset image segmentation network model is trained based on the damaged package image training set to obtain a damaged package segmentation model; and the damaged package segmentation model is stored. That is, the damaged package segmentation model is pre-trained and can be called when used.

[0102] Preferably, the preset image segmentation network model is MaskRCNN. Damage detection is performed on the package area image through the damaged package segmentation model to obtain multiple damage masks on the package area image, and the damage mask is determined as the first package damage area.

[0103] S203: When it is identified that there are at least two first package damaged regions on the package region image, cluster the at least two first package damaged regions to obtain at least one second package damaged region.

[0104] In the embodiment of the present application, identifying the first package damaged area in the package area image may have three results:

[0105] (1) There is no first package damaged area on the package area image. When there is no first package damaged area on the package area image, it can be directly determined that the package in the package area image is not damaged.

[0106] (2) There is only one first package damaged area on the package area image. When it is identified that there is only one first package damaged area on the package area image, clustering is not required, and the damage state of the package in the package area image is directly determined based on the area ratio of the first package damaged area on the package area image.

[0107] (3) There are at least two first package damaged regions on the package region image. When it is identified that there are at least two first package damaged regions on the package region image, the at least two first package damaged regions are clustered to obtain at least one second package damaged region.

[0108] In the embodiment of the present application, when at least two first package damaged regions are identified on the package region image, clustering the at least two first package damaged regions to obtain at least one second package damaged region may include:

[0109] (1) Obtain at least two minimum circumscribed circles of damaged areas corresponding to at least two damaged areas of the first packages.

[0110] Among them, the minimum circumscribed circle of the damaged area is the minimum circle surrounding the damaged area of ​​the first package. For example, if the damaged area of ​​the first package is a triangle, then the minimum circumscribed circle of the damaged area is a circle passing through the three vertices of the triangle.

[0111] (2) Obtain the center position and radius length of the minimum circumscribed circle of at least two damaged areas.

[0112] Specifically, a rectangular coordinate system is established on the wrapped area image, the center position of the circle is the center coordinate of the minimum circumscribed circle of the damaged area, and the center positions and radius lengths of at least two minimum circumscribed circles of the damaged area are obtained.

[0113] (3) Clustering the at least two minimum circumscribed circles of the at least two damaged areas based on the center positions and radius lengths of the minimum circumscribed circles of the at least two damaged areas to obtain at least one second package damaged area.

[0114] Preferably, the KNN method is used to cluster at least two minimum circumscribed circles of damaged areas based on the center position and radius length of the minimum circumscribed circles of at least two damaged areas. The KNN (K-Nearest Neighbor) method, also known as the K nearest neighbor method, was first proposed by Cover and Hart in 1968. It is a relatively mature method in theory and one of the simplest machine learning algorithms. The idea of ​​this method is very simple and intuitive: if most of the K most similar samples of a sample in the feature space (i.e., the nearest samples in the feature space) belong to a certain category, then the sample also belongs to this category. In the classification decision, this method only determines the category of the sample to be classified based on the category of the nearest one or several samples.

[0115] In other embodiments, other clustering algorithms such as K-Means may also be used for clustering, which can be selected according to specific circumstances.

[0116] In the embodiment of the present application, clustering the at least two minimum circumscribed circles of the at least two damaged areas based on the center positions and radius lengths of the minimum circumscribed circles of the at least two damaged areas to obtain at least one second package damaged area may include:

[0117] 1) Obtain a preset minimum circumscribed circle sample set of the damaged area, wherein the minimum circumscribed circle sample set of the damaged area includes a plurality of classified minimum circumscribed circles. The minimum circumscribed circle sample set of the damaged area is preset in advance and is marked with the center position, radius length and category of the classified circumscribed circles.

[0118] 2) The minimum circumscribed circle with the largest radius among the minimum circumscribed circles of at least two damaged areas is determined as the target minimum circumscribed circle.

[0119] 3) The center position and radius length of the target minimum circumscribed circle are used as vectors for calculating the Euclidean distance, and the Euclidean distance between the target minimum circumscribed circle and each classified minimum circumscribed circle is calculated.

[0120] Among them, the Euclidean distance, that is, the spatial distance between two points, is the L2 norm of the vector difference between the two points. The Euclidean distance between two n-dimensional vectors A(x11,x12,...,x1n) and B(x21,x22,...,x2n) is:

[0121]

[0122] Of course, the Euclidean distance can also be replaced by Manhattan distance, Chebyshev distance, etc.

[0123] 4) Sort the multiple classified minimum circumscribed circles from large to small according to the Euclidean distance, and obtain a preset number of classified minimum circumscribed circles with the highest Euclidean distance.

[0124] The preset number can be set according to the specific situation. For the KNN algorithm, the preset number is K.

[0125] 5) The category with the highest frequency among a preset number of classified minimum circumscribed circles is determined as the category of the target minimum circumscribed circle.

[0126] For example, the preset number is 10, the number belonging to category E is 2, the number belonging to category F is 5, and the number belonging to category G is 3, then the category of the target minimum circumscribed circle is category F.

[0127] Further, after the category of the target minimum circumscribed circle is obtained, the target minimum circumscribed circle is removed from at least two damaged area minimum circumscribed circles and added to a preset damaged area minimum circumscribed circle sample set.

[0128] 6) After obtaining the category of the minimum circumscribed circle of each damaged area, the minimum circumscribed circle of the damaged area of ​​the same category is determined as the damaged area of ​​the second package as a whole.

[0129] After determining the category by taking the minimum circumscribed circle of each damaged area as the target minimum circumscribed circle one by one, the minimum circumscribed circle of the damaged areas of the same category is determined as the second package damaged area as a whole. Each second package damaged area is a collection of at least one minimum circumscribed circle of damaged areas that are relatively close to each other. The damaged areas that are relatively close to each other can be connected into a whole area, thereby avoiding the problem that a pure target detection method identifies a single damaged area as multiple damaged areas and that the accuracy of package damaged detection is reduced due to the excessive dispersion of multiple damaged areas. This can improve the accuracy of package damaged detection.

[0130] The present application utilizes the minimum circumscribed circle of the damaged area for clustering, which can better overcome the disadvantages of large morphological changes and numerous patterns when locating the damaged area by the traditional target detection algorithm, and improve the accuracy of package damage detection. Of course, in other embodiments, at least two first package damage areas can also be directly clustered, and the present application does not limit this.

[0131] S204: Determine a damage state of the package in the package area image based on at least one second package damage area.

[0132] In the embodiment of the present application, determining the damage state of the package in the package area image based on at least one second package damage area may include:

[0133] (1) Calculate the area ratio of each damaged area of ​​the second package in the package area image to obtain the calculated area ratio of each damaged area of ​​the second package.

[0134] For example, the number of damaged areas of the second package is 4, and the calculated area proportions of each damaged area of ​​the second package are 6%, 4%, 3%, and 1%, respectively.

[0135] (2) Based on the calculated area ratio and the preset area level correspondence relationship, the damage level of each damaged area of ​​the second package is divided into damage levels to obtain the damage level of each damaged area of ​​the second package.

[0136] In a specific embodiment, the preset area level correspondence relationship may be:

[0137] When the calculated area ratio of the damaged area of ​​the second package is greater than the first preset threshold, the damage level of the damaged area of ​​the second package is determined to be severe damage;

[0138] When the calculated area ratio of the damaged area of ​​the second package is not greater than the first preset threshold and greater than the second preset threshold, the damage level of the damaged area of ​​the second package is determined to be general damage;

[0139] When the calculated area ratio of the damaged area of ​​the second package is not greater than the second preset threshold, it is determined that the damage level of the damaged area of ​​the second package is slightly damaged.

[0140] For example, the first preset threshold is 5%, and the second preset threshold is 2%, which can be adjusted according to actual conditions.

[0141] (3) Based on the damage level of each damaged area of ​​the second package, the number of damaged areas of the second package at each damage level is counted.

[0142] For example, the calculated area percentages of the damaged areas of the second packages are 6%, 4%, 3%, and 1% respectively. Then there is one package with severe damage, two packages with general damage, and one package with slight damage.

[0143] (4) determining a damage state of the package in the package area image based on the number of damaged areas of the second package at each damage level in the package area image,

[0144] Specifically, each damage level is determined as the target damage level in order from high to low, and it is determined whether the number of damaged areas of the second package of the target damage level is greater than the target damage level assessment number. When the number of damaged areas of the second package of the target damage level is greater than the target damage level assessment number, the target damage level is determined as the damage level of the package area image, and the damage state of the package area image is obtained. Among them, the higher the damage level, the larger the damaged area. The damage levels of severe damage level, general damage level, and slight damage level gradually decrease.

[0145] For example, the serious damage level assessment number is 1, the general damage level assessment number is 1, and the minor damage level assessment number is 1. Of course, the serious damage level assessment number, the general damage level assessment number, and the minor damage level assessment number are set according to specific circumstances. For example, the serious damage level assessment number is 2, the general damage level assessment number is 2, and the minor damage level assessment number is 2.

[0146] Statistics are taken on the package area image, the severe damage level is determined as the target damage level, and it is determined whether the number of second package damaged areas with severe damage level is greater than the severe damage level assessment number; if the number of second package damaged areas with severe damage level is greater than the severe damage level assessment number, that is, there is a second package damaged area with an area greater than 5%, and the entire package area image is recorded as severely damaged.

[0147] If the number of damaged areas of the second package with severe damage level is not greater than the assessment number of severe damage level, that is, there is no damaged area of ​​the second package with an area greater than 5%, determine whether the number of damaged areas of the second package with general damage level is greater than the assessment number of general damage level; if the number of damaged areas of the second package with general damage level is greater than the assessment number of general damage level, that is, there is a damaged area of ​​the second package with an area not greater than 5% and greater than 2%, the entire package area image is recorded as general damage.

[0148] If the number of damaged areas of the second package with general damage level is not greater than the number of assessed general damage level, that is, there is no damaged area of ​​the second package with an area less than 5% and greater than 2%, determine whether the number of damaged areas of the second package with slight damage level is greater than the number of assessed slight damage level; if the number of damaged areas of the second package with slight damage level is greater than the number of assessed slight damage level, that is, there is a damaged area of ​​the second package with an area less than 2%, the entire package area image is recorded as slightly damaged.

[0149] The present application provides a package damage detection method, device, electronic device and storage medium, the package damage detection method comprising: obtaining a package area image, wherein the package area image contains package features; identifying a first package damage area in the package area image; when at least two first package damage areas are identified on the package area image, clustering the at least two first package damage areas to obtain at least one second package damage area; and determining the damage state of the package in the package area image based on the at least one second package damage area. The present application can connect damaged areas that are close to each other into a whole area, avoiding the problem that a pure target detection method identifies a single damaged area as multiple damaged areas and that the multiple damaged areas are too dispersed, resulting in a reduced accuracy rate of package damage detection, and can improve the accuracy rate of package damage detection.

[0150] In order to better implement the package damage detection method in the embodiment of the present application, based on the package damage detection method, the embodiment of the present application also provides a package damage detection device, such as Figure 3 As shown, Figure 3 : is a schematic diagram of the structure of an embodiment of a package damage detection device provided in an embodiment of the present application, and the package damage detection device includes:

[0151] An acquisition unit 301 is used to acquire a package area image, wherein the package area image contains package features;

[0152] An identification unit 302, configured to identify a first package damaged region in the package region image;

[0153] A clustering unit 303 is used for clustering the at least two first package damaged regions to obtain at least one second package damaged region when at least two first package damaged regions are identified on the package region image;

[0154] The determining unit 304 is configured to determine a damage state of a package in the package region image based on at least one second package damage region.

[0155] The clustering unit 303 is further used to obtain at least two minimum circumscribed circles of damaged areas corresponding to at least two damaged areas of the first packages;

[0156] Obtain the center position and radius length of the minimum circumscribed circle of at least two damaged areas;

[0157] At least two minimum circumscribed circles of the at least two damaged areas are clustered based on the center positions and radius lengths of the minimum circumscribed circles of the at least two damaged areas to obtain at least one second package damaged area.

[0158] The determination unit 304 is further used to calculate the area ratio of each damaged area of ​​the second package in the package area image to obtain the calculated area ratio of each damaged area of ​​the second package;

[0159] Based on the calculated area ratio and the preset area level correspondence relationship, the damaged areas of each second package are divided into damage levels to obtain the damage level of each damaged area of ​​the second package;

[0160] Based on the damage level of each damaged area of ​​the second package, the number of damaged areas of the second package at each damage level is counted;

[0161] Based on the number of damaged regions of the second parcel at each damage level in the parcel region image, a damage state of the parcel in the parcel region image is determined.

[0162] The recognition unit 302 is also used to call the trained damaged package segmentation model;

[0163] The parcel region image is instance segmented based on the damaged parcel segmentation model to obtain a first parcel damaged region in the parcel region image.

[0164] The acquisition unit 301 is further used to acquire a damaged package image training set, wherein the images in the damaged package image training set are images of package regions with damaged regions marked;

[0165] The preset image segmentation network model is trained based on the damaged package image training set to obtain a damaged package segmentation model;

[0166] Store the damaged package segmentation model.

[0167] The determining unit 304 is further configured to determine that the parcel in the parcel area image is not damaged when no first parcel damaged area is identified in the parcel area image.

[0168] And / or, when it is identified that there is only one first package damaged area on the package area image, the damage state of the package in the package area image is determined based on the area ratio of the first package damaged area on the package area image.

[0169] The clustering unit 303 is further used to obtain a preset damaged area minimum circumscribed circle sample set, wherein the damaged area minimum circumscribed circle sample set includes a plurality of classified minimum circumscribed circles;

[0170] Determine the minimum circumscribed circle with the largest radius among the minimum circumscribed circles of at least two damaged areas as the target minimum circumscribed circle;

[0171] The center position and radius length of the target minimum circumscribed circle are used as vectors for calculating the Euclidean distance, and the Euclidean distance between the target minimum circumscribed circle and each classified minimum circumscribed circle is calculated;

[0172] Sort multiple classified minimum circumscribed circles from large to small according to the Euclidean distance, and obtain a preset number of classified minimum circumscribed circles with top Euclidean distance sorting;

[0173] Determine the category with the highest frequency among a preset number of classified minimum circumscribed circles as the category of the target minimum circumscribed circle;

[0174] After the categories of the minimum circumscribed circles of the damaged areas are obtained, the minimum circumscribed circles of the damaged areas of the same category are determined as the damaged areas of the second package as a whole.

[0175] The present application also provides an electronic device that integrates any package damage detection device provided in the present application. Figure 4 As shown, it shows a schematic diagram of the structure of the electronic device involved in the embodiment of the present application, specifically:

[0176] The electronic device may include components such as a processor 401 with one or more processing cores, a memory 402 with one or more computer-readable storage media, a power supply 403, and an input unit 404. Those skilled in the art will appreciate that the electronic device structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. Among them:

[0177] The processor 401 is the control center of the electronic device, and uses various interfaces and lines to connect various parts of the entire electronic device. By running or executing software programs and / or modules stored in the memory 402, and calling data stored in the memory 402, the processor 401 performs various functions of the electronic device and processes data, thereby monitoring the electronic device as a whole. Optionally, the processor 401 may include one or more processing cores; preferably, the processor 401 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 401.

[0178] The memory 402 can be used to store software programs and modules. The processor 401 executes various functional applications and data processing by running the software programs and modules stored in the memory 402. The memory 402 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 402 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory 402 may also include a memory controller to provide the processor 401 with access to the memory 402.

[0179] The electronic device also includes a power supply 403 for supplying power to each component. Preferably, the power supply 403 can be logically connected to the processor 401 through a power management system, so as to manage charging, discharging, power consumption and other functions through the power management system. The power supply 403 can also include one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, power status indicators and other arbitrary components.

[0180] The electronic device may further include an input unit 404, which may be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.

[0181] Although not shown, the electronic device may further include a display unit, etc., which will not be described in detail herein. Specifically in this embodiment, the processor 401 in the electronic device will load the executable files corresponding to the processes of one or more application programs into the memory 402 according to the following instructions, and the processor 401 will run the application programs stored in the memory 402, thereby realizing various functions, as follows:

[0182] Acquire a package area image, wherein the package area image contains package features;

[0183] identifying a first package damaged region in the package region image;

[0184] When at least two first package damaged regions are identified on the package region image, clustering the at least two first package damaged regions to obtain at least one second package damaged region;

[0185] A damage state of the package in the package area image is determined based on at least one second package damage area.

[0186] A person of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.

[0187] To this end, the embodiment of the present application provides a computer-readable storage medium, which may include: a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, etc. A computer program is stored thereon, and the computer program is loaded by a processor to execute the steps in any of the package damage detection methods provided in the embodiment of the present application. For example, the computer program loaded by the processor can execute the following steps:

[0188] Acquire a package area image, wherein the package area image contains package features;

[0189] identifying a first package damaged region in the package region image;

[0190] When at least two first package damaged regions are identified on the package region image, clustering the at least two first package damaged regions to obtain at least one second package damaged region;

[0191] A damage state of the package in the package area image is determined based on at least one second package damage area.

[0192] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the detailed description of other embodiments above, and will not be repeated here.

[0193] In specific implementation, the above units or structures can be implemented as independent entities, or can be arbitrarily combined to be implemented as the same or several entities. The specific implementation of the above units or structures can refer to the previous method embodiments, which will not be repeated here.

[0194] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.

[0195] The above is a detailed introduction to a package damage detection method, device, electronic device and storage medium provided in the embodiments of the present application. Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for those skilled in the art, according to the idea of ​​the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A method for detecting damaged packages, characterized in that: The method for detecting package damage includes: Acquire a package area image, wherein the package area image contains package features; identifying a first package damaged region in the package region image; When at least two first package damaged regions are identified on the package region image, clustering the at least two first package damaged regions to obtain at least one second package damaged region; A damage state of the package in the package area image is determined based on the at least one second package damage area.

2. The method for detecting damaged packages according to claim 1, characterized in that: The clustering of the at least two first package damaged regions to obtain at least one second package damaged region includes: Obtaining at least two minimum circumscribed circles of damaged areas corresponding to the at least two first package damaged areas; Obtaining the center position and radius length of the minimum circumscribed circle of the at least two damaged areas; The at least two minimum circumscribed circles of the at least two damaged areas are clustered based on the center positions and radius lengths of the minimum circumscribed circles of the at least two damaged areas to obtain the at least one second package damaged area.

3. The method for detecting damaged packages according to claim 1, characterized in that: The determining the damage state of the package in the package area image based on the at least one second package damage area includes: Calculate the area ratio of each damaged area of ​​the second package in the package area image to obtain the calculated area ratio of each damaged area of ​​the second package; Based on the calculated area ratio and the preset area level correspondence relationship, the damaged areas of each second package are divided into damage levels to obtain the damage levels of the damaged areas of each second package; Counting the number of damaged areas of the second packages at each damage level based on the damage levels of the damaged areas of the second packages; Based on the number of damaged regions of the second parcel at each damage level in the parcel region image, a damage state of the parcel in the parcel region image is determined.

4. The method for detecting damaged packages according to claim 1, characterized in that: The identifying the first package damaged area in the package area image includes: Call the trained damaged package segmentation model; The package area image is instance segmented based on the damaged package segmentation model to obtain a first package damaged area in the package area image.

5. The method for detecting damaged packages according to claim 4, characterized in that: Before calling the trained damaged package segmentation model, the method further includes: Acquire a damaged package image training set, wherein the images in the damaged package image training set are images of package areas with damaged areas marked; Training a preset image segmentation network model based on the damaged package image training set to obtain a damaged package segmentation model; The damaged package segmentation model is stored.

6. The method for detecting damaged packages according to claim 1, characterized in that: The method for detecting damaged packages also includes: When no first package damaged area is identified on the package area image, determining that the package in the package area image is not damaged, And / or, when it is identified that there is only one first package damaged area on the package area image, the damage state of the package in the package area image is determined based on the area ratio of the first package damaged area on the package area image.

7. The method for detecting damaged packages according to claim 2, characterized in that: The clustering of the at least two minimum circumscribed circles of the at least two damaged areas based on the center positions and radius lengths of the minimum circumscribed circles of the at least two damaged areas to obtain the at least one second package damaged area includes: Acquire a preset damaged area minimum circumscribed circle sample set, wherein the damaged area minimum circumscribed circle sample set includes a plurality of classified minimum circumscribed circles; Determine the minimum circumscribed circle with the largest radius among the at least two minimum circumscribed circles of the damaged areas as the target minimum circumscribed circle; Taking the center position and radius length of the target minimum circumscribed circle as vectors for calculating the Euclidean distance, the Euclidean distance between the target minimum circumscribed circle and each of the classified minimum circumscribed circles is calculated; sorting the multiple classified minimum circumscribed circles from large to small according to the Euclidean distance, and obtaining a preset number of classified minimum circumscribed circles with top Euclidean distance sorting; Determine the category with the highest appearance frequency among the preset number of classified minimum circumscribed circles as the category of the target minimum circumscribed circle; After obtaining the categories of the minimum circumscribed circles of the damaged areas, the minimum circumscribed circles of the damaged areas of the same category are determined as the damaged area of ​​the second package as a whole.

8. A package damage detection device, characterized in that: The package damage detection device comprises: An acquisition unit, used for acquiring a package area image, wherein the package area image contains package features; an identification unit, configured to identify a first package damaged region in the package region image; a clustering unit, configured to cluster the at least two first package damaged regions to obtain at least one second package damaged region when at least two first package damaged regions are identified on the package region image; A determining unit is used to determine a damage state of the package in the package area image based on the at least one second package damage area.

9. An electronic device, characterized in that: The electronic device comprises: one or more processors; Memory; and One or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the processor to implement the package damage detection method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and the computer program is loaded by a processor to execute the steps in the method for detecting package damage according to any one of claims 1 to 7.