A method and device for detecting the quality of a hand-rolled cigar, and an electronic device

CN118172350BActive Publication Date: 2026-09-25HUBEI CHINA TOBACCO INDUSTRY CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202410401361.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-04-03
Publication Date
2026-09-25
Estimated Expiration
2044-04-03

AI Technical Summary

Technical Problem

[0002]近年来,随着市场对雪茄需求的提高以及雪茄年产量的增加,要完成生产过程多品规、大批量的人工检测,将导致大量人力成本的投入

Benefits of technology

[0014]本说明书实施例提供的方法及装置,无需大量的算力便能快速高效且智能化的对流水线上的手卷雪茄进行缺陷质量检测,避免人工检测的疏漏,提高了雪茄的质量,还节省人力成本。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118172350B_ABST
    Figure CN118172350B_ABST
Patent Text Reader

Abstract

Embodiments of the present specification disclose a method and device for detecting the quality of hand-rolled cigars and an electronic device. The method comprises obtaining an initial image of a cigar to be detected, and constructing an x-axis projection histogram and a y-axis projection histogram; constructing a fitting curve based on polynomial fitting to determine the y-value range of the cigar to be detected; determining the x-axis segmentation coordinates of the cigar to be detected, and determining the y-axis segmentation coordinates of the cigar to be detected; determining a cigar image, generating a binary image corresponding to the cigar image, and generating a quality detection result based on the zero-pixel proportion of the binary image. Embodiments of the present specification can quickly and efficiently detect the defects of hand-rolled cigars on a production line without requiring a large amount of computing power, avoiding the omissions of manual detection, improving the quality of cigars, and saving labor costs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This specification relates to data processing technology in one or more embodiments, and more particularly to a method, apparatus and electronic device for quality inspection of hand-rolled cigars. Background Technology

[0002] In recent years, with the increasing market demand for cigars and the rise in annual cigar production, the need for large-scale, multi-variety manual inspection during the production process has resulted in significant labor costs. Furthermore, manual inspection suffers from drawbacks such as low efficiency, large space requirements, relatively outdated equipment, insufficient accuracy to meet quality standards, and errors in manually recorded data. While advancements in instrument manufacturing technology allow for more accurate measurements of parameters like weight, length, and circumference of hand-rolled cigars, most visual defects still rely on visual inspection, leading to considerable errors. Additionally, although deep learning methods have significantly improved defect detection, these algorithms require a large number of training samples and substantial computing power, hindering their integration into production line equipment. Therefore, currently, there is no suitable method for efficient and intelligent defect detection of hand-rolled cigars on a production line. Summary of the Invention

[0003] To address the aforementioned problems, this specification describes one or more embodiments of a method, apparatus, and electronic device for quality testing of hand-rolled cigars.

[0004] According to a first aspect, a method for quality inspection of hand-rolled cigars is provided, the method comprising: Obtain an initial image of the cigar to be detected, generate an initial binarized image corresponding to the initial image, and construct the x-axis projection histogram and y-axis projection histogram of the initial binarized image; The fitting curve of the y-axis projection histogram is constructed based on polynomial fitting, and the range of y-values ​​of the cigar to be detected is determined according to the trough position of the fitting curve. The x-axis segmentation coordinates of the cigar to be tested are determined based on the x-axis projection histogram, and the y-axis segmentation coordinates of the cigar to be tested are determined based on the y-value range and the y-axis projection histogram. The cigar image is determined based on the x-axis segmentation coordinates and y-axis segmentation coordinates, a cigar binarized image corresponding to the cigar image is generated, and the quality detection result of the detected cigar is generated based on the proportion of zero-value pixels in the cigar binarized image.

[0005] Preferably, acquiring the initial image of the cigar to be detected includes: After identifying the cigar to be detected using laser marking, an initial image of the cigar to be detected is acquired using a high-speed linear CCD camera.

[0006] Preferably, generating the initial binarized image corresponding to the initial image includes: The initial image is cropped based on the similarity calculation with the template image to obtain a cropped image; Generate an initial binarized image corresponding to the cropped image.

