[go: up one dir, main page]

CN113805304B - Automatic focusing system and method for linear array camera - Google Patents

Automatic focusing system and method for linear array camera Download PDF

Info

Publication number
CN113805304B
CN113805304B CN202111354772.1A CN202111354772A CN113805304B CN 113805304 B CN113805304 B CN 113805304B CN 202111354772 A CN202111354772 A CN 202111354772A CN 113805304 B CN113805304 B CN 113805304B
Authority
CN
China
Prior art keywords
target
evaluation value
image
camera
focusing
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202111354772.1A
Other languages
Chinese (zh)
Other versions
CN113805304A (en
Inventor
钟洪萍
章灵伟
郑建
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhejiang Shuangyuan Technology Co ltd
Original Assignee
Zhejiang Shuangyuan Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhejiang Shuangyuan Technology Co ltd filed Critical Zhejiang Shuangyuan Technology Co ltd
Priority to CN202111354772.1A priority Critical patent/CN113805304B/en
Publication of CN113805304A publication Critical patent/CN113805304A/en
Application granted granted Critical
Publication of CN113805304B publication Critical patent/CN113805304B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G02OPTICS
    • G02BOPTICAL ELEMENTS, SYSTEMS OR APPARATUS
    • G02B7/00Mountings, adjusting means, or light-tight connections, for optical elements
    • G02B7/28Systems for automatic generation of focusing signals
    • G02B7/36Systems for automatic generation of focusing signals using image sharpness techniques, e.g. image processing techniques for generating autofocus signals
    • GPHYSICS
    • G02OPTICS
    • G02BOPTICAL ELEMENTS, SYSTEMS OR APPARATUS
    • G02B7/00Mountings, adjusting means, or light-tight connections, for optical elements
    • G02B7/28Systems for automatic generation of focusing signals
    • G02B7/36Systems for automatic generation of focusing signals using image sharpness techniques, e.g. image processing techniques for generating autofocus signals
    • G02B7/38Systems for automatic generation of focusing signals using image sharpness techniques, e.g. image processing techniques for generating autofocus signals measured at different points on the optical axis, e.g. focussing on two or more planes and comparing image data
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N23/00Cameras or camera modules comprising electronic image sensors; Control thereof
    • H04N23/60Control of cameras or camera modules
    • H04N23/67Focus control based on electronic image sensor signals
    • H04N23/675Focus control based on electronic image sensor signals comprising setting of focusing regions

Landscapes

  • Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • General Physics & Mathematics (AREA)
  • Optics & Photonics (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Studio Devices (AREA)

Abstract

The invention discloses an automatic focusing system and method for a linear array camera, wherein the linear array camera acquires continuous image data of a first shot target and a second shot target according to a preset focusing step length and a focusing search direction under the control of a camera adjusting mechanism; the image processing device processes the continuous image data to obtain a first-order difference of gray values of a first shot target and a second shot target image, determines a focusing window according to the first-order difference of the gray values of the first shot target and the second shot target image, processes the continuous image data collected in the focusing window to obtain an out-of-focus evaluation value of the image, and controls the camera adjusting mechanism to adjust the linear array camera according to the out-of-focus evaluation value until a lens of the linear array camera is located at an in-focus position for a global view; the system and the method can effectively reduce the calculated amount in the focusing process and improve the focusing accuracy.

Description

Automatic focusing system and method for linear array camera
Technical Field
The invention relates to the technical field of image processing, in particular to an automatic focusing system and method for a linear array camera.
Background
Line cameras are widely used in the field of industrial inspection, wherein the most typical application scenario is to inspect the surface of continuous materials for defects, such as paper, metal, thin films, non-woven fabrics and the like. The object to be detected usually moves at a constant speed, and then is continuously scanned line by one or more linear array cameras so as to uniformly detect the material of the whole surface of the object. Although the line-scan camera has a very large visual field and very high precision, the working mode only scans one line of a target object as line data in a digital image at a time, so that the most appropriate focal length is difficult to find for the global visual field of a lens, and the definition of the whole imaging is influenced.
In an actual application scene, most of linear array cameras in the industrial field still stay at a manual focusing stage, and sometimes, the installation position of the cameras is higher, so that the manual operation process is dangerous. The manual focusing usually uses whether a local view is clear to image as a basis for judging whether the focusing is good or bad, so that the conditions that a part of the whole breadth of a camera is clear and a part of the whole breadth is fuzzy frequently occur. The traditional automatic focusing method mainly comprises a distance measurement method and an image detection method according to different implementation principles, has respective applicable aspects, but also has the defects of complex operation, high equipment cost, difficulty in system miniaturization and the like.
Patent document CN 112995521B provides a high-precision auto-focusing method for a linear array camera based on sine stripes, which includes: building a focusing calibration system comprising an obliquely placed display device, a linear array camera and a motion device; the display device circularly plays the sine stripe images with different initial phases according to the frequency which is coordinated with the photographing frequency of the linear array camera, so as to obtain phase shift data; calculating phase data from the phase shift data; the degree based on the linearity of the phase change is used as an evaluation standard to obtain the optimal phase; calculating the optimal focusing distance of the linear array camera according to the position of the optimal phase and the size, pose length and angle of each part of the focusing calibration system; and adjusting the linear array camera to the position of the optimal distance from the measured object according to the optimal focusing distance to finish focusing. However, the scheme has a complex hardware structure and a large calculation amount, so that the production cost is high.
Disclosure of Invention
The invention provides an automatic focusing system and method for a linear array camera, which can effectively reduce the calculated amount in the automatic focusing process and improve the focusing accuracy.
An automatic focusing system for a linear array camera comprises a first shot target, a second shot target, the linear array camera, an image processing device and a camera adjusting mechanism;
the first shot target and the second shot target are positioned at two ends of the visual field of the line camera; the linear array camera is used for acquiring continuous image data of the first shot target and the second shot target according to a preset focusing step length and a focusing search direction under the control of the camera adjusting mechanism;
the image processing device is used for processing the continuous image data, obtaining a first-order difference of gray values of images of a first shot target and a second shot target, determining a focusing window according to the first-order difference of the gray values of the images of the first shot target and the second shot target, processing the continuous image data collected in the focusing window to obtain an out-of-focus evaluation value of the images, and controlling the camera adjusting mechanism to adjust the linear array camera according to the out-of-focus evaluation value until a lens of the linear array camera is located at an in-focus position for a global view.
Further, the image processing apparatus is configured to set a position region between two inflection points of the first difference of the image gradation value of the first subject as a focus window of the first subject, and set a position region between two inflection points of the first difference of the image gradation value of the second subject as a focus window of the second subject.
Further, the image processing device is further configured to calculate, according to continuous image data collected in the focusing window, a continuous first photographic target defocus evaluation value and a continuous second photographic target defocus evaluation value, respectively, determine whether focusing is required, and when it is determined that focusing is required, control the camera adjustment mechanism to adjust the line camera according to the continuous first photographic target defocus evaluation value and the continuous second photographic target defocus evaluation value until the lens of the line camera is located at an in-focus position with respect to the global field of view.
Further, when the first and second photographic target defocus evaluation values at the position of the lens of the line camera are close to equal and peak values, it is determined that focusing is not required.
Further, the image processing device is used for determining the angle adjustment direction between the plane where the lens of the line camera is located and the detection plane according to the continuous first shot target defocus evaluation value and the continuous second shot target defocus evaluation value, and controlling the camera adjusting mechanism to adjust the corresponding angle according to a preset angle step;
the image processing device is further used for controlling continuous acquisition of continuous image data of the first shot target and the second shot target according to a preset image distance step length after angle adjustment, adjusting the angle of the linear camera lens according to the first shot target defocus degree evaluation value and the second shot target defocus degree evaluation value again until the angle adjustment range is searched, and determining the position where the first shot target defocus degree evaluation value and the second shot target defocus degree evaluation value are approximately equal and are peak values as a positive focal position;
the detection plane is a plane where the first shot target and the second shot target are located.
Further, the first photographic target defocus degree evaluation value is expressed by the following formula:
Figure 637645DEST_PATH_IMAGE001
wherein,
Figure 916179DEST_PATH_IMAGE002
as the first photographic target defocus degree evaluation value,
Figure 611734DEST_PATH_IMAGE003
the resolution of the representation of the image is,
Figure 292114DEST_PATH_IMAGE004
representing the gray-scale values of the pixels of the image,
Figure 437925DEST_PATH_IMAGE005
a line segment function composed of two inflection points representing the first-order difference of the gray value of the first shot target image;
the second photographic target defocus degree evaluation value is expressed by the following formula:
Figure 187444DEST_PATH_IMAGE006
wherein,
Figure 670377DEST_PATH_IMAGE007
as the second photographic target defocus degree evaluation value,
Figure 221576DEST_PATH_IMAGE003
the resolution of the representation of the image is,
Figure 131763DEST_PATH_IMAGE008
representing the gray-scale values of the pixels of the image,
Figure 637087DEST_PATH_IMAGE009
and a line segment function consisting of two inflection points representing the first order difference of the gray values of the second subject image.
Further, with a first shooting target on the left and a second shooting target on the right as a reference, if the peak value of the first shooting target defocus degree evaluation value appears before the peak value of the second shooting target defocus degree evaluation value, determining that the angle adjustment direction is clockwise;
and if the peak value of the second shooting target defocus evaluation value appears before the peak value of the first shooting target defocus evaluation value, determining that the angle adjustment direction is anticlockwise.
Further, the camera adjustment mechanism includes a first stepping motor and a second stepping motor; the first stepping motor is used for adjusting the angle between the plane where the lens of the linear array camera is located and the detection plane according to a preset angle step;
and the second stepping motor is used for adjusting the image distance of the linear array camera according to a preset image distance step length.
Further, the image processing apparatus is further configured to record, by using a least square method, a first photographic target defocus evaluation value and a second continuous photographic target defocus evaluation value of each continuous image data sampling point, and perform curve fitting with the positions of the corresponding first stepping motor and second stepping motor, and determine, as an optimal positive focus position, a position where the peak values of the first photographic target defocus evaluation value and the second photographic target defocus evaluation value are approximately equal and the peak values appear at the time of angle adjustment and image distance adjustment.
An automatic focusing method for a linear array camera by adopting the system comprises the following steps:
the linear array camera acquires continuous image data of the first shot target and the second shot target according to a preset focusing step length and a focusing search direction under the control of the camera adjusting mechanism;
the image processing device processes the continuous image data to obtain a first-order difference of gray values of a first shot target and a second shot target image, determines a focusing window according to the first-order difference of the gray values of the first shot target and the second shot target image, processes the continuous image data collected in the focusing window to obtain an evaluation value of the defocusing degree of the image, and controls the camera adjusting mechanism to adjust the linear array camera according to the evaluation value of the defocusing degree until a lens of the linear array camera is located at a forward focus position for a global view.
The automatic focusing system and method for the linear array camera provided by the invention at least have the following beneficial effects:
(1) the focusing window is selected by adopting a method for constructing the first-order difference focusing window of the gray level image, so that the number of image pixels participating in calculation can be effectively reduced, the calculation amount is reduced, a shot target is ensured to be positioned in the constructed focusing window, and the adverse effect of a background area on a focusing result is reduced;
(2) the focusing position is found through the defocusing degree values of the two shot targets, so that the focusing precision and the real-time performance can be effectively ensured;
(3) the best positive focal position is accurately positioned through least square fitting, and the accuracy of determining the positive focal position can be further improved.
Drawings
Fig. 1 is a schematic structural diagram of an embodiment of an automatic focusing system for a line camera according to the present invention.
Fig. 2 is a schematic diagram of an embodiment of a first-order difference signal curve of gray scale values of images of a first photographic target and a second photographic target in the automatic focusing system for a line camera provided by the invention.
Fig. 3 is a schematic diagram of an embodiment of a line-array camera and a detection plane in the automatic focusing system for a line-array camera provided by the invention.
Fig. 4 is a schematic diagram of an embodiment of clockwise adjustment of a line camera in an automatic focusing system for a line camera according to the present invention.
Fig. 5 is a schematic diagram of an embodiment of counterclockwise adjustment of a line camera in an automatic focusing system for a line camera according to the present invention.
Fig. 6 is a step diagram of an embodiment of an automatic focusing method for a line camera according to the present invention.
Fig. 7 is a flowchart of an embodiment of an automatic focusing method for a line camera according to the present invention.
In order to better understand the technical solution, the technical solution will be described in detail with reference to the drawings and the specific embodiments.
Referring to fig. 1, in some embodiments, there is provided an autofocus system for a line camera, comprising a first subject 101, a second subject 102, a line camera 103, an image processing apparatus 104, and a camera adjustment mechanism 105;
the first photographic target 101 and the second photographic target 102 are positioned at two ends of the visual field of the line camera 103; the linear array camera 103 is used for acquiring continuous image data of the first shot target 101 and the second shot target 102 according to a preset focusing step length and a focusing search direction under the control of the camera adjusting mechanism 105;
the image processing device 104 is configured to process the continuous image data, obtain a first-order difference between image gray scale values of the first subject object 101 and the second subject object 102, determine a focusing window according to the first-order difference between the image gray scale values of the first subject object 101 and the second subject object 102, process the continuous image data acquired in the focusing window to obtain a defocus evaluation value of the image, and control the camera adjusting mechanism 105 to adjust the line camera 103 according to the defocus evaluation value until a lens of the line camera 103 is located at a forward focus position for a global field of view.
Specifically, a linear array camera focusing debugging platform is built, a first shot target and a second shot target are placed on the same horizontal line at two ends of the platform, and the first shot target and the second shot target are enabled to be arranged at two ends of the visual field of the linear array camera 103.
In the focusing process, the linear array camera 103 acquires continuous image data of a first shot target 101 and a second shot target 102 according to a preset focusing step length and a focusing search direction under the control of the camera adjusting mechanism 105; wherein the focus search direction includes: the method comprises the following steps that the optical center of a lens of the linear array camera is close to or far away from a camera sensor, the included angle between the plane where the lens of the linear array camera is located and a detection plane is enlarged or reduced, a preset focusing step comprises a preset angle step and a preset image distance step, the included angle between the plane where the lens of the linear array camera is located and the detection plane is adjusted according to the preset angle step, and the distance between the optical center of the lens of the linear array camera and the camera sensor is adjusted according to the preset image distance step.
Further, the image processing device 104 processes the continuous image data, including converting the continuous image into a grayscale image, and obtaining a first order difference of image grayscale values of the grayscale image, and determines a focusing window according to the first order difference of the image grayscale values of the first and second subjects 101 and 102.
A focus window, i.e., a focus area, where the first subject 101 and the second subject 102 are imaged on the same image, and therefore it is necessary to determine the approximate range of the first subject 101 and the second subject 102 on the image, i.e., two approximate focus areas on the image.
The linear array camera is in a linear shape, namely thousands of pixels are arranged in the length direction, the width is only a few pixels, and one line of pixel data of the imaging is taken
Figure 923712DEST_PATH_IMAGE010
Performing a first-order difference, i.e. the difference between two consecutive adjacent pixels
Figure 329416DEST_PATH_IMAGE011
Specifically, the image processing apparatus sets a position region between two inflection points of the first order difference of the image gradation value of the first subject as the focus window of the first subject 101, and sets a position region between two inflection points of the first order difference of the image gradation value of the second subject 102 as the focus window of the second subject.
Referring to fig. 2, a first order difference signal curve of the gray scale values of the images of the first subject 101 and the second subject 102 is shown in fig. 2, wherein the ordinate represents the gray scale level, i.e. the difference between the gray scale values of two adjacent pixels, the abscissa represents the pixel coordinate of one row of pixels, the left side of the image is the first order difference signal curve of the gray scale value of the image of the first subject 101, the inflection points are 1 and 2, the area between the inflection point 1 and the inflection point 2 is the focusing window of the first subject 101, the right side is the first order difference signal curve of the gray scale value of the image of the second subject 102, the inflection points are 3 and 4, and the area between the inflection point 3 and the inflection point 4 is the focusing window of the second subject 102.
In the calculation process of the defocus degree, the more the number of pixels of the image participating in the calculation is, the larger the calculation amount is, so in order to reduce the calculation amount and enhance the real-time performance of the automatic focusing system, the participation of the pixels in the background area of the image in the calculation should be reduced as much as possible. Meanwhile, in order to adapt to the situation of size change of an imaging target, a method for constructing a first-order difference focusing window of a gray image is adopted. The selection of the focusing window obtains inflection point information through the first-order difference of the gray values of the images, because the inflection point determines the boundary position of two shot objects in the background image, and then the width of the focusing window is determined by the distance between the coordinate positions of the inflection point. By the method of solving the gray level image of the original image and calculating the first-order difference, the position of the shot target is determined in a self-adaptive manner, the shot target is ensured to be positioned in the constructed focusing window, the adverse effect of a background area on the focusing result is reduced, and the application scene of the change of the size of the imaging target is met.
Further, the image processing device 104 is further configured to calculate, according to the continuous image data collected in the focusing window, a continuous first target-to-be-photographed defocus evaluation value and a continuous second target-to-be-photographed defocus evaluation value, respectively, determine whether focusing is required, and when it is determined that focusing is required, control the camera adjusting mechanism 105 to adjust the line camera 103 until the lens of the line camera 103 is located at the in-focus position with respect to the global field of view according to the continuous first target-to-be-photographed defocus evaluation value and the continuous second target-to-be-photographed defocus evaluation value.
The target defocus degree evaluation value is calculated through a defocus degree evaluation function, and the defocus degree evaluation function mainly focuses on depth information representing the image focus degree and quantitatively describes the image definition degree. The higher the defocus evaluation value is, the higher the image sharpness is, and the more blurred the image is when the image is positive.
The first photographic target defocus degree evaluation value is expressed by the following formula:
Figure 676084DEST_PATH_IMAGE001
wherein,
Figure 291873DEST_PATH_IMAGE002
as the first photographic target defocus degree evaluation value,
Figure 365877DEST_PATH_IMAGE003
the resolution of the representation of the image is,
Figure 609777DEST_PATH_IMAGE004
representing the gray-scale values of the pixels of the image,
Figure 143658DEST_PATH_IMAGE005
a line segment function composed of two inflection points representing the first-order difference of the gray value of the first shot target image;
the second photographic target defocus degree evaluation value is expressed by the following formula:
Figure 371377DEST_PATH_IMAGE006
wherein,
Figure 246142DEST_PATH_IMAGE007
as the second photographic target defocus degree evaluation value,
Figure 610127DEST_PATH_IMAGE003
the resolution of the representation of the image is,
Figure 439543DEST_PATH_IMAGE008
representing the gray-scale values of the pixels of the image,
Figure 639711DEST_PATH_IMAGE009
and a line segment function consisting of two inflection points representing the first order difference of the gray values of the second subject image.
Specifically, when the first and second photographic target defocus evaluation values at the position of the lens of the line camera are close to equal and peak values, it is determined that focusing is not required, otherwise, focusing is required.
The values described in this embodiment are approximately equal, and the difference between the two defocus evaluation values is within 3%.
Further, the image processing device 104 is configured to determine an angle adjustment direction between a plane where the lens of the line camera 103 is located and the detection plane according to the continuous first photographic target defocus evaluation value and the continuous second photographic target defocus evaluation value at which peaks occur, and control the camera adjusting mechanism 105 to adjust the corresponding angle according to a preset angle step;
the image processing device 104 is further configured to control to continuously acquire continuous image data of the first and second targets according to a preset image distance step after adjusting the angle, adjust the angles between the lens of the line camera and the detection plane according to the continuous defocus evaluation values of the first and second targets again until the search of the angle adjustment range is completed, obtain defocus evaluation values of the two targets to be detected at each angle and each image distance when the search of the angle adjustment range is completed, and determine the position where the defocus evaluation values of the first and second targets are approximately equal and are peak values as a positive focus position;
the detection plane is a plane where the first shot target and the second shot target are located.
Specifically, with a first photographic target on the left and a second photographic target on the right as a reference, if the peak value of the first photographic target defocus degree evaluation value appears before the peak value of the second photographic target defocus degree evaluation value, the angle adjustment direction is determined to be clockwise;
if the peak value of the second photographic target defocus evaluation value appears earlier than the peak value of the first photographic target defocus evaluation value, the angle adjustment direction is determined to be counterclockwise.
Referring to fig. 3, a plane where the lens of the line camera is located is AB, a detection plane is CD, if a peak value of the defocus value of the first object appears before a peak value of the defocus evaluation value of the second object, the angle is adjusted clockwise, as shown in fig. 4, an included angle formed by the plane where the lens of the line camera is located and the detection plane is reduced, otherwise, if the peak value of the defocus evaluation value of the second object appears before the peak value of the defocus evaluation value of the first object, the adjustment direction is counterclockwise, as shown in fig. 5, an included angle formed by the plane where the lens of the line camera is located and the detection plane is increased.
Further, the camera adjusting mechanism 105 includes a first stepping motor and a second stepping motor; the first stepping motor is used for adjusting the angle between the plane where the lens of the linear array camera 103 is located and the detection plane according to a preset angle step;
and the second stepping motor is used for adjusting the image distance of the linear array camera according to the preset image distance step length, namely the distance between the optical center of the lens of the linear array camera and the camera sensor.
Further, during the focusing process, the focusing is performed according to a preset focusing step, the smaller the preset focusing step is set, the more accurate the focusing is, but the angle of rotation of the stepping motor is affected by the pulse width, the accuracy is limited, and the positive focal position obtained through the above steps may not be the optimal positive focal position, so the image processing apparatus 104 is further configured to record the first and second continuous target defocus evaluation values of each continuous image data sampling point by using the least square method, perform curve fitting with the positions of the corresponding first and second stepping motors, and determine the optimal positive focal position at the position where the peak values of the first and second continuous defocus evaluation values of the first and second continuous targets are nearly equal and the peak values appear during the angle adjustment and the image distance adjustment.
Through curve fitting of the defocus degree evaluation value and the position of the stepping motor, the position where the peak values of the first continuous defocus degree evaluation value and the second continuous defocus degree evaluation value are closer to be equal can be found, and therefore the optimal positive focus position can be determined.
Referring to fig. 6, in some embodiments, there is further provided an autofocus method for a line camera employing the above system, including:
s1, acquiring continuous image data of the first shot target and the second shot target by the linear array camera according to a preset focusing step length and a focusing search direction under the control of the camera adjusting mechanism;
s2, the image processing device processes the continuous image data to obtain a first order difference of gray scale values of a first shot target and a second shot target image, determines a focusing window according to the first order difference of the gray scale values of the first shot target and the second shot target image, processes the continuous image data collected in the focusing window to obtain a defocusing degree evaluation value of the image, and controls the camera adjusting mechanism to adjust the linear array camera according to the defocusing degree evaluation value until the lens of the linear array camera is located at a positive focal position for a global visual field.
Specifically, in step S2, the image processing apparatus sets the first-order difference in image gradation value of the first subject to be close to the region between the inflection point of the line camera field of view edge and the inflection point of the image gradation value of the second subject to be close to the line camera field of view edge as the focusing window.
Further, referring to fig. 7, in step S2, the image processing apparatus calculates a first continuous evaluation value of the defocus of the object to be photographed and a second continuous evaluation value of the defocus of the object to be photographed based on the continuous image data collected in the focusing window, determines whether focusing is required, and controls the camera adjustment mechanism to adjust the line camera until the lens of the line camera is located at the in-focus position with respect to the global field of view based on the first continuous evaluation value of the defocus of the object to be photographed and the second continuous evaluation value of the defocus of the object to be photographed when it is determined that focusing is required. And when the first shooting target defocusing degree evaluation value and the second shooting target defocusing degree evaluation value of the position where the lens of the linear array camera is located are equal and extreme values, determining that focusing is not needed.
Further, in step S2, the image processing apparatus determines an angle adjustment direction between a plane where the lens of the line camera is located and the detection plane according to the first subject defocus evaluation value and the time when the consecutive second subject defocus evaluation values have peaks, and controls the camera adjustment mechanism to adjust the corresponding angle according to a preset angle step;
after the angle is adjusted by the image processing device, continuously acquiring continuous image data of the first shot target and the second shot target according to preset image distance step length control, adjusting the angle of the linear camera lens according to the first shot target out-of-focus degree evaluation value and the second shot target out-of-focus degree evaluation value again until the searching of the angle adjustment range is finished, and determining the positions, which are approximately equal to each other and are peak values, of the first shot target out-of-focus degree evaluation value and the second shot target out-of-focus degree evaluation value as positive focal positions;
the detection plane is a plane where the first shot target and the second shot target are located.
Wherein the first photographic target defocus degree evaluation value is expressed by the following formula:
Figure 71830DEST_PATH_IMAGE001
wherein,
Figure 539589DEST_PATH_IMAGE002
as the first photographic target defocus degree evaluation value,
Figure 664540DEST_PATH_IMAGE003
the resolution of the representation of the image is,
Figure 86425DEST_PATH_IMAGE004
representing the gray-scale values of the pixels of the image,
Figure 587813DEST_PATH_IMAGE005
a line segment function composed of two inflection points representing the first-order difference of the gray value of the first shot target image;
the second photographic target defocus degree evaluation value is expressed by the following formula:
Figure 801757DEST_PATH_IMAGE006
wherein,
Figure 84227DEST_PATH_IMAGE007
as the second photographic target defocus degree evaluation value,
Figure 508255DEST_PATH_IMAGE003
the resolution of the representation of the image is,
Figure 32909DEST_PATH_IMAGE008
representing the gray-scale values of the pixels of the image,
Figure 491572DEST_PATH_IMAGE009
and a line segment function consisting of two inflection points representing the first order difference of the gray values of the second subject image.
With a first shooting target at the left and a second shooting target at the right as a reference, if the peak value of the first shooting target defocus degree evaluation value occurs before the peak value of the second shooting target defocus degree evaluation value, determining that the angle adjustment direction is clockwise;
and if the peak value of the second shooting target defocus evaluation value appears before the peak value of the first shooting target defocus evaluation value, determining that the angle adjustment direction is anticlockwise.
Further, the camera adjustment mechanism includes a first stepping motor and a second stepping motor; the first stepping motor is used for adjusting the angle between the plane where the lens of the linear array camera is located and the detection plane according to a preset angle step;
and the second stepping motor is used for adjusting the image distance of the linear array camera according to a preset image distance step length.
In some embodiments, the method further comprises:
and S3, the image processing device records the first photographic target defocusing degree evaluation value and the continuous second photographic target defocusing degree evaluation value of each continuous image data sampling point by adopting a least square method, performs curve fitting on the positions of the corresponding first stepping motor and the second stepping motor, and determines the position where the peak values of the first photographic target defocusing degree evaluation value and the second photographic target defocusing degree evaluation value are approximately equal and appear during angle adjustment and image distance adjustment as the best positive focal position.
The automatic focusing system and method for the linear array camera provided by the embodiment at least have the following beneficial effects:
(1) the focusing window is selected by adopting a method for constructing the first-order difference focusing window of the gray level image, so that the number of image pixels participating in calculation can be effectively reduced, the calculation amount is reduced, a shot target is ensured to be positioned in the constructed focusing window, and the adverse effect of a background area on a focusing result is reduced;
(2) the focusing position is found through the defocusing degree values of the two shot targets, so that the focusing precision and the real-time performance can be effectively ensured;
(3) the best positive focal position is accurately positioned through least square fitting, and the accuracy of determining the positive focal position can be further improved.
While preferred embodiments of the present invention have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all such alterations and modifications as fall within the scope of the invention. It will be apparent to those skilled in the art that various changes and modifications may be made in the present invention without departing from the spirit and scope of the invention. Thus, if such modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include such modifications and variations.

Claims (10)

1. An automatic focusing system for a linear array camera is characterized by comprising a first shot target, a second shot target, the linear array camera, an image processing device and a camera adjusting mechanism;
the first shot target and the second shot target are positioned at two ends of the visual field of the line camera; the linear array camera is used for acquiring continuous image data of the first shot target and the second shot target according to a preset focusing step length and a focusing search direction under the control of the camera adjusting mechanism;
the image processing device is used for processing the continuous image data, obtaining a first-order difference of gray values of images of a first shot target and a second shot target, determining a focusing window according to the first-order difference of the gray values of the images of the first shot target and the second shot target, processing the continuous image data collected in the focusing window to obtain an out-of-focus evaluation value of the images, and controlling the camera adjusting mechanism to adjust the linear array camera according to the out-of-focus evaluation value until a lens of the linear array camera is located at an in-focus position for a global view.
2. The system according to claim 1, wherein the image processing means is configured to set a position area between two inflection points of the first difference of the image gradation value of the first subject as a focusing window of the first subject, and set a position area between two inflection points of the first difference of the image gradation value of the second subject as a focusing window of the second subject.
3. The system according to claim 1, wherein the image processing device is further configured to calculate a continuous first subject target defocus degree evaluation value and a continuous second subject target defocus degree evaluation value respectively according to continuous image data collected in the focusing window, determine whether focusing is required, and control the camera adjustment mechanism to adjust the line camera until the lens of the line camera is located at a forward focus position for a global field of view according to the continuous first subject target defocus degree evaluation value and the continuous second subject target defocus degree evaluation value when determining that focusing is required.
4. The system according to claim 3, wherein focusing is determined to be unnecessary when the first and second photographic target defocus evaluation values at the position of the lens of the line camera are close to equal to each other, i.e., the difference between the first and second photographic target defocus evaluation values is within 3%, and are peak values.
5. The system according to claim 4, wherein the image processing device is configured to determine an angle adjustment direction between a plane where the lens of the line camera is located and the detection plane according to the timing of occurrence of peaks of the consecutive first and second defocus evaluation values, and control the camera adjustment mechanism to adjust the corresponding angle according to a preset angle step;
the image processing device is further used for controlling continuous acquisition of continuous image data of the first photographic target and the second photographic target according to a preset image distance step length after angle adjustment, adjusting the angle of the linear camera lens according to continuous first photographic target defocus degree evaluation value and second photographic target defocus degree evaluation value again until the search of the angle adjustment range is finished, and determining the positions of the first photographic target defocus degree evaluation value and the second photographic target defocus degree evaluation value which are close to equal and are peak values as the positive focal positions;
the detection plane is a plane where the first shot target and the second shot target are located.
6. The system according to claim 3 or 5, wherein the first photographic target defocus degree evaluation value is expressed by the following formula:
Figure DEST_PATH_IMAGE001
wherein,
Figure 742916DEST_PATH_IMAGE002
as the first photographic target defocus degree evaluation value,
Figure DEST_PATH_IMAGE003
the resolution of the representation of the image is,
Figure 339683DEST_PATH_IMAGE004
representing the gray-scale values of the pixels of the image,
Figure DEST_PATH_IMAGE005
a line segment function composed of two inflection points representing the first-order difference of the gray value of the first shot target image;
the second photographic target defocus degree evaluation value is expressed by the following formula:
Figure 57103DEST_PATH_IMAGE006
wherein,
Figure DEST_PATH_IMAGE007
as the second photographic target defocus degree evaluation value,
Figure 668957DEST_PATH_IMAGE008
the resolution of the representation of the image is,
Figure DEST_PATH_IMAGE009
representing the gray-scale values of the pixels of the image,
Figure 155433DEST_PATH_IMAGE010
and a line segment function consisting of two inflection points representing the first order difference of the gray values of the second subject image.
7. The system according to claim 5, wherein with a first subject on the left and a second subject on the right as a reference, if the peak value of the first subject defocus degree evaluation value appears earlier than the peak value of the second subject defocus degree evaluation value, the angle adjustment direction is determined to be clockwise;
and if the peak value of the second shooting target defocus evaluation value appears before the peak value of the first shooting target defocus evaluation value, determining that the angle adjustment direction is anticlockwise.
8. The system of claim 5, wherein the camera adjustment mechanism comprises a first stepper motor and a second stepper motor; the first stepping motor is used for adjusting the angle between the plane where the lens of the linear array camera is located and the detection plane according to a preset angle step;
and the second stepping motor is used for adjusting the image distance of the linear array camera according to a preset image distance step length.
9. The system according to claim 8, wherein the image processing apparatus is further configured to record a first subject defocus evaluation value and a second subject defocus evaluation value of each successive image data sampling point by a least square method, perform curve fitting with the positions of the corresponding first stepping motor and second stepping motor, and determine a position where the peak values of the first subject defocus evaluation value and the second subject defocus evaluation value are approximately equal and appear at the time of angle adjustment and image distance adjustment as the best positive focus position.
10. An autofocus method for a line camera employing the system of any of claims 1 to 9, comprising:
the linear array camera acquires continuous image data of the first shot target and the second shot target according to a preset focusing step length and a focusing search direction under the control of the camera adjusting mechanism;
the image processing device processes the continuous image data to obtain a first-order difference of gray values of a first shot target and a second shot target image, determines a focusing window according to the first-order difference of the gray values of the first shot target and the second shot target image, processes the continuous image data collected in the focusing window to obtain an evaluation value of the defocusing degree of the image, and controls the camera adjusting mechanism to adjust the linear array camera according to the evaluation value of the defocusing degree until a lens of the linear array camera is located at a forward focus position for a global view.
CN202111354772.1A 2021-11-16 2021-11-16 Automatic focusing system and method for linear array camera Active CN113805304B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111354772.1A CN113805304B (en) 2021-11-16 2021-11-16 Automatic focusing system and method for linear array camera

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111354772.1A CN113805304B (en) 2021-11-16 2021-11-16 Automatic focusing system and method for linear array camera

Publications (2)

Publication Number Publication Date
CN113805304A CN113805304A (en) 2021-12-17
CN113805304B true CN113805304B (en) 2022-03-18

Family

ID=78898690

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111354772.1A Active CN113805304B (en) 2021-11-16 2021-11-16 Automatic focusing system and method for linear array camera

Country Status (1)

Country Link
CN (1) CN113805304B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TWI815584B (en) * 2022-07-28 2023-09-11 大陸商業成科技(成都)有限公司 Lens focusing method and system performing the same

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102724401A (en) * 2012-05-18 2012-10-10 深圳大学 System and method of linear array CCD camera multi-point automatic focusing
CN113313711A (en) * 2021-07-29 2021-08-27 浙江双元科技股份有限公司 Camera, system and detection method for detecting width of lithium battery pole piece

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102595049B (en) * 2012-03-16 2014-11-26 盛司潼 Automatic focusing control system and method
CN105072330B (en) * 2015-07-17 2019-01-11 电子科技大学 A kind of automatic focusing method of line-scan digital camera
JP6745152B2 (en) * 2016-07-01 2020-08-26 株式会社ニューフレアテクノロジー Focusing device, focusing method, and pattern inspection method
CN108345085A (en) * 2017-01-25 2018-07-31 广州康昕瑞基因健康科技有限公司 Focus method and focusing system
JP2019068342A (en) * 2017-10-04 2019-04-25 キヤノン株式会社 Image processing apparatus, imaging apparatus, image processing method, program, and storage medium
JP7337562B2 (en) * 2019-06-25 2023-09-04 キヤノン株式会社 IMAGE PROCESSING DEVICE, IMAGING DEVICE, CONTROL METHOD FOR IMAGE PROCESSING DEVICE, AND PROGRAM
CN112995521B (en) * 2021-04-21 2021-07-30 征图新视(江苏)科技股份有限公司 High-precision automatic focusing method for line scan cameras based on sinusoidal fringes

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102724401A (en) * 2012-05-18 2012-10-10 深圳大学 System and method of linear array CCD camera multi-point automatic focusing
CN113313711A (en) * 2021-07-29 2021-08-27 浙江双元科技股份有限公司 Camera, system and detection method for detecting width of lithium battery pole piece

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TWI815584B (en) * 2022-07-28 2023-09-11 大陸商業成科技(成都)有限公司 Lens focusing method and system performing the same

Also Published As

Publication number Publication date
CN113805304A (en) 2021-12-17

Similar Documents

Publication Publication Date Title
KR101415872B1 (en) METHOD AND APPARATUS FOR AUTO-FOCUS ADJUSTMENT
JP4858263B2 (en) 3D measuring device
CN111083365B (en) Method and device for rapidly detecting optimal focal plane position
JP4957134B2 (en) Distance measuring device
US8773529B2 (en) Projector with automatic focusing and illustration procedure
US8064761B2 (en) Method to determine auto focus of a digital camera
US6023056A (en) Scene-based autofocus method
CN109883391B (en) Monocular distance measurement method based on digital imaging of microlens array
KR101774167B1 (en) Focus position detection device, focus position detection method, and computer program for focus position detection
EP2795890A1 (en) Method and system for image centering during zooming
CN111970500A (en) Automatic distance step calibration method and system for projection equipment
CN114913171B (en) Image defocus detection method, device, electronic device and storage medium
CN112461853B (en) Automatic focusing method and system
CN113805304B (en) Automatic focusing system and method for linear array camera
JP4334784B2 (en) Autofocus device and imaging device using the same
CN112839168B (en) Method for automatically adjusting camera imaging resolution in AOI detection system
JP2015152749A (en) Imaging device and control method of the same
JP3058781B2 (en) Focusing point detection method
CN110440712B (en) Self-adaptive large-field-depth three-dimensional scanning method and system
JP5454392B2 (en) Ranging device and imaging device
JP2014095631A (en) Three-dimensional measurement device and three-dimensional measurement method
CN116320748A (en) Automatic focusing method and device, electronic equipment and automatic optical detection equipment
JP2605004B2 (en) Automatic tracking device in camera
JP4598372B2 (en) 3D field for calibration, 3D field for calibration
JPH0252204A (en) Measuring instrument for three-dimensional coordinate

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant