A method, device and electronic device for optimizing cigarette packaging box scanning images

By calculating and filtering the pixel points of the scanned image of the cigarette packaging box column by column, optimizing the structured light stripe image, solving the image inaccuracy caused by laser scattering and diffuse reflection, and improving the accuracy of three-dimensional scanning.

CN114742948BActive Publication Date: 2025-02-18HUBEI CHINA TOBACCO INDUSTRY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210383147.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-13
Publication Date
2025-02-18
Estimated Expiration
2042-04-13

AI Technical Summary

Technical Problem

When detecting the ink surface of cigarette packaging box, due to the influence of surface roughness, scattering, diffuse reflection and other phenomena will occur during laser irradiation, resulting in inaccuracy of the structured light stripe image, which will affect the accuracy of the three-dimensional scanning results.

Method used

By calculating the average grayscale value of each column of pixel points in the structured light stripe image column by column, filter out the pixel points higher than the average grayscale value, zero the pixel points lower than the average grayscale value, record the number of pixel points retained until The number of retained is lower than the preset number, calculate the center position of the structured light and optimize the image.

Benefits of technology

The weak light effects caused by scattering, diffuse reflection, etc. are eliminated, the accuracy of the center position of the structured light is improved, and the accuracy of the three-dimensional image is ensured.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114742948B_ABST
    Figure CN114742948B_ABST
Patent Text Reader

Abstract

The present invention discloses a method, device and electronic device for optimizing the scanning image of a cigarette packaging box, the method comprising acquiring a structured light stripe image collected by a camera needle, calculating the average grayscale value of each current column pixel point in the structured light stripe image column by column; filtering the current column pixel points based on the average grayscale value to set the pixel grayscale value below the average grayscale value to zero; recording the number of pixel points retained, and repeating the steps of calculating the average grayscale value of each current column pixel point in the structured light stripe image column by column until the number of pixel points retained is lower than the preset number of pixel points retained; calculating the center position of the structured light based on each current column pixel point corresponding to the number of pixel points retained, and optimizing the structured light stripe image according to the center position of the structured light. The present invention eliminates the imaging influence of weak light caused by scattering, diffuse reflection, etc. on the structured light stripe image, improves the accuracy of the center position of the optimized image structured light, and thus ensures the accuracy of the three-dimensional image finally scanned.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of laser scanning technology, and in particular to a method, device and electronic equipment for optimizing scanning images of cigarette packaging boxes. Background Art

[0002] The line structured light three-dimensional scanning device fixes the laser emitter and the camera system at a certain angle so that the camera can obtain the stripe image projected by the laser on the target object, and then obtain the three-dimensional coordinate information of the surface contour of the measured object. When the laser is irradiated onto a plane without reflection and scattering, it should ideally be a thin straight light strip, and the line width at each location is the same. The grayscale value of the light spot on each column obeys the Gaussian distribution, the grayscale value at the brightest light intensity is higher, and the grayscale values ​​of the remaining pixels are smaller. However, when detecting the ink surface of the cigarette packaging box, due to the influence of the surface roughness, scattering, diffuse reflection and other phenomena will occur when the laser is irradiated onto the measured surface, and the line width at each location is also different. This is because the shadow caused by the occlusion will cause some line segments to be missing, and the reflection characteristics of the ink surface make some columns of light spots in the image no longer obey the ideal Gaussian distribution. Therefore, in actual situations, there is a deviation between the centroid position of the structured light strip of the packaging box collected by the camera and the actual position, which in turn affects the accuracy of the scanning results of the entire measurement system. Summary of the invention

[0003] In order to solve the above problems, the embodiments of the present application provide a method, device and electronic device for optimizing a scanned image of a cigarette package.

[0004] In a first aspect, an embodiment of the present application provides a method for optimizing a scanned image of a cigarette package, the method comprising:

[0005] Acquire a structured light fringe image captured by a camera for a scanned object, and calculate the average grayscale value of each current column of pixels in the structured light fringe image column by column;

[0006] The pixel points in the current column are screened based on the average grayscale value, so as to set the grayscale values ​​of pixels below the average grayscale value to zero, and the pixel grayscale value is the grayscale value of the pixel points in the current column;