[0007] Preferably, the step of cropping the initial image based on similarity calculation with the template image to obtain a cropped image includes: The initial image is cropped based on a preset cropping ratio to obtain the cropped image; The cropped image is resampled, grayscaled, and median filtered to obtain a preprocessed image; The preprocessed image is cropped based on the similarity calculation with the template image to obtain the cropped image.

[0008] Preferably, determining the y-axis segmentation coordinates of the cigar to be detected based on the y-value range and the y-axis projection histogram includes: Within the range of y values, determine the upper and lower boundaries of the cigar, and compare the y-axis projection histogram and the fitted curve; For any x value corresponding to the upper boundary of the cigar, the larger y value in the y-axis projection histogram and the fitted curve is taken as the upper boundary y value; For any x value corresponding to the lower boundary of the cigar, the smaller y value in the y-axis projection histogram and the fitted curve is taken as the lower boundary y value; The y-axis segmentation coordinates of the cigar to be detected are determined based on the y-values ​​of the upper and lower boundaries.

[0009] Preferably, the method further includes: The cigar image is converted from the RGB color space to the YUV color space, and the luminance component of the cigar image is determined. Image blocks are extracted from the luminance component, and the differences between the image blocks and preset basic color blocks are measured to determine the cigar color of the cigar image.

[0010] Preferably, the method further includes: The moisture content and density of the cigar under test are detected based on the principle of resonant perturbation, the outer diameter of the cigar under test is detected based on a through-beam LED light curtain, and the weight of the cigar under test is detected based on a weighing sensor.

[0011] According to a second aspect, a quality testing device for hand-rolled cigars is provided, the device comprising: The acquisition module is used to acquire an initial image of the cigar to be detected, generate an initial binarized image corresponding to the initial image, and construct the x-axis projection histogram and y-axis projection histogram of the initial binarized image. The fitting module is used to construct a fitting curve of the y-axis projection histogram based on polynomial fitting, and to determine the range of y-values ​​of the cigar to be detected based on the trough position of the fitting curve. The determining module is used to determine the x-axis segmentation coordinates of the cigar to be detected based on the x-axis projection histogram, and to determine the y-axis segmentation coordinates of the cigar to be detected based on the y-value range and the y-axis projection histogram. The detection module is used to determine the cigar image based on the x-axis segmentation coordinates and y-axis segmentation coordinates, generate a cigar binarized image corresponding to the cigar image, and generate a quality detection result of the detected cigar based on the proportion of zero-value pixels in the cigar binarized image.

[0012] According to a third aspect, an electronic device is provided, including a processor and a memory; The processor is connected to the memory; The memory is used to store executable program code; The processor runs a program corresponding to the executable program code stored in the memory to perform the steps of the method provided as in the first aspect or any possible implementation thereof.

[0013] According to a fourth aspect, a computer-readable storage medium is provided having a computer program stored thereon, the computer-readable storage medium storing instructions that, when executed on a computer or processor, cause the computer or processor to perform the method provided as in the first aspect or any possible implementation thereof.

[0014] The methods and apparatus provided in the embodiments of this specification can quickly, efficiently and intelligently detect defects in hand-rolled cigars on the production line without requiring a large amount of computing power. This avoids the oversights of manual inspection, improves the quality of cigars, and saves labor costs. Attached Figure Description

[0015] 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.

[0016] Figure 1 This is a flowchart illustrating a method for quality inspection of hand-rolled cigars in one embodiment of this specification.

[0017] Figure 2 This is a schematic diagram of the structure of a quality inspection device for hand-rolled cigars in one embodiment of this specification.

[0018] Figure 3 This is a schematic diagram of the structure of an electronic device in one embodiment of this specification. Detailed Implementation

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

[0020] 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.

[0021] 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.

[0022] See Figure 1 , Figure 1 This is a flowchart illustrating a method for quality inspection of hand-rolled cigars provided in an embodiment of this application. In this embodiment, the method includes: S101. Obtain the initial image of the cigar to be detected, generate the initial binarized image corresponding to the initial image, and construct the x-axis projection histogram and y-axis projection histogram of the initial binarized image.

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

