A method and apparatus for detecting mold and impurities in tobacco packs before slicing.

By performing mean filtering, RGB decomposition, and contrast enhancement on tobacco leaf images, a detection model was constructed, which solved the problems of efficiency and accuracy in detecting mold and debris on the surface of tobacco packs, and achieved efficient quality control of tobacco packs.

CN115578371BActive Publication Date: 2026-05-26HUBEI CHINA TOBACCO INDUSTRY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
HUBEI CHINA TOBACCO INDUSTRY CO LTD
Filing Date
2022-10-31
Publication Date
2026-05-26

AI Technical Summary

Technical Problem

Existing technologies cannot effectively monitor mold and debris on the surface of cigarette packs, resulting in low efficiency and poor accuracy of manual inspections, and there is a risk of missed detections.

Method used

An image processing method based on tobacco leaf debris and mold was adopted. A detection model was constructed by mean filtering, RGB color channel decomposition, single threshold segmentation and contrast enhancement to identify debris and mold in tobacco leaves.

Benefits of technology

This improved the efficiency and accuracy of cigarette pack inspection, reduced the risk of underreporting small-area mold and debris, and ensured the quality of cigarette packs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115578371B_ABST
    Figure CN115578371B_ABST
Patent Text Reader

Abstract

This invention discloses a method and apparatus for detecting mold and debris on tobacco bales before slicing. The method includes acquiring images of tobacco leaves containing debris; performing mean filtering on the images; decomposing the processed images into RGB color channels; and performing single-threshold segmentation on the images corresponding to each RGB color channel to obtain tobacco leaf debris training data. Next, acquiring images of moldy tobacco leaves; performing contrast enhancement processing on the moldy tobacco leaves; and performing single-threshold segmentation on the processed images to obtain moldy tobacco leaves training data. A detection model is constructed based on the training data of moldy tobacco leaves and the training data of moldy tobacco leaves. Newly received tobacco leaf images are then processed based on the detection model to generate tobacco leaf detection results. This method reduces the risk of missed detections of small-area mold or debris, ensures the quality of tobacco bales, and improves detection efficiency and accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of tobacco technology, and more specifically, to a method and apparatus for detecting mold and impurities before slicing tobacco bales. Background Technology

[0002] Currently, the FT531 unpacking system has a total of 3 CCD vision systems, which respectively detect the packing straps of the cigarette box, the cardboard on the upper surface of the cigarette pack, and the cardboard on the lower surface of the cigarette pack. However, it cannot monitor surface mold or debris (cardboard, plastic bags, cable ties, etc. that have fallen onto the side of the cigarette pack), which poses a potential quality hazard due to mold and debris.

[0003] Therefore, manual visual inspection of cigarette packs is still required. However, there are two problems with this method: First, it requires multiple workstations to inspect all six sides of the pack for mold and debris, which is labor-intensive. Second, prolonged manual work can easily cause visual fatigue, increasing the risk of missing small areas of mold or debris. Summary of the Invention

[0004] To address the aforementioned issues, this application provides a method and apparatus for detecting mold and impurities in tobacco packs before slicing.

[0005] In a first aspect, embodiments of this application provide a method for detecting mold and impurities based on pre-sliced ​​tobacco packs, the method comprising:

[0006] Acquire tobacco leaf debris images, perform mean filtering on the tobacco leaf debris images, decompose the processed tobacco leaf debris images according to RGB color channels, and perform single threshold segmentation on the tobacco leaf debris images corresponding to each RGB color channel to obtain tobacco leaf debris training data.

[0007] Acquire tobacco leaf mold images, perform contrast enhancement processing on the tobacco leaf mold images, and then perform single threshold segmentation on the processed tobacco leaf mold images to obtain tobacco leaf mold training data.

[0008] A detection model is constructed based on the training data of tobacco leaf debris and tobacco leaf mold, and the newly received tobacco leaf images are processed based on the detection model to generate tobacco leaf detection results.

