CN115860025A - Two-dimensional code image processing method, device, equipment, storage medium and program product - Google Patents

Two-dimensional code image processing method, device, equipment, storage medium and program product Download PDF

Info

Publication number
CN115860025A
CN115860025A CN202211683420.5A CN202211683420A CN115860025A CN 115860025 A CN115860025 A CN 115860025A CN 202211683420 A CN202211683420 A CN 202211683420A CN 115860025 A CN115860025 A CN 115860025A
Authority
CN
China
Prior art keywords
dimensional code
code image
target
value
gray
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211683420.5A
Other languages
Chinese (zh)
Inventor
全绍军
陈赛平
廖伟建
郭腾飞
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Longse Technology Co ltd
Original Assignee
Longse Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Longse Technology Co ltd filed Critical Longse Technology Co ltd
Priority to CN202211683420.5A priority Critical patent/CN115860025A/en
Publication of CN115860025A publication Critical patent/CN115860025A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Image Analysis (AREA)

Abstract

The present application relates to a two-dimensional code image processing method, apparatus, device, storage medium, and program product, the method comprising: sampling the cut original two-dimensional code image to obtain a two-dimensional code image to be analyzed; processing the two-dimensional code image to be analyzed based on the mapping relation between the actual gray value and the target gray value of the two-dimensional code image to be analyzed to obtain a target two-dimensional code image; performing gray histogram statistics on the target two-dimensional code image, and determining a value range in which a conversion threshold corresponding to the target two-dimensional code image is located based on a gray histogram statistical result; determining a middle conversion threshold corresponding to the target two-dimensional code image based on the middle value of the value range; and performing binarization conversion processing on the target two-dimensional code image according to the value range and the intermediate conversion threshold value to obtain a processing result corresponding to the target two-dimensional code image.

Description

