Code scanning processing method and electronic equipment

By controlling the coordinated operation of the positioning light and the fill light in a timely manner, and combining scene-specific parameters and exposure strategies for regions of interest, the problems of decoding failure and bit errors during the scanning process are solved, achieving efficient and accurate scanning processing, adapting to diverse scenarios and reducing hardware costs.

CN121745129APending Publication Date: 2026-03-27FUJIAN LANDI COMMERCIAL EQUIPMENT CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-15
Publication Date
2026-03-27

AI Technical Summary

Technical Problem

In existing technologies, decoding failures and errors often occur during the scanning process, especially under the interference of positioning light, which affects the decoding success rate and user experience. In addition, traditional solutions increase hardware costs and structural complexity.

Method used

By controlling the coordinated operation of the positioning light and the fill light in a timing manner, the positioning light is turned off before acquisition and the fill light is turned on after acquisition. Combined with scene-based parameter configuration and region of interest exposure strategy, a single buffer and high frame rate acquisition mechanism are adopted to optimize the barcode scanning system.

Benefits of technology

It improves decoding success rate, solves alignment difficulties, optimizes user experience, adapts to diverse scanning scenarios, reduces hardware costs, and improves scanning accuracy and speed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121745129A_ABST
    Figure CN121745129A_ABST
Patent Text Reader

Abstract

The invention discloses a code scanning processing method and electronic equipment. The method is applied to the electronic equipment, the electronic equipment comprises a camera, a light supplementing lamp and a positioning lamp, and the method comprises the following steps: starting the camera; before a code image used for decoding is collected, the positioning lamp is turned off, and the light supplementing lamp is turned on; after the code image is acquired, turning on a positioning lamp; and decoding the code image to obtain a decoding result. During code scanning, the camera is turned on, and the default state of the positioning lamp is turned on, so that a code pattern needing to be identified can be directly indicated and aligned through the positioning lamp, and a user can more conveniently position a code scanning area; turning off the positioning lamp during image acquisition to prevent red light from interfering with image quality, and turning on the light supplement lamp to ensure proper image brightness; and turning on a positioning lamp in a non-acquisition period to provide alignment guidance for the user. According to the method, the problem of image local overexposure caused by irradiation of the positioning lamp is effectively solved, and the image quality, the decoding success rate and the decoding speed are improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of code scanning, in particular to a code scanning processing method applied to an electronic device and the electronic device. BACKGROUND

[0002] With the development of technology, many scenes will use the code scanning function, and users can obtain relevant information through code scanning. However, in the related art, after code scanning, decoding failure and code error often occur, which affects normal use. SUMMARY

[0003] The present application solves the technical problem of providing a code scanning processing method and an electronic device, which realizes a code scanning method with multiple parameters, accurate alignment and automatic light compensation.

[0004] To solve the above technical problems, the present application adopts a technical solution as follows: A code scanning processing method applied to an electronic device, the method comprising: turning on the camera; turning off the positioning lamp and turning on the light compensation lamp before collecting a code image for decoding; turning on the positioning lamp after completing the collection of the code image; decoding the code image to obtain a decoding result.

[0005] To solve the above technical problems, the present application adopts another technical solution as follows: An electronic device comprising a memory, a processor and a computer program stored in the memory and running on the processor, wherein the processor implements each step of the above code scanning processing method when executing the computer program.

[0006] The present application has the following advantages: when scanning a code, the camera is turned on, and the positioning lamp is in the default state of being turned on. The user can directly align the pattern to be recognized through the positioning lamp, which is more convenient for the user to position the code scanning area. The positioning lamp is turned off before collecting a code image for decoding, which can avoid the influence of the red light of the positioning lamp on the code image during the collection of the code image, and can avoid decoding failure and code error, thereby improving the decoding success rate. After completing the collection of the code image, the positioning lamp is turned on, and the code image is decoded. The present application cooperates the positioning lamp and the light compensation lamp to provide sufficient brightness for the light compensation lamp during the collection of the code image, thereby improving the definition of the code image in a dark environment. The positioning lamp is turned on in the non-collection stage to provide intuitive alignment guidance for the operator, thereby solving the alignment difficulty problem. While ensuring fast decoding, the use experience of the operator is optimized, the code scanning demand is adapted, and the accuracy of code scanning is improved. BRIEF DESCRIPTION OF DRAWINGS