[0007] Recording the number of retained pixels, and repeating the step of calculating the average grayscale value of the pixels of the current column in each column of the structured light fringe image column by column until the number of retained pixels is lower than a preset number of retained pixels, the number of retained pixels being the sum of the number of pixels of the current column that are not set to zero in each column;

[0008] The structured light center position is calculated based on each of the current column pixel points corresponding to the reserved number of pixel points, and the structured light fringe image is optimized according to the structured light center position.

[0009] Preferably, before acquiring the structured light fringe image collected by the camera for the scanned object, the method further includes:

[0010] Acquire laser data information of a laser transmitter, and determine a laser operating band based on the laser data information;

[0011] Auxiliary information for selecting a narrow-band filter is generated based on the laser operating band.

[0012] Preferably, the step of calculating the average grayscale value of pixels in each current column of the structured light fringe image column by column includes:

[0013] Dividing the structured light fringe image into a plurality of column pixel point sets column by column, and recording the column to which each column pixel point set belongs, wherein the column pixel point set includes at least one current column pixel point;

[0014] The average grayscale value of all the current column pixels in each column pixel set is calculated respectively.

[0015] Preferably, the calculating the structured light center position based on each of the current column pixels corresponding to the reserved number of pixels includes:

[0016] Respectively obtain the row order of each of the current column pixel points corresponding to the reserved number of pixel points in the column pixel point set, and determine the coordinate position of each of the current column pixel points in the structured light fringe image based on the row order and the belonging column;

[0017] An average value is calculated based on each of the coordinate positions to obtain the center position of the structured light.

[0018] Preferably, after determining the coordinate position of each pixel point in the current column in the structured light fringe image based on the row sorting and the belonging column, the method further includes:

[0019] Randomly select two coordinate positions and calculate the pixel distance between the two coordinate positions;

[0020] Repeat the step of arbitrarily selecting two of the coordinate positions until all the pixel point distances are obtained, and then construct a clustered pixel point set so that the pixel point distance between any two pixels in the current column in the clustered pixel point set is less than a preset distance;

[0021] The calculating the average value based on each of the coordinate positions to obtain the center position of the structured light includes:

[0022] The average values ​​of all the coordinate positions of each of the clustered pixel points are calculated respectively to obtain at least one structured light center position.

[0023] Preferably, after calculating the average values ​​of all the coordinate positions of each of the clustered pixel points to obtain at least one structured light center position, the method further includes:

[0024] When there are two center positions of the structured light, marking the two center positions of the structured light;

[0025] Adjusting the laser incident angle of the laser transmitter within a preset angle range, and continuously monitoring the position change of the center position of each structured light to generate a position change curve;

[0026] The two position change curves are compared, and the structured light center position corresponding to the position change curve with a relatively gentle curve change is deleted.

[0027] In a second aspect, an embodiment of the present application provides a device for optimizing a scanned image of a cigarette package, the device comprising:

[0028] An acquisition module is used to acquire a structured light fringe image collected by a camera for a scanned object, and calculate the average grayscale value of each current column of pixel points in the structured light fringe image column by column;

[0029] A screening module, used for screening the pixel points in the current column based on the average grayscale value, so as to set the grayscale value of pixels below the average grayscale value to zero, the grayscale value of the pixel being the grayscale value of the pixel points in the current column;

[0030] A recording module, used for recording the number of retained pixels, and repeating the step of calculating the average grayscale value of the pixels of the current column in each column of the structured light fringe image column by column until the number of retained pixels is lower than a preset number of retained pixels, the number of retained pixels being the sum of the number of pixels of the current column that are not set to zero in each column;

[0031] A calculation module is used to calculate the center position of the structured light based on each of the current column pixel points corresponding to the reserved number of pixel points, and optimize the structured light stripe image according to the structured light center position.

[0032] In a third aspect, an embodiment of the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the steps of the method provided in the first aspect or any possible implementation of the first aspect are implemented.

[0033] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method provided in the first aspect or any possible implementation manner of the first aspect.

[0034] The beneficial effect of the present invention is that the average gray value of each column of pixel points in the collected structured light stripe image is calculated column by column, so as to screen each pixel point in the column respectively, and only retain the pixel points with larger gray value, that is, the pixel points in the area with larger brightness, and then determine the position of the structured light center through a small number of screened pixel points. The imaging effect of weak light caused by scattering, diffuse reflection, etc. on the structured light stripe image is eliminated, and the accuracy of the center position of the optimized image structured light is improved, thereby ensuring the accuracy of the final scanned three-dimensional image. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0036] Figure 1 A schematic diagram of a flow chart of a cigarette package box scanning image optimization method provided in an embodiment of the present application;