Two-dimensional code image processing method, device, equipment, storage medium and program product
Technical Field
The present application relates to the field of image processing technologies, and in particular, to a two-dimensional code image processing method, apparatus, device, storage medium, and program product.
Background
In recent years, various embedded products have been provided, and two-dimensional codes are selected as media for transferring WiFi account passwords and other verification information. The wireless network camera (i.e. WiFi camera) is one of the embedded products, and because this type of product has certain operation limitations, it can only access the wireless network by analyzing the externally transmitted wireless network connection information. In general, a wireless network camera performs configuration of relevant network parameters by scanning and analyzing a two-dimensional code including wireless network connection information generated by an external terminal device.
However, because the image signal processing unit in the wireless network camera performs some adaptive changes on the acquired image brightness based on the external illumination condition, when the screen brightness of the terminal device for displaying the two-dimensional code is too high and the external illumination condition is not good, the two-dimensional code image processed by the image signal processing unit often shows an overexposure state, which directly affects the success rate of identifying the two-dimensional code image. Therefore, based on the prior art, it is difficult to realize accurate identification of a two-dimensional code image in a wireless network camera.
Disclosure of Invention
In view of the foregoing, it is desirable to provide a two-dimensional code image processing method, apparatus, device, storage medium, and program product.
In a first aspect, the present application provides a two-dimensional code image processing method, which is applied to a wireless network camera, and the method includes:
sampling the cut original two-dimensional code image to obtain a two-dimensional code image to be analyzed;
processing the two-dimensional code image to be analyzed based on the mapping relation between the actual gray value and the target gray value of the two-dimensional code image to be analyzed to obtain a target two-dimensional code image;
performing gray histogram statistics on the target two-dimensional code image, and determining a value range in which a conversion threshold corresponding to the target two-dimensional code image is located based on a gray histogram statistical result;
determining a middle conversion threshold corresponding to the target two-dimensional code image based on the middle value of the value range;
and performing binarization conversion processing on the target two-dimensional code image according to the value range and the intermediate conversion threshold value to obtain a processing result corresponding to the target two-dimensional code image.
In one embodiment, the sampling the clipped original two-dimensional code image to obtain a two-dimensional code image to be analyzed includes:
performing edge cutting on the original two-dimensional code image based on a preset image size to obtain a cut original two-dimensional code image; and performing interlaced alternate sampling on the cut original two-dimensional code image to obtain the two-dimensional code image to be analyzed.
In one embodiment, the processing the to-be-analyzed two-dimensional code image based on the mapping relationship between the actual gray value and the target gray value of the to-be-analyzed two-dimensional code image to obtain the target two-dimensional code image includes:
determining a value interval of an actual gray value of each pixel point of the two-dimensional code image to be analyzed based on the image brightness gain information; determining a target gray value corresponding to each actual gray value according to the value interval and a preset gray mapping rule; and processing the two-dimensional code image to be analyzed based on the target gray value to obtain the target two-dimensional code image.
In one embodiment, the determining, based on the statistical result of the histogram of gray scale, a value range in which a conversion threshold corresponding to the target two-dimensional code image is located includes:
traversing the statistical result of the gray histogram by adopting a pre-configured sliding window, and determining the position of a wave crest of the statistical result of the gray histogram; determining the starting position of the value range on one side close to the original point in the gray level histogram statistical result based on the shortest distance from the position of the peak to the balance position; and obtaining the end position of the value range according to the starting position of the value range and a preset translation step length.
In one embodiment, the sampling range of the sliding window is determined based on the width value of the sliding window; the sampling threshold of the sliding window is determined based on the height value of the sliding window.
In one embodiment, the performing binarization conversion processing on the target two-dimensional code image according to the value range and the intermediate conversion threshold to obtain a processing result corresponding to the target two-dimensional code image includes:
performing binarization conversion processing on the target two-dimensional code image according to the starting position of the value range, the end position of the value range and the intermediate conversion threshold value to obtain a processing result corresponding to the target two-dimensional code image; and identifying the target two-dimensional code image based on a processing result corresponding to the target two-dimensional code image.
In a second aspect, the present application further provides a two-dimensional code image processing apparatus, which is applied to a wireless network camera, and the apparatus includes:
the image sampling module is used for sampling the cut original two-dimensional code image to obtain a two-dimensional code image to be analyzed;
the gray mapping module is used for processing the two-dimensional code image to be analyzed based on the mapping relation between the actual gray value and the target gray value of the two-dimensional code image to be analyzed to obtain a target two-dimensional code image;
the threshold range determining module is used for carrying out gray histogram statistics on the target two-dimensional code image and determining a value range where a conversion threshold corresponding to the target two-dimensional code image is located based on a gray histogram statistical result;
the intermediate threshold value determining module is used for determining an intermediate conversion threshold value corresponding to the target two-dimensional code image based on the intermediate value of the value range;
and the processing result acquisition module is used for carrying out binarization conversion processing on the target two-dimensional code image according to the value range and the intermediate conversion threshold value to obtain a processing result corresponding to the target two-dimensional code image.
In a third aspect, the present application also provides a computer device. The computer device comprises a memory storing a computer program and a processor implementing the steps of the above method when executing the computer program.
In a fourth aspect, the present application further provides a computer-readable storage medium. The computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the above-mentioned method.
In a fifth aspect, the present application further provides a computer program product. The computer program product comprises a computer program which, when being executed by a processor, carries out the steps of the above-mentioned method.
According to the two-dimensional code image processing method, the two-dimensional code image processing device, the two-dimensional code image processing equipment, the storage medium and the program product, firstly, the cut original two-dimensional code image is sampled, and the two-dimensional code image to be analyzed is obtained. And then, processing the two-dimensional code image to be analyzed based on the mapping relation between the actual gray value and the target gray value of the two-dimensional code image to be analyzed to obtain the target two-dimensional code image. And then, carrying out gray histogram statistics on the target two-dimensional code image, and determining the value range of the conversion threshold corresponding to the target two-dimensional code image based on the gray histogram statistical result. And then, determining a middle conversion threshold corresponding to the target two-dimensional code image based on the middle value of the value range. And finally, performing binarization conversion processing on the target two-dimensional code image according to the value range and the intermediate conversion threshold value to obtain a processing result corresponding to the target two-dimensional code image. According to the method and the device, firstly, resampling is carried out on a cut original two-dimensional code image, then, on the basis of the mapping relation between the actual gray value and the target gray value of the resampled two-dimensional code image, the gray value corresponding to each pixel point in the two-dimensional code image is brought into the range of the target gray value, and finally, the two-dimensional code image is subjected to binaryzation conversion through the conversion threshold value range selected dynamically.
Drawings
Fig. 1 is a schematic flowchart of a two-dimensional code image processing method in one embodiment;
fig. 2 is a schematic flow chart illustrating a specific manner of obtaining a two-dimensional code image to be analyzed in one embodiment;
FIG. 3 is a schematic flow chart illustrating a specific manner of obtaining a target two-dimensional code image according to an embodiment;
fig. 4 is a schematic flow chart illustrating a specific manner of determining a value range in which a transition threshold value is located in one embodiment;
fig. 5 is a schematic flow chart illustrating a specific manner of obtaining a processing result corresponding to a target two-dimensional code image in one embodiment;
fig. 6 is a block diagram showing a configuration of a two-dimensional code image processing apparatus according to an embodiment;
FIG. 7 is a diagram illustrating an internal structure of a computer device according to an embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
As used herein, the singular forms "a", "an" and "the" may include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms "comprises/comprising," "includes" or "including," or "having," and the like, specify the presence of stated features, integers, steps, operations, components, parts, or combinations thereof, but do not preclude the presence or addition of one or more other features, integers, steps, operations, components, parts, or combinations thereof. Also, as used in this specification, the term "and/or" includes any and all combinations of the associated listed items.
In recent years, various embedded products have been provided, and two-dimensional codes are selected as media for transferring WiFi account passwords and other verification information. The wireless network camera (i.e. WiFi camera) is one of the embedded products, and because this type of product has certain operation limitations, it can only access the wireless network by analyzing the externally transmitted wireless network connection information. Generally, a wireless network camera scans a two-dimensional code containing wireless network connection information generated by an external terminal device, transmits an obtained two-dimensional code image to a two-dimensional code image recognition library, such as a zbar library, in the wireless network camera for recognition and analysis, and configures related network parameters based on an analysis result.
However, because an Image Signal processing unit (ISP) in the wireless network camera may perform some adaptive changes on the acquired Image brightness based on the external illumination condition, and when the screen brightness of the terminal device for displaying the two-dimensional code is too high and the external illumination condition is not good, the two-dimensional code Image processed by the Image Signal processing unit often shows an overexposed state, which may directly affect the recognition success rate of the two-dimensional code Image.
In addition, because the wireless network camera adopts an embedded system with specificity, the use mode of the available memory of the wireless network camera has a plurality of limitations, the analysis time of the two-dimensional code recognition library on the two-dimensional code increases along with the increase of the image size, and the two-dimensional code image obtained based on the prior art still has a certain redundant data amount, which not only brings extra burden to the memory capacity of the wireless network camera, but also reduces the efficiency of two-dimensional code image recognition in the wireless network camera.
Therefore, based on the prior art, the two-dimensional code image is difficult to be accurately identified in the wireless network camera, and the problem of low efficiency in identifying the two-dimensional code image exists.
The two-dimensional code image processing method provided by the embodiment of the application can be applied to a server to execute. The data storage system can store data to be processed by the server; the data storage system can be integrated on a server, and can also be placed on a cloud or other network servers; the server may be implemented as a stand-alone server or as a server cluster comprised of multiple servers.
In one embodiment, as shown in fig. 1, there is provided a two-dimensional code image processing method applied to a wireless network camera, including the following steps:
and step S110, sampling the cut original two-dimensional code image to obtain a two-dimensional code image to be analyzed.
In this step, the original two-dimensional code image is an original two-dimensional code image acquired by means of camera shooting and the like; sampling the cut original two-dimensional code image, namely cutting the collected original two-dimensional code image based on a preset size, and then re-sampling the cut original two-dimensional code image; the two-dimension code image to be analyzed refers to the steps of firstly cutting an original two-dimension code image obtained through collection based on a preset size, and then resampling the cut original two-dimension code image, so as to obtain the two-dimension code image to be analyzed.
In practical applications, the original two-dimensional code image may be an original two-dimensional code image with a higher resolution acquired by a front-end camera of the wireless network camera, for example, an original two-dimensional code image with a resolution of 1080P acquired by a front-end camera of the wireless network camera.
And step S120, processing the two-dimensional code image to be analyzed based on the mapping relation between the actual gray value and the target gray value of the two-dimensional code image to be analyzed to obtain the target two-dimensional code image.
In this step, the two-dimensional code image to be analyzed refers to that the acquired original two-dimensional code image is cut based on a preset size, and then the cut original two-dimensional code image is resampled, so that the obtained two-dimensional code image to be analyzed is obtained; the actual gray value of the two-dimensional code image to be analyzed refers to the actual gray value corresponding to each pixel point in the two-dimensional code image to be analyzed; the target gray value refers to a target gray value corresponding to each pixel point in the two-dimensional code image to be analyzed; the mapping relation between the actual gray value of the two-dimensional code image to be analyzed and the target gray value refers to the mapping relation between the actual gray value corresponding to each pixel point in the two-dimensional code image to be analyzed and the target gray value corresponding to each pixel point in the two-dimensional code image to be analyzed; the target two-dimensional code image is a target two-dimensional code image obtained by processing the two-dimensional code image to be analyzed based on the mapping relationship between the actual gray value corresponding to each pixel point in the two-dimensional code image to be analyzed and the target gray value corresponding to each pixel point in the two-dimensional code image to be analyzed.
In practical application, a specific manner of processing the two-dimensional code image to be analyzed based on the mapping relationship between the actual gray value and the target gray value of the two-dimensional code image to be analyzed may be to replace the actual gray value corresponding to each pixel point in the two-dimensional code image to be analyzed by using the target gray value corresponding to each pixel point in the two-dimensional code image to be analyzed, so that the gray value interval corresponding to each pixel point in the two-dimensional code image to be analyzed all falls into the target gray value interval.
Step S130, carrying out gray histogram statistics on the target two-dimensional code image, and determining the value range of the conversion threshold corresponding to the target two-dimensional code image based on the gray histogram statistical result.
In this step, the target two-dimensional code image refers to a mapping relationship between an actual gray value corresponding to each pixel point in the two-dimensional code image to be analyzed and a target gray value corresponding to each pixel point in the two-dimensional code image to be analyzed, and the two-dimensional code image to be analyzed is processed, so that the obtained target two-dimensional code image is obtained; the gray histogram statistical result refers to a gray histogram statistical result obtained by performing gray histogram statistics on the target two-dimensional code image; determining the value range of the conversion threshold corresponding to the target two-dimensional code image based on the statistical result of the gray histogram, namely determining the value range of the conversion threshold corresponding to the target two-dimensional code image in the statistical result of the gray histogram.
And step S140, determining a middle conversion threshold corresponding to the target two-dimensional code image based on the middle value of the value range.
In this step, the value range refers to a value range in which a conversion threshold corresponding to the target two-dimensional code image is located; the middle value of the value range refers to the middle value of the value range where the conversion threshold corresponding to the target two-dimensional code image is located; the target two-dimensional code image is a target two-dimensional code image obtained by processing the two-dimensional code image to be analyzed based on the mapping relation between the actual gray value corresponding to each pixel point in the two-dimensional code image to be analyzed and the target gray value corresponding to each pixel point in the two-dimensional code image to be analyzed; determining a middle conversion threshold corresponding to the target two-dimensional code image based on the middle value of the value range, wherein the middle value of the value range where the conversion threshold corresponding to the target two-dimensional code image is located is used as the middle conversion threshold corresponding to the target two-dimensional code image.
And S150, performing binarization conversion processing on the target two-dimensional code image according to the value range and the intermediate conversion threshold value to obtain a processing result corresponding to the target two-dimensional code image.
In this step, the value range refers to a value range in which a conversion threshold corresponding to the target two-dimensional code image is located; the intermediate conversion threshold is an intermediate conversion threshold corresponding to the target two-dimensional code image and determined based on the intermediate value of the value range; the target two-dimensional code image is a mapping relation between an actual gray value corresponding to each pixel point in the two-dimensional code image to be analyzed and a target gray value corresponding to each pixel point in the two-dimensional code image to be analyzed, and the two-dimensional code image to be analyzed is processed, so that the obtained target two-dimensional code image is obtained; performing binarization conversion processing on the target two-dimensional code image according to the value range and the intermediate conversion threshold value, wherein the binarization conversion processing is performed on the target two-dimensional code image respectively based on the value range and the intermediate conversion threshold value; the processing result corresponding to the target two-dimensional code image is a processing result corresponding to the target two-dimensional code image obtained by performing binarization conversion processing on the target two-dimensional code image based on the value range and the intermediate conversion threshold value.
According to the two-dimensional code image processing method, firstly, the clipped original two-dimensional code image is sampled to obtain the two-dimensional code image to be analyzed. And then, processing the two-dimensional code image to be analyzed based on the mapping relation between the actual gray value and the target gray value of the two-dimensional code image to be analyzed to obtain the target two-dimensional code image. And then, carrying out gray histogram statistics on the target two-dimensional code image, and determining the value range of the conversion threshold corresponding to the target two-dimensional code image based on the gray histogram statistical result. And then, determining a middle conversion threshold corresponding to the target two-dimensional code image based on the middle value of the value range. And finally, performing binarization conversion processing on the target two-dimensional code image according to the value range and the intermediate conversion threshold value to obtain a processing result corresponding to the target two-dimensional code image. According to the method and the device, firstly, resampling is carried out on a cut original two-dimensional code image, then, based on the mapping relation between the actual gray value and the target gray value of the two-dimensional code image after resampling, the gray value corresponding to each pixel point in the two-dimensional code image is brought into the target gray value range, finally, the two-dimensional code image is subjected to binarization conversion by adopting a conversion threshold value range which is dynamically selected, the accuracy rate of identification for the two-dimensional code image is improved on the basis of effectively improving the quality of the two-dimensional code image after binarization processing, the redundant data volume in identification for the two-dimensional code image can be reduced, and the efficiency of identification for the two-dimensional code image is effectively improved.
As to a specific manner of obtaining the two-dimensional code image to be analyzed, in an embodiment, as shown in fig. 2, the step S110 specifically includes:
and step S210, based on the preset image size, performing edge cutting on the original two-dimensional code image to obtain a cut original two-dimensional code image.
In the step, the original two-dimensional code image refers to an original two-dimensional code image acquired by means of camera shooting and the like; the cut original two-dimensional code image refers to a cut original two-dimensional code image obtained by performing edge cutting on the original two-dimensional code image based on a preset image size.
In practical application, assuming that an original two-dimensional code image with a resolution of 1080P is acquired through a front-end camera of a wireless network camera and a preset image size is 1600 × 800 (width × height), edge clipping is performed on the original two-dimensional code image based on the preset image size to obtain a clipped original two-dimensional code
The image is an original two-dimensional code image 5 with the resolution of 1080P, which is subjected to edge cutting based on the preset image size of 1600 × 800 to obtain a cut original two-dimensional code image with the image size of 1600 × 800; the specific reason why the original two-dimensional code image is subjected to edge clipping based on the preset image size may be that in the actual two-dimensional code scanning operation, the probability that the user places the two-dimensional code image at the edge position of the camera is low (that is, the utilization rate of the image edge position is low), and the acquired image edge position often has shadows
The distortion of the identification accuracy rate is responded (namely the utilization rate is low), so that most useful information in the original two-dimensional code image can be reserved in a mode of performing edge 0 cutting on the original two-dimensional code image, the size of the image subjected to edge cutting can be effectively reduced, and the problem that the available memory of a wireless network camera adopting an embedded system with specificity is limited can be solved.
And step S220, performing interlaced alternate sampling on the cut original two-dimensional code image to obtain a two-dimensional code image to be analyzed.
In the step 5, the cut original two-dimensional code image refers to a cut original two-dimensional code image obtained by performing edge cutting on the original two-dimensional code image based on a preset image size; the method for sampling the cut original two-dimensional code image in alternate lines and columns means that the cut original two-dimensional code image is resampled in a mode of extracting one line of data in alternate lines and one line of data in alternate columns so as to enable the original two-dimensional code image to be resampled
The size of the newly sampled image is half of the size of the original image; the two-dimensional code image to be analyzed is a mode of extracting one row of data at intervals of one row and one column of data at intervals of one column for the original two-dimensional code image of 0 after being cut,
and re-sampling is carried out, so that a two-dimensional code image to be analyzed is obtained.
In practical applications, assuming that the cropped original two-dimensional code image is cropped from an original image with a resolution of 1080P and the image size of the cropped original two-dimensional code image is 1600 × 800, the cropped original two-dimensional code image is resampled by extracting one row of data at intervals and one column of data at intervals, and a two-dimensional code image to be analyzed with an image size of 800 × 400 (width × height) can be obtained 5. Compared with the wireless network camera, the size of the two-dimensional code image is adjusted by directly setting the target resolution or the target image size of the collected image, the two-dimensional code image is resampled by adopting the method, the definition of the processed two-dimensional code image can be effectively improved, and more useful information is reserved in the processed two-dimensional code image.
According to the embodiment, the original two-dimensional code image after being cut is subjected to interlaced sampling at intervals to obtain the two-dimensional code image to be analyzed, so that the effective control on the size of the two-dimensional code image is successfully realized, the definition of the two-dimensional code image after the image size is adjusted is improved, the processing efficiency of the two-dimensional code image is improved, and the identification accuracy on the two-dimensional code image is guaranteed.
As to a specific manner of obtaining the target two-dimensional code image, in an embodiment, as shown in fig. 3, the step S120 specifically includes:
step S310, determining a value interval where the actual gray value of each pixel point of the two-dimensional code image to be analyzed is located based on the image brightness gain information.
In this step, the image brightness gain information may be embodied as a brightness-related parameter that is set in an image signal processing unit in the wireless network camera by a user and is used for performing brightness gain on the captured image, and the user may reduce a value range of an image gray value by adjusting the brightness-related parameter; the determination of the value interval of the actual gray value of each pixel point of the two-dimensional code image to be analyzed based on the image brightness gain information means that the value interval of the actual gray value of each pixel point of the two-dimensional code image to be analyzed is determined after the actual gray value of each pixel point of the two-dimensional code image to be analyzed is determined based on the image brightness gain information.
Step S320, determining a target gray value corresponding to each actual gray value according to the value range and the preset gray mapping rule.
In this step, the value range refers to a value range in which the actual gray value of each pixel point of the two-dimensional code image to be analyzed is located; the preset gray mapping rule is a preset gray mapping rule which maps the value interval of the actual gray value of each pixel point of the two-dimensional code image to be analyzed to the value interval of the target gray value; the target gray value corresponding to each actual gray value refers to a target gray value corresponding to the actual gray value of each pixel point of the two-dimensional code image to be analyzed.
In practical applications, the preset gray scale mapping rule may map the minimum value of the value range to 0, and map the maximum value of the value range to 255 (that is, map the value range of the actual gray scale value to the target gray scale value range [0,255 ]), so as to restore the gray scale value range of the two-dimensional code image adjusted by the image brightness gain information to the normal gray scale value range.
And step S330, processing the two-dimensional code image to be analyzed based on the target gray value to obtain a target two-dimensional code image.
In this step, the target gray value, that is, the target gray value corresponding to each actual gray value, refers to the target gray value corresponding to the actual gray value of each pixel point of the two-dimensional code image to be analyzed; the target two-dimensional code image is obtained by replacing an actual gray value corresponding to each pixel point of the two-dimensional code image to be analyzed with a target gray value corresponding to the pixel point.
In the embodiment, the actual gray value corresponding to each pixel point in the two-dimensional code image is determined based on the image brightness gain information, and the target two-dimensional code image is obtained according to the mapping relationship between each gray value and the target gray value, so that the gray value range corresponding to the two-dimensional code image is restored to be within the normal gray value range, and therefore, the problem that the identification accuracy of the two-dimensional code image is reduced due to the fact that the acquired two-dimensional code image is automatically adjusted by adopting the preset image brightness gain information is effectively solved, and the efficiency of identifying the two-dimensional code image is improved.
As to the specific manner of determining the value range where the conversion threshold is located, in an embodiment, as shown in fig. 4, the step S130 specifically includes:
and step S410, traversing the gray histogram statistical result by adopting a pre-configured sliding window, and determining the position of the peak of the gray histogram statistical result.
In this step, the pre-configured sliding window refers to a sliding window in which parameter configurations such as a sampling range, a sampling threshold, a continuous sampling interval, and the like are performed in advance; the gray histogram statistical result refers to a gray histogram statistical result obtained by performing gray histogram statistics on the target two-dimensional code image; the peak position of the gray histogram statistical result is the peak position of the gray histogram statistical result determined after traversing the gray histogram statistical result by adopting the pre-configured sliding window.
In practical application, the continuous sampling interval may be set to start from the minimum value 0 of the pixel gray-scale value and then end by sliding to the maximum value 255 of the pixel gray-scale value, so as to traverse the gray-scale histogram statistical result and further find out the position of the peak in the gray-scale histogram statistical result.
Step S420, determining a starting point position of the value range based on the shortest distance from the peak position to the equilibrium position on the side close to the origin in the gray histogram statistical result.
In this step, the grayscale histogram statistical result refers to a grayscale histogram statistical result obtained by performing grayscale histogram statistics on the target two-dimensional code image; the side close to the origin in the statistical result of the gray histogram refers to the side close to the 0 value (i.e. the origin of the rectangular coordinate system) in the statistical result of the gray histogram; the position of the wave peak, namely the position of the wave peak of the gray histogram statistical result, means that the position of the wave peak of the gray histogram statistical result is determined after traversing the gray histogram statistical result by adopting the pre-configured sliding window; the shortest distance from the position of the peak to the equilibrium position is the shortest distance from the position of the peak to the equilibrium position (namely, the gentle position with relatively small change slope of the average value); the value range refers to the value range of a conversion threshold value corresponding to the target two-dimensional code image; the starting point position of the value range refers to the starting point position of the value range where the conversion threshold corresponding to the target two-dimensional code image is located, which is determined on the side, close to the original point, in the gray level histogram statistical result based on the shortest distance from the peak position to the balance position.
And step S430, obtaining the end position of the value range according to the start position of the value range and the preset translation step length.
In this step, the value range refers to a value range in which a conversion threshold corresponding to the target two-dimensional code image is located; the starting point position of the value range refers to the starting point position of the value range where the conversion threshold corresponding to the target two-dimensional code image is located, which is determined on the basis of the shortest distance from the peak position to the balance position, on the side, close to the original point, in the gray histogram statistical result; the preset translation step length is a preset translation step length representing a specific distance for translation from the starting position of the value range to the increasing direction of the X-axis numerical value of the rectangular coordinate system in the statistical result of the gray level histogram; the end position of the value range refers to the end position of the value range obtained after the corresponding distance of the translation in the direction is increased from the start position of the value range to the X-axis numerical value of the rectangular coordinate system in the statistical result of the gray histogram according to the start position of the value range and the preset translation step length.
According to the embodiment, the image quality of the two-dimensional code image after binarization processing is improved by dynamically selecting the value range of the conversion threshold value for performing binarization conversion on the two-dimensional code image, on the basis of successfully avoiding the problem that black points in the two-dimensional code image are not obvious due to overexposure of the image, and the accuracy rate for identifying the two-dimensional code image is effectively improved.
As to a specific manner of setting the sliding window for sampling, in an embodiment, the sampling range of the sliding window is determined based on the width value of the sliding window; the sampling threshold value of the sliding window is determined based on the height value of the sliding window.
As to a specific manner of obtaining the processing result corresponding to the target two-dimensional code image, in an embodiment, as shown in fig. 5, the step S150 specifically includes:
step S510, performing binarization conversion processing on the target two-dimensional code image according to the starting position of the value range, the ending position of the value range, and the intermediate conversion threshold value, so as to obtain a processing result corresponding to the target two-dimensional code image.
In this step, the value range refers to a value range in which a conversion threshold corresponding to the target two-dimensional code image is located; the starting point position of the value range refers to the starting point position of the value range where the conversion threshold corresponding to the target two-dimensional code image is located, which is determined on the basis of the shortest distance from the peak position to the balance position, on the side, close to the original point, in the gray histogram statistical result; the end position of the value range refers to the end position of the value range obtained after the corresponding distance of the translation in the direction is increased from the start position of the value range to the X-axis numerical value of the rectangular coordinate system in the statistical result of the gray histogram according to the start position of the value range and the preset translation step length; the intermediate conversion threshold value is an intermediate conversion threshold value corresponding to the target two-dimensional code image and determined based on the intermediate value of the value range; the processing results corresponding to the target two-dimensional code image are three processing results corresponding to the target two-dimensional code image, which are obtained by performing binarization conversion processing on the target two-dimensional code image based on the starting point position of the value range, the end point position of the value range and the intermediate conversion threshold respectively (namely, a first processing result corresponding to the target two-dimensional code image obtained by performing binarization conversion processing on the target two-dimensional code image based on the starting point position of the value range, a second processing result corresponding to the target two-dimensional code image obtained by performing binarization conversion processing on the target two-dimensional code image based on the end point position of the value range, and a third processing result corresponding to the target two-dimensional code image obtained by performing binarization conversion processing on the target two-dimensional code image based on the intermediate conversion threshold).
Step S520, identifying the target two-dimensional code image based on the processing result corresponding to the target two-dimensional code image.
In this step, the processing results corresponding to the target two-dimensional code image refer to three processing results corresponding to the target two-dimensional code image obtained by performing binarization conversion on the target two-dimensional code image based on the starting position of the value range, the end position of the value range and the intermediate conversion threshold; identifying the target two-dimensional code image based on the processing result corresponding to the target two-dimensional code image means that the identification and the analysis are sequentially performed on the three processing results corresponding to the target two-dimensional code image.
In practical application, the specific manner of sequentially identifying and analyzing the three processing results corresponding to the target two-dimensional code image may be that the three processing results corresponding to the target two-dimensional code image are sequentially sent to a two-dimensional code identification library built in the wireless network camera to identify and analyze the two-dimensional code image.
According to the embodiment, the processing result corresponding to the target two-dimensional code image is obtained based on the starting position, the end position and the middle conversion threshold of the value range where the conversion threshold is located, so that the image quality of the two-dimensional code image after binarization processing is improved, more useful information in the two-dimensional code image is reserved, and the accuracy of identification on the two-dimensional code image is effectively improved.
It should be understood that, although the steps in the flowcharts related to the embodiments described above are shown in sequence as indicated by the arrows, the steps are not necessarily performed in sequence as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least a part of the steps in the flowcharts related to the embodiments described above may include multiple steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, and the execution order of the steps or stages is not necessarily sequential, but may be performed alternately or alternately with other steps or at least a part of the steps or stages in other steps.
Based on the same inventive concept, the embodiment of the present application further provides a two-dimensional code image processing apparatus for implementing the above-mentioned X two-dimensional code image processing method. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme described in the method, so that specific limitations in one or more embodiments of the two-dimensional code image processing device provided below can be referred to the limitations on the two-dimensional code image processing method in the foregoing, and details are not repeated herein.
In one embodiment, as shown in fig. 6, there is provided a two-dimensional code image processing apparatus applied to a wireless network camera, the apparatus 600 including:
the image sampling module 610 is configured to sample the clipped original two-dimensional code image to obtain a two-dimensional code image to be analyzed;
the gray mapping module 620 is configured to process the two-dimensional code image to be analyzed based on a mapping relationship between an actual gray value and a target gray value of the two-dimensional code image to be analyzed to obtain a target two-dimensional code image;
a threshold range determining module 630, configured to perform grayscale histogram statistics on the target two-dimensional code image, and determine, based on a grayscale histogram statistical result, a value range in which a conversion threshold corresponding to the target two-dimensional code image is located;
an intermediate threshold determining module 640, configured to determine an intermediate conversion threshold corresponding to the target two-dimensional code image based on the intermediate value of the value range;
and the processing result obtaining module 650 is configured to perform binarization conversion processing on the target two-dimensional code image according to the value range and the intermediate conversion threshold value, so as to obtain a processing result corresponding to the target two-dimensional code image.
In one embodiment, the image sampling module 610 is specifically configured to perform edge clipping on an original two-dimensional code image based on a preset image size to obtain a clipped original two-dimensional code image; and performing interlaced alternate sampling on the cut original two-dimensional code image to obtain the two-dimensional code image to be analyzed.
In one embodiment, the gray mapping module 620 is specifically configured to determine, based on the image brightness gain information, a value range in which an actual gray value of each pixel of the two-dimensional code image to be analyzed is located; determining a target gray value corresponding to each actual gray value according to the value range and a preset gray mapping rule; and processing the two-dimensional code image to be analyzed based on the target gray value to obtain the target two-dimensional code image.
In one embodiment, the threshold range determining module 630 is specifically configured to traverse the grayscale histogram statistical result by using a pre-configured sliding window, and determine a position of a peak of the grayscale histogram statistical result; determining the starting position of the value range on one side close to the original point in the gray level histogram statistical result based on the shortest distance from the position of the peak to the balance position; and obtaining the end position of the value range according to the starting position of the value range and a preset translation step length.
In one embodiment, in the threshold range determining module 630, the sampling range of the sliding window is determined based on the width value of the sliding window; the sampling threshold of the sliding window is determined based on the height value of the sliding window.
In one embodiment, the processing result obtaining module 650 is specifically configured to perform binarization conversion processing on the target two-dimensional code image according to the starting position of the value range, the ending position of the value range, and the intermediate conversion threshold, so as to obtain a processing result corresponding to the target two-dimensional code image; and identifying the target two-dimensional code image based on the processing result corresponding to the target two-dimensional code image.
All or part of the modules in the two-dimensional code image processing device can be realized by software, hardware and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, a computer device is provided, which may be a server, the internal structure of which may be as shown in fig. 7. The computer device includes a processor, a memory, an Input/Output interface (I/O for short), and a communication interface. The processor, the memory and the input/output interface are connected through a system bus, and the communication interface is connected to the system bus through the input/output interface. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operating system and the computer program to run on the non-volatile storage medium. The database of the computer equipment is used for storing data such as two-dimensional code image processing related data. The input/output interface of the computer device is used for exchanging information between the processor and an external device. The communication interface of the computer device is used for connecting and communicating with an external terminal through a network. The computer program is executed by a processor to implement a two-dimensional code image processing method.
Those skilled in the art will appreciate that the architecture shown in fig. 7 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, a computer device is provided, comprising a memory and a processor, the memory having stored therein a computer program, the processor implementing the steps of the above-described method embodiments when executing the computer program.
In an embodiment, a computer-readable storage medium is provided, on which a computer program is stored, which computer program, when being executed by a processor, carries out the steps of the above-mentioned method embodiments.
In an embodiment, a computer program product is provided, comprising a computer program which, when executed by a processor, carries out the steps in the method embodiments described above.
It should be noted that, the user information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) referred to in the present application are information and data authorized by the user or sufficiently authorized by each party, and the collection, use and processing of the related data need to comply with the relevant laws and regulations and standards of the relevant country and region.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, database, or other medium used in the embodiments provided herein may include at least one of non-volatile and volatile memory. The nonvolatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical Memory, high-density embedded nonvolatile Memory, resistive Random Access Memory (ReRAM), magnetic Random Access Memory (MRAM), ferroelectric Random Access Memory (FRAM), phase Change Memory (PCM), graphene Memory, and the like. Volatile Memory can include Random Access Memory (RAM), external cache Memory, and the like. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM), among others. The databases referred to in various embodiments provided herein may include at least one of relational and non-relational databases. The non-relational database may include, but is not limited to, a block chain based distributed database, and the like. The processors referred to in the various embodiments provided herein may be, without limitation, general purpose processors, central processing units, graphics processors, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, or the like.
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the present application. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present application shall be subject to the appended claims.

