Dynamic focusing method based on industrial measurement system

By using computer vision technology to obtain the working distance and defocus distance of the measured target in an industrial measurement system, and dynamic focus adjustment is performed in combination with the principle of camera imaging, the problems of low autofocus efficiency and insufficient dynamic focus capability in the existing technology are solved, and the problem of low autofocus efficiency and insufficient dynamic focus capability is achieved. Efficient and real-time dynamic focus effect.

CN119485017AInactive Publication Date: 2025-02-18CHANGCHUN INST OF OPTICS FINE MECHANICS & PHYSICS CHINESE ACAD OF SCI

Patent Information

Application Number
CN202510027496.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-08
Publication Date
2025-02-18
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The existing automatic focus technology has problems such as inefficiency and inability to achieve dynamic focus in industrial measurement systems, resulting in insufficient real-time and dynamic focus capabilities.

Method used

The dynamic focus method based on the industrial measurement system is adopted to obtain the working distance and defocus distance of the measured target through computer vision technology, and the lens adjustment direction is judged based on the camera imaging principle, so as to realize real-time focus monitoring and dynamic adjustment.

Benefits of technology

It improves the real-time focus of the industrial measurement system, realizes dynamic focus capability, reduces the time consumption of the focus process, and improves the working efficiency of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119485017A_ABST
    Figure CN119485017A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of automatic focusing, and particularly relates to a dynamic focusing method based on an industrial measurement system. Comprising the following steps: S1, fixing a target on a measured target, and aligning a lens of an industrial measurement system with the measured target to obtain an image data set of the measured target; s2, sequentially inputting the detected target images into a target acquisition network to obtain a target image data set; s3, correspondingly calculating the working distance of the target relative to the camera based on the prediction frame of each target image; s4, all the target images are subjected to denoising and illumination normalization processing, and a processed target image data set is obtained; s5, predicting the predicted defocus distance of each processed target image by using a deep regression network; s6, performing static adjustment on the lens to obtain a clear first frame of target image; and S7, dynamically adjusting the lens according to the motion state of the target to be measured and the working distance of the target relative to the camera. The invention has the capability of dynamic focusing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of automatic focusing, and in particular relates to a dynamic focusing method based on an industrial measurement system. Background Art

[0002] In the field of vision-based industrial measurement, target contours are usually very important signal detection information. For many industrial measurement systems, identifying target contours is an important factor related to detection quality and accuracy. Therefore, many industrial measurement systems need to have autofocus functions.

[0003] Among the many autofocus methods, the traditional focusing method obtains a series of images with different clarity during the focusing process, and then uses the focus evaluation function to calculate the evaluation value to guide the focusing process, and then controls the stepper motor to drive the imaging lens to move and guide the lens to move to the quasi-focus position.

[0004] The traditional focusing method has the following problems: (1) If the search step size of the traditional focusing method is not selected well, the number of lens adjustments will increase, which will lead to a huge consumption of time in the autofocus process and reduce the real-time measurement performance of the industrial measurement system.

[0005] (2) The focus window extraction method of the traditional focusing method lacks universality and will increase the probability of focusing failure.

[0006] (3) Since the traditional focusing method requires the acquisition of multiple out-of-focus images, when the target moves, it is difficult for the traditional focusing method to complete dynamic monitoring and real-time adjustment of the focal plane of the target.

[0007] With the development of computer vision technology and embedded platforms, many solutions have been proposed at home and abroad to solve the problem of time-consuming autofocus.

[0008] The Chinese invention patent entitled "A camera autofocus method and camera based on multi-step parameter optimization" (publication number CN118018845A, publication date May 10, 2024) proposes a camera autofocus method based on multi-compensation optimization: this method constructs an autofocus model based on a focus data set, and obtains the total autofocus cost function according to the autofocus model; then establishes an evaluation function based on the total autofocus cost function of the autofocus model, and optimizes and iterates based on the optimization goal of minimizing the evaluation function to obtain the optimal step parameter of the autofocus model, and updates the autofocus model based on the optimal step parameter. The principle of this method is simple and easy to implement, but there are also some problems: (1) Although the time consumption of the fixed step strategy can be reduced by adaptive step size, multiple images still need to be collected. (2) Image clarity is easily affected by image content and external noise. Therefore, if the step size is judged multiple times according to the autofocus model, the judgment error will increase exponentially, eventually leading to focus failure.