[0037] Figure 2 A schematic diagram of the structure of a cigarette package scanning image optimization device provided in an embodiment of the present application;

[0038] Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0039] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.

[0040] In the following introduction, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance. The following introduction provides multiple embodiments of the present application, and different embodiments can be replaced or combined, so the present application can also be considered to include all possible combinations of the same and / or different embodiments recorded. Therefore, if one embodiment includes features A, B, and C, and another embodiment includes features B and D, then the present application should also be considered to include embodiments containing one or more of all other possible combinations of A, B, C, and D, although the embodiment may not be clearly recorded in the following text.

[0041] 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 functions and arrangements of the elements described without departing from the scope of the present application. Various processes or components may be appropriately omitted, substituted or added to each example. For example, the described method may be performed in an order different from the order described, and various steps may be added, omitted or combined. In addition, features described in some examples may be combined in other examples.

[0042] See also Figure 1 , Figure 1 : is a flow chart of a method for optimizing a cigarette package scanning image provided in an embodiment of the present application. In the embodiment of the present application, the method comprises:

[0043] S101, obtaining a structured light fringe image captured by a camera for a scanned object, and calculating the average grayscale value of each current column of pixel points in the structured light fringe image column by column.

[0044] The execution subject of the present application may be a controller of a line structured light three-dimensional scanning device.

[0045] The structured light fringe image in the embodiment of the present application can be understood as an image that can be captured by a camera after the laser from a laser transmitter is reflected by the surface of the scanned object.

[0046] The current column of pixels in the embodiment of the present application can be understood as any pixel in a column of pixel sets that are currently being calculated for the image.

[0047] In the embodiment of the present application, since the ink on the surface of the cigarette packaging box is irregular during actual printing, after the laser of the laser transmitter is irradiated to the surface of the box, scattering, diffuse reflection and other phenomena will occur, which will cause the stripes in the structured light stripe image to shift, that is, the obtained stripe image is not accurate enough, which will affect the accuracy of the three-dimensional surface contour finally generated. Therefore, after the present application collects the structured light stripe image through the camera, it is necessary to process and optimize the structured light stripe image before generating a three-dimensional surface contour based on the optimized structured light stripe image, so as to ensure the accuracy of the three-dimensional scanning. Specifically, since the structured light stripe image is essentially composed of a large number of pixels, the present application will first calculate the average grayscale value of each pixel in each column of the image column by column.

[0048] In one possible implementation manner, before acquiring the structured light fringe image collected by the camera for the scanned object, the method further includes:

[0049] Acquire laser data information of a laser transmitter, and determine a laser operating band based on the laser data information;

[0050] Auxiliary information for selecting a narrow-band filter is generated based on the laser operating band.

[0051] The narrow-band filter selection auxiliary information in the embodiment of the present application can be understood as information characterizing the model of the narrow-band filter that should be selected, and the applicable band of the narrow-band filter of this model is the same as the laser working band.

[0052] In an embodiment of the present application, the working band of the laser emitted by the laser transmitter can be determined through the laser data information of the laser transmitter. In order to improve the scanning accuracy, auxiliary information for selecting a narrow-band filter can be generated based on the laser working band to remind the staff to install a narrow-band filter of the corresponding type on the camera, thereby retaining the light of the laser wavelength and filtering out the rest of the interfering natural light.

[0053] In one possible implementation, calculating the average grayscale value of each current column of pixels in the structured light fringe image column by column includes:

[0054] Dividing the structured light fringe image into a plurality of column pixel point sets column by column, and recording the column to which each column pixel point set belongs, wherein the column pixel point set includes at least one current column pixel point;

[0055] The average grayscale value of all the current column pixels in each column pixel set is calculated respectively.

[0056] In the embodiment of the present application, the column pixel point set can be understood as a pixel point set consisting of all current column pixel points of the column.

[0057] In the embodiment of the present application, the entire structured light stripe image is first divided into several column pixel sets with columns as the basic unit, and the column to which each column pixel set belongs, that is, the column number to which it belongs, is recorded respectively, so as to determine the position of each column pixel set in the image later. Then, the average grayscale value corresponding to the column pixel set is calculated based on the grayscale values ​​of all the current column pixels in the column pixel set.

[0058] S102 , filtering the pixel points in the current column based on the average grayscale value, so as to set the grayscale values ​​of pixels below the average grayscale value to zero, the pixel grayscale value being the grayscale value of the pixel points in the current column.

[0059] In the embodiment of the present application, since the purpose of the present application is to exclude interference light such as scattering and diffuse reflection to ensure the accuracy of the final optimized structured light center position, and for a complete beam of incident laser, the proportion of light diverged due to the unevenness of the ink is small, so the present application will screen out the light stripe part with the strongest brightness from the stripe image as the final determined structured light center. For this reason, the present application does not calculate the average grayscale value of all pixels in the entire image, but each column calculates the average grayscale value of the column separately. Because for a beam of light, there is a gap between the light intensity in the center and the light intensity in the peripheral area. The present application only needs to screen and determine the pixel points with larger light intensity in each column. If the average grayscale value of the entire image is selected, the pixel points at the edge of the laser will be excluded, affecting the accuracy. Taking a certain column of pixel points as an example, after calculating the average grayscale value of the column, the grayscale value of each current column pixel point in the column will be compared one by one, and the current column pixel points with grayscale values ​​lower than the average grayscale value will be processed with zero pixel grayscale values ​​to complete the screening process. For the current column pixel points whose grayscale values ​​are higher than the average grayscale value, their original grayscale values ​​will be retained instead of being adjusted to a uniform value for further screening.

[0060] It is possible that at least one screening result will be obtained through the above screening process, but in fact, there may be a column where the corresponding light of the current column pixel points is not the normal reflected light of the laser. Therefore, for any column of the current column pixel points, when there is only one current column pixel point whose grayscale value is not set to zero after the screening is completed, it is necessary to compare the pixel grayscale value of the current column pixel point with the average grayscale value of the adjacent column. If the difference between the two is greater than the preset difference, it means that the grayscale difference between the only remaining current column pixel point and the pixel points obtained by screening the remaining columns is too large, and it is also not a pixel point whose grayscale value should be retained. At this time, the pixel grayscale value of the current column pixel point will also be set to zero.

[0061] S103, recording the number of retained pixels, and repeating the step of calculating the average grayscale value of the pixels in the current column of each column in the structured light stripe image column by column until the number of retained pixels is lower than the preset number of retained pixels, and the number of retained pixels is the sum of the number of pixels in the current column that are not set to zero in each column.

[0062] In the embodiment of the present application, each time the overall screening process is completed, the number of pixels that still retain grayscale values ​​is recorded, and the screening process is repeated until the recorded number of pixels is lower than the preset number (for example, 10). It is then considered that the screening has been accurate enough and the center position of the structured light can be optimized.

[0063] S104, calculating a structured light center position based on each of the current column of pixel points corresponding to the reserved number of pixel points, and optimizing the structured light fringe image according to the structured light center position.

[0064] In an embodiment of the present application, after completing the entire screening process, the current column pixels corresponding to the number of retained pixels will be determined, and the center position of the structured light will be calculated based on these current column pixels. The spot and stripe positions of the structured light stripe image are optimized to improve the accuracy of the structured light stripe image.

[0065] In one possible implementation, the calculating the structured light center position based on each of the current column pixels corresponding to the reserved number of pixels includes:

[0066] Respectively obtain the row order of each of the current column pixel points corresponding to the reserved number of pixel points in the column pixel point set, and determine the coordinate position of each of the current column pixel points in the structured light fringe image based on the row order and the belonging column;

[0067] An average value is calculated based on each of the coordinate positions to obtain the center position of the structured light.

[0068] In the embodiment of the present application, the row arrangement of the current column pixel points whose grayscale values ​​are retained in the column pixel point set is obtained, that is, the row sorting in the column pixel point set. The coordinate position of each current column pixel point whose grayscale value is retained in the structured light stripe image can be determined by row sorting and column attribution. The average coordinate of each coordinate position is calculated and the average value coordinate is used as the center position of the structured light.

[0069] In one possible implementation, after determining the coordinate position of each pixel point in the current column in the structured light fringe image based on the row sorting and the belonging column, the method further includes:

[0070] Randomly select two coordinate positions and calculate the pixel distance between the two coordinate positions;

