Background
The conventional Chip On Board (COB) camera module includes a circuit Board (or substrate), an image capturing die, a lens mount and an optical lens, wherein the image capturing die is disposed On the circuit Board, the lens mount is disposed On the circuit Board at a position corresponding to the image capturing die, and the optical lens is movably disposed On the lens mount, so that the optical lens can move On the lens mount to adjust a distance between the optical lens and the image capturing die, thereby achieving the purpose of adjusting a focusing position of the image capturing die in an image capturing.
Referring to fig. 1 or 2, when the optical lens performs focal length adjustment, the photographing module is usually started to capture an image, and then the human eye determines whether the captured image is clear or blurred, if so, the distance between the optical lens and the image capturing die is adjusted until the human eye determines that the image is clear.
But the resolution of the photography module is higher and higher, the manual focusing method is likely to be misjudged or the consistency of the focal length of the photography module is error, and the other optical lens focusing method is a defocusing depth method (DFD, depth From Defocus). The defocusing depth method is to build a proper mathematical model for a photographing module in advance by capturing images of two or more different defocusing positions and calculate the defocusing depth of a target object in combination with various parameters of the photographing module, so as to judge the focus position to realize focusing. Another method is a focusing depth method (DFF, depthFrom Focus), which is to collect a series of blurred to clear digital images through a computer (or a special circuit system), process the evaluation function of the definition of each frame of image, judge whether the focusing is accurate, that is, whether the imaging is clear, and give feedback signals to control the focal length of the optical lens until the collected digital images reach the clearest, and finally finish focusing.
Common evaluation functions are gradient evaluation functions, spectrum evaluation functions and statistical evaluation functions. The gradient function is used for extracting edge information of the image, the image with high focusing degree is clearer, a more obvious sharp edge is presented, and the image has a larger gradient function value; the spectrum evaluation function is provided with two functions of discrete cosine transformation and Fourier transformation, and a high-frequency component in the image is extracted as an evaluation function; the statistical evaluation function mainly includes an ac power function, a dc power function, a Range function, a menmayfunction, a Masgrn function, and an image gray variance function, and one of the image gray variance functions (D (f)) is that the image is the sharpest when fully focused, and has a larger gray difference than the blurred image, so that the gray change can be used as the basis of focus evaluation, and the formula is as follows:
D(f)=∑ y ∑ x (|f(x,y)-μ| 2 )
wherein x is the coordinate position of the pixel point in the horizontal direction, y is the coordinate position of the pixel point in the vertical direction, f (x, y) is the gray value of the pixel point at a certain position in the image, and mu is the average gray value of the whole image.
As mentioned above, the automatic focusing process of the gray variance function of the image needs to collect a lot of images, and the gray variance processing data is to increase the gray variance, so in practical application, the calculation of the square variance is still a more complex operation processing mode, and therefore how to simplify the calculation so as to achieve the fast and efficient processing requirements is the current urgent problem to be solved.
Disclosure of Invention
In view of the background art, an objective of the present invention is to provide a focusing process for finding out a target focal length position of a camera module with a simpler and faster evaluation process.
According to the present invention, the electronic computing unit is utilized to perform the following steps during the focusing process, the photographing module captures a focusing target image to generate a focusing image, the image processing module analyzes the focusing image to obtain gray values of all or part of the pixel points, the focusing analysis module calculates the discrete distribution degree of the gray values of all the pixel points, calculates the average standard deviation of the discrete distribution degree, and each time adjusts the focal position of the photographing module, i.e. circularly and sequentially performs all the steps until the average standard deviation of all the focal positions of the photographing module is obtained, and then the focusing analysis module finds the largest of all the average standard deviations, i.e. the focal position corresponding to the largest of the average standard deviations is the target focal position.
The focusing target image is formed by staggered arrangement of dark square grids and light square grids in the longitudinal direction and the transverse direction respectively, wherein the dark square grids are black square grids, and the light square grids are white square grids. Or the focusing target image is a one-dimensional bar code with different thickness, or the focusing target image is a two-dimensional bar code, or the focusing target image is a combination of the one-dimensional bar code and the two-dimensional bar code.
The method for calculating the discrete distribution degree of the gray values of the obtained primitive points is to calculate the gray values of all primitive points and average the gray values to obtain the average gray value, and the formula is as follows:
where α represents an average gray value, m is a transverse coordinate value of the focusing image, n is a transverse coordinate value of the focusing image, and G (m, n) is a gray value of the coordinates (m, n).
Subtracting absolute values from the average gray values of all the primitive points to obtain discrete distribution degrees, wherein the formula is as follows:
β(m,n)=|G(m,n)-α|
where β (m, n) is the degree of discrete distribution of the gradation values of the respective primitive points, G (m, n) is the gradation value of the coordinates (m, n), and α represents the average gradation value.
The average standard deviation of each focal length position of the photographing module is obtained by calculating all discrete distribution degrees in an average way, and the formula is as follows:
wherein delta is the average standard deviation of each focal length position, beta (m, n) is the discrete distribution degree of gray values of each primitive point, m is the transverse coordinate value of the focusing image, and n is the transverse coordinate value of the focusing image.
According to the invention, the lens focusing system comprises a photographing module, an image processing module, a focusing analysis module and a focus adjustment module, wherein the photographing module photographs a focusing target image to generate a focusing image, the image processing module is connected with the photographing module and receives the focusing image, the focusing analysis module processes the focusing image to obtain gray values of all or partial primitive points, the focusing analysis module is connected with the image processing module and receives the gray values of all primitive points, the discrete distribution degree of the gray values of all primitive points is calculated, the average standard deviation of the discrete distribution degree is calculated, the focus adjustment module is connected with the photographing module, the focus adjustment module adjusts the photographing module to a plurality of focus positions, and the photographing module photographs a focusing target image at all focus positions and respectively generates respective focusing images.
The focusing adjustment module is further connected with the focusing analysis module, and sends a focusing adjustment signal to the focusing adjustment module after the focusing analysis module finishes obtaining the average standard deviation of the current focus position each time, the focusing adjustment module adjusts the photographing module to the next focus position, the focusing adjustment module finishes adjusting to the next focus position, and then a photographing signal is generated to the photographing module, and the photographing module photographs a focusing target image to generate the next focusing image.
The focusing analysis module analyzes that the variation trend of the average standard deviation of all the currently obtained focal length positions gradually increases to the average standard deviation of one of the focal length positions, and then gradually decreases, namely stops sending out the focal length adjusting signal, and takes the focal length position with the largest average standard deviation as the target focal length position.
The focus adjustment module adjusts the focus position of the photographing module according to a plurality of focus adjustment signals, the focus analysis module analyzes that the variation trend of the average standard deviation of each focus position is gradually reduced, the focus adjustment signals sent by the focus adjustment module enable the focus adjustment module to reversely adjust the focus position, the variation trend of the average standard deviation is gradually increased to the average standard deviation of one focus position and then gradually reduced, and the focus position with the largest average standard deviation is taken as a target focus position.
In summary, the image processing module of the present invention analyzes the focusing image to obtain the gray values of the primitive points at all or part of the positions, and then calculates the discrete degree and the average standard deviation of each gray value, without calculating the variance, thereby reducing the difficulty of calculation and accelerating the processing speed.
Detailed Description
Embodiments of the present invention will be further illustrated by the following description in conjunction with the accompanying drawings. Wherever possible, the same reference numbers will be used throughout the drawings and the description to refer to the same or like parts. In the drawings, the shape and thickness may be exaggerated for simplicity and convenience. It is to be understood that components not specifically shown in the drawings or described in the specification are in forms known to those of ordinary skill in the art. Many variations and modifications may be made by one of ordinary skill in the art in light of the disclosure herein.
When a component is referred to as being "on …," it can be broadly interpreted as referring to the component as being directly on the other component or as having other components present in both. Conversely, when one component is referred to as being "directly on" another component, it cannot have other components in between. As used herein, the term "and/or" includes any combination of one or more of the listed associated items.
The following description of "one embodiment" or "an embodiment" refers to a particular component, structure, or feature associated with at least one embodiment. Thus, the appearances of the phrase "one embodiment" or "an embodiment" in various places in the following are not necessarily all referring to the same embodiment. Furthermore, the particular features, structures, and characteristics of the embodiments may be combined in any suitable manner.
The present invention is described with respect to the following examples which are intended to be illustrative only, since it will be apparent to those skilled in the art that various changes and modifications can be made therein without departing from the spirit and scope of the invention as defined in the following claims. Throughout the specification and claims, the terms "a" and "an" include the inclusion of "one or at least one" of the element or component unless the context clearly dictates otherwise. Furthermore, as used in this application, the singular articles also include a recitation of a plurality of elements or components unless it is apparent from the specific context that the plural is excluded. Moreover, as used in this description and throughout the claims that follow, the meaning of "in" may include "in" and "on" unless the context clearly dictates otherwise. The terms (terms) used throughout the specification and claims, unless otherwise indicated, shall generally be construed from a plain meaning of each term used in this field, in the context of the disclosure, and in the special context. Certain terms used to describe the present invention are discussed below, or elsewhere in this specification, to provide additional guidance to the practitioner (practioner) in describing the present invention. The use of examples anywhere throughout this specification including any examples of words discussed herein is illustrative only, and certainly not limiting of the scope and meaning of the invention or any exemplary words. As such, the invention is not limited to the various embodiments set forth in this specification.
It will be appreciated that the terms "comprising," "including," "having," "containing," and the like as used herein are open-ended, and are meant to include, but not be limited to. Furthermore, not all of the objects, advantages, or features of the present disclosure are required to be achieved by any one embodiment or claim of the present disclosure. Furthermore, the abstract sections and headings are for assistance in patent document searching only and are not intended to limit the claims of the invention.
Furthermore, the term "electrically coupled" or "electrically connected" as used herein includes any direct or indirect electrical connection. For example, if a first device is electrically coupled to a second device, that connection may be made directly to the second device or indirectly to the second device through other devices or connection means. In addition, while the transmission and provision of electrical signals have been described with respect to their transmission, it will be understood by those skilled in the art that the transmission of electrical signals may be accompanied by attenuation or other non-ideal variations, the source and the receiving end of the transmission or provision of electrical signals should be considered substantially the same signal unless specifically stated. For example, if an electrical signal S is transmitted (or provided) from terminal a of the electronic circuit to terminal B of the electronic circuit, wherein a voltage drop may occur through a source/drain of a transistor switch and/or possibly stray capacitance, the purpose of the design is to achieve certain specific technical effects without deliberately using attenuation or other non-ideal variations in the transmission (or provision), the electrical signal S should be considered to be substantially the same signal at both terminals a and B of the electronic circuit.
Unless specifically stated otherwise, some terms or words such as "can", "possible", "about", "may", "about", or "about" are generally intended to mean that the present embodiment has, but may also be construed as possibly unwanted features, elements, or steps. In other embodiments, these features, components, or steps may not be required.
Referring to fig. 1, the present invention is a lens focusing system, which includes a photographing module 1, an image processing module 2, a focusing analysis module 3 and a focusing adjustment module 4, wherein the photographing module 1 is located at a predetermined position relative to a focusing target image, and photographs the focusing target image to generate a focusing image. The image processing module 2 is connected to the photographing module 1 and receives the focusing image, and the image processing module processes the focusing image to obtain gray values of the primitive points at all or part of the positions. The focusing analysis module 3 is connected with the image processing module 2, receives the gray values of the primitive points, calculates the discrete distribution degree of the gray values of the primitive points, and calculates the average standard deviation of the discrete distribution degree.
Referring to fig. 2, in the present invention, a photographing module 1 includes a circuit board 10 (or a substrate), an image capturing die 12, a lens mount 14 and an optical lens 16, wherein the image capturing die 12 is disposed on the circuit board 10, the lens mount 14 is disposed around the image capturing die 12, the optical lens 16 is movably disposed on the lens mount 14, the distance between the optical lens 16 and the image capturing die 12 can be adjusted by adjusting the optical lens 16 to rotate on the lens mount, and the focal distance position can be manually adjusted or automatically adjusted by adjusting the focal distance position, in order to automatically adjust the focal distance, in the present invention, the focal distance adjusting module 4 is connected to the photographing module 1, and the photographing module 1 is connected to a plurality of focal distance positions, and the photographing module 1 photographs a focusing target image at each focal distance position and generates respective focusing images. The lens mount 14 and the optical lens 16 are usually screwed together, so that the distance between the optical lens 16 and the image capturing die 12 can be adjusted by rotating the optical lens 16.
In the present invention, referring to fig. 3A, the focusing target image may be a regular or irregular image with high gray scale contrast, for example, the focusing target image may be formed by alternately arranging dark square cells and light square cells in the longitudinal direction and the transverse direction, and in particular, the dark square cells are black square cells, and the light square cells are white square cells. Or the focusing target image is a one-dimensional bar Code with different thickness, or the focusing target image is a two-dimensional bar Code, or the focusing target image is a combination of the one-dimensional bar Code and the two-dimensional bar Code, wherein the two-dimensional bar Code can be a quick response image Code (Quick Response Code, QR Code for short).
In the present invention, taking a focusing target image formed by dark square grids as black square grids and light square grids as white square grids as an example, the reason why an image with high gray scale contrast ratio is adopted as the focusing target image is described, when the photographing module 1 photographs the focusing target image formed by staggered arrangement of the dark square grids and the light square grids, the gray scale value of each pixel point of the focusing image corresponding to black ziegler is approximately 0 or equal to 0, and the gray scale value of each pixel point corresponding to white ziegler is approximately 255 or equal to 255, therefore, when the gray scale value difference of each pixel point of the focusing image is larger, the focusing image is shown to be clearer, and the focusing image with the largest gray scale value difference in different focusing images is the target focal length position.
In order to more clearly solve the difference between gray values of the primitive points of the focusing image and the corresponding relation between the focusing images shot at different focal positions, the focusing images shot at different focal positions and the gray distribution thereof are provided for explanation, please refer to fig. 3A to 3C, which respectively show the focusing images shot at the target focal positions and the focusing images shot at the three non-target focal positions, and fig. 4A to 4C show the distribution diagrams of gray values of the primitive points of the lowest X-direction coordinates.
In order to enable the focus adjustment module 4 to further perform focus adjustment after the focus analysis module 3 obtains the average standard deviation of the current focus position each time, in the present invention, the focus adjustment module 4 is further connected to the focus analysis module 3, the focus analysis module 3 sends a focus adjustment signal to the focus adjustment module 4 after each time the focus analysis module 3 completes obtaining the average standard deviation of the current focus position, the focus adjustment module 4 adjusts the photographing module 1 to the next focus position again, the focus adjustment module 4 completes adjusting to the next focus position, and then generates a photographing signal to the photographing module 1, and the photographing module 1 photographs the focus adjustment target image to generate the next focusing image.
However, in practical implementation of the present invention, the focal length adjusting module 4 may not necessarily receive the focal length adjusting signal sent by the focusing analyzing module 3 to adjust the focal length position of the photographing module 1, and the focal length adjusting module 4 may also receive the photographing signal from the photographing module 1 as the focal length adjusting signal after the photographing module 1 finishes photographing one focusing image each time.
In the present invention, the focal length adjustment module 4 may adjust the optical module of the photographing module 1 from the focal length position of 0 to 360 degrees to focus at the same angle, for example: the focusing images of all angles can be obtained by adjusting 1 degree for 360 times, and the average standard deviation of the discrete distribution degree is obtained from the focusing images, wherein the largest focusing image is the target focal length position. However, if the focal length of the photographing module 1 is adjusted in the same direction, the distance between the optical module and the image capturing die 12 is increased or decreased, and the corresponding focusing image is also gradually clearer or more blurred, so that according to such trend change, when the trend of the average standard deviation of the focal length positions obtained at present is gradually increased to the average standard deviation of one of the focal length positions, the focusing analysis module 3 starts to gradually decrease, i.e. stops sending the focal length adjusting signal, and takes the focal length position with the largest average standard deviation as the target focal length position.
Or, when the focal length adjusting module 4 adjusts the focal length position of the photographing module 1 according to the plurality of focal length adjusting signals, the focusing analyzing module 3 analyzes that the obtained variation trend of the average standard deviation of each focal length position is gradually reduced, the focal length adjusting signal sent by the focal length adjusting module 4 is to make the focal length adjusting module 4 reversely adjust the focal length position, and the variation trend of the average standard deviation is changed to gradually increase to the average standard deviation of one of the focal length positions and then gradually decrease, and the focal length position with the largest average standard deviation is taken as the target focal length position.
By the above adjustment method, the camera module 1 can adjust the focal length position according to the trend without focusing from 0 to 360 degrees, so as to reduce the adjustment times and speed up focusing.
Referring to fig. 5, the present invention is a lens focusing method, in which an electronic computing unit is used to perform the following steps:
(S100) adjusting the focal length position of the photographing module 1;
(S101) capturing a focusing target image by the photographing module 1 to generate a focusing image;
(S102) the image processing module 2 analyzes the focusing image to obtain gray values of the primitive points at all positions or partial positions;
(S103) the focusing analysis module 3 calculates the discrete distribution degree of the gray value of each acquired primitive point, and calculates the average standard deviation of the discrete distribution degree;
(S104) judging whether the adjustment of the focal length positions of the photographing module 1 is completed, if yes, performing the step (S105), otherwise, performing the step (S100);
and (S105) the focusing analysis module finds out the largest one of all the average standard deviations, and the focal length position corresponding to the largest one of the average standard deviations is the target focal length position.
In the present invention, the focusing target image is formed by alternately arranging dark square grids and light square grids in the longitudinal direction and the transverse direction respectively, wherein the dark square grids are black square grids, and the light square grids are white square grids. Or the focusing target image is a one-dimensional bar code with different thickness, or the focusing target image is a two-dimensional bar code, or the focusing target image is a combination of the one-dimensional bar code and the two-dimensional bar code. The electronic computing unit can be an electronic device with computing capability such as a desktop computer, a notebook computer or a tablet computer.
In the present invention, the gray value of each pixel point is calculated to average the gray value of all pixel points to obtain an average gray value, and the formula is as follows:
where α represents an average gray value, m represents a horizontal coordinate value of the focusing image, n represents a horizontal coordinate value of the focusing image, G (m, n) represents a gray value of the coordinates (m, n), as shown in fig. 6, which is a schematic diagram illustrating a distribution state of gray values of each pixel point in fig. 3A, a line below α represents an average gray value, as shown in fig. 7, which is a schematic diagram illustrating a distribution state of gray values of each pixel point in fig. 3C, and a line below α represents an average gray value.
Subtracting absolute values from the average gray values of all the primitive points to obtain discrete distribution degrees, wherein the formula is as follows:
β(m,n)=|G(m,n)-α|
where β (m, n) is the degree of discrete distribution of the gradation values of the respective primitive points, G (m, n) is the gradation value of the coordinates (m, n), and α represents the average gradation value. Fig. 8 is a schematic diagram of the degree of discrete distribution of fig. 6, and fig. 9 is a schematic diagram of the degree of discrete distribution of fig. 7.
The average standard deviation of all focal length positions of the imaging module 1 is obtained by calculating the average of all discrete distribution degrees, and the formula is as follows:
wherein delta is the average standard deviation of each focal length position, beta (m, n) is the discrete distribution degree of gray values of each primitive point, m is the transverse coordinate value of the focusing image, and n is the transverse coordinate value of the focusing image.
In addition, in order to reduce the calculation amount of the gray value, the average gray value, the discrete distribution degree and the average standard deviation of the focusing image, the invention can only take the local image of the focusing image for calculation, but is not limited to take the local image of the focusing image for calculation, and the invention can still calculate the whole image of the whole focusing image.
As described above, the present invention can accomplish the adjustment of the focal length in a simple and rapid manner, and the evaluation function is simpler than the conventional evaluation function, so that the present invention can accomplish the operation more rapidly, and the focusing operation of the photographing module 1 is completed.
The foregoing description is only illustrative of the preferred embodiments of the present invention and is not to be construed as limiting the scope of the invention, which is defined by the appended claims and their equivalents.