[0009] The Chinese invention patent named "Autofocus method, microscope and computer-readable storage medium" (publication number CN117880627A, publication date April 12, 2024) proposes to obtain multiple images collected from the target area, select multiple candidate points on both sides of the first maximum value from the image clarity curve, and obtain candidate vectors; regress the candidate vectors to obtain a regression line; based on the second maximum value in the regression line, select the first image from the multiple images, and use the position of the first image as the focus position to achieve autofocus. This method performs autofocus by calculating the regression line of the clarity curve. Although it avoids the problem of collecting a large number of images, it is still difficult to complete the autofocus of dynamic targets; in addition, the clarity curve is not a perfect single-peak curve, and its regression line will also have a large error problem. The role of the industrial measurement system is to recognize the information of the three-dimensional environment through images, such as the shape, position, posture and movement of the measured target. As a key module in the industrial measurement system, autofocus must not only have excellent real-time performance, but also have the ability of dynamic focus and real-time tracking of the focal plane when the measured target moves. However, as mentioned above, the traditional focusing method requires collecting a large number of images, and generally requires adjusting the lens up to 10-20 times. In industrial measurement systems with high real-time requirements, this will seriously reduce the working efficiency of the industrial measurement system. In addition, multiple lens adjustments are also difficult to meet the dynamic focusing requirements in the industrial measurement system, and are affected by external noise, resulting in poor real-time performance of the industrial measurement system, making it difficult to complete dynamic focusing tasks. Summary of the invention

[0010] In view of this, the present invention aims to provide a dynamic focusing method based on an industrial measurement system to solve the problems that the existing focusing technology is inefficient and cannot focus on dynamic targets. The present invention improves the real-time focusing of the industrial measurement system through computer vision technology, and enables its autofocus module to have the ability of dynamic focusing.

[0011] To achieve the above object, the technical solution created by the present invention is implemented as follows: A dynamic focusing method based on an industrial measurement system specifically comprises the following steps: S1: Fix the target on the measured object, aim the lens of the industrial measurement system at the measured object, adjust the position and distance of the lens relative to the measured object, and obtain the image data set of the measured object; S2: inputting the target images contained in the target image dataset into the target acquisition network in sequence to obtain the target image dataset, wherein the target image dataset includes target images with prediction boxes corresponding to the target images one by one; S3: Calculate the working distance R of the target relative to the camera based on the predicted frame correspondence of each target image i ; S4: performing denoising and illumination normalization processing on all target images to obtain a processed target image data set; S5: Use the deep regression network to predict the predicted defocus distance D of each target image after processing i ; S6: statically adjusting the lens according to the predicted defocus distance D1 of the first frame target image to obtain a clear first frame target image; S7: Determine whether the target to be measured moves, and determine whether the target to be measured moves according to the motion state of the target to be measured and the working distance R of the target relative to the camera. i Make dynamic adjustments to the lens.

[0012] Furthermore, in step S2, the target acquisition network is a Yolov8 network.

[0013] Furthermore, in step S3, the format of the prediction box is , and are the two diagonal coordinates of the prediction box of the target image in the i-th frame; Calculate the working distance R of the target on the current target image relative to the camera i The formula used is: ; in, is the actual height of the target in the target image of the i-th frame, is the actual width of the target in the target image of the i-th frame, It is the pixel value occupied by the width of the prediction box in the target image of the i-th frame.

[0014] Furthermore, in step S4, a Gaussian denoising method is used to sequentially perform denoising operations on all target images; an adaptive Gamma transform is used to sequentially perform illumination normalization operations on all target images; The formula for adaptive Gamma transformation is: =log 10 0.5 / log 255 ; in, is the adaptive Gamma transformation result of the target image of the i-th frame, is the grayscale mean of the target image in the i-th frame.

[0015] Further, in step S5, the deep regression network is composed of a feature extraction network and a regression network, and the output of the feature extraction network is used as the input of the regression network, the feature extraction network is a MoblieNet network or a Shufflenet network, and the regression network includes an MLP network.