[0071] Repeat the step of arbitrarily selecting two of the coordinate positions until all the pixel point distances are obtained, and then construct a clustered pixel point set so that the pixel point distance between any two pixels in the current column in the clustered pixel point set is less than a preset distance;

[0072] The calculating the average value based on each of the coordinate positions to obtain the center position of the structured light includes:

[0073] The average values ​​of all the coordinate positions of each of the clustered pixel points are calculated respectively to obtain at least one structured light center position.

[0074] In the embodiment of the present application, a transparent film is provided on the surface of the finished packaging box. The reflection problem of the film will also affect the effect of three-dimensional scanning, that is, when the laser is irradiated at an oblique angle, part of the light is directly reflected by the film surface, and part passes through the film to irradiate the surface of the packaging box body to generate reflection. Both reflected lights will eventually be collected by the camera, but in actual situations, the staff only wants to obtain the reflected light generated by the surface of the box body, so it is also necessary to distinguish the film reflected light. Specifically, after calculating each coordinate position, the pixel distance between each pair of coordinate positions will be calculated. When there is no film reflection, the retained current column pixels should show a certain degree of aggregation, and the pixel distance between any two pixels of the pixel points characterized by the aggregation should be within a certain range, that is, less than the preset distance. Based on this, the aggregated pixel point set will be constructed according to the pixel point distance. If there is a problem of film reflection, two aggregated pixel point sets will be generated due to the reception of two beams of reflected light, and the center position of the structured light will be calculated based on each aggregated pixel point set, so as to realize the recognition and distinction of the film and box body reflected light.

[0075] In one possible implementation manner, after calculating the average values ​​of all the coordinate positions of each of the clustered pixel points to obtain at least one structured light center position, the method further includes:

[0076] When there are two center positions of the structured light, marking the two center positions of the structured light;

[0077] Adjusting the laser incident angle of the laser transmitter within a preset angle range, and continuously monitoring the position change of the center position of each structured light to generate a position change curve;

[0078] The two position change curves are compared, and the structured light center position corresponding to the position change curve with a relatively gentle curve change is deleted.

[0079] In the embodiment of the present application, in order to determine which of the two obtained structured light center positions is the position corresponding to the required reflected light of the ink layer of the box body, after marking the two structured light center positions, the structured light center position is changed by changing the laser incident angle of the laser emitter, and the entire position change process is continuously monitored to generate two position change curves. Since the film is a plastic product, its surface is relatively smoother, so as the incident angle changes, the change trend of the change curve of the structured light center position corresponding to the film should be relatively gentle. However, due to the unevenness of the ink printing on the surface of the packaging box body, as the incident angle changes, the structured light center position will change with the uneven position and will not be stable when changing, and the fluctuation is large, which will lead to a relatively steeper change trend of the curve. Therefore, by comparing the two position change curves, it is possible to determine where the reflected light corresponds to each structured light center position, and then delete the structured light center position corresponding to the position change curve reflected by the film, that is, the relatively gentle curve change, to eliminate the interference of the film.

[0080] The following will be combined with the attached Figure 2 , the cigarette packaging box scanning image optimization device provided in the embodiment of the present application is introduced in detail. It should be noted that the attached Figure 2 The cigarette packaging box scanning image optimization device shown is used to implement the present application Figure 1 For the convenience of explanation, only the part related to the embodiment of the present application is shown. For the specific technical details not disclosed, please refer to the present application. Figure 1 The embodiment shown.

[0081] See also Figure 2 , Figure 2 Schematic diagram of the structure of a cigarette packaging box scanning image optimization device provided in an embodiment of the present application. Figure 2 As shown, the device comprises:

[0082] An acquisition module 201 is used to acquire a structured light fringe image collected by a camera for a scanned object, and calculate the average grayscale value of each current column of pixels in the structured light fringe image column by column;

[0083] A screening module 202, configured to screen the pixels in the current column based on the average grayscale value, so as to set the grayscale values ​​of pixels below the average grayscale value to zero, the grayscale value of the pixel being the grayscale value of the pixels in the current column;

[0084] A recording module 203 is used to record the number of retained pixels, and repeat the step of calculating the average grayscale value of the pixels of the current column in each column of the structured light fringe image column by column until the number of retained pixels is lower than a preset number of retained pixels, and the number of retained pixels is the sum of the number of pixels of the current column that are not set to zero in each column;