[0009] Preferably, the step of decomposing the processed tobacco debris image according to RGB color channels and performing single-threshold segmentation on the tobacco debris image corresponding to each RGB color channel to obtain tobacco debris training data includes:

[0010] The processed tobacco debris image is decomposed based on the RGB color channels to obtain an R channel image, a G channel image, and a B channel image. The RGB color channels include the R channel, the G channel, and the B channel.

[0011] The R-channel image, G-channel image, and B-channel image are segmented by a single threshold, and the first feature data with an area value less than a first preset threshold is extracted. The first feature data is the tobacco debris training data.

[0012] Preferably, the method further includes:

[0013] Convert the R-channel image, G-channel image, and B-channel image into an HSI-channel image;

[0014] The HSI channel image is segmented using a single threshold, and second feature data with an area value less than a second preset threshold is extracted. The second feature data is then added to the tobacco debris training data.

[0015] Preferably, the step of performing single-threshold segmentation on the processed tobacco leaf mold image to obtain tobacco leaf mold training data includes:

[0016] The processed tobacco leaf moldy image is segmented using a single threshold, and third feature data with area values ​​less than a third preset threshold are extracted. The third feature data is the tobacco leaf moldy training data.

[0017] Preferably, the detection model includes a first detection model and a second detection model;

[0018] The construction of the detection model based on the tobacco leaf debris training data and tobacco leaf mold training data includes:

[0019] Acquire training images and slice the training images. Based on the tobacco leaf debris training data and tobacco leaf mold training data, label the sliced ​​training images and train them to construct the first detection model.

[0020] Based on the training data of tobacco debris and tobacco mold, the training images are semantically segmented, labeled, and the second detection model is trained and constructed.

[0021] Preferably, the step of processing the newly received tobacco leaf image based on the detection model to generate tobacco leaf detection results includes:

[0022] The newly received tobacco leaf image is sliced, and the sliced ​​tobacco leaf image is imported into the first detection model to obtain a first judgment result;

[0023] The tobacco leaf image is imported into the second detection model to obtain a second judgment result;

[0024] The tobacco leaf detection results are generated based on the first and second judgment results.

[0025] Secondly, embodiments of this application provide a detection device for moldy impurities before slicing tobacco packages, the device comprising:

[0026] The first acquisition module is used to acquire tobacco leaf debris images, perform mean filtering on the tobacco leaf debris images, decompose the processed tobacco leaf debris images according to RGB color channels, and perform single threshold segmentation on the tobacco leaf debris images corresponding to each RGB color channel to obtain tobacco leaf debris training data.

[0027] The second acquisition module is used to acquire tobacco leaf mold images, perform contrast enhancement processing on the tobacco leaf mold images, and perform single threshold segmentation on the processed tobacco leaf mold images to obtain tobacco leaf mold training data.

[0028] The detection module is used to construct a detection model based on the tobacco leaf debris training data and tobacco leaf mold training data, and to process newly received tobacco leaf images based on the detection model to generate tobacco leaf detection results.

[0029] Thirdly, embodiments of this application provide an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the method provided as in the first aspect or any possible implementation of the first aspect.

[0030] Fourthly, embodiments of this application provide a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the method provided as in the first aspect or any possible implementation thereof.

[0031] The beneficial effects of this invention are as follows: by separately processing training data on tobacco leaf debris and training data on tobacco leaf mold to construct a detection model for detecting tobacco packs, the risk of underreporting small-area mold or debris is reduced, ensuring the quality of tobacco packs and improving detection efficiency and accuracy. Attached Figure Description

[0032] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0033] Figure 1 A flowchart illustrating a method for detecting mold and impurities before slicing cigarette packs, provided in this application embodiment;

[0034] Figure 2A schematic diagram of a detection device for mold and impurities before slicing tobacco packs, provided in an embodiment of this application;

[0035] Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0036] The technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings.

[0037] In the following description, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance. The following description provides multiple embodiments of this application, which can be substituted or combined with each other. Therefore, this application can also be considered to include all possible combinations of the same and / or different embodiments described. Thus, if one embodiment includes features A, B, and C, and another embodiment includes features B and D, then this application should also be considered to include embodiments containing one or more other possible combinations of A, B, C, and D, even if such embodiments are not explicitly described in the following text.