[0016] Furthermore, in step S5, the predicted defocus distance of each target image after processing is predicted using a deep regression network. The expression is: ; in, is the predicted defocus distance of the target image of the i-th frame output by the deep regression network, () is the trained deep regression network, is the target image of the i-th frame, are the network parameters of the deep regression network.

[0017] Furthermore, during the training of the deep regression network, the SmoothL1 loss function is used to evaluate the difference between the predicted defocus distance output by the deep regression network and the corresponding actual defocus distance: ; in, () is the SmoothL1 loss function, is the actual defocus distance annotated for the target image in the i-th frame, The predicted defocus distance annotated for the target image of the i-th frame; The minimum loss parameter of the deep regression network is solved by the following formula , and adjust the network parameters of the deep regression network through the gradient descent optimizer : ; Wherein, C is the total number of target images contained in the target image dataset.

[0018] Furthermore, step S5 specifically includes the following steps: S51: Set the size of the image input to the deep regression network to ; S52: If the prediction box of the current target image satisfies or , the resolution of the current target image is scaled to , the best defocus distance of the current target image is obtained , execute step S54, otherwise execute step S53; S53: If the prediction box of the current target image satisfies or , then the current target image is divided into The size is The sub-regions are selected and each sub-region is input into the deep regression network in turn, and the optimal defocus distance of the current target image is calculated by the following formula: ; ; Wherein, K is the number of sub-regions, and i is an integer not exceeding K; S54: Replace the current target image with the next target image, and repeat steps S52-S53 until the optimal defocus distance of all target images is obtained.

[0019] Further, in step S6, the lens is adjusted according to the optimal defocus distance D1 of the first frame target image so that the lens position , is the initial position of the lens.

[0020] Furthermore, step S7 specifically includes the following steps: S71: If the second frame target image satisfies , If the distance judgment threshold is set, the target is judged not to have moved, and the lens is not adjusted, so that the lens position , execute step S74, otherwise execute step S72; S72: If the second frame target image satisfies and , determine the working distance of the target Increase, adjust the lens to the positive direction , so that the lens position , execute step S74, otherwise execute step S73; S73: If the second frame target image satisfies and , determine the working distance of the target To reduce, adjust the lens in the opposite direction , so that the lens position ; S74: Replace the second frame of target image with the next frame of target image, and repeat steps S71-S73 until the dynamic adjustment of the lens is completed based on all target images.

[0021] Compared with the prior art, the invention can achieve the following beneficial effects: (1) The present invention creates a dynamic focusing method based on an industrial measurement system. The working distance and defocus distance of the measured object (including the target) are obtained by computer vision technology, and the adjustment direction of the lens is determined by combining the camera imaging principle. The real-time monitoring and dynamic adjustment of the target focal plane are realized in the industrial measurement system. Compared with the traditional focusing method, the present invention has the advantages of strong adaptability, low cost, and no need for professional operation.

[0022] (2) The dynamic focusing method based on the industrial measurement system created by the present invention adopts computer vision technology to complete automatic focusing, which can increase the intelligence of the industrial measurement system and is also in line with the current international development trend of integrating visual systems with computer vision technology. The present invention completes dynamic focusing through computer vision technology, breaking through the technical barrier that traditional focusing methods cannot complete dynamic focusing. At the same time, after experimental analysis, in the case of static focusing, the time consumption of the focusing process of the present invention can be reduced by more than 50%, greatly improving the real-time performance of the industrial measurement system. The hardware equipment of the present invention has low cost consumption and is conducive to popularization in embedded processors with limited computing power. The principle of the present invention is simple and easy to transplant. It can be applied to other visual systems that require automatic focusing function, that is, the dynamic focusing method of the present invention can not only be embedded in the industrial measurement system, but also can be placed in the machine vision positioning system. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] The drawings constituting part of the present invention are used to provide a further understanding of the present invention. The exemplary embodiments and descriptions of the present invention are used to explain the present invention and do not constitute an improper limitation on the present invention. In the drawings: Figure 1 A schematic flow chart of a dynamic focusing method based on an industrial measurement system according to an embodiment of the present invention; Figure 2 A schematic diagram of each target image included in the target image data set described in the embodiment of the present invention; Figure 3 A schematic diagram of the target described in the embodiment of the present invention; Figure 4 A schematic diagram of a prediction frame according to an embodiment of the present invention; Figure 5 A schematic diagram of imaging of any point in space in an image coordinate system according to an embodiment of the present invention; Figure 6 A schematic structural diagram of the optimal defocus distance described in an embodiment of the present invention. DETAILED DESCRIPTION

[0024] In order to make the purpose, technical solution and advantages of the invention more clear, the invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described here are only used to explain the invention and do not constitute a limitation of the invention.

[0025] It should be noted that, in the absence of conflict, the embodiments of the present invention and the features in the embodiments may be combined with each other.

[0026] In the description of the present invention, it should be understood that the terms "center", "longitudinal", "lateral", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside" and the like indicate positions or positional relationships based on the positions or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present invention. In addition, the terms "first", "second", etc. are only used for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, features defined as "first", "second", etc. may explicitly or implicitly include one or more of the features. In the description of the present invention, unless otherwise specified, "multiple" means two or more.

[0027] In the description of the invention, it should be noted that, unless otherwise clearly specified and limited, the terms "installation", "connection" and "connection" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in the invention can be understood according to specific circumstances.

[0028] The present invention will be described in detail below with reference to the accompanying drawings and in combination with embodiments.

[0029] like Figure 1As shown, the present invention provides a dynamic focusing method based on an industrial measurement system, which realizes static focusing and dynamic focusing of the industrial measurement system through computer vision technology. The dynamic focusing method specifically includes the following steps: S1: Fix the target on the object to be measured, aim the lens of the industrial measurement system at the object to be measured, adjust the position and distance of the lens relative to the object to be measured, and obtain the image data set of the object to be measured.

[0030] S2: inputting the target images contained in the target image dataset into the target acquisition network in sequence to obtain the target image dataset, wherein the target image dataset includes target images with prediction boxes corresponding to the target images one by one.

[0031] like Figure 2 As shown in the figure, the target image dataset contains target images with different blur levels, and the real defocus distance of each frame of the target image is annotated. Annotation is the preprocessing process of the image. In the process of collecting the target image dataset, the real defocus distance of the clearest image is annotated as 0, and the remaining images can be decreased according to the step size of the camera acquisition. The slightly clear image is annotated with 0.2 because it differs from the golden hook position of the clearest image by 0.2, and the very blurry image is annotated with 5.3 because it differs from the golden hook position of the clearest image by 5.3. The clearest image can be obtained according to the maximum value of the image gradient or image clarity evaluation function.

[0032] The target acquisition network is a Yolov8 network. It should be noted that the targets of industrial measurement systems are diverse, and it is difficult for the target acquisition network to identify all the targets. However, the target is different from the target, and its characteristics and shape are fixed, and the data set is easy to obtain. Therefore, the target is fixed on the target so that the target can be used to judge the defocus of the target.

[0033] The target has various shapes, such as Figure 3 As shown, the target here is a concentric circle pattern, and the diameter of the outer circle is 5.5 cm.

[0034] Before focusing on the current frame target image containing the target to be detected, the present invention uses the target acquisition network to perform target recognition. That is, before the system is initialized, a target data set of about 40 target images is collected for training to obtain a target acquisition network with fixed weights, and the target acquisition network is written into the algorithm of the smart device to complete the detection task of a specific target.

[0035] S3: Calculate the working distance R of the target relative to the camera based on the predicted frame correspondence of each target image i ; like Figure 4 As shown, the format of the prediction box is , and are the two diagonal coordinates of the prediction box of the target image of the i-th frame, and the resolution of the target image is , the target height here is 5.5cm.

[0036] like Figure 5 As shown, according to the similarity principle of imaging, is the world coordinate system, is the camera coordinate system, is the image coordinate system. The length and width of the target in the actual scene show a certain simple proportional relationship with the length and width of the projection in the target image, and the value is . Calculate the working distance R of the target on the current target image relative to the camera i The formula used is: ; in, is the actual height of the target in the target image of the i-th frame, is the actual width of the target in the target image of the i-th frame, It is the pixel value occupied by the width of the prediction box in the target image of the i-th frame.

