Microcosmic code image detection method, device and system and medium
By generating the minimum external ellipse of the microcode image and judging its direction consistency, the problems of large calculation volume and high accuracy in the prior art are solved, efficient and accurate judgment of the sharpness of the microcode image is achieved, and the decoding success rate and user experience of the genuine image are improved.
Patent Information
- Application Number
- CN202510962312.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-14
- Publication Date
- 2025-08-12
- Estimated Expiration
- 2045-07-14
AI Technical Summary
The prior art has a large amount of calculation and high calculation accuracy requirements when judging the sharpness of microcode images, making it difficult to effectively identify image blur caused by jitter, which affects the reliability of the traceability system.
By obtaining the placeholder in the microcode image, a minimum external ellipse is generated, and the direction information of each placeholder is confirmed, the image clarity is judged based on the direction consistency, and the direction consistency of the minimum external ellipse is used to identify unclearity caused by jitter, reducing the calculation amount and improving judgment efficiency.
It improves the accuracy and operation efficiency of microcode image clarity judgment, reduces the difficulty of decoding pirated images, enhances the user experience of genuine users, and reduces the amount of calculation.
Smart Images

Figure CN120471082A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of image detection, and in particular to a method, device, system, and medium for detecting microscopic code images. Background Art
[0002] As a new generation of microscopic dot array anti-counterfeiting technology, the clarity of microcode images directly impacts the reliability of the traceability system. Clarity determination is a crucial step in microcode image processing, often used to check image clarity and assess image quality and reliability. For microcode images, image clarity is often closely related to geometric features such as the shape, size, and distribution of black dots. During the image capture process, image blur (manifested as black dot adhesion or morphological distortion) caused by handheld device shake or loss of focus is a major source of interference. Existing methods for determining jitter based on black dot shape change calculate the ratio of the area of the smallest circumscribed circle of the black dot to its actual area to determine if jitter is present. However, due to the small size of the black dots, determining jitter based on area change requires significant computational effort and high precision, placing high demands on the device's computing power. Therefore, a more efficient method for determining the clarity of microcode images is urgently needed. Summary of the Invention
[0003] Embodiments of the present invention provide a method, device, system, and medium for detecting a micro code image, which can more effectively detect whether a micro code image is clear.
[0004] According to one aspect of the present invention, a method for detecting a micro code image is provided, comprising: acquiring a micro code image, the micro code image including a plurality of occupied points; generating a minimum circumscribed ellipse for each occupied point; determining directional information of each minimum circumscribed ellipse; and determining the clarity of the micro code image based on the directional information.
[0005] Optionally, after obtaining the micro code image, the method further includes: preprocessing the micro code image.
[0006] Optionally, acquiring the micro code image includes: photographing the anti-counterfeiting mark to generate the micro code image.
[0007] Optionally, before generating a minimum circumscribed ellipse for each occupied point, the method includes: extracting the outline of the occupied point from the micro code image using an edge detection or threshold segmentation method.
[0008] Optionally, generating a minimum circumscribed ellipse for each occupied point includes: generating the minimum circumscribed ellipse based on the contour by a minimum circumscribed ellipse fitting algorithm.
[0009] Optionally, confirming the direction information of each minimum circumscribed ellipse includes: generating the direction information according to the major axis direction of the minimum circumscribed ellipse.
[0010] Optionally, determining the clarity of the micro code image based on the direction information includes: calculating a proportion of different directions in the direction information, and determining the clarity of the micro code image according to a maximum proportion of the same direction.
[0011] According to another aspect of the present invention, a device for detecting a microscopic code image is provided, comprising: an image acquisition module for acquiring a microscopic code image, the microscopic code image including a plurality of occupied points; an ellipse fitting module for generating a minimum circumscribed ellipse for each occupied point; a direction confirmation module for confirming the direction information of each minimum circumscribed ellipse; and a clarity determination module for confirming the clarity of the microscopic code image based on the direction information.
[0012] According to another aspect of the present invention, a microscopic code image detection system is provided, comprising: an image capture device; one or more processors; and a memory for storing one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors implement any of the aforementioned microscopic code image detection methods.
[0013] According to another aspect of the present invention, a storage medium is provided, on which a computer program is stored, wherein the program, when executed by a processor, implements the above-mentioned method for detecting a microscopic code image.
[0014] Compared to the prior art, the microcode image detection method of this embodiment uses the direction of the minimum circumscribed ellipse of each dot to determine whether the image is unclear due to camera shake. When the microcode image is genuinely printed, each dot is relatively regular and essentially undistorted, meaning that all dot patterns have no apparent directionality. Once camera shake occurs, the dot patterns in the captured image will be stretched in the direction of the shake. Therefore, the directional image stretching caused by camera shake can be used as a good indicator of poor focus and image clarity. On the other hand, when the microcode image is counterfeit, if printing problems cause some pixels to be stretched or stuck perpendicular to the direction of the shake, the dot pattern stretching caused by the camera shake and the stretching caused by the pirated printing will cancel each other out, making it impossible to accurately identify camera shake and provide timely notification or correction for abnormal camera shake. In other words, pirated images are more likely to appear blurred using the methods of this embodiment, further increasing the difficulty of decoding pirated microcode images. This means that this method increases the probability of capturing and decoding legitimate microcode images clearly, while decreasing the probability of capturing and decoding pirated microcode images clearly, thereby improving the user experience for legitimate users. Furthermore, this method only requires calculating the number of consistent orientations of the circumscribed ellipse, thus reducing the computational effort and allowing it to be adjusted based on the number of valid occupants in the captured image. This results in more accurate clarity judgments and improved operational efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0016] Figure 1 This is a flowchart of a method for detecting a microscopic code image provided in Example 1 of the present invention.
[0017] Figure 2 This is a flow chart of a method for detecting a microscopic code image provided in the second embodiment of the present invention.
[0018] Figure 3 Schematic diagram of a micro code image detection device provided in embodiment 3 of the present invention.
[0019] Figure 4 Schematic diagram of a micro code image detection device provided in a fourth embodiment of the present invention.
[0020] Figure 5 Schematic diagram of a microscopic code image detection system provided in Example 5 of the present invention.
[0021] Figure 6 is a schematic diagram of a microscopic code image under different conditions provided by any embodiment of the present invention. DETAILED DESCRIPTION
[0022] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the embodiments described are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of the present invention.
[0023] It should be noted that the terms "first", "second", etc. in the description and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0024] Example 1
[0025] Figure 1 This is a flow chart of a micro code image detection method provided in the first embodiment of the present invention. This embodiment can be applied to a micro code image detection device. The device can be implemented by software and / or hardware and can generally be integrated into a micro code image detection system. The micro code image detection system of this embodiment includes an image capture device and a processor. Figure 1 As shown, the method includes the following operations:
[0026] S110: Acquire a micro code image, wherein the micro code image includes a plurality of occupied sites.
[0027] In this embodiment, the anti-counterfeiting mark can be photographed to generate the micro code image. Specifically, the anti-counterfeiting mark can include a plurality of randomly distributed quantum dots as dot sites, and these quantum dots have a preset size and shape. In one embodiment, the micro code image can include a plurality of black dots formed on a white, gray, yellow or other background color with a pattern or color as dot sites. The black dots can be round dots or square dots. The micro code image as an anti-counterfeiting mark is generally attached to the surface of the product. The user can decode the micro code image to identify the authenticity of the product by photographing it. When the label is imitated, after copying or photocopying, since the black dots in the micro code image are extremely small in size (generally around 30-50 microns in diameter), the copying process may cause the shape of the black dots to change. For example, the original round black dots may be deformed or stretched into irregular shapes or lines due to the quality of the paper or printing quality. Figure 6 As shown in Figure 63.
[0028] S120. Generate a minimum circumscribed ellipse for each occupied point.
[0029] In this embodiment, for each occupied point, a preset image processing method can be used to extract the contour shape of each occupied point, and then a minimum ellipse fitting method is used to fit a minimum ellipse outside each occupied point. In one embodiment, at least three non-adjacent pixels of the ellipse are tangent to the contour of the occupied point.
[0030] S130: Confirm the direction information of each minimum circumscribed ellipse.
[0031] In this embodiment, the direction information of each minimum circumscribed ellipse is generated based on the major axis direction of the minimum circumscribed ellipse. If the major and minor axes of the minimum circumscribed ellipse of the occupied site are equal, that is, the minimum circumscribed ellipse is the minimum circumscribed circle, the corresponding direction information is set to zero or not considered in the calculation.
[0032] S140: Determine the clarity of the micro code image based on the direction information.
[0033] In one embodiment, the proportions of different directions in the directional information are calculated, and the clarity of the micro code image is determined based on the maximum proportion of the same direction. If the maximum proportion of the same direction is greater than a preset threshold, the micro code image is determined to be unclear, i.e., the image was jittered. Otherwise, the micro code image is determined to be clear, i.e., the image was not jittered.
[0034] Compared with the prior art, the detection method of the micro code image of this embodiment determines whether the image is unclear due to shooting shake by the direction of the minimum circumscribed ellipse of each dot. When the micro code image is genuine, the shape of each dot is relatively regular and basically not deformed, that is, all the dot-occupies have no obvious directionality (such as Figure 6 As shown in 61 in the figure), once the shooting is shaken, the position of the shot image in the direction of the shake will be stretched (as shown in Figure 6 62 in the figure), the directional consistency of the circumscribed ellipse in this case can be used to better identify whether the image is unclear due to shaking shooting. Therefore, the directional image stretching caused by shaking can be used as a good indicator of poor focus and unclear image. On the other hand, when the micro code image is not genuine (such as Figure 6 (As shown in Figure 63), if printing problems cause some pixels to be stretched or stuck perpendicular to the shaking direction, the stretching of the occupied points caused by the shaking shooting and the stretching caused by the pirated printing will cancel each other out, making it impossible to correctly identify the shaking of the captured image, and thus unable to promptly prompt or correct the abnormal shaking shooting. In other words, pirated images are more likely to be captured as blurry images under the method of this embodiment, further increasing the difficulty of decoding pirated microcode images. In other words, this method increases the probability of capturing clear images and decoding legitimate microcode images, reduces the probability of capturing clear images and decoding pirated microcode images, and improves the user experience of legitimate users. In addition, the judgment in this case only requires calculating the statistics of the consistent direction of the circumscribed ellipse. Therefore, not only is the computational effort small, but the computational effort can also be adjusted based on the effective occupied points in the captured image. This not only makes the clarity judgment more accurate, but also improves the operating efficiency.
[0035] Example 2
[0036] Figure 2 This is a flow chart of a micro code image detection method provided by the second embodiment of the present invention. This embodiment can be applied to a micro code image detection device. The device can be implemented by software and / or hardware and can generally be integrated into a micro code image detection system. The micro code image detection system of this embodiment includes an image capture device and a processor. Figure 2 As shown, the method includes the following operations:
[0037] S110: Acquire a micro code image, wherein the micro code image includes a plurality of occupied sites.
[0038] In this embodiment, a scanning device, such as a mobile phone or a barcode scanner, can be used to capture the anti-counterfeiting mark to generate the microcode image. Specifically, the anti-counterfeiting mark can include a plurality of randomly distributed quantum dots as dot sites, each of which has a predetermined size and shape. In one embodiment, the microcode image can include a plurality of black dots formed on a white background as dot sites, which can be circular or square. The microcode image, as an anti-counterfeiting mark, is typically affixed to the surface of a product. Users can decode the microcode image to verify the authenticity of the product by capturing it. When the label is counterfeited, the black dots in the microcode image are extremely small (typically around 30-50 microns in diameter). This process can cause the shape of the black dots to change. For example, originally circular black dots may be deformed or stretched into irregular shapes or lines due to the quality of the paper or printing.
[0039] S160: Preprocess the micro code image.
[0040] In this embodiment, the image captured is the image to be processed, and preprocessing the image to be processed may include grayscale conversion, scaling, and binarization. In one embodiment, preprocessing the micro code image includes the following steps S161-S163.
[0041] S161: De-noise the image to be processed.
[0042] In this embodiment, one or more of the following methods can be used to denoise the image to be processed:
[0043] Mean Filtering: This method reduces noise by replacing the pixel value of any pixel in the image to be processed with the average value of all pixels in its neighborhood.
[0044] Median Filtering: For each pixel of the image to be processed, the median value of all pixels in its neighborhood is taken as the new value of the point.
[0045] Gaussian Filtering: Similar to mean filtering, but uses a weighted average based on Gaussian distribution weights. This gives higher weights to pixels closer to the center of each occupied pixel in the processed image, thereby better preserving edges.
[0046] Bilateral filtering: This method combines spatial proximity and pixel value similarity. It considers not only the spatial distance between pixels but also their color values or intensity differences, thus effectively preserving edges while denoising.
[0047] Wavelet Denoising: Wavelet transform is used to convert an image into the wavelet domain. In this domain, the signal energy is concentrated in a few coefficients, while the noise is relatively dispersed. By thresholding these coefficients, the noise of the image can be effectively removed.
[0048] Deep learning methods: This embodiment can also use image denoising techniques based on models such as convolutional neural networks (CNNs). These methods generally require a large amount of training data and can be directly applied to the denoising task of the image to be processed after training.
[0049] S162: Convert the denoised microscopic code image into a grayscale image.
[0050] In this embodiment, grayscale conversion of the denoised microcode image can be performed using at least one of an averaging method and a weighted / brightness method. The averaging method takes the average of the R, G, and B color components of each pixel in the denoised microcode image as the grayscale value of that pixel. For example, grayscale value = (R + G + B) / 3. The weighted / brightness method calculates the grayscale value by assigning different weights to the R, G, and B components of each pixel in the microcode image, based on the fact that the human eye is most sensitive to green light, followed by red light, and least sensitive to blue light. For example, Gray = 0.299 × R + 0.587 × G + 0.114 × B, where 0.299, 0.587, and 0.114 are the grayscale conversion weight coefficients used in the weighted / brightness method of this embodiment.
[0051] S163. Scaling the grayscale image at least once to obtain an image of standard size.
[0052] In one embodiment, the target image size to be output may be determined, for example, 256x256, i.e., an image with 256 pixels in each row and column. The image is then scaled using an interpolation algorithm, such as bilinear interpolation, nearest neighbor interpolation, regional interpolation, or cubic spline interpolation.
[0053] S120. Generate a minimum circumscribed ellipse for each occupied point.
[0054] Specifically, generating a minimum circumscribed ellipse for each occupied point may include steps S121 - S122 .
[0055] S121. Extract the outline of the occupied point from the micro code image using edge detection or threshold segmentation method.
[0056] Specifically, in this embodiment, edge detection methods are used to identify locations within the microcode image where luminance changes dramatically. In one embodiment, the Canny algorithm can be used for edge detection to extract the contours of the occupied points. In this embodiment, the threshold segmentation method uses global threshold segmentation (e.g., the Otsu method) to extract local features and extract the contours of the occupied points. In this embodiment, the contour of each extracted occupied point can be identified as an independent connected region. Specifically, in one embodiment, the findContours function of OpenCV can be used to find the contours of all connected regions corresponding to all occupied points in the microcode image, that is, the contours of all occupied points in the microcode image. In this embodiment, the contour of each occupied point is recorded to generate a contour list.
[0057] S122. When the outline size meets the requirements, generate a minimum circumscribed ellipse for each occupied point.
[0058] In this embodiment, the pixel values of the contours must be greater than a preset threshold, for example, 3 pixels, to avoid failure in fitting the minimum circumscribed ellipse. If the pixel values of the contours are greater than the preset threshold, the cv2.fitEllipse() function is used to input the contour of each occupied site to generate a minimum circumscribed ellipse for each site. If the pixel values of the contours are less than or equal to the preset threshold, the minimum circumscribed ellipse fitting is abandoned.
[0059] S130: Confirm the direction information of each minimum circumscribed ellipse.
[0060] In this example, after a successful minimum circumscribed ellipse fit, the cv2.fitEllipse() function returns a tuple (center, axes, angle) containing the following elements. Center is the ellipse's center coordinates (x, y); axes is the lengths of the major and minor axes (major_axis_length, minor_axis_length); and angle is the ellipse's rotation angle (in degrees), indicating the orientation of the ellipse's major axis. Therefore, the orientation of each minimum circumscribed ellipse can be determined based on the ellipse's rotation angle in the returned information.
[0061] S140: Determine the clarity of the micro code image based on the direction information.
[0062] In one embodiment, the proportion of different directions in the direction information is calculated, and the clarity of the micro code image is determined based on the maximum proportion of the same direction; wherein, if the maximum proportion of the same direction is greater than a preset threshold, the micro code image is determined to be unclear, that is, the shooting is jittery; otherwise, the micro code image is determined to be clear, that is, the shooting is not jittery. In one embodiment, the direction distribution of the minimum circumscribed ellipse of all code points is counted, and the direction consistency index is calculated; if the direction consistency index is greater than one , it is recorded as jitter. The larger the ratio is, the more jittery the lens is and the less clear the image is.
[0063] In one embodiment, the direction consistency index The calculation formula is:
[0064]
[0065] in, is the number of black dots in the maximum frequency interval in the θ distribution histogram; is the total number of black spots involved in the statistics; is the half-height width angle value of the maximum frequency interval; The appropriate threshold is set according to actual needs. If the value is greater than the threshold, it is considered jitter, and if it is less than the threshold, it is considered no jitter.
[0066] In an alternative embodiment, an adaptive threshold may also be used. , used to solve the stability issues caused by different shooting conditions (such as changes in the number of black spots). Among them: is the empirical coefficient.
[0067] In one embodiment, we also tested the algorithm's operating speed. The results showed that, across 10,000 test samples, image clarity recognition took only 5.53 milliseconds per image. Therefore, the algorithm proposed in this invention has a relatively fast processing speed when processing images with small patterns, and can meet application scenarios with high real-time requirements.
[0068] S150: Prompt the user to take a photo based on the clarity.
[0069] In this embodiment, when an image is determined to be unclear due to shaking, the user can be prompted to retake the image through visual means (e.g., displaying an icon or color change) or auditory means (sound prompt). Furthermore, the user can be prompted to change the focus direction based on the clarity trend of multiple images captured consecutively during the focus movement process, so that the user can capture a clear microcode image as quickly as possible.
[0070] Compared with the prior art, the micro code image detection method of this embodiment improves the efficiency of fitting the minimum ellipse by preprocessing the image in advance, thereby improving the efficiency of judging the clarity of the micro code image. In addition, when the clarity is abnormal, the user is promptly reminded to take a photo, which increases the success rate of the user in taking clear pictures and enhances the user experience.
[0071] Example 3
[0072] Figure 3 This is a schematic diagram of the structure of a micro code image detection device provided by the third embodiment of the present invention. The device 300 can be implemented by software and / or hardware, and can generally be integrated into a micro code image detection system, such as Figure 3 As shown, the device 300 includes: an image acquisition module 310 , an ellipse fitting module 320 , a direction confirmation module 330 and a clarity judgment module 340 .
[0073] The image acquisition module 310 is used to acquire a micro code image, where the micro code image includes a plurality of occupied sites.
[0074] In this embodiment, the microcode image can be generated by photographing the anti-counterfeiting mark. Specifically, the anti-counterfeiting mark can include a plurality of randomly distributed quantum dots as dot-spots, each of a predetermined size and shape. In one embodiment, the microcode image can include a plurality of black dots on a white background as dot-spots, which can be circular or square. The microcode image, serving as the anti-counterfeiting mark, is typically affixed to the surface of a product. Users can photograph the microcode image to decode and verify the authenticity of the product. When the label is counterfeited, the extremely small size of the black dots in the microcode image (typically around 100-500 microns in diameter) can cause the dots to change shape during the copying process. For example, originally circular black dots may be deformed or stretched into irregular shapes or lines due to the quality of the paper or printing.
[0075] The ellipse fitting module 320 is used to generate a minimum circumscribed ellipse for each occupant point.
[0076] In this embodiment, for each occupied point, a preset image processing method can be used to extract the contour shape of each occupied point, and then a minimum ellipse fitting method is used to fit a minimum ellipse outside each occupied point. In one embodiment, at least three non-adjacent pixels of the ellipse are tangent to the contour of the occupied point.
[0077] The direction confirmation module 330 is used to confirm the direction information of each minimum circumscribed ellipse.
[0078] In this embodiment, the direction information of each minimum circumscribed ellipse is generated based on the major axis direction of the minimum circumscribed ellipse. If the major and minor axes of the minimum circumscribed ellipse of the occupied site are equal, that is, the minimum circumscribed ellipse is the minimum circumscribed circle, the corresponding direction information is set to zero or not considered in the calculation.
[0079] The clarity determination module 340 determines the clarity of the micro code image based on the direction information.
[0080] In one embodiment, the proportions of different directions in the directional information are calculated, and the clarity of the micro code image is determined based on the maximum proportion of the same direction. If the maximum proportion of the same direction is greater than a preset threshold, the micro code image is determined to be unclear, i.e., the image was jittered. Otherwise, the micro code image is determined to be clear, i.e., the image was not jittered.
[0081] In this embodiment, the above-mentioned micro code image detection device can execute the micro code image detection method provided in any embodiment of the present invention, and has the functional modules and beneficial effects corresponding to the execution method. For technical details not fully described in this embodiment, please refer to the micro code image detection method provided in any embodiment of the present invention. Since the micro code image detection device introduced above is a device that can execute the micro code image detection method in the embodiment of the present invention, based on the micro code image detection method introduced in the embodiment of the present invention, those skilled in the art can understand the specific implementation of the micro code image detection device of this embodiment and its various variations. Therefore, how the micro code image detection device implements the micro code image detection method in the embodiment of the present invention will not be described in detail here. As long as those skilled in the art implement the device used by the micro code image detection method in the embodiment of the present invention, it falls within the scope of protection to be protected by this application.
[0082] Example 4
[0083] Figure 4 4 is a schematic diagram of a micro code image detection device provided by the fourth embodiment of the present invention. The device 400 can be implemented by software and / or hardware, and can generally be integrated into a micro code image detection system, such as Figure 4 As shown, the device 400 includes: an image acquisition module 410, a pre-processing module 460, an ellipse fitting module 420, a direction confirmation module 430, a clarity judgment module 440 and a shooting prompt module 450.
[0084] The image acquisition module 410 is used to acquire a micro code image, where the micro code image includes a plurality of occupied sites.
[0085] In this embodiment, a scanning device, such as a mobile phone or a barcode scanner, can be used to capture the anti-counterfeiting mark to generate the microcode image. Specifically, the anti-counterfeiting mark can include a plurality of randomly distributed quantum dots as dot sites, each of which has a predetermined size and shape. In one embodiment, the microcode image can include a plurality of black dots formed on a white background as dot sites, which can be circular or square. The microcode image, as an anti-counterfeiting mark, is typically affixed to the surface of a product. Users can decode the microcode image to verify the authenticity of the product by capturing it. When the label is counterfeited, the black dots in the microcode image are extremely small (typically around 100-500 microns in diameter). This process can cause the shape of the black dots to change. For example, originally circular black dots may be deformed or stretched into irregular shapes or lines due to the quality of the paper or printing.
[0086] The pre-processing module 460 is used to pre-process the micro code image.
[0087] In this embodiment, the captured image is the image to be processed, and preprocessing the image to be processed may include grayscale conversion, scaling, and binarization. In one embodiment, the preprocessing module 460 may include an image denoising module 461, a grayscale conversion module 462, and an image scaling module 463.
[0088] The image denoising module 461 can use one or more of the following modules to denoise the image to be processed: Mean Filtering module: used to reduce noise by replacing the pixel value of any pixel in the image to be processed with the average value of all pixels in its neighborhood. Median Filtering module: used to take the median value of all pixels in the neighborhood of each pixel point in the image to be processed as the new value of the point. Gaussian Filtering module: used to perform mean filtering on pixels, but the weighted average is based on the weights of the Gaussian distribution. This gives pixels closer to the center of each occupied point in the image to be processed a higher weight, thereby better preserving edges. Bilateral Filtering module: used to perform filtering by combining the two factors of spatial proximity and pixel value similarity. It not only considers the spatial distance between pixels, but also their color value or intensity differences, so it can better protect the edges of the image to be processed while denoising. Wavelet Denoising: This module uses wavelet transforms to convert images into the wavelet domain. In this domain, signal energy is concentrated in a small number of coefficients, while noise is relatively dispersed. By thresholding these coefficients, noise can be effectively removed from the processed image. Deep Learning Image Denoising: This module uses image denoising techniques based on models such as convolutional neural networks (CNNs).
[0089] The grayscale conversion module 462 is used to convert the denoised microcode image into a grayscale image. In this embodiment, the grayscale conversion of the denoised microcode image can be performed using at least one of an averaging method and a weighted / brightness method. The averaging method takes the average of the R, G, and B color components of each pixel in the denoised microcode image as the grayscale value of that pixel. For example, grayscale value = (R + G + B) / 3. The weighted / brightness method calculates the grayscale value by assigning different weights to the R, G, and B components of each pixel in the microcode image, based on the fact that the human eye is most sensitive to green light, followed by red light, and least sensitive to blue light. For example, Gray = 0.299 × R + 0.587 × G + 0.114 × B, where 0.299, 0.587, and 0.114 are the grayscale conversion weight coefficients used in the weighted / brightness method in this embodiment.
[0090] Image scaling module 463 is used to scale the grayscale image at least once to obtain a standard-sized image. In one embodiment, the target output image size can be determined, for example, 256x256, i.e., an image with 256 pixels in each row and column. The image is then scaled using an interpolation algorithm, such as bilinear interpolation, nearest neighbor interpolation, regional interpolation, or cubic spline interpolation.
[0091] The ellipse fitting module 420 is used to generate a minimum circumscribed ellipse for each occupancy point. In this embodiment, the ellipse fitting module 420 includes a contour extraction module 421 and an ellipse generation module 422 .
[0092] The contour extraction module 421 extracts the contour of the occupied point from the micro code image using an edge detection method or a threshold segmentation method.
[0093] Specifically, in this embodiment, the contour extraction module 421 uses edge detection to identify locations within the microcode image where brightness changes dramatically. In one embodiment, the Canny algorithm can be used for edge detection to extract the contours of the occupied points. In this embodiment, the threshold segmentation method uses global threshold segmentation (e.g., the Otsu method) to perform local feature extraction to extract the contours of the occupied points. In this embodiment, the extracted contour of each occupied point can be identified as an independent connected region. In this embodiment, the contour of each occupied point is recorded to generate a contour list. Specifically, in one embodiment, the findContours function of OpenCV can be used to find the contours of all connected regions corresponding to all occupied points in the microcode image, that is, the contours of all occupied points in the microcode image.
[0094] In this embodiment, the ellipse generation module 422 is used to generate a minimum circumscribed ellipse when the outline size meets the requirements. Specifically, the outline pixel value must be greater than a preset threshold, for example, 3 pixels, to avoid failure in fitting the minimum circumscribed ellipse. If the outline pixel value is greater than the preset threshold, the ellipse generation module 422 uses the cv2.fitEllipse() function to input the contour of each occupied point to generate a minimum circumscribed ellipse for each occupied point. If the outline pixel value is less than or equal to the preset threshold, the minimum circumscribed ellipse fitting is abandoned.
[0095] The direction confirmation module 430 is used to confirm the direction information of each minimum circumscribed ellipse.
[0096] In this embodiment, after a minimum circumscribed ellipse is successfully fitted, the function cv2.fitEllipse() used by the orientation confirmation module 430 returns a tuple (center, axes, angle) containing the following elements: center is the ellipse center coordinates (x, y); axes is the lengths of the major and minor axes (major_axis_length and minor_axis_length); and angle is the ellipse rotation angle (in degrees), i.e., the direction of the ellipse's major axis. Therefore, the orientation of each minimum circumscribed ellipse can be determined based on the ellipse rotation angle returned.
[0097] The clarity determination module 440 determines the clarity of the micro code image based on the direction information.
[0098] In one embodiment, the clarity judgment module 440 calculates the proportion of different directions in the direction information, and judges the clarity of the micro code image based on the maximum proportion of the same direction; wherein, if the maximum proportion of the same direction is greater than a preset threshold, the micro code image is determined to be unclear, that is, the shooting is jittery; otherwise, the micro code image is determined to be clear, that is, the shooting is not jittery. In one embodiment, the direction distribution of the minimum circumscribed ellipse of all code points is counted, and the direction consistency index is calculated; if the direction consistency index is greater than one , it is recorded as jitter. The larger the ratio is, the more jittery the lens is and the less clear the image is.
[0099] In one embodiment, the direction consistency index The calculation formula is:
[0100]
[0101] in, is the number of black dots in the maximum frequency interval in the θ distribution histogram; is the total number of black spots involved in the statistics; is the half-height width angle value of the maximum frequency interval; The appropriate threshold is set according to actual needs. If the value is greater than the threshold, it is considered jitter, and if it is less than the threshold, it is considered no jitter.
[0102] In an alternative embodiment, an adaptive threshold may also be used. , used to solve the stability issues caused by different shooting conditions (such as changes in the number of black spots). Among them: is the empirical coefficient.
[0103] The shooting prompt module 450 prompts the user to shoot based on the clarity.
[0104] In this embodiment, when the image is determined to be unclear due to shaking, the shooting prompt module 450 can remind the user to retake the image through visual means (such as displaying an icon or color change) or auditory means (sound prompt). In addition, the user can be prompted to move the focus direction based on the clarity trend of multiple images captured continuously during the shooting process, so that the user can capture a clear micro code image as soon as possible.
[0105] In this embodiment, the above-mentioned micro code image detection device can execute the micro code image detection method provided in any embodiment of the present invention, and has the functional modules and beneficial effects corresponding to the execution method. For technical details not fully described in this embodiment, please refer to the micro code image detection method provided in any embodiment of the present invention. Since the micro code image detection device introduced above is a device that can execute the micro code image detection method in the embodiment of the present invention, based on the micro code image detection method introduced in the embodiment of the present invention, those skilled in the art can understand the specific implementation of the micro code image detection device of this embodiment and its various variations. Therefore, how the micro code image detection device implements the micro code image detection method in the embodiment of the present invention will not be described in detail here. As long as those skilled in the art implement the device used by the micro code image detection method in the embodiment of the present invention, it falls within the scope of protection to be protected by this application.
[0106] Example 5
[0107] Figure 5 FIG. 1 shows a schematic diagram of a microscopic code image detection system provided by embodiment 6 of the present invention. Figure 5As shown, the microscopic code image detection system 500 includes an image capture device 21, one or more processors 11, and a memory communicatively connected to at least one of the processors 11. The memory stores a computer program executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in a read-only memory (ROM) 12 or loaded from a storage unit 18 into a random access memory (RAM) 13. The RAM 13 can also store various programs and data required for the operation of the microscopic code image detection system 500. The processor 11, ROM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0108] Multiple components of the microscopic code image detection system 500 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a magnetic disk, optical disk, etc.; and a communication unit 19, such as a network card, modem, wireless communication transceiver, etc. The communication unit 19 allows the microscopic code image detection system 500 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.
[0109] The processor 11 can be any general-purpose and / or specialized processing component with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various specialized artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, digital signal processors (DSPs), and any other suitable processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above. For example, the processor of the microscopic code image detection system 500 implements the microscopic code image detection method.
[0110] In some embodiments, the microscopic code image detection method can be implemented as a computer program tangibly embodied in a computer-readable storage medium, such as the storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed into the microscopic code image detection system 500 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the microscopic code image detection method described above can be performed. Alternatively, in other embodiments, the processor 11 can be configured to execute the microscopic code image detection method via any other suitable means (e.g., via firmware).
[0111] Various embodiments of the systems and techniques described herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include being implemented in one or more computer programs that are executable and / or interpreted on a programmable system that includes at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0112] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when the computer program is executed by the processor, the functions / operations specified in the flowcharts and / or block diagrams are implemented. The computer program may be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0113] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, device, or apparatus. A computer-readable storage medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or apparatus, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media may include an electrical connection based on one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0114] To provide interaction with a user, the systems and techniques described herein can be implemented on a mobile terminal having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the mobile terminal. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0115] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0116] A computing system may include clients and servers. The clients and servers are typically remote from each other and typically interact via a communication network. This client-server relationship arises through computer programs running on the respective computers, creating a client-server relationship. The server may be a cloud server, also known as a cloud computing server or cloud host. This server is a hosting product within the cloud computing service ecosystem that addresses the management difficulties and limited scalability of traditional physical hosting and VPS services.
[0117] Example 6
[0118] Embodiment 6 of the present invention further provides a computer storage medium storing a computer program, wherein the computer program, when executed by a computer processor, is used to execute the method for detecting a microscopic code image described in any of the above embodiments of the present invention.
[0119] The computer storage media of the embodiments of the present invention may employ any combination of one or more computer-readable media. The computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM, or flash memory), optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In this document, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0120] A computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0121] The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wire, optical cable, radio frequency (RF), etc., or any suitable combination of the foregoing.
[0122] The above specific embodiments do not limit the scope of protection of the present invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may be made based on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention are intended to be included within the scope of protection of the present invention.
Claims
1. A method for detecting a microscopic code image, characterized in that: The method comprises: Acquire a micro code image, wherein the micro code image includes a plurality of occupied sites; Generate the minimum circumscribed ellipse for each occupied point; Confirm the direction information of each minimum circumscribed ellipse; The clarity of the micro code image is confirmed based on the direction information.
2. The method for detecting a microscopic code image according to claim 1, wherein: After obtaining the micro code image, the method further includes: preprocessing the micro code image, wherein the preprocessing includes one of grayscale conversion, scaling, and binarization.
3. The method for detecting a microscopic code image according to claim 1, wherein: The obtaining of the micro code image includes: photographing the anti-counterfeiting mark to generate the micro code image.
4. The method for detecting a microscopic code image according to claim 1, wherein: Before generating the minimum circumscribed ellipse for each occupied point, the method includes: extracting the outline of the occupied point from the micro code image using an edge detection or threshold segmentation method.
5. The method for detecting a microscopic code image according to claim 4, wherein: Generating a minimum circumscribed ellipse for each occupied point includes: generating the minimum circumscribed ellipse based on the contour by a minimum circumscribed ellipse fitting algorithm.
6. The method for detecting a microscopic code image according to claim 1, wherein: Confirming the direction information of each minimum circumscribed ellipse includes: generating the direction information according to the major axis direction of the minimum circumscribed ellipse.
7. The method for detecting a microscopic code image according to claim 1, wherein: The determining the clarity of the micro code image based on the direction information includes: The proportion of different directions in the direction information is calculated, and the clarity of the micro code image is determined according to the maximum proportion of the same direction.
8. A device for detecting microscopic code images, characterized in that: include: An image acquisition module, configured to acquire a micro code image, wherein the micro code image includes a plurality of occupied sites; Ellipse fitting module, used to generate the minimum circumscribed ellipse for each occupied site; A direction confirmation module is used to confirm the direction information of each minimum circumscribed ellipse; A clarity determination module is configured to determine the clarity of the micro code image based on the direction information.
9. A micro code image detection system, characterized in that: include: an image capturing device; one or more processors; a memory for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the method for detecting a microscopic code image as described in any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method for detecting a microscopic code image as described in any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Calculating method of image block rotation angle and apparatus thereof
CN107220938A
Fuzzy recognizable two-dimensional code positioning and distortion correction method
CN113076768A
Multi-finger fingerprint synchronous extraction method
CN117809340A
Code scanning distance evaluation method and device for microscopic coding code pattern, and mobile terminal
CN118569287A
Two dimensional barcode
US20180157946A1