[0085] The calculation module 204 is used to calculate the center position of the structured light based on each of the current column of pixels corresponding to the reserved number of pixels, and optimize the structured light stripe image according to the center position of the structured light.

[0086] In one possible implementation, the device further comprises:

[0087] A first determination module is used to obtain laser data information of a laser transmitter and determine a laser operating band based on the laser data information;

[0088] The filtering module is used to generate narrow-band filter selection auxiliary information based on the laser working band.

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

[0090] A division unit, used for dividing the structured light fringe image into a plurality of column pixel point sets column by column, and recording the column to which each column pixel point set belongs, wherein the column pixel point set includes at least one current column pixel point;

[0091] The first calculation unit is used to respectively calculate the average grayscale value of all the current column pixel points in each column pixel point set.

[0092] In one possible implementation, the calculation module 204 includes:

[0093] A first determining unit, configured to respectively obtain the row order of each of the current column pixels corresponding to the reserved number of pixels in the column pixel set, and determine the coordinate position of each of the current column pixels in the structured light fringe image based on the row order and the belonging column;

[0094] The average value calculation unit is used to calculate the average value based on each of the coordinate positions to obtain the center position of the structured light.

[0095] In one possible implementation, the calculation module 204 further includes:

[0096] A second calculation unit is used to arbitrarily select two coordinate positions and calculate the pixel point distance between the two coordinate positions;

[0097] a repeating unit, configured to repeat the step of arbitrarily selecting two of the coordinate positions until all the pixel point distances are obtained, and then construct a clustered pixel point set so that the pixel point distance between any two pixel points in the current column in the clustered pixel point set is less than a preset distance;

[0098] The average value calculation unit comprises:

[0099] The average value calculation element is used to calculate the average value of all the coordinate positions of each of the clustered pixel points to obtain at least one structured light center position.

[0100] In one possible implementation, the calculation module 204 further includes:

[0101] a marking unit, used for marking two center positions of the structured light when there are two center positions of the structured light;

[0102] A monitoring unit, used to adjust the laser incident angle of the laser transmitter within a preset angle range, and continuously monitor the position change of the center position of each structured light to generate a position change curve;

[0103] The comparison unit is used to compare the two position change curves and delete the structured light center position corresponding to the position change curve with a relatively gentle curve change.

[0104] Those skilled in the art can clearly understand that the technical solutions of the embodiments of the present application can be implemented with the help of software and / or hardware. The "unit" and "module" in this specification refer to software and / or hardware that can independently complete or cooperate with other components to complete specific functions, where the hardware can be, for example, a field programmable gate array (FPGA), an integrated circuit (IC), etc.

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

[0106] See also Figure 3 , which shows a schematic diagram of the structure of an electronic device involved in an embodiment of the present application, the electronic device can be used to implement Figure 1 The method in the embodiment shown. Figure 3 As shown, the electronic device 300 may include: at least one central processor 301 , at least one network interface 304 , a user interface 303 , a memory 305 , and at least one communication bus 302 .

[0107] The communication bus 302 is used to realize the connection and communication between these components.

[0108] The user interface 303 may include a display screen (Display) and a camera (Camera). Optionally, the user interface 303 may also include a standard wired interface and a wireless interface.

[0109] The network interface 304 may optionally include a standard wired interface or a wireless interface (such as a WI-FI interface).

[0110] Among them, the central processing unit 301 may include one or more processing cores. The central processing unit 301 uses various interfaces and lines to connect various parts of the entire electronic device 300, and executes various functions and processes data of the terminal 300 by running or executing instructions, programs, code sets or instruction sets stored in the memory 305, and calling data stored in the memory 305. Optionally, the central processing unit 301 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The central processing unit 301 can integrate one or a combination of a central processing unit (Central Processing Unit, CPU), a graphics processing unit (Graphics Processing Unit, GPU) and a modem. Among them, the CPU mainly processes the operating system, user interface and application programs; the GPU is responsible for rendering and drawing the content to be displayed on the display screen; the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the central processing unit 301, and it can be implemented separately through a chip.