Claims (10)

1. A two-dimensional code image processing method is characterized by being applied to a wireless network camera, and comprises the following steps:
sampling the cut original two-dimensional code image to obtain a two-dimensional code image to be analyzed;
processing the two-dimensional code image to be analyzed based on the mapping relation between the actual gray value and the target gray value of the two-dimensional code image to be analyzed to obtain a target two-dimensional code image;
performing gray histogram statistics on the target two-dimensional code image, and determining a value range in which a conversion threshold corresponding to the target two-dimensional code image is located based on a gray histogram statistical result;
determining a middle conversion threshold corresponding to the target two-dimensional code image based on the middle value of the value range;
and performing binarization conversion processing on the target two-dimensional code image according to the value range and the intermediate conversion threshold value to obtain a processing result corresponding to the target two-dimensional code image.
2. The method of claim 1, wherein the sampling the clipped original two-dimensional code image to obtain a two-dimensional code image to be analyzed comprises:
performing edge cutting on the original two-dimensional code image based on a preset image size to obtain a cut original two-dimensional code image;
and performing interlaced alternate sampling on the cut original two-dimensional code image to obtain the two-dimensional code image to be analyzed.
3. The method according to claim 1, wherein the processing the two-dimensional code image to be analyzed based on the mapping relationship between the actual gray value and the target gray value of the two-dimensional code image to be analyzed to obtain the target two-dimensional code image comprises:
determining a value interval of an actual gray value of each pixel point of the two-dimensional code image to be analyzed based on the image brightness gain information;
determining a target gray value corresponding to each actual gray value according to the value range and a preset gray mapping rule;
and processing the two-dimensional code image to be analyzed based on the target gray value to obtain the target two-dimensional code image.
4. The method of claim 1, wherein the determining a value range of a conversion threshold corresponding to the target two-dimensional code image based on a gray histogram statistical result includes:
traversing the gray level histogram statistical result by adopting a pre-configured sliding window, and determining the position of a peak of the gray level histogram statistical result;
determining the starting position of the value range on one side close to the original point in the gray level histogram statistical result based on the shortest distance from the position of the peak to the balance position;
and obtaining the end position of the value range according to the starting position of the value range and a preset translation step length.
5. The method of claim 4, wherein the sampling range of the sliding window is determined based on a width value of the sliding window; the sampling threshold of the sliding window is determined based on the height value of the sliding window.
6. The method according to claim 4 or 5, wherein the performing binarization conversion processing on the target two-dimensional code image according to the value range and the intermediate conversion threshold value to obtain a processing result corresponding to the target two-dimensional code image comprises:
performing binarization conversion processing on the target two-dimensional code image according to the starting position of the value range, the end position of the value range and the intermediate conversion threshold value to obtain a processing result corresponding to the target two-dimensional code image;
and identifying the target two-dimensional code image based on the processing result corresponding to the target two-dimensional code image.
7. A two-dimensional code image processing device is characterized by being applied to a wireless network camera, and the device comprises:
the image sampling module is used for sampling the cut original two-dimensional code image to obtain a two-dimensional code image to be analyzed;
the gray mapping module is used for processing the two-dimensional code image to be analyzed based on the mapping relation between the actual gray value and the target gray value of the two-dimensional code image to be analyzed to obtain a target two-dimensional code image;
the threshold range determining module is used for carrying out gray histogram statistics on the target two-dimensional code image and determining a value range where a conversion threshold corresponding to the target two-dimensional code image is located based on a gray histogram statistical result;
the intermediate threshold value determining module is used for determining an intermediate conversion threshold value corresponding to the target two-dimensional code image based on the intermediate value of the value range;
and the processing result acquisition module is used for carrying out binarization conversion processing on the target two-dimensional code image according to the value range and the intermediate conversion threshold value to obtain a processing result corresponding to the target two-dimensional code image.
8. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor, when executing the computer program, implements the steps of the method of any of claims 1 to 6.
9. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 6.
10. A computer program product comprising a computer program, characterized in that the computer program realizes the steps of the method of any one of claims 1 to 6 when executed by a processor.
CN202211683420.5A 2022-12-27 2022-12-27 Two-dimensional code image processing method, device, equipment, storage medium and program product Pending CN115860025A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211683420.5A CN115860025A (en) 2022-12-27 2022-12-27 Two-dimensional code image processing method, device, equipment, storage medium and program product

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211683420.5A CN115860025A (en) 2022-12-27 2022-12-27 Two-dimensional code image processing method, device, equipment, storage medium and program product