[0038] The following description provides examples and does not limit the scope, applicability, or examples set forth in the claims. Changes may be made to the function and arrangement of the described elements without departing from the scope of this application. Various processes or components may be appropriately omitted, substituted, or added to the examples. For example, the described methods may be performed in a different order than described, and various steps may be added, omitted, or combined. Furthermore, features described with respect to some examples may be combined into other examples.

[0039] See Figure 1 , Figure 1 This is a schematic flowchart illustrating a method for detecting mold and impurities before slicing tobacco packages, provided in an embodiment of this application. In this embodiment, the method includes:

[0040] S101. Obtain tobacco debris images, perform mean filtering on the tobacco debris images, decompose the processed tobacco debris images according to RGB color channels, and perform single threshold segmentation on the tobacco debris images corresponding to each RGB color channel to obtain tobacco debris training data.

[0041] The entity executing this application may be a cloud server.

[0042] In this embodiment of the application, in order to detect impurities and mold in tobacco leaves, the cloud server needs to construct a detection model for detecting impurities and mold in tobacco leaf images. To this end, the tobacco leaf images containing impurities and tobacco leaf images containing mold used to train the model need to be processed separately. These images can be selected from historical data.

[0043] For images of tobacco debris, the first step is to preprocess them using mean filtering. Mean filtering linearly smooths the grayscale values ​​of all input images. The filter matrix consists of 1 (calculated as equal) and a size of Mask Height x Mask Width. The result of the convolution is divided by the mask height x mask width. For edge processing, grayscale values ​​are reflected to the image edges. The pixel value at any point in the mean filtering is the mean of the surrounding N / times M pixels.

[0044] In order to better identify and distinguish debris, the preprocessed tobacco debris image is decomposed into RGB color channels to obtain images of each color channel. Then, each color channel image is segmented according to a single threshold to determine the tobacco debris training data for training.

[0045] In one possible implementation, the step of decomposing the processed tobacco debris image according to RGB color channels and performing single-threshold segmentation on the tobacco debris image corresponding to each RGB color channel to obtain tobacco debris training data includes:

[0046] The processed tobacco debris image is decomposed based on the RGB color channels to obtain an R channel image, a G channel image, and a B channel image. The RGB color channels include the R channel, the G channel, and the B channel.

[0047] The R-channel image, G-channel image, and B-channel image are segmented by a single threshold, and the first feature data with an area value less than a first preset threshold is extracted. The first feature data is the tobacco debris training data.

[0048] In this embodiment, the preprocessed tobacco debris image is decomposed according to the RGB color channels to obtain R channel image, G channel image and B channel image. Then, feature segmentation is performed in each channel according to the area size and a first preset threshold to extract the first feature data corresponding to the debris.

[0049] In one possible implementation, the method further includes:

[0050] Convert the R-channel image, G-channel image, and B-channel image into an HSI-channel image;

[0051] The HSI channel image is segmented using a single threshold, and second feature data with an area value less than a second preset threshold is extracted. The second feature data is then added to the tobacco debris training data.

[0052] In this embodiment, the images of the RGB three color channels are also converted into HSI channel images, thereby performing a second feature data extraction process for single-threshold segmentation of the HSI channel images. Ultimately, this achieves the following: threshold segmentation of the R channel image extracts reddish impurities; threshold segmentation of the G channel image extracts greenish impurities; threshold segmentation of the B channel image extracts bluish impurities; and threshold segmentation of the S channel image of the HSI image extracts highly saturated impurities. Furthermore, an SG filter can be used to filter the image, thereby employing SG difference images to address the problem of false alarms caused by reflective tobacco leaves in red.

[0053] S102. Obtain tobacco leaf mold images, perform contrast enhancement processing on the tobacco leaf mold images, and then perform single threshold segmentation on the processed tobacco leaf mold images to obtain tobacco leaf mold training data.