[0111] Among them, the memory 305 may include a random access memory (Random Access Memory, RAM) and may also include a read-only memory (Read-Only Memory). Optionally, the memory 305 includes a non-transitory computer-readable storage medium. The memory 305 can be used to store instructions, programs, codes, 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 a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area may store data involved in the above-mentioned various method embodiments, etc. The memory 305 may also be optionally at least one storage device located away from the aforementioned central processor 301. As Figure 3 As shown, the memory 305 as a computer storage medium may include an operating system, a network communication module, a user interface module, and program instructions.

[0112] exist Figure 3 In the electronic device 300 shown, the user interface 303 is mainly used to provide an input interface for the user and obtain the data input by the user; and the central processor 301 can be used to call the cigarette package scan image optimization application stored in the memory 305, and specifically perform the following operations:

[0113] Acquire a structured light fringe image captured by a camera for a scanned object, and calculate the average grayscale value of each current column of pixels in the structured light fringe image column by column;

[0114] The pixel points in the current column are screened based on the average grayscale value, so as to set the grayscale values ​​of pixels below the average grayscale value to zero, and the pixel grayscale value is the grayscale value of the pixel points in the current column;

[0115] Recording the number of retained pixels, and repeating the step of calculating the average grayscale value of the pixels of the current column in each column of the structured light fringe image column by column until the number of retained pixels is lower than a preset number of retained pixels, the number of retained pixels being the sum of the number of pixels of the current column that are not set to zero in each column;

[0116] The structured light center position is calculated based on each of the current column pixel points corresponding to the reserved number of pixel points, and the structured light fringe image is optimized according to the structured light center position.

[0117] The present application also provides a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, the steps of the above method are implemented. The computer-readable storage medium may include, but is not limited to, any type of disk, including a floppy disk, an optical disk, a DVD, a CD-ROM, a micro drive, and a magneto-optical disk, a ROM, a RAM, an EPROM, an EEPROM, a DRAM, a VRAM, a flash memory device, a magnetic card or an optical card, a nanosystem (including a molecular memory IC), or any type of medium or device suitable for storing instructions and / or data.

[0118] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.

[0119] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0120] In the several embodiments provided in the present application, it should be understood that the disclosed devices can be implemented in other ways. For example, the device embodiments described above are only schematic, such as the division of the units, which is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some service interfaces, and the indirect coupling or communication connection of devices or units can be electrical or other forms.

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

[0122] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0123] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application, 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. The computer software product is stored in a memory, including a number of instructions to enable a computer device (which can be a personal computer, server or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned memory includes: U disk, read-only memory (ROM), random access memory (RAM), mobile hard disk, disk or optical disk and other media that can store program codes.

[0124] A person skilled in the art may understand that all or part of the steps in the various methods of the above embodiments may be completed by entering a program to instruct related hardware, and the program may be stored in a computer-readable memory, which may include a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0125] The above is only an exemplary embodiment of the present disclosure, and the scope of the present disclosure cannot be limited thereto. That is, any equivalent changes and modifications made according to the teachings of the present disclosure are still within the scope of the present disclosure. After considering the specification and practicing the disclosure here, those skilled in the art will easily think of the implementation scheme of the present disclosure. This application is intended to cover any modification, use or adaptation of the present disclosure, which follows the general principles of the present disclosure and includes common knowledge or customary technical means in the technical field not recorded in the present disclosure. The description and examples are regarded as exemplary only, and the scope and spirit of the present disclosure are defined by the claims.

Claims

