Graphic code identification method and device, computer equipment and storage medium
By turning on the flash and image enhancement processing on the terminal device, the problem of low recognition rate of graphic codes in low-light environments is solved, achieving higher recognition accuracy and efficiency.
Patent Information
- Application Number
- CN202410348378.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-26
- Publication Date
- 2024-08-30
AI Technical Summary
In low-light environments, the recognition rate of graphic codes is low, and the ambient light is too strong or reflective, causing code scanning to fail.
By turning on the flash on the terminal device to automatically adjust the screen brightness, and performing image capture and image enhancement processing when recognition is unsuccessful, to improve the graphic code recognition rate.
Improve the recognition rate of graphic codes in low-brightness environments, reduce manual operations by users, improve recognition efficiency and improve the accuracy of graphic code recognition.
Smart Images

Figure CN118569280A
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to a method, device, computer equipment, storage medium and computer program product for recognizing a graphic code. Background Art
[0002] With the popularization of smart phones and the general trend of digital transformation, the usage rate of graphic codes (such as QR codes, barcodes, etc.) is increasing, especially in high-frequency offline payment scenarios.
[0003] However, when a mobile device is used to scan a barcode for identification, if the ambient light is insufficient, the barcode will fail to be scanned. When too much light is irradiated on the surface of the graphic code, the graphic code or the surface to which the graphic code is attached often produces reflections, causing the barcode to fail to be scanned.
[0004] Therefore, there is a problem in the related art that the recognition rate of graphic codes is low. Summary of the invention
[0005] Based on this, it is necessary to provide a method, device, computer equipment, computer-readable storage medium and computer program product for identifying a graphic code that can improve the recognition rate of the graphic code in response to the above technical problems.
[0006] In a first aspect, the present application provides a method for identifying a graphic code, comprising:
[0007] When the code scanning function is turned on, the graphic code of the interface currently displayed by the terminal device is recognized, and when the graphic code information is not recognized, the current screen brightness of the terminal device is obtained;
[0008] When the current screen brightness is lower than a preset brightness threshold, turning on the flash to arouse the automatic screen brightness adjustment function of the terminal device, and performing graphic code recognition on the interface currently displayed by the terminal device;
[0009] In the case where the graphic code information is not recognized, an image to be processed is obtained by photographing the interface currently displayed by the terminal device; pixels of the image to be processed meet a preset condition;
[0010] The image to be processed is subjected to image enhancement processing, and graphic code recognition is performed on the image after the image enhancement processing.
[0011] In one embodiment, turning on the flashlight to invoke the automatic screen brightness adjustment function of the terminal device and performing graphic code recognition on the interface currently displayed by the terminal device includes:
[0012] Continuously turning on the flashlight within a preset time and obtaining the current screen brightness of the terminal device;
[0013] According to the current screen brightness, identifying whether the screen of the terminal device automatically increases the brightness;
[0014] When the screen brightness of the terminal device is automatically increased, a graphic code is identified for the interface currently displayed by the terminal device.
[0015] In one embodiment, obtaining the current screen brightness of the terminal device includes:
[0016] Acquire an image to be brightness recognized obtained by photographing the interface currently displayed by the terminal device; the pixels of the image to be brightness recognized are lower than the pixels of the image to be processed;
[0017] The image brightness of the image to be brightness-recognized is identified, and the current screen brightness is obtained according to the image brightness.
[0018] In one embodiment, the step of performing image enhancement processing on the image to be processed and performing graphic code recognition on the image after image enhancement processing includes:
[0019] Performing image enhancement processing on the image to be processed, and using the image after the image enhancement processing as the enhanced image;
[0020] Performing graphic code extraction processing on the enhanced image to obtain an extraction result;
[0021] The extraction result is subjected to graphic code recognition, and when it is recognized that the extraction result contains the graphic code information, the extracted graphic code information is stored.
[0022] In one embodiment, the method further comprises:
[0023] When it is identified that the extraction result does not contain the graphic code information, the image to be processed is sent to the background; the background is used to input the image to be processed into a pre-trained graphic code recognition model, and perform graphic code recognition on the image to be processed through the pre-trained graphic code recognition model to obtain a graphic code recognition result.
[0024] In one embodiment, the method further comprises:
[0025] When the current screen brightness reaches the preset brightness threshold, return to the step of obtaining the image to be processed obtained by photographing the interface currently displayed on the terminal device.
[0026] In one embodiment, the method further comprises:
[0027] In the case where the screen of the terminal device does not automatically increase the brightness, the process returns to the step of acquiring the image to be processed obtained by photographing the interface currently displayed on the terminal device.
[0028] In a second aspect, the present application further provides a device for recognizing a graphic code, comprising:
[0029] The first recognition module is used to perform graphic code recognition on the interface currently displayed by the terminal device when the code scanning function is turned on, and obtain the current screen brightness of the terminal device when no graphic code information is recognized;
[0030] A second recognition module is used to turn on the flashlight to evoke the automatic screen brightness adjustment function of the terminal device when the current screen brightness is lower than a preset brightness threshold, and perform graphic code recognition on the interface currently displayed by the terminal device;
[0031] A shooting module, used for acquiring an image to be processed obtained by shooting the interface currently displayed by the terminal device when the graphic code information is not recognized; the pixels of the image to be processed meet a preset condition;
[0032] The third recognition module is used to perform image enhancement processing on the image to be processed, and perform graphic code recognition on the image after the image enhancement processing.
[0033] In a third aspect, the present application further provides a computer device, wherein the computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the steps of the above method are implemented.
[0034] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the steps of the above method when executed by a processor.
[0035] In a fifth aspect, the present application further provides a computer program product, wherein the computer program product comprises a computer program, and when the computer program is executed by a processor, the steps of the above method are implemented.
[0036] The above-mentioned graphic code recognition method, device, computer equipment, storage medium and computer program product perform graphic code recognition on the interface currently displayed by the terminal device when the code scanning function is turned on, and obtain the current screen brightness of the terminal device when no graphic code information is recognized; when the current screen brightness is lower than a preset brightness threshold, turn on the flash to arouse the automatic screen brightness adjustment function of the terminal device, and perform graphic code recognition on the interface currently displayed by the terminal device; when no graphic code information is recognized, obtain a to-be-processed image obtained by photographing the interface currently displayed by the terminal device; the pixels of the to-be-processed image meet preset conditions; perform image enhancement processing on the to-be-processed image, and perform graphic code recognition on the image after the image enhancement processing.
[0037] In this way, when the graphic code information is not recognized in the interface currently displayed by the terminal device, the flash is turned on to evoke the screen brightness adjustment function of the terminal device by judging whether the screen brightness of the terminal device reaches the preset brightness threshold, and the graphic code recognition is performed on the interface currently displayed by the terminal device again. If the recognition is not successful, the image is captured, and the image is enhanced, and the graphic code recognition is performed on the image after the image enhancement process to extract the graphic code information, thereby achieving the technical effect of improving the graphic code recognition rate of the terminal device in a low-brightness environment through multiple recognition functions and fill light functions. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0039] Figure 1 A schematic diagram of a flow chart of a method for recognizing a graphic code in an embodiment;
[0040] Figure 2 This is an external structural diagram of a code scanning device in an embodiment;
[0041] Figure 3 This is an internal structure diagram of a code scanning device in one embodiment;
[0042] Figure 4 This is a front view of the appearance of a barcode scanning gun in one embodiment;
[0043] Figure 5 This is a side view of the appearance of a barcode scanning gun in one embodiment;
[0044] Figure 6This is a back view of the appearance of a barcode scanning gun in one embodiment;
[0045] Figure 7 is a flow chart of yet another method for recognizing a graphic code in one embodiment;
[0046] Figure 8 is a flow chart of a method for recognizing a graphic code in another embodiment;
[0047] Fig. 9 is a structural block diagram of a device for recognizing a graphic code in one embodiment;
[0048] FIG. 10 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0049] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0050] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure 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 data used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0051] In one embodiment, Figure 1 As shown, a method for recognizing a graphic code is provided. This embodiment takes the method applied to a code scanning device as an example. In this embodiment, the method includes the following steps:
[0052] Step S110, when the code scanning function is turned on, the graphic code of the interface currently displayed by the terminal device is recognized, and when the graphic code information is not recognized, the current screen brightness of the terminal device is obtained.
[0053] The terminal device may include but is not limited to various personal computers, laptops, smart phones, tablet computers, Internet of Things devices, etc.
[0054] The graphic code information includes but is not limited to bar code information, text code information, one-dimensional code information, two-dimensional code information or three-dimensional code information.
[0055] In a specific implementation, when the code scanning function is turned on, the code scanning device can capture an image of the interface currently displayed by the terminal device for graphic code recognition. If no graphic code information is recognized, the current screen brightness of the terminal device is obtained.
[0056] Among them, the code scanning device can continuously determine whether the collected image information contains graphic code information within a certain period of time (for example, 3 seconds, or other time lengths, which are not specifically limited here). If not, it is determined that the graphic code information is not recognized, and the current screen brightness of the terminal device is further obtained to determine whether the current screen brightness of the terminal device is too low, which may affect the recognition of the graphic code information.
[0057] Among them, the code scanning device can be provided with a code scanning button, and when the code scanning button is pressed, the code scanning function is turned on.
[0058] Step S120, when the current screen brightness is lower than a preset brightness threshold, turning on the flash to arouse the automatic screen brightness adjustment function of the terminal device, and performing graphic code recognition on the interface currently displayed by the terminal device.
[0059] In a specific implementation, when the current screen brightness of the terminal device is lower than a preset brightness threshold, it can be determined that the current screen brightness of the terminal device is low, which may affect the recognition of graphic code information. In this case, the code scanning device can turn on the flash to illuminate the screen of the terminal device to activate the automatic screen brightness adjustment function of the terminal device, and perform graphic code recognition on the interface currently displayed by the terminal device.
[0060] Step S130, when no graphic code information is recognized, obtaining an image to be processed by photographing the interface currently displayed on the terminal device.
[0061] The pixels of the image to be processed meet the preset conditions.
[0062] In a specific implementation, when the code scanning device turns on the flashlight to identify the graphic code of the interface currently displayed by the terminal device, if the code scanning device fails to identify the graphic code information again, the code scanning device can obtain an image obtained by shooting the interface currently displayed by the terminal device as the image to be processed. Among them, the code scanning device can call a high-definition camera to shoot the interface currently displayed by the terminal device to obtain a high-definition image as the image to be processed, so that the pixels of the image to be processed meet the preset high-definition conditions.
[0063] Step S140, performing image enhancement processing on the image to be processed, and performing graphic code recognition on the image after the image enhancement processing.
[0064] In a specific implementation, the code scanning device can perform image enhancement processing on the image to be processed to obtain an image after image enhancement processing, so as to perform graphic code recognition on the image after image enhancement processing.
[0065] In the above-mentioned graphic code recognition method, by turning on the code scanning function, the graphic code recognition is performed on the interface currently displayed by the terminal device, and when the graphic code information is not recognized, the current screen brightness of the terminal device is obtained; when the current screen brightness is lower than a preset brightness threshold, the flash is turned on to arouse the automatic screen brightness adjustment function of the terminal device, and the graphic code recognition is performed on the interface currently displayed by the terminal device; when the graphic code information is not recognized, the image to be processed is obtained by photographing the interface currently displayed by the terminal device; the pixels of the image to be processed meet the preset conditions; image enhancement processing is performed on the image to be processed, and graphic code recognition is performed on the image after the image enhancement processing.
[0066] In this way, when the graphic code information is not recognized in the interface currently displayed by the terminal device, the flash is turned on to evoke the screen brightness adjustment of the terminal device by judging whether the screen brightness of the terminal device reaches the preset brightness threshold, and the graphic code recognition is performed on the interface currently displayed by the terminal device again. If the recognition is not successful, the image is captured, and the image is enhanced, and the graphic code recognition is performed on the image after the image enhancement process to extract the graphic code information, thereby achieving the technical effect of improving the graphic code recognition rate of the terminal device in a low-brightness environment through multiple recognition functions and fill light functions.
[0067] In one embodiment, a flash is turned on to arouse the automatic screen brightness adjustment function of the terminal device, and a graphic code recognition is performed on the interface currently displayed by the terminal device, including: turning on the flash within a preset time period and obtaining the current screen brightness of the terminal device; according to the current screen brightness, identifying whether the screen of the terminal device automatically increases the brightness; when the screen of the terminal device automatically increases the brightness, a graphic code recognition is performed on the interface currently displayed by the terminal device.
[0068] In a specific implementation, when the code scanning device turns on the flash and performs graphic code recognition on the interface currently displayed on the terminal device, the code scanning device can continue to turn on the flash for a preset period of time to invoke the screen brightness adjustment function of the terminal device, and obtain the current screen brightness of the terminal device after the flash is turned on. According to the current screen brightness, it is determined whether the screen of the terminal device automatically increases the brightness, that is, whether the screen brightness adjustment function of the terminal device is successfully awakened, and when the screen of the terminal device automatically increases the brightness, the graphic code recognition is performed on the interface currently displayed by the terminal device.
[0069] When the screen of the terminal device does not automatically increase the brightness, that is, when the screen brightness adjustment function of the terminal device fails to be invoked, the code scanning device directly returns to the step of obtaining the image to be processed by photographing the interface currently displayed by the terminal device, and performs image enhancement processing on the image to be processed to perform graphic code recognition on the image after image enhancement processing. There is no need to directly perform graphic code recognition on the currently displayed interface when the screen of the terminal device does not automatically increase the brightness, thereby avoiding waste of resources caused by invalid recognition.
[0070] The technical solution of this embodiment is to turn on the flashlight within a preset time and obtain the current screen brightness of the terminal device; according to the current screen brightness, identify whether the screen of the terminal device automatically increases the brightness; and when the screen of the terminal device automatically increases the brightness, perform graphic code recognition on the interface currently displayed by the terminal device. In this way, when the flashlight is turned on to successfully invoke the automatic adjustment function of the screen brightness of the terminal device, the graphic code recognition is performed again on the interface currently displayed by the terminal device, realizing the method of automatically invoking the flashlight to compensate for the defect that the screen of the terminal device does not automatically light up, reducing the manual operation of the user and improving the efficiency of graphic code recognition.
[0071] In one embodiment, obtaining the current screen brightness of a terminal device includes: obtaining an image to be recognized by brightness by photographing an interface currently displayed by the terminal device; the pixels of the image to be recognized by brightness are lower than the pixels of the image to be processed; identifying the image brightness of the image to be recognized by brightness, and obtaining the current screen brightness based on the image brightness.
[0072] In a specific implementation, when the code scanning device obtains the current screen brightness of the terminal device, the code scanning device can obtain an image to be recognized by photographing the interface currently displayed by the terminal device; the pixels of the image to be recognized by brightness are lower than the pixels of the image to be processed. Specifically, the code scanning device can call a low-resolution camera to photograph the interface currently displayed by the terminal device, and the image obtained by photographing is used as the image to be recognized by brightness.
[0073] It should be noted that the barcode scanning device may be provided with a low-resolution camera and a high-resolution camera, which are used to capture the image to be brightness recognized and the image to be processed, respectively. The barcode scanning device may also be provided with a camera with two working modes, which can capture the image to be processed by switching to a high-resolution working mode and the image to be processed by switching to a low-resolution working mode. No specific limitation is made here.
[0074] The code scanning device can identify the image brightness of the image to be recognized by brightness, and obtain the current screen brightness of the terminal device according to the image brightness. Among them, the code scanning device can calculate the average brightness of the image to be recognized by brightness to obtain the image brightness. In this way, by shooting the interface currently displayed by the terminal device to obtain a low-pixel image to be recognized by brightness for brightness recognition, it can not only reduce the computing resources and memory consumption required for brightness calculation, but also realize more accurate judgment of the screen brightness of the terminal device through image processing technology.
[0075] In some embodiments, the code scanning device can directly use the image brightness as the current screen brightness. In other embodiments, after calculating the image brightness, the code scanning device can map the image brightness of the image to be brightness-recognized to the corresponding screen brightness according to a preset mapping relationship between the image brightness and the screen brightness, thereby obtaining the current screen brightness of the terminal device.
[0076] The technical solution of this embodiment is to obtain an image to be recognized by brightness by photographing the interface currently displayed by the terminal device; the pixels of the image to be recognized by brightness are lower than the pixels of the image to be processed; the image brightness of the image to be recognized by brightness is identified, and the current screen brightness is obtained according to the image brightness. In this way, by photographing the interface currently displayed by the terminal device to obtain an image to be recognized by brightness with lower pixels, brightness recognition is performed, and the current screen brightness of the terminal device is obtained, which can not only reduce the computing resources and memory consumption required for brightness calculation, but also achieve the technical effect of more accurately judging the screen brightness of the terminal device through image processing technology, thereby improving the accuracy of the judgment of the screen brightness of the terminal device.
[0077] In one embodiment, image enhancement processing is performed on the image to be processed, and graphic code recognition is performed on the image after the image enhancement processing, including: performing image enhancement processing on the image to be processed, and using the image after the image enhancement processing as an enhanced image; the image quality of the enhanced image is higher than the image quality of the image to be processed; performing graphic code extraction processing on the enhanced image to obtain an extraction result; performing graphic code recognition on the extraction result, and when it is recognized that the extraction result contains graphic code information, the extracted graphic code information is stored.
[0078] In a specific implementation, when the barcode scanning device performs image enhancement processing on the image to be processed and performs graphic code recognition on the image after image enhancement processing, the barcode scanning device can perform image enhancement processing on the image to be processed and use the image after image enhancement processing as the enhanced image, and the image quality of the enhanced image is higher than that of the image to be processed. Then, the barcode scanning device can perform graphic code extraction processing on the enhanced image to obtain an extraction result; perform graphic code recognition on the extraction result, and store the extracted graphic code information when it is recognized that the extraction result contains graphic code information. When it is recognized that the extraction result does not contain graphic code information, the recognition is terminated and the graphic code recognition fails.
[0079] Among them, the image enhancement processing method may include but is not limited to a histogram equalization method, an image sharpening method, a noise removal method and the like. Specifically, the barcode scanning device may use a histogram equalization method to achieve image enhancement, by adjusting the brightness distribution of the image pixels of the image to be processed, enhancing the contrast and details of the image to be processed, and obtaining an enhanced image. The barcode scanning device may use an image sharpening method to achieve image enhancement, by enhancing the edges and details of the image to be processed, to obtain an enhanced image, so that the enhanced image is clearer. The barcode scanning device may also use a noise removal method to achieve image enhancement, by using a filter and other methods to remove noise in the image to be processed, so that the image quality of the enhanced image is improved.
[0080] In the process of extracting the graphic code from the enhanced image and obtaining the extraction result, the code scanning device may use edge detection, shape detection and other methods to extract the graphic code. Specifically, the code scanning device may use edge detection algorithms (such as Sobel, Canny, etc.) to identify edge information in the enhanced image, thereby extracting the outline of the graphic code. Alternatively, the code scanning device may use a shape detection method to identify a graphic code of a specific shape through a shape matching algorithm or a contour extraction algorithm.
[0081] It should be noted that these methods can be used in combination, and appropriate methods can be selected for processing according to specific image and graphic code features to achieve the purpose of image enhancement and graphic code extraction.
[0082] Among them, when the code scanning device performs graphic code recognition on the extraction result and determines whether the extraction result contains graphic code information, the code scanning device can use template matching, feature extraction and matching, deep learning and other methods to determine whether the extraction result contains graphic code information. Specifically, in the process of using the template matching method, the code scanning device can use a pre-defined template to match the extraction result. If the matching degree is higher than the set threshold, it is considered that the extraction result contains graphic code information. In the process of using the feature extraction and matching method, the code scanning device can obtain the features of the extraction result (such as color, shape, texture, etc.) and match them with known graphic code features to identify whether there is graphic code information. In the process of using the deep learning method, the code scanning device can use a convolutional neural network (CNN) or other deep learning models to perform feature learning and classification on the extraction result to identify graphic code information.
[0083] The above method can select a suitable method to perform graphic code recognition according to actual conditions. When the graphic code information is recognized, the extracted graphic code information can be stored for subsequent application.
[0084] The technical solution of this embodiment performs image enhancement processing on the image to be processed, and uses the image after image enhancement processing as the enhanced image; the image quality of the enhanced image is higher than the image quality of the image to be processed; the enhanced image is subjected to graphic code extraction processing to obtain an extraction result; the extraction result is subjected to graphic code recognition, and when it is recognized that the extraction result contains graphic code information, the extracted graphic code information is stored. In this way, by performing image enhancement processing on the image to be processed, the enhanced image with higher image quality is subjected to graphic code extraction processing, thereby identifying whether the graphic code information is extracted, achieving more accurate graphic code extraction and recognition, and improving the recognition rate of the graphic code.
[0085] In one embodiment, the method also includes: when it is identified that the extraction result does not contain graphic code information, sending the image to be processed to the background; the background is used to input the image to be processed into a pre-trained graphic code recognition model, and perform graphic code recognition on the image to be processed through the pre-trained graphic code recognition model to obtain a graphic code recognition result.
[0086] In specific implementation, in some embodiments, when the code scanning device recognizes that the extraction result does not contain the graphic code information, the code scanning device can further send the image to be processed to the background to instruct the background to input the image to be processed into the pre-trained graphic code recognition model, and perform graphic code recognition on the image to be processed through the pre-trained graphic code recognition model to obtain the graphic code recognition result. Specifically, if there is graphic code information in the image to be processed, the pre-trained graphic code recognition model can segment the graphic code from the image to be processed; if there is no graphic code information, the pre-trained graphic code recognition model can output the result of "recognition failure".
[0087] The technical solution of this embodiment is to send the image to be processed to the background when it is recognized that the extraction result does not contain the graphic code information; the background is used to input the image to be processed into the pre-trained graphic code recognition model, and perform graphic code recognition on the image to be processed through the pre-trained graphic code recognition model to obtain the graphic code recognition result. In this way, when the code scanning device fails to recognize the graphic code based on the enhanced image, the image to be processed is further sent to the background, and the background uses an artificial intelligence model to perform graphic code recognition. Since the background usually has more powerful computing resources, it can support more complex artificial intelligence models, thereby improving the accuracy and efficiency of graphic code recognition; and sending the image to be processed to the background for processing can improve data security, avoid sensitive information leakage, and improve data privacy and security.
[0088] In one embodiment, the method further includes: when the current screen brightness reaches a preset brightness threshold, returning to the step of acquiring an image to be processed obtained by photographing the interface currently displayed on the terminal device.
[0089] The preset brightness threshold may be the maximum brightness value of the screen of the terminal device.
[0090] In a specific implementation, when the barcode scanning device identifies the current screen brightness of the terminal device, if the current screen brightness reaches a preset brightness threshold, there is no need to turn on the flash. The barcode scanning device returns to the step of obtaining the image to be processed by photographing the interface currently displayed by the terminal device, performs image enhancement processing on the image to be processed, and performs graphic code recognition on the image after image enhancement processing.
[0091] In some embodiments, the code scanning device can also identify the ambient brightness of the environment in which the terminal device is currently located. When the ambient brightness reaches a preset brightness threshold, there is no need to turn on the flash. The code scanning device returns to the step of obtaining the image to be processed by photographing the interface currently displayed by the terminal device, performs image enhancement processing on the image to be processed, and performs graphic code recognition on the image after image enhancement processing.
[0092] In some embodiments, the code scanning device may be provided with a light sensor to detect the ambient brightness.
[0093] In other embodiments, the barcode scanning device may also calculate the ambient brightness by using an image obtained by photographing the interface currently displayed by the terminal device. Specifically, the barcode scanning device may obtain an image to be brightness-recognized obtained by photographing the interface currently displayed by the terminal device, and after determining the image brightness of the image to be brightness-recognized, the image brightness of the image to be brightness-recognized is mapped to the corresponding ambient brightness according to a preset mapping relationship between the image brightness and the ambient brightness, thereby obtaining the ambient brightness of the environment in which the terminal device is currently located.
[0094] The technical solution of this embodiment, when the current screen brightness reaches a preset brightness threshold, returns to the step of obtaining the image to be processed obtained by photographing the interface currently displayed by the terminal device, performs image enhancement processing on the image to be processed, and performs graphic code recognition on the image after image enhancement processing. In this way, when the current screen brightness reaches the preset brightness threshold, it means that the failure to recognize the graphic code information at this time is not caused by the low screen brightness of the terminal device, then the interface currently displayed by the terminal device is directly photographed to obtain the image to be processed so as to perform image enhancement processing on the image to be processed and perform graphic code recognition, which realizes that when the screen brightness of the terminal device is sufficient, the image obtained by photographing is directly enhanced so as to better perform graphic code recognition, thereby helping to improve the accuracy and efficiency of graphic code recognition.
[0095] In practical applications, in order to facilitate understanding by those skilled in the art, Figure 2 An external structure diagram of a code scanning device 210 is provided. Figure 2 As shown, the code scanning device 210 is mainly composed of a storage unit 220, an image processing unit 230, a control unit 240, a collection unit 250, a broadcast unit 260, and a housing 270. The storage unit 220 is connected to the image processing unit 230 and the control unit 240, the image processing unit 230 is connected to the control unit 240, the control unit 240 is connected to the collection unit 250 and the broadcast unit 260, and the collection unit 250 is connected to the housing 270.
[0096] Figure 3 A diagram of the internal structure of a code scanning device 210 is provided. Figure 3 As shown, the storage unit 220 has a built-in storage chip 2201, which is used to store the scanning device parameters (such as dark light illumination threshold) and the collected data.
[0097] The image processing unit 230 is responsible for processing the collected image data and has the ability to calculate the average brightness of the image and extract graphic code information.
[0098] The control unit 240 is responsible for controlling the operation of each unit.
[0099] The acquisition unit 250 includes a camera 2501 , a flash 2502 , an illumination collector 2503 , and a code collector 2504 .
[0100] Camera 2501 is used to capture the interface currently displayed on the terminal device.
[0101] The flash 2502 is used to improve the ambient illumination.
[0102] The illumination collector 2503 is used to collect the ambient illumination of the terminal device.
[0103] The barcode collector 2504 is used to collect barcode information.
[0104] The announcement unit 260 has a built-in buzzer 2601, and when the recognition is successful, the buzzer 2601 emits a "beep" prompt sound.
[0105] In practical applications, the barcode scanning device may be a barcode scanning gun. Figure 4 , Figure 5 , Figure 6 Shown are the front view, side view, and back view of the barcode scanner.
[0106] The housing 270 is composed of a gun body 2701 , a code scanning button 2702 , a handle 2703 , and a mesh 2704 .
[0107] The gun body 2701 has a built-in storage unit 220 , an image processing unit 230 , a control unit 240 , and a collection unit 250 .
[0108] The handle 2703 is convenient for the user to hold the barcode scanner, and includes a barcode scanner button 2702 and a broadcast unit 260 .
[0109] The barcode scanning gun button 2702 is a barcode scanning switch with a built-in sensor. When the user presses this button, the control unit 240 starts working.
[0110] The mesh 2704 has an annular segmented opening for transmitting the buzzer sound.
[0111] In order to facilitate the understanding of those skilled in the art, Figure 7 A flow chart of another method for identifying a graphic code is provided. Figure 7 As shown, the specific steps are as follows:
[0112] Step S701: The control unit determines whether the scan code button is pressed. If so, proceed to step S702; otherwise, proceed to step S701.
[0113] Step S702: The control unit initializes the recognition counter to set the recognition times to 1, and proceeds to step S703.
[0114] Step S703: The control unit notifies the barcode scanner to start working, collects images of the interface currently displayed on the terminal device, and proceeds to step S704.
[0115] Step S704: The barcode scanner continuously determines within a certain period of time (e.g., 3 seconds) whether the collected information contains graphic code information. If yes, proceed to step S718, otherwise proceed to step S705.
[0116] Step S705: The control unit increases the recognition times by 1 in the recognition counter, and proceeds to step S706.
[0117] Step S706: The control unit determines whether the identification counter is 2, and if so, proceeds to step S707, otherwise, proceeds to step S713.
[0118] Step S707: the control unit notifies the camera to work, and the interface currently displayed by the terminal device is imaged to obtain an image to be brightness recognized, and then proceeds to step S708.
[0119] Step S708: the control unit stores the image to be brightness recognized collected by the camera in the storage unit, and proceeds to S709.
[0120] Step S709: The control unit notifies the image processing unit to work, reads the image to be recognized by brightness from the storage unit, and calculates the average brightness of the image to be recognized by brightness. Then, the process continues to step S710.
[0121] Step S710: If the average brightness deviates from the mean threshold value preset by the system (such as 150), it is considered that the brightness of the image to be recognized is insufficient, that is, the screen brightness of the terminal device is low, and proceed to step S711, otherwise proceed to step S712.
[0122] Step S711: The flash light is on for a certain period of time (eg, 2 seconds), and then proceed to step S703.
[0123] Step S712: Determine whether the graphic code information is extracted.
[0124] Step S713: Determine whether the identification counter is 3, if so, proceed to step S714, otherwise proceed to step S720.
[0125] Step S714: The control unit notifies the camera to work, collects the image of the interface currently displayed by the terminal device, obtains the image to be processed, and proceeds to step S715.
[0126] Step S715: The control unit stores the image to be processed acquired by the camera in the storage unit, and proceeds to S716.
[0127] Step S716: The control unit notifies the image processing unit to start working, reads the image to be processed from the storage unit, extracts the graphic code, and proceeds to step S717.
[0128] Step S717: The control unit determines whether the extracted information contains graphic code information, if so, proceeds to step S718, otherwise, proceeds to step S720.
[0129] Step S718: The control unit stores the graphic code information collected by the camera in the storage unit, and proceeds to step S719.
[0130] Step S719: The control unit notifies the buzzer to emit a "beep" prompt sound.
[0131] Step S720: End this recognition.
[0132] Thus, compared with the existing barcode scanners, the barcode scanner of the present application has the advantages of multiple recognition functions and fill light functions, which can effectively improve the recognition rate of graphic codes.
[0133] In another embodiment, Figure 8 As shown, a method for recognizing a graphic code is provided, and the method is applied to a code scanning device as an example for explanation, and includes the following steps:
[0134] Step S802, when the code scanning function is turned on, the graphic code of the interface currently displayed by the terminal device is recognized, and when the graphic code information is not recognized, the current screen brightness of the terminal device is obtained.
[0135] Step S804, when the current screen brightness is lower than a preset brightness threshold, the flash is continuously turned on for a preset time period, and the current screen brightness of the terminal device is obtained.
[0136] Step S806: Identify whether the screen of the terminal device automatically increases the brightness according to the current screen brightness.
[0137] Step S808: When the screen brightness of the terminal device is automatically increased, a graphic code is recognized for the interface currently displayed by the terminal device.
[0138] Step S810, when no graphic code information is recognized, obtaining an image to be processed by photographing the interface currently displayed on the terminal device.
[0139] Step S812: performing image enhancement processing on the image to be processed, and using the image after the image enhancement processing as the enhanced image.
[0140] Step S814, performing graphic code extraction processing on the enhanced image to obtain an extraction result.
[0141] Step S816, performing graphic code recognition on the extraction result, and storing the extracted graphic code information when it is recognized that the extraction result contains graphic code information.
[0142] It should be noted that the specific limitations of the above steps can refer to the specific limitations of a method for recognizing a graphic code mentioned above.
[0143] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0144] Based on the same inventive concept, the embodiment of the present application also provides a graphic code recognition device for implementing the graphic code recognition method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in the embodiments of one or more graphic code recognition devices provided below can refer to the limitations of the graphic code recognition method above, and will not be repeated here.
[0145] In an exemplary embodiment, Fig. 9 As shown, a device for identifying a graphic code is provided, comprising: a first identification module 910, a second identification module 920, a shooting module 930 and a third identification module 940, wherein:
[0146] The first recognition module 910 is used to perform graphic code recognition on the interface currently displayed by the terminal device when the code scanning function is turned on, and to obtain the current screen brightness of the terminal device when no graphic code information is recognized.
[0147] The second recognition module 920 is used to turn on the flash to evoke the automatic screen brightness adjustment function of the terminal device when the current screen brightness is lower than a preset brightness threshold, and perform graphic code recognition on the interface currently displayed by the terminal device.
[0148] The shooting module 930 is used to obtain the image to be processed by shooting the interface currently displayed by the terminal device when the graphic code information is not recognized; the pixels of the image to be processed meet the preset conditions.
[0149] The third recognition module 940 is used to perform image enhancement processing on the image to be processed, and perform graphic code recognition on the image after the image enhancement processing.
[0150] In one of the embodiments, the second identification module 920 is specifically used to continuously turn on the flash within a preset time period and obtain the current screen brightness of the terminal device; based on the current screen brightness, identify whether the screen of the terminal device automatically increases the brightness; when the screen of the terminal device automatically increases the brightness, perform graphic code recognition on the interface currently displayed by the terminal device.
[0151] In one embodiment, the second recognition module 920 or the first recognition module 910 is specifically used to obtain an image to be recognized by brightness by photographing the interface currently displayed by the terminal device; the pixels of the image to be recognized by brightness are lower than the pixels of the image to be processed; recognize the image brightness of the image to be recognized by brightness, and obtain the current screen brightness according to the image brightness.
[0152] In one embodiment, the third recognition module 940 is specifically used to perform image enhancement processing on the image to be processed, and use the image after image enhancement processing as the enhanced image; the image quality of the enhanced image is higher than the image quality of the image to be processed; perform graphic code extraction processing on the enhanced image to obtain an extraction result; perform graphic code recognition on the extraction result, and when it is recognized that the extraction result contains the graphic code information, the extracted graphic code information is stored.
[0153] In one embodiment, the device also includes: an image sending module, which is used to send the image to be processed to the background when it is recognized that the extraction result does not contain the graphic code information; the background is used to input the image to be processed into a pre-trained graphic code recognition model, and perform graphic code recognition on the image to be processed through the pre-trained graphic code recognition model to obtain a graphic code recognition result.
[0154] In one of the embodiments, the second recognition module 920 is further used to return to the step of obtaining the image to be processed obtained by photographing the interface currently displayed on the terminal device when the current screen brightness reaches the preset brightness threshold.
[0155] In one of the embodiments, the second recognition module 920 is further used to return to the step of obtaining the image to be processed obtained by photographing the interface currently displayed by the terminal device when the screen of the terminal device does not automatically increase the brightness.
[0156] Each module in the above-mentioned graphic code recognition device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each module.
[0157] In an exemplary embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be shown in FIG10. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit, and an input device. The processor, the memory, and the input / output interface are connected via a system bus, and the communication interface, the display unit, and the input device are connected to the system bus via the input / output interface. The processor of the computer device is used 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 and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner may be implemented through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a method for recognizing a graphic code is implemented. The display unit of the computer device is used to form a visually visible picture, which may be a display screen, a projection device, or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device shell, or an external keyboard, touchpad or mouse.
[0158] Those skilled in the art will understand that the structure shown in FIG. 10 is merely a block diagram of a partial structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.
[0159] In one embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above method embodiments when executing the computer program.
[0160] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.
[0161] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.
[0162] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.
[0163] Among them, this application provides users with corresponding operation entrances for them to choose to agree or reject the automated decision-making results; if the user chooses to reject, the expert decision-making process will be entered.
[0164] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0165] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0166] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A method for recognizing a graphic code, characterized in that: The method comprises: When the code scanning function is turned on, the graphic code of the interface currently displayed by the terminal device is recognized, and when the graphic code information is not recognized, the current screen brightness of the terminal device is obtained; When the current screen brightness is lower than a preset brightness threshold, turning on the flash to arouse the automatic screen brightness adjustment function of the terminal device, and performing graphic code recognition on the interface currently displayed by the terminal device; In the case where the graphic code information is not recognized, an image to be processed is obtained by photographing the interface currently displayed by the terminal device; pixels of the image to be processed meet a preset condition; The image to be processed is subjected to image enhancement processing, and graphic code recognition is performed on the image after the image enhancement processing.
2. The method according to claim 1, characterized in that The step of turning on the flashlight to arouse the automatic screen brightness adjustment function of the terminal device and performing graphic code recognition on the interface currently displayed by the terminal device includes: Continuously turning on the flashlight within a preset time and obtaining the current screen brightness of the terminal device; According to the current screen brightness, identifying whether the screen of the terminal device automatically increases the brightness; When the screen brightness of the terminal device is automatically increased, a graphic code is identified for the interface currently displayed by the terminal device.
3. The method according to claim 1 or 2, characterized in that: The obtaining the current screen brightness of the terminal device includes: Acquire an image to be brightness recognized obtained by photographing the interface currently displayed by the terminal device; the pixels of the image to be brightness recognized are lower than the pixels of the image to be processed; The image brightness of the image to be brightness-recognized is identified, and the current screen brightness is obtained according to the image brightness.
4. The method according to claim 1, characterized in that The performing image enhancement processing on the image to be processed and performing graphic code recognition on the image after the image enhancement processing includes: Performing image enhancement processing on the image to be processed, and using the image after the image enhancement processing as the enhanced image; Performing graphic code extraction processing on the enhanced image to obtain an extraction result; The extraction result is subjected to graphic code recognition, and when it is recognized that the extraction result contains the graphic code information, the extracted graphic code information is stored.
5. The method according to claim 4, characterized in that The method further comprises: When it is identified that the extraction result does not contain the graphic code information, the image to be processed is sent to the background; the background is used to input the image to be processed into a pre-trained graphic code recognition model, and perform graphic code recognition on the image to be processed through the pre-trained graphic code recognition model to obtain a graphic code recognition result.
6. The method according to claim 1, characterized in that The method further comprises: When the current screen brightness reaches the preset brightness threshold, return to the step of obtaining the image to be processed obtained by photographing the interface currently displayed on the terminal device.
7. The method according to claim 2, characterized in that The method further comprises: In the case where the screen of the terminal device does not automatically increase the brightness, the process returns to the step of acquiring the image to be processed obtained by photographing the interface currently displayed on the terminal device.
8. A device for recognizing a graphic code, characterized in that: The device comprises: The first recognition module is used to perform graphic code recognition on the interface currently displayed by the terminal device when the code scanning function is turned on, and obtain the current screen brightness of the terminal device when no graphic code information is recognized; A second recognition module is used to turn on the flashlight to evoke the automatic screen brightness adjustment function of the terminal device when the current screen brightness is lower than a preset brightness threshold, and perform graphic code recognition on the interface currently displayed by the terminal device; A shooting module, used for acquiring an image to be processed obtained by shooting the interface currently displayed by the terminal device when the graphic code information is not recognized; the pixels of the image to be processed meet a preset condition; The third recognition module is used to perform image enhancement processing on the image to be processed, and perform graphic code recognition on the image after the image enhancement processing.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
11. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