[0054] In this embodiment, mold in tobacco leaves is not as easily distinguishable as debris. Therefore, a contrast enhancement method is used to preprocess the tobacco leaf mold image to enhance the high-frequency areas (edges and corners). This process can use low-pass filtering (mean_image). The contrast-enhanced gray value (res) is calculated from the filtered gray value (mean) and the original gray value (orig) as follows:

[0055] res:=round((orig - mean)*Favctor + orig

[0056] After completing the preprocessing to enhance contrast, the processed image is then segmented using a single threshold to obtain tobacco mold training data for mold recognition training.

[0057] In one possible implementation, the step of performing single-threshold segmentation on the processed tobacco leaf mold image to obtain tobacco leaf mold training data includes:

[0058] The processed tobacco leaf moldy image is segmented using a single threshold, and third feature data with area values ​​less than a third preset threshold are extracted. The third feature data is the tobacco leaf moldy training data.

[0059] In this embodiment of the application, for the preprocessed tobacco leaf moldy image, the moldy part and the normal part can be distinguished well. Therefore, the image can be segmented by a single threshold, and the third feature data corresponding to the smaller area, i.e. the moldy part, can be extracted according to the area as the tobacco leaf moldy training data.

[0060] The first preset threshold, the second preset threshold, and the third preset threshold can be set to the same value or different values.

[0061] S103. Construct a detection model based on the training data of tobacco leaf debris and tobacco leaf mold, and process the newly received tobacco leaf images based on the detection model to generate tobacco leaf detection results.

[0062] In this embodiment, a detection model can be trained and constructed using training data on tobacco debris and tobacco mold. When a new tobacco leaf image requiring debris and mold identification is received, the detection model processes the image to generate the detection result. The detection model can be a neural convolutional network model, comprising an input layer, a hidden layer, a fully connected layer, and an output layer. The input layer is used to input the tobacco leaf image.

[0063] In one possible implementation, the detection model includes a first detection model and a second detection model;

[0064] The construction of the detection model based on the tobacco leaf debris training data and tobacco leaf mold training data includes:

[0065] Acquire training images and slice the training images. Based on the tobacco leaf debris training data and tobacco leaf mold training data, label the sliced ​​training images and train them to construct the first detection model.

[0066] Based on the training data of tobacco debris and tobacco mold, the training images are semantically segmented, labeled, and the second detection model is trained and constructed.

[0067] In this embodiment, considering that tobacco leaf images may have obvious impurities or subtle mold characteristics in reality, a first detection model and a second detection model are trained for more efficient identification, achieving cascaded detection. Specifically, the training process of the first detection model involves first slicing the training image into 64*64 pixels (adjustable according to the classification network), then labeling and classifying the sliced ​​image (normal, moldy, defective) based on features from the two types of training data, and finally inputting the image into the training dataset to output the model. The second detection model directly labels the image using a traditional semantic segmentation algorithm and trains it, thus outputting the model.

[0068] In one possible implementation, the step of processing the newly received tobacco leaf image based on the detection model to generate a tobacco leaf detection result includes:

[0069] The newly received tobacco leaf image is sliced, and the sliced ​​tobacco leaf image is imported into the first detection model to obtain a first judgment result;

[0070] The tobacco leaf image is imported into the second detection model to obtain a second judgment result;

[0071] The tobacco leaf detection results are generated based on the first and second judgment results.

[0072] In this embodiment, newly received tobacco leaf images are detected using a first detection model and a second detection model to obtain a first judgment result and a second judgment result. By integrating the first judgment result and the second judgment result, a comprehensive tobacco leaf detection result is generated to characterize whether there are impurities and mold in the tobacco leaf image.

[0073] The following will be combined with the appendix Figure 2 This application provides a detailed description of the detection device for mold and impurities based on pre-slicing tobacco packs, as provided in the embodiments of this application. It should be noted that the appendix... Figure 2 The device shown is for detecting mold and impurities in tobacco packages before slicing, and is used to perform the functions described in this application. Figure 1 The methods shown in the embodiments are for illustrative purposes only, illustrating the parts relevant to the embodiments of this application. For specific technical details not disclosed, please refer to this application. Figure 1 The example shown.

[0074] Please see Figure 2 , Figure 2 This is a schematic diagram of a detection device for mold and impurities before slicing tobacco packs, provided in an embodiment of this application. Figure 2 As shown, the device includes:

[0075] The first acquisition module 201 is used to acquire tobacco debris images, perform mean filtering on the tobacco debris images, decompose the processed tobacco debris images according to RGB color channels, and perform single threshold segmentation on the tobacco debris images corresponding to each RGB color channel to obtain tobacco debris training data.

[0076] The second acquisition module 202 is used to acquire tobacco leaf mold images, perform contrast enhancement processing on the tobacco leaf mold images, and perform single threshold segmentation on the processed tobacco leaf mold images to obtain tobacco leaf mold training data.

[0077] The detection module 203 is used to construct a detection model based on the tobacco leaf debris training data and tobacco leaf mold training data, and to process newly received tobacco leaf images based on the detection model to generate tobacco leaf detection results.

[0078] In one possible implementation, the first acquisition module 201 includes:

[0079] The decomposition unit is used to decompose the processed tobacco debris image based on the RGB color channels to obtain an R channel image, a G channel image, and a B channel image, wherein the RGB color channels include the R channel, the G channel, and the B channel;

[0080] The first extraction unit is used to perform single-threshold segmentation on the R-channel image, G-channel image and B-channel image respectively, and extract first feature data with an area value less than a first preset threshold. The first feature data is the tobacco leaf debris training data.

[0081] In one possible implementation, the device further includes:

[0082] The conversion module is used to convert the R-channel image, G-channel image, and B-channel image into an HSI-channel image;

[0083] The extraction module is used to perform single-threshold segmentation on the HSI channel image, extract second feature data with an area value less than a second preset threshold, and add the second feature data to the tobacco debris training data.

[0084] In one possible implementation, the second acquisition module 202 includes:

[0085] The second extraction unit is used to perform single-threshold segmentation on the processed tobacco leaf mold image and extract third feature data whose area value is less than a third preset threshold. The third feature data is the tobacco leaf mold training data.

[0086] In one possible implementation, the detection module 203 includes:

[0087] The first construction unit is used to acquire training images, slice the training images, label the sliced ​​training images based on the tobacco leaf debris training data and tobacco leaf mold training data, and train them to construct the first detection model.

[0088] The second construction unit is used to perform semantic segmentation on the training image based on the tobacco leaf debris training data and the tobacco leaf mold training data, label the training image, and train and construct the second detection model.

[0089] In one possible implementation, the detection module 203 further includes:

[0090] The first judgment unit is used to slice the newly received tobacco leaf image, import the sliced ​​tobacco leaf image into the first detection model, and obtain the first judgment result.

[0091] The second judgment unit is used to import the tobacco leaf image into the second detection model to obtain a second judgment result;

[0092] The generation unit is used to generate tobacco leaf detection results based on the first judgment result and the second judgment result.

[0093] Those skilled in the art will clearly understand that the technical solutions of the embodiments of this application can be implemented by means of software and / or hardware. In this specification, "unit" and "module" refer to software and / or hardware that can independently complete or cooperate with other components to complete a specific function, wherein the hardware may be, for example, a field-programmable gate array (FPGA), an integrated circuit (IC), etc.

[0094] Each processing unit and / or module in the embodiments of this application can be implemented by an analog circuit that implements the functions described in the embodiments of this application, or by software that executes the functions described in the embodiments of this application.

[0095] See Figure 3 It shows a schematic diagram of the structure of an electronic device according to an embodiment of this application, which can be used to implement... Figure 1 The method in the illustrated embodiment. (As shown) Figure 3 As shown, the electronic device 300 may include: at least one central processing unit 301, at least one network interface 304, user interface 303, memory 305, and at least one communication bus 302.

[0096] The communication bus 302 is used to enable communication between these components.

[0097] The user interface 303 may include a display screen and a camera. Optionally, the user interface 303 may also include a standard wired interface and a wireless interface.

[0098] The network interface 304 may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface).

[0099] The central processing unit 301 may include one or more processing cores. The central processing unit 301 connects to various parts within the electronic device 300 using various interfaces and lines. It executes various functions of the terminal 300 and processes data by running or executing instructions, programs, code sets, or instruction sets stored in the memory 305, and by calling data stored in the memory 305. Optionally, the central processing unit 301 may be implemented using at least one hardware form of Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), or Programmable Logic Array (PLA). The central processing unit 301 may integrate one or more of the following: a central processing unit (CPU), a graphics processing unit (GPU), and a modem. The CPU primarily handles the operating system, user interface, and applications; the GPU is responsible for rendering and drawing the content required for display; and the modem handles wireless communication. It is understood that the modem may also be implemented as a separate chip without being integrated into the central processing unit 301.

[0100] The memory 305 may include random access memory (RAM) or read-only memory. Optionally, the memory 305 may include a non-transitory computer-readable storage medium. The memory 305 may be used to store instructions, programs, code, code sets, or instruction sets. The memory 305 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as touch function, sound playback function, image playback function, etc.), instructions for implementing the above-described method embodiments, etc.; the data storage area may store data involved in the above-described method embodiments, etc. Optionally, the memory 305 may also be at least one storage device located remotely from the aforementioned central processing unit 301. Figure 3 As shown, the memory 305, which serves as a computer storage medium, may include an operating system, a network communication module, a user interface module, and program instructions.