[0007] Figure 1 A flow chart of the steps of a code scanning processing method provided by an embodiment of the present application; Figure 2 A region of interest diagram of the present application; Figure 3 A positioning lamp region diagram of the present application; Figure 4 A preview overall flow diagram of the present application; Figure 5 A terminal structure diagram of the present application, wherein Fig. a is a front preview diagram, and Fig. b is a back camera diagram; Figure 6 A code image filtering red positioning lamp effect diagram of the present application, wherein Fig. a is a filtering red lamp effect, and Fig. b is a non-filtering red lamp effect; Figure 7 A structure diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION

[0008] In order to make the technical problems to be solved by the present application, the technical solutions and beneficial effects clearer and more apparent, the present application will be further described in detail below in combination with the 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.

[0009] In the following description, specific details are set forth in order to provide a thorough understanding of embodiments of the present application. However, persons of ordinary skill in the art will readily recognize that embodiments of the present application can be practiced without these specific details. In other instances, well-known structures, devices, circuits, and methods have not been described in detail in order to avoid obscuring the present application.

[0010] It should be understood that when used in the specification and the appended claims of the present application, the term "comprising" indicates the presence of the described features, integers, steps, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof.

[0011] Reference within the specification of this application to "one embodiment" or "some embodiments" means that a particular feature, structure, or characteristic described in connection with the embodiment is included in at least one embodiment of the application. The appearances of the phrase "in one embodiment" or "in some embodiments" in various places within specified descriptions in this specification are not necessarily all referring to the same embodiment, however, but can refer to one or more but not all embodiments. The terms "including," "comprising," "carrying," "having," "containing," and variations thereof are meant to encompass the item listed thereafter but do not exclude additional, unrecited items. These terms are also meant to encompass items that are recited in addition to the item listed thereafter.

[0012] In the related art, with the continuous expansion of the field of simple code scanning payment scenarios, various simple terminals have been widely applied. As a core function, the processing speed and code scanning success rate of code scanning recognition directly affect transaction efficiency and user experience. In order to assist users in quickly aligning barcodes on terminal devices, it is necessary to update the terminal devices to enable a system process that can accurately scan and decode in different environments.

[0013] However, in the related art, there are methods of assisting code scanning by equipping positioning lights and fill-in lights on simple terminal devices, but the light of the positioning light will interfere with the code image quality and affect the decoding success rate during code image acquisition. Some solutions filter the red light of the positioning light by adding a physical filter, but this way increases hardware costs and structural complexity. For example, for a small screen size, after displaying the necessary prompt information (such as the title bar, status bar, prompt bar, etc.), there is no more space to display the code image to be recognized. If the positioning light is not effectively controlled, its red light may cause the collected code image to be locally too bright or overexposed, especially when the code image is located in the red light irradiation area, which can easily cause decoding failure or code error, thereby affecting payment efficiency and user experience. To solve the impact of the red positioning light on code scanning, some manufacturers add a red filter in front of the camera to filter out the red light, so that the collected image will not have abnormal bright spots.

[0014] In addition, in the related art, the code scanning scheme usually adjusts the exposure parameter based on the average brightness of the entire code image, without focusing on the region of interest actually containing the code image, resulting in inaccurate exposure control and poor adaptability in different code scanning scenarios. Meanwhile, most devices only support a fixed set of code scanning parameters, which cannot be adaptively adjusted to adapt to diversified scenarios such as payment codes (self-luminous) and paper codes (without reflection), further limiting the optimization of code scanning performance. If the exposure of the code image in the next frame is adjusted based on the entire image, it is possible that the barcode region area s1 is already very bright, but s1 only occupies a small range of the entire s, so the influence on the brightness of the entire code image is limited, the average brightness of the code image is very low, and according to the exposure algorithm, the exposure time will be lengthened at this time, which finally causes the barcode region to be overexposed and decoding fails.

[0015] In addition, most simple POS terminals only adapt to a set of code scanning parameters, and life codes mainly include two types: 1) scenes with backlight, such as mobile payment codes, refund codes, etc.; 2) scenes without light sources, such as goods, static payment codes, etc.; different scenes have different requirements for the exposure time of the camera and the brightness of the fill light, and if only one set of parameters is provided, the code scanning performance cannot be fully utilized, which not only may cause slow code scanning speed, but also may cause a series of serious problems such as code errors.

[0016] To solve the above problems, the present application provides a code scanning processing method and an electronic device. The method solves the interference of the light source by timing control of the positioning light and the fill light, improves the code image quality in different environments by using the intelligent exposure strategy of scene-based parameter configuration and region-of-interest focusing, and ensures the processing efficiency under limited resources by combining the single buffer and the high frame rate acquisition mechanism, thereby constructing a code scanning processing system that is efficient, accurate in decoding, and has environmental perception capability on a low-cost hardware platform. The following specifically introduces a code scanning processing method of the present application.