Publications (1)

Publication Number Publication Date
CN115860025A true CN115860025A (en) 2023-03-28

Family

ID=85653430

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211683420.5A Pending CN115860025A (en) 2022-12-27 2022-12-27 Two-dimensional code image processing method, device, equipment, storage medium and program product

Country Status (1)

Country Link
CN (1) CN115860025A (en)

Similar Documents

Publication Publication Date Title
CN111179177B (en) Image reconstruction model training method, image reconstruction method, device and medium
CN109685050B (en) Character recognition method, device, equipment and storage medium
CN109784372B (en) Target classification method based on convolutional neural network
CN111597945B (en) Target detection method, device, equipment and medium
CN112419202A (en) Wild animal image automatic identification system based on big data and deep learning
CN111882565B (en) Image binarization method, device, equipment and storage medium
CN112883983A (en) Feature extraction method and device and electronic system
CN111159150A (en) Data expansion method and device
CN111970518A (en) Image frame loss processing method, system, equipment and computer storage medium
CN116862812A (en) Infrared image processing method, device, computer equipment, storage medium and product
CN113657370B (en) Character recognition method and related equipment thereof
CN115240203A (en) Service data processing method, device, equipment and storage medium
CN113065400A (en) Invoice seal detection method and device based on anchor-frame-free two-stage network
CN117523162A (en) Aviation structure image preprocessing method based on deep neural network model
CN115860025A (en) Two-dimensional code image processing method, device, equipment, storage medium and program product
US9838032B2 (en) Data compression device, data compression method, and computer program product
CN115330279A (en) Company selection method based on stock trend graph similarity detection
CN112637609B (en) Image real-time transmission method, sending end and receiving end
CN114511862A (en) Form identification method and device and electronic equipment
RU2728949C1 (en) Method of constructing and processing images and system for implementing thereof
CN114463764A (en) Table line detection method and device, computer equipment and storage medium
US8908986B1 (en) Systems and methods for selecting ink colors
CN113706639A (en) Image compression method and device based on rectangular NAM, storage medium and computing equipment
CN117710235B (en) Image target enhancement method, device, computer equipment and storage medium
CN118505573B (en) Spectral data recovery method, device and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination