A code scanning method and a code scanning device suitable for the code scanning method
Patent Information
- Application Number
- CN202611151850.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2025-08-05
- Filing Date
- 2026-07-31
- Publication Date
- 2026-10-30
AI Technical Summary
[0006]本发明的目的在于解决现有技术中扫码设备的快速扫码实现方式导致扫码设备能耗增加的问题
本发明的适用于扫码设备的扫码方法,在使用扫码设备进行扫码时,先通过测距单元获取扫码设备与待扫码对象之间的距离,即目标物距数值;在获取到目标物距数值之后,根据预先确定的物距数值与像距数值的映射关系确定目标像距数值,该目标像距数值为对焦镜头与图像传感器之间的理想距离,在该目标像距数值下图像传感器能够获取到较为清晰的条码图像;在确定目标像距数值之后,基于目标像距数值对扫码设备的扫码头进行相应的镜头对焦操作,然后启动图像传感器获取条码图像,进而实现扫码操作。
Smart Images

Figure CN123013978A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of barcode scanning equipment, and more specifically, relates to a barcode scanning method and barcode scanning equipment suitable for barcode scanning equipment. Background Technology
[0002] A barcode scanning device is an electronic device with barcode scanning capabilities. It is widely used in various scanning scenarios, such as couriers using logistics PDAs to scan barcodes on logistics packages, cashiers using barcode scanners to scan barcodes on goods, and consumers using mobile phones to scan barcodes for payment.
[0003] For barcode scanning devices, an important product requirement is that they support both short-range and long-range scanning, meaning that the range of scanning distances they support is wide enough to allow the scanning devices to adapt to different application scenarios.
[0004] To support both close-range and long-range scanning, existing scanning devices typically employ scanners with autofocus lenses. However, traditional autofocus scanners rely on camera focusing, which requires image comparison algorithms to determine focus accuracy. This results in a lengthy focusing process, leading to slower scanning speeds and a less efficient user experience.
[0005] To address the issues of long focusing time and slow scanning speed in barcode scanning devices, some researchers have proposed a distance-based autofocus method for these devices to achieve faster scanning. For example, Chinese invention patent application CN116709017A discloses a scanning method and electronic device. The scanning method involves the electronic device activating its camera module and controlling a distance measuring module to measure the distance between the electronic device and the target barcode. Based on this measured distance, the electronic device determines the target movement parameters of the camera module, thereby achieving rapid autofocus and subsequent barcode recognition. However, while this solution effectively addresses the issues of long focusing time and slow scanning speed, the simultaneous activation of the camera module and the control of the distance measuring module significantly increases the energy consumption of the scanning device. Summary of the Invention
[0006] The purpose of this invention is to solve the problem of increased energy consumption caused by the fast scanning method of existing barcode scanning devices.
[0007] To achieve the above objectives, the present invention provides a barcode scanning method and a barcode scanning device suitable for barcode scanning equipment.
[0008] According to a first aspect of the present invention, a barcode scanning method suitable for a barcode scanning device is provided, the barcode scanning device including a ranging unit, a focusing lens, an image sensor, and a distance adjustment unit for adjusting the relative distance between the focusing lens and the image sensor; The scanning method includes: When the image sensor is in a closed or dormant state, the target distance value corresponding to the object to be scanned is obtained by the ranging unit in the ranging standby mode. The target position corresponding to the focusing lens is determined based on the target object distance value; With the image sensor in a closed or dormant state, the distance adjustment unit is controlled to adjust the focusing lens to the target position; After the focusing lens reaches the target position, the image sensor is activated to acquire an image of the object to be scanned; and The image is then barcode decoded.
[0009] Optionally, the constant ranging mode includes: the ranging unit periodically obtains the object distance value according to a preset ranging time interval.
[0010] Optionally, the ranging unit operates at a first ranging frequency when no object to be scanned is detected, and operates at a second ranging frequency higher than the first ranging frequency after detecting that the object to be scanned has entered a preset scanning distance range.
[0011] Optionally, before obtaining the target object distance value, the method also includes receiving a scanning command; The scanning instruction is generated by user operation, or automatically generated when at least one of the following conditions is met: The object to be scanned enters the preset scanning distance range; The time the object to be scanned stays within the preset scanning distance range reaches a preset time; or The variation range of multiple consecutively obtained object distance values is less than the preset stability threshold.
[0012] Optionally, determining the target position corresponding to the focusing lens based on the target object distance value includes: Based on the pre-stored mapping relationship between object distance values and image distance values, determine the target image distance value corresponding to the target object distance value; and The target position of the focusing lens is determined based on the target image distance value.
[0013] Alternatively, the mapping relationship between the object distance value and the image distance value may be represented by a lookup table, a fitting function, a piecewise function, or a calibrated lens position curve.
[0014] Optionally, the effective scanning distance of the scanning device is divided into multiple object distance intervals, and each object distance interval corresponds to a preset lens position. Determining the target position corresponding to the focusing lens based on the target object distance value includes: Determine the object distance interval to which the target object distance value belongs; and The preset lens position corresponding to the object distance range is determined as the target position.
[0015] Alternatively, two adjacent object distance intervals may have overlapping object distance ranges; When the target object distance value is within the overlapping object distance range, the preset lens position with the smaller movement distance from the current position of the focusing lens is selected from the preset lens positions corresponding to the two adjacent object distance intervals as the target position.
[0016] Optionally, a hysteresis region is provided between two adjacent object distance intervals, and the switching threshold used to switch from the first object distance interval to the second object distance interval is different from the switching threshold used to switch from the second object distance interval to the first object distance interval.
[0017] Optionally, controlling the distance adjustment unit to adjust the focusing lens to the target position includes: The target position is determined directly based on the target object distance value, and the focusing lens is controlled to move to the target position, instead of acquiring images and comparing image sharpness at multiple candidate lens positions.
[0018] Optionally, the ranging unit also outputs a ranging quality parameter corresponding to the target distance value; Before determining the target position based on the target distance value, the method further includes: Based on the ranging quality parameters, determine whether the target distance value meets the preset confidence conditions.
[0019] Optionally, the ranging quality parameters include at least one of echo intensity, signal-to-noise ratio, ranging confidence level, number of effective ranging points, dispersion of continuous ranging results, stability of continuous ranging results, and ranging status indicator.
[0020] Optionally, when the target distance value meets the preset confidence condition, the target position is determined based on the target distance value. When the target object distance value does not meet the preset confidence condition, the multiple consecutively obtained object distance values are filtered, and the target position is determined based on the filtered object distance value; or, the focusing lens is adjusted to a preset fault-tolerant position.
[0021] Alternatively, a refocusing compensation procedure can be performed if barcode decoding fails to be completed based on the acquired image. The compensation focus procedure includes: using the target position as a reference, controlling the focusing lens to move to at least one compensation position within a preset compensation range, and acquiring an image at the compensation position to re-decode the barcode.
[0022] Optionally, the focusing lens is determined to have reached the target position when any of the following conditions are met: Receive the positioning signal output by the distance adjustment unit; The stop signal output by the distance adjustment unit is received; Receive the position feedback signal output by the distance adjustment unit; or A preset driving time elapses from the issuance of the lens movement command to the distance adjustment unit.
[0023] Optionally, the ranging unit continuously obtains multiple object distance values according to a preset ranging time interval; Based on the multiple object distance values and the acquisition time of each object distance value, the relative motion parameters between the scanning device and the object to be scanned are determined; Based on the current object distance value, the relative motion parameters, and the estimated time from obtaining the current object distance value to the image sensor performing exposure, a predicted object distance value corresponding to the image sensor performing exposure is determined; and The target position of the focusing lens is determined based on the predicted object distance value.
[0024] Optionally, the relative motion parameters include at least one of the following: relative direction of movement, relative speed of movement, rate of change of object distance, and relative acceleration of movement. The estimated time includes at least one of the following: distance measurement result processing time, time required for the distance adjustment unit to drive the focusing lens, stabilization time after the focusing lens moves, startup time of the image sensor, and exposure delay.
[0025] Optionally, the ranging direction of the ranging unit does not coincide with the imaging optical axis of the focusing lens, and the scanning device stores the parallax compensation parameters between the ranging unit and the image sensor. The scanning method also includes: Based on the target distance value and the disparity compensation parameter, the predicted image position corresponding to the ranging position of the ranging unit within the imaging area of the image sensor is determined; and Based on whether the predicted image location is located within a preset scanning area or a candidate area of the target to be decoded, it is determined whether the target distance value is the target ranging result.
[0026] Optionally, when the predicted image location is located within the preset scanning area or the candidate area, the target location is determined based on the target object distance value. When the predicted image location is outside the preset scanning area or the candidate area, the ranging result is obtained again, the ranging result corresponding to the preset scanning area is selected from multiple ranging results, or the focusing lens is adjusted to a preset error-tolerant position.
[0027] Optionally, the scanning device may also include a supplementary lighting unit; The scanning method also includes: Determine the target illumination parameters based on the target object distance value; and When the image sensor is activated to acquire the image, the supplementary lighting unit is controlled according to the target supplementary lighting parameters.
[0028] Optionally, the target supplementary lighting parameters include at least one of supplementary lighting intensity, supplementary lighting duration, supplementary lighting on time, supplementary lighting off time, and the activation status of different supplementary lighting sources; When the target object distance value is in the close object distance range, reduce the supplementary light intensity of the supplementary light unit or shorten the supplementary light duration; When the target object distance value is in the long distance object distance range, the supplementary light intensity of the supplementary light unit is increased or the supplementary light duration is extended.
[0029] Optionally, the scanning device stores at least one historical object distance value and historical lens position corresponding to a successful barcode decoding during a historical scanning process; When the difference between the target distance value corresponding to this scan and the historical object distance value is less than a preset distance difference, the focusing lens is kept at the historical lens position, or the focusing lens is adjusted near the historical lens position.
[0030] Optionally, after acquiring the image or decoding the barcode, the image sensor is turned off or put into a sleep state, and the ranging unit continues to maintain the ranging standby mode.
[0031] According to a second aspect of the present invention, a barcode scanning device is provided, the barcode scanning device comprising: The ranging unit is used to obtain the target distance value corresponding to the object to be scanned in the constant ranging mode. Focusing lens; Image sensor; A distance adjustment unit is used to adjust the relative distance between the focusing lens and the image sensor; and The control unit is connected to the ranging unit, the image sensor, and the distance adjustment unit, respectively. The control unit is configured as follows: When the image sensor is in a turned-off or sleep state, the distance value of the target object is obtained through the ranging unit; The target position corresponding to the focusing lens is determined based on the target object distance value; With the image sensor in a closed or dormant state, the distance adjustment unit is controlled to adjust the focusing lens to the target position; After the focusing lens reaches the target position, the image sensor is activated to acquire an image of the object to be scanned; and The image is then barcode decoded.
[0032] Optionally, the scanning device further includes a storage unit, which stores at least one of the following information: The mapping relationship between object distance and image distance; The correspondence between object distance ranges and preset lens positions; Distance measurement quality judgment criteria; Parallax compensation parameters; Fill light parameters; and Historical object distance values and historical camera positions corresponding to successful barcode decoding during historical scanning processes.
[0033] Optionally, the distance adjustment unit includes at least one of a piezoelectric element, a voice coil motor, a stepper motor, a shape memory alloy driver, a liquid lens driver, or a microelectromechanical driver. The distance adjustment unit is used to drive the focusing lens to move relative to the image sensor, drive the image sensor to move relative to the focusing lens, or simultaneously adjust the positions of the focusing lens and the image sensor.
[0034] Optionally, the ranging unit includes at least one of a time-of-flight ranging module, an infrared ranging module, an ultrasonic ranging module, a laser triangulation ranging module, a structured light ranging module, or a binocular ranging module.
[0035] The beneficial effects of this invention are as follows: The present invention provides a barcode scanning method applicable to barcode scanning devices. When scanning with the barcode scanning device, the distance between the scanning device and the object to be scanned, i.e., the target object distance value, is first obtained through a ranging unit. After obtaining the target object distance value, a target image distance value is determined according to a pre-determined mapping relationship between the object distance value and the image distance value. This target image distance value is the ideal distance between the focusing lens and the image sensor, at which the image sensor can acquire a relatively clear barcode image. After determining the target image distance value, the scanning terminal of the barcode scanning device is focused accordingly based on the target image distance value, and then the image sensor is activated to acquire the barcode image, thereby realizing the scanning operation.
[0036] The present invention provides a barcode scanning method applicable to barcode scanners. Based on measuring the distance between the barcode scanner and the object to be scanned (i.e., the target object distance value), and determining the target image distance value using this target object distance value, the method can quickly determine the target image distance value used to obtain a clear barcode image for the image sensor. This allows for accurate lens focusing in a single, rapid operation, enabling fast barcode scanning. The scanning method of the present invention performs distance measurement and lens focusing first, and only after the lens focusing operation is completed does the image sensor begin acquiring the barcode image. Compared to existing fast barcode scanning methods, this setup has a negligible impact on scanning speed, while significantly reducing the energy consumption of the barcode scanner. This achieves a substantial reduction in energy consumption without sacrificing scanning speed, effectively solving the problem of increased energy consumption caused by fast barcode scanning methods in existing technologies.
[0037] Other features and advantages of the present invention will be described in detail in the following detailed description section. Attached Figure Description
[0038] The present invention can be better understood by referring to the following description taken in conjunction with the accompanying drawings, in which the same or similar reference numerals are used throughout the drawings to denote the same or similar parts.
[0039] Figure 1 A flowchart illustrating the implementation of a barcode scanning method applicable to a barcode scanning device according to an embodiment of the present invention is shown; Figure 2 A schematic diagram illustrating the focusing principle of a barcode scanning device according to an embodiment of the present invention is shown. Detailed Implementation
[0040] To enable those skilled in the art to more fully understand the technical solutions of the present invention, exemplary embodiments of the present invention will be described more comprehensively and in detail below with reference to the accompanying drawings. Obviously, the one or more embodiments of the present invention described below are merely one or more specific ways to implement the technical solutions of the present invention, and are not exhaustive. It should be understood that other ways belonging to a general inventive concept can be used to implement the technical solutions of the present invention, and should not be limited to the embodiments described exemplary. Based on one or more embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0041] Example: Figure 1 A flowchart illustrating the implementation of a barcode scanning method applicable to a barcode scanning device according to an embodiment of the present invention is shown. (Refer to...) Figure 1 This invention provides a barcode scanning method suitable for barcode scanning devices. Specifically, the barcode scanning device in this embodiment may include a scanning terminal, which includes a ranging unit, a focusing lens, and an image sensor. The ranging unit can be, for example, an instrument or device with ranging function such as a Time-of-Flight (ToF) ranging module, an infrared ranging module (IR ranging), an ultrasonic ranging module, a laser triangulation ranging module, a structured light ranging module, or a binocular ranging module. The focusing lens and the image sensor constitute a camera unit. The scanning terminal also includes a distance adjustment unit for adjusting the distance between the focusing lens and the image sensor.
[0042] In some embodiments, the barcode scanning device further includes a control unit, a storage unit, and a supplementary lighting unit. The control unit is connected to the ranging unit, the distance adjustment unit, the image sensor, and the supplementary lighting unit, respectively, and is used to control the operating status of each of the aforementioned units. The storage unit is used to store at least one of the following: the mapping relationship between object distance values and image distance values, the correspondence between object distance ranges and lens positions, ranging quality judgment conditions, parallax compensation parameters, exposure parameters, and supplementary lighting parameters.
[0043] The control unit can be implemented by the central processing unit, microcontroller, digital signal processor, image signal processor or control chip dedicated to scanning control of the barcode scanning device, or it can be implemented by two or more of the aforementioned devices.
[0044] The scanning method applicable to barcode scanning devices in this embodiment includes the following steps: Step S100: Receive a scanning command to start the ranging unit and put it into a ranging standby mode; Step S200: Obtain the distance value of a target object through the ranging unit; Step S300: Adjust the distance between the focusing lens in the camera unit and the image sensor based on the target distance value obtained by the ranging unit; Step S400: Activate the image sensor and acquire an image through the image sensor; Step S500: Complete the scanning process.
[0045] In step S100, the specific form of receiving the scanning command may include: launching the corresponding application through the user interface of the scanning device, or launching the application through a physical button on the scanning device. This embodiment of the invention is not limited to the above-described receiving method. In other embodiments, the scanning command can also be automatically generated by the scanning device based on the change in object distance obtained by the ranging unit. For example, when the control unit determines that the object to be scanned has entered a preset scanning distance range, the dwell time within the preset scanning distance range reaches a preset time, or the change in the continuously obtained object distance values is less than a preset stable threshold, the control unit automatically generates a scanning command. In some embodiments of this application, the preset scanning distance range is configured by the application software as a parameter, such as 100mm ~ 300mm; the preset time is configured by the application software as a time range, such as 500ms ~ 2000ms; and the preset stable threshold is configured by the application software as a stable threshold, such as 5mm. It should be noted that, in order to reduce the energy consumption of the barcode scanning device, in this embodiment, while the ranging unit of the barcode scanning device is in the ranging standby state, other functions or units of the barcode scanning device (such as the camera unit) are in a closed or dormant state.
[0046] In this embodiment, the constant ranging mode does not necessarily mean that the ranging unit always operates at the maximum ranging frequency and maximum output power. The ranging unit can perform periodic ranging at preset time intervals, or it can operate at a first ranging frequency when there is no object to be scanned, and switch to a second ranging frequency higher than the first ranging frequency after detecting that the object to be scanned has entered a preset distance range. In some embodiments of this application, the first ranging frequency is configured by the application software, for example, 1Hz; the second ranging frequency is configured by the application software, for example, 100Hz. This can further reduce the power consumption of the ranging unit during non-scanning periods.
[0047] After obtaining the target distance value in step S200, this is used as the activation mechanism for the distance adjustment unit of the camera unit in step S300. In step S300, after the scanning device obtains the target distance value through the ranging unit, the distance adjustment unit in the camera unit adjusts the distance between the focusing lens and the image sensor according to the target distance value, so as to make the target object present the clearest (or relatively clear) image in the image sensor.
[0048] In some implementations, in addition to outputting the target distance value, the ranging unit also outputs ranging quality parameters corresponding to the target distance value. These ranging quality parameters include at least one of the following: echo intensity, signal-to-noise ratio, ranging confidence level, number of effective ranging points, dispersion of continuous ranging results, stability of continuous ranging results, and ranging status indicator.
[0049] The control unit determines whether the corresponding target distance value meets preset confidence conditions based on the ranging quality parameters. Preset confidence conditions may include at least one of the following: echo intensity not lower than a preset echo threshold, signal-to-noise ratio not lower than a preset signal-to-noise ratio threshold, ranging confidence not lower than a preset confidence threshold, the dispersion of multiple consecutive target distance values not greater than a preset dispersion threshold, or the variation amplitude of multiple consecutive target distance values not greater than a preset variation threshold. In some embodiments of this application, each of the aforementioned thresholds can be flexibly configured by application software to adapt to specific scenarios, such as: ranging confidence higher than 80%, and the variation amplitude of multiple target distance values less than 10mm.
[0050] When the target object distance value meets the preset confidence condition, the control unit uses the target object distance value as the effective object distance value for determining the position of the focusing lens.
[0051] When the target object distance value does not meet the preset confidence condition, the control unit does not directly adjust the focusing lens based on the target object distance value obtained in a single transaction. Instead, it filters multiple consecutively obtained object distance values and determines the target image distance value based on the filtered object distance value. The filtering method can be mean filtering, median filtering, weighted average filtering, amplitude limiting filtering, Kalman filtering, or other filtering methods that can suppress abnormal ranging results. In some embodiments of this application, the number of object distance values used for filtering can be configured by the application software to adjust the filtering intensity. For example, the number of filtered object distance values can be set to 5.
[0052] When multiple consecutive object distance values do not meet the preset reliability conditions, the control unit can adjust the focusing lens to a preset tolerance position. The preset tolerance position can be the lens position corresponding to the most commonly used scanning distance of the barcode scanner, or a lens position that provides a large decodeable depth of field within the preset scanning distance range. The most commonly used scanning distance and the preset tolerance position can be configured via application software to adapt to different scenarios, such as 15cm, 22cm, or 30cm.
[0053] In some embodiments, the control unit can also initiate a compensation focus program when initial focusing is completed according to the target object distance value, but decoding fails based on the acquired image. The compensation focus program uses the initial focus position as a reference, causing the focusing lens to make at least one small movement within a preset compensation range, and acquiring images at different compensation positions to obtain an image that meets the barcode decoding requirements. In some embodiments of this application, the preset compensation range is ±10cm, the single movement distance is 2cm, and the maximum number of compensations is 5. Since compensation focus is only initiated when initial decoding fails, it does not substantially affect the focusing speed and energy consumption during normal barcode scanning.
[0054] Furthermore, this embodiment can divide the effective scanning distance of the barcode scanner into multiple object distance intervals, and set corresponding preset lens positions for different object distance intervals. In some embodiments of this application, the multiple object distance intervals may include a near object distance interval, a medium object distance interval, and a far object distance interval, with the specific range of each object distance interval being: near distance: 15cm, medium distance: 22cm, and far distance: 30cm.
[0055] When the effective object distance value falls within one of the object distance intervals, the control unit controls the distance adjustment unit to move the focusing lens to the preset lens position corresponding to that object distance interval, without having to continuously calculate the corresponding lens position for each object distance value. Since barcode decoding usually only requires the image sharpness to reach a preset decoding threshold, rather than obtaining the sharpest image in a photographic sense, using discrete object distance intervals and preset lens positions can reduce the computational load of the control unit and shorten the response time of the distance adjustment unit.
[0056] Adjacent object distance intervals may have partially overlapping object distance ranges. When the effective object distance values are within the overlapping object distance ranges, the control unit can select a preset lens position with a smaller movement distance based on the current position of the focusing lens, thereby reducing the lens movement distance and the energy consumption of the distance adjustment unit.
[0057] In other embodiments, a hysteresis region is provided between two adjacent object distance intervals. The control unit uses different switching thresholds for switching from the first object distance interval to the second object distance interval and from the second object distance interval to the first object distance interval. The control unit only adjusts the focusing lens to the preset lens position corresponding to the adjacent object distance interval when the effective object distance value exceeds the exit threshold corresponding to the current object distance interval. This avoids the focusing lens repeatedly moving between two preset lens positions when the effective object distance value fluctuates near the boundary of the object distance interval. In some embodiments of this application, the hysteresis region and the corresponding entry and exit thresholds are 3cm to 5cm. In addition to using a discrete correspondence between object distance ranges and preset lens positions, the control unit can also determine the target image distance value based on a pre-stored continuous mapping relationship between object distance values and image distance values. This continuous mapping relationship can be represented using a lookup table, a fitting function, a piecewise function, or a calibrated lens position curve.
[0058] Next, in step S400, the image sensor in the camera unit is activated, enabling the scanning device to acquire an image of the target object and complete the image scanning process. It should be noted that, in this embodiment of the invention, to reduce the power consumption of the scanning device, the image sensor is in a switched-off or dormant state before step S400; once the distance adjustment unit stops operating (i.e., after the distance adjustment between the focusing lens and the image sensor is completed), the image sensor function is activated, and the scanning process in step S500 is completed. Specifically, during the period when the ranging unit obtains the target distance value and the distance adjustment unit adjusts the focusing lens, the image sensor remains in a switched-off or dormant state. The control unit can determine that the focusing lens has reached the target position and activate the image sensor after receiving the arrival signal, stop signal, or position feedback signal output by the distance adjustment unit.
[0059] In embodiments where the distance adjustment unit does not have a position feedback function, the control unit can activate the image sensor after issuing a lens movement command to the distance adjustment unit and then waiting for a preset driving time. The preset driving time is determined based on the lens movement distance, the driving speed of the distance adjustment unit, and the stabilization time of the distance adjustment unit. In some embodiments of this application, it is specifically determined by the physical characteristics of the driving components; for example, for a voice coil motor, it can generally reach about 10 milliseconds.
[0060] The target object image mentioned above includes, but is not limited to, one-dimensional barcodes (1D Barcode) or two-dimensional barcodes (2D Barcode); and the scanning program is a program that identifies the target object through a camera unit and reads the information content of the target object itself, which is collectively referred to as the scanning program in this embodiment of the invention.
[0061] Specifically, Figure 2 A schematic diagram illustrating the focusing principle of the barcode scanning device according to an embodiment of the present invention is shown. In the diagram, 100 represents the image sensor, 200 represents the focusing lens, 300 represents the ranging unit, 400 represents the object to be scanned, and 500 represents the distance adjustment unit. A represents the focusing range of the scanning terminal; under the control of the distance adjustment unit, the focusing lens can move within the focusing range. B represents the object distance, i.e., the distance between the scanning terminal and the object to be scanned.
[0062] Reference Figure 2When using a barcode scanner, the distance between the scanner and the object to be scanned, i.e., the target object distance, is first obtained through a ranging unit. After obtaining the target object distance, the target image distance is determined based on the mapping relationship between object distance and image distance values pre-acquired or stored in the scanner. This target image distance is the ideal distance between the focusing lens and the image sensor, at which the image sensor acquires a clear barcode image. After determining the target image distance, the distance adjustment unit is activated to adjust the image distance, the scanner lens is focused, and then the image sensor is activated to acquire the image of the target object (e.g., the barcode image), thus realizing the scanning operation. It should be noted that the target image distance does not necessarily correspond to the image distance that produces the absolutely clearest image of the object to be scanned, but can be the image distance that ensures the clarity, contrast, or barcode feature integrity of the acquired image meets preset decoding conditions. The scanning method for barcode scanning devices using the embodiments of the present invention, compared with the existing lens focusing method based on image comparison algorithms, can avoid the image comparison process, so that the focusing process occurs before image exposure, thereby greatly reducing the impact of the focusing process on the scanning and recognition speed, and thus achieving the goal of supporting multiple scanning distance application scenarios without sacrificing performance.
[0063] In some embodiments, to accommodate scanning scenarios where there is relative motion between the scanning device and the object to be scanned, the ranging unit continuously acquires multiple object distance values at preset ranging time intervals. The control unit determines the relative motion parameters between the scanning device and the object to be scanned based on these multiple object distance values and the acquisition time corresponding to each value. The relative motion parameters include at least one of relative movement direction, relative movement speed, object distance change rate, and relative movement acceleration. In some embodiments of this application, the preset ranging time interval is 10 ms.
[0064] The control unit determines the predicted object distance between the scanning device and the object to be scanned when the image sensor performs exposure, based on the current target object distance value, relative motion parameters, and the estimated time between obtaining the current target object distance value and the image sensor performing exposure.
[0065] The estimated time may include at least one of the following: the time required for the control unit to process the ranging result, the time required for the distance adjustment unit to drive the focusing lens, the stabilization time after the focusing lens moves, the image sensor startup time, and the image sensor exposure delay. The aforementioned time parameters are [provided by the inventor].
[0066] The control unit determines the target image distance based on the predicted object distance value, rather than solely on the current target object distance value, and controls the distance adjustment unit to adjust the distance between the focusing lens and the image sensor. In this way, the focal plane corresponding to the focusing lens can match the position of the object to be scanned when the image sensor actually performs exposure, thereby reducing focusing lag caused by movement of the scanning device or the object to be scanned.
[0067] When the rate of change of the target object distance value exceeds a preset rate of change threshold, the control unit can update the predicted object distance value based on the latest obtained object distance value and correct the target position of the focusing lens; alternatively, it can delay the exposure time of the image sensor until the rate of change of the target object distance value decreases below the preset rate of change threshold. In some embodiments of this application, the preset rate of change threshold is 5 meters per second.
[0068] Specifically, in this embodiment of the invention, the distance adjustment unit for adjusting the distance between the focusing lens and the image sensor is implemented using a piezoelectric element or a motor. The position of the focusing lens is adjusted by the piezoelectric element or motor to regulate the distance between the focusing lens and the image sensor, thereby obtaining a clearer image on the image sensor. The image distance is adjusted based on the ranging result (i.e., object distance) from the ranging unit. The distance adjustment unit can also be implemented using a voice coil motor, a stepper motor, a shape memory alloy drive, a liquid lens drive, or a microelectromechanical system (MEMS) drive. The distance adjustment unit can drive the focusing lens to move relative to the image sensor, or drive the image sensor to move relative to the focusing lens, or simultaneously adjust the positions of both the focusing lens and the image sensor. The barcode scanning application resides in the system background and starts with the system. Upon startup, the ranging unit is activated. When not scanning, the image distance is not adjusted; only during barcode scanning is the camera activated and the image distance adjusted according to the object distance value to obtain a clearer image. Since the barcode decoding algorithm does not have strict requirements for image sharpness, it does not need to focus multiple times to obtain the sharpest image distance like a regular camera. It only needs to adjust the image distance once to achieve the focus effect required for decoding.
[0069] In this embodiment, adjusting the image distance once means that when the target object distance value meets the preset confidence condition and the object to be scanned has not moved relative to the target object distance value or the predicted object distance value, the control unit directly determines the target lens position based on the target object distance value or the predicted object distance value, and controls the distance adjustment unit to move the focusing lens to the target lens position, without needing to acquire images at multiple candidate lens positions and compare image sharpness.
[0070] If the initial decoding fails, the ranging result does not meet the preset reliability conditions, or the target object distance changes abnormally, the aforementioned compensation focusing procedure can be initiated. Therefore, "adjusting the image distance once" does not exclude compensation adjustments made in abnormal situations to improve the scanning success rate.
[0071] Specifically, in this embodiment of the invention, the ranging unit starts working after the system is started and remains in the object distance detection state as long as the system does not enter sleep mode; conversely, the camera unit or image sensor only starts after the distance adjustment unit stops operating (i.e., after the distance between the focusing lens and the image sensor is adjusted) and is ready to enter the barcode scanning program to scan, thereby achieving the purpose of early ranging and low power consumption control.
[0072] In some implementations, the control unit also performs coordinated control of the illumination unit and the image sensor based on the target object distance value. Specifically, the control unit determines the target illumination parameters and the target exposure parameters based on the target object distance value.
[0073] The target illumination parameters include at least one of the following: illumination intensity, illumination duration, illumination on / off time, illumination off time, and the activation status of different illumination sources. The target exposure parameters include at least one of the following: exposure time, analog gain, digital gain, image frame rate, image resolution, and exposure start time.
[0074] When the target object distance is within the close object distance range, the control unit reduces the supplementary light intensity, shortens the supplementary light duration, reduces the image sensor gain, or shortens the exposure time to reduce local overexposure caused by surface reflection of the object to be scanned. In some embodiments of this application, the supplementary light current limit can be lowered to a minimum at close range to save power and effectively suppress supplementary light heating. A typical current limit is 100mA. The exposure parameters are actually handled by the camera's exposure algorithm and are unrelated to the distance.
[0075] When the target object distance is within the long distance range, the control unit increases the supplementary light intensity, extends the supplementary light duration, increases the image sensor gain, or adjusts the exposure time to improve the brightness and signal-to-noise ratio of the image area corresponding to the object to be scanned. In some embodiments of this application, the supplementary light current limit can be temporarily increased to the maximum at long distances, supporting scanning and recognition at greater distances at the cost of greater current drive and heat generation. The typical drive current is 400mA. The exposure parameters are handled by the camera's exposure algorithm itself and are actually unrelated to the distance.
[0076] The control unit can activate the fill light unit and image sensor after the distance adjustment unit completes the focus lens position adjustment, or it can pre-activate the fill light unit when the distance adjustment unit is about to complete the position adjustment, so that the fill light unit reaches the target brightness when the image sensor performs exposure. In some embodiments of this application, the pre-activation time of the fill light unit is less than 1 millisecond.
[0077] After the image sensor completes image acquisition, the control unit can turn off the supplementary light unit and put the image sensor back into a shutdown or sleep state; the ranging unit will remain in the ranging standby mode to obtain object distance information in advance for the next scanning operation.
[0078] Specifically, in this embodiment of the invention, the barcode scanning application starts with the system and remains permanently running in the background. The ranging unit and the image sensor are both controlled by this background application. The ranging unit can work independently, thereby realizing a simple ranging function and its derived box volume measurement function.
[0079] In some implementations, the ranging direction of the ranging unit does not completely coincide with the imaging optical axis of the focusing lens. For example, as... Figure 2 As shown, the ranging unit 300 can be positioned on one side of the focusing lens 200, creating a preset spatial distance between the ranging unit 300 and the focusing lens 200. Therefore, when scanning codes at close range or when the object to be scanned is tilted, there may be parallax between the actual position measured by the ranging unit and the corresponding position in the center of the image sensor's imaging area.
[0080] Therefore, the scanning device pre-stores parallax compensation parameters between the ranging unit and the image sensor. These parallax compensation parameters can be determined based on the installation distance between the ranging unit and the focusing lens, the ranging direction of the ranging unit, the imaging optical axis direction of the focusing lens, the field of view of the focusing lens, and the target object distance. In some embodiments of this application, the specific installation distance is 5~10mm, the typical angle is 0~4°, and the typical field of view range of the lens is 30°~70°.
[0081] The control unit determines the predicted image position corresponding to the ranging unit's ranging position within the image sensor's imaging area based on the target object distance value and parallax compensation parameters, and determines whether the predicted image position is located within the preset scanning area or the candidate area of the target to be decoded.
[0082] When the predicted image location is within the preset scanning area or the candidate area of the target to be decoded, the control unit uses the target object distance value to determine the target image distance value.
[0083] When the predicted image location is outside the preset scanning area or the candidate area of the target to be decoded, the control unit can determine the target distance value as a non-target ranging result, and obtain the ranging result again, select the ranging result corresponding to the preset scanning area from multiple ranging results, or adjust the focusing lens to the preset fault-tolerant position.
[0084] Parallax compensation parameters can be stored in the scanning device in the form of lookup tables, coordinate transformation matrices, fitting functions, or piecewise mapping relationships.
[0085] Specifically, in this embodiment of the invention, when the camera unit is not working, the ranging unit continues to operate normally to obtain object distance information in advance, ensuring that focusing is completed before exposure. During focusing, there is no need to repeatedly adjust the image distance or perform image comparison calculations, reducing the scanning device's dependence on the system ISP and significantly improving focusing speed. The independently operating ranging unit is also used for ranging and box volume measurement.
[0086] In some embodiments, the control unit can also store the historical object distance value and historical lens position corresponding to at least one successful decoding during a historical scanning process. When the difference between the target object distance value corresponding to the next scanning operation and the historical object distance value is less than a preset distance difference, the control unit can keep the focusing lens in the historical lens position, or only make minor adjustments near the historical lens position, to further shorten the lens adjustment time in continuous scanning scenarios. In some embodiments of this application, the preset distance difference and minor adjustment range are 5cm.
[0087] After completing the barcode scanning procedure in step S500, the control unit can output the barcode decoding result and update the object distance value, lens position, ranging quality parameters, exposure parameters, and fill light parameters corresponding to this scan based on whether the decoding result was successfully obtained. The data corresponding to successful decoding can be used as historical reference data for subsequent barcode scanning control; the data corresponding to unsuccessful decoding can be used to adjust the compensation focus strategy or ranging quality judgment conditions.
[0088] It should be noted that the aforementioned range measurement reliability judgment, object distance range and hysteresis control, motion prediction focusing, parallax compensation, and supplementary lighting and exposure coordination control can be implemented in combination, or one or more of them can be selected for implementation according to the hardware configuration of the barcode scanning device and the application scenario.
[0089] For example, in fixed POS scanning devices, object distance range, hysteresis control, and supplementary lighting and exposure coordination control can be adopted; in handheld logistics PDAs, continuous ranging and motion predictive focusing can be further adopted; in scanning terminals where the ranging unit and the imaging optical axis have a large distance, parallax compensation can be further adopted; in scenarios where the reflectivity of the object to be scanned varies greatly, ranging reliability judgment and abnormal ranging handling can be adopted.
[0090] While one or more embodiments of the present invention have been described above, those skilled in the art will recognize that the present invention can be implemented in any other form without departing from its spirit and scope. Therefore, the embodiments described above are illustrative and not restrictive, and many modifications and substitutions will be apparent to those skilled in the art without departing from the spirit and scope of the invention as defined in the appended claims.
Claims
1. A barcode scanning method suitable for a barcode scanning device, the barcode scanning device comprising a ranging unit, a focusing lens, an image sensor, and a distance adjustment unit for adjusting the relative distance between the focusing lens and the image sensor, characterized in that, The scanning method includes: When the image sensor is in a closed or dormant state, the target distance value corresponding to the object to be scanned is obtained by the ranging unit in the ranging standby mode. The target position corresponding to the focusing lens is determined based on the target object distance value; With the image sensor in a closed or dormant state, the distance adjustment unit is controlled to adjust the focusing lens to the target position; After the focusing lens reaches the target position, the image sensor is activated to acquire an image of the object to be scanned; and The image is then barcode decoded.
2. The scanning method according to claim 1, characterized in that, The constant ranging mode includes: the ranging unit periodically obtains the object distance value according to a preset ranging time interval.
3. The scanning method according to claim 2, characterized in that, The ranging unit operates at a first ranging frequency when no object to be scanned is detected, and operates at a second ranging frequency higher than the first ranging frequency after detecting that the object to be scanned has entered a preset scanning distance range.
4. The scanning method according to claim 1, characterized in that, Before obtaining the target object distance value, the process also includes receiving a scanning command; The scanning instruction is generated by user operation, or automatically generated when at least one of the following conditions is met: The object to be scanned enters the preset scanning distance range; The time the object to be scanned stays within the preset scanning distance range reaches a preset time; or The variation range of multiple consecutively obtained object distance values is less than the preset stability threshold.
5. The scanning method according to claim 1, characterized in that, Determining the target position corresponding to the focusing lens based on the target object distance value includes: Based on the pre-stored mapping relationship between object distance values and image distance values, determine the target image distance value corresponding to the target object distance value; and The target position of the focusing lens is determined based on the target image distance value.
6. The scanning method according to claim 5, characterized in that, The mapping relationship between the object distance value and the image distance value is represented by a lookup table, a fitting function, a piecewise function, or a lens position curve obtained through calibration.
7. The scanning method according to claim 1, characterized in that, The effective scanning distance of the scanning device is divided into multiple object distance intervals, and each object distance interval corresponds to a preset lens position. Determining the target position corresponding to the focusing lens based on the target object distance value includes: Determine the object distance interval to which the target object distance value belongs; as well as The preset lens position corresponding to the object distance range is determined as the target position.
8. The scanning method according to claim 7, characterized in that, Two adjacent object distance intervals have overlapping object distance ranges; When the target object distance value is within the overlapping object distance range, the preset lens position with the smaller movement distance from the current position of the focusing lens is selected from the preset lens positions corresponding to the two adjacent object distance intervals as the target position.
9. The scanning method according to claim 7, characterized in that, A hysteresis region is provided between two adjacent object distance intervals. The switching threshold used to switch from the first object distance interval to the second object distance interval is different from the switching threshold used to switch from the second object distance interval to the first object distance interval.
10. The scanning method according to claim 1, characterized in that, Controlling the distance adjustment unit to adjust the focusing lens to the target position includes: The target position is determined directly based on the target object distance value, and the focusing lens is controlled to move to the target position, instead of acquiring images and comparing image sharpness at multiple candidate lens positions.
11. The scanning method according to claim 1, characterized in that, The ranging unit also outputs ranging quality parameters corresponding to the target distance value; Before determining the target position based on the target distance value, the method further includes: Based on the ranging quality parameters, determine whether the target distance value meets the preset confidence conditions.
12. The scanning method according to claim 11, characterized in that, The ranging quality parameters include at least one of the following: echo intensity, signal-to-noise ratio, ranging confidence level, number of effective ranging points, dispersion of continuous ranging results, stability of continuous ranging results, and ranging status indicator.
13. The scanning method according to claim 11, characterized in that: When the target distance value meets the preset confidence condition, the target position is determined based on the target distance value. When the target object distance value does not meet the preset confidence condition, the multiple consecutively obtained object distance values are filtered, and the target position is determined based on the filtered object distance value; or, the focusing lens is adjusted to a preset fault-tolerant position.
14. The scanning method according to claim 1, characterized in that, If barcode decoding fails to be completed successfully based on the acquired image, a refocusing compensation procedure is executed. The compensation focus procedure includes: using the target position as a reference, controlling the focusing lens to move to at least one compensation position within a preset compensation range, and acquiring an image at the compensation position to re-decode the barcode.
15. The scanning method according to claim 1, characterized in that, The focusing lens is determined to have reached the target position when any of the following conditions are met: Receive the positioning signal output by the distance adjustment unit; The stop signal output by the distance adjustment unit is received; Receive the position feedback signal output by the distance adjustment unit; or A preset driving time elapses from the issuance of the lens movement command to the distance adjustment unit.
16. The scanning method according to claim 1, characterized in that, The ranging unit continuously obtains multiple object distance values according to a preset ranging time interval; Based on the multiple object distance values and the acquisition time of each object distance value, the relative motion parameters between the scanning device and the object to be scanned are determined; Based on the current object distance value, the relative motion parameters, and the estimated time from obtaining the current object distance value to the image sensor performing exposure, the predicted object distance value corresponding to the image sensor performing exposure is determined; as well as The target position of the focusing lens is determined based on the predicted object distance value.
17. The scanning method according to claim 16, characterized in that, The relative motion parameters include at least one of the following: relative direction of movement, relative speed of movement, rate of change of object distance, and relative acceleration of movement. The estimated time includes at least one of the following: distance measurement result processing time, time required for the distance adjustment unit to drive the focusing lens, stabilization time after the focusing lens moves, startup time of the image sensor, and exposure delay.
18. The scanning method according to claim 1, characterized in that, The ranging direction of the ranging unit does not coincide with the imaging optical axis of the focusing lens, and the scanning device stores the parallax compensation parameters between the ranging unit and the image sensor. The scanning method also includes: Based on the target distance value and the disparity compensation parameter, determine the predicted image position corresponding to the ranging position of the ranging unit within the imaging area of the image sensor; and Based on whether the predicted image location is located within a preset scanning area or a candidate area of the target to be decoded, it is determined whether the target distance value is the target ranging result.
19. The scanning method according to claim 18, characterized in that: When the predicted image location is located within the preset scanning area or the candidate area, the target location is determined based on the target object distance value. When the predicted image location is outside the preset scanning area or the candidate area, the ranging result is obtained again, the ranging result corresponding to the preset scanning area is selected from multiple ranging results, or the focusing lens is adjusted to a preset error-tolerant position.
20. The scanning method according to claim 1, characterized in that, The scanning device also includes a supplementary lighting unit; The scanning method also includes: Determine the target illumination parameters based on the target object distance value; and When the image sensor is activated to acquire the image, the supplementary lighting unit is controlled according to the target supplementary lighting parameters.
21. The scanning method according to claim 20, characterized in that, The target supplementary lighting parameters include at least one of the following: supplementary lighting intensity, supplementary lighting duration, supplementary lighting on time, supplementary lighting off time, and activation status of different supplementary lighting sources; When the target object distance value is in the close object distance range, reduce the supplementary light intensity of the supplementary light unit or shorten the supplementary light duration; When the target object distance value is in the long distance object distance range, the supplementary light intensity of the supplementary light unit is increased or the supplementary light duration is extended.
22. The scanning method according to claim 1, characterized in that, The scanning device stores at least one historical object distance value and historical lens position corresponding to a successful barcode decoding during a historical scanning process. When the difference between the target distance value corresponding to this scan and the historical object distance value is less than a preset distance difference, the focusing lens is kept at the historical lens position, or the focusing lens is adjusted near the historical lens position.
23. The scanning method according to claim 1, characterized in that, After acquiring the image or decoding the barcode, the image sensor is turned off or put into sleep mode, and the ranging unit continues to maintain the ranging standby mode.
24. A barcode scanning device, characterized in that, include: The ranging unit is used to obtain the target distance value corresponding to the object to be scanned in the constant ranging mode. Focusing lens; Image sensor; A distance adjustment unit is used to adjust the relative distance between the focusing lens and the image sensor; as well as The control unit is connected to the ranging unit, the image sensor, and the distance adjustment unit, respectively. The control unit is configured as follows: When the image sensor is in a turned-off or sleep state, the distance value of the target object is obtained through the ranging unit; The target position corresponding to the focusing lens is determined based on the target object distance value; With the image sensor in a closed or dormant state, the distance adjustment unit is controlled to adjust the focusing lens to the target position; After the focusing lens reaches the target position, the image sensor is activated to acquire an image of the object to be scanned; as well as The image is then barcode decoded.
25. The barcode scanning device according to claim 24, characterized in that, It also includes a storage unit that stores at least one of the following information: The mapping relationship between object distance and image distance; The correspondence between object distance ranges and preset lens positions; Distance measurement quality judgment criteria; Parallax compensation parameters; Fill light parameters; as well as Historical object distance values and historical camera positions corresponding to successful barcode decoding during historical scanning processes.
26. The barcode scanning device according to claim 23, characterized in that, The distance adjustment unit includes at least one of a piezoelectric element, a voice coil motor, a stepper motor, a shape memory alloy driver, a liquid lens driver, or a microelectromechanical system (MEMS) driver. The distance adjustment unit is used to drive the focusing lens to move relative to the image sensor, drive the image sensor to move relative to the focusing lens, or simultaneously adjust the positions of the focusing lens and the image sensor.
27. The barcode scanning device according to claim 24, characterized in that, The ranging unit includes at least one of a time-of-flight ranging module, an infrared ranging module, an ultrasonic ranging module, a laser triangulation ranging module, a structured light ranging module, or a binocular ranging module.
Citation Information
Patent Citations
Code scanning method and electronic equipment
CN116709017A