[0037] Use the above steps to obtain the working distance R of the target relative to the camera i , the real distance of the target recognized in each frame can be simply estimated. In addition, by continuously acquiring two frames of target images The value can be used to determine whether the target is moving and the direction of movement, thereby guiding the autofocus process.

[0038] S4: Perform denoising and illumination normalization processing on all target images to obtain a processed target image dataset.

[0039] The Gaussian denoising method is used to perform denoising operations on all target images in turn; the adaptive Gamma transform is used to perform illumination normalization operations on all target images in turn; The formula for adaptive Gamma transformation is: =log 10 0.5 / log 255 ; in, is the adaptive Gamma transformation result of the target image of the i-th frame, is the grayscale mean of the target image in the i-th frame.

[0040] In real situations, the illumination intensity of the input target image is different. The role of Gamma transformation is to increase the accuracy of the deep regression network and reduce the influence of illumination intensity. After experiments, this method can reduce the error of the deep regression network by 8%. Images with different degrees of blur are different. The human visual system can classify multiple images with different degrees of blur (clear images, relatively clear images, blurred images). Computer vision technology simulates human visual perception ability and then performs quantitative analysis on the degree of blur of the image, which is the deep regression task.

[0041] S5: Use the deep regression network to predict the predicted defocus distance D of each target image after processing i ; The deep regression network consists of a feature extraction network and a regression network, and the output of the feature extraction network is used as the input of the regression network. The feature extraction network is a MoblieNet network or a Shufflenet network, and the regression network includes an MLP network. First, the feature extraction network is used to extract image features, and then the regression network is used to complete the nonlinear fitting of image features. The final regressor of the deep regression network needs to have actual physical meaning to simplify the focusing process. Therefore, the regressor is defined as the defocus distance from the current image position to the best focus position, such as Figure 6 As shown, the defocus distance of the current initial focus position relative to the actual best focus position is the best defocus distance.

[0042] The predicted defocus distance of each target image after processing is predicted using a deep regression network The expression is: ; in, is the predicted defocus distance of the target image of the i-th frame output by the deep regression network, () is the trained deep regression network, is the target image of the i-th frame, are the network parameters of the deep regression network.

[0043] During the training of the deep regression network, the SmoothL1 loss function is used to evaluate the difference between the predicted defocus distance output by the deep regression network and the corresponding actual defocus distance: ; in, () is the SmoothL1 loss function, is the actual defocus distance annotated for the target image in the i-th frame, The predicted defocus distance annotated for the target image of the i-th frame; The minimum loss parameter of the deep regression network is solved by the following formula , and adjust the network parameters of the deep regression network through the gradient descent optimizer : ; Wherein, C is the total number of target images contained in the target image dataset.

[0044] According to the above training steps, a deep regression network with fixed weights can be obtained.

[0045] Step S5 specifically includes the following steps: Since the distance between the target and the camera will change, the size of the target image acquired by the target acquisition network will also change, and the target image will not be suitable for input into the deep regression network. Therefore, in order to facilitate the input of the target image into the deep regression network, the present invention adopts the method of regional division: S51: Set the size of the image input to the deep regression network to , The design value can be 224, 400, 640, etc. The larger the value, the slower the prediction efficiency of the deep regression network. Therefore, it can be adjusted according to the actual target size designed in the device work. Set to 224.

[0046] S52: If the prediction box of the current target image satisfies or , the resolution of the current target image is scaled to , the best defocus distance of the current target image is obtained , execute step S44, otherwise execute step S43.

[0047] Since the target is designed to be circular, the target acquires the network and The difference will not be particularly large, so it will not cause the scale of the target image to be unbalanced. At this time, the defocus distance of the target image is calculated to be , the model can obtain the defocus distance by predicting it only once.

[0048] S53: If the prediction box of the current target image satisfies or , then the current target image is divided into The size is The sub-regions are selected and each sub-region is input into the deep regression network in turn, and the optimal defocus distance of the current target image is calculated by the following formula: ; ; Wherein, K is the number of sub-regions, and i is an integer not exceeding K; S54: Replace the current target image with the next target image, and repeat steps S52-S53 until the optimal defocus distance of all target images is obtained.