[0024] In the embodiments described in this specification, the cloud server will acquire initial images of the cigars to be inspected being transported on the conveyor belt using cameras installed on the conveyor belt. Besides the cigars, the initial images will also contain other interference items such as the conveyor belt. Therefore, the cloud server first needs to determine the outer casing of the hand-rolled cigar from the acquired initial images to represent the actual location of the cigar. To optimize the positioning results and reduce computational load, and to improve the accuracy of the outer casing coordinates, the cloud server will process the initial image using a modified coordinate axis projection method. Specifically, the cloud server will first binarize the initial image to obtain an initial binarized image. Then, it will construct the x-axis projection histogram and y-axis projection histogram corresponding to the initial binarized image based on the x-axis and y-axis directions, respectively. Subsequently, the image coordinates of the outer casing will be determined based on these two histograms.

[0025] In one possible implementation, acquiring an initial image of the cigar to be detected includes: After identifying the cigar to be detected using laser marking, an initial image of the cigar to be detected is acquired using a high-speed linear CCD camera.

[0026] In the embodiments of this specification, in order to identify hand-rolled cigars, the hand-rolled cigars can be marked with laser technology in the previous production steps. When the high-speed linear CCD camera recognizes the laser mark, it is considered that a hand-rolled cigar has entered the image shooting area. At this time, the cloud server will control the high-speed linear CCD camera to capture the image of the cigar to be detected and obtain the initial image.

[0027] In one possible implementation, generating the initial binarized image corresponding to the initial image includes: The initial image is cropped based on the similarity calculation with the template image to obtain a cropped image; Generate an initial binarized image corresponding to the cropped image.

[0028] In the embodiments described in this specification, due to the complex background of the conveyor belt in the image, to reduce the impact of background information on the cigar positioning accuracy, the cloud server will use a template matching method to find the cigar location. Specifically, the cloud server has a pre-set template image of the cigar. The cloud server will compare the initial image with the template image, calculate the similarity between the two, and regard the area with a similarity higher than the preset similarity as the area where the cigar is located. This is used to crop the initial image to obtain a cropped image. The result of template matching can only provide a relatively rough range of the outer casing of the hand-rolled cigar. Therefore, it is necessary to further determine the coordinate range of the cigar using a coordinate axis projection method.

[0029] In one possible implementation, cropping the initial image based on similarity calculation with the template image to obtain a cropped image includes: The initial image is cropped based on a preset cropping ratio to obtain the cropped image; The cropped image is resampled, grayscaled, and median filtered to obtain a preprocessed image; The preprocessed image is cropped based on the similarity calculation with the template image to obtain the cropped image.

[0030] In the embodiments described in this specification, before template matching is performed on the image, the cloud server will crop the initial image according to a preset cropping ratio to reduce computational load and background interference, which is beneficial for subsequent steps to better segment the hand-rolled cigar from the image. Generally, a region ranging from 1 / 5 to 3 / 5 of the original image, i.e., 2 / 5, is selected as the preset cropping ratio. Next, the cloud server will resample, grayscale, and perform median filtering on the cropped image to reduce noise interference.

[0031] S102. Construct a fitting curve for the y-axis projection histogram based on polynomial fitting, and determine the y-value range of the cigar to be detected based on the trough position of the fitting curve.

[0032] In the embodiments described in this specification, in practice, the y-axis projection method for processing cigar images is easily affected by the processing accuracy during the previous image preprocessing. Furthermore, because the cigar base on the conveyor belt in the image is made of black material, it is clearly different from the cigar and the metal conveyor belt structure, resulting in two distinct troughs in the y-axis projection histogram. The portion between these two troughs corresponds to the actual part of the cigar. Based on this characteristic, the cloud server constructs a fitting curve for the y-axis projection histogram using polynomial fitting. The two trough positions are then determined based on this fitting curve, and the range between these two trough positions is defined as the y-value range of the cigar to be detected.

