Method and system for dynamically adjusting focal length of industrial camera
By constructing a height surface model using the NURBS surface fitting algorithm, the problem of image blurring caused by fixed focal length in LED motherboard inspection by industrial cameras is solved, enabling efficient and precise adjustment of the focal length and ensuring clear imaging in all fields of view.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- GUANGDONG LAB OF ARTIFICIAL INTELLIGENCE & DIGITAL ECONOMY (SZ)
- Filing Date
- 2025-12-05
- Publication Date
- 2026-04-21
AI Technical Summary
In existing technologies, industrial cameras used for LED motherboard inspection suffer from localized unevenness due to fixed focal length, resulting in blurred images and affecting the accuracy of inspection results. Furthermore, existing methods are either inefficient or lack precision.
A height surface model is constructed using a non-uniform rational B-spline NURBS surface fitting algorithm. Based on the ranging coordinate information, the focal length-height correlation is dynamically adjusted. The overall field of view height is fitted and the focal length is adjusted by selecting the ranging field of view area.
It improves the efficiency and accuracy of focus adjustment, ensuring clear imaging in all fields of view and meeting the testing requirements of mass production.
Smart Images

Figure CN121908130A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of machine vision technology, and in particular to a method and system for dynamically adjusting the focal length of an industrial camera. Background Technology
[0002] In the mass production and inspection of LED chips, industrial cameras are needed to capture images of multiple fields of view on the LED motherboard, and then algorithms are used to identify chip defects. In existing technologies, industrial cameras typically use fixed focal length shooting, that is, a single focal length parameter is preset to uniformly image all fields of view of the entire LED motherboard.
[0003] However, LED motherboards are prone to unevenness during processing, transportation, or installation due to stress release and material deformation. When shooting with a fixed focal length, only a portion of the field of view can be imaged clearly; the remaining fields of view suffer from image blurring and loss of detail due to the mismatch between actual height and focal length. This difference in image quality directly leads to misjudgments or incorrect assessments by defect detection algorithms, severely affecting the accuracy of detection results. To improve the current problem of height-focal-length mismatch, methods such as adjusting the distance for each field of view or fixing the focal length in sections are commonly used. However, adjusting the distance for each field of view requires excessive time, which cannot meet the efficiency requirements of mass production. While fixing the focal length in sections improves efficiency, height differences still exist within the field of view, failing to resolve the image blurring caused by local unevenness. Summary of the Invention
[0004] The purpose of this invention is to overcome the shortcomings of the prior art. This invention provides a method and system for dynamic focal length adjustment of industrial cameras, which can improve the efficiency of focal length adjustment, ensure accurate focal length adjustment of industrial cameras, and clear imaging of all fields of view.
[0005] To address the aforementioned technical problems, this invention provides a method for dynamically adjusting the focal length of an industrial camera, the method comprising: The detection area of the LED motherboard to be tested is divided into several field-of-view areas; Select several ranging field-of-view areas from all the fields of view and determine the ranging coordinate information of each ranging field-of-view area; Based on the ranging coordinate information, a height surface model is constructed using a non-uniform rational B-spline NURBS surface fitting algorithm. Based on the coordinate information of each field of view region, the height curve model is used to perform height fitting to obtain the fitted height of each field of view region. A focal length-height correlation is established, and the target focal length of the industrial camera is determined based on the focal length-height correlation and the fitted height.
[0006] Optionally, dividing the detection area of the LED motherboard to be tested into several field-of-view regions includes: Acquire the field of view information of a single shot from an industrial camera, and determine the number of regions to be divided based on the single field of view information. Based on the number of regions, the detection area of the LED motherboard to be tested is divided into several field-of-view regions.
[0007] Optionally, the selection of several ranging field of view areas across all fields of view includes: Set up several edge views, and determine the longitudinal step size and the lateral step size based on the edge views; Based on the aforementioned longitudinal and lateral step sizes, several ranging field of view regions are selected across all fields of view.
[0008] Optionally, the step of constructing a height surface model based on the ranging coordinate information using a non-uniform rational B-spline NURBS surface fitting algorithm includes: The ranging coordinate information is mapped to a two-dimensional parameter domain to obtain coordinate parameter values; Based on preset constraints, node vectors are generated from the coordinate parameter values to obtain the target node vectors. Based on the target node vector, the three-dimensional coordinates of the control vertex and the corresponding weight factor of the control vertex are determined using a system of linear equations; Based on the target node vector, construct p-order B-spline basis functions in the u-direction and q-order B-spline basis functions in the v-direction. Based on the target node vector, the p-order B-spline basis functions in the u-direction and q-order B-spline basis functions in the v-direction, the three-dimensional coordinates of the control vertices, and the weight factors corresponding to the control vertices, construct a height surface model.
[0009] Optionally, the expression for the u-direction p-order B-spline basis function is: , in, Let u be the p-th order B-spline basis function. , , , and For different u-direction node vectors, Let u be the basis function of the i-th P-1 degree B-spline. Let u be the (i+1)th P-1 degree B-spline basis function in the direction of u.
[0010] Optionally, the expression for the height surface model is: , in, For points on the surface, Let u be the p-th order B-spline basis function. Let m be the number of target node vectors in the u direction, n be the number of target node vectors in the v direction, u be the target node vector in the u direction, and v be the target node vector in the v direction. To control the weight factors corresponding to the vertices, The control mesh is generated based on the three-dimensional coordinates of the control vertices.
[0011] Optionally, the step of using the height curve model to perform height fitting based on the coordinate information of each visual field region to obtain the fitted height of each visual field region includes: The coordinate information of each field of view is linearly transformed to obtain the linearly transformed coordinate information of each field of view. The linearly transformed coordinate information is input into the height curve model for height fitting to obtain the fitted height of each field of view area.
[0012] Optionally, the step of constructing a focal length-height correlation and determining the target focal length of the industrial camera based on the focal length-height correlation and the fitted height includes: The relationship between height and focal length is derived based on the Gaussian lens formula, thus obtaining the theoretical relationship between height and focal length. Based on the theoretical relationship and experimental data, a relationship model is fitted to obtain the target relationship model, and the focal length-height correlation is determined based on the target relationship model. Based on the focal length-height correlation, a target focal length corresponding to the fitted height is matched and fitted, and a focusing command is generated based on the target focal length. The industrial camera adjusts the focal length based on the focusing command, and captures LED motherboard images in each field of view based on the industrial camera with the adjusted focal length.
[0013] Optionally, after the industrial camera with adjusted focus captures images of the LED motherboard in each field of view, it further includes: The LED motherboard images of each field of view are preprocessed to obtain preprocessed LED motherboard images; Edge gradient information of the preprocessed LED motherboard image is extracted based on the edge detection operator; Sharpness quantification is performed based on the edge gradient information to obtain the sharpness information of each LED motherboard image; Image clarity is determined based on the sharpness information of each LED motherboard image.
[0014] In addition, the present invention also provides a dynamic focal length adjustment system for an industrial camera, the system comprising: Region division module: used to divide the detection area of the LED motherboard to be tested into several field of view regions; Distance Coordinate Determination Module: Used to select several distance measurement field of view areas in all field of view areas and determine the distance measurement coordinate information of each distance measurement field of view area; Model building module: used to build a height surface model based on the ranging coordinate information using a non-uniform rational B-spline NURBS surface fitting algorithm; Height Fitting Module: Used to perform height fitting based on the coordinate information of each field of view using the height curve model, and obtain the fitted height of each field of view; Focal length determination module: used to construct a focal length-height correlation and determine the target focal length of the industrial camera based on the focal length-height correlation and the fitted height.
[0015] In this embodiment of the invention, the detection area of the LED motherboard to be tested is divided into several field-of-view regions. Several ranging field-of-view regions are selected from all these regions, and the ranging coordinate information of each region is determined. Based on the ranging coordinate information, a height surface model is constructed using a NURBS surface fitting algorithm. Based on the coordinate information of each field-of-view region, a height curve model is used for height fitting to obtain the fitted height of each region. The target focal length of the industrial camera is determined based on the focal length-height correlation and the fitted height. The NURBS surface fitting algorithm has the ability to smooth out local height anomalies, avoiding focusing deviations caused by ranging errors in a single field of view. It eliminates the need to measure the distance of each field of view individually; instead, it only requires constructing a model based on the coordinates of the selected ranging field-of-view regions to fit the overall height of the field of view. This improves the efficiency of focal length adjustment, ensures accurate focal length adjustment of the industrial camera, and guarantees clear imaging across all fields of view. Attached Figure Description
[0016] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1 This is a flowchart illustrating the dynamic focal length adjustment method for an industrial camera according to an embodiment of the present invention. Figure 2 This is a flowchart illustrating a method for dynamically adjusting the focal length of an industrial camera according to another embodiment of the present invention. Figure 3 This is a schematic diagram of the structural composition of the dynamic focal length adjustment system for an industrial camera in an embodiment of the present invention; Figure 4 This is a schematic diagram comparing the actual height data and the fitted height data in an embodiment of the present invention. Detailed Implementation
[0018] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0019] Example 1 Please see Figure 1 , Figure 1 This is a flowchart illustrating the dynamic focal length adjustment method for an industrial camera according to an embodiment of the present invention. The method includes: S11: Divide the detection area of the LED motherboard to be tested into several viewing areas; In the specific implementation of this invention, the field of view information of a single shot of an industrial camera is obtained, and the number of regions is determined based on the single shot field of view information; based on the number of regions, the detection area of the main board of the light-emitting diode (LED) to be tested is divided into several field of view regions, so that the size of each field of view matches the field of view of a single shot of the industrial camera, thereby improving the clarity of the field of view imaging.
[0020] S12: Select several ranging field of view areas in all fields of view areas, and determine the ranging coordinate information of each ranging field of view area; In the specific implementation of this invention, several edge views are set, and the longitudinal step size and the lateral step size are determined based on the edge views. Based on the longitudinal step size and the lateral step size, several ranging view areas are selected in all view areas, and the ranging coordinate information of each ranging view area is determined. It is not necessary to measure the distance of each view individually, which can shorten the ranging time.
[0021] S13: Construct a height surface model based on the distance measurement coordinate information using the NURBS surface fitting algorithm; In the specific implementation of this invention, the ranging coordinate information is mapped to a two-dimensional parameter domain to obtain coordinate parameter values; node vectors are generated based on preset constraints to obtain target node vectors; the three-dimensional coordinates of the control vertex and the corresponding weight factors of the control vertex are determined using interpolation and linear equations based on the target node vectors; u-direction p-order B-spline basis functions and v-direction q-order B-spline basis functions are constructed based on the target node vectors, and a height surface model is constructed based on the target node vectors, u-direction p-order B-spline basis functions and v-direction q-order B-spline basis functions, the three-dimensional coordinates of the control vertex, and the corresponding weight factors of the control vertex. A non-uniform rational B-spline (NURBS) surface fitting algorithm is used, and ranging is performed only within the selected ranging field of view area to achieve overall field of view height fitting, ensuring accurate focal length adjustment of the industrial camera and clear imaging of all fields of view.
[0022] S14: Based on the coordinate information of each field of view region, the height curve model is used to perform height fitting to obtain the fitted height of each field of view region; In the specific implementation of this invention, the coordinate information of each field of view is linearly transformed to obtain the linearly transformed coordinate information of each field of view; the linearly transformed coordinate information is input into the height curve model for height fitting to obtain the fitted height of each field of view, making the obtained fitted height more accurate.
[0023] S15: Construct a focal length-height correlation and determine the target focal length of the industrial camera based on the focal length-height correlation and the fitted height.
[0024] In the specific implementation of this invention, the relationship between height and focal length is derived based on the Gaussian lens formula to obtain the theoretical relationship between height and focal length; based on the theoretical relationship and experimental data, a relationship model is fitted to obtain a target relationship model, and the focal length-height correlation is determined based on the target relationship model; based on the focal length-height correlation, a target focal length corresponding to the fitted height is matched, and a focusing command is generated based on the target focal length; the industrial camera adjusts its focal length based on the focusing command, and the industrial camera captures images of the LED motherboard in each field of view based on the focal length adjustment, realizing the rapid and accurate calculation of the height of all fields of view, and then dynamically adjusting the focal length of the industrial camera to ensure clear imaging of all fields of view, while taking into account both detection efficiency and accuracy.
[0025] In this embodiment of the invention, the detection area of the LED motherboard to be tested is divided into several field-of-view regions. Several ranging field-of-view regions are selected from all these regions, and the ranging coordinate information of each region is determined. Based on the ranging coordinate information, a height surface model is constructed using a NURBS surface fitting algorithm. Based on the coordinate information of each field-of-view region, a height curve model is used for height fitting to obtain the fitted height of each region. The target focal length of the industrial camera is determined based on the focal length-height correlation and the fitted height. The NURBS surface fitting algorithm has the ability to smooth out local height anomalies, avoiding focusing deviations caused by ranging errors in a single field of view. It eliminates the need to measure the distance of each field of view individually; instead, it only requires constructing a model based on the coordinates of the selected ranging field-of-view regions to fit the overall height of the field of view. This improves the efficiency of focal length adjustment, ensures accurate focal length adjustment of the industrial camera, and guarantees clear imaging across all fields of view.
[0026] Example 2 Please see Figure 2 , Figure 2 This is a flowchart illustrating a method for dynamically adjusting the focal length of an industrial camera according to another embodiment of the present invention, the method comprising: S201: Divide the detection area of the LED motherboard to be tested into several viewing areas; In the specific implementation of this invention, dividing the detection area of the LED motherboard to be tested into several field of view areas includes: acquiring single-shot field of view information of an industrial camera, and determining the number of area divisions based on the single-shot field of view information; and dividing the detection area of the LED motherboard to be tested into several field of view areas based on the number of area divisions.
[0027] Specifically, the field of view information of a single shot from an industrial camera is obtained. This single-shot field of view information refers to the size of the field of view in a single shot by the industrial camera. Based on this single-shot field of view information, the number of regions to be divided is determined, that is, the number of evenly divided field of view regions is determined according to the single-shot field of view information. Based on the number of regions to be divided, the detection area of the LED motherboard to be tested is divided into several field of view regions, that is, the detection area of the LED motherboard to be tested is divided into several evenly distributed field of view regions.
[0028] S202: Select several ranging field of view areas in all fields of view areas, and determine the ranging coordinate information of each ranging field of view area; In the specific implementation of this invention, the step of selecting several ranging field of view areas in all field of view areas includes: setting several edge fields of view, and determining the longitudinal step size and the lateral step size based on the edge fields of view; and selecting several ranging field of view areas in all field of view areas based on the longitudinal step size and the lateral step size.
[0029] Specifically, several edge views can be set, including four edge views. The longitudinal and lateral step sizes are determined based on the edge views. To avoid singular values in the views, the longitudinal and lateral step sizes corresponding to the views can be appropriately moved away from the boundary by 1 to 2 rows / columns when selecting edge views. The specific step sizes can be dynamically configured in the control unit.
[0030] Based on the aforementioned longitudinal and lateral step sizes, several ranging field-of-view regions are selected from all fields of view. These ranging field-of-view regions are evenly distributed throughout the total field of view. For example, in a 30×50 field-of-view matrix, a ranging field-of-view region is selected every 7-8 fields of view to ensure coverage of the entire detection area. The ranging coordinate information of each ranging field-of-view region is determined, namely, the X-axis coordinate, Y-axis coordinate, and corresponding height of each ranging field-of-view region.
[0031] S203: Map the ranging coordinate information to a two-dimensional parameter domain to obtain coordinate parameter values; In the specific implementation of this invention, the ranging coordinate information is mapped to a two-dimensional parameter domain to obtain coordinate parameter values. That is, the ranging coordinates are mapped to the two-dimensional parameter domain (u, v), and parameter values are assigned to each coordinate data point. Uniform parameterization, chord length parameterization, centripetal parameterization, etc., can be used, and the appropriate method must be selected based on the data distribution.
[0032] S204: Generate a node vector from the coordinate parameter values based on preset constraints to obtain the target node vector; In the specific implementation of this invention, the preset constraint condition can be: number of nodes = number of control vertices + number of times + 1. Based on the preset constraint condition, node vectors are generated for the coordinate parameter values. According to the preset constraint condition, node vectors in the u direction and node vectors in the v direction are generated for the coordinate parameter values respectively, thus obtaining the target node vector.
[0033] S205: Based on the target node vector, use a system of linear equations to determine the three-dimensional coordinates of the control vertex and the weight factor corresponding to the control vertex; In the specific implementation of this invention, the three-dimensional coordinates of the control vertices and the weight factors corresponding to the control vertices are determined by using a system of linear equations based on the target node vector. A system of linear equations of the target node vector and the surface equations can be established based on the least squares principle. By solving the system of linear equations, the three-dimensional coordinates of the control vertices and the weight factors corresponding to each control vertex can be obtained.
[0034] S206: Construct a p-order B-spline basis function in the u direction and a q-order B-spline basis function in the v direction based on the target node vector, and construct a height surface model based on the target node vector, the p-order B-spline basis function in the u direction and the q-order B-spline basis function in the v direction, the three-dimensional coordinates of the control vertex and the weight factor corresponding to the control vertex; In the specific implementation of this invention, the expression for the u-direction p-order B-spline basis function is: , in, Let u be the p-th order B-spline basis function. , , , and For different u-direction node vectors, Let u be the basis function of the i-th P-1 degree B-spline. Let u be the (i+1)th P-1 degree B-spline basis function in the direction of u.
[0035] The expression for the height surface model is: , in, For points on the surface, Let u be the p-th order B-spline basis function. Let m be the number of target node vectors in the u direction, n be the number of target node vectors in the v direction, u be the target node vector in the u direction, and v be the target node vector in the v direction. To control the weight factors corresponding to the vertices, The control mesh is generated based on the three-dimensional coordinates of the control vertices.
[0036] Specifically, NURBS curves, by controlling vertices and weights, can accurately represent complex curve and surface shapes, making them suitable for modeling real-world objects and smoothly fitting data points. Based on the target node vector, u-direction p-order B-spline basis functions and v-direction q-order B-spline basis functions are constructed. The spline basis functions are the core components of B-spline curves, defined by node vectors and recursive formulas, possessing local support and piecewise polynomial properties. The local support of the basis functions ensures that adjusting a single control point only affects a local curve segment, while the continuity of the basis functions guarantees smooth curve connections at nodes. The expression for the u-direction p-order B-spline basis function is: , in, Let u be the p-th order B-spline basis function. , , , and For different u-direction node vectors, Let u be the basis function of the i-th P-1 degree B-spline. Let u be the (i+1)th P-1 degree B-spline basis function in the direction of u.
[0037] Based on the target node vector, the p-order B-spline basis function in the u direction and the q-order B-spline basis function in the v direction, the three-dimensional coordinates of the control vertices and the weight factors corresponding to the control vertices, a height surface model is constructed. The expression of the height surface model is as follows: , in, For points on the surface, Let u be the p-th order B-spline basis function. Let m be the number of target node vectors in the u direction, n be the number of target node vectors in the v direction, u be the target node vector in the u direction, and v be the target node vector in the v direction. To control the weight factors corresponding to the vertices, This is a control mesh generated based on the three-dimensional coordinates of the control vertices. The NURBS surface fitting algorithm provides smoothing capabilities for local height anomalies (such as small protrusions on the motherboard), avoiding focusing deviations caused by single-view ranging errors and improving the stability of the detection results.
[0038] S207: Based on the coordinate information of each field of view region, the height curve model is used to perform height fitting to obtain the fitted height of each field of view region; In the specific implementation of this invention, the coordinate information of each field of view is linearly transformed to obtain the linearly transformed coordinate information of each field of view; the linearly transformed coordinate information is input into the height curve model for height fitting to obtain the fitted height of each field of view.
[0039] Specifically, the coordinate information of each field of view region is linearly transformed, which maps the coordinate information of each field of view region to a two-dimensional parameter domain (u, v), and assigns parameter values to each coordinate data point. Uniform parameterization, chord length parameterization, and centripetal parameterization can be used, and the choice should be made based on the data distribution to obtain the linearly transformed coordinate information of each field of view region.
[0040] The linearly transformed coordinate information is input into the height curve model for height fitting to obtain the fitted height for each field of view region. Using NURBS surface fitting, the overall field of view height can be fitted simply through field-of-view distance measurement. Figure 4 As shown, by comparing the actual height data and the fitted height data, it can be seen that the deviation between the fitted field of view height and the actual field of view height is less than 0.1%, ensuring that the focal length of the industrial camera is accurately adjusted, all fields of view are clearly imaged, and the image resolution can meet the defect detection requirements, such as pixel size ≤10μm.
[0041] S208: Construct a focal length-height correlation and determine the target focal length of the industrial camera based on the focal length-height correlation and the fitted height.
[0042] In the specific implementation of this invention, the construction of the focal length-height correlation relationship and the determination of the target focal length of the industrial camera based on the focal length-height correlation relationship and the fitted height include: deriving the relationship between height and focal length based on the Gaussian lens formula to obtain the theoretical relationship between height and focal length; fitting a relationship model based on the theoretical relationship and experimental data to obtain a target relationship model, and determining the focal length-height correlation relationship based on the target relationship model; matching the target focal length corresponding to the fitted height based on the focal length-height correlation relationship, and generating a focusing command based on the target focal length; the industrial camera adjusting the focal length based on the focusing command; and capturing LED motherboard images in each field of view based on the industrial camera with the adjusted focal length.
[0043] Specifically, based on the Gaussian lens formula, the relationship between height and focal length is derived, obtaining the theoretical relationship between them. The Gaussian lens formula is: , Where u is the object distance (height) and v is the image distance; when the camera sensor is fixed, v is a constant.
[0044] Based on the theoretical relationship and experimental data, a relationship model is fitted to obtain a target relationship model. The focal length-height correlation is determined based on the target relationship model. The focal length is adjusted to obtain a clear image at a known height. Multiple sets of experimental data are recorded. The actual corresponding relationship model is obtained by fitting the theoretical relationship. The correlation between focal length and height is determined by this relationship model.
[0045] Based on the focal length-height correlation, a target focal length corresponding to the fitted height is matched. That is, the target focal length corresponding to the fitted height is matched in the focal length-height correlation, and a focusing command is generated based on the target focal length. The control unit sends the focusing command to the industrial camera, and the industrial camera adjusts the focal length based on the focusing command. Based on the focal length adjustment, the industrial camera captures LED motherboard images in each field of view area.
[0046] Furthermore, after the industrial camera with adjusted focal length captures LED motherboard images in each field of view, the process further includes: preprocessing the LED motherboard images in each field of view to obtain preprocessed LED motherboard images; extracting edge gradient information of the preprocessed LED motherboard images based on an edge detection operator; performing sharpness quantification based on the edge gradient information to obtain sharpness information of each LED motherboard image; and judging image clarity based on the sharpness information of each LED motherboard image.
[0047] Specifically, after capturing images of the LED motherboard, the sharpness of each image can be assessed to verify the effect. Preprocessing is performed on the LED motherboard images of each field of view, including grayscale conversion to obtain grayscale LED motherboard images. Grayscale conversion reduces computational load. A Gaussian filter is then used to perform mild denoising on the grayscale LED motherboard images, preserving edge information while avoiding noise interference with edge detection. After this mild denoising, the image preprocessing is complete, yielding the preprocessed LED motherboard image.
[0048] Edge gradient information of the preprocessed LED motherboard image is extracted based on edge detection operators. The Sobel operator can be used to calculate the horizontal / vertical gradients of the image, thus obtaining edge gradient information. The Sobel operator is a commonly used edge detection tool in image processing, capable of calculating the gradients in both the horizontal and vertical directions. A 3×3 convolution kernel is used to calculate the weighted difference between adjacent pixels to determine the horizontal gradient. The 3×3 convolution kernel enables fast computation; the algorithm is simple and fast, suitable for real-time applications. The vertical gradient calculation is similar to the horizontal calculation, but the kernel weights are adjusted to the vertical direction. The Sobel operator effectively reduces noise interference in edge detection, making it particularly suitable for processing images with grayscale gradients and high noise levels.
[0049] Sharpness is quantified based on the edge gradient information. A gradient threshold is set, and the edge gradient information is compared with the gradient threshold. Pixels with gradient values higher than the threshold are selected as valid edge pixels, which can eliminate interference from smooth areas. The average, sum, or variance of the gradient amplitudes of the selected valid edge pixels are calculated as the image sharpness value, thus obtaining the sharpness information of each LED motherboard image. Image clarity is judged based on the sharpness information of each LED motherboard image, that is, the sharpness information is compared with a preset threshold to determine whether each LED motherboard image is clear. If there is a problem with blurriness, the focus can be readjusted in the field of view.
[0050] In this embodiment of the invention, the detection area of the LED motherboard to be tested is divided into several field-of-view regions. Several ranging field-of-view regions are selected from all these regions, and the ranging coordinate information of each region is determined. Based on the ranging coordinate information, a height surface model is constructed using a NURBS surface fitting algorithm. Based on the coordinate information of each field-of-view region, a height curve model is used for height fitting to obtain the fitted height of each region. The target focal length of the industrial camera is determined based on the focal length-height correlation and the fitted height. The NURBS surface fitting algorithm has the ability to smooth out local height anomalies, avoiding focusing deviations caused by ranging errors in a single field of view. It eliminates the need to measure the distance of each field of view individually; instead, it only requires constructing a model based on the coordinates of the selected ranging field-of-view regions to fit the overall height of the field of view. This improves the efficiency of focal length adjustment, ensures accurate focal length adjustment of the industrial camera, and guarantees clear imaging across all fields of view.
[0051] Example 3 Please see Figure 3 , Figure 3 This is a schematic diagram of the structural composition of the industrial camera's dynamic focal length adjustment system according to an embodiment of the present invention. The system includes: Region division module 31: used to divide the detection area of the LED motherboard to be tested into several field of view areas; Distance coordinate determination module 32: used to select several distance measurement field of view areas in all field of view areas and determine the distance measurement coordinate information of each distance measurement field of view area; Model building module 33: used to build a height surface model based on the ranging coordinate information using a non-uniform rational B-spline NURBS surface fitting algorithm; Height fitting module 34: used to perform height fitting based on the coordinate information of each field of view using the height curve model, and obtain the fitted height of each field of view; Focal length determination module 35: used to construct a focal length-height correlation relationship and determine the target focal length of the industrial camera based on the focal length-height correlation relationship and the fitted height.
[0052] In the specific implementation of this invention, the specific implementation methods of the system items can be referred to the implementation methods of the above-mentioned method items, and will not be repeated here.
[0053] In this embodiment of the invention, the detection area of the LED motherboard to be tested is divided into several field-of-view regions. Several ranging field-of-view regions are selected from all these regions, and the ranging coordinate information of each region is determined. Based on the ranging coordinate information, a height surface model is constructed using a NURBS surface fitting algorithm. Based on the coordinate information of each field-of-view region, a height curve model is used for height fitting to obtain the fitted height of each region. The target focal length of the industrial camera is determined based on the focal length-height correlation and the fitted height. The NURBS surface fitting algorithm has the ability to smooth out local height anomalies, avoiding focusing deviations caused by ranging errors in a single field of view. It eliminates the need to measure the distance of each field of view individually; instead, it only requires constructing a model based on the coordinates of the selected ranging field-of-view regions to fit the overall height of the field of view. This improves the efficiency of focal length adjustment, ensures accurate focal length adjustment of the industrial camera, and guarantees clear imaging across all fields of view.
[0054] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, which may include: read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0055] Furthermore, the above provides a detailed description of the method and system for dynamic focal length adjustment of an industrial camera provided by the embodiments of the present invention. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. A method for dynamically adjusting the focal length of an industrial camera, characterized in that, The method includes: The detection area of the LED motherboard to be tested is divided into several field-of-view areas; Select several ranging field-of-view areas from all the fields of view and determine the ranging coordinate information of each ranging field-of-view area; Based on the ranging coordinate information, a height surface model is constructed using a non-uniform rational B-spline NURBS surface fitting algorithm. Based on the coordinate information of each field of view region, the height curve model is used to perform height fitting to obtain the fitted height of each field of view region. A focal length-height correlation is established, and the target focal length of the industrial camera is determined based on the focal length-height correlation and the fitted height.
2. The method for dynamically adjusting the focal length of an industrial camera according to claim 1, characterized in that, The process of dividing the detection area of the LED motherboard under test into several field-of-view regions includes: Acquire the field of view information of a single shot from an industrial camera, and determine the number of regions to be divided based on the single field of view information. Based on the number of regions, the detection area of the LED motherboard to be tested is divided into several field-of-view regions.
3. The method for dynamically adjusting the focal length of an industrial camera according to claim 1, characterized in that, The selection of several ranging field-of-view regions across all fields of view includes: Set up several edge views, and determine the longitudinal step size and the lateral step size based on the edge views; Based on the aforementioned longitudinal and lateral step sizes, several ranging field of view regions are selected across all fields of view.
4. The method for dynamically adjusting the focal length of an industrial camera according to claim 1, characterized in that, The construction of a height surface model based on the ranging coordinate information using a non-uniform rational B-spline NURBS surface fitting algorithm includes: The ranging coordinate information is mapped to a two-dimensional parameter domain to obtain coordinate parameter values; Based on preset constraints, node vectors are generated from the coordinate parameter values to obtain the target node vectors. Based on the target node vector, the three-dimensional coordinates of the control vertex and the corresponding weight factor of the control vertex are determined using a system of linear equations; Based on the target node vector, construct p-order B-spline basis functions in the u-direction and q-order B-spline basis functions in the v-direction. Based on the target node vector, the p-order B-spline basis functions in the u-direction and q-order B-spline basis functions in the v-direction, the three-dimensional coordinates of the control vertices, and the weight factors corresponding to the control vertices, construct a height surface model.
5. The method for dynamically adjusting the focal length of an industrial camera according to claim 4, characterized in that, The expression for the u-direction p-order B-spline basis function is: , in, Let u be the p-th order B-spline basis function. , , , and For different u-direction node vectors, Let u be the basis function of the i-th P-1 degree B-spline. Let u be the (i+1)th P-1 degree B-spline basis function in the direction of u.
6. The method for dynamically adjusting the focal length of an industrial camera according to claim 4, characterized in that, The expression for the height surface model is: , in, For a point on a curved surface, Let u be the p-th order B-spline basis function. Let m be the number of target node vectors in the u direction, n be the number of target node vectors in the v direction, u be the target node vector in the u direction, and v be the target node vector in the v direction. To control the weight factors corresponding to the vertices, The control mesh is generated based on the three-dimensional coordinates of the control vertices.
7. The method for dynamically adjusting the focal length of an industrial camera according to claim 1, characterized in that, The height fitting process, based on the coordinate information of each visual field region, utilizes the height curve model to obtain the fitted height for each visual field region, including: The coordinate information of each field of view is linearly transformed to obtain the linearly transformed coordinate information of each field of view. The linearly transformed coordinate information is input into the height curve model for height fitting to obtain the fitted height of each field of view area.
8. The method for dynamically adjusting the focal length of an industrial camera according to claim 1, characterized in that, The process of constructing a focal length-height correlation and determining the target focal length of the industrial camera based on the focal length-height correlation and the fitted height includes: The relationship between height and focal length is derived based on the Gaussian lens formula, thus obtaining the theoretical relationship between height and focal length. Based on the theoretical relationship and experimental data, a relationship model is fitted to obtain the target relationship model, and the focal length-height correlation is determined based on the target relationship model. Based on the focal length-height correlation, a target focal length corresponding to the fitted height is matched and fitted, and a focusing command is generated based on the target focal length. The industrial camera adjusts the focal length based on the focusing command, and captures LED motherboard images in each field of view based on the industrial camera with the adjusted focal length.
9. The method for dynamically adjusting the focal length of an industrial camera according to claim 8, characterized in that, After the industrial camera with adjusted focal length captures images of the LED motherboard in each field of view, it also includes: The LED motherboard images of each field of view are preprocessed to obtain preprocessed LED motherboard images; Edge gradient information of the preprocessed LED motherboard image is extracted based on the edge detection operator; Sharpness quantification is performed based on the edge gradient information to obtain the sharpness information of each LED motherboard image; Image clarity is determined based on the sharpness information of each LED motherboard image.
10. A dynamic focal length adjustment system for an industrial camera, characterized in that, The system includes: Region division module: used to divide the detection area of the LED motherboard to be tested into several field of view regions; Distance Coordinate Determination Module: Used to select several distance measurement field of view areas in all field of view areas and determine the distance measurement coordinate information of each distance measurement field of view area; Model building module: used to build a height surface model based on the ranging coordinate information using a non-uniform rational B-spline NURBS surface fitting algorithm; Height Fitting Module: Used to perform height fitting based on the coordinate information of each field of view using the height curve model, and obtain the fitted height of each field of view; Focal length determination module: used to construct a focal length-height correlation and determine the target focal length of the industrial camera based on the focal length-height correlation and the fitted height.