[0017] The code scanning processing method of the present application can be widely applied to various barcode recognition scenarios, especially in simple POS terminal devices with small screen size and limited hardware resources. The electronic device of the present application can be a mobile POS terminal, a portable code scanner, etc. equipped with a camera, a fill light, a positioning light, and a decoding module.

[0018] The following specifically introduces the code scanning processing method in the present application, with reference to the accompanying Figure 1 , including steps 110-140.

[0019] Step 110: Turn on the camera. Taking a POS terminal as an example, the mobile POS terminal initializes the camera, closes the automatic exposure control (AEC) function of the camera, configures the camera output format as Only Y, that is, the code image output by the camera only contains the Y value of the brightness information, and turns on to prepare for subsequent code image acquisition.

[0020] Step 120: Turn off the positioning light and turn on the fill light before collecting the code image for decoding. Before the camera of the mobile POS terminal starts collecting the code image for decoding, the system of the mobile POS terminal turns off the positioning light (such as a red positioning light), and at the same time, turns on the fill light to provide uniform and sufficient illumination for code image collection.

[0021] Step 130: Turn on the positioning light after the collection of the code image is completed. After the mobile POS terminal completes the collection of the code image to be decoded, the system of the mobile POS terminal re-turns on the positioning light.

[0022] Step 140: Decode the code image to obtain a decoding result. The mobile POS terminal decodes the collected code image to obtain a decoding result.

[0023] In this way, the camera is turned on and the positioning light is turned on by default when scanning the code, which enables the operator to directly align the code image to be recognized through the positioning light indication. By precisely controlling the working timing of the positioning light and the fill light, the positioning light is turned off in the key stage of code image collection to eliminate the interference of red light, and the positioning light is turned on in the non-collection stage to provide continuous alignment guidance, thereby achieving the best balance between code image quality guarantee and user experience optimization. This timing control strategy of the positioning light and the fill light fundamentally solves the problem of local over-brightness or over-exposure of the code image caused by the irradiation of the positioning light, and significantly improves the decoding success rate. At the same time, the cooperative work of the positioning light and the fill light ensures the adaptability in different environmental conditions: the fill light intelligently fills light during collection, effectively enhancing the image clarity of paper codes and other targets without reflective characteristics; the positioning light provides clear visual alignment reference during the collection interval, effectively solving the alignment difficulty caused by the insufficient preview area of small-screen devices. Through this method, the convenience of code scanning operation is significantly improved, and precise adaptation to diversified code scanning scenarios is achieved.

[0024] In an embodiment of the present application, steps 110 include steps 150 to 151.

[0025] Step 150: Receive code scanning mode selection information and match the default configuration according to the code scanning mode selection information. For example, before the camera of the mobile POS terminal starts, the system of the mobile POS terminal receives the code scanning mode information selected by the user according to the current use scenario, including but not limited to different scene modes such as "biasing electronic code" or "biasing paper code". According to the selected code scanning mode, the system matches the corresponding default configuration from the parameter library preset in the register, provides targeted parameter basis for code scanning operation in different scenarios, and makes the subsequent exposure adjustment faster and more expected.

[0026] Step 151: initial exposure parameters and fill light parameters according to the default configuration. Based on the default configuration obtained in step 150, the initial parameters of the camera are preset, and the initial brightness value of the fill light is intelligently set according to the ambient light conditions and the selected code scanning mode. The preset of these parameters ensures that the system can quickly enter the best acquisition state in different code scanning scenes, avoiding the multiple adjustments and recognition delays caused by parameter mismatch in traditional solutions.

[0027] Step 110 includes step 152.

[0028] Step 152: turn on the fill light according to the fill light parameters, and collect the code image according to the initial exposure parameters. Based on the fill light parameters in step 151, the on-off state and brightness output of the fill light are controlled to ensure the most suitable lighting conditions for the current scene.

[0029] In this way, by introducing a scene-based parameter preset mechanism, the system can intelligently match the optimal acquisition parameter configuration for different code scanning scenes. This scene-identified adaptive parameter adjustment not only effectively solves the poor adaptability of traditional fixed parameter solutions in variable environments, but also significantly reduces the number of adjustments in the acquisition process through optimized initial parameter settings, achieving the technical effect of quickly obtaining high-quality code images in diverse scenes, thereby improving the decoding success rate while further optimizing the code scanning response speed and user experience.

[0030] In an embodiment of the present application, step 120 includes step 160.