[0101] exist Figure 3In the illustrated electronic device 300, the user interface 303 is mainly used to provide an input interface for the user and to acquire user input data; while the central processing unit 301 can be used to call the detection application based on pre-slicing mold and impurities of tobacco packs stored in the memory 305, and specifically perform the following operations:

[0102] Acquire tobacco leaf debris images, perform mean filtering on the tobacco leaf debris images, decompose the processed tobacco leaf debris images according to RGB color channels, and perform single threshold segmentation on the tobacco leaf debris images corresponding to each RGB color channel to obtain tobacco leaf debris training data.

[0103] Acquire tobacco leaf mold images, perform contrast enhancement processing on the tobacco leaf mold images, and then perform single threshold segmentation on the processed tobacco leaf mold images to obtain tobacco leaf mold training data.

[0104] A detection model is constructed based on the training data of tobacco leaf debris and tobacco leaf mold, and the newly received tobacco leaf images are processed based on the detection model to generate tobacco leaf detection results.

[0105] This application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the above-described method. The computer-readable storage medium may include, but is not limited to, any type of disk, including floppy disks, optical disks, DVDs, CD-ROMs, microdrives, as well as magneto-optical disks, ROMs, RAMs, EPROMs, EEPROMs, DRAMs, VRAMs, flash memory devices, magnetic cards or optical cards, nanosystems (including molecular memory ICs), or any type of medium or device suitable for storing instructions and / or data.

[0106] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.

[0107] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.

[0108] In the several embodiments provided in this application, it should be understood that the disclosed apparatus can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some service interface; the indirect coupling or communication connection between devices or units may be electrical or other forms.

[0109] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0110] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0111] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage device (CMD). Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a memory and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned memory includes various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.

[0112] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, which may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, etc.

[0113] The foregoing description is merely an exemplary embodiment of this disclosure and should not be construed as limiting the scope of this disclosure. Any equivalent changes and modifications made in accordance with the teachings of this disclosure shall still fall within the scope of this disclosure. Those skilled in the art will readily conceive of embodiments of this disclosure upon considering the specification and practicing the disclosure herein. This application is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not described herein. The specification and embodiments are to be considered exemplary only, and the scope and spirit of this disclosure are defined by the claims.

Claims