[0049] S6: statically adjusting the lens according to the predicted defocus distance D1 of the first frame target image to obtain a clear first frame target image; When focusing begins, the target to be measured does not move. The lens is adjusted according to the best defocus distance D1 of the first frame target image so that the lens position , is the initial position of the lens. At this point, static focusing is completed and a clear image of the target can be obtained.

[0050] It should be noted that the error of the deep regression network obtained through appropriate training methods will be stabilized within 5% of the data set acquisition range, which is smaller than the focusing error of the traditional focusing method and has sufficient accuracy.

[0051] During the focusing process of the second target image and subsequent target images, the target to be measured will move. The difficulty of dynamic focusing is that it is difficult to obtain the motion state of the target to be measured, so it is impossible to determine the focusing direction.

[0052] The principle of the traditional focusing method's hill climbing search method is to determine the size relationship between the image clarity evaluation values ​​of two consecutive frames of the target. When the measured target (target) moves, the image resolution of the measured (target) is different, so the traditional focusing method is not applicable in this case.

[0053] The efficiency of static focusing using a deep regression network in the present invention is much higher than that of traditional focusing methods, and a single focus takes only 0.2s-0.5s. Therefore, after the target working distance is obtained using a target recognition network, it is sufficient to complete the tasks of dynamic focusing and focal plane tracking.

[0054] The specific methods of dynamic focus are as follows: S7: Determine whether the target to be measured moves, and determine whether the target to be measured moves according to the motion state of the target to be measured and the working distance R of the target relative to the camera. i Make dynamic adjustments to the lens.

[0055] S71: If the second frame target image satisfies , it is determined that the target has not moved, and the lens is not adjusted, so that the lens position , execute step S74, otherwise execute step S72; S72: If the second frame target image satisfies and , determine the working distance of the target Increase, adjust the lens to the positive direction , so that the lens position , execute step S74, otherwise execute step S73; S73: If the second frame target image satisfies and , determine the working distance of the target To reduce, adjust the lens in the opposite direction , so that the lens position ; S74: Replace the second frame of target image with the next frame of target image, and repeat steps S71-S73 until the dynamic adjustment of the lens is completed based on all target images.

[0056] For the distance judgment threshold, set the interval to 0.05-0.1m.

[0057] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the disclosure of the present invention can be performed in parallel, sequentially or in different orders, as long as the desired results of the technical solution disclosed in the present invention can be achieved, and this document does not limit this.

[0058] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A dynamic focusing method based on an industrial measurement system, characterized in that: The specific steps include: S1: Fix the target on the measured object, aim the lens of the industrial measurement system at the measured object, adjust the position and distance of the lens relative to the measured object, and obtain the image data set of the measured object; S2: inputting the target images contained in the target image dataset into the target acquisition network in sequence to obtain the target image dataset, wherein the target image dataset includes target images with prediction boxes corresponding to the target images one by one; S3: Calculate the working distance R of the target relative to the camera based on the predicted frame correspondence of each target image i ; S4: performing denoising and illumination normalization processing on all target images to obtain a processed target image data set; S5: Use the deep regression network to predict the predicted defocus distance D of each target image after processing i ; S6: statically adjusting the lens according to the predicted defocus distance D1 of the first frame target image to obtain a clear first frame target image; S7: Determine whether the target to be measured moves, and determine whether the target to be measured moves according to the motion state of the target to be measured and the working distance R of the target relative to the camera. i Make dynamic adjustments to the lens.

2. The dynamic focusing method based on the industrial measurement system according to claim 1, characterized in that: In step S2, the target acquisition network is a Yolov8 network.

3. The dynamic focusing method based on the industrial measurement system according to claim 1, characterized in that: In step S3, the format of the prediction box is , and are the two diagonal coordinates of the prediction box of the target image in the i-th frame; Calculate the working distance R of the target on the current target image relative to the camera i The formula used is: ; in, is the actual height of the target in the target image of the i-th frame, is the actual width of the target in the target image of the i-th frame, It is the pixel value occupied by the width of the prediction box in the target image of the i-th frame.