[0033] As an example, the process of polynomial fitting can be as follows: First, an edge detection algorithm is used to extract pixels suspected of being edges. Then, one or more edge regions are selected based on these suspected edge pixels, and the edge points extracted from these regions are used as data points for polynomial fitting. Next, an appropriate polynomial model is selected, and the number of coefficients to be fitted is determined based on the order of the selected model. The coefficients of the polynomial are calculated using the least squares method or other optimization algorithms based on the data points, resulting in a polynomial function. Finally, a fitting curve is constructed based on the polynomial function.

[0034] S103. Determine the x-axis segmentation coordinates of the cigar to be tested based on the x-axis projection histogram, and determine the y-axis segmentation coordinates of the cigar to be tested based on the y-value range and the y-axis projection histogram.

[0035] In the embodiments of this specification, for the x-axis projection histogram, each column represents the number of non-zero pixels in that column of the binary image (i.e., foreground pixels), and 0 values ​​(black) are used as placeholders in the histogram. Specifically, starting from the origin of the screen coordinates, the pixel value of the i-th pixel is calculated sequentially along the x-axis direction (y=0). When the first non-zero pixel value is encountered, that point is recorded as the starting point; when a zero pixel value is encountered again, it is recorded as the ending point. If there is no ending point after traversing the image, the maximum x-axis coordinate value of the image is recorded as the ending point. By determining the area range corresponding to the foreground pixels, the x-axis segmentation coordinates of the cigar to be detected can be determined. Similarly, for the y-axis projection histogram, each row represents the number of non-zero pixels in that column of the binary image (i.e., foreground pixels), and 0 values ​​(black) are used as placeholders in the histogram. Specifically, starting from the screen coordinate origin, the pixel value of the j-th pixel is calculated sequentially along the y-axis (x=0). The point where the first non-zero pixel value is encountered is recorded as the starting point, and the point where a zero pixel value is encountered again is recorded as the ending point. If no ending point is found after traversing the image, the maximum y-axis coordinate value of the image is recorded as the ending point. By determining the region corresponding to the foreground pixels and filtering the region based on the y-value range, the y-axis segmentation coordinates of the cigar to be detected can be determined.

[0036] In one possible implementation, determining the y-axis segmentation coordinates of the cigar to be detected based on the y-value range and the y-axis projection histogram includes: Within the range of y values, determine the upper and lower boundaries of the cigar, and compare the y-axis projection histogram and the fitted curve; For any x value corresponding to the upper boundary of the cigar, the larger y value in the y-axis projection histogram and the fitted curve is taken as the upper boundary y value; For any x value corresponding to the lower boundary of the cigar, the smaller y value in the y-axis projection histogram and the fitted curve is taken as the lower boundary y value; The y-axis segmentation coordinates of the cigar to be detected are determined based on the y-values ​​of the upper and lower boundaries.

[0037] In the embodiments of this specification, the range of the cigar can be determined by the y-axis coordinates of the troughs of the fitted curve. Furthermore, the upper and lower boundaries of the cigar can be determined within the y-range based on the boundary positions of zero and non-zero values. For the upper boundary of the cigar, the larger y-value obtained by the y-axis projection method and the polynomial fitting method is selected as the final upper boundary y-value. For the lower boundary of the cigar, the smaller y-value obtained by the y-axis projection method and the polynomial fitting method is selected as the final lower boundary y-value. Finally, the cloud server determines the y-axis segmentation coordinates of the cigar to be detected based on the respective upper and lower boundary y-values.

[0038] S104. Determine the cigar image based on the x-axis segmentation coordinates and y-axis segmentation coordinates, generate a cigar binarized image corresponding to the cigar image, and generate the quality detection result of the detected cigar based on the proportion of zero-value pixels in the cigar binarized image.