[0031] Step 160: store the collected code image in a single buffer area, which is configured to store only the latest image frame each time. The system allocates a single buffer area of fixed size in memory for storing code image data collected by the camera. The single buffer area uses an overwrite writing mechanism, and each time a new code image is collected, the system directly writes the new image data into the single buffer area, overwriting the image content of the previous frame, thereby ensuring that the single buffer area always stores the latest collected code image frame. This single buffer area design effectively avoids the frame data confusion or processing delay problems that may occur in the multi-buffer area solution, while significantly reducing the system's occupation of memory resources.

[0032] Step 140 includes step 161.

[0033] Step 161: Single buffer adopts single frame decoding mode to decode code image. The MPU decoding board independently decodes the current code image stored in the single buffer without relying on the correlation information of the previous and next frames. The time consumption of single frame decoding is controlled within 20ms to 60ms, and the total time consumption from image acquisition to decoding completion is about 53ms in the best case. Even in the worst case, such as poor image quality but still decodable, and waiting for the next valid image, the total time consumption can be controlled within 120ms. Compared with the traditional Android smart POS platform with processing time of more than 300ms, the single frame decoding mechanism of the present solution significantly improves the processing efficiency while ensuring decoding accuracy.

[0034] In this way, by adopting the single buffer storage mechanism, the system realizes efficient use of memory resources while ensuring real-time code image processing. This design not only avoids the memory overhead and frame management complexity brought by the multi-buffer architecture, but also improves decoding accuracy and response speed by ensuring that the latest image data is always processed. The single buffer overwrite mechanism cooperates with high frame rate acquisition to form an efficient and real-time image processing pipeline, providing a stable and reliable technical foundation for code scanning recognition. By adopting the single frame independent decoding strategy, the complexity and delay caused by multi-frame correlation are avoided, so that the user obtains immediate and independent response every time he scans the code. It discards the cumbersome multi-frame analysis, and through the close cooperation with high frame rate acquisition and single buffer technology, it ensures that the system can always process the latest code image, thereby realizing fast decoding response and accurate recognition result. With a more concise architecture and lower resource occupation, it provides users with a smoother code scanning experience.

[0035] In an embodiment of the present application, step 151 includes step 1511 and step 1512.

[0036] Step 1511: Acquire ambient light and screen light of the scanned code device. Ambient light around the camera and the brightness of the entire code image are analyzed.

[0037] Step 1512: Set initial exposure parameters and light compensation lamp parameters according to ambient light, screen light and default configuration. Dynamically adjust according to the brightness characteristics of ambient light and screen light, for example: appropriately reduce exposure time to prevent overexposure in strong ambient light, and appropriately increase gain to ensure code image details in screen light dominated scenes. Synchronously control the brightness level of the light compensation lamp, for example: in paper code mode, if the ambient light is weak, start the light compensation lamp and increase the light compensation intensity, and in electronic code mode, reduce the light compensation intensity to avoid screen reflection.

[0038] In this way, through the ambient light, screen light perception and parameter adaptive mechanism, while ensuring the code image quality, the exposure parameter and the light compensation strategy are precisely controlled. This design not only solves the problem that a single parameter cannot adapt to multiple scenes, but also avoids the tediousness of manual adjustment through intelligent light sensing analysis. The organic combination of ambient light sensing and preset parameters improves decoding accuracy while significantly optimizing the scanning code experience of users in different lighting environments.

[0039] In an embodiment of the present application, step 130 comprises step 170 and step 171.

[0040] Step 170: Determine the region of interest from the code image. Considering that the operation habit usually aligns the positioning lamp region with the code image region, the position near the red region is most likely to be the place where the code image exists.

[0041] Please refer to Figure 2 , the region of interest is set as a rectangular region near the center of the image, and the size is preferably 320x240 pixels. This region corresponds to the positioning lamp irradiation region and is most likely to be the location of the code image. By limiting the analysis range to this specific region, the system can focus on the image part that is most likely to contain the barcode.

[0042] Step 171: Calculate the average brightness of the pixels in the region of interest in the code image using the interval sampling method. For example, for the above-mentioned 320x240 pixel region of interest, sample every 8 pixels horizontally and every 8 pixels vertically, a total of 1200 (40x30) sample points are collected, and the average gray value of these sample points is calculated as the brightness representative value of the entire region of interest. This interval sampling method reduces the processing time compared to full pixel point calculation, while still accurately reflecting the overall brightness characteristics of the region.