1. A method for optimizing a cigarette package scan image, characterized in that: The method comprises: Acquire a structured light fringe image captured by a camera for a scanned object, and calculate the average grayscale value of each current column of pixels in the structured light fringe image column by column; The pixel points in the current column are screened based on the average grayscale value, so as to set the grayscale values ​​of pixels below the average grayscale value to zero, and the pixel grayscale value is the grayscale value of the pixel points in the current column; Recording the number of retained pixels, and repeating the step of calculating the average grayscale value of the pixels of the current column in each column of the structured light fringe image column by column until the number of retained pixels is lower than a preset number of retained pixels, the number of retained pixels being the sum of the number of pixels of the current column that are not set to zero in each column; Calculating the center position of the structured light based on each of the current column of pixel points corresponding to the reserved number of pixel points, and optimizing the structured light fringe image according to the structured light center position; The step of calculating the average grayscale value of the pixels in each current column of the structured light fringe image column by column includes: Dividing the structured light fringe image into a plurality of column pixel point sets column by column, and recording the column to which each column pixel point set belongs, wherein the column pixel point set includes at least one current column pixel point; Calculate the average grayscale value of all the current column pixels in each column pixel set respectively; The calculating the structured light center position based on each of the current column pixel points corresponding to the reserved number of pixel points includes: Respectively obtain the row order of each of the current column pixel points corresponding to the reserved number of pixel points in the column pixel point set, and determine the coordinate position of each of the current column pixel points in the structured light fringe image based on the row order and the belonging column; Calculate the average value based on the coordinate positions to obtain the center position of the structured light; After determining the coordinate position of each pixel point in the current column in the structured light fringe image based on the row sorting and the belonging column, the method further includes: Randomly select two coordinate positions and calculate the pixel distance between the two coordinate positions; Repeat the step of arbitrarily selecting two of the coordinate positions until all the pixel point distances are obtained, and then construct a clustered pixel point set so that the pixel point distance between any two pixels in the current column in the clustered pixel point set is less than a preset distance; The calculating the average value based on each of the coordinate positions to obtain the center position of the structured light includes: The average values ​​of all the coordinate positions of each of the clustered pixel points are calculated respectively to obtain at least one structured light center position.

2. The method according to claim 1, characterized in that: Before acquiring the structured light fringe image collected by the camera for the scanned object, the method further includes: Acquire laser data information of a laser transmitter, and determine a laser operating band based on the laser data information; Auxiliary information for selecting a narrow-band filter is generated based on the laser operating band.

3. The method according to claim 1, characterized in that After calculating the average values ​​of all the coordinate positions of each of the clustered pixel points to obtain at least one structured light center position, the method further includes: When there are two center positions of the structured light, marking the two center positions of the structured light; Adjusting the laser incident angle of the laser transmitter within a preset angle range, and continuously monitoring the position change of the center position of each structured light to generate a position change curve; The two position change curves are compared, and the structured light center position corresponding to the position change curve with a relatively gentle curve change is deleted.

4. A cigarette package scanning image optimization device, characterized in that: The device comprises: An acquisition module is used to acquire a structured light fringe image collected by a camera for a scanned object, and calculate the average grayscale value of each current column of pixel points in the structured light fringe image column by column; A screening module, used for screening the pixel points in the current column based on the average grayscale value, so as to set the grayscale value of pixels below the average grayscale value to zero, the grayscale value of the pixel being the grayscale value of the pixel points in the current column; A recording module, used for recording the number of retained pixels, and repeating the step of calculating the average grayscale value of the pixels of the current column in each column of the structured light fringe image column by column until the number of retained pixels is lower than a preset number of retained pixels, the number of retained pixels being the sum of the number of pixels of the current column that are not set to zero in each column; A calculation module, configured to calculate a structured light center position based on each of the current column of pixel points corresponding to the reserved number of pixel points, and optimize the structured light fringe image according to the structured light center position; Wherein, the acquisition module includes: A division unit, used for dividing the structured light fringe image into a plurality of column pixel point sets column by column, and recording the column to which each column pixel point set belongs, wherein the column pixel point set includes at least one current column pixel point; A first calculation unit, used for respectively calculating the average grayscale value of all the current column pixel points in each column pixel point set; The calculation module comprises: A first determining unit, configured to respectively obtain the row order of each of the current column pixels corresponding to the reserved number of pixels in the column pixel set, and determine the coordinate position of each of the current column pixels in the structured light fringe image based on the row order and the belonging column; an average value calculation unit, used to calculate the average value based on each of the coordinate positions to obtain the center position of the structured light; The calculation module also includes: A second calculation unit is used to arbitrarily select two coordinate positions and calculate the pixel point distance between the two coordinate positions; a repeating unit, configured to repeat the step of arbitrarily selecting two of the coordinate positions until all the pixel point distances are obtained, and then construct a clustered pixel point set so that the pixel point distance between any two pixel points in the current column in the clustered pixel point set is less than a preset distance; The average value calculation unit comprises: The average value calculation element is used to calculate the average value of all the coordinate positions of each of the clustered pixel point sets to obtain at least one structured light center position.

5. 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, the steps of the method according to any one of claims 1 to 3 are implemented.

6. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 3 are implemented.

Citation Information

Patent Citations

  • Method using improved iterative algorithm to extract target image

    CN107564018A

  • Stripe center extraction method of structured light stripe image

    CN110599539A