Control method of image measurement equipment and image measurement equipment
By controlling the movement and exploration operation of the image sensor in the image measurement device, quickly determine the optimal observation position and adjust the movement direction and speed in real time, the problem of automatic focus in the prior art is solved, and the measurement efficiency and accuracy are improved.
Patent Information
- Application Number
- CN202411999677.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2025-05-06
AI Technical Summary
The automatic focus scheme of the existing three-dimensional image measuring instrument is long, resulting in low measurement efficiency.
By controlling the image sensor to move along the axis of the motion axis and performing exploration operations, the optimal observation position is quickly determined, and the movement direction and speed are adjusted in real time according to changes in the signal quality score to achieve fast and accurate focus.
It significantly shortens the autofocus time, improves measurement efficiency and accuracy, and achieves efficient and precise control of image measurement equipment.
Smart Images

Figure CN119946243A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the technical field of image measuring equipment, and in particular, relates to a control method of image measuring equipment and an image measuring equipment. Background Art
[0002] In the field of image measuring equipment technology, especially the technology of three-dimensional image measuring instruments, automatic focusing of image sensors in the Z-axis direction can improve measurement accuracy and enhance user experience.
[0003] The autofocus solution of the three-dimensional image measuring instrument in the prior art is usually a fixed-speed autofocus solution based on a complete path. That is, given a fixed Z-axis stroke, the Z-axis motor moves the image sensor within the maximum movable range at a fixed moving speed. While moving, the image sensor is collected at various positions during movement to obtain each frame of signal for evaluation, calculate the peak score, and record the Z-axis coordinate corresponding to the peak value and the optimal focus position. After the image sensor completes the entire moving stroke, the image sensor is controlled to return to the Z-axis coordinate position with the highest peak score to measure the object to be measured.
[0004] This autofocus solution takes a long time and has low measurement efficiency. Summary of the invention
[0005] The embodiments of the present application provide a control method and device for an image measuring device, an image measuring device, and a computer-readable storage medium, which can significantly shorten the autofocus time of an image sensor and improve the measurement efficiency and measurement accuracy of the image measuring device.
[0006] A first aspect of an embodiment of the present application provides a method for controlling an image measuring device, comprising:
[0007] At each moment when the image sensor moves along the axis of the motion axis and performs an exploration operation, a score of the quality of the signal of the object to be measured collected by the image sensor is obtained; wherein the exploration operation is used to locate the first position of the image sensor in the axis direction; the quality of the signal collected by the image sensor at the first position is higher than the quality of the signal collected at any second position; the second position is a position other than the first position in the axis direction; and the time interval between two adjacent moments is less than a time interval threshold;
[0008] Determine and update the target moving direction of the image sensor according to the change of the score, and control the image sensor to move in the target moving direction so that the distance between the image sensor and the first position becomes smaller;
[0009] According to the change in the score, the first position is determined;
[0010] The image sensor is controlled to move to a first position.
[0011] A second aspect of an embodiment of the present application provides an image measuring device, comprising: an image sensor, a motion axis, a drive component and a control module, wherein the image sensor is arranged on the motion axis, the drive component is connected to the motion axis and is used to drive the motion axis to move so as to drive the image sensor to move along the axial direction of the motion axis, and the control module is respectively connected to the drive component and the image sensor, wherein the control module is used to execute the steps of the control method of the above-mentioned image measuring device.
[0012] A third aspect of an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps of the control method of the above-mentioned image measuring device are implemented.
[0013] The control method of the image measuring device provided by the first aspect of the embodiment of the present application controls the image sensor to move along the axis direction of the motion axis and performs an exploration operation to quickly and accurately determine the best observation position of the image sensor for the object to be measured in the axis direction. In the exploration operation, by obtaining the quality score of the signal of the object to be measured collected by the image sensor at each moment, the target moving direction of the image sensor is quickly and accurately determined according to the change of the score, so that the image sensor is close to the best observation position. And, according to the change of the score, the best observation position is accurately located, thereby achieving real-time and precise focusing. Moreover, this scheme can locate the best observation position when the image sensor is close to the best observation position, so that the image sensor can be quickly controlled to move to the best observation position to measure the object to be measured. Thereby, the time spent in the autofocus process is significantly saved, and the measurement efficiency and measurement accuracy of the image measuring device can be further improved, and efficient and precise control of the image measuring device is achieved, and the user experience is better.
[0014] It can be understood that the beneficial effects of the second to third aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0016] Figure 1 is a schematic diagram of a usage scenario of an image measuring device provided by an embodiment of the present application;
[0017] Figure 2 is a schematic diagram of the principle of the auto-focus path of an image sensor in the prior art;
[0018] Figure 3 It is a flowchart of a control method of an image measuring device provided by an embodiment of the present application;
[0019] Figure 4 It is a schematic diagram of a visual sensor provided by an embodiment of the present application collecting signals at different positions to generate an image;
[0020] Figure 5a to Figure 5c This is a schematic diagram of a line scan laser sensor provided by an embodiment of the present application collecting signals at different positions to generate an image;
[0021] Figures 6a to 6c It is a schematic diagram of a signal intensity curve of a spectral confocal displacement sensor collecting signals at different positions provided by an embodiment of the present application;
[0022] Figures 7a to 7e is a schematic diagram of the principle of the auto-focus path of the image sensor provided by different embodiments of the present application;
[0023] Figure 8 is a schematic diagram of a scoring window at different times during an exploration operation provided by an embodiment of the present application;
[0024] Figure 9a and Figure 9b They are partial schematic diagrams of score change curves of image sensors provided by different embodiments of the present application during the autofocus process;
[0025] Fig.10 is a schematic diagram of a principle for determining position offsets of different image sensors provided by an embodiment of the present application;
[0026] Fig.11 is a flow chart of a control method of an image measuring device provided by another embodiment of the present application;
[0027] Fig.12 is a structural schematic diagram of an image measuring device provided by another embodiment of the present application;
[0028] Fig.13 is a schematic diagram of the structure of a control device for an image measuring device provided by an embodiment of the present application;
[0029] Fig.14 It is a structural diagram of a terminal device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0030] In the following description, for the purpose of explanation rather than limitation, specific details such as specific system structures, technologies, etc. are proposed so as to thoroughly understand the embodiments of the present application. However, it should be clear to those skilled in the art that the present application can also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from hindering the description of the present application. It should be understood that when used in the present application specification and the attached claims, the term "including" indicates the presence of the described features, wholes, steps, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components, and / or their collections. It should also be understood that the term "and / or" used in the present application specification and the attached claims refers to any combination of one or more of the items listed in the association and all possible combinations, and includes these combinations. In addition, in the description of the present application specification and the attached claims, the terms "first", "second", "third", etc. are only used to distinguish the description, and cannot be understood as indicating or implying relative importance. References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0031] First of all, it should be noted that a person skilled in the art can understand that the embodiment of the present application is a control method for an image measuring device, and the "focusing" described in the embodiment of the present application is completely different from the principle and method of automatic focusing of a camera in the conventional sense. The automatic focusing of a camera is usually a process of automatically adjusting the image distance (adjusting the distance between the camera lens and the imaging sensor) at a sufficiently low speed within a sufficiently small range. It does not involve the movement control of the camera, nor does it consider the problems of camera movement speed control, position control, etc., and does not consider other problems derived from movement control.
[0032] The image measuring equipment can be a three-dimensional image measuring instrument, also known as a three-coordinate image measuring instrument. It can use optical imaging technology and computer signal intensity processing technology to accurately measure the three-dimensional size, shape and position of an object. Three-coordinate image measuring instruments are widely used in manufacturing, electronics, mold industry and other fields for quality control, product inspection and reverse engineering. The core components of the three-coordinate image measuring instrument are the optical imaging system and the movable three-axis (X-axis, Y-axis, Z-axis) mechanical mobile platform. The optical imaging system can accurately measure the size of the object, and the three-axis mechanical mobile platform can move in the three directions of X, Y and Z, so that the image sensor can fully observe any position on the platform, thereby realizing the measurement of complex shapes and large-sized objects.
[0033] like Figure 1 As shown, the image measuring device 100 may include a visual sensor 110, a Z-axis 120, a Z-axis motor 130 and a measuring platform 140. When the image measuring device 100 is working, the object to be measured is located on the measuring platform 140. The visual sensor 110 is arranged below the Z-axis 120, and can move up and down with the Z-axis under the drive of the Z-axis motor 130. That is, the visual sensor can move along the straight line direction (the axial direction of the Z-axis) where Z0Z1 is located in the figure. The visual axis direction of the visual sensor 110 is parallel to the axial direction of the Z-axis 120 and perpendicular to the measuring platform 140. The movable range of the visual sensor 110 along the axial direction of the Z-axis 120 can be Figure 1 In other words, the visual sensor 110 can move between Z0 and Z1, and Z0 and Z1 are two limit points for the visual sensor 110 to move along the axis direction of the Z-axis 120. When the Z-axis motor 130 drives the Z-axis 120 to move the visual sensor 110 to any limit point, the corresponding limit alarm will be triggered and the Z-axis 120 will be prevented from moving further to avoid damage to the hardware.
[0034] It can be understood that, under normal circumstances, for a three-coordinate image measuring instrument, the observation effect of the image sensor when observing the object to be measured at different positions is different, which is specifically manifested in that the intensity of the signal output when observing the object to be measured at different positions is different, so the accuracy of the image of the object to be measured generated in the end is different. For observing objects to be measured at different heights or observing different height areas of the same object to be measured, in order to improve the measurement accuracy of the image measuring equipment, it is usually necessary to first locate the best observation position (or best focus position) of the image sensor for the object to be measured. Specifically, before generating the image of the object to be measured, the image sensor can be controlled to move within the movable range in the Z-axis direction to automatically find the best observation position of the object to be measured.
[0035] Combination Figure 1 and Figure 2, usually, the best observation position Z* of the visual sensor 110 for the object to be measured is between Z0 and Z1. In the prior art, in order to locate the best observation position of the image sensor for the object to be measured, the image sensor is usually controlled to move to various positions within the entire movable range and collect signals of the object to be measured, and the quality of the signals collected at each position is scored, and the position with the highest score is taken as the best observation position. For example, control Figure 1 The visual sensor 110 in the image sensor 110 moves from the Z0 position to the Z1 position at a uniform speed, evaluates the images taken at each position, obtains a score (for example, a clarity score), and takes the Z* position with the highest score between Z0 and Z1 as the best observation position. Then, the image sensor is controlled to move to the best observation position to collect and generate an image of the object to be measured. In other words, in the prior art, the image sensor needs to complete the entire observation range to determine the best observation position of the object to be measured.
[0036] It is understandable that the prior art solution takes a long time to locate the best observation position. And usually, the image sensor is far away from the best observation position when it is at the limit point. Therefore, it still takes a long time to return to the best observation position after the positioning is completed. Figure 2 As shown, in the prior art, the image sensor needs to spend at least the time to move from Z0 to Z1 and then from Z1 back to Z* during autofocus. And it is necessary to control the image sensor to move to the limit point position (such as Z0) before autofocusing. Otherwise, autofocusing will take more time. In the process of the image sensor locating the best observation position (for example, moving from Z0 to Z1), if the moving speed is high, it is difficult to accurately locate the best observation position, resulting in low measurement accuracy; if the moving speed is low, the positioning time will be greatly increased, resulting in extremely low measurement efficiency, and user satisfaction will also be greatly reduced.
[0037] In order to at least partially solve the above technical problems, embodiments of the present application provide a control method of an image measuring device, an image measuring device, and a storage medium.
[0038] like Figure 3 As shown, the control method of the image measuring device provided in the embodiment of the present application includes the following steps:
[0039] Step S310, at each moment when the image sensor moves along the axis direction of the motion axis and performs the exploration operation, obtain a score of the quality of the signal of the object to be measured collected by the image sensor. The exploration operation is used to locate the first position of the image sensor in the axis direction. The quality of the signal collected by the image sensor in the first position is higher than the quality of the signal collected at any second position, and the second position is a position other than the first position in the axis direction. The time interval between two adjacent moments is less than the time interval threshold.
[0040] The image sensor in the embodiment of the present application may be a visual sensor (for example, a camera that can capture RGB images or grayscale images), a line scan laser sensor, or a spectral confocal displacement sensor. Figure 1 In the image measuring device, the motion axis can be Figure 1 The Z axis 120 in the figure. The axis direction of the motion axis can be Figure 1 The direction of the straight line where the central axis of the middle Z axis 120 is located is the direction of the straight line Z0Z1. Taking the observation platform 140 being parallel to the horizontal plane as an example, the axial direction of the motion axis can be the direction of gravity. To put it simply, Figure 1 The visual sensor 110 in the embodiment can move vertically up and down in a horizontal plane. The first position can be the best observation position for the image sensor to observe the object to be measured. Figure 1 For the visual sensor 110 in the observation platform, the first position may be a position where the visual sensor 110 maintains an optimal object distance with the object to be measured, that is, when the visual sensor 110 is located at the first position and photographs a certain object to be measured below, the image of the object to be measured can be made at the focus. It can be understood that when the object to be measured on the observation platform changes, the optimal observation position of the visual sensor 110 to photograph the new object to be measured may change.
[0041] The exploration operation in this step can be to control the image sensor to collect signals at a higher frequency while the image sensor is moving, analyze the signals, and adjust the distance between the image sensor and the object to be measured according to the analysis results (i.e., adjust the object distance by automatically controlling the image sensor to move along the Z-axis direction), until the optimal observation position (first position) of the current object to be measured is determined. In short, the exploration operation is the operation process of exploring and locating the first position.
[0042] In one example, at the initial moment of the exploration operation, the image sensor can be controlled to move from the initial position (current position) along a preset direction at a preset initial speed. This solution can reduce the time consumption of autofocus. For example, if the current position of the image sensor is close to the first position, the first position can be quickly located. Specifically, in combination with Figure 1 , at the initial moment, the image sensor can be controlled to move from the initial position along the Z0Z1 direction or along the Z1Z0 direction. The initial speed can be set arbitrarily according to actual needs, and this application does not limit it. In this scheme, the initial position of the image sensor can be arbitrary. That is, the initial position can be anywhere between Z0 and Z1. Exemplarily, considering that the initial position may be near the first position (Z*), in order to increase the probability that the image sensor collects a signal at this position, the initial speed can be set smaller.
[0043] In another example, at the initial moment of the exploration operation, the image sensor may be controlled to move to the upper limit position. Figure 1 The Z0 position in , so that the initial moving direction can be more reasonable.
[0044] In an embodiment of the present application, the time interval between two adjacent moments may be fixed or not. In an embodiment of the present application, the time interval between two adjacent moments is less than or equal to a time interval threshold. The time interval threshold may be set according to actual needs, such as 0.1s, 1s, etc. For example, each time the image sensor collects a frame of signal, a score is counted for the signal. When the statistics of a frame of signal are finished, the latest signal collected by the image sensor at the time when the statistics are finished may be counted.
[0045] It is understandable that image sensors such as visual sensors, line scan laser sensors, spectral confocal displacement sensors, etc. will have different measurement effects at different distances from the object to be measured. When the image sensor is in the best observation position, the signal output by the sensor is usually the strongest, that is, the signal quality is the highest. When the image sensor is far away from the best observation position, the sensor output signal is weaker, that is, the signal quality is lower.
[0046] Before step S310, the control method of the image measuring device provided in the embodiment of the present application may further include: acquiring the signal of the object to be measured collected by the image sensor at each moment in the exploration operation; and performing quality evaluation on the signal to obtain a quality score of the signal.
[0047] In an embodiment of the present application, a variety of suitable methods can be used to evaluate the quality of the signal collected by the image sensor to obtain a quality score for each frame of the signal (for simplicity, it may be referred to as a focus score hereinafter). For example, a mathematical statistical model can be pre-constructed or a deep learning model can be trained as a quality evaluation model, and then the signal collected by the image sensor can be input into the quality evaluation model to obtain a quality score for the signal. It can be understood that the quality score of the signal collected by the image sensor at the first position (optimal observation position) of the object to be measured is the highest. The farther the image sensor is from the first position, the lower the quality score of the signal collected from the object to be measured. Therefore, the focus score can be an important basis for determining the first position of the image sensor. Exemplarily, for each moment, after the image sensor collects a frame of the current signal, the preset focus score calculation method can be used to calculate the signal strength characteristics, and finally a score is obtained. As shown in FIG. Figure 2 As shown in the figure, the closer the intensity of the frame signal is to the peak value, the higher the score; when the signal intensity is at the peak value, it means that the image sensor is in the best observation position for measuring the object to be measured. Therefore, the focus score corresponding to the first position is the maximum value of the focus scores corresponding to various positions within the movable range of the image sensor.
[0048] In the embodiment of the present application, the image sensor may be any one of a plurality of image sensors. The focus scores of signals from different image sensors are calculated in different ways.
[0049] like Figure 4 As shown, when the image sensor is a visual sensor, the clarity of the image generated by the signal collected by the visual sensor can be used to characterize the quality of its signal. A variety of suitable image clarity evaluation methods (for example, gradient method, variance method, entropy function, structural similarity, etc.) can be used to evaluate and calculate the focus score of the signal collected by the visual sensor. Figure 4 Figure a in the figure may be an image generated by a signal collected by the visual sensor at a position far away from the first position. The image clarity is low, and the focus score is, for example, 17.129. Figure 4 Figure b in the figure may be an image generated by a signal collected by the visual sensor at a position closer to the first position. The image clarity is high, and the focus score is, for example, 308.89. Figure 4 Figure c in the figure may be an image generated by the signal collected by the visual sensor at the first position, with the highest image clarity and a focus score of, for example, 496.429. It is understood that as the visual sensor moves away from the first position, the clarity of the image generated by the signal collected by the visual sensor gradually decreases, and the focus score also gradually decreases (below 496.429).
[0050] like Figure 5a to Figure 5c As shown, when the image sensor is a line scan laser sensor, the quality of the signal can be characterized by the ratio of the foreground area (the color area except the black area in the figure) in the image generated by the signal collected by the line scan laser sensor to the entire image area. Figure 5a As shown, the position of the line scan laser sensor is far from the first position, so the foreground area in the image generated by the signal collected by the line scan laser sensor accounts for a small proportion, and the focus score of the signal collected at this position is, for example, 0.8. Figure 5b As shown, the position of the line scan laser sensor is closer to the first position, so the proportion of the foreground area in the image generated by the signal collected by the line scan laser sensor increases, and the focus score of the signal collected at this position is, for example, 55.8. Figure 5c As shown, when the line scan laser sensor is located at the first position, the foreground area in the image generated by the signal collected by the line scan laser sensor accounts for the largest proportion, and the focus score of the signal collected at this position is, for example, 89.3. Similarly, as the line scan laser sensor moves away from the first position, the proportion of the foreground area in the image generated by the signal collected by the line scan laser sensor gradually decreases, and the focus score also gradually decreases (below 89.3).
[0051] like Figures 6a to 6cAs shown, when the image sensor is a spectral confocal displacement sensor, the peak value of the effective area in the signal intensity curve of the signal collected by the spectral confocal displacement sensor can be used to characterize the quality of its signal. Figure 6a As shown, the position of the spectral confocal displacement sensor is far from the first position, so the peak value of the effective area in the signal intensity curve of the signal collected by the spectral confocal displacement sensor is small, and the focus score of the signal collected at this position is, for example, 5.2. Figure 6b As shown, the position of the spectral confocal displacement sensor is closer to the first position, so the peak value of the effective area in the signal intensity curve of the signal collected by the spectral confocal displacement sensor increases, and the focus score of the signal collected at this position is, for example, 252.3. Figure 6c As shown, when the spectral confocal displacement sensor is located at the first position, the peak value of the effective area in the signal intensity curve of the signal collected by the spectral confocal displacement sensor is the largest, and the focus score of the signal collected at this position is, for example, 910.5. Similarly, as the spectral confocal displacement sensor moves away from the first position, the peak value of the effective area in the signal intensity curve of the signal collected by it gradually decreases, and the focus score also gradually decreases (below 910.5).
[0052] Step S320 , determining and updating the target moving direction of the image sensor according to the change of the score, and controlling the image sensor to move in the target moving direction so that the distance between the image sensor and the first position becomes smaller.
[0053] It can be understood that the closer the image sensor is to the first position, the higher the focus score of the collected signal; the farther the image sensor is from the first position, the lower the focus score of the collected signal. If the image sensor moves toward the first position, its score generally increases gradually with the increase of movement time; if the image sensor moves in a direction away from the first position, its score generally decreases gradually with the increase of movement time. Therefore, the target movement direction of the image sensor can be determined according to the change of the focus score, so that the image sensor can move toward the first position in most of the time period, so that the image sensor can be quickly controlled to approach and reach the first position.
[0054] In the embodiment of the present application, a variety of suitable logics can be used to determine and update the target movement direction of the image sensor in real time or at regular intervals according to the change of the focus score of the image sensor acquisition signal over time. The image sensor can also be controlled to move according to the target movement direction in a timely manner.
[0055] In one example, the target moving direction of the image sensor can be determined in real time based on the change in the score. Exemplarily, the change in the new score counted at the current moment relative to at least one historical score counted previously can be counted at each moment. For example, the new score of the i-th frame signal (i≥2) counted at the current moment can be compared with the historical score of the i-1-th frame signal counted at the previous moment, and the target moving direction of the image sensor at the next moment can be determined based on the comparison result. For example, if the new score counted at the current moment is less than the historical score counted at the previous moment, it can be determined that the target moving direction of the image sensor at the next moment is opposite to the current moving direction. The moving direction of the image sensor can then be changed at the next moment. If the new score counted at the current moment is greater than or equal to the historical score counted at the previous moment, it can be determined that the target moving direction of the image sensor at the next moment is the same as the current moving direction. The image sensor can then be controlled to keep moving in the original moving direction at the next moment.
[0056] In another example, the change of the score within a period of time can also be analyzed at a preset frequency, and then the target movement direction of the image sensor within the next period of time can be determined. For example, the change of the focus score counted within every 2 seconds can be analyzed, and specifically the change trend of multiple scores counted within the period of time can be analyzed. Then, the target movement direction of the image sensor in the next period of time can be determined according to the change trend. Exemplarily, the change trend may include: an upward trend indicating that the score is constantly increasing, a downward trend indicating that the score is constantly decreasing, and an oscillating trend indicating that the score is in a fluctuating state. Exemplarily, if the change trend determined in the current 2 seconds is an upward trend or an oscillating trend, it can be determined that the target movement direction of the image sensor in the next 2 seconds is the same as the current movement direction; if the change trend determined in the current 2 seconds is a downward trend, it can be determined that the target movement direction of the image sensor in the next 2 seconds is opposite to the current movement direction. It should be noted that in actual control, the image sensor can also be controlled to keep moving in the current movement direction by default at each moment, and only when the change trend of the score is determined to be a downward trend in a certain period of time, that is, the commutation condition is met, the commutation control signal is sent to the Z-axis motor, thereby changing the target movement direction of the image sensor.
[0057] It can be understood that in this step, it is possible to timely identify whether the target moving direction of the image sensor is toward the optimal observation position according to the change in the score. If it is identified that the moving direction is toward the optimal observation position, the image sensor can be controlled to maintain the current target moving direction and continue to move toward the optimal observation position, so that the image sensor continues to approach the first position. If it is identified that the moving direction of the image sensor deviates from the optimal observation position, the image sensor can be timely controlled to turn around and move toward the optimal observation position, or the image sensor can be quickly approached to the first position.
[0058] Step S330, determining the first position according to the change of the score.
[0059] In the embodiment of the present application, a variety of suitable methods can be used to determine the first position based on the changes in the scores counted in the exploration operation. As previously mentioned, the score of the quality of the signal collected by the image sensor when it is in the first position is greater than the score of the quality of the signal collected at other positions. Therefore, in this step, the maximum value of the score can be counted and continuously updated at a preset frequency in the exploration operation. Analyze the changes in the maximum score, and determine that the acquisition position of the signal corresponding to the maximum score is the first position, at least based on the situation that the maximum score has not changed for a period of time. For example, determine the coordinate of the first position in the Z-axis direction, such as Figure 1 Z* in .
[0060] In one example, when the maximum score is greater than or equal to a preset score threshold and the maximum score does not change within a period of time, the signal collection position corresponding to the maximum score is determined to be the first position.
[0061] In another example, the position segment of the image sensor in the autofocus can also be determined in real time based on the change in the score, and then the acquisition position of the signal corresponding to the maximum score can be determined as the first position when the changes in the position segment of the image sensor and the maximum score meet the corresponding conditions. For example, the position segment of the image sensor can be classified according to the distance between different positions of the image sensor in the Z-axis direction and the first position. For example, at least the position segment of the image sensor can be divided into a far focus segment indicating a farther distance from the first position and a near focus segment indicating a closer distance from the first position. Specifically, the position segment of the image sensor can be divided into a near focus segment and a far focus segment according to the difference in scores within a unit time. Reference Figure 2 In the focus score variation curve shown in FIG. 1 , for example, the distance between the limit point Z0 and the first position Z* is 200 mm, and the distance between the limit point Z1 and the first position Z* is 300 mm. Figure 2As shown, the closer the distance Z* is, the greater the slope of the score curve of the collected signal is, and the greater the change per unit time is. The above-mentioned segment classification method can be used to roughly determine the Z-axis position within the range of distance Z*±50mm as the near focal segment, and determine other positions on the Z axis as the far focal segment. Furthermore, when it is determined that the maximum score does not change for at least a period of time when the image sensor is in the near focal segment, the acquisition position of the signal corresponding to the maximum score is determined to be the first position. In another example, considering that the image sensor may not collect signals when it is in the first position, the acquisition position of the signal corresponding to the maximum score counted is not the first position. Therefore, it can be first determined that the image sensor has passed the first position when the maximum score does not change for at least a period of time when the image sensor is in the near focal segment. Then, the image sensor can be controlled to return to the acquisition position of the signal corresponding to the maximum score to move at a lower moving speed and / or a higher signal acquisition frequency to collect signals, and the score is counted to update the maximum score. Finally, the acquisition position of the signal corresponding to the updated maximum score is the first position.
[0062] It can be understood that, when the hardware processing speed is fast, the image sensor can achieve real-time statistics of scores after collecting a frame of signal. In this case, the acquisition time of the signal corresponding to the score is the time for calculating the score. Therefore, the position of the image sensor when the score corresponding to the maximum value is calculated can be determined as the first position. On the contrary, when the hardware processing speed is slow, it may take a certain time for the image sensor to collect and process a frame of signal, and it may also take a certain time to calculate the score of the signal quality, that is, there is a certain time difference between the signal acquisition time and the time to obtain the score. Therefore, when determining the first position, the time difference also needs to be considered. In an example, the position of the image sensor can be recorded once for each frame of signal score. The time required for signal acquisition and statistical scoring, that is, the above-mentioned time difference, can be determined in advance through testing. In this way, after determining the maximum value of the score, the second position of the image sensor when the score is recorded can be found first. Then, the position offset is determined according to the product of the moving speed of the image sensor at that time and the time difference. Finally, the accurate first position is obtained according to the second position and the position offset. In another example, the second position of the image sensor and the timestamp at each position can also be recorded in real time to obtain a time series of the second position. Similarly, the image sensor records the signal acquisition time while acquiring the signal, that is, to obtain a signal time series. Similarly, a score time series can also be obtained based on the timestamp (signal acquisition time) carried in the signal time series. In other words, the score of each signal is matched to the timestamp when the signal was acquired. After determining the maximum value of the score corresponding to the focal position, the timestamp corresponding to the score can be searched. The timestamp is the time when the image sensor is located at the first position. Then, the second position corresponding to the timestamp is searched from the time series of the second position as the first position.
[0063] Step S340, controlling the image sensor to move to the first position.
[0064] After accurately determining the best observation position of the image sensor for the current object to be measured, the image sensor can be controlled to move to the best observation position to measure the object to be measured. In this step, the moving speed of the image sensor can be set to be relatively large, thereby further shortening the time consumed by autofocus.
[0065] It can be understood that since step S320 can timely control the image sensor to move to the optimal observation position, when the first position is determined, the position of the image sensor is close to the first position, so the image sensor can be quickly controlled to reach the first position. Both the moving path during the entire mobile exploration process and the moving path for controlling the image sensor to reach the first position are short. Therefore, the control method of the embodiment of the present application can significantly shorten the time required for the autofocus process, and the control efficiency of mobile focus is higher.
[0066] The control method of the image measuring device provided in the embodiment of the present application controls the image sensor to move along the axis direction of the motion axis and performs an exploration operation to quickly and accurately determine the best observation position of the image sensor for the object to be measured in the axis direction. In the exploration operation, by obtaining the quality score of the signal of the object to be measured collected by the image sensor at each moment, according to the change of the score, the target moving direction of the image sensor is quickly and accurately determined and updated, and the image sensor is controlled to move in the target moving direction, so that the image sensor can move toward the first position in most time periods, so that the image sensor quickly approaches and passes through the best observation position. And, according to the change of the score, the best observation position is accurately located, thereby achieving real-time and precise focusing. And, this scheme can achieve the best observation position when the image sensor is close to the best observation position, so that the image sensor can be quickly controlled to move to the best observation position to measure the object to be measured. Thereby, the time spent in the automatic focusing process is significantly saved, the measurement efficiency and measurement accuracy of the image measuring device can be further improved, and the efficient and precise control of the image measuring device is achieved, and the user experience is better.
[0067] In one embodiment, the image sensor includes any one of the following: a visual sensor, a line scan laser sensor, and a spectral confocal displacement sensor.
[0068] The autofocus solution of the three-dimensional image measuring instrument in the prior art is usually only applicable to the case where the image sensor is a visual sensor. However, the image sensor of the three-dimensional image measuring instrument is not only a visual sensor, but also a 3D line scan laser sensor and a spectral confocal displacement sensor. How to control the movement of the machine through the signals of these sensors is a key issue. The autofocus algorithm for the image measuring instrument in the prior art often does not care about the problem of coordination between various types of image sensors and machine control. The control method of the above-mentioned image measuring device provided in the embodiment of the present application comprehensively considers the influence caused by the continuous movement of the sensor in each link of "different sensors collect signal strength-calculation decision-machine execution", and the above-mentioned mobile control scheme that can realize the automatic focus of the image sensor can be applied to the automatic focus control of various image sensors including visual sensors (such as cameras), line scan laser sensors, and spectral confocal displacement sensors, which not only improves the efficiency and accuracy of the autofocus of the three-dimensional image measuring instrument, but also realizes the compatibility of various image sensors, and the user experience is better and the commercial value is higher.
[0069] In one implementation, the control method of the image measuring device provided in the embodiment of the present application further includes:
[0070] During the exploration operation, the moving speed and / or acquisition frequency of the image sensor is determined according to the change of the score.
[0071] In an embodiment of the present application, at the initial moment of the exploration operation, the image sensor can be controlled to move at a preset initial speed, and the signal of the object to be measured can be collected at a preset initial collection frequency. After the initial moment, the moving speed and / or collection frequency of the image sensor can be adjusted according to the change of the focus score of the signal collected by the image sensor over time. As described above, the target moving direction of the image sensor is also adjusted in time during the exploration operation, so that the image sensor can approach the first position. In this step, in the process of the image sensor approaching the first position, the moving speed and / or collection frequency of the image sensor are also adjusted in time according to the change of the focus score of the signal collected by the image sensor over time, so that the image sensor can reach the first position more quickly and locate the first position more accurately.
[0072] In the embodiment of the present application, a variety of appropriate speed determination logics may be used to determine the moving speed of the image sensor according to changes in the score.
[0073] In one embodiment, the moving speed and / or acquisition frequency of the image sensor is determined according to the change in the score, including: determining the bit segment of the image sensor according to the change in the score; determining the moving speed and / or acquisition frequency of the image sensor according to the bit segment.
[0074] In the embodiment of the present application, the bit segment where the image sensor is located can be determined first according to the change of the score in the current time period (which can be a moment or the accumulated time of multiple moments). Then, the moving speed and / or acquisition frequency of the image sensor can be determined according to the determined bit segment.
[0075] In the embodiment of the present application, the position segment where the image sensor is located can represent the position stage where the image sensor is located, specifically reflecting the distance between the image sensor and the first position. For example, the position segment where the image sensor is located is divided into a far focus segment (indicating that the position is far from the first position) and a near focus segment (indicating that the position is close to the first position). In addition, the position segment where the image sensor is located can also represent the movement control stage where the image sensor is located, specifically reflecting the purpose of controlling the movement of the image sensor. Of course, for example, the position segment where the image sensor is located can also be divided into a coarse positioning segment (for example, a movement control stage before determining that the image sensor has passed the first position) and a fine positioning segment (a movement control stage after determining that the image sensor has passed the first position, i.e., the focus search segment hereinafter). Specifically, the coarse positioning segment can be used to control the image sensor to approach the first position to preliminarily locate the approximate position interval of the first position; the fine positioning segment (the focus search segment hereinafter) can control the image sensor to further locate the accurate position of the first position.
[0076] In the embodiment of the present application, different bit segments can match different moving speeds of the image sensor. The optimal moving speeds matched to different bit segments of different image sensors can be determined in advance through a large number of test experiments to obtain the corresponding relationship between the bit segment and the moving speed. After determining the bit segment of the image sensor in each time period, the moving speed of the image sensor in the next time period can be quickly and accurately determined based on the corresponding relationship.
[0077] In the embodiment of the present application, different bit segments can also match different signal acquisition frequencies of the image sensor. Similarly, the optimal moving speed matched to different bit segments of different image sensors can be determined in advance through a large number of test experiments to obtain the corresponding relationship between the bit segment and the signal acquisition frequency. After determining the bit segment of the image sensor in each time period, the acquisition frequency of the image sensor in the next time period can be quickly and accurately determined based on the corresponding relationship.
[0078] In the above scheme, when controlling the image sensor to perform the exploration operation, the position segment of the image sensor is first determined according to the change of the score of the signal collected by the image sensor over time, and then the moving speed and signal collection frequency of the image sensor are determined. The image sensor moves at a more appropriate moving speed in different focusing stages and collects the signal of the object to be measured at a more appropriate signal collection frequency, so that the image sensor reaches the first position more quickly and locates to the first position more accurately. A faster, more accurate and smarter autofocus solution is provided, which has good adaptability and scalability.
[0079] In another embodiment, the moving speed and / or acquisition frequency of the image sensor in the next time period can also be determined directly based on the change in the score of the image sensor over a period of time. For example, an end-to-end deep learning model can be pre-trained. The input of the model can be an ordered array representing the scores collected over a period of time (for example, every 2 seconds), and the output of the model can be the probability that the best moving speed in the next period of time is each speed gear, or the output of the model can be the probability that the best signal acquisition frequency in the next period of time is each frequency gear.
[0080] In the above scheme, in the process of controlling the image sensor to move and perform the exploration operation to locate the best observation position for the object to be measured, the moving speed and / or acquisition frequency of the image sensor are quickly and accurately determined according to the change of the score of the acquisition signal over time. In this way, the image sensor can reach the best observation position more quickly and locate the best observation position more accurately. Thereby, the accuracy and efficiency of the measurement can be further improved.
[0081] In one implementation, the control method of the image measuring device provided in the embodiment of the present application further includes:
[0082] At each moment in the exploration operation, the new score counted at that moment is added to the score window, where the scores in the score window are arranged in the order of the statistical time;
[0083] When the score in the score window is full, delete the first historical score in the score window;
[0084] Determines how the scores in the score window change.
[0085] In the embodiment of the present application, the size of the score window is the upper limit of the number of scores that can be accommodated in the score window, and the size can be set to a variety of appropriate values according to actual needs. Optionally, the size of the score window at each moment in the entire exploration operation can be the same. Alternatively, the size of the score window at different moments in the exploration operation can also be different. For example, the size of the score window of the image sensor is different in different bit segments.
[0086] For example, the size of the score window for a period of time after the exploration operation starts is 2. Before the first frame signal collected by the image sensor is counted, the score window does not contain any score. Then, after the score of the first frame signal collected by the image sensor is counted (for example, called the first frame score), the first frame score can be added to the first position in the score window; after the score of the second frame signal collected by the image sensor is counted, the second frame score is added to the second position in the score window. After the score of the third frame signal collected by the image sensor is counted, since the score window at this moment is full, the first frame score and the second frame score are both historical scores. Since the first frame score is in front, the first frame score is deleted, and the third frame score is added to the score window, where the second frame score is in front and the third frame score is in the back (similar to the form of a sliding window).
[0087] In an embodiment of the present application, the change of the score in the score window is determined based on the difference between the new score in the score window at each moment and one or more historical scores in the score window. For example, the difference between the new score and one of the historical scores can be calculated. Exemplarily, based on the size of the difference, the change trend information such as whether the score is getting bigger or smaller, changing faster or slower can be analyzed. Then, based on the change trend information, the position segment of the image sensor, the target movement direction, the signal acquisition frequency, the movement speed, the size of the score window, etc. can be determined.
[0088] In the exploration operation, the continuously updated score window is used to timely and accurately determine the change of the score of the signal collected by the image sensor over time, so that the moving direction, moving speed, signal collection frequency, etc. of the image sensor can be adjusted in a timely and accurate manner. In addition, this solution has a small amount of calculation, simpler processing, and more accurate calculation, so that real-time and precise control of the image sensor can be achieved, and the user experience is better.
[0089] In one implementation, the segment includes a far focus segment and a near focus segment, and determining the segment where the image sensor is located according to a change in the score includes:
[0090] For each moment in at least some of the moments in the exploration operation, determining a difference between a new score and a historical score in the score window at that moment;
[0091] When the difference is less than or equal to the difference threshold, it is determined that the segment where the image sensor is located is the telephoto segment, wherein the new score is the score counted at this moment, and the historical score is the score counted at at least one moment before this moment;
[0092] When the difference is greater than the difference threshold, determining that the segment where the image sensor is located is a near focus segment;
[0093] Based on the bit segment, determine the image sensor's movement speed and / or acquisition frequency, including:
[0094] When it is determined that the image sensor is at a telephoto section, determining a moving speed of the image sensor to be a first speed and / or determining an acquisition frequency of the image sensor to be a first frequency;
[0095] When it is determined that the image sensor is in a near focus section, the moving speed of the image sensor is determined to be a second speed and / or the acquisition frequency of the image sensor is determined to be a second frequency, wherein the first speed is greater than the second speed and the first frequency is less than the second frequency.
[0096] like Figure 7a As shown, the best observation position of the image sensor for the object to be measured is, for example, the Z* position on the Z axis. From the score change curve in the figure, it can be seen that: when the image sensor is in a segment far from the Z* position, the score changes slowly, and the curvature of the corresponding curve portion is small; when the image sensor is in a segment far from the Z* position, the score changes quickly, and the curvature of the corresponding curve portion is large. Therefore, at least part of the time in the exploration operation (for example, at each time before determining that the image sensor has passed the first position), according to the difference between the new score and the historical score in each time scoring window and the preset difference threshold, it is determined whether the segment where the image sensor is located at that moment is the near focus segment or the far focus segment.
[0097] In the embodiment of the present application, the difference threshold can be set to a suitable value according to actual needs, and different difference thresholds can be set for different image sensors, which can be determined in advance through testing.
[0098] For example, at a certain moment, the size of the score window is 2. Then the absolute value of the difference between the new score counted at the current moment and the historical score counted at the previous moment can be calculated. The difference threshold is, for example, an absolute value threshold. The absolute value threshold is, for example, 20. Then, if the absolute value of the difference between the new score in the score window at the current moment and the historical score is less than or equal to 20, it can be determined that the image sensor is in the telephoto section at the current moment. For example, it means that the image sensor is at the telephoto section at the current moment. Figure 7a In the middle Z0~Za, Zb~Z1 segment, it is far from Z*. If the absolute value of the difference between the new score in the current score window and the historical score is greater than 20, it can be determined that the image sensor is in the near focus segment at the current moment. For example, it means that the image sensor is currently located at Figure 7a The middle section Za~Zb is closer to Z*.
[0099] In an embodiment of the present application, after determining the position segment in which the image sensor is located, the moving speed and / or signal acquisition frequency of the image sensor can be accurately determined and updated. In an embodiment of the present application, the moving speed of the image sensor in the near focus segment can be set to be relatively small, so as to collect signals when the image sensor is at the first position or near the first position as much as possible, so as to facilitate better positioning of the first position. The moving speed of the image sensor in the far focus segment can be set to be relatively large, so that the image sensor can pass through the first position quickly. Similarly, the signal acquisition frequency of the image sensor in the near focus segment can be set to be relatively large, so as to collect signals when the image sensor is at the first position or near the first position as much as possible, so as to facilitate better positioning of the first position. The signal acquisition frequency of the image sensor in the far focus segment can be set to be relatively small, so as to increase the processing speed.
[0100] Specifically, at a certain moment, the moving speed of the image sensor at the next moment can be determined to be the first speed at least based on the situation that the image sensor is in the telephoto section at a certain moment. Exemplarily, the first speed can be greater than a speed threshold (e.g., 1 mm / s). For example, at the initial moment, the image sensor is controlled to start moving at a preset initial speed. The initial speed is, for example, less than or equal to the speed threshold. Figure 7a As shown, if the initial position of the image sensor is close to Z0 and far from Z*, when the score in the score window reaches the upper limit (the size of the score window) for the first time, the image sensor is determined to be in the far focal section according to the situation that the difference between the new score in the score window and the historical score is less than or equal to the difference threshold, and then the moving speed of the image sensor can be increased to the first speed, so that the image sensor quickly approaches the first position Z*. After the image sensor reaches Za, the image sensor can be determined to be in the near focal section according to the situation that the difference between the new score in the score window and the historical score is greater than the difference threshold, and then the moving speed of the image sensor can be reduced to the second speed to facilitate better positioning at the first position.
[0101] In some examples, the initial position of the image sensor is not fixed. Figure 7a , 7b As shown in FIG. 7c , the initial position of the image sensor may be at the far focal length. In this case, the image sensor is successively at the far focal length and the near focal length during the exploration operation. Therefore, its moving speed may be changed from the initial speed to the first speed, and then from the first speed to the second speed. Figure 7d and 7e As shown, the initial position of the image sensor may be in the near focus section. In this case, the image sensor may always be in the near focus section during the exploration operation, so its moving speed may be directly converted from the initial speed to the second speed.
[0102] In the above scheme, the difference between the new score and the historical score in the score window at different times is used to determine whether the image sensor is in the near focus section or the far focus section, and then the moving speed of the image sensor in the near focus section is determined to be less than the moving speed in the far focus section, and the signal acquisition frequency of the image sensor in the near focus section is determined to be greater than the signal acquisition frequency in the far focus section. This "autofocus" scheme based on changes in signal quality scores not only improves the efficiency and accuracy of focusing by intelligently adjusting the moving speed and acquisition frequency of the image sensor, but also optimizes the user experience and equipment performance. It further improves the measurement accuracy and efficiency of image measurement equipment.
[0103] In addition, it can be understood that, unlike the traditional camera focus, in the process of focusing the image sensor, the movement of the image sensor and the signal acquisition are performed synchronously. In addition, the movable range of the image measuring instrument is large, and the moving speed is usually large. For example, the movable range is between 1000mm-2000mm, and the moving speed can reach up to 300mm / s. In addition, the image sensor collects signals, measures signal strength, transmits, calculates scores, etc., which all take time. For example, the exposure and sampling time of a 3D line scan laser sensor alone is as long as 1-2s. Therefore, there is a difference between the time when the image sensor collects each frame of signal and the time when the score of the frame signal is obtained, that is, the delay processing time. During the delay processing time, the image sensor keeps moving, so the position of the image sensor when collecting each frame of signal (signal acquisition position) is often different from the position of the image sensor when calculating the score of the frame of signal. That is, when the score is calculated, the image sensor has moved a short distance, so there is a difference between the acquisition position of the signal corresponding to the score and the position of the image sensor when the score of the signal is obtained, that is, there is a certain position offset.
[0104] Therefore, if the influence of the position offset is not considered, it is very likely that the first position located is not the optimal observation position. In the embodiment of the present application, the influence of the position offset is fully taken into account, and it is creatively proposed that the moving speed of the image sensor when it is in the near focal length is less than the moving speed when it is in the far focal length. In this way, as the image sensor approaches the first position, its moving speed gradually decreases. The smaller the moving speed of the image sensor, to a certain extent, is equivalent to reducing the time-consuming influence of the process of effective sensor sampling to the recording position, so the smaller the position offset, thereby ensuring the reliability of the highest score position (first position) finally obtained. Therefore, the scheme of controlling the moving speed of the image sensor when it is in the near focal length to be less than the moving speed when it is in the far focal length helps to more accurately locate the first position and improve the measurement accuracy and efficiency of the image measuring equipment.
[0105] In one embodiment, the position segment includes a focus search segment. The focus search segment is the above-mentioned precise positioning segment. Determining the position segment where the image sensor is located according to the change in the score also includes: after determining that the image sensor has passed the first position, determining that the position segment where the image sensor is located is the focus search segment;
[0106] Based on the bit segment, determine the image sensor's movement speed and / or acquisition frequency, including:
[0107] When it is determined that the image sensor is in the focus search segment, the moving speed of the image sensor is determined to be a third speed and / or the acquisition frequency of the image sensor is determined to be a third frequency, wherein the third speed is less than the moving speed of the image sensor when it is in other segments outside the focus search segment, and the third frequency is greater than the acquisition frequency of the image sensor when it is in other segments outside the focus search segment.
[0108] It can be understood that, in general, when it is determined based on the change of the score in the score window that the image sensor has passed the first position, the image sensor has left the first position. Figures 7b to 7e As shown, usually when the score of the signal of the image sensor reaches the peak score and gradually falls back, it can be more accurately determined that the image sensor has passed the first position. In order to more accurately locate the first position, when it is determined that the image sensor has passed the first position, the image sensor can be controlled to turn around and continue to perform the precise positioning operation of the first position. In the embodiment of the present application, when the image sensor is in the precise positioning operation, it is determined that the image sensor is in the focus search stage.
[0109] In the embodiment of the present application, after determining that the image sensor has passed the first position, the position segment of the image sensor is determined to be the focus search segment. Optionally, at the moment when it is determined that the image sensor has passed the first position, it is determined that the image sensor is in the focus stage at the next moment. Alternatively, after determining that the image sensor has passed the first position, the image sensor is first controlled to turn around and move in the direction of the first position, and then at the moment when the image sensor successfully turns around, it is determined that the image sensor is in the focus search segment.
[0110] In the embodiment of the present application, when it is determined that the image sensor is in the focus search stage, the moving speed of the image sensor is determined to be a third speed and / or the acquisition frequency of the image sensor is determined to be a third frequency.
[0111] For example, reference Figure 7b and Figure 7c, the image sensor successively experiences the far focal length, the near focal length, and gradually passes through the first position during the exploration operation. After determining that the image sensor has passed the first position according to the change in the score, it turns around and continues to move to perform the precise positioning operation. Therefore, the image sensor also experiences the focus search stage in the final stage of the exploration operation. In this example, the moving speed of the image sensor when it is in the far focal length is the first speed, the moving speed when it is in the near focal length is the second speed, and the moving speed when it is in the focus search stage is the third speed. Among them, the third speed is less than the first speed and the second speed. Specifically, the first speed, the second speed, and the third speed decrease in sequence. In this way, the image sensor can quickly approach the first position at a higher moving speed (first); when approaching the first position, by reducing the moving speed (second speed), a more detailed search can be performed in a smaller range, thereby narrowing the focus search range more quickly; in the final precise positioning stage, using the lowest third speed can ensure that the sensor moves and collects signals at the smallest pace, which helps to achieve accurate positioning of the focus point and improve the accuracy of focusing.
[0112] In an embodiment of the present application, the third speed may be less than the preset speed. The preset speed may be set to a smaller value according to actual needs. For example, the preset speed may be set according to the position offset threshold and the above-mentioned delay processing time. For example, the position offset threshold is 0.2mm, that is, the image sensor collects basically the same signal within 0.2mm, meeting the accuracy requirement. If the delay processing time is, for example, 0.5 seconds, then the preset speed may be set to 0.2 / 0.5=0.4mm / s. That is, the third speed may be set to be less than or equal to 0.4mm / s, so that the influence of the position offset on the measurement result may be minimized, thereby making it more reliable to obtain the highest score position (first position) in the focus search stage, that is, it may be achieved to a certain extent that the highest score position located is the best observation position.
[0113] Of course, in some examples, the image sensor's bit segment may not include the above-mentioned focus search segment. For example, when the image sensor is located at the far focus segment, the image sensor's acquisition frequency is a smaller first frequency, and when the image sensor is located at the near focus segment, the image sensor's acquisition frequency increases to a second frequency. Then, through a period of movement and score collection, the peak score (for example, the score of the image sensor collecting the signal at the Z* position) can be accurately collected. After collecting the peak score, it can be determined that the image sensor has passed the first position based on the fact that the maximum value of the scores accumulated and collected for at least a period of time is the peak score and the score gradually decreases, and the acquisition position of the signal corresponding to the peak score can be determined as the first position. Subsequently, there is no need to perform additional precise positioning (i.e., the focus search segment may not be involved), and step S340 can be directly executed to go to the first position.
[0114] In one embodiment, the size of the score window is different when the image sensor is in different positions, and the size of the score window is equal to the upper limit of the number of scores that can be accommodated in the score window. Determining the change of the score in the score window includes: for each moment in at least part of the moments in the exploration operation, determining the difference between the new score and the historical score in the score window at that moment; the control method of the image measurement device provided by the embodiment of the present application also includes: determining the position segment of the image sensor according to the difference between the new score and the historical score in the score window at the current moment; determining the size of the score window at the next moment according to the position segment of the image sensor, wherein the smaller the distance between the position segment of the image sensor and the first position, the larger the size of the determined score window.
[0115] In the embodiment of the present application, when the image sensor is currently located in the far focal segment, the size of the scoring window at the next moment can be determined to be the first size; when the image sensor is currently located in the near focal segment, the size of the scoring window at the next moment can be determined to be the second size; when the image sensor is currently located in the focus search segment, the size of the scoring window at the next moment can be determined to be the third size. The first size, the second size, and the third size increase in sequence. Figure 8 As shown, the first size can be equal to 2 (i.e., the score window can accommodate at most two scores), the second size can be equal to 3 (i.e., the score window can accommodate at most 3 scores), and the third size can be equal to 8 (i.e., the score window can accommodate at most 8 scores).
[0116] As mentioned above, the moving speed of the image sensor gradually decreases when it is in the far focus section, the near focus section, and the focus search section. Alternatively, the signal acquisition frequency of the image sensor gradually increases when it is in the far focus section, the near focus section, and the focus search section. Figure 9a and Figure 9b As shown, when the image sensor is in the near focus section or the focus search section, the image sensor moves at a low speed or the signal acquisition frequency is high, and the sensor collects signals more densely (for example, the interval between two frames of signal acquisition is only 1mm). It is disturbed by other noise factors such as the fluctuation of the light source and the electrical noise of the sensor, resulting in a slight reverse change in the signal intensity characteristics of the two frames. Therefore, there are some slight reverse fluctuations on the signal score curve. This fluctuation will cause certain interference to the decision of the moving direction of the image sensor. Taking into account the adverse effects of these interference factors on the control of the device, the above-mentioned control method of the embodiment of the present application has different sizes of the scoring windows when the moving speed / signal acquisition frequency is different when the image sensor is in different segments, so that the moving direction of the image sensor can be accurately determined according to the overall change of the signal in the entire scoring window. Thereby, the focusing efficiency and focusing accuracy of the image sensor can be further improved, and the control of the image sensor can be more precise.
[0117] In one embodiment, the control method of the image measuring equipment provided in the embodiment of the present application also includes: obtaining a third position of the image sensor in the axial direction at the moment of counting each score; determining the first position according to the change of the score, including: screening out the first score when the image sensor has passed the first position according to the change of the score; determining the first position according to the third position obtained at the first moment, wherein the first moment is the moment when the first score is counted.
[0118] In one example, when the hardware processing speed is fast, the image sensor can calculate the score in real time after collecting a frame of signal. In this case, the time of collecting the signal corresponding to the score is the time of calculating the score. Therefore, in this example, the third position of the image sensor when the first score is calculated can be determined as the first position.
[0119] In another example, when the hardware processing speed is slow, there is a certain time difference between the acquisition time of a frame signal and the time when the focus score of the signal is obtained. Therefore, when determining the first position, the time difference also needs to be considered. Therefore, the first position can be comprehensively determined based on the third position obtained at the first moment and the position offset of the image sensor within the time difference.
[0120] The execution logic of the method for determining the first position is simpler and more reasonable, the amount of calculation is smaller, and the first position is determined more accurately, so that the image sensor can be automatically focused quickly, and the image measurement equipment can be controlled in real time and accurately.
[0121] In one embodiment, the control method of the image measuring equipment provided in the embodiment of the present application also includes: at each moment of at least part of the moments in the exploration operation, determining the maximum value of each score counted from the initial moment of the exploration operation to the current moment; based on the change of the score, screening out the first score when the image sensor has passed the first position, including: based on the situation that the maximum value determined for at least a period of time has not changed, determining that the image sensor has passed the first position, and determining that the first score is equal to the score corresponding to the maximum value.
[0122] In the embodiment of the present application, at least part of the moments in the exploration operation can be each moment of the exploration operation, that is, each moment between the initial moment of the exploration operation and the moment when the first position is successfully located. In this example, when the score window is filled with scores for the first time, the maximum value of the score in the current window can be recorded as the initial value of the maximum value and stored. For example, the stored maximum value is called the historical maximum value. Afterwards, at the next moment, the maximum value of the score in the score window is compared with the stored historical maximum value. If the maximum value of the score in the score window is greater than the historical maximum value, the value of the former is updated to the historical maximum value; otherwise, the original historical maximum value is retained unchanged. That is, at each subsequent moment, the maximum value of the score in the score window is compared with the historical maximum value stored at that moment, and the historical maximum value is updated according to the comparison result. Of course, in some cases, in order to save computing resources, the frequency of updating the historical maximum value can also be reduced in the exploration operation, such as updating the maximum value every multiple moments. For example, in the case where the score is counted every 0.1 seconds, the update frequency of the historical maximum value can be appropriately reduced, such as updating the historical maximum value every 0.5 seconds. That is, the maximum value of the score collected in the last 0.5 seconds can be compared with the stored historical maximum value, and the historical maximum value can be updated according to the comparison result.
[0123] In the embodiment of the present application, at least a period of time can be set according to actual needs. For example, at least a period of time can be greater than the update frequency of the maximum value in the above example. For example, if the historical maximum value is updated every 0.5 seconds, then at least a period of time can be greater than or equal to 0.5 seconds, such as at least 0.5 seconds, at least 0.6 seconds, etc. In addition, in the example of real-time updating of the historical maximum value (for example, updating the historical maximum value every 0.1 seconds), as the image sensor gradually approaches the first position, the score of the collected signal gradually increases. Therefore, under normal circumstances, the historical maximum value at each moment will be updated. When reaching the first position, the peak score is collected, and the historical maximum value is updated to the value of the peak score (if the signal is not collected when reaching the first position due to the influence of the acquisition frequency and the moving speed, the historical maximum value is the approximate peak score of the adjacent position corresponding to the first position). Thereafter, the historical maximum value will not be updated. Therefore, in an ideal case, it can be directly determined that the image sensor has passed the first position based on the fact that the historical maximum value at a certain moment has not been updated. And determine that the first score is equal to the score of the historical maximum value (i.e., the peak score). However, in some special cases, affected by interference factors, the change trend of the local curve part in the score curve may also be as follows Figure 9a and Figure 9bIn this case, the historical maximum value may not be updated at a certain moment before the image sensor reaches the first position. In order to reduce the impact of such interference factors on the decision, at least a period of time greater than a moment can be set, for example, at least a period of time is at least 0.2 seconds.
[0124] It can be understood that the first score determined by the above scheme may be a peak score corresponding to the first position, or it may be a similar peak score corresponding to a position adjacent to the first position. In some examples, after determining that the image sensor has passed the first position, the signal collection position corresponding to the first score can be calculated, and the signal collection position can be used as the first position to directly control the image sensor to move to the position to collect the signal of the object to be measured. In other examples, after determining that the image sensor has passed the first position, the signal collection position corresponding to the first score can be calculated, and the image sensor can be controlled to move to a smaller area near the position to move and collect signals at a slower speed, and when the maximum value of the signal collected in the area is greater than the first score, the historical maximum value can be further updated, that is, the peak score can be accurately obtained. The signal collection position corresponding to the peak score can be used as the first position.
[0125] The above scheme can timely determine and update the maximum value of the accumulated collected scores during the exploration operation, and timely determine that the image sensor has passed the first position based on the fact that the maximum value of the score has not changed for at least a period of time. After that, the image sensor can be controlled to return to the first position or to the vicinity of the first position to accurately locate the first position. In this way, the unnecessary movement of the image sensor and the time and computing power resources required for signal acquisition can be reduced, thereby improving the efficiency of autofocus.
[0126] In one embodiment, determining the first position based on the third position obtained at the first moment includes: determining the first position based on the third position and a position offset, wherein the position offset is equal to the product of a delayed processing time corresponding to the image sensor and a moving speed at the first moment, and the delayed processing time includes the time spent calculating each score.
[0127] As mentioned above, there is a difference between the time when the image sensor collects each frame signal and the time when the score of the frame signal is obtained, that is, the delayed processing time. During the delayed processing time, the image sensor keeps moving, so the position where the image sensor collects each frame signal (signal collection position) is often different from the position where the image sensor is located when the score of the frame signal is calculated. That is, when the score is calculated, the image sensor has run a short distance, so there is a difference between the collection position of the signal corresponding to the score and the third position where the image sensor is located when the score of the signal is obtained, and there is a certain position offset. In addition, through research, it is found that if a camera, a spectral confocal displacement sensor and a line scanning laser sensor are installed on three different image measuring devices respectively, when the starting position of the image sensor is consistent and the moving speed is consistent, the image sensor is immediately controlled to stop moving when the measurement is completed, then there is a large difference in the stop moving position of the three. In other words, for different image measuring devices, different image sensors have different corresponding delayed processing times, so the corresponding position offsets are also different. Specifically, the position offset corresponding to each image sensor is equal to the product of the delayed processing time corresponding to the image sensor and the moving speed at the first moment.
[0128] In the embodiment of the present application, the corresponding delay processing time is determined in advance for different image sensors through testing, and the position offset is calculated. Fig.10 As shown in the figure, for the camera, spectral confocal displacement sensor and line scan laser image sensor, when the three are aligned for the score calculation completion position of a frame signal, the position offset between the camera shooting position and the score calculation completion position is △a, the position offset between the spectral confocal displacement sensor exposure position and the score calculation completion position is △b, and the position offset between the line scan laser sensor scanning position and the score calculation completion position is △c. It can be seen from the figure that △a<△b<△c.
[0129] It can be understood that the lower the moving speed of the image sensor, the lower the position offset. In the extreme case, when the moving speed is always 0, the position offset is 0, but the moving speed of the image sensor in the actual process cannot be 0. In the embodiment of the present application, the position offset is also calculated based on the delayed processing time corresponding to the image sensor and the moving speed at that moment. Thereby, the positioning accuracy of the first position can be further improved. The above scheme takes into account the position offset between the score acquisition position and the signal acquisition position caused by the delayed processing time corresponding to the image sensor, so that the image sensor can be controlled to reach the first position more accurately, thereby significantly improving the measurement accuracy of the image measurement device.
[0130] In addition, as mentioned above, in the process of precisely positioning the first position in the final stage (focusing stage) of the exploration operation, the moving speed of the image sensor can be set to a smaller third speed. It can be understood that when the third speed is smaller, the calculated position offset is also smaller, thereby further reducing the influence of the position offset on the measurement result.
[0131] In one embodiment, the target movement direction of the image sensor is determined and updated based on the change in the score, including: for each moment in at least part of the moments in the exploration operation, based on the situation that the new score in the score window at that moment is less than the historical score in the score window, determining that the target movement direction of the image sensor at the next moment is opposite to the current movement direction; and / or based on the situation that the new score is greater than or equal to the historical score in the score window, determining that the target movement direction of the image sensor at the next moment is the same as the current movement direction.
[0132] By way of example and not limitation, in the exploration operation, when the score window is full and includes a new score obtained at the current moment, the target movement direction of the image sensor at the next moment is determined to be opposite to the current movement direction based on the fact that the new score in the score window at this moment is less than the historical score in the score window; or, the target movement direction of the image sensor at the next moment is determined to be the same as the current movement direction based on the fact that the new score is greater than or equal to the historical score in the score window. Figure 8 In the example of the three-stage scoring window shown, the target moving direction can be determined once for each frame of new signal score obtained from the moment of obtaining the score of the second frame to each moment before entering the focus search stage. In this way, the target moving direction can be updated in real time, so that the image sensor can be controlled accurately in real time. In particular, for the situation where the new score in the scoring window at this moment is less than the historical score in the scoring window, the solution of determining that the target moving direction of the image sensor at the next moment is opposite to the current moving direction can be timely adjusted when the image sensor does not move toward the first position, so that the image sensor is facing the first position at most moments during the exploration process, so that the image sensor can quickly approach and reach the first position.
[0133] Specifically, in some cases, when the new score in the scoring window at this moment is less than the historical score in the scoring window, it can be determined that the target moving direction of the image sensor at the next moment is opposite to the current moving direction. In other cases, when the new score in the scoring window at this moment is less than the historical score in the scoring window, it is also necessary to determine whether other conditions for changing the direction are met at the current moment. Only when other conditions are met at the same time, it is determined that the target moving direction of the image sensor at the next moment is opposite to the current moving direction.
[0134] In the embodiment of the present application, when the size of the score window is equal to 2, the size of the new score and the historical score in the score window can be directly compared. When the size of the score window is greater than 2, the size of the new score in the score window and any historical score in the score window can be specifically compared, or the size of the new score and a specific historical score in the score window (for example, the first historical score in the score window or the last historical score in the score window) can be compared. Alternatively, the size of the new score in the score window and each historical score in the score window can be compared to obtain a comprehensive comparison result. Alternatively, the size of the new score in the score window and the average of all historical scores can be compared.
[0135] In a specific example, if Figure 8 As shown, in the near focus section, the window size is 3, and the size of the new score in the score window and the first historical score (i.e., the earliest historical score obtained) can be directly compared. For example, when the score of the 5th frame is obtained, the size between the score of the 5th frame and the score of the 3rd frame can be compared. If the former is greater than or equal to the latter, it can be determined that the moving direction of the image sensor at the next moment remains unchanged; otherwise, it is determined that the moving direction of the image sensor at the next moment is opposite to the current moving direction.
[0136] In this solution, the moving direction of the image sensor can be accurately determined in real time during the autofocus process of the image sensor. The image sensor can be controlled to turn around in time when the initial moving direction deviates from the first position or when the image sensor has passed the first position, so that the image sensor moves toward the first position during most of the time period during the autofocus process, which can reduce invalid movement and effectively improve the autofocus efficiency.
[0137] In one embodiment, the control method of the image measuring device provided in the embodiment of the present application also includes: at each moment in the exploration operation, determining the maximum value of each score counted from the initial moment of the exploration operation to the current moment; based on the situation that the new score in the score window at this moment is less than the historical score in the score window, determining that the target movement direction of the image sensor at the next moment is opposite to the current movement direction, including: when the image sensor is in a near focus section, if the new score is less than the historical score in the score window and the scores in the score window are all less than the maximum value, then determining that the target movement direction of the image sensor at the next moment is opposite to the current movement direction.
[0138] like Figure 9bAs shown, for example, the signal collection position corresponding to the peak 1 of the score curve in the figure can be the first position Z*, and the signal collection position corresponding to the peak 2 of the score curve in the figure (for example, recorded as Z') can be between Z* and Z1 and close to Z*. If the starting position of the image sensor is at Z1, the above-mentioned control method of the embodiment of the present application can be used to control the image sensor from the far focal length to the near focal length, and continuously approach Z*, the score in the score window continues to increase, and the maximum value of the accumulated statistical score (that is, the historical maximum value) is continuously updated. At the moment when the image sensor passes through Z' and obtains the focus score (for example, called the peak 2 score) of the signal collected at this position, the historical maximum value can be updated to the peak 2 score. The image sensor continues to move, as Figure 9b As shown, affected by interference factors, the signal score between peak 2 and peak 1 may be less than the historical maximum value (peak 2 score) at this moment. However, since the historical maximum value is still in the current score window (the size of the score window of the near focus section is larger), it means that the image sensor has not completely passed the first position at this time. Therefore, the image sensor is still controlled to keep moving in the original direction of movement, so that the image sensor can reach Z* and the historical maximum value can be updated to the peak 1 score. Finally, when the new score in the score window is less than the historical score and the scores in the score window are all less than the peak 1 score (that is, the historical maximum value is not in the current score window), it can be determined that the image sensor has passed the first position. At this time, the image sensor can be controlled to turn. After successfully turning, the image sensor can be controlled to go to the position corresponding to the peak 1 score for measurement. Alternatively, after successfully turning, entering the focus search section, the image sensor can be controlled to perform a precise positioning operation near the position corresponding to the peak 1 score to accurately determine the first position.
[0139] The above solution can further improve the accuracy of automatic focus control of the image sensor and improve the measurement accuracy of the image measuring equipment.
[0140] Fig.11 A flow chart showing a control method of an image measuring device according to another embodiment of the present application is shown. Fig.11As shown, in general, at the beginning of the exploration operation, that is, when the autofocus is started, the image sensor can be controlled to move at the default initial speed and initial direction. At each moment in the movement process, the position offset corresponding to each frame signal can be dynamically calculated for the image sensor. At the same time, the signal strength score of each signal collected by the image sensor (that is, the aforementioned focus score) is calculated and recorded. By analyzing the changes in the focus scores of some signals collected successively, it is determined in real time whether the current moving direction is correct. It is also possible to determine the current focus stage (that is, the position segment) of the image sensor. When it is determined that the image sensor is in the far focus segment, the moving speed of the image sensor in the position segment can be controlled to be a larger first speed; when it is determined that the image sensor is in the near focus segment, the moving speed of the image sensor in the position segment can be controlled to be a smaller second speed to reduce the impact of real-time movement on the decision. In addition, by analyzing the changes in the signal score, it is determined whether the image sensor has passed the optimal observation position (first position). After determining that the image sensor has passed the optimal observation position, the image sensor is controlled to change direction and enter the last stage of the exploration process, namely the focus search stage, and the image sensor is controlled to move to the optimal observation position at a slow third speed (the third speed is less than the second speed), and the optimal observation position is accurately located in combination with the dynamically calculated position offset. After that, the image sensor can be controlled to move quickly to the optimal observation position to accurately measure the object to be measured. In this way, fast and accurate autofocus can be achieved for various types of image sensors. It should be noted that before the speed change command is issued, the image sensor can maintain a uniform speed; after the speed change command is issued, the Z axis will continue to maintain a uniform speed when it reaches the new target speed; and the movement of the Z axis does not stop.
[0141] Specifically, combined Figure 7b to Figure 7e as well as Fig.11 The control process of the image measuring device can be divided into four stages at most, wherein the first three stages are stages for exploring the best observation position for the object to be measured (i.e., the exploration operation in the embodiment of the present application), and the fourth stage is the stage for going to the best observation position after finding it (i.e., Figure 7b to Figure 7e to the focal length shown in ).
[0142] First, at the initial moment of the exploration operation, the position of the image sensor in the Z-axis direction is random (it may be located in the far focal length or near focal length between Z0 and Z*, or in the near focal length or far focal length between Z* and Z1). The initial movement direction of the image sensor is also random, and may be toward Z* or away from Z*.
[0143] Figure 7b to Figure 7e Similar movement trajectories under four different initial positions of the image sensor are shown and listed respectively.
[0144] Fig.11The first stage shown in FIG. 1 is the telephoto stage (for the case where the initial position of the image sensor is far from the optimal observation position). Figure 7b and 7c As shown, the initial position of the image sensor is far from the optimal observation position, and the initial moving direction may be toward the optimal observation position or away from the optimal observation position. During the movement process, the signal collected by the image sensor will be acquired in real time, and the focus score of each frame signal will be calculated. Then, the focus score is stored in the sampling score window. The default size of the score window is A, that is, there are at most A scores in the window (such as when A=2, there are at most 2 score records in the window). During the movement process, every time a latest focus score is calculated, the score is placed in the sampling score window. When there are 2 scores in the sampling score window, a decision can be made: according to the score change, confirm whether it is currently moving in the direction of the optimal observation position (determine the moving direction at the next moment), the position segment of the image sensor, and the moving speed of the image sensor. Since the score changes less in the telephoto segment, it can be determined that the image sensor is in the telephoto segment when the difference between the new score and the historical score in the score window is less than the difference threshold. And the moving speed of the image sensor can be determined to be the larger first speed. In this way, the difference between the scores of the two frames of signals in the score window is relatively large, and it is difficult for the decision to be affected by noise fluctuations, so the sampling score window size in the first stage is often small, for example, 2.
[0145] In the first stage, when the score in the score window is full, a decision can be made. A few specific scores in the score window can be obtained for mathematical calculation, and then the moving direction of the image sensor at this time (whether it is toward the best observation position) and the position segment it is in can be inferred based on the results, so as to make instructions that affect the subsequent movement of the Z-axis motor. For example, the oldest score and the latest score in the score window are obtained for difference calculation. If the difference is less than 0, it means that the focus score has become lower, indicating that the current moving direction of the image sensor deviates from the best observation position, so the first decision is issued to the Z-axis motor: turn around. During the process of turning around, since the machine is in the speed change stage at this time (that is, the original speed is A, and it becomes -A after a certain period of time), the dynamic offset calculation during this period will be suspended. When the machine movement speed has become -A, it is considered that the turn has been successful. If the difference is greater than 0, it means that the focus score is gradually increasing, that is, the initial moving direction is toward the best observation position, and a decision to maintain the current moving direction can be issued.
[0146] Exemplarily, in this stage, when the sampling score window is full, the latest score in the sampling score window can be retained, and then the oldest score in the sampling score window can be deleted to update the window. As long as the window is still full after the update, mathematical operations and decision execution will continue. By analogy, the sampling score window will continuously update the latest score, and mathematical operations will be performed in real time to obtain decisions. The decision results can be used to infer in real time whether the current moving direction of the image sensor is correct (i.e., whether it is facing the best observation position), and the image sensor can be guided to gradually move to the best observation position through repeated decisions.
[0147] It can be understood that as the image sensor position gets closer to the optimal observation position, the score difference in the sampling score window will gradually increase. When the difference between the new score and the historical score is greater than or equal to the difference threshold, it is determined that the image sensor enters the second stage (i.e., the near focus stage).
[0148] After the image sensor enters the second stage (near focal length), the Z-axis movement speed can be controlled to decrease to the second speed by adjusting the operating parameters of the Z-axis motor, such as 1 / 4 or 1 / 8 of the first speed. At the same time, the size of the sampling score window is adjusted, specifically from A to B (for example, A=2, B=3). The specific reduction in the second speed can be adjusted according to the window change. Since the decision is easily affected by the noise fluctuation of the score at a slow speed, increasing the size of the sampling score window can reduce the adverse effect of the fluctuation on the decision.
[0149] In some cases, such as Figure 7e As shown, the initial position of the image sensor may also be in the near focal length, and the forward direction is away from the optimal observation position. According to the new score in the scoring window being less than the historical score, it can be determined that the current moving direction is wrong, and the image sensor is controlled to turn around and move toward the optimal observation position.
[0150] When the image sensor is in the near-focus section and gradually approaches the optimal observation position, the score gradually increases, and the maximum score during this period is often in the current score window. After the image sensor exceeds the optimal observation position, the maximum score will not change, but the score will gradually decrease. Therefore, it can be determined that the image sensor has passed the optimal observation position at least based on the difference between the new score and the historical score in the score window being less than 0. In order to make the control more precise, if the score gradually decreases in the sampling score window of the second stage, and the highest score in the sampling score window is lower than the highest score previously recorded, it is considered that the optimal observation position has been passed at this time and is moving in the direction away from the optimal observation position. At this time, it can be determined that the image sensor has entered the third stage (focus search section), and the image sensor can be controlled to turn around and perform precise positioning operations.
[0151] In the second stage when the image sensor is in the close focus stage, the new score and the historical maximum value can continue to be compared in real time. If the new score is the highest score ever, the Z-axis position corresponding to the signal of the highest score can be refreshed.
[0152] When the image sensor enters the third stage, it means that the image sensor has passed the optimal observation position, but due to speed, it may not collect signals at the optimal observation position (that is, the scoring window does not contain the peak score in the scoring curve). Therefore, the image sensor can be controlled to turn around and move back to the optimal observation position. In the third stage, the movement speed of the Z axis can be controlled to decrease again, and the sampling scoring window can be enlarged again, so that the image sensor can collect signals at the optimal observation position. For example, combined with Figure 8 , the window size at this stage can be 8. It should be noted that, considering that the moving speed of the image sensor at this stage is much smaller than that in the second stage, in order to improve the accuracy of the decision (reduce the interference caused by the large difference in the score span), when the image sensor is first determined to be in the focus search stage, the score in the score window can be cleared. Figure 8 As shown, the scores of the first scoring window of the focus search segment can all be the scores of the signals collected after entering the focus search segment. At the same time, the value of the position offset is made as low as possible (the lower the speed, the lower the position offset). In the third stage, the scores of the latest signal strengths are constantly compared, and the Z-axis position corresponding to the signal strength frame with the highest score is refreshed. Then, if the difference between the new score and the historical score in the scoring window is less than 0, and the historical maximum value is not in the current scoring window, the third stage can be ended and the fourth stage can be entered. And the best observation position can be determined based on the signal collection position corresponding to the updated historical maximum value.
[0153] It can be understood that the fundamental purpose of the third stage is to slowly scan the area near the best observation position at a slower speed to ensure that the peak signal intensity can be captured and the corresponding position can be recorded. This is because from the focus score curve, it can be seen that due to the influence of noise, there may be multiple peaks in the score curve area of the best observation position. Because the historical maximum value is constantly updated during movement, slow movement can minimize the risk of missing the real peak signal.
[0154] In the fourth stage (i.e. Figure 7a to Figure 7e There is no need to count the scores or make decisions with a scoring window. Instead, the image sensor is indirectly controlled to return to the best observation position by controlling the Z-axis motor. For example, the image sensor can be controlled to move to the best observation position at a faster fourth speed. Furthermore, the image sensor can be controlled to measure the object to be measured at this position.
[0155] In the above scheme, in the process of controlling the image sensor to move and perform the exploration operation, the image sensor is gradually controlled to approach the best observation position through multiple stages of judgment. After determining that the image sensor passes the best observation position, the score of the signal collected by the image sensor at the best observation position can be obtained through further precise positioning, so as to accurately locate the best observation position. By reducing the speed in the above multiple stages, the machine speed is gradually reduced, so that the calculated dynamic position offset is smaller, so that the time-consuming influence of the intermediate links (i.e., each link from the start of sampling the signal to obtaining the score of the signal) can be avoided. Through multi-stage calculation and decision-making, the moving speed is gradually reduced. Therefore, each time entering the next stage, the position offset will be reduced, which is equivalent to reducing the time-consuming influence of the process of sensor sampling to the recording position, thereby ensuring the reliability of obtaining the highest score position in the final stage, so that the highest score position is as close to the best observation position as possible. And in this scheme, by gradually reducing the speed and gradually reducing the movement error, the final stop position of the image sensor is as close to the best observation position as possible. Thus, the path in the fourth stage is shorter.
[0156] In addition, during the exploration operation, specifically in the first to third stages, if the next stage cannot be entered smoothly due to some unexpected circumstances, such as moving to the limit point of the Z axis (that is, the end of the Z axis) and being unable to move forward, this autofocus will also end by moving to the position corresponding to the currently recorded highest historical focus score.
[0157] Finally, the overall moving path of the autofocus process of this scheme ( Figures 7a to 7e The dotted line in the figure indicates the path), compared with the moving path of the traditional autofocus solution ( Figure 2 The dotted line in the figure indicates the path). This solution has a shorter total distance to move, and because the moving speed at different stages is dynamically adjusted, it is not easy to miss the peak position, so the probability of successful focusing is higher and the focusing is more accurate. This can significantly improve the measurement accuracy and efficiency of image measurement equipment.
[0158] The present application also provides an image measurement device. Fig.12 As shown, the image measuring device 1200 includes: an image sensor 1210, a motion axis 1220, a driving component 1230 and a control module 1240, wherein the image sensor 1210 is arranged on the motion axis 1220, the driving component 1230 is connected to the motion axis 1220 and is used to drive the motion axis 1220 to move, so as to drive the image sensor 1210 to move along the axis direction of the motion axis 1220, and the control module 1240 is respectively connected to the driving component 1230 and the image sensor 1210, wherein the control module 1240 is used to execute the steps of the control method of the above-mentioned image measuring device.
[0159] The present application also provides a control device for an image measuring device. Fig.13 As shown, the control device 1300 of the image measuring device includes: an acquisition module 1310, which is used to obtain the quality score of the signal of the object to be measured collected by the image sensor at each moment when the image sensor moves along the axial direction of the moving axis and performs the exploration operation; wherein the exploration operation is used to locate the first position of the image sensor in the axial direction; the quality of the signal collected by the image sensor at the first position is higher than the quality of the signal collected at any second position; the second position is other positions except the first position in the axial direction; the time interval between two adjacent moments is less than the time interval threshold; a first determination module 1320, which is used to determine the target moving direction of the image sensor according to the change of the score, so that the image sensor is close to the first position; a second determination module 1330, which is used to determine the first position according to the change of the score; and a moving module 1340, which is used to control the image sensor to move to the first position.
[0160] like Fig.14 As shown, the embodiment of the present application further provides a terminal device 1400, including: at least one processor 1410 ( Fig.14 Only one processor is shown in the figure), a memory 1420, and a computer program 1430 stored in the memory 1420 and executable on at least one processor 1410. When the processor 1410 executes the computer program 1430, the steps of the control method of the above-mentioned image measuring device are implemented.
[0161] The terminal device may include but is not limited to a processor and a memory. Fig.14 It is only an example of a terminal device and does not constitute a limitation on the terminal device. It may include more or fewer components than shown in the figure, or combine certain components, or different components. The processor may be a central processing unit (CPU), and the processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0162] The embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the steps in the control method of the above-mentioned image measuring device can be implemented.
[0163] The embodiment of the present application provides a computer program product. When the computer program product is executed on a terminal device, the terminal device can implement the steps in the control method of the above-mentioned image measuring device.
[0164] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / modules are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0165] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. The functional modules in the embodiment can be integrated into a processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The above-mentioned integrated modules can be implemented in the form of hardware or in the form of software functional modules. In addition, the specific names of the functional modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the modules in the above-mentioned devices, equipment, and systems can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0166] Various aspects of the apparatus, devices, systems, and methods described herein may be implemented as functions programmed into any of a variety of circuits, including programmable logic devices (PLDs), such as field programmable gate arrays (FPGAs), programmable array logic (PAL) devices, electronic programmable logic and storage devices, standard cell-based devices, and application-specific integrated circuits (ASICs). Some other possibilities for implementing these aspects of the system include: microcontrollers with memory, such as electronically erasable programmable read-only memory (EEPROM), embedded microprocessors, firmware, software, etc. In addition, these aspects of the system may be embodied in microprocessors with software-based circuit simulation, discrete logic (sequential and combinational), custom devices, fuzzy (neural) logic, quantum devices, and combinations of any of the above various device types. Of course, the underlying device technology may be provided in a variety of component types, such as metal oxide semiconductor field effect transistor (MOSFET) technology such as complementary metal oxide semiconductor (CMOS), bipolar technology such as emitter coupled logic (ECL), polymer technology (e.g., silicon conjugated polymer and metal conjugated polymer metal structure), hybrid analog and digital, etc.
[0167] The various functions or processes disclosed herein may be described as data and / or instructions embodied in various computer-readable media in terms of their behavior, register transfers, logic components, transistors, geometric layouts, and / or other characteristics. Computer-readable media that may contain such formatted data and / or instructions include, but are not limited to, various forms of non-volatile storage media (e.g., optical, magnetic, or semiconductor storage media) and carrier waves, which may be used to transmit such formatted data and / or instructions via wireless, optical, or wired signal media, or any combination thereof. When received in any of a variety of circuits (e.g., computers), such data and / or instructions may be processed by a processing entity (e.g., one or more processors).
[0168] The above description of the illustrated embodiments of the systems and methods is not intended to be exhaustive or to limit the systems and methods to the precise forms disclosed. Although specific embodiments and examples of the system components and methods are described herein for illustrative purposes, it will be appreciated by those skilled in the art that various equivalent modifications may be made within the scope of the systems, components, and methods. The teachings of the systems and methods provided herein may be applied to other processing systems and methods, not just to the above-described systems and methods.
[0169] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A control method for an image measuring device, characterized in that: include: At each moment when the image sensor moves along the axial direction of the motion axis and performs an exploration operation, a score of the quality of the signal of the object to be measured collected by the image sensor is obtained; wherein the exploration operation is used to locate the first position of the image sensor in the axial direction; the quality of the signal collected by the image sensor at the first position is higher than the quality of the signal collected at any second position; the second position is a position other than the first position in the axial direction; the time interval between two adjacent moments is less than a time interval threshold; Determining and updating a target moving direction of the image sensor according to a change in the score, and controlling the image sensor to move in the target moving direction so that a distance between the image sensor and the first position becomes smaller; determining the first position according to a change in the score; The image sensor is controlled to move to the first position.
2. The control method of the image measuring device according to claim 1, characterized in that: The method further comprises: During the exploration operation, the moving speed and / or acquisition frequency of the image sensor is determined according to the change of the score.
3. The control method of the image measuring device according to claim 2, characterized in that: Determining the moving speed and / or acquisition frequency of the image sensor according to the change of the score includes: Determining the position segment of the image sensor according to the change of the score; The moving speed and / or acquisition frequency of the image sensor is determined according to the bit segment.
4. The control method of the image measuring device according to claim 3, characterized in that: The segment includes a far focus segment and a near focus segment, and determining the segment where the image sensor is located according to a change in the score includes: For each moment in at least some of the moments in the exploration operation, determining a difference between a new score and a historical score in the score window at that moment; When the difference is less than or equal to the difference threshold, determining that the segment where the image sensor is located is a telephoto segment, wherein the new score is a score counted at this moment, and the historical score is a score counted at at least one moment before this moment; When the difference is greater than the difference threshold, determining that the segment where the image sensor is located is a near focus segment; Determining the moving speed and / or acquisition frequency of the image sensor according to the bit segment includes: When it is determined that the image sensor is in a telephoto section, determining a moving speed of the image sensor to be a first speed and / or determining an acquisition frequency of the image sensor to be a first frequency; When it is determined that the image sensor is in a near focus section, the moving speed of the image sensor is determined to be a second speed and / or the acquisition frequency of the image sensor is determined to be a second frequency, wherein the first speed is greater than the second speed and the first frequency is less than the second frequency.
5. The control method of the image measuring device according to claim 3, characterized in that: The bit segment includes a focus search segment, and determining the bit segment where the image sensor is located according to a change in the score further includes: After determining that the image sensor has passed the first position, determining that the position segment of the image sensor is a focus search segment; Determining the moving speed and / or acquisition frequency of the image sensor according to the bit segment includes: When it is determined that the image sensor is in the focus search segment, the moving speed of the image sensor is determined to be a third speed and / or the acquisition frequency of the image sensor is determined to be a third frequency, wherein the third speed is smaller than the moving speed of the image sensor when it is in other segments outside the focus search segment, and the third frequency is greater than the acquisition frequency of the image sensor when it is in other segments outside the focus search segment.
6. The control method of the image measuring device according to any one of claims 1 to 5, characterized in that: The method further comprises: At each moment in the exploration operation, a new score counted at that moment is added to a score window, wherein each score in the score window is arranged in the order of the statistical time; When the score in the score window is full, deleting the first historical score in the score window; Determine the change of the score in the score window.
7. The control method of the image measuring device according to claim 6, characterized in that: The size of the score window when the image sensor is in different bit segments is different, and the size of the score window is equal to the upper limit of the number of scores that can be accommodated in the score window, and determining the change of the score in the score window includes: For each moment in at least some of the moments in the exploration operation, determining a difference between a new score and a historical score in the score window at that moment; The method further comprises: Determining the bit segment where the image sensor is located according to the difference between the new score and the historical score in the current scoring window; The size of the score window at the next moment is determined according to the bit segment where the image sensor is located, wherein the smaller the distance between the bit segment where the image sensor is located and the first position is, the larger the size of the determined score window is.
8. The control method of the image measuring device according to any one of claims 1 to 5, characterized in that: The method further comprises: At the moment when each score is counted, obtaining a third position of the image sensor in the direction of the axis; The determining the first position according to the change of the score includes: According to the change of the score, filtering out the first score when the image sensor has passed the first position; The first position is determined according to a third position obtained at a first moment, wherein the first moment is a moment when the first score is calculated.
9. The control method of the image measuring device according to claim 8, characterized in that: The determining the first position according to the third position acquired at the first moment includes: The first position is determined according to the third position and the position offset, wherein the position offset is equal to the product of the delayed processing time corresponding to the image sensor and the moving speed at the first moment, and the delayed processing time includes the time spent calculating each score.
10. An image measuring device, characterized in that: include: An image sensor, a motion axis, a drive component and a control module, wherein the image sensor is arranged on the motion axis, the drive component is connected to the motion axis and is used to drive the motion axis to move so as to drive the image sensor to move along the axial direction of the motion axis, and the control module is respectively connected to the drive component and the image sensor, wherein the control module is used to execute the steps of the control method of the image measuring device according to any one of claims 1 to 9.