[0043] In this way, by limiting the region of interest and using the interval sampling strategy, the system improves the processing efficiency while ensuring the accuracy of brightness evaluation. The accurate positioning of the region of interest ensures that system resources are concentrated in the position where the barcode is most likely to appear, and the interval sampling method effectively balances the needs of calculation accuracy and processing speed. This brightness evaluation mechanism works together with exposure adjustment, light compensation control and other functions to build a fast-response intelligent exposure control system, providing reliable technical support for improving the success rate of scanning codes.

[0044] In an embodiment of the present application, step 171 comprises step 1711 and step 1712.

[0045] Step 1711: Adjust the exposure time and gain of the camera in the configured electronic device based on the average pixel brightness. Precise adjustment is performed based on the average pixel brightness of the region of interest calculated in Step 171. The system compares the real-time collected average brightness of the region of interest with a preset target brightness threshold. When the brightness is lower than the ideal range, the exposure time and gain are appropriately increased according to a preset step size; when the brightness is higher than the ideal range, the exposure time and gain are correspondingly decreased. To avoid brightness fluctuations during parameter adjustment, the adjustment range is controlled within a reasonable range each time.

[0046] Step 1712: Adjust the expected brightness of the fill light based on the average pixel brightness. The brightness of the fill light is dynamically adjusted based on the average pixel brightness of the region of interest calculated in Step 171: In paper code mode, if the ambient light is severely insufficient and the exposure parameters are close to their upper limit, the fill light is activated and the brightness is gradually increased to a suitable level; in electronic code mode, a strategy of reducing the fill light intensity is prioritized to avoid image overexposure caused by screen reflections.

[0047] In this way, by adjusting the brightness based on the calculated average pixel brightness of the region of interest, the code image is ensured to maintain an appropriate brightness level, effectively avoiding decoding failures caused by overexposure or underexposure. This adjustment mechanism, based on the calculated average brightness of the region of interest in the code image, provides stable code image quality in varying scanning environments, laying the foundation for fast and accurate code image recognition.

[0048] In one embodiment of this application, step 171 includes step 1713.

[0049] Step 1713: When the scanning mode is the first mode, which is biased towards electronic codes, reduce the exposure time and gain, and decrease the expected brightness; when the scanning mode is the second mode, which is biased towards paper codes, increase the exposure time and gain, activate the fill light, and enhance the expected brightness. For example: when the system recognizes that it is currently in the first mode, please refer to the position of the positioning light in the image. Figure 3 As shown, the exposure control logic pre-determines the basic characteristics of the electronic screen as a self-emissive source, employing a control strategy different from paper codes. The system automatically sets the base exposure time to a shorter level, correspondingly lowers the code image gain parameter, and significantly reduces or completely turns off the supplementary light brightness. This configuration is based on the following technical considerations: the electronic screen has its own backlight, and its brightness is sufficient for code image acquisition. If the exposure parameters of paper codes were used, it would easily lead to overexposure of the code image, causing the barcode area to lose detail due to high brightness, forming bright spots, and ultimately leading to decoding failure. By pre-setting a shorter exposure time and a lower gain, the system can effectively suppress the overexposure phenomenon caused by the screen's self-emissive nature, ensuring that the contrast and edge sharpness of the barcode pattern are preserved.

[0050] When the system identifies that it is currently in the second mode, the exposure control logic adopts a regulation strategy different from that of the electronic code based on the requirement of the non-reflective feature of the paper code, and the system automatically sets the basic exposure time to a longer position, the code image gain parameter is correspondingly improved, and the fill light is started and gradually enhanced to an appropriate level. This configuration is based on the following technical considerations: the paper code itself does not emit light and has limited reflectivity, and in the case of insufficient ambient light, a longer exposure time and stronger fill light illumination are required. If the exposure parameters of the electronic code are used, it is easy to cause the code image to be insufficient in brightness, so that the barcode area cannot be recognized due to loss of dark details, and ultimately decoding fails. By appropriately increasing the exposure time and gain parameter, and cooperating with the enhanced illumination of the fill light, the system can effectively improve the brightness and contrast of the paper code image, and ensure the integrity and recognizability of the barcode pattern.

[0051] In this way, by customizing the exposure and fill light strategies for electronic code and paper code scenes, the system realizes accurate adaptation to the optical characteristics of different code media. This scene-based configuration not only avoids overexposure of electronic screens and improves the first recognition rate for self-luminous barcodes such as mobile payment codes, but also effectively solves the problem of insufficient brightness of paper codes in dark environments. Through the intelligent scene recognition and parameter adaptive mechanism, the system not only ensures decoding accuracy, but also effectively reduces the overall power consumption of the system by optimizing the fill light usage strategy. The intelligent recognition mechanism and the existing scene mode selection function of the system complement each other, and together provide users with more accurate and efficient scanning experience.