[0039] In the embodiments described in this specification, based on the determined x-axis and y-axis segmentation coordinates, the cigar image can be reverse-engineered from the image before binarization, resulting in a precise representation of the cigar's position. Next, the cloud server re-binarizes the cigar image and determines the position and proportion of zero-value pixels in the binarized image. The position corresponding to the zero-value pixels is the location of the defect. The size of the defect area can be determined based on the proportion of zero-value pixels. The cloud server can pre-set different quality levels for the cigar based on different defect area ranges. Then, the quality level of the cigar can be quickly determined based on the proportion of zero-value pixels, thereby generating the corresponding quality inspection result.

[0040] In one possible implementation, the method further includes: The cigar image is converted from the RGB color space to the YUV color space, and the luminance component of the cigar image is determined. Image blocks are extracted from the luminance component, and the differences between the image blocks and preset basic color blocks are measured to determine the cigar color of the cigar image.

[0041] In the embodiments of this specification, cigar images are generally stored in the RGB color space by default. The YUV color space is better suited to representing human perception of brightness and color than the RGB color space, thus representing color information more accurately. Furthermore, YUV color space signals are more resistant to interference during transmission, better ensuring the integrity of image information. Therefore, the cloud server converts the cigar image to the YUV color space and uses the brightness component (Y component) of the cigar image to color-sort the hand-rolled cigar. Cigars are generally classified into light, medium, and dark colors, each with a pre-stored base color block. The cloud server determines the base color block with the smallest difference by calculating the difference between the image block cropped from the center region of the brightness component and each base color block. This base color block is the cigar color of the cigar image. The difference measure can be calculated using methods such as Euclidean distance, Manhattan distance, or Minkowski distance.

[0042] In one possible implementation, the method further includes: The moisture content and density of the cigar under test are detected based on the principle of resonant perturbation, the outer diameter of the cigar under test is detected based on a through-beam LED light curtain, and the weight of the cigar under test is detected based on a weighing sensor.

[0043] In the embodiments of this specification, the cloud server can also detect the moisture content and density of the cigars to be tested. Specifically, it can control the cigars to be tested to enter the resonant cavity, and through the principle of resonant perturbation, measure the frequency change and bandwidth change before and after the cigars are placed in, forming a ratio between the two. This ratio is then substituted into the moisture content calculation formula and the density calculation formula to obtain the moisture content and density of the cigars to be tested. Similarly, through the through-beam LED light curtain of the CCD laser micrometer, high-speed measurement of the outer diameter of hand-rolled cigars can be achieved. In addition, the weight of hand-rolled cigars can be detected through a belt-type high-speed, high-precision dynamic checkweighing station integrating a high-precision weighing sensor. These detection data can be comprehensively evaluated together with image defects and color separation, and a quality inspection result can be generated based on the comprehensive evaluation result.

[0044] The following will be combined with the appendix Figure 2 This application provides a detailed description of the quality inspection device for hand-rolled cigars provided in its embodiments. It should be noted that the appendix... Figure 2 The quality inspection device for hand-rolled cigars shown 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.

[0045] Please see Figure 2 , Figure 2 This is a schematic diagram of the structure of a quality inspection device for hand-rolled cigars provided in an embodiment of this application. Figure 2 As shown, the device includes: The acquisition module 201 is used to acquire an initial image of the cigar to be detected, generate an initial binarized image corresponding to the initial image, and construct the x-axis projection histogram and y-axis projection histogram of the initial binarized image. The fitting module 202 is used to construct a fitting curve of the y-axis projection histogram based on polynomial fitting, and to determine the range of y-values ​​of the cigar to be detected based on the trough position of the fitting curve. The determining module 203 is used to determine the x-axis segmentation coordinates of the cigar to be detected based on the x-axis projection histogram, and to determine the y-axis segmentation coordinates of the cigar to be detected based on the y-value range and the y-axis projection histogram. The detection module 204 is used to determine the cigar image based on the x-axis segmentation coordinates and y-axis segmentation coordinates, generate a cigar binarized image corresponding to the cigar image, and generate a quality detection result of the detected cigar based on the proportion of zero-value pixels in the cigar binarized image.

[0046] In one possible implementation, the acquisition module 201 is specifically used for: After identifying the cigar to be detected using laser marking, an initial image of the cigar to be detected is acquired using a high-speed linear CCD camera.