1. A method for detecting mold and impurities in tobacco packages before slicing, characterized in that, The method includes: Acquire tobacco leaf debris images, perform mean filtering on the tobacco leaf debris images, decompose the processed tobacco leaf debris images according to RGB color channels, and perform single threshold segmentation on the tobacco leaf debris images corresponding to each RGB color channel to obtain tobacco leaf debris training data. Acquire tobacco leaf mold images, perform contrast enhancement processing on the tobacco leaf mold images, and then perform single threshold segmentation on the processed tobacco leaf mold images to obtain tobacco leaf mold training data. A detection model is constructed based on the training data of tobacco leaf debris and tobacco leaf mold, and the newly received tobacco leaf images are processed based on the detection model to generate tobacco leaf detection results. The process of decomposing the processed tobacco debris image into RGB color channels and performing single-threshold segmentation on the tobacco debris image corresponding to each RGB color channel to obtain tobacco debris training data includes: The processed tobacco debris image is decomposed based on the RGB color channels to obtain an R channel image, a G channel image, and a B channel image. The RGB color channels include the R channel, the G channel, and the B channel. The R-channel image, G-channel image and B-channel image are segmented by a single threshold respectively, and the first feature data with an area value less than a first preset threshold is extracted. The first feature data is the tobacco debris training data. The process of performing single-threshold segmentation on the processed tobacco leaf mold image to obtain tobacco leaf mold training data includes: The processed tobacco leaf moldy image is segmented using a single threshold, and third feature data with area values ​​less than a third preset threshold are extracted. The third feature data is the tobacco leaf moldy training data.

2. The method of claim 1, wherein, The method further includes: Convert the R-channel image, G-channel image, and B-channel image into an HSI-channel image; The HSI channel image is segmented using a single threshold, and second feature data with an area value less than a second preset threshold is extracted. The second feature data is then added to the tobacco debris training data.

3. The method of claim 1, wherein, The detection model includes a first detection model and a second detection model; The construction of the detection model based on the tobacco leaf debris training data and tobacco leaf mold training data includes: Acquire training images and slice the training images. Based on the tobacco leaf debris training data and tobacco leaf mold training data, label the sliced ​​training images and train them to construct the first detection model. Based on the training data of tobacco debris and tobacco mold, the training images are semantically segmented, labeled, and the second detection model is trained and constructed.

4. The method of claim 3, wherein, The step of processing the newly received tobacco leaf images based on the detection model to generate tobacco leaf detection results includes: The newly received tobacco leaf image is sliced, and the sliced ​​tobacco leaf image is imported into the first detection model to obtain a first judgment result; The tobacco leaf image is imported into the second detection model to obtain a second judgment result; The tobacco leaf detection results are generated based on the first and second judgment results.

5. A device for detecting mold and impurities before slicing tobacco packs, characterized in that, The device includes: The first acquisition module is used to acquire tobacco leaf debris images, perform mean filtering on the tobacco leaf debris images, decompose the processed tobacco leaf debris images according to RGB color channels, and perform single threshold segmentation on the tobacco leaf debris images corresponding to each RGB color channel to obtain tobacco leaf debris training data. The second acquisition module is used to acquire tobacco leaf mold images, perform contrast enhancement processing on the tobacco leaf mold images, and perform single threshold segmentation on the processed tobacco leaf mold images to obtain tobacco leaf mold training data. The detection module is used to construct a detection model based on the tobacco leaf debris training data and tobacco leaf mold training data, and to process newly received tobacco leaf images based on the detection model to generate tobacco leaf detection results. The first acquisition module includes: The decomposition unit is used to decompose the processed tobacco debris image based on the RGB color channels to obtain an R channel image, a G channel image, and a B channel image, wherein the RGB color channels include the R channel, the G channel, and the B channel; The first extraction unit is used to perform single threshold segmentation on the R channel image, G channel image and B channel image respectively, and extract the first feature data with an area value less than the first preset threshold. The first feature data is the tobacco leaf debris training data. The second acquisition module includes: The second extraction unit is used to perform single-threshold segmentation on the processed tobacco leaf mold image and extract third feature data whose area value is less than a third preset threshold. The third feature data is the tobacco leaf mold training data.

6. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method as described in any one of claims 1-4.

7. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method as described in any one of claims 1-4.