A lightweight contraband identification model training method for a logistics scene
By using X-ray scanning and image processing technology, the RGB color values and outlines of logistics items are extracted and compared with a prohibited items dataset, solving the problem of low efficiency in prohibited items identification in logistics scenarios and achieving highly accurate and efficient prohibited items detection.
Patent Information
- Application Number
- CN202510765364.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-10
- Publication Date
- 2025-12-26
- Estimated Expiration
- 2045-06-10
AI Technical Summary
Existing contraband identification technologies are inefficient and inaccurate in logistics scenarios, especially when various types of items are placed in a disorderly manner, making it difficult to identify them effectively. In addition, traditional manual identification methods are labor-intensive and inefficient.
Images of logistics items are obtained by X-ray scanning, and after preprocessing, RGB color values are extracted. Material difference thresholds are analyzed to extract the outline of individual items. The outlines of prohibited items are then compared with a dataset of prohibited items to determine whether prohibited items exist.
It improves the accuracy and versatility of contraband identification, is applicable to complex placement scenarios, enhances identification efficiency, and is suitable for merchants and individuals sending packages as well as for the detection of important facilities.
Smart Images

Figure CN120635814B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of contraband identification, in particular to a lightweight contraband identification model training method for logistics scenarios. BACKGROUND
[0002] Contraband identification technology refers to an automated detection technology based on computer vision, sensor fusion and artificial intelligence, aiming to quickly and accurately identify prohibited items in a specific scene by analyzing image, video or sensor data. This technology is widely used in logistics security checks, public transportation, public place security and other scenarios, with the core goal of improving security check efficiency, reducing labor costs, and ensuring the accuracy of security and prevention.
[0003] Existing contraband identification technology is usually identified by artificial means, and the role of machine assistance is low during artificial identification. Employees need to constantly monitor the X-ray security machine to ensure that there are no contraband in the logistics pieces. However, the pressure on the logistics industry is very high, whether it is online shopping or personal mailing, and the in-out warehouse volume is very large every day. Traditional manual identification requires high resistance to pressure from employees, and the logistics piece volume is large, traditional manual identification is slow, and has some impact on the efficiency of logistics piece in-out warehouse. In addition, existing contraband identification technology is usually used for identifying single items in express sorting, i.e. a package contains only one item. However, in reality, in addition to most online shopping goods, personal mailing packages and a small amount of remaining goods store multiple types of items and are placed in disarray. Existing contraband identification technology is difficult to identify the items in them. At the same time, existing contraband identification technology also uses scanning the face sheet information of the logistics piece to identify whether the goods contain contraband. However, some goods are confidential and cannot be identified by the face sheet, and when personal mailing is messy, the face sheet information cannot include all the items. For example, in the patent application with publication number CN116618319A, a "contraband express sorting method" is disclosed, which identifies contraband by scanning the face sheet information of the logistics piece. In some cases, it cannot be correctly identified. Existing contraband identification technology also has the problems of using traditional manual identification or poor application scenarios, resulting in low contraband identification efficiency and low contraband identification accuracy. SUMMARY
[0004] The present application aims to at least solve one of the technical problems in the prior art by X-ray scanning the logistics articles, obtaining X-ray images of the logistics articles, then preprocessing the X-ray images to obtain enhanced images of the X-ray images, extracting RGB color values of the pixel points in the enhanced images, classifying sample images based on the materials of the contraband, analyzing the RGB difference threshold between different articles of the same material in the enhanced images based on the sample images, then analyzing and calculating the neighbor R difference, neighbor G difference and neighbor B difference based on the RGB difference threshold and the RGB color values of the enhanced images, extracting the single article based on the neighbor R difference, neighbor G difference and neighbor B difference, and extracting the contour image of the single article. At the same time, a random number of different types of contraband are placed in the storage box, the contraband in the storage box is marked as a contraband sample, the contour image of the contraband sample is extracted and marked as a sample contour, the contour similarity threshold is analyzed based on the sample contour and the contraband sample in the contraband contour dataset, and finally the article contour is compared with the contraband contour in the contraband contour dataset based on the contour similarity threshold to determine whether there is contraband, so as to solve the problem that the existing contraband identification technology still uses traditional manual identification or has poor application scene, resulting in low identification efficiency of the contraband and low contraband identification accuracy.
[0005] To achieve the above-mentioned purpose, in a first aspect, the present application provides a lightweight contraband identification model training method for a logistics scene, comprising the following steps:
[0006] X-ray scanning the logistics articles to obtain X-ray images of the logistics articles;
[0007] Preprocessing the X-ray images to obtain enhanced images of the X-ray images;
[0008] Extracting the RGB color values of the pixel points in the enhanced images, classifying sample images based on the materials of the contraband, and analyzing the RGB difference threshold between different articles of the same material in the enhanced images based on the sample images;
[0009] Extracting the single article based on the RGB difference threshold and combining the RGB color values of the enhanced images, and extracting the contour of the single article to obtain the contour image of the single article;
[0010] Selecting a random number of different types of contraband and placing them in the storage box, marking the contraband in the storage box as a contraband sample, extracting the contour image of the contraband sample, and marking it as a sample contour, and analyzing the contour similarity threshold based on the sample contour and the contraband sample in the contraband contour dataset;
[0011] Comparing the article contour with the contraband contour in the contraband contour dataset based on the contour similarity threshold to determine whether there is contraband.
[0012] Further, the X-ray scanning of the logistics articles specifically comprises X-ray scanning of the logistics articles by an X-ray security inspection machine to obtain an X-ray image.
[0013] Further, the preprocessing of the X-ray image to obtain an enhanced image of the X-ray image comprises the following sub-steps:
[0014] The X-ray image is subjected to denoising processing and sharpening processing.
[0015] After the denoising processing and the sharpening processing are completed, the X-ray image is changed into an erosion image to obtain the enhanced image.
[0016] Further, the RGB color values of the pixel points in the enhanced image are extracted, sample images are classified and obtained based on the materials of the contraband, and the RGB difference threshold between different articles of the same material in the enhanced image is analyzed based on the sample images, which comprises the following sub-steps:
[0017] The pixel points in the enhanced image are numbered and marked as D(n,m) in the order of first from left to right and then from top to bottom, where n and m are positive integers, and D(n,m) represents a pixel point in the nth row and the mth column;
[0018] The RGB color values of the pixel points in the enhanced image are extracted, the RGB color values including R color, G color and B color, representing the values of the red, green and blue three channels, respectively, and the R color, G color and B color of D(n,m) are marked as R(n,m), G(n,m) and B(n,m), respectively;
[0019] The same material contraband is selected as a group, named as a homogeneous group, and a first sample number of images of each contraband in the homogeneous group are obtained, named as standard images, the brands, shapes and sizes of the contraband in the standard images of the same type of contraband are not completely the same, the enhanced images corresponding to the standard images are obtained, and marked as sample images;
[0020] In the X-ray image, articles of different materials are distinguished by different colors, and are generally divided into yellow, blue and green, for the enhanced image, only the yellow in the enhanced image is retained to obtain a yellow image, only the blue in the enhanced image is retained to obtain a blue image, and only the green in the enhanced image is retained to obtain a green image, and the yellow image, the blue image and the green image are collectively referred to as a single-color image.
[0021] For any sample image, the single-color image in the sample image is extracted, and for any single-color image, R(n,m), G(n,m) and B(n,m) in the single-color image are extracted and marked as PR(n,m), PG(n,m) and PB(n,m), respectively.
[0022] Based on PR(n,m), PG(n,m) and PB(n,m), analyze the RGB difference threshold between different objects of the same material.
[0023] Further, based on PR(n,m), PG(n,m) and PB(n,m), analyzing the RGB difference threshold between different objects of the same material includes the following sub-steps:
[0024] Respectively, obtain the minimum value of PR(n,m), PG(n,m) and PB(n,m), respectively marked as minR, minG and minB;
[0025] Calculate the difference between each PR(n,m) and minR, named as homologous R difference, calculate the difference between each PG(n,m) and minR, named as homologous G difference, calculate the difference between each PB(n,m) and minR, named as homologous B difference, and calculate the homologous R difference, homologous G difference and homologous B difference in each single-tone image;
[0026] Calculate the average value of homologous R difference, marked as homologous average R difference, calculate the average value of homologous G difference, marked as homologous average G difference, and calculate the average value of homologous B difference, marked as homologous average B difference;
[0027] For any two sample images in the homogenous group, respectively marked as T1 and T2, calculate the average value of PR(n,m) in T1, marked as TR1, calculate the average value of PG(n,m) in T1, marked as TG1, calculate the average value of PB(n,m) in T1, marked as TB1, calculate the average value of PR(n,m) in T2, marked as TR2, calculate the average value of PG(n,m) in T2, marked as TG2, and calculate the average value of PB(n,m) in T2, marked as TB2;
[0028] Calculate |TR1-TR2| to obtain the heterologous average R difference, calculate |TG1-TG2| to obtain the heterologous average G difference, and calculate |TB1-TB2| to obtain the heterologous average B difference;
[0029] Obtain the median value between the homologous average R difference and the heterologous average R difference, marked as R difference threshold, obtain the median value between the homologous average G difference and the heterologous average G difference, marked as G difference threshold, and obtain the median value between the homologous average B difference and the heterologous average B difference, marked as B difference threshold;
[0030] The R difference threshold, G difference threshold and B difference threshold are the RGB difference threshold.
[0031] Further, based on the RGB difference threshold and combined with the RGB color value of the enhanced image, extract the single piece of the object, perform contour extraction on the single piece of the object, and obtain the contour image of the single piece of the object, including the following sub-steps:
[0032] Calculate the neighbor point R difference, the neighbor point G difference and the neighbor point B difference based on the RGB difference threshold and in combination with the RGB color value analysis of the enhanced image.
[0033] Extract the single piece of the article based on the neighbor point R difference, the neighbor point G difference and the neighbor point B difference, and extract the outline image of the single piece of the article.
[0034] Further, the calculation of the neighbor point R difference, the neighbor point G difference and the neighbor point B difference based on the RGB difference threshold and in combination with the RGB color value analysis of the enhanced image comprises the following sub-steps:
[0035] Name the storage box to be scanned as the storage to be identified, name the enhanced image of the storage to be identified as the image to be identified, and name the single-tone image of the image to be identified as the single-tone image to be identified;
[0036] For any single-tone image to be identified, randomly select a pixel point corresponding to the tone of the single-tone image to be identified, mark it as a starting point, obtain the R color, the G color and the B color of the starting point, and mark them as QR, QG and QB respectively, name the pixel point adjacent to the starting point as a neighbor point, and obtain the R color, the G color and the B color of the neighbor point, and mark them as LR, LG and LB respectively;
[0037] Calculate |QR-LR| to obtain the neighbor point R difference, calculate |QG-LG| to obtain the neighbor point G difference, and calculate |QB-LB| to obtain the neighbor point B difference.
[0038] Further, the extraction of the single piece of the article based on the neighbor point R difference, the neighbor point G difference and the neighbor point B difference, and the extraction of the outline image of the single piece of the article comprises the following sub-steps:
[0039] Determine whether the neighbor point R difference is less than or equal to the R difference threshold, whether the neighbor point G difference is less than or equal to the G difference threshold, and whether the neighbor point B difference is less than or equal to the B difference threshold, and if all are yes, output a pixel homologous signal, otherwise output a pixel heterologous signal;
[0040] If the pixel homologous signal is output, mark the neighbor point as the starting point, and if a new starting point appears, find the corresponding neighbor point again for analysis until there is no new starting point;
[0041] Mark the image composed of the starting point as a single piece of the article, and extract the outline of the single piece of the article by OpenCV edge detection technology to obtain the outline image of the single piece of the article;
[0042] Exclude the starting point and randomly select the starting point again until all the pixel points in the single-tone image to be identified become pure white;
[0043] Calculate the average value of each R color, G color and B color of each single item respectively to obtain R average color, G average color and B average color, compare the R average color, G average color and B average color of any two single items, if the difference between the R average color, G average color and B average color is less than or equal to the R difference threshold, G difference threshold and B difference threshold respectively, then mark the corresponding two single items as homologous analysis items;
[0044] Find the two closest contour lines between the homologous analysis items and mark them as the contour lines to be analyzed, and find whether the contour lines to be analyzed belong to single items other than the homologous analysis items, if yes, integrate the homologous analysis items into the same single item and re-extract the contour image.
[0045] Further, a random number of different types of contraband are placed in the storage box, the contraband in the storage box is marked as a contraband sample, the contour image of the contraband sample is extracted and marked as a sample contour, and the sample contour and the contraband contour in the contraband contour dataset are analyzed according to the following substeps:
[0046] Set the second sample number of storage boxes, and place a random number of different types of contraband in each storage box, and mark the storage boxes as sample boxes;
[0047] For any sample box, extract the contour image of each single item in the sample box, and mark it as a sample contour, each sample contour corresponding to a contraband sample;
[0048] Construct a contraband contour dataset, which stores contour images of different brands, different sizes and different appearances of all types of contraband, i.e. contraband contours;
[0049] Find the contraband contour of the contraband sample in the contraband contour dataset, mark it as the original contour, and analyze the similarity between the sample contour corresponding to the contraband sample and the original contour to obtain the similarity, which is named as sample similarity;
[0050] Analyze the sample similarity of each contraband sample in each sample box, find the minimum value, and mark it as the contour similarity threshold.
[0051] Further, based on the contour similarity threshold, compare the item contour with the contraband contour in the contraband contour dataset to determine whether there is contraband, including the following substeps:
[0052] After the light-weight contraband identification model is trained, when identifying the contraband, extract the contour image of the single item in the X-ray image, and name it as the item contour;
[0053] Obtain the color tone of the single color tone image where the single item is located, and mark it as the target color tone;
[0054] find the contraband contour of the contraband containing the target color tone in the target contour set, and mark it as a target contour set;
[0055] perform similarity analysis on the article contour and each contraband contour in the target contour set to obtain an article similarity, find the maximum value in the article similarity, and mark it as a target similarity;
[0056] Compare the target similarity with the contour similarity threshold value, if the target similarity is greater than or equal to the contour similarity threshold value, mark the article single piece as contraband, otherwise output an article compliance signal.
[0057] The present application has the advantages that: the present application obtains the X-ray image of the logistics article by X-ray scanning the logistics article, then pre-processes the X-ray image to obtain an enhanced image of the X-ray image, extracts the RGB color value of the pixel points in the enhanced image, classifies and obtains sample images based on the material of the contraband, analyzes the RGB difference threshold value between different articles of the same material in the enhanced image based on the sample images, then analyzes and calculates the neighbor point R difference, the neighbor point G difference and the neighbor point B difference based on the RGB difference threshold value and the RGB color value of the enhanced image, extracts the article single piece based on the neighbor point R difference, the neighbor point G difference and the neighbor point B difference, and extracts the contour image of the article single piece, which has the advantages that the contour image of an article single piece can be extracted in a complex placement scene and among different kinds of articles, the combination analysis of the contours of different articles can be effectively prevented to cause errors in the recognition result, and the accuracy and the universality of the contraband identification are improved.
[0058] The present application has the advantages that: the present application places a random number of different kinds of contraband in the storage box, marks the contraband in the storage box as a contraband sample, extracts the contour image of the contraband sample, marks it as a sample contour, analyzes the contour similarity threshold value from the sample contour and the contraband sample in the contraband contour data set, and finally compares the article contour with the contraband contour in the contraband contour data set based on the contour similarity threshold value to determine whether there is contraband, which has the advantages that the contour similarity threshold value in a complex placement scene can be determined, the method can be applied to both commercial mail sending and individual mail sending, and can assist in the contraband detection of important facilities such as airports and high-speed rail stations, provides a judgment basis in a complex application scene, and improves the accuracy and effectiveness of the contraband identification. BRIEF DESCRIPTION OF DRAWINGS
[0059] Figure 1 The present application has the advantages that: the present application obtains the X-ray image of the logistics article by X-ray scanning the logistics article, then pre-processes the X-ray image to obtain an enhanced image of the X-ray image, extracts the RGB color value of the pixel points in the enhanced image, classifies and obtains sample images based on the material of the contraband, analyzes the RGB difference threshold value between different articles of the same material in the enhanced image based on the sample images, then analyzes and calculates the neighbor point R difference, the neighbor point G difference and the neighbor point B difference based on the RGB difference threshold value and the RGB color value of the enhanced image, extracts the article single piece based on the neighbor point R difference, the neighbor point G difference and the neighbor point B difference, and extracts the contour image of the article single piece, which has the advantages that the contour image of an article single piece can be extracted in a complex placement scene and among different kinds of articles, the combination analysis of the contours of different articles can be effectively prevented to cause errors in the recognition result, and the accuracy and the universality of the contraband identification are improved.
[0060] Figure 2 The present application has the advantages that: the present application obtains the X-ray image of the logistics article by X-ray scanning the logistics article, then pre-processes the X-ray image to obtain an enhanced image of the X-ray image, extracts the RGB color value of the pixel points in the enhanced image, classifies and obtains sample images based on the material of the contraband, analyzes the RGB difference threshold value between different articles of the same material in the enhanced image based on the sample images, then analyzes and calculates the neighbor point R difference, the neighbor point G difference and the neighbor point B difference based on the RGB difference threshold value and the RGB color value of the enhanced image, extracts the article single piece based on the neighbor point R difference, the neighbor point G difference and the neighbor point B difference, and extracts the contour image of the article single piece, which has the advantages that the contour image of an article single piece can be extracted in a complex placement scene and among different kinds of articles, the combination analysis of the contours of different articles can be effectively prevented to cause errors in the recognition result, and the accuracy and the universality of the contraband identification are improved.
[0061] Figure 3 The present application has the advantages that: the present application obtains the X-ray image of the logistics article by X-ray scanning the logistics article, then pre-processes the X-ray image to obtain an enhanced image of the X-ray image, extracts the RGB color value of the pixel points in the enhanced image, classifies and obtains sample images based on the material of the contraband, analyzes the RGB difference threshold value between different articles of the same material in the enhanced image based on the sample images, then analyzes and calculates the neighbor point R difference, the neighbor point G difference and the neighbor point B difference based on the RGB difference threshold value and the RGB color value of the enhanced image, extracts the article single piece based on the neighbor point R difference, the neighbor point G difference and the neighbor point B difference, and extracts the contour image of the article single piece, which has the advantages that the contour image of an article single piece can be extracted in a complex placement scene and among different kinds of articles, the combination analysis of the contours of different articles can be effectively prevented to cause errors in the recognition result, and the accuracy and the universality of the contraband identification are improved.
[0062] Figure 4 is a profile image of the present application;
[0063] Figure 5 is a gray scale image of the enhanced image of the present application;
[0064] Figure 6 is a schematic diagram of the profile image of the single piece of the article extracted in the blue tone image of the present application;
[0065] Figure 7 is a schematic diagram of the profile line to be analyzed of the present application. DETAILED DESCRIPTION
[0066] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor fall within the scope of protection of the present application.
[0067] Embodiment 1, please refer to Figure 1 As shown in the figure, the present application provides a light-weight contraband identification model training method for a logistics scene, including the following steps:
[0068] Step S1, X-ray scanning is performed on the logistics article to obtain an X-ray image of the logistics article; the X-ray scanning on the logistics article is specifically performed by an X-ray security inspection machine on the logistics article to obtain the X-ray image;
[0069] In a specific implementation, the X-ray scanning is performed on the logistics article by using an existing X-ray security inspection machine to obtain the X-ray image.
[0070] Step S2, the X-ray image is preprocessed to obtain an enhanced image of the X-ray image; step S2 includes the following substeps:
[0071] Step S201, the X-ray image is subjected to denoising processing and sharpening processing;
[0072] Step S202, after the denoising processing and the sharpening processing are completed, the X-ray image is changed into an erosion image to obtain the enhanced image;
[0073] In a specific implementation, the X-ray image is subjected to denoising processing and sharpening processing by using existing denoising technology and sharpening technology, and then the X-ray image is changed into an erosion image to obtain the enhanced image. Since the enhanced image is a color image, it is meaningless to display the color image in the form of a gray scale image in the present embodiment, and therefore the enhanced image is not displayed.
[0074] Step S3, extract the RGB color value of the pixel points in the enhanced image, classify the sample images based on the material of the prohibited articles, and analyze the RGB difference threshold between different articles of the same material in the enhanced image based on the sample images; step S3 includes the following sub-steps:
[0075] Step S301, numbering the pixel points in the enhanced image, and marking them as D(n,m) in the order of first from left to right and then from top to bottom, where n and m are positive integers, and D(n,m) represents the pixel point in the nth row and the mth column;
[0076] Step S302, extract the RGB color value of the pixel points in the enhanced image, the RGB color value includes R color, G color and B color, which represent the values of red, green and blue three channels respectively, and mark the R color, G color and B color of D(n,m) as R(n,m), G(n,m) and B(n,m) respectively;
[0077] Step S303, select prohibited articles of the same material as a group, named homogeneous group, and obtain a first sample number of images of each prohibited article in the homogeneous group, named standard image, the brand, shape and size of the prohibited articles in the standard image of the same type of prohibited articles are not completely the same, obtain the enhanced image corresponding to the standard image, and mark it as sample image;
[0078] In a specific implementation, D(n,m) is only used to distinguish different pixel points, therefore, D(n,m) is not specifically described in this embodiment, for the material of the articles, such as controlled knives, the knife body is a metal material, the lighter shell has metal material and plastic material, the thermal cup is a stainless steel material, different materials exhibit different colors in the X-ray image, and the same material exhibits similar but not identical colors in the X-ray image if the density of part of the elements or materials is different, in the prohibited article identification, if the materials are different, the identification difficulty is low, and if the materials are the same, the identification difficulty is high, therefore, the prohibited articles of the same material are divided into a homogeneous group, and the identification ability of the light-weight prohibited article identification model in a complex scene is enhanced based on the homogeneous group; for example, a homogeneous group includes multiple metal prohibited articles such as kitchen knives, scissors, folding knives and butterfly knives, the kitchen knives, scissors, folding knives and butterfly knives are different types of prohibited articles, a first sample number of images of each type of prohibited article is obtained, the setting of the first sample number has no specific limitation, which is determined according to the ability of the user to obtain different brands, appearances and sizes of the same type of prohibited article, for example, the user can only obtain 108 types of kitchen knives, and the first sample number is set to 108, the first sample number corresponding to each type of prohibited article is not the same, and in different standard images of the same type of prohibited article, at least one of the brand, shape and size parameters is different from other standard images, the enhanced image corresponding to the standard image is obtained, and the sample image is obtained;
[0079] Step S304, in the X-ray image, different materials of the object are distinguished by different colors, which are generally divided into yellow, blue and green, for the enhanced image, only the yellow tone in the enhanced image is retained to obtain a yellow tone image, only the blue tone in the enhanced image is retained to obtain a blue tone image, and only the green tone in the enhanced image is retained to obtain a green tone image, the yellow tone image, the blue tone image and the green tone image are collectively referred to as a single tone image;
[0080] Step S305, for any sample image, the single tone image in the sample image is extracted, for any single tone image, R(n,m), G(n,m) and B(n,m) in the single tone image are extracted, which are respectively marked as PR(n,m), PG(n,m) and PB(n,m);
[0081] In the implementation, in the X-ray scanning, different materials of the object exhibit different colors under the X-ray, mainly including organic matter, inorganic matter and mixture, the organic matter often presents different shades of yellow tone in the X-ray security image, the inorganic matter exhibits different shades of blue tone in the X-ray security image, and the mixture displays different levels of green tone in the X-ray security image, the distinction of the yellow tone, the blue tone and the green tone adopts the existing color wheel standard, which will not be specifically described in the embodiment; PR(n,m), PG(n,m) and PB(n,m) are extracted according to the method in step S302, and PR(n,m), PG(n,m) and PB(n,m) of different single tone images in different sample images are independent of each other;
[0082] Step S306, based on PR(n,m), PG(n,m) and PB(n,m), the RGB difference threshold between different objects of the same material is analyzed;
[0083] Step S306 includes the following sub-steps:
[0084] Step S306.1, the minimum values of PR(n,m), PG(n,m) and PB(n,m) are respectively obtained, which are respectively marked as minR, minG and minB;
[0085] Step S306.2, the difference between each PR(n,m) and minR is calculated, which is named as homologous R difference, the difference between each PG(n,m) and minR is calculated, which is named as homologous G difference, and the difference between each PB(n,m) and minR is calculated, which is named as homologous B difference, the homologous R difference, the homologous G difference and the homologous B difference in each single tone image are calculated;
[0086] Step S306.3, the average value of the homologous R difference is calculated, which is marked as homologous average R difference, the average value of the homologous G difference is calculated, which is marked as homologous average G difference, and the average value of the homologous B difference is calculated, which is marked as homologous average B difference;
[0087] In specific implementation, the homologous R difference, the homologous G difference and the homologous B difference represent the fluctuation size of the RGB color value of the same material in the single-tone map. For example, in a single-tone map, the minR is 203, and the PR(45, 68) is 211, so the homologous R difference of the PR(45, 68) is 8. Each pixel point corresponds to a homologous R difference, a homologous G difference and a homologous B difference. The homologous average R difference, the homologous average G difference and the homologous average B difference represent the average value of the fluctuation size of the RGB color value of the same material in the single-tone map.
[0088] Step S306.4, for any two sample images in the homogenous group, respectively marked as T1 and T2, the average value of PR(n, m) in T1 is calculated and marked as TR1, the average value of PG(n, m) in T1 is calculated and marked as TG1, the average value of PB(n, m) in T1 is calculated and marked as TB1, the average value of PR(n, m) in T2 is calculated and marked as TR2, the average value of PG(n, m) in T2 is calculated and marked as TG2, and the average value of PB(n, m) in T2 is calculated and marked as TB2.
[0089] Step S306.5, the |TR1-TR2| is calculated to obtain the heterologous average R difference, the |TG1-TG2| is calculated to obtain the heterologous average G difference, and the |TB1-TB2| is calculated to obtain the heterologous average B difference.
[0090] Step S306.6, the median value between the homologous average R difference and the heterologous average R difference is obtained and marked as the R difference threshold, the median value between the homologous average G difference and the heterologous average G difference is obtained and marked as the G difference threshold, and the median value between the homologous average B difference and the heterologous average B difference is obtained and marked as the B difference threshold.
[0091] Step S306.7, the R difference threshold, the G difference threshold and the B difference threshold are the RGB difference threshold.
[0092] In specific implementation, TR1 is the average value of the R color value of each pixel point in T1. It should be noted that when TR1 is calculated, only the pixel points of the same tone as the single-tone map are considered. The definitions of TG1, TB1, TR2, TG2 and TB2 are similar to TR1. The heterologous average R difference, the heterologous average G difference and the heterologous average B difference represent the difference size of the R color value, the G color value and the B color value of different products under the premise of the same material. For example, TR1 is 205, TR2 is 221, and the heterologous average R difference is calculated to be 16, which means that the R color value of the two same materials of the contraband T1 and T2 has an average difference of 16. In this embodiment, the homologous average R difference is 4, the R difference threshold is calculated to be 10, the G difference threshold is calculated to be 9, and the B difference threshold is calculated to be 9.
[0093] Step S4, based on the RGB difference threshold and combined with the RGB color value of the enhanced image, the single piece of the article is extracted, and the contour image of the single piece of the article is obtained; step S4 includes the following substeps:
[0094] Step S401, based on the RGB difference threshold and combined with the RGB color value of the enhanced image, the neighbor point R difference, the neighbor point G difference and the neighbor point B difference are calculated;
[0095] Step S401 includes the following substeps:
[0096] Step S401.1, the storage box to be scanned is named as the to-be-identified storage object, the enhanced image of the to-be-identified storage object is named as the to-be-identified image, and the single-tone image of the to-be-identified image is named as the to-be-identified single-tone image;
[0097] Please refer to Figure 2 As shown in the figure, step S401.2, for any to-be-identified single-tone image, a pixel point corresponding to the color tone of the to-be-identified single-tone image is randomly selected, which is marked as a starting point, the R color, G color and B color of the starting point are obtained, which are marked as QR, QG and QB respectively, and the pixel point adjacent to the starting point is named as a neighbor point, and the R color, G color and B color of the neighbor point are obtained, which are marked as LR, LG and LB respectively.
[0098] Step S401.3, |QR-LR| is calculated to obtain the neighbor point R difference, |QG-LG| is calculated to obtain the neighbor point G difference, and |QB-LB| is calculated to obtain the neighbor point B difference.
[0099] In a specific implementation, assuming that the to-be-identified single-tone image is a blue-tone image, a pixel point of the blue tone in the to-be-identified single-tone image is randomly selected as the starting point, as shown in the figure Figure 2 The starting point QR, QG and QB are obtained as 205, 227 and 255 respectively. Since the color difference between some neighbor points and the starting point is too small, the boundary between the pixel points is not obvious, and a black line segment is added in this embodiment to distinguish different pixel points. The neighbor points of the starting point include 1 to 8 in Figure 2 For example, the LR, LG and LB of the neighbor point 1 are 213, 240 and 255 respectively, and the neighbor point R difference, the neighbor point G difference and the neighbor point B difference of the neighbor point 1 are calculated as 8, 13 and 0 respectively.
[0100] Step S402, based on the neighbor point R difference, the neighbor point G difference and the neighbor point B difference, the single piece of the article is extracted, and the contour image of the single piece of the article is extracted.
[0101] Step S402 includes the following substeps:
[0102] Step S402.1, judging whether the adjacent point R difference is less than or equal to the R difference threshold, the adjacent point G difference is less than or equal to the G difference threshold, and the adjacent point B difference is less than or equal to the B difference threshold, if all are yes, outputting the pixel homologous signal, otherwise outputting the pixel heterologous signal;
[0103] Step S402.2, if the pixel homologous signal is outputted, marking the adjacent point as the starting point, if a new starting point appears, searching for the corresponding adjacent point again for analysis until there is no new starting point;
[0104] In the specific implementation, the adjacent point R difference, the adjacent point G difference and the adjacent point B difference of the adjacent point 1 are 8, 13 and 0 respectively, wherein the adjacent point R difference and the adjacent point B difference are less than the R difference threshold and the B difference threshold respectively, but the adjacent point G difference is greater than the G difference threshold, thus the pixel heterologous signal is outputted, and the adjacent point 3, the adjacent point 5, the adjacent point 6, the adjacent point 7 and the adjacent point 8 are analyzed in the same way to output the pixel homologous signal, marking the adjacent point 3, the adjacent point 5, the adjacent point 6, the adjacent point 7 and the adjacent point 8 as the starting point, since a new starting point appears, searching for the adjacent point of the new starting point again for analysis, that is, searching for the adjacent point of the adjacent point 3, the adjacent point 5, the adjacent point 6, the adjacent point 7 and the adjacent point 8 in the adjacent point 1, Figure 2 The starting point is not included in the searching range of the adjacent point, and only the new starting point is analyzed, Figure 2 The starting point in the adjacent point 1 has been analyzed and is not included in the analysis range;
[0105] Referring to FIG. 4B, step S402.3, marking the image composed of the starting points as the single piece of the article, extracting the contour of the single piece of the article through the OpenCV edge detection technology to obtain the contour image of the single piece of the article; Figures 3-4
[0106] Step S402.4, removing the starting points and randomly selecting the starting points again until all the pixel points in the single-tone image to be recognized become pure white;
[0107] Referring to FIG. 4C, step S402.5, calculating the average value of each R color, G color and B color of each single piece of the article respectively to obtain the R average color, the G average color and the B average color, comparing the R average color, the G average color and the B average color of any two single pieces of the article, if the difference between the R average color, the G average color and the B average color is less than or equal to the R difference threshold, the G difference threshold and the B difference threshold respectively, marking the corresponding two single pieces of the article as the homologous analysis article; Figures 5-6 Referring to FIG. 4D, step S402.6, calculating the average value of the R color, the G color and the B color of each single piece of the article to obtain the R average color, the G average color and the B average color, comparing the R average color, the G average color and the B average color of any two single pieces of the article, if the difference between the R average color, the G average color and the B average color is less than or equal to the R difference threshold, the G difference threshold and the B difference threshold respectively, marking the corresponding two single pieces of the article as the homologous analysis article;
[0108] Figure 7 As shown, in step S402.6, the two closest contour lines between the homologous analysis articles are found, marked as the to-be-analyzed contour line, and it is determined whether the to-be-analyzed contour line belongs to an article single piece outside the homologous analysis articles. If yes, the homologous analysis articles are integrated into the same article single piece, and the contour image is re-extracted.
[0109] In a specific implementation, the extracted article single piece is as shown in Figure 3 As shown, the contour of the article single piece is extracted by using the existing OpenCV edge detection technology to obtain a contour image as shown in Figure 4 As shown, the enhanced image to be recognized in this embodiment is as shown in Figure 5 Figure 5 The enhanced image is a gray image, not a color image. In fact, the enhanced image used for recognition is a color image. Figure 6 Figure 5 The contour image of the extracted article single piece in the blue tone of the atlas 1 and the atlas 3 is as shown in the figure. The R average color, the G average color, and the B average color of the article 1 are 211, 242, and 253, respectively, and the R average color, the G average color, and the B average color of the article 3 are 214, 241, and 254, respectively. The R average color of the atlas 1 and the atlas 3 differs by 3, which is less than the R difference threshold. The G average color and the B average color differ by 1, which are less than the G difference threshold and the B difference threshold, respectively. Therefore, the article 1 and the article 3 are integrated into the homologous analysis articles. The to-be-analyzed contour line is as shown in Figure 7 As shown, it is found that the to-be-analyzed contour line belongs to the article 2. Therefore, the article 1 and the article 3 are integrated into the same article single piece. It should be noted that when it is determined whether the to-be-analyzed contour line belongs to an article single piece outside the homologous analysis articles, it is not limited to the current single color tone image, but all article single pieces in all single color tone images are searched. In fact, the contour image of the article 1 and the article 3 can be extracted from the atlas 1 and the atlas 3, and the to-be-analyzed contour line is removed during the extraction. Figure 6
[0110] In step S5, a random number of different types of contraband are placed in the storage box, the contraband in the storage box is marked as a contraband sample, the contour image of the contraband sample is extracted, and the sample contour is marked. The sample contour is analyzed by the contraband contour in the contraband contour data set, and the contraband contour similarity threshold is analyzed. Step S5 includes the following sub-steps:
[0111] In step S501, a second sample number of storage boxes are set, and a random number of different types of contraband are placed in each storage box. The storage box is marked as a sample box.
[0112] In step S502, for any sample box, the contour image of each article single piece in the sample box is extracted, and the sample contour is marked. Each sample contour corresponds to a contraband sample.
[0113] Step S503, construct a prohibited contour data set, and the prohibited contour data set stores the contour images of different brands, different sizes and different appearances of all kinds of prohibited items, i.e. prohibited contours;
[0114] Step S504, find the prohibited contour of the prohibited sample in the prohibited contour data set, mark it as an original contour, and perform similarity analysis on the sample contour corresponding to the prohibited sample and the original contour to obtain the similarity obtained by the analysis, which is named as sample similarity;
[0115] Step S505, analyze the sample similarity of each prohibited sample in each sample box, find the minimum value in it, and mark it as a contour similarity threshold;
[0116] In a specific implementation, the second sample quantity is set by the user, and there is no special requirement. In this embodiment, the second sample quantity is set to 50, i.e. the sample box is scanned 50 times by the X-ray security inspection machine, and the prohibited items and the placement manner in the sample box are different each time. In a certain analysis, a sample contour is extracted, and since it is a sample box, it is known that the sample contour corresponds to an A brand B lighter, i.e. the prohibited sample is an A brand B lighter. Find the prohibited contour of the A brand B lighter in the prohibited contour data set and perform similarity analysis on the sample contour. The existing similarity analysis algorithm is used for analysis, and finally the sample similarity is 76%. In the 50 times of sample box analysis, the minimum value of the sample similarity of all prohibited samples and the prohibited contour is 52%, i.e. in the complex placement, the same prohibited item needs to have at least 52% similarity when performing similarity analysis, and the contour similarity threshold is 52%.
[0117] Step S6, based on the contour similarity threshold, compare the item contour with the prohibited contour in the prohibited contour data set to determine whether there is prohibited item; Step S6 includes the following sub-steps:
[0118] Step S601, after the light-weight prohibited item recognition model is trained, when identifying the prohibited item, the contour image of the single item in the X-ray image is extracted, which is named as item contour;
[0119] Step S602, obtain the color tone of the single color tone image in which the single item is located, and mark it as target color tone;
[0120] Step S603, find the prohibited contour of the prohibited item containing the target color tone in the prohibited contour data set, and mark it as target contour set;
[0121] Step S604, perform similarity analysis on the item contour and each prohibited contour in the target contour set to obtain the item similarity, and find the maximum value in the item similarity, which is marked as target similarity;
[0122] Step S605, the target similarity is compared with the contour similarity threshold, if the target similarity is greater than or equal to the contour similarity threshold, the single piece of the article is marked as contraband, otherwise, an article compliance signal is output;
[0123] In a specific implementation, steps S2 to S5 are all training processes of the lightweight contraband identification model. If the article contour is extracted in the blue tone image, the target tone is blue, the contraband contour of the contraband containing the blue tone in the contraband contour data set is searched, and the target contour set is obtained. This step can improve the identification efficiency. The subsequent identification process of the contraband is clear, and this embodiment will not be described in detail.
[0124] In embodiment 2, the electronic device can include a processor, a communication interface, a memory, and a communication bus. The processor, the communication interface, and the memory can communicate with each other through the communication bus. The memory stores computer readable instructions. The processor can call the instructions in the memory. When the computer readable instructions are executed by the processor, the steps of the lightweight contraband identification model training method for the logistics scene are run to realize the following functions: obtaining an X-ray image of a logistics article; preprocessing the X-ray image to obtain an enhanced image of the X-ray image; analyzing the RGB difference threshold between different articles of the same material in the enhanced image based on a sample image; extracting a single piece of the article based on the RGB difference threshold and the RGB color value of the enhanced image; extracting a contour image of the contraband sample and marking it as a sample contour; analyzing the contour similarity threshold from the sample contour and the contraband contour of the contraband sample in the contraband contour data set; and determining whether there is contraband based on the contour similarity threshold.
[0125] In addition, the logical instructions in the memory described above can be implemented in the form of a software function unit and sold or used as an independent product. When stored in a computer readable storage medium, the technical solutions of the present application can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in the embodiments of the present application. The foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, and various storage medium that can store program codes.
[0126] Embodiment 3, the present application also provides a computer program product, the computer program product includes a computer program stored on a computer readable storage medium, the computer program includes program instructions, when the program instructions are executed by a computer, the computer can execute a lightweight contraband identification model training method for a logistics scene provided by each method, the method includes: obtaining an X-ray image of a logistics article; preprocessing the X-ray image to obtain an enhanced image of the X-ray image; analyzing the RGB difference threshold between different articles of the same material in the enhanced image based on the sample image; extracting the article single based on the RGB difference threshold and combining the RGB color value of the enhanced image; extracting the contour image of the contraband sample, and marking it as a sample contour; analyzing the contour similarity threshold of the sample contour and the contraband contour in the contraband contour dataset; based on the contour similarity threshold, determining whether there is contraband.
[0127] Embodiment 4, the present application also provides a computer readable storage medium, the present application provides a storage medium, a computer program is stored on the storage medium, when the computer program is executed by a processor, the steps in the lightweight contraband identification model training method for a logistics scene are run to realize the following functions: obtaining an X-ray image of a logistics article; preprocessing the X-ray image to obtain an enhanced image of the X-ray image; analyzing the RGB difference threshold between different articles of the same material in the enhanced image based on the sample image; extracting the article single based on the RGB difference threshold and combining the RGB color value of the enhanced image; extracting the contour image of the contraband sample, and marking it as a sample contour; analyzing the contour similarity threshold of the sample contour and the contraband contour in the contraband contour dataset; based on the contour similarity threshold, determining whether there is contraband.
[0128] Through the description of the above embodiments, the embodiments of the present application can be provided as a method, a system or a computer program product. Based on such understanding, the above technical solutions can be embodied in the form of a software product, which can be stored in a computer readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., including a plurality of instructions to make a computer device (which can be a personal computer, server, or network device, etc.) execute the method described in each embodiment or some parts of the embodiment.
[0129] In the embodiments of the present application, it should be understood that the disclosed system or method can be implemented in other ways. The embodiments described above are only illustrative, for example, the division of modules or units is only a logical function division, and other division manners can be used in actual implementation, for example, a plurality of modules or units can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the displayed or discussed each other can be through some communication interface, the indirect coupling or communication connection between the system, the module and the unit can be electrical, mechanical or other forms.
[0130] Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present application, and not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: it can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacement for part of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for training a lightweight contraband identification model for logistics scenarios, characterized in that, The method comprises the following steps: X-ray scanning of the logistics articles to obtain X-ray images of the logistics articles; Pretreatment of the X-ray images to obtain enhanced images of the X-ray images; Extraction of RGB color values of pixel points in the enhanced images, classification of sample images based on the material of the prohibited articles, and analysis of the RGB difference threshold between different articles of the same material in the enhanced images based on the sample images; Extraction of the single piece of the article based on the RGB difference threshold and the RGB color values of the enhanced images, contour extraction of the single piece of the article to obtain a contour image of the single piece of the article; Randomly selecting a certain number of different types of prohibited articles and placing them in a storage box, marking the prohibited articles in the storage box as prohibited samples, extracting the contour image of the prohibited samples, and marking it as a sample contour, and analyzing the contour similarity threshold of the sample contour and the prohibited contour of the prohibited sample in the prohibited contour dataset; Comparison of the article contour with the prohibited contour in the prohibited contour dataset based on the contour similarity threshold to determine whether there is a prohibited article; The extraction of the RGB color values of the pixel points in the enhanced images, the classification of the sample images based on the material of the prohibited articles, and the analysis of the RGB difference threshold between different articles of the same material in the enhanced images based on the sample images comprises the following sub-steps: Numbering the pixel points in the enhanced image, and marking them as D(n,m) in the order of first from left to right and then from top to bottom, wherein n and m are positive integers, and D(n,m) represents the pixel point in the nth row and the mth column; Extraction of the RGB color values of the pixel points in the enhanced image, wherein the RGB color values include R color, G color and B color, which represent the values of the red, green and blue three channels respectively, and R(n,m), G(n,m) and B(n,m) are marked for R color, G color and B color of D(n,m) respectively; Selecting prohibited articles of the same material as a group, named as a homogeneous group, obtaining a first sample number of images of each type of prohibited article in the homogeneous group, and naming them as standard images, wherein the brand, shape and size of the prohibited articles in the standard images of the same type of prohibited articles are not completely the same, obtaining the enhanced images corresponding to the standard images, and marking them as sample images; In the X-ray image, articles of different materials are distinguished by different colors, and are generally divided into yellow, blue and green, for the enhanced image, only the yellow tone in the enhanced image is retained to obtain a yellow tone image, only the blue tone in the enhanced image is retained to obtain a blue tone image, and only the green tone in the enhanced image is retained to obtain a green tone image, and the yellow tone image, the blue tone image and the green tone image are collectively referred to as a single tone image; For any sample image, the single tone image in the sample image is extracted, and for any single tone image, R(n,m), G(n,m) and B(n,m) in the single tone image are extracted and marked as PR(n,m), PG(n,m) and PB(n,m) respectively; Analysis of the RGB difference threshold between different articles of the same material based on PR(n,m), PG(n,m) and PB(n,m).
2. The method of claim 1, wherein the method is a method of training a lightweight contraband identification model for a logistics scenario. The X-ray scanning of the logistics articles is specifically performed by an X-ray security inspection machine to obtain the X-ray images.
3. The method of claim 2, wherein the method is characterized by, The X-ray image is preprocessed to obtain an enhanced image of the X-ray image, including the following sub-steps: The X-ray image is denoised and sharpened; After denoising and sharpening, the X-ray image is changed to an erosion image to obtain the enhanced image.
4. The method of claim 3, wherein the method is characterized by, Based on PR(n,m), PG(n,m) and PB(n,m), the RGB difference threshold between different objects of the same material is analyzed, including the following sub-steps: The minimum values of PR(n,m), PG(n,m) and PB(n,m) are obtained, respectively, and are marked as minR, minG and minB; The difference between each PR(n,m) and minR is calculated and named as homologous R difference, the difference between each PG(n,m) and minR is calculated and named as homologous G difference, and the difference between each PB(n,m) and minR is calculated and named as homologous B difference. The homologous R difference, homologous G difference and homologous B difference in each single-tone image are calculated. The average value of the homologous R difference is calculated and marked as homologous average R difference, the average value of the homologous G difference is calculated and marked as homologous average G difference, and the average value of the homologous B difference is calculated and marked as homologous average B difference. For any two sample images in the homogenous group, marked as T1 and T2, the average value of PR(n,m) in T1 is calculated and marked as TR1, the average value of PG(n,m) in T1 is calculated and marked as TG1, the average value of PB(n,m) in T1 is calculated and marked as TB1, the average value of PR(n,m) in T2 is calculated and marked as TR2, the average value of PG(n,m) in T2 is calculated and marked as TG2, and the average value of PB(n,m) in T2 is calculated and marked as TB2. The |TR1-TR2| is calculated to obtain the heterologous average R difference, the |TG1-TG2| is calculated to obtain the heterologous average G difference, and the |TB1-TB2| is calculated to obtain the heterologous average B difference. The median value between the homologous average R difference and the heterologous average R difference is obtained and marked as R difference threshold, the median value between the homologous average G difference and the heterologous average G difference is obtained and marked as G difference threshold, and the median value between the homologous average B difference and the heterologous average B difference is obtained and marked as B difference threshold. The R difference threshold, G difference threshold and B difference threshold are the RGB difference threshold.
5. The method of claim 4, wherein the method is a method of training a lightweight contraband identification model for a logistics scenario. Based on the RGB difference threshold and the RGB color value of the enhanced image, a single object is extracted, the contour of the single object is extracted, and a contour image of the single object is obtained, including the following sub-steps: Based on the RGB difference threshold and the RGB color value of the enhanced image, the neighbor point R difference, neighbor point G difference and neighbor point B difference are calculated. Based on the neighbor point R difference, neighbor point G difference and neighbor point B difference, the single object is extracted, and the contour image of the single object is extracted.
6. The method of claim 5, wherein the method is a method of training a lightweight contraband identification model for a logistics scenario. Based on the RGB difference threshold and the RGB color value of the enhanced image, the neighbor point R difference, neighbor point G difference and neighbor point B difference are calculated, including the following sub-steps: The storage box to be scanned is named as the to-be-identified storage object, the enhanced image of the to-be-identified storage object is named as the to-be-identified image, and the single-tone image of the to-be-identified image is named as the to-be-identified single-tone image. For any to-be-identified monotone graph, a pixel point corresponding to the color tone of the to-be-identified monotone graph is randomly selected and marked as a starting point, the R color, G color and B color of the starting point are obtained and marked as QR, QG and QB respectively, a pixel point adjacent to the starting point is named as an adjacent point, and the R color, G color and B color of the adjacent point are obtained and marked as LR, LG and LB respectively; |QR-LR| is calculated to obtain the R difference of the adjacent point, |QG-LG| is calculated to obtain the G difference of the adjacent point, and |QB-LB| is calculated to obtain the B difference of the adjacent point.
7. The method of claim 6, wherein the method is a method of training a lightweight contraband identification model for a logistics scenario. Based on the R difference of the adjacent point, the G difference of the adjacent point and the B difference of the adjacent point, an article single piece is extracted, and the contour image of the article single piece comprises the following sub-steps: It is judged whether the R difference of the adjacent point is less than or equal to the R difference threshold value, whether the G difference of the adjacent point is less than or equal to the G difference threshold value, and whether the B difference of the adjacent point is less than or equal to the B difference threshold value, and if all are yes, a pixel homologous signal is output, otherwise a pixel heterologous signal is output; If the pixel homologous signal is output, the adjacent point is marked as the starting point, if a new starting point appears, the corresponding adjacent point is analyzed again until there is no new starting point; The image composed of the starting point is marked as an article single piece, the OpenCV edge detection technology is used to extract the contour of the article single piece to obtain the contour image of the article single piece; The starting point is removed, and the starting point is randomly selected again until all the pixel points in the to-be-identified monotone graph become pure white; The average values of the R color, G color and B color of each article single piece are calculated respectively to obtain R average color, G average color and B average color, the R average color, G average color and B average color of any two article single pieces are compared, if the differences of the R average color, G average color and B average color are all less than or equal to the R difference threshold value, G difference threshold value and B difference threshold value respectively, the corresponding two article single pieces are marked as homologous analysis articles; The two contour lines closest to each other between the homologous analysis articles are found and marked as to-be-analyzed contour lines, it is judged whether the to-be-analyzed contour lines belong to the article single pieces other than the homologous analysis articles, if yes, the homologous analysis articles are integrated into the same article single piece and the contour image is extracted again.
8. The method of claim 7, wherein the method is a method of training a lightweight contraband identification model for a logistics scenario. Random number of different types of contraband are selected and placed in the storage box, the contraband in the storage box are marked as contraband samples, the contour image of the contraband samples is extracted and marked as a sample contour, and the sample contour and the contraband contour in the contraband contour dataset are analyzed according to the following sub-steps: A second sample number of storage boxes are set, and random number of different types of contraband are placed in each storage box, and the storage boxes are marked as sample boxes; For any sample box, the contour image of each article single piece in the sample box is extracted and marked as a sample contour, and each sample contour corresponds to a contraband sample; A contraband contour dataset is constructed, and the contraband contour dataset stores the contour images of all types of contraband of different brands, different sizes and different appearances, i.e. contraband contours; The contraband contour of the contraband sample in the contraband contour dataset is found and marked as an original contour, the sample contour corresponding to the contraband sample is analyzed for similarity with the original contour, the obtained similarity is named as a sample similarity; Sample similarity of each contraband sample in each sample box is analyzed, and a minimum value is found and marked as a contour similarity threshold.
9. The method of claim 8, wherein the method is a method of training a lightweight contraband identification model for a logistics scenario. Based on the contour similarity threshold, the item contour is compared with the contraband contours in the contraband contour dataset to determine whether there is contraband, including the following sub-steps: After the training of the lightweight contraband identification model is completed, when identifying the contraband, the contour image of the single item in the X-ray image is extracted and named as the item contour. The hue of the single-color tone in which the single item is located is obtained and marked as the target hue. The contraband contours of the contraband containing the target hue in the contraband contour dataset are found and marked as the target contour set. The similarity of the item contour and each contraband contour in the target contour set is analyzed to obtain the item similarity, and the maximum value in the item similarity is found and marked as the target similarity. The target similarity is compared with the contour similarity threshold, and if the target similarity is greater than or equal to the contour similarity threshold, the single item is marked as contraband, otherwise, an item compliance signal is output.
Citation Information
Patent Citations
Contraband express sorting method
CN116618319A
Cigarette cut tobacco crimpness quantification characterization method
CN108871187A
Luggage contraband detection method and device based on characteristic difference
CN117523266A