[0047] In one possible implementation, the acquisition module 201 is further configured to: The initial image is cropped based on the similarity calculation with the template image to obtain a cropped image; Generate an initial binarized image corresponding to the cropped image.

[0048] In one possible implementation, the acquisition module 201 is further configured to: The initial image is cropped based on a preset cropping ratio to obtain the cropped image; The cropped image is resampled, grayscaled, and median filtered to obtain a preprocessed image; The preprocessed image is cropped based on the similarity calculation with the template image to obtain the cropped image.

[0049] In one possible implementation, the determining module 203 is specifically used for: Within the range of y values, determine the upper and lower boundaries of the cigar, and compare the y-axis projection histogram and the fitted curve; For any x value corresponding to the upper boundary of the cigar, the larger y value in the y-axis projection histogram and the fitted curve is taken as the upper boundary y value; For any x value corresponding to the lower boundary of the cigar, the smaller y value in the y-axis projection histogram and the fitted curve is taken as the lower boundary y value; The y-axis segmentation coordinates of the cigar to be detected are determined based on the y-values ​​of the upper and lower boundaries.

[0050] In one possible implementation, the detection module 204 is further configured to: The cigar image is converted from the RGB color space to the YUV color space, and the luminance component of the cigar image is determined. Image blocks are extracted from the luminance component, and the differences between the image blocks and preset basic color blocks are measured to determine the cigar color of the cigar image.

[0051] In one possible implementation, the detection module 204 is further configured to: The moisture content and density of the cigar under test are detected based on the principle of resonant perturbation, the outer diameter of the cigar under test is detected based on a through-beam LED light curtain, and the weight of the cigar under test is detected based on a weighing sensor.

[0052] 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.

[0053] 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.

[0054] 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 processor 301, at least one network interface 304, user interface 303, memory 305, and at least one communication bus 302.

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

[0056] 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.

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

[0058] The processor 301 may include one or more processing cores. The processor 301 connects to various parts within the electronic device 300 using various interfaces and lines, and performs various functions 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 processor 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 processor 301 may integrate one or a combination of several of the following: Central Processing Unit (CPU), Graphics Processing Unit (GPU), and 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 processor 301.

[0059] 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 can 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 processor 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.

[0060] 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 processor 301 can be used to call the hand-rolled cigar quality detection application stored in the memory 305 and specifically perform the following operations: Obtain an initial image of the cigar to be detected, generate an initial binarized image corresponding to the initial image, and construct the x-axis projection histogram and y-axis projection histogram of the initial binarized image; The fitting curve of the y-axis projection histogram is constructed based on polynomial fitting, and the range of y-values ​​of the cigar to be detected is determined according to the trough position of the fitting curve. The x-axis segmentation coordinates of the cigar to be tested are determined based on the x-axis projection histogram, and the y-axis segmentation coordinates of the cigar to be tested are determined based on the y-value range and the y-axis projection histogram. The cigar image is determined based on the x-axis segmentation coordinates and y-axis segmentation coordinates, a cigar binarized image corresponding to the cigar image is generated, and the quality detection result of the detected cigar is generated based on the proportion of zero-value pixels in the cigar binarized image.

[0061] 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.

[0062] 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.

[0063] 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.

[0064] 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.

[0065] 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.

[0066] 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.

[0067] 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.

[0068] 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.

