Focusing method, device and storage medium
The focusing method for code reading cameras optimizes focus and reading accuracy by integrating image and code reading scores to adjust lens positions, addressing distance variations and improving industrial reading efficiency.
Patent Information
- Application Number
- JP2023580583
- Authority / Receiving Office
- JP · JP
- Patent Type
- Patents
- Current Assignee / Owner
- Priority Date
- 2021-07-08
- Filing Date
- 2022-07-07
- Publication Date
- 2026-01-21
- Estimated Expiration
- 2042-07-07
AI Technical Summary
Existing code reading cameras face challenges in maintaining optimal focus and reading accuracy due to varying distances from the work surface, leading to inefficiencies in industrial applications.
A focusing method that combines image definition ratings and code reading ratings at multiple lens positions to determine an optimal focus position, using a combination of coarse and fine search techniques to adjust the lens position for precise autofocusing.
Ensures high image clarity and successful code reading by determining the optimal lens position, enhancing the focusing effectiveness and reading success rate of code reading cameras in industrial scenarios.
Smart Images

Figure 0007803985000001 
Figure 0007803985000002 
Figure 0007803985000003
Abstract
Description
CROSS-REFERENCE TO RELATED APPLICATIONS
[0001] This application claims priority from a Chinese patent application bearing application number 202110771982.4 and entitled "Focusing method, apparatus and storage medium," filed with the State Intellectual Property Office of the People's Republic of China on July 8, 2021, the entire contents of which are incorporated herein by reference. [Technical Field]
[0002] This application relates to the field of image acquisition technology, and in particular to focusing methods, devices and storage media. [Background technology]
[0003] Currently, code reading cameras for reading two-dimensional codes and barcodes are widely used in industrial scenarios such as delivery and logistics. When using a code reading camera to read a code, the distance from the code reading camera to the work surface is constantly changing. In this case, an automatic focusing method is usually used to quickly focus the code reading camera on the work surface.
[0004] In a related technology, during autofocusing of a code reading camera, each time the lens of the code reading camera moves to a certain position, one frame of image is captured at that position. Then, an image definition rating for the captured image is calculated using the image autocorrelation method or the image high frequency component method. After obtaining image definition ratings for multiple positions of the lens of the code reading camera in this way, the position with the highest image definition rating is determined to be the optimal position for the lens, and the lens is then driven to move to that optimal position, thereby performing autofocusing. Summary of the Invention
[0005] The present invention provides a focusing method, device, and storage medium that can ensure the resolution of a code reading camera after focusing and ensure the success rate of code reading after focusing.
[0006] In one embodiment, obtaining an image definition rating and a code reading rating at a plurality of positions of a lens of a code reading camera, the code reading rating representing a success rate of code reading by the code reading camera; determining an optimal position for the lens based on the image definition ratings and the code reading ratings at the plurality of positions; and performing focusing based on the optimum position of the lens.
[0007] In one possible embodiment, determining an optimal position for the lens based on image definition ratings and code reading ratings at the plurality of positions comprises: determining at least one coarse position of the lens from the plurality of positions based on image definition ratings at the plurality of positions; determining an optimal position for the lens based on at least one general position of the lens and code reading scores at the plurality of positions; and performing focusing based on the optimum position of the lens.
[0008] In one possible embodiment, obtaining image definition ratings and code reading ratings at a plurality of positions of the lens of the code reading camera comprises: obtaining an image definition rating and a code reading rating at a search starting point of the lens, the search starting point being a start point or an end point of a stroke of the lens, the start point of the lens stroke being a position point at which the vertical distance between the lens and the target surface of the object to be code read is maximum, and the end point of the lens stroke being a position point at which the vertical distance between the lens and the target surface is minimum; controlling the lens to move from the search starting point along a specified search direction by a specified search step width, wherein if the search starting point is the starting point of a stroke on the lens, the specified search direction is the direction from the starting point of the stroke to the end point of the stroke, and if the search starting point is the end point of the stroke on the lens, the specified search direction is the direction from the end point of the stroke on the lens to the starting point of the stroke; and each time the lens moves by the specified search step width, obtaining an image definition score and a code reading score after the lens has moved.
[0009] In one possible embodiment, determining at least one coarse position of the lens from the plurality of positions based on image definition ratings at the plurality of positions comprises: During the process of the lens moving along the specified search direction, the acquired multiple image definition ratings tend to change from increasing to decreasing as the lens moves, and when a rate of decrease of the most recently acquired image definition rating relative to the maximum value of the multiple image definition ratings reaches a first threshold, it is determined whether or not the code reading rating at a first position corresponding to the maximum value of the multiple image definition ratings is greater than a second threshold; and if the code reading score at the first location is greater than the second threshold, determining the first location as a coarse location for the lens.
[0010] In one possible embodiment, determining at least one coarse position of the lens from the plurality of positions based on image definition ratings at the plurality of positions comprises: plotting a curve of the relationship between the plurality of locations and the image definition ratings at the plurality of locations; obtaining at least one peak image definition score value from said relationship curve; determining a second location from the at least one location corresponding to a peak value of the at least one image definition rating, the second location having a corresponding code reading rating greater than a second threshold; and determining the determined second position as the at least one coarse position of the lens.
[0011] In one possible embodiment, determining an optimal position of the lens based on at least one general position of the lens and code reading scores at the plurality of positions comprises: determining a candidate search interval corresponding to each of the rough positions, the candidate search interval being a lens position interval centered on the corresponding rough position; determining a local maximum value of the code reading score within each candidate search section from among the code reading scores corresponding to each position included in each candidate search section; determining an optimal position for the lens based on a local maximum of code reading scores within each candidate search interval.
[0012] In one possible embodiment, determining the optimal position of the lens based on a local maximum of code reading scores within each candidate search interval comprises: if there is one candidate search section and one position within the candidate search section that corresponds to the local maximum value of the code reading score, determining the position within the candidate search section that corresponds to the local maximum value of the code reading score as the optimal position of the lens; when there is one candidate search section and a plurality of positions corresponding to the local maximum values of the code reading score within the candidate search section, selecting a third position that is closest to a rough position corresponding to the candidate search section from the plurality of positions corresponding to the local maximum values of the code reading score within the candidate search section, and setting the third position as the optimum position of the lens; If there are multiple candidate search sections, the maximum value among the local maximum values of the code reading scores in the multiple candidate search sections is set as a global maximum value, and if there is only one position corresponding to the global maximum, the position corresponding to the global maximum is set as the optimal position of the lens, and if there are multiple positions corresponding to the global maximum, the distance between each of the multiple positions corresponding to the global maximum and a rough position corresponding to the candidate search section in which the lens is located is determined, and the optimal position of the lens is set as the position at which the distance between the position and the rough position corresponding to the candidate search section in which the lens is located is the smallest.
[0013] In one possible embodiment, performing focusing based on the optimal position of the lens comprises: determining a focus movement direction and movement distance of the lens based on the optimal position of the lens and the current position of the lens; and driving the lens to move it to an optimum position based on the focusing movement direction and movement distance of the lens, thereby achieving focusing.
[0014] In another aspect, an acquisition module for acquiring an image definition score and a code reading score at a plurality of positions of a lens of a code reading camera, the code reading score representing a success rate of code reading by the code reading camera; a determination module for determining an optimal position for the lens based on the image definition scores and the code reading scores at the plurality of positions; a focusing module for performing focusing based on the optimum position of the lens.
[0015] In one possible embodiment, the determination module comprises: a first determination module that determines at least one coarse position of the lens from the plurality of positions based on image definition ratings at the plurality of positions; and a second determination module that determines an optimal position for the lens based on at least one coarse position of the lens and code reading scores at the plurality of positions.
[0016] In one possible embodiment, the acquisition module mainly comprises: obtaining an image definition rating and a code reading rating at a search starting point of the lens, the search starting point being a start point or an end point of a stroke of the lens, the start point of the lens stroke being a position point at which the vertical distance between the lens and the target surface of the object to be code read is maximum, and the end point of the lens stroke being a position point at which the vertical distance between the lens and the target surface is minimum; controlling the lens to move from the search starting point along a specified search direction by a specified search step width, wherein if the search starting point is the starting point of a stroke on the lens, the specified search direction is the direction from the starting point of the stroke to the end point of the stroke, and if the search starting point is the end point of the stroke on the lens, the specified search direction is the direction from the end point of the stroke on the lens to the starting point of the stroke; Each time the lens moves by the specified search step width, an image definition score and a code reading score are obtained after the lens has moved.
[0017] In one possible embodiment, the first determination module mainly comprises: During the process of the lens moving along the specified search direction, the acquired multiple image definition ratings tend to change from increasing to decreasing as the lens moves, and when a rate of decrease of the most recently acquired image definition rating relative to the maximum value of the multiple image definition ratings reaches a first threshold, it is determined whether or not the code reading rating at a first position corresponding to the maximum value of the multiple image definition ratings is greater than a second threshold; and if the code reading score at the first location is greater than the second threshold, determining the first location as the coarse location of the lens.
[0018] In one possible embodiment, the first determination module mainly comprises: plotting a curve of the relationship between the plurality of locations and the image definition ratings at the plurality of locations; obtaining at least one peak image definition score value from said relationship curve; determining a second location from the at least one location corresponding to a peak value of the at least one image definition rating, the second location having a corresponding code reading rating greater than a second threshold; and determining the determined second position as a coarse position of at least one of the lenses.
[0019] In one possible embodiment, the second determination module mainly comprises: determining a candidate search interval corresponding to each of the rough positions, the candidate search interval being a lens position interval centered on the corresponding rough position; determining a local maximum value of the code reading score within each candidate search section from among the code reading scores corresponding to each position included in each candidate search section; and determining an optimal position for the lens based on the local maximum of the code reading score within each candidate search interval.
[0020] In one possible embodiment, the second determination module mainly comprises: if there is one candidate search section and one position within the candidate search section that corresponds to the local maximum value of the code reading score, determining the position within the candidate search section that corresponds to the local maximum value of the code reading score as the optimal position of the lens; when there is one candidate search section and a plurality of positions corresponding to the local maximum values of the code reading score within the candidate search section, selecting a third position that is closest to a rough position corresponding to the candidate search section from the plurality of positions corresponding to the local maximum values of the code reading score within the candidate search section, and setting the third position as the optimum position of the lens; If there are multiple candidate search sections, the maximum value among the local maximum values of the code reading scores within the multiple candidate search sections is taken as the global maximum value, and if there is one position corresponding to the global maximum, the position corresponding to the global maximum is taken as the optimal position of the lens, and if there are multiple positions corresponding to the global maximum, the distance between each of the multiple positions corresponding to the global maximum and a rough position corresponding to the candidate search section in which the lens itself is located is determined, and the position at which the distance from the rough position corresponding to the candidate search section in which the lens itself is located is the smallest is taken as the optimal position of the lens.
[0021] In one possible embodiment, the focusing module mainly comprises: determining a focus movement direction and movement distance of the lens based on the optimal position of the lens and the current position of the lens; Based on the focusing movement direction and movement distance of the lens, the lens is driven to move to an optimum position for focusing.
[0022] In another aspect, there is provided a focusing device including a control unit, a motor, a lens, and a moving mechanism, the moving mechanism moves the lens in a direction perpendicular to the lens surface of the lens, The control unit is connected to the motor, and the control unit controls the motor by executing any of the methods described above to drive the moving mechanism and move the lens to perform focusing, thereby providing a focusing device.
[0023] In another aspect, there is provided a computer device including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other via the communication bus, the memory is for storing a computer program, and the processor is for executing the program stored in the memory to implement the steps of the focusing method described above.
[0024] In another aspect, a computer-readable storage medium is provided having a computer program recorded thereon, the computer program implementing the steps of the focusing method described above when executed by a processor.
[0025] In another aspect, there is provided a computer program product comprising instructions which, when executed on a computer, cause the computer to perform the steps of the focusing method described above. [Effects of the Invention]
[0026] The technical solution provided by this application has at least the following beneficial effects: In this embodiment, automatic focusing is performed based on the image definition score and code reading score at different positions of the lens of the code reading camera. Because the code reading score can represent the code reading success rate of the code reading camera, this embodiment actually combines the image definition and code reading effect of the code reading camera to evaluate the focusing effect at different positions of the lens, thereby determining the optimal position of the lens and performing automatic focusing. In this way, not only can the image definition captured by the code reading camera after focusing be ensured, but also the code reading success rate of the code reading camera after focusing. [Brief explanation of the drawings]
[0027] In order to more clearly explain the technical solutions of the embodiments of the present application and the prior art, the drawings necessary for the following embodiments and the prior art will be briefly described. Of course, the drawings described below are only a part of the embodiments of the present application, and those skilled in the art can derive other drawings based on these drawings without any creative work. [Figure 1] FIG. 1 is a system architecture diagram of the focusing method provided by the present embodiment. [Figure 2] FIG. 2 is a schematic diagram of the configuration of a focusing device provided in this embodiment. [Figure 3a] FIG. 3a is a flowchart of a focusing method provided by an embodiment of the present invention. [Figure 3b] FIG. 3b is a flowchart of another focusing method provided by an embodiment of the present invention. [Figure 4] FIG. 4 is a graph of image definition scores provided by the present examples. [Figure 5a] FIG. 5a is a schematic diagram of another focusing device provided by the present embodiment. [Figure 5b] FIG. 5b is a schematic diagram of the configuration of yet another focusing device provided by the present embodiment. [Figure 6a] FIG. 6a is a schematic diagram of the configuration of a computer device provided by an embodiment of the present application. [Figure 6b] FIG. 6b is a schematic diagram of another computer device provided by the present embodiment. DETAILED DESCRIPTION OF THE INVENTION
[0028] In order to clarify the objectives, technical solutions and advantages of the embodiments of the present application, the embodiments of the present application will be described in more detail below by way of examples with reference to the drawings. Of course, the described embodiments are only a part of the embodiments of the present application, and are not all of the embodiments. Based on the embodiments of the present application, all other embodiments that can be obtained by a person skilled in the art without creative work fall within the scope of protection of the present application.
[0029] Before describing the focusing method provided by the present embodiment in detail, an application scenario of the present embodiment will be described.
[0030] The focusing method provided by the present embodiment can be applied to industrial scenarios involving reading two-dimensional codes or barcodes. For example, in a logistics transfer center, a code reading camera is installed on a gantry above an automated baggage conveyor, and the code reading camera reads the two-dimensional codes or barcodes on the top surface of the baggage to sort it. Because different bags have different heights, the distance from the code reading camera to the top surface of each baggage varies. In this case, the focusing method provided by the present embodiment can adjust the distance between the lens of the code reading camera and the top surface of the baggage, thereby achieving rapid auto-focusing. For example, a code reading camera is installed on a factory production line, and the code reading camera reads the two-dimensional codes or barcodes of products on the production line to input product information data. In this case, the distance from the code reading camera to the surface on which the product's two-dimensional code or barcode is located may change due to structural adjustments to the production line or re-installation of the code reading camera. In this case, the focusing method provided by the present embodiment can adjust the distance between the lens of the code reading camera and the top surface of the baggage, thereby achieving rapid auto-focusing.
[0031] For example, in the application scenario described above, after the code reading camera is positioned, a stationary reference object is first placed below the lens of the code reading camera, and the code reading camera can be focused using the reference object. After the code reading camera is focused, the code reading camera is ready for use. During subsequent use of the code reading camera, the object to be read passes below the lens of the code reading camera. If there is a large difference in altitude between the object to be read and the reference object used for focusing, the code reading camera can be refocused. In this case, the focusing method provided by the present embodiment can achieve rapid autofocusing.
[0032] The above are only two possible application scenarios provided by the present embodiment, and the present embodiment may also be applied to other industrial code reading scenarios that require autofocus, but the present embodiment is not limited thereto.
[0033] Next, a system architecture according to the embodiment of the present invention will be described.
[0034] 1 is an architecture diagram of an image capturing system provided by an embodiment of the present application. As shown in FIG. 1, the image capturing system includes a code reading camera 101, a conveyor 102, and an object 103 on the conveyor 102 whose code is to be read.
[0035] The code reading camera 101 may be mounted on a gantry above the conveyor 102. The lens of the code reading camera 101 faces the target surface of the object 103 on the conveyor 102 whose code is to be read. The target surface is the plane on which the two-dimensional code or barcode is located. In the delivery logistics industry, the target surface is usually the top surface of the package when it is placed on the conveyor 102, i.e., the surface of the package that faces away from the conveyor. Of course, in other possible scenarios, the target surface may be the side surface of the object 103 whose code is to be read, but the present embodiment is not limited thereto.
[0036] In this embodiment, the code reading camera 101 may capture an image when detecting a trigger signal. The code reading camera 101 first adjusts the position of the lens by moving the lens. In this application, adjusting the lens position refers to adjusting the position of the entire lens or adjusting the position of a local portion of the lens, and the focal length of the code reading camera should be changed along with the adjustment of the lens position. For example, in one possible embodiment, if the lens shape is maintained, the center of gravity of the lens may be adjusted. In another possible embodiment, if the lens is a T-Lens (variable focus) lens or a liquid lens, the relative positions of each point within the lens may be adjusted, that is, the shape of the lens may be changed to adjust the center of gravity of the lens.
[0037] For convenience, the following description focuses on adjusting the center of gravity of the lens. However, the principle behind changing the shape of the lens is exactly the same, and therefore a description thereof will be omitted. Since the distance between the lens and the target surface of the object to be scanned changes as the center of gravity changes, adjusting the center of gravity of the lens corresponds to adjusting the distance between the lens and the target surface of the object to be scanned. Each time the distance is adjusted, the code-reading camera captures an image of the object to be scanned. The captured image is used to calculate image definition ratings and code reading ratings for multiple lens positions. Furthermore, the optimal lens position can be determined from the multiple lens positions based on the image definition ratings and code reading ratings. In this specification, a single image capture may refer to the capture of one image, but it may also refer to the capture of multiple images. When a single image is captured, the image definition rating indicates the clarity of the image, and the code reading rating indicates the quality of the 2D code and barcode in the image. When multiple images are captured, the image definition rating represents the overall clarity of the multiple images, while the code reading rating represents the overall quality of the 2D code and barcode in the multiple images. For example, the resolution of each of the multiple images may be determined to obtain an image definition rating representing the average clarity of all images, or the clearest image may be determined from the multiple images to generate an image definition rating representing the clarity of the clearest image. The code reading camera then controls the lens with a motor to move to the optimal position and focus. After focusing is complete, the code reading camera 101 captures an image of the 2D code or barcode on the target surface of the object 103 to be read and reads the 2D code or barcode.
[0038] In one possible embodiment, Fig. 2 is a schematic diagram showing a focusing device 200 applied to a code reading camera. As shown in Fig. 2, the focusing device 200 includes a control unit 201, a motor 202, a lens 203, and a moving mechanism 204.
[0039] The control unit 201 is connected to a motor 202. As shown in FIG. 2, the lens 203 may be located on a moving mechanism 204. Alternatively, the lens 203 may be connected to the moving mechanism 204 (not shown in FIG. 2). The motor 202 is connected to the moving mechanism 204. In this manner, the control unit 201 can control the motor 202 to drive the moving mechanism 204 to move. The movement of the moving mechanism 204 moves the lens 203. The moving mechanism 204 moves the lens 203 in a direction perpendicular to the lens surface of the lens 203, i.e., in the direction of the optical axis of the lens surface (hereinafter referred to as the lens surface axis), and the stroke of the moving mechanism 204 is constant. In this manner, the moving mechanism 204 also moves the lens 203 along an axis perpendicular to its lens surface, and the stroke of the lens 203 is also constant.
[0040] In this embodiment, the control unit 201 first controls the motor 202 to drive the moving mechanism 204 to continue moving the lens 203 along a specified search direction at a specified search step width, thereby searching for a rough position of the lens 203. The specified search step width may be a fixed step width or a variable step width. For example, in one possible embodiment, the search step width is fixed to a step width of 1 unit, and in another possible embodiment, the search step width is initially set to a step width of 2 units, but decreases as the image definition rating improves.
[0041] After obtaining the rough position of the lens 203, the control unit 201 determines the optimum position of the lens 203 based on the code reading score at each position of the lens 203 determined in the rough search process, and calculates the movement distance and focusing movement direction from the current position of the lens 203 to the optimum position. Then, the control unit 201 controls the motor 202 to drive the movement mechanism 204 to move the lens 203 by the movement distance along the focusing movement direction, and achieves focusing by reaching the optimum position.
[0042] In addition to the focusing device 200, the code reading camera may also include other assemblies required for a camera, such as an image sensor, a filter assembly, a light compensation device, etc., but a description thereof will be omitted in this embodiment.
[0043] Next, the focusing method provided by the embodiment of the present invention will be described in detail.
[0044] 3 is a flowchart of a focusing method provided in an embodiment of the present application, which is applied to a code reading camera, but can also be applied to an electronic device that controls and focuses the code reading camera independently of the code reading camera. For example, it is applied to the control unit of the code reading camera shown in FIG. 2. As shown in FIG. 3, the method includes the following steps:
[0045] Step 301: Obtain image definition scores and code reading scores at multiple positions of the lens of a code reading camera, and the code reading scores are for representing the success rate of code reading by the code reading camera.
[0046] It is understood that the higher the quality of the two-dimensional code or barcode in the image captured by the code reading camera, the higher the success rate of code reading by the code reading camera, and therefore the code reading rating can represent the success rate of code reading by the code reading camera.
[0047] In this embodiment, after the code reading camera starts to focus, the image definition score and the code reading score are first obtained at the search start point of the lens. The so-called search start point means that the lens starts to move from the search start point after starting to focus.
[0048] For example, the search starting point may be the starting point of a lens stroke or the end point of a lens stroke of the code reading camera. The starting point of the lens stroke is the position where the vertical distance between the lens and the target surface of the object to be read is maximum, and the end point of the lens stroke is the position where the vertical distance between the lens and the target surface is minimum. In other words, when the movement mechanism of the code reading camera moves the lens in a direction perpendicular to the lens surface away from the target surface, the distance from the lens to the target surface becomes maximum when the lens reaches a point where it cannot move any further. The position where the lens exists at this time corresponds to the starting point of the lens stroke. Correspondingly, when the movement mechanism of the code reading camera moves the lens in a direction perpendicular to the lens surface toward the target surface, the distance from the lens to the target surface becomes minimum when the lens reaches a point where it cannot move any further. The position where the lens exists at this time corresponds to the end point of the lens stroke. Then, for the convenience of focusing the code reading camera, in one possible embodiment, the code reading camera adjusts the position of the lens to the start point of the stroke or the end point of the stroke beforehand every time autofocusing is required.
[0049] The code reading camera captures an image of the lens at the search starting point, and calculates an image definition score for the lens at that position using the captured image at that position through image autocorrelation, image high frequency component, or other methods for image definition score. A higher image definition score indicates a higher level of clarity of the captured image when the lens captures an image at that position.
[0050] At the same time, the code reading camera can calculate the code reading score of the barcode in the image captured at that search starting point according to the ISO 15416 standard, or the code reading score of the 2D code in the image captured at that search starting point according to the ISO 15415 standard. A higher code reading score indicates a better code reading effect when reading the code on the image at that position of the lens.
[0051] After obtaining the image definition score and code reading score at the search starting point, the code reading camera controls the motor to drive the lens to continue moving from the search starting point. Each time the lens moves to a certain position, the code reading camera calculates the image definition score and code reading score at that position of the lens.
[0052] For example, the code reading camera controls a motor to drive the lens to move from the search starting point along a specified search direction by a specified search step width. In this way, one image definition rating and one code reading rating are obtained each time the lens moves by the specified search step width. If the search starting point is the start point of a lens stroke, the specified search direction is the direction from the start point of the lens stroke to the end point of the stroke, and if the search starting point is the end point of the lens stroke, the specified search direction is the direction from the end point of the lens stroke to the start point of the stroke.
[0053] As can be seen from the above, in a code reading camera, the lens is located on or connected to a moving mechanism, and the lens can be moved by moving the moving mechanism. The moving mechanism moves in a direction perpendicular to the lens surface, and the movable stroke of the moving mechanism is constant. Thus, the lens also moves in a direction perpendicular to the lens surface by the moving mechanism, and the lens stroke is also constant. Here, the lens can move by a specified search step width during movement, and the specified search step width corresponds to the distance of one movement of the lens. In the present embodiment, the specified search step width may be artificially set. The smaller the specified search step width, the higher the search accuracy, but the larger the specified search step width, the higher the search efficiency.
[0054] In one possible embodiment, when the code reading camera starts to focus, the lens may not be located at the start of the stroke or the end of the stroke, in which case the code reading camera can control the lens to move from its current position to the start of the stroke or the end of the stroke of the lens, and move from the start of the stroke or the end of the stroke of the lens along the specified search direction with the specified search step width according to the method described above.
[0055] During the movement of the lens, each time the lens moves to a certain position, the code reading camera captures an image at that position, and the image definition rating of the lens at that position can be calculated using the captured image at that position using the image autocorrelation method, the image high frequency component method, or other methods for calculating the image definition rating.
[0056] At the same time, the code reading camera can calculate the code reading score of the barcode in the image captured at that location based on the ISO15416 standard, or the code reading score of the two-dimensional code in the image captured at that location based on the ISO15415 standard.
[0057] In some possible scenarios, after the lens moves to a certain position, there may be no 2D code or barcode in the field of view of the code reading camera at that position, in which case the code reading score calculated by the code reading camera based on the image captured at that position will be 0 or another small value.
[0058] Step S302: Determine an optimal position for the lens based on the image definition scores and code reading scores at multiple positions.
[0059] The method for determining the optimum position varies depending on the application scenario, but the image definition rating and code reading rating at the optimum position should be as high as possible, and the image definition rating at any other position should be lower than the image definition rating at the optimum position, or the code reading rating should be lower than the code reading rating at the optimum position.
[0060] By way of example, in one possible embodiment, an overall rating for each location is determined based on the image definition ratings and code reading ratings at multiple locations, and the location with the highest overall rating is determined as the optimum position for the lens.
[0061] The overall score for each location is obtained by weighting the image definition score and code reading score at that location, and when performing the weighting, the weight of the image definition score and the weight of the code reading score may be set by the user based on actual needs and / or experience.
[0062] In another possible embodiment, step 302 includes step 3021 and step 3022, as shown in FIG. 3b.
[0063] Step 3021: Determine at least one coarse position of the lens from the plurality of positions based on the image definition ratings at the plurality of positions.
[0064] In one possible embodiment, as can be seen from the description of step 301 above, each time the lens moves once along the specified search direction by the specified search step width, the code reading camera may calculate the image definition rating and code reading rating after the lens has moved once. As a result, the code reading camera obtains one image definition rating for each position after the lens has moved while moving, i.e., the code reading camera determines once the tendency of all obtained image definition ratings to change as the lens moves. As the lens moves, the obtained image definition ratings tend to increase and then decrease. If the rate of decrease of the most recently obtained image definition rating relative to the maximum value of the obtained image definition ratings reaches a first threshold, the code reading camera further determines whether the code reading rating at the first position corresponding to the maximum value of the obtained image definition ratings is greater than a second threshold. If the code reading rating is greater than the second threshold, the code reading camera determines that the first position is the rough position of the lens.
[0065] Each time the lens moves to a certain position, the code reading camera acquires an image definition rating for that position. The code reading camera can plot a relationship curve between each acquired image definition rating and the corresponding position. If the image definition ratings on the relationship curve show a tendency to increase and then decrease, the code reading camera calculates the difference between the maximum value of the acquired image definition ratings and the image definition rating at the current position of the lens, and calculates the ratio of this difference to the maximum value of the multiple image definition ratings. This ratio represents a decrease. If the decrease ratio is greater than a first threshold, it is determined that the decrease ratio has reached the first threshold, and it is considered that the lens position at which image definition is at its highest is found. In this case, the code reading camera can further determine whether the code reading rating at the first position corresponding to the maximum value of the multiple image definition ratings is greater than a second threshold. If the code reading score at the first position is greater than the second threshold, it indicates that a two-dimensional code or a barcode is present in the field of view of the code reading camera when the lens is located at the first position, and the code reading camera can determine the optimal position of the lens based on the code reading score. In this case, the code reading camera can determine the first position as the rough position of the lens. In response, the code reading camera can stop moving the lens, i.e., stop searching for the rough position of the lens.
[0066] The first threshold is a predetermined percentage, which may be 20%, 40%, or other values, and is not limited to the present embodiment. The second threshold may be a predetermined value equal to or less than the minimum code reading score when a 2D code or barcode is present in the field of view of the code reading camera. For example, the second threshold may be a value of 0, 1, 2, etc., and is not limited to the present embodiment.
[0067] Of course, if the plotted relationship curve between the image definition rating and the lens position does not show a tendency for the image definition rating to increase and then decrease, or if it shows a tendency for the image definition rating to increase and then decrease but the rate of decrease between the image definition rating at the current position of the lens and the maximum value among the multiple image definition ratings obtained does not reach the first threshold, or if the code reading rating at the first position corresponding to the maximum value among the multiple image definition ratings obtained is less than the second threshold, the code reading camera can continue to drive and move the lens to obtain the image definition rating and code reading rating at the next position, and repeat the above judgment process.
[0068] In this way, in the above embodiment, even if the lens does not move to all positions along the specified search direction, the code reading camera may find a certain rough position, thus reducing the search time and improving the search efficiency.
[0069] In another possible embodiment, the code reading camera can determine at least one coarse position of the lens based on the image definition ratings obtained at all positions during the lens movement as the lens moves from the start of the stroke to the end of the movement, or as the lens moves from the end of the stroke to the start of the stroke.
[0070] Illustratively, in this embodiment, a relationship curve between a plurality of positions during the movement of the plot lens of the code reading camera and the image definition rating at the plurality of positions is plotted, at least one peak value of the image definition rating is obtained from the relationship curve, and from at least one position corresponding to the peak value of the at least one image definition rating, a second position at which the corresponding code reading rating is greater than a second threshold value is determined, and the determined second position can be set as at least one rough position of the lens.
[0071] The plot lens of the code reading camera may plot a relationship curve between the image definition rating at a plurality of positions acquired from the search start point to the search end point and the plurality of positions. In this way, the plotted relationship curve may have one or more peak points. In this case, the code reading camera acquires at least one peak value of the image definition rating by acquiring the peak value of the image definition rating at each peak point of the relationship curve.
[0072] The peak value of the image definition score may be determined from the relationship curve based on any peak detection algorithm, and is not limited to this application.
[0073] After obtaining at least one peak value of the image definition score, the code reading camera determines whether the code reading score at the position corresponding to each peak value of the image definition score is greater than a second threshold, and determines the position where the corresponding code reading score is greater than the second threshold as the second position. At this time, the determined second position may be one or more, and the code reading camera may determine the determined second position as at least one rough position.
[0074] Figure 4 is a curve diagram showing the relationship between multiple positions and image definition ratings at multiple positions in an embodiment of the present invention. As shown in Figure 4, the curve has three peak points, and the code reading camera can obtain the peak values at each peak point to obtain three peak image definition rating values S1, S2, and S3. The code reading camera then determines whether the code reading rating at the position corresponding to each peak value is greater than a second threshold. If the second threshold is 0, and the code reading ratings at position A corresponding to S1 and position C corresponding to S3 are both greater than 0, and the code reading rating at position B corresponding to S2 is equal to 0, the code reading camera will determine positions A and C as the rough positions of the lens.
[0075] In some possible situations, when determining whether the code reading scores at positions corresponding to the peak values of each image definition score are greater than the second threshold, it is possible that all of the code reading scores at positions corresponding to the peak values of each image definition score are less than or equal to the second threshold. As such, no positions where the code reading score is greater than the second threshold can be obtained, that is, the number of second positions is 0. In this case, the code reading camera obtains the maximum image definition score from at least one peak value of the image definition score, and determines the position corresponding to the maximum image definition score as the optimal position of the lens. Further, referring to the implementation method in step 304, the code reading camera can perform focusing based on the optimal position of the lens.
[0076] Step 3022: Determine an optimal position for the lens based on the code reading scores at least in one general position and in multiple positions of the lens.
[0077] After obtaining at least one coarse position of the lens, the code reading camera determines an optimal position of the lens by performing a fine search on at least one coarse position and other positions near the coarse position based on the obtained code reading scores.
[0078] For example, the code reading camera first determines a candidate search section corresponding to each of the rough positions, where the candidate search section is a lens position section centered on the corresponding rough position, and determines the local maximum value of the code reading score within each candidate search section from the code reading score corresponding to each position included in each candidate search section, and determines the optimal position of the lens based on the local maximum value of the code reading score within each candidate search section.
[0079] Taking one of the rough positions as an example, for convenience of explanation, this rough position will be referred to as the first rough position, and the code reading camera will configure a candidate search section corresponding to the first rough position by specifying a distance forward and a distance backward along the specified search direction with the first rough position as the center, where the specified distance is greater than the specified search step width.
[0080] For example, if the first rough position is S, then by moving forward by L and then backward by L along the specified search direction with the position S as the center, a candidate search section [SL, S+L] is constructed, where S is greater than L.
[0081] After determining a candidate search section corresponding to the first rough position, the code reading camera acquires code reading scores at each position of the lens movement included in the candidate search section and determines the maximum value from the acquired code reading scores, which corresponds to the local maximum value of the code reading scores within the candidate search section. Note that when there is one rough position, there is also one corresponding candidate search section. In this way, there is also one local maximum value of the code reading scores. Although there is one local maximum value of the code reading scores, there may be one or more positions corresponding to the local maximum value of the code reading scores. In other words, the code reading score at one position may be the local maximum value, or the code reading scores at multiple positions may all be the same and all may be the local maximum value of the code reading scores. Thus, if there is one candidate search section and one position within the candidate search section that corresponds to the local maximum value of the code reading score, the code reading camera can directly set the position corresponding to the local maximum value of the code reading score as the optimum position for the lens.If there is one candidate search section and multiple positions within the candidate search section that correspond to the local maximum value of the code reading score, the code reading camera can select a third position that is roughly closest to the candidate search section from the multiple positions within the candidate search section that correspond to the local maximum value of the code reading score, and set the third position as the optimum position for the lens.
[0082] When there are multiple coarse positions, there are multiple corresponding candidate search sections, and multiple local maxima of the obtained code reading scores. In this case, the code reading camera first determines the maximum of the local maxima of the code reading scores in the multiple candidate search sections to obtain the global maximum. At this time, there may be one or more positions corresponding to the global maximum. As a result, if there is one position corresponding to the global maximum, the position corresponding to the global maximum can be directly determined as the optimal position of the lens. If there are multiple positions corresponding to the global maximum, the distance between each position corresponding to the global maximum and the coarse position corresponding to the candidate search section in which the corresponding position is located can be determined, and the position with the shortest distance from the coarse position corresponding to the candidate search section in which the global maximum is located can be determined as the optimal position of the lens.
[0083] For example, suppose there are three positions corresponding to the global maximum, a, b, and c, where a is located in candidate search section U1 and the rough position corresponding to U1 is M, b is located in candidate search section U2 and the rough position corresponding to U2 is N, and c is located in candidate search section U3 and the rough position corresponding to U3 is Q. The code reading camera calculates the distance between a and M to obtain the first distance, calculates the distance between b and N to obtain the second distance, and calculates the distance between c and Q to obtain the third distance. The lengths of the first, second, and third distances are compared, and if the first distance is the smallest, a is determined to be the optimal position for the lens.
[0084] In some possible embodiments, in step 301, the code reading camera can obtain an image definition rating of the lens at the search starting point when the lens is located at the search starting point, and then, each time the lens of the code reading camera moves once by the specified search step width from the search starting point, the code reading camera can obtain an image definition rating at the position where the moved lens is located. For distinction, the specified search step width adopted here is referred to as the first search step width.
[0085] In this way, the code reading camera acquires one image definition rating at each position during lens movement, i.e., the tendency of all acquired image definition ratings to change with lens movement is determined once. As the lens moves, the acquired image definition ratings tend to increase and then decrease, and if the rate of decrease of the most recently acquired image definition rating relative to the maximum value among the acquired image definition ratings reaches a first threshold, the position corresponding to the maximum value among the acquired image definition ratings is determined to be the found rough position.
[0086] Alternatively, the code reading camera obtains at least one peak value of the image definition rating from among the image definition ratings at all positions obtained while moving from the start point of the lens stroke to the end point of the stroke, or while moving from the end point of the stroke to the start point of the stroke, by referring to the methods described in steps 3021 and 3022 above, and determines at least one position corresponding to the at least one peak value of the image definition rating as at least one rough position.
[0087] After obtaining at least one coarse position, the code reading camera can determine a candidate search zone corresponding to each coarse position by referring to the method described in this step. Then, for each candidate search zone corresponding to each coarse position, the code reading camera controls the lens to move from one end point in the candidate search zone to another end point in the candidate search zone by a second search step width, where the second search step width is the first search step width used in performing the coarse position search described above. After moving by the second search step width, the code reading camera can capture an image once and calculate a code reading score at the position where the lens has moved based on the captured image. In this way, the code reading camera may obtain code reading scores at multiple positions of the lens in each candidate search zone. Then, the code reading camera determines the local maximum value of the code reading score within each candidate search section based on the code reading score at multiple positions in each candidate search section, and further determines the optimal position of the lens based on the local maximum value of the code reading score within each candidate search section by referring to the method described in this step, which will not be repeated here.
[0088] Step 303: Focusing is performed based on the optimum position of the lens.
[0089] After determining the optimal position of the lens, the code reading camera calculates the distance difference between the current position of the lens and the optimal position of the lens to obtain the movement distance of the lens. At the same time, the code reading camera further determines whether the direction from the current position of the lens to the optimal position of the lens is the direction from the start point of the stroke to the end point of the stroke or the direction from the end point of the stroke to the start point of the stroke, and the determined direction is the subsequent movement direction of the lens.
[0090] After determining the distance and direction of movement of the lens, the code reading camera controls the motor to drive the lens to move the distance along the direction of movement, and reach the optimum position of the lens to focus.
[0091] In this embodiment, autofocusing is performed based on the image definition score and code reading score at different positions of the lens of the code reading camera. Because the code reading score can represent the code reading success rate of the code reading camera, this embodiment actually combines the image definition and code reading effect of the code reading camera and evaluates the focusing effect at different positions of the lens to determine the optimal lens position and then perform autofocusing. In this way, not only can the image definition captured by the code reading camera after focusing be ensured, but also the code reading success rate of the code reading camera after focusing be ensured.
[0092] In this embodiment, after finding the peak value of the image definition rating, at least one rough position is obtained by removing positions where there is no code reading rating from the positions corresponding to the peak value of the image definition rating. In this way, the at least one rough position obtained is a position where a 2D code or barcode is present in the field of view, avoiding the influence of the pseudo peak value of the image definition and improving the focusing success rate.
[0093] Next, a focusing device provided by the embodiment of the present invention will be described.
[0094] 5a is a schematic diagram of a focusing device 500 provided in an embodiment of the present application, which can be implemented as part or the whole of a code reading camera through software, hardware, or a combination of both. Referring to FIG. 5a, the device 500 includes an acquisition module 501, a determination module 502, and a focusing module 503.
[0095] the acquisition module 501 is for acquiring image definition scores and code reading scores at multiple positions of the lens of the code reading camera, the code reading scores representing the success rate of code reading by the code reading camera; a determining module 502 for determining an optimal position of the lens based on the image definition ratings at the plurality of positions; The focusing module 503 is for performing focusing based on the optimum position of the lens.
[0096] In one possible embodiment, as shown in FIG. 5b, the determination module 502: a first determining module 5021 for determining at least one coarse position of the lens from the plurality of positions based on the image definition ratings at the plurality of positions; and a second determination module 5022 for determining an optimal position of the lens based on the code reading scores at least one general position and a plurality of positions of the lens.
[0097] In one possible embodiment, the acquisition module 501 mainly includes: Obtaining an image definition rating and a code reading rating at a search starting point of the lens, the search starting point being the start point or end point of the lens stroke, the start point of the lens stroke being the position where the vertical distance between the lens and the target surface of the object to be code read is maximum, and the end point of the lens stroke being the position where the vertical distance between the lens and the target surface is minimum; controlling the lens to move from a search starting point along a specified search direction by a specified search step width, wherein if the search starting point is the start point of a lens stroke, the specified search direction is the direction from the start point of the lens stroke to the end point of the stroke, and if the search starting point is the end point of the lens stroke, the specified search direction is the direction from the end point of the lens stroke to the start point of the stroke; Each time the lens moves by a specified search step width, an image definition score and a code reading score are obtained after the lens has moved.
[0098] In one possible embodiment, the first determination module 5021 mainly: During the process of the lens moving along the specified search direction, the acquired multiple image definition ratings tend to increase and then decrease as the lens moves, and when the rate of decrease of the most recently acquired image definition rating relative to the maximum value of the multiple image definition ratings reaches a first threshold, it is determined whether the code reading rating at the first position corresponding to the maximum value of the multiple image definition ratings is greater than a second threshold; If the code reading score at the first location is greater than a second threshold, the first location is used as the coarse location of the lens.
[0099] In one possible embodiment, the first determination module 5021 mainly: Plotting a curve of the relationship between the plurality of locations and the image definition rating at the plurality of locations; obtaining at least one peak value of the image definition rating from the relationship curve; determining a second location from the at least one location corresponding to a peak value of the at least one image definition rating, the second location having a corresponding code reading rating greater than a second threshold; and determining the determined second position as the coarse position of at least one of the lenses.
[0100] In one possible embodiment, the second determination module 5022 mainly: determining a candidate search section corresponding to each of the rough positions, the candidate search section being a lens position section centered on the corresponding rough position; determining a local maximum value of the code reading score within each candidate search section from among the code reading scores corresponding to each position included in each candidate search section; and determining the optimum position of the lens based on the local maximum of the code reading score within each candidate search interval.
[0101] In one possible embodiment, the second determination module 5022 mainly: If there is one candidate search section and one position corresponding to the local maximum value of the code reading score within the candidate search section, determining the position corresponding to the local maximum value of the code reading score within the candidate search section as the optimal position of the lens; When there is one candidate search section and a plurality of positions corresponding to the local maximum value of the code reading score within the candidate search section, selecting a third position that has the closest rough positional distance corresponding to the candidate search section from the plurality of positions corresponding to the local maximum value of the code reading score within the candidate search section, and setting the third position as the optimum position of the lens; When there are multiple candidate search sections, the maximum value among the local maximum values of the code reading scores within the multiple candidate search sections is taken as the global maximum value, and when there is one position corresponding to the global maximum, the position corresponding to the global maximum is taken as the optimal position of the lens, and when there are multiple positions corresponding to the global maximum, the distance between each of the multiple positions corresponding to the global maximum and a rough position corresponding to the candidate search section in which the lens itself is located is determined, and the position at which the distance from the rough position corresponding to the candidate search section in which the lens itself is located is the smallest is taken as the optimal position of the lens.
[0102] In one possible embodiment, the focusing module 503 mainly includes: determining a focus movement direction and movement distance of the lens based on the optimum position of the lens and the current position of the lens; Based on the focusing movement direction and movement distance of the lens, the lens is driven to move to the optimum position for focusing.
[0103] In this embodiment, autofocusing is performed based on the image definition score and code reading score at different positions of the lens of the code reading camera. Because the code reading score can represent the code reading success rate of the code reading camera, this embodiment actually combines the image definition and code reading effect of the code reading camera to evaluate the focusing effect at different positions of the lens, thereby determining the optimal lens position for autofocusing. In this way, not only can the image definition captured by the code reading camera after focusing be ensured, but also the code reading success rate of the code reading camera after focusing be ensured.
[0104] Although the focusing device provided in the above embodiments is described by way of example with the division of each functional module when performing focusing, in actual application, the above functions can be distributed to be performed by different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to perform all or part of the above-described functions. Note that the device and focusing method embodiments provided in the above embodiments belong to the same technical concept, and the specific implementation steps thereof are to be referred to in the method embodiments, and will not be described again here.
[0105] 6a is a schematic diagram of a computer device provided in the present embodiment, and the code reading camera in the above embodiment may be realized by the computer device.
[0106] Typically, the computing device 600 includes a processor 601 and a memory 602 .
[0107] The processor 601 may include one or more processing cores, such as a 4-core processor or an 8-core processor. The processor 601 may be implemented in at least one hardware form, such as a DSP (Digital Signal Processing) or an FPGA (Field-Programmable Gate Array). The processor 601 may include a primary processor and a secondary processor. The primary processor, also called a CPU (Central Processing Unit), processes data in a wake-up state. The secondary processor is a low-power processor that processes data in a standby state. In some embodiments, the processor 601 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing content to be displayed on a display. In some embodiments, the processor 601 may further include an AI (Artificial Intelligence) processor, which processes computational operations related to machine learning. The control unit in the focusing device 200 shown in FIG.
[0108] The memory 602 may include one or more computer-readable storage media, which may be non-transitory. The memory 602 may further include high-speed random access memory, non-volatile memory, such as one or more magnetic disk storage devices or flash memory devices. In some embodiments, the non-transitory computer-readable storage media in the memory 602 is used to store at least one command that is executed by the processor 601 to implement the focusing method provided by the method embodiments herein.
[0109] 6b, the computing device 600 further includes a peripheral interface 603 and at least one peripheral device. The processor 601, the memory 602, and the peripheral interface 603 may be connected via a bus or signal lines. Any of the peripheral devices may be connected to the peripheral interface 603 via a bus, signal lines, or a circuit board. Specifically, the peripheral devices include at least one of an RF circuit 604, a display 605, a camera assembly 606, an audio circuit 607, a positioning assembly 608, and a power supply 609.
[0110] The peripheral interface 603 may be used to connect at least one peripheral device related to I / O (Input / Output) to the processor 601 and the memory 602. In some embodiments, the processor 601, the memory 602, and the peripheral interface 603 are integrated on the same circuit board. In some other embodiments, any one or two of the processor 601, the memory 602, and the peripheral interface 603 may be implemented on a single circuit board, and this embodiment is not limited thereto.
[0111] The RF circuitry 604 is for receiving and transmitting RF (Radio Frequency) signals, also referred to as electromagnetic signals. The RF circuitry 604 communicates with the electromagnetic signals via a communication network and other communication devices. The RF circuitry 604 converts electrical signals into electromagnetic signals and transmits them, or converts received electromagnetic signals into electrical signals. In one possible embodiment, the RF circuitry 604 includes an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a user identity module card, etc. The RF circuitry 604 communicates with other terminals via at least one wireless communication protocol. The wireless communication protocol may include, but is not limited to, a metropolitan area network, various generations of mobile communication networks (2G, 3G, 4G, and 5G), a wireless local area network, and / or a Wi-Fi (Wireless Fidelity) network. In some embodiments, the RF circuitry 604 may further include circuitry related to NFC (Near Field Communication), although the present application is not limited thereto.
[0112] The display 605 is used to display a user interface (UI). The UI may include graphics, text, icons, videos, and any combination thereof. If the display 605 is a touch display, the display 605 may further receive touch signals from or above the surface of the display 605. The touch signals may be input to the processor 601 as control signals for processing. The display 605 may then be used to provide virtual buttons and / or a virtual keyboard, also referred to as soft buttons and / or a soft keyboard. In some embodiments, the display 605 may be a single display mounted on the front panel of the computer device 600. In other embodiments, the display 605 may be two displays mounted on different surfaces of the computer device 600 or may be designed to be foldable. In other embodiments, the display 605 may be a flexible display mounted on a curved or foldable surface of the computer device 600. Furthermore, the display 605 may be mounted in a non-rectangular or irregular shape, i.e., an irregularly shaped display. The display 605 may be made of materials such as LCD (Liquid Crystal Display), OLED (Organic Light-Emitting Diode), and the like.
[0113] The camera assembly 606 is for capturing images or videos. The camera assembly 606 may include the focusing device 200 shown in FIG. 2 above. In addition, the camera assembly may further include an image sensor, a filter assembly, a light supplement device, etc. The image sensor is for generating and outputting an image signal through exposure. The filter assembly filters out a specific wavelength band from the visible light entering the camera assembly. The light supplement device supplements light during the exposure process of the image sensor.
[0114] The audio circuit 607 may include a microphone and a speaker. The microphone collects sound waves from the user or the environment, converts the sound waves into electrical signals, and inputs them to the processor 601 for processing or to the RF circuit 604, thereby enabling voice communication. For purposes of stereo pickup or noise reduction, multiple microphones may be installed at different locations on the computer device 600. The microphone may also be an array microphone or an omnidirectional microphone. The speaker converts electrical signals from the processor 601 or the RF circuit 604 into sound waves. The speaker may be a conventional thin-film speaker or a piezoelectric ceramic speaker. A piezoelectric ceramic speaker can convert electrical signals into sound waves that humans can hear, as well as into sound waves that humans cannot hear, making it suitable for distance measurement and other applications.
[0115] The positioning assembly 608 is for determining the current geographical location of the computing device 600 to realize navigation or LBS (Location Based Service), and may be a positioning assembly based on the American GPS (Global Positioning System), the Chinese Beidou system, or the European Union's Galileo system.
[0116] The power supply 609 is for supplying power to each assembly in the computing device 600. The power supply 609 may be an AC power supply, a DC power supply, a disposable battery, or a rechargeable battery. If the power supply 609 includes a rechargeable battery, the rechargeable battery allows for wired or wireless charging. The rechargeable battery is for enabling fast charging technology.
[0117] Those skilled in the art should understand that the configuration shown in FIG. 6b is not limiting of the computing device 600, which may include more or fewer assemblies than those shown, combine some assemblies, or employ different assembly arrangements.
[0118] The present embodiment further provides a non-transitory computer-readable storage medium, in which instructions, when executed by a processor of a computer device, enable the computer device to perform the focusing method provided in the above embodiment. For example, the computer-readable storage medium may be a ROM, RAM, CD-ROM, tape, floppy disk, optical data storage device, etc.
[0119] It should be noted that the computer-readable storage medium mentioned in the embodiments of the present application may be a non-volatile storage medium, in other words, a non-transitory storage medium.
[0120] The present embodiment further provides a computer program product including commands that, when executed on a computing device, cause the computing device to perform the focusing method provided by the above embodiment.
[0121] The above description is merely a preferred embodiment of the present application, and is not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present application should be included in the protection scope of the present application.
Claims
1. obtaining an image definition rating and a code reading rating at a plurality of positions of the lens of a code reading camera, the image definition rating representing the degree of clarity of the image, and the code reading rating being calculated for the code in the image and representing the quality of the code in the image; determining at least one coarse position of the lens from the plurality of positions based on image definition ratings at the plurality of positions; determining an optimal position for the lens based on code reading scores at least one general position of the lens and the plurality of positions; performing focusing based on the optimum position of the lens; Including, determining an optimal position of the lens based on at least one general position of the lens and code reading scores at the plurality of positions, determining a candidate search interval corresponding to each of the rough positions, the candidate search interval being a lens position interval centered on the corresponding rough position; determining a local maximum value of the code reading score within each candidate search interval from the code reading scores corresponding to each position included in each candidate search interval; determining an optimal position for the lens based on a local maximum of code reading scores within each candidate search interval; Including, determining an optimal position of the lens based on a local maximum of code reading scores within each of the candidate search intervals; if there is one candidate search section and one position within the candidate search section that corresponds to the local maximum value of the code reading score, determining the position within the candidate search section that corresponds to the local maximum value of the code reading score as the optimal position of the lens; when there is one candidate search section and a plurality of positions corresponding to the local maximum values of the code reading score within the candidate search section, selecting a third position from the plurality of positions corresponding to the local maximum values of the code reading score within the candidate search section that is closest to a rough position corresponding to the candidate search section, and setting the third position as the optimum position of the lens; If there are a plurality of candidate search sections, the maximum value among the local maximum values of the code reading scores in the plurality of candidate search sections is set as a global maximum value, if there is only one position corresponding to the global maximum, the position corresponding to the global maximum is set as the optimum position of the lens, if there are a plurality of positions corresponding to the global maximum, determining the distance between each of the plurality of positions corresponding to the global maximum and a rough position corresponding to the candidate search section in which the lens itself is located, and setting as the optimum position of the lens the position at which the distance between the position and the rough position corresponding to the candidate search section in which the lens itself is located is the smallest. A focusing method characterized by:
2. Obtaining image definition ratings and code reading ratings at a plurality of positions of the lens of the code reading camera includes: The lens acquires an image definition rating and a code reading rating at a search starting point, the search starting point being a start point or an end point of a stroke of the lens, the start point of the lens stroke being a position point at which the vertical distance between the lens and the target surface of the object to be code read is maximum, and the end point of the lens stroke being a position point at which the vertical distance between the lens and the target surface is minimum; controlling the lens to move from the search starting point along a specified search direction by a specified search step width, wherein if the search starting point is the starting point of a stroke on the lens, the specified search direction is the direction from the starting point of the stroke to the end point of the stroke, and if the search starting point is the end point of the stroke on the lens, the specified search direction is the direction from the end point of the stroke on the lens to the starting point of the stroke; each time the lens moves by the specified search step width, an image definition rating and a code reading rating are obtained after the lens has moved; 2. The method of claim 1, comprising:
3. Determining at least one coarse position of the lens from the plurality of positions based on image definition ratings at the plurality of positions includes: During the process of the lens moving along the specified search direction, the acquired multiple image definition ratings tend to change from increasing to decreasing as the lens moves, and when a rate of decrease of the most recently acquired image definition rating relative to the maximum value of the multiple image definition ratings reaches a first threshold, it is determined whether or not the code reading rating at a first position corresponding to the maximum value of the multiple image definition ratings is greater than a second threshold; and if the code reading score at the first location is greater than the second threshold, determining the first location as the coarse location of the lens.
3. The method of claim 2.
4. Determining at least one coarse position of the lens from the plurality of positions based on image definition ratings at the plurality of positions includes: plotting a curve of the relationship between the plurality of locations and the image definition ratings at the plurality of locations; obtaining at least one peak value of image definition rating from said relationship curve; determining a second location from the at least one location corresponding to a peak value of the at least one image definition score, the second location having a corresponding code reading score greater than a second threshold; and determining the determined second position as at least one coarse position of the lens.
2. The method of claim 1 .
5. The focusing based on the optimum position of the lens is determining a focus movement direction and movement distance of the lens based on the optimal position of the lens and the current position of the lens; driving the lens to move it to an optimum position based on the focusing movement direction and movement distance of the lens, and focusing; 2. The method of claim 1, comprising:
6. an acquisition module for acquiring an image definition score and a code reading score at a plurality of positions of the lens of the code reading camera, the image definition score representing the degree of clarity of the image, and the code reading score being calculated for the code in the image and representing the quality of the code in the image; a determination module for determining an optimal position for the lens based on the image definition ratings at the plurality of positions; a focusing module for performing focusing based on the optimum position of the lens; The determination module: a first determination module for determining at least one coarse position of the lens from the plurality of positions based on image definition ratings at the plurality of positions; a second determination module for determining an optimal position of the lens based on at least one general position of the lens and code reading scores at the plurality of positions; the acquisition module is used to acquire an image definition rating and a code reading rating at a search starting point of the lens, the search starting point being a start point or an end point of a stroke of the lens, the start point of the lens stroke being a position where a vertical distance between the lens and a target surface of an object to be read a code is maximum, and the end point of the lens stroke being a position where a vertical distance between the lens and the target surface is minimum; control the lens to move from the search starting point along a specified search direction by a specified search step width, where if the search starting point is the start point of the lens stroke, the specified search direction is a direction from the start point of the lens stroke to the end point of the stroke, and if the search starting point is the end point of the lens stroke, the specified search direction is a direction from the end point of the lens stroke to the start point of the stroke; and acquire an image definition rating and a code reading rating after the lens has moved each time the lens moves by the specified search step width; the first determination module is used to determine whether a code reading score at a first position corresponding to a maximum value among the plurality of image definition scores is greater than a second threshold value when, during a process in which the lens moves along the specified search direction, the acquired plurality of image definition scores tend to change from an increase to a decrease as the lens moves, and a rate of decrease of the most recently acquired image definition score relative to a maximum value among the plurality of image definition scores reaches a first threshold value; and, when the code reading score at the first position is greater than the second threshold value, determine the first position as a rough position of the lens; or the first determination module is used for plotting a relationship curve between the plurality of positions and image definition ratings at the plurality of positions; obtaining at least one peak value of the image definition rating from the relationship curve of the image definition rating; determining a second position from the at least one position corresponding to the peak value of the at least one image definition rating, where the corresponding code reading rating is greater than a second threshold; and determining the determined second position as at least one rough position of the lens; the second determination module is used for determining candidate search intervals corresponding to each of the rough positions, each of the candidate search intervals being a lens position interval centered on the corresponding rough position; determining a local maximum value of code reading scores in each candidate search interval from among code reading scores corresponding to each position included in each candidate search interval; and determining an optimal position of the lens based on the determined local maximum value of code reading scores; The second determination module further determines, when there is one candidate search section and there is one position within the candidate search section that corresponds to the local maximum value of the code reading score, the position within the candidate search section that corresponds to the local maximum value of the code reading score as the optimum position of the lens; and, when there is one candidate search section and there are multiple positions within the candidate search section that correspond to the local maximum value of the code reading score, selects a third position that is closest to a rough position corresponding to the candidate search section from the multiple positions within the candidate search section that correspond to the local maximum value of the code reading score, and determines the third position as the optimum position of the lens. and if there are a plurality of candidate search sections, determining the maximum value among the local maxima of the code reading scores in the plurality of candidate search sections as a global maximum value, and if there is only one position corresponding to the global maximum, determining the position corresponding to the global maximum as the optimum position of the lens, and if there are a plurality of positions corresponding to the global maximum, determining the distance between each of the plurality of positions corresponding to the global maximum and a rough position corresponding to the candidate search section in which the lens itself is located, and determining the position at which the distance from the rough position corresponding to the candidate search section in which the lens itself is located is the smallest, The focusing device is characterized in that the focusing module is used to determine a focusing movement direction and movement distance of the lens based on the optimal position of the lens and the current position of the lens, and to drive the lens to move it to the optimal position of the lens and focus it based on the focusing movement direction and movement distance of the lens.
7. A focusing device including a control unit, a motor, a lens, and a moving mechanism, the moving mechanism is for moving the lens in a direction perpendicular to the lens surface of the lens, The control unit is connected to the motor, and the control unit controls the motor to drive the moving mechanism and move the lens to perform focusing by executing a method described in any one of claims 1 to 5.
8. A computer-readable storage medium having a computer program recorded thereon, the computer-readable storage medium being adapted to implement the steps of the method according to any one of claims 1 to 5 when executed by a processor.
Citation Information
Patent Citations
Automatic focusing system
JP1991050513A
Digital camera
JP2007334242A
Camera system
JP2009175279A
Bar code reader and program
JP2012123813A
Optical information reader
JP2018136860A