[0052] In one embodiment of the present application, step 1711 includes step 1714.

[0053] Step 1714: Compare the average pixel brightness of the region of interest with the ambient brightness threshold; if the average pixel brightness is higher than the first ambient brightness threshold, reduce the exposure time and gain, and turn off the fill light; if the average pixel brightness is lower than the second ambient brightness threshold, increase the exposure time and gain, and simultaneously increase the expected brightness of the fill light. This brightness adaptive adjustment mechanism complements the scene-based parameter configuration of step 1713, and together constitutes the intelligent exposure control system of the system. Specifically, when the system is in the first mode biased towards electronic codes, based on the lower exposure parameters set in step 1713, if the average brightness of the region of interest is detected to be higher than the first ambient brightness threshold, the system will further reduce the exposure time and gain to cope with the risk of overexposure in strong light environment; when the system is in the second mode biased towards paper codes, based on the higher exposure parameters set in step 1713, if the average brightness of the region of interest is detected to be lower than the second ambient brightness threshold, the system will further increase the exposure time and gain, and enhance the brightness of the fill light to improve the image quality in dark light environment.

[0054] Dynamic changes of ambient light can have a significant impact on the quality of code images. In strong light environments, even if lower exposure parameters suitable for electronic codes are used, local overexposure can still occur, in which case the exposure parameters need to be further reduced to ensure image quality. In dark light environments, even if the light compensation strategy suitable for paper codes is enabled, there can still be insufficient brightness, in which case the exposure and light compensation intensity need to be further enhanced. By combining scene-based preset parameters with environmental adaptive adjustment, the system can always maintain optimal image acquisition effects in different code scanning scenes and environmental conditions.

[0055] In this way, through the dual optimization of scene-based preset parameters and environmental adaptive adjustment, the system constructs a multi-level and intelligent exposure control system. This control strategy not only realizes precise adaptation to the optical characteristics of different code media, but also dynamically responds to changes in ambient light, ensuring code image quality and decoding success rate while further improving the adaptability and stability of the system in various complex environments. The intelligent exposure control mechanism cooperates with the existing scene mode selection function of the system to provide users with a more accurate, efficient, and environmentally adaptive code scanning experience.

[0056] In an embodiment of the present application, step 140 comprises step 142.

[0057] Step 142: If the decoding result is decoding failure, the expected brightness of the light compensation lamp is readjusted, and the step of turning off the positioning lamp is returned to. For example, when the decoding result of the current frame code image returned by the MPU decoding board is failure, the system does not immediately acquire the next frame, but first starts the light compensation lamp brightness adjustment process: based on the recently calculated average brightness of the region of interest, the expected brightness value of the light compensation lamp is increased by a preset amount, usually controlled within the range of 10% to 20%, to avoid brightness mutation leading to further deterioration of code image quality.

[0058] After adjusting the light compensation lamp parameters, the system immediately returns to the step of turning off the positioning lamp and reopens a new round of code image acquisition and decoding process. This design ensures that the red light interference of the positioning lamp can be effectively excluded during the retry process, and the improvement of the light compensation condition provides a more optimized lighting environment for code image recognition.

[0059] In this way, by establishing a parameter adaptive adjustment mechanism after decoding failure, the system realizes dynamic response to complex lighting environments. This intelligent retry strategy not only solves accidental decoding failures caused by transient light deficiency, but also provides stable performance guarantees for continuous code scanning through systematic parameter optimization. The precise cooperation between light compensation lamp brightness step adjustment and positioning lamp on-off control not only ensures the continuity of user experience, but also improves the overall recognition success rate of the system in harsh lighting conditions.

[0060] In summary, the application constructs a precise and fast decoding code processing system. The system cooperates the positioning lamp and the light supplement lamp through the timing control mechanism. The positioning lamp is turned off to eliminate the red light interference when collecting the image, and the light supplement lamp is turned on to provide suitable illumination. The positioning lamp is turned on to provide intuitive alignment guidance for the user in the non-collection stage. Thus, the image local overexposure problem caused by the positioning lamp irradiation is effectively solved without increasing the hardware filter, and the decoding success rate and image quality are improved.