[0069] 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 quality inspection of hand-rolled cigars, characterized in that, The method includes: Obtain an initial image of the cigar to be detected, generate an initial binarized image corresponding to the initial image, and construct the x-axis projection histogram and y-axis projection histogram of the initial binarized image; The fitting curve of the y-axis projection histogram is constructed based on polynomial fitting, and the range of y-values ​​of the cigar to be detected is determined according to the trough position of the fitting curve. The x-axis segmentation coordinates of the cigar to be tested are determined based on the x-axis projection histogram, and the y-axis segmentation coordinates of the cigar to be tested are determined based on the y-value range and the y-axis projection histogram. The cigar image is determined based on the x-axis segmentation coordinates and y-axis segmentation coordinates, a cigar binarized image corresponding to the cigar image is generated, and the quality detection result of the detected cigar is generated based on the proportion of zero-value pixels in the cigar binarized image. Determining the y-axis segmentation coordinates of the cigar to be detected based on the y-value range and the y-axis projection histogram includes: Within the range of y values, determine the upper and lower boundaries of the cigar, and compare the y-axis projection histogram and the fitted curve; For any x value corresponding to the upper boundary of the cigar, the larger y value in the y-axis projection histogram and the fitted curve is taken as the upper boundary y value; For any x value corresponding to the lower boundary of the cigar, the smaller y value in the y-axis projection histogram and the fitted curve is taken as the lower boundary y value; The y-axis segmentation coordinates of the cigar to be detected are determined based on the y-values ​​of the upper and lower boundaries.

2. The method according to claim 1, characterized in that, The process of obtaining an initial image of the cigar to be detected includes: After identifying the cigar to be detected using laser marking, an initial image of the cigar to be detected is acquired using a high-speed linear CCD camera.

3. The method according to claim 1, characterized in that, The generation of the initial binarized image corresponding to the initial image includes: The initial image is cropped based on the similarity calculation with the template image to obtain a cropped image; Generate an initial binarized image corresponding to the cropped image.

4. The method according to claim 3, characterized in that, The cropping of the initial image based on similarity calculation with the template image to obtain the cropped image includes: The initial image is cropped based on a preset cropping ratio to obtain the cropped image; The cropped image is resampled, grayscaled, and median filtered to obtain a preprocessed image; The preprocessed image is cropped based on the similarity calculation with the template image to obtain the cropped image.

5. The method according to claim 1, characterized in that, The method further includes: The cigar image is converted from the RGB color space to the YUV color space, and the luminance component of the cigar image is determined. Image blocks are extracted from the luminance component, and the differences between the image blocks and preset basic color blocks are measured to determine the cigar color of the cigar image.

6. The method according to claim 1, characterized in that, The method further includes: The moisture content and density of the cigar under test are detected based on the principle of resonant perturbation, the outer diameter of the cigar under test is detected based on a through-beam LED light curtain, and the weight of the cigar under test is detected based on a weighing sensor.

7. A quality inspection device for hand-rolled cigars, characterized in that, The device includes: The acquisition module is used to acquire an initial image of the cigar to be detected, generate an initial binarized image corresponding to the initial image, and construct the x-axis projection histogram and y-axis projection histogram of the initial binarized image. The fitting module is used to construct a fitting curve of the y-axis projection histogram based on polynomial fitting, and to determine the range of y-values ​​of the cigar to be detected based on the trough position of the fitting curve. The determining module is used to determine the x-axis segmentation coordinates of the cigar to be detected based on the x-axis projection histogram, and to determine the y-axis segmentation coordinates of the cigar to be detected based on the y-value range and the y-axis projection histogram. The detection module is used to determine the cigar image based on the x-axis segmentation coordinates and y-axis segmentation coordinates, generate a cigar binarized image corresponding to the cigar image, and generate a quality detection result of the detected cigar based on the proportion of zero-value pixels in the cigar binarized image. The determining module is specifically used for: Within the range of y values, determine the upper and lower boundaries of the cigar, and compare the y-axis projection histogram and the fitted curve; For any x value corresponding to the upper boundary of the cigar, the larger y value in the y-axis projection histogram and the fitted curve is taken as the upper boundary y value; For any x value corresponding to the lower boundary of the cigar, the smaller y value in the y-axis projection histogram and the fitted curve is taken as the lower boundary y value; The y-axis segmentation coordinates of the cigar to be detected are determined based on the y-values ​​of the upper and lower boundaries.

8. 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-6.

9. A computer-readable storage medium having a computer program stored thereon, the computer-readable storage medium storing instructions that, when executed on a computer or processor, cause the computer or processor to perform the steps of the method as claimed in any one of claims 1-6.

Citation Information

Patent Citations

  • File image segmentation method and device, computer device and storage medium

    CN110728687A