4. The dynamic focusing method based on the industrial measurement system according to claim 1, characterized in that: In step S4, a Gaussian denoising method is used to perform denoising operations on all target images in turn; an adaptive Gamma transform is used to perform illumination normalization operations on all target images in turn; The formula for adaptive Gamma transformation is: =log 10 0.5 / log 255 ; in, is the adaptive Gamma transformation result of the target image of the i-th frame, is the grayscale mean of the target image in the i-th frame.

5. The dynamic focusing method based on the industrial measurement system according to claim 1, characterized in that: In step S5, the deep regression network is composed of a feature extraction network and a regression network, and the output of the feature extraction network is used as the input of the regression network. The feature extraction network is a MoblieNet network or a Shufflenet network, and the regression network includes an MLP network.

6. The dynamic focusing method based on the industrial measurement system according to claim 3, characterized in that: In step S5, the predicted defocus distance of each target image after processing is predicted using the deep regression network The expression is: ; in, is the predicted defocus distance of the target image of the i-th frame output by the deep regression network, () is the trained deep regression network, is the target image of the i-th frame, are the network parameters of the deep regression network.

7. The dynamic focusing method based on the industrial measurement system according to claim 6, characterized in that: During the training of the deep regression network, the SmoothL1 loss function is used to evaluate the difference between the predicted defocus distance output by the deep regression network and the corresponding actual defocus distance: ; in, () is the SmoothL1 loss function, is the actual defocus distance annotated for the target image in the i-th frame, The predicted defocus distance annotated for the target image of the i-th frame; The minimum loss parameter of the deep regression network is solved by the following formula , and adjust the network parameters of the deep regression network through the gradient descent optimizer : ; Wherein, C is the total number of target images contained in the target image dataset.

8. The dynamic focusing method based on the industrial measurement system according to claim 7, characterized in that: Step S5 specifically includes the following steps: S51: Set the size of the image input to the deep regression network to ; S52: If the prediction box of the current target image satisfies or , the resolution of the current target image is scaled to , the predicted defocus distance of the current target image is obtained, and step S54 is executed; otherwise, step S53 is executed; S53: If the prediction box of the current target image satisfies or , then the current target image is divided into The size is The sub-regions are selected and each sub-region is input into the deep regression network in turn, and the predicted defocus distance of the current target image is calculated by the following formula: ; ; Wherein, K is the number of sub-regions, and i is an integer not exceeding K; S54: Replace the current target image with the next target image, and repeat steps S52-S53 until the optimal defocus distance of all target images is obtained.

9. The dynamic focusing method based on the industrial measurement system according to claim 8, characterized in that: In step S6, the lens is adjusted according to the optimal defocus distance D1 of the first frame target image so that the lens position , is the initial position of the lens.

10. The dynamic focusing method based on an industrial measurement system according to claim 8, characterized in that: Step S7 specifically includes the following steps: S71: If the second frame target image satisfies , If the distance judgment threshold is set, the target is judged not to have moved, and the lens is not adjusted, so that the lens position , execute step S74, otherwise execute step S72; S72: If the second frame target image satisfies and , determine the working distance of the target Increase, adjust the lens to the positive direction , so that the lens position , execute step S74, otherwise execute step S73; S73: If the second frame target image satisfies and , determine the working distance of the target To reduce, adjust the lens in the opposite direction , so that the lens position ; S74: Replace the second frame of target image with the next frame of target image, and repeat steps S71-S73 until the dynamic adjustment of the lens is completed based on all target images.

Citation Information

Patent Citations

  • Automatic focusing method, microscope and computer readable storage medium

    CN117880627A

  • Camera automatic focusing method based on multi-step parameter optimization and camera

    CN118018845A

  • Method and device for measuring three-dimensional coordinate of object

    CN102062574A

  • Automatic focusing method of optical imaging system for estimating defocusing amount of single image

    CN117528238A

  • Automatic focus adjusting device

    JP1990205810A

Cited By

  • Visual measuring instrument and measuring method for resolving position and attitude of space target

    CN120252510A

  • Vision measuring instrument and measurement method for space target position and attitude calculation

    CN120252510B