[0061] Further, the system introduces a scene-based parameter configuration mechanism, supports the user to select different modes such as "bias electronic code" or "bias paper code" according to the actual use scene, and matches the preset camera exposure parameters and light supplement lamp brightness according to this, to realize the precise adaptation to the optical characteristics of different code media. Combined with the intelligent exposure strategy of the region of interest focusing, the system only analyzes the brightness and controls the exposure of the region of interest of the code image, avoids the exposure misadjustment caused by the average brightness calculation of the whole code image, and further improves the precision and adaptability of the exposure control.

[0062] In addition, the system adopts a single buffer storage mechanism and a high frame rate acquisition scheme to realize efficient flow and real-time processing of code image data under limited memory resources, ensures that each decoding is the latest collected code image frame, effectively reduces the decoding delay, and improves the system response speed.

[0063] Through the cooperation and optimization of the above-mentioned multiple technical links, the application constructs a code processing system with rapid response, accurate recognition, strong environmental adaptability and excellent user experience on a low-cost hardware platform, effectively solves the problems of alignment difficulty, slow decoding speed, low success rate and poor environmental adaptability of the existing mobile POS terminal in the code scanning process, and provides a feasible technical path for the efficient application of code image recognition technology on resource-limited devices.

[0064] Please refer to Figure 4 , the application embodiments of the application will be specifically introduced below, including the following steps.

[0065] 1. The system performs initialization operation, the user selects the camera parameters and the code scanning mode according to the current use scene, including the first mode of biasing electronic code and the second mode of biasing paper code; and matches the corresponding default configuration from the register preset parameter library according to the selected mode. It is equivalent to the above step 150.

[0066] 2. Start the camera and configure its working parameters: set the frame rate to 30fps, and configure the image format to Only Y mode; at the same time, start the display screen, open a single buffer space of 640x480 size in the memory, and clear the existing buffer content. It is equivalent to the above step 110.

[0067] 3. Before acquiring the code image for decoding, turn off the positioning light to avoid red light interference, and at the same time turn on the supplementary light according to the supplementary light parameters corresponding to the selected scanning mode to provide uniform and sufficient illumination for code image acquisition. This is equivalent to step 120 above.

[0068] 4. Based on the default configuration of the selected scanning mode, automatically adjust the camera's exposure time and gain parameters; synchronously adjust the expected brightness of the fill light to provide optimal lighting conditions for image acquisition in different scenarios, equivalent to steps 151 and 1512 above.

[0069] 5. Acquire the code image to be decoded; determine the region of interest from the code image, and calculate the average pixel brightness of the region using an interval sampling method, wherein the region of interest of 320×240 pixels is sampled every 8 pixels horizontally and every 8 pixels vertically. This is equivalent to steps 170 and 171 above.

[0070] 6. After completing the code image acquisition, turn on the positioning light to provide alignment guidance for the user; the MPU decoding board uses a single-frame decoding method to independently decode the current code image stored in a single buffer, without relying on the correlation information of previous and subsequent frames. This is equivalent to steps 130 and 141 above.

[0071] 7. Judge the decoding result. If decoding is successful, turn off the camera, fill light, and positioning light, clear the single buffer space, and complete this scanning process. If decoding fails, readjust the camera exposure time, gain, and expected brightness of the fill light based on the average brightness of the region of interest, and return to step 3 to re-acquire and process the code image. This is equivalent to step 142 above.

[0072] 8. Turn off the camera, fill light, and positioning light, and clear the buffer zone. This is equivalent to step 140 above.

[0073] 9. After completing this scanning process, the system can continue to acquire ambient brightness data through the camera and dynamically adjust system parameters; based on changes in ambient light and scanning success rate statistics, it can optimize the configuration parameters of each scene mode to achieve adaptive improvement in system performance. This is equivalent to step 1511 above.

[0074] The following describes specific application embodiments of this application. This application can apply the above solution to a simple POS terminal. A schematic diagram of the terminal appearance is shown below. Figure 5 As shown, there is a CMOS camera, an LED fill light, a positioning light, an MPU decoding board, and a display screen.

[0075] Wherein: the CMOS camera is responsible for collecting code images, in order to reduce the storage space of the image as much as possible, the camera image format is set to Only Y mode through the register, that is, the collected image data only contains Y component brightness information, and a lens of 45° to 60° is adopted.

[0076] The LED light supplement is used for enhancing the environmental brightness under the condition of low environmental brightness, especially the paper commodity code without a self-provided light source, so as to improve the brightness of the collected code image and be more conducive to decoding.

[0077] The positioning lamp provides clear and fast alignment function, and is convenient for operators to operate in time, when the light emitted by the positioning lamp is located in the central area of the code, it is indicated that the code reading engine has been aimed.

[0078] The MPU decoding board is mainly responsible for decoding the image collected by the camera, and in order to reduce the occupation of RAM space as much as possible, the frame rate of the camera and the decoding time of a single frame image are comprehensively evaluated, and the single frame decoding form is used, that is, one frame is collected and one frame is decoded.

[0079] Please refer to Figure 6 In an embodiment of the present application, Figure 6 The code image filtering red positioning lamp effect diagram is that the red light is emitted by the simple terminal device of the present application, the system controls the time sequence relationship between the positioning lamp and the code image collection, and effectively avoids the interference of the red light on the code image quality. Wherein, the a diagram is the collection effect after the filtering red lamp mechanism of the present application is started, the overall brightness of the image is uniform, and the code area is clear and distinguishable; the b diagram is the effect without starting the filtering mechanism, and obvious red light spots can be seen, and the code area loses details due to overexposure. This time sequence control mode effectively solves the problem of local overexposure of the image caused by the positioning lamp without increasing the hardware optical filter, and improves the decoding success rate.

[0080] Please refer to Figure 7 The present application further provides an electronic device 700, comprising a memory 701, a processor 702, a computer program stored in the memory 701 and running on the processor 702, and each step of the above-mentioned code scanning processing method is realized when the processor 702 executes the computer program.

[0081] The electronic device of the present application has the same advantages as the above-mentioned method, which will not be repeated here.

[0082] The above is only an embodiment of the present application, and does not limit the patent range of the present application, any equivalent transformation made by using the content of the specification and drawings, or direct or indirect application in related technical fields, is also included in the patent protection range of the present application.

Claims

1. A code scanning processing method, characterized by, The method is applied to an electronic device including a camera, a light compensation lamp and a positioning lamp, and the method comprises: starting the camera; before collecting a code image for decoding, turning off the positioning lamp and starting the light compensation lamp; after the collection of the code image is completed, starting the positioning lamp; decoding the code image to obtain a decoding result.

2. The method of claim 1, wherein, Before starting the camera, the method further comprises: receiving scan code mode selection information, and matching a default configuration according to the scan code mode selection information; setting initial exposure parameters and light compensation lamp parameters according to the default configuration; After starting the camera, the method further comprises: starting the light compensation lamp according to the light compensation lamp parameters, and collecting the code image according to the initial exposure parameters.

3. The method of claim 1, wherein, After starting the light compensation lamp, the method further comprises: storing the collected code image in a single buffer, which is configured to store only one latest image each time; The decoding of the code image to obtain a decoding result comprises: decoding the code image in a single-frame decoding mode by using the single buffer.

4. The method of claim 2, wherein, The method further comprises: obtaining ambient light and screen light of a device to be scanned; setting initial exposure parameters and light compensation lamp parameters according to the ambient light, screen light and the default configuration.

5. The method of claim 1, wherein, After the collection of the code image is completed, the method further comprises: determining a region of interest from the code image; calculating a mean value of pixel brightness in the region of interest in the code image in an interval sampling manner.

6. The method of claim 5, wherein, After the calculation of the mean value of pixel brightness in the region of interest in the code image in the interval sampling manner, the method further comprises: adjusting exposure time and gain of the camera of the electronic device according to the mean value of pixel brightness; adjusting expected brightness of the light compensation lamp according to the mean value of pixel brightness.

7. The method of claim 6, wherein, The method further comprises: when the scan code mode is a first mode biased towards electronic codes, reducing the exposure time and gain, and reducing the expected brightness; when the scan code mode is a second mode biased towards paper codes, increasing the exposure time and gain, and increasing the expected brightness.

8. The method of claim 6, wherein, The adjustment of the exposure time and gain of the camera of the electronic device according to the mean value of pixel brightness comprises: comparing the mean value of pixel brightness in the region of interest with an ambient brightness threshold value; if the mean value of pixel brightness is higher than a first ambient brightness threshold value, reducing the exposure time and gain, and turning off the light compensation lamp; if the mean value of pixel brightness is lower than a second ambient brightness threshold value, increasing the exposure time and gain, and simultaneously increasing the expected brightness of the light compensation lamp.

9. The method of claim 1, wherein, After the decoding of the code image to obtain a decoding result, the method further comprises: if the decoding result is a decoding failure, readjusting the expected brightness of the light compensation lamp, and returning to the step of turning off the positioning lamp.

10. An electronic device comprising a memory, a processor, and a computer program stored on the memory and running on the processor, characterized in that, The processor executes the computer program to implement each step in the scan code processing method according to any one of claims 1 to 9.