A method and apparatus for automatic zooming
Patent Information
- Application Number
- CN202411303812.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-19
- Publication Date
- 2026-10-09
- Estimated Expiration
- 2044-09-19
AI Technical Summary
[0004]针对现有技术的至少一个缺陷或改进需求,本发明提供了一种自动变倍的调节方法及装置,解决了通过人员控制电机调节方式无法做到精确倍率调节,且调节耗时长,存在无法保证多工位一致性及重复精度的问题,实现了高精度快速调节,保证了多工位一致性及重复精度
[0016] This invention provides an automatic zoom adjustment method that automatically adjusts three drive mechanisms: a first drive mechanism to move the camera and lens as a whole to achieve working distance adjustment and focusing; a second drive mechanism to move the camera to achieve back focal length adjustment; and a third drive mechanism to rotate the lens to achieve front focal length adjustment. This method achieves high-precision and rapid adjustment while ensuring consistency and repeatability across multiple workstations.
Smart Images

Figure CN119946422B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of visual inspection, and more specifically, to an automatic zoom adjustment method and apparatus. Background Technology
[0002] In visual inspection, different requirements are placed on the camera and lens of visual inspection equipment due to the different sizes and resolutions of the inspected products. In actual inspection, when the products to be inspected change frequently, in order to avoid constantly changing the configuration of the inspection instrument, the lens is generally designed to be compatible to ensure that it can be adjusted without disassembling the lens, so as to adapt to different inspection environment requirements.
[0003] Currently, automatic zoom devices involve adjusting the front focal length, back focal length, working distance, and focus. Precise magnification adjustment cannot be achieved by manually controlling the motor, and the adjustment is time-consuming. There are also problems with the consistency and repeatability of multiple stations. Summary of the Invention
[0004] To address at least one defect or improvement requirement in the prior art, this invention provides an automatic zoom adjustment method and apparatus, which solves the problems that manual motor adjustment cannot achieve precise zoom adjustment, is time-consuming, and cannot guarantee consistency and repeatability across multiple workstations. This invention achieves high-precision and rapid adjustment, ensuring consistency and repeatability across multiple workstations.
[0005] To achieve the above objectives, according to a first aspect of the present invention, an automatic zoom adjustment method is provided. The method includes: acquiring a detection image of an object to be inspected; determining a current magnification based on the detection image; calculating the absolute value of the difference between the current magnification and a target magnification, and defining it as an absolute difference; if the absolute difference is greater than a preset difference, calculating the movement distance of a drive mechanism, wherein the drive mechanism includes a first drive shaft for moving the camera and lens as a whole, a second drive shaft for moving the camera, and a third drive shaft for rotating the lens; automatically adjusting the drive mechanism according to the movement distance until the target magnification is reached to complete the automatic zoom, wherein the movement distance includes a first movement distance of the first drive shaft, a second movement distance of the second drive shaft, and a third movement distance of the third drive shaft.
[0006] In an exemplary embodiment, calculating the movement distance of the drive mechanism includes: obtaining a fitting function between magnification and working distance; determining a first distance of the fitting function at a target magnification value, wherein the first distance is the working distance from the lens to the object under inspection when the magnification is the target magnification; determining a second distance of the fitting function at a current magnification value, wherein the second distance is the working distance from the lens to the object under inspection when the magnification is the current magnification; determining a third distance of the fitting function at a set magnification value, wherein the set magnification is obtained by removing a set error from the target magnification; and determining the first movement distance in the movement distance based on the first distance, the second distance, and the third distance.
[0007] In one exemplary embodiment, the calculation of the travel distance of the drive mechanism includes: determining the current position and travel direction of the second drive shaft; and determining a second travel distance in the travel distance based on the current magnification and the target magnification, combined with the current position of the shaft and the travel direction.
[0008] In an exemplary embodiment, calculating the movement distance of the drive mechanism includes: obtaining the first absolute position of the third drive shaft when the lens magnification is a first magnification; obtaining the second absolute position of the third drive shaft when the lens magnification is a second magnification; calculating the target magnification absolute position based on the target magnification, the first absolute position, and the second absolute position; and determining the third movement distance in the movement distance using the target magnification absolute position and the current position of the third drive shaft.
[0009] In an exemplary embodiment, before acquiring a detection image of the object to be inspected and determining the current magnification based on the detection image, the method further includes: automatically exposing the object to be inspected based on the target brightness; and automatically focusing the automatically exposed object to be inspected based on the target sharpness.
[0010] In an exemplary embodiment, after acquiring a detection image of the object to be inspected and determining the current magnification based on the detection image, the method further includes: calculating the absolute value of the difference between the current mapping and the target mapping, and determining it as the absolute error; if the absolute error is greater than a preset error, calculating the moving distance of the drive mechanism; and automatically adjusting the drive mechanism according to the moving distance until the target mapping is reached and automatic magnification is completed.
[0011] In an exemplary embodiment, the automatic adjustment of the drive mechanism according to the moving distance until the target magnification is reached to complete the automatic zoom includes: controlling the first drive shaft to move the camera and the lens as a whole by the first moving distance; controlling the second drive shaft to move the camera by the second moving distance; and controlling the third drive shaft to rotate the lens by the third moving distance.
[0012] According to a second aspect of the present invention, an automatic zoom adjustment device is also provided, comprising: an acquisition unit for acquiring a detection image of an object to be inspected and determining a current magnification based on the detection image; a determination unit for calculating the absolute value of the difference between the current magnification and a target magnification and determining it as an absolute difference; a first calculation unit for calculating a moving distance of a drive mechanism when the absolute difference is greater than a preset difference, wherein the drive mechanism includes a first drive shaft for moving the camera and lens as a whole, a second drive shaft for moving the camera, and a third drive shaft for rotating the lens; and a first adjustment unit for automatically adjusting the drive mechanism according to the moving distance until the target magnification is reached to complete the automatic zoom, wherein the moving distance includes a first moving distance of the first drive shaft, a second moving distance of the second drive shaft, and a third moving distance of the third drive shaft.
[0013] According to a third aspect of the invention, a computer-readable storage medium is also provided, wherein a computer program is stored therein, wherein the computer program is configured to execute the above-described automatic zoom adjustment method when it is run.
[0014] According to a fourth aspect of the present invention, an electronic device is also provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the above-described automatic zoom adjustment method via the computer program.
[0015] In summary, compared with the prior art, the above-described technical solutions conceived by this invention can achieve the following beneficial effects:
[0016] This invention provides an automatic zoom adjustment method that automatically adjusts three drive mechanisms: a first drive mechanism to move the camera and lens as a whole to achieve working distance adjustment and focusing; a second drive mechanism to move the camera to achieve back focal length adjustment; and a third drive mechanism to rotate the lens to achieve front focal length adjustment. This method achieves high-precision and rapid adjustment while ensuring consistency and repeatability across multiple workstations. Attached Figure Description
[0017] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0018] Figure 1 A flowchart illustrating an optional automatic zoom adjustment method provided in this application embodiment;
[0019] Figure 2 A flowchart illustrating another optional automatic zoom adjustment method provided in this application embodiment;
[0020] Figure 3 A schematic diagram of an optional automatic zoom adjustment device provided in an embodiment of this application;
[0021] Figure 4 This is a schematic diagram of an optional electronic device provided in an embodiment of this application. Detailed Implementation
[0022] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention. Furthermore, the technical features involved in the various embodiments of this invention described below can be combined with each other as long as they do not conflict with each other.
[0023] The terms "first," "second," "third," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish different objects, not to describe a specific order. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or apparatuses.
[0024] According to one aspect of an embodiment of this application, an automatic zoom adjustment method is provided. The following is in conjunction with... Figure 1 This application describes an automatic zoom adjustment method provided in its embodiments.
[0025] Figure 1 This is a flowchart illustrating an optional automatic zoom adjustment method provided in an embodiment of this application, as shown below. Figure 1 As shown, the process of this method may include the following steps:
[0026] S102, Acquire a detection image of the object to be inspected, and determine the current magnification based on the detection image;
[0027] S104, Calculate the absolute value of the difference between the current magnification and the target magnification, and determine it as the absolute difference;
[0028] S106, if the absolute difference is greater than a preset difference, calculate the moving distance of the drive mechanism, wherein the drive mechanism includes a first drive shaft for driving the camera and lens to move as a whole, a second drive shaft for driving the camera to move, and a third drive shaft for driving the lens to rotate.
[0029] S108, the drive mechanism is automatically adjusted according to the moving distance until the target magnification is reached to complete the automatic magnification, wherein the moving distance includes the first moving distance of the first drive shaft, the second moving distance of the second drive shaft, and the third moving distance of the third drive shaft.
[0030] The automatic zoom adjustment method provided in this application embodiment is applicable to visual inspection in situations where the configuration of the inspection instrument needs to be adjusted when the object to be inspected (e.g., the product to be inspected) changes. The inspection instrument can be an automatic zoom device, and the automatic zoom device can involve front focal length, back focal length, working distance, and focus adjustment when adjusting the configuration.
[0031] Optionally, in this embodiment, to avoid the need to constantly change the configuration of the inspection instrument, the lens is generally designed with a compatible structure to ensure adjustment without disassembling the lens, thus adapting to different inspection environment requirements. During visual inspection, the target magnification can be achieved by automatically adjusting the drive mechanism through an automatic zoom device.
[0032] When adjusting the automatic zoom, the camera first acquires an image of the object to be inspected and determines the current magnification. Then, the absolute value of the difference between the current magnification and the target magnification is calculated and defined as the absolute difference. If the absolute difference is greater than a preset difference, the movement distance of the three drive mechanisms for automatic zoom adjustment is calculated. Specifically, the drive mechanisms include a first drive shaft for moving the camera and lens as a whole, a second drive shaft for moving the camera, and a third drive shaft for rotating the lens. Further, the movement distance includes a first movement distance of the first drive shaft, a second movement distance of the second drive shaft, and a third movement distance of the third drive shaft.
[0033] After determining the travel distance of each drive mechanism, the drive mechanism can be automatically adjusted according to the travel distance until the target magnification is reached to complete the automatic magnification (that is, the absolute value of the difference between the current magnification and the target magnification to be adjusted is not greater than the preset difference).
[0034] In one optional example, Figure 2 A flowchart illustrating another optional automatic zoom adjustment method provided in this application embodiment is shown below. Figure 2 As shown, after enabling automatic zoom adjustment, the object under inspection can be automatically exposed to improve detection brightness, and automatically focused to improve detection clarity. After the above preprocessing is completed, the detection image of the object under inspection can be acquired, and it can be determined whether the absolute value of the difference between the current magnification and the target magnification is greater than the preset error (or whether the absolute value of the difference between the current mapping and the target mapping is greater than the preset error). If it is less than the preset error, it means that the current magnification meets the visual inspection requirements, and automatic zoom can be ended and visual inspection can be started. If the absolute value of the difference between the current magnification and the target magnification is greater than the preset error (or the absolute value of the difference between the current mapping and the target mapping is greater than the preset error), the moving distance of the drive mechanism can be calculated. If one automatic zoom adjustment cannot meet the detection accuracy, the adjustment operation can be performed n times in a preset time until the target magnification is reached and automatic zoom is completed, that is, the absolute value of the difference between the current magnification and the target magnification to be adjusted is not greater than the preset difference.
[0035] Through steps S102 to S108, a detection image of the object to be inspected is acquired, and the current magnification is determined based on the detection image. The absolute value of the difference between the current magnification and the target magnification is calculated and determined as the absolute difference. If the absolute difference is greater than a preset difference, the moving distance of the drive mechanism is calculated. The drive mechanism includes a first drive shaft for moving the camera and lens as a whole, a second drive shaft for moving the camera, and a third drive shaft for rotating the lens. The drive mechanism is automatically adjusted according to the moving distance until the target magnification is reached to complete the automatic zoom. The moving distance includes the first moving distance of the first drive shaft, the second moving distance of the second drive shaft, and the third moving distance of the third drive shaft. By automatically adjusting the three drive mechanisms, the first drive mechanism is used to move the camera and lens as a whole to achieve working distance adjustment and focusing; the second drive mechanism is used to move the camera to achieve back focal length adjustment; and the third drive mechanism is used to rotate the lens to achieve front focal length adjustment. This achieves high-precision and rapid adjustment while ensuring consistency and repeatability across multiple workstations.
[0036] In one exemplary embodiment, the travel distance of the computational drive mechanism includes:
[0037] S11, obtain the fitting function between the magnification and the working distance;
[0038] S12, determine the first distance of the fitting function under the target magnification value, wherein the first distance is the working distance from the lens to the object under inspection when the magnification is the target magnification;
[0039] S13, determine the second distance of the fitting function at the current magnification value, wherein the second distance is the working distance from the lens to the object under inspection when the magnification is the current magnification;
[0040] S14, determine the third distance of the fitting function under the set multiplier value, wherein the set multiplier is obtained by removing the set error from the target multiplier;
[0041] S15, determine the first moving distance in the moving distance based on the first distance, the second distance and the third distance.
[0042] In this embodiment, when calculating the moving distance of the drive mechanism, the first moving distance of the first drive mechanism can be calculated first. The first drive mechanism drives the camera and lens to move as a whole, so as to realize the adjustment of the working distance and focusing.
[0043] For example, the first moving distance of the first drive mechanism is calculated as follows: a fitting function between the magnification and the working distance can be obtained, and a first distance of the fitting function at the target magnification value can be determined. Here, the first distance is the working distance from the lens to the object under inspection when the magnification is the target magnification. After determining the first distance, a second distance of the fitting function at the current magnification value can be determined, that is, the working distance from the lens to the object under inspection when the magnification is the current magnification. Finally, a third distance of the fitting function at the set magnification value is determined, that is, the magnification value obtained by removing the set error from the target magnification. The first moving distance is then determined based on the first distance, the second distance, and the third distance.
[0044] Specifically, the fitting function f(x) is derived from the relationship between the magnification and the working distance. This fitting function can be expressed as: f(x) = 130.3*x^-0.9249-0.3258*x^6+4*x^5-20.41*x^4+56.27*x^3-91.74*x^2+92.51*x
[0045] D=|f(x1)-f(x0)|-|f(x0)-f(x2)|-0.05;
[0046] Where x is the magnification; x0 is the target magnification; x1 is the current magnification; x2 is the target magnification minus the movement error (empirical value), i.e., the set magnification; and D is the first movement distance. f(x0) is the working distance from the lens to the object under inspection when the magnification is the target magnification, f(x1) is the working distance from the lens to the object under inspection when the magnification is the current magnification, and f(x2) is the working distance at the set magnification value.
[0047] In this embodiment, the first moving distance in the moving distance of the drive mechanism is calculated to achieve adjustment and focusing of the working distance, thereby improving the clarity and accuracy of visual inspection.
[0048] In one exemplary embodiment, the travel distance of the computational drive mechanism includes:
[0049] S21, determine the current position and direction of movement of the second drive shaft;
[0050] S22, based on the current magnification and the target magnification, and combined with the current position of the axis and the direction of movement, determine the second movement distance in the movement distance.
[0051] In this embodiment, when calculating the moving distance of the drive mechanism, the second moving distance of the second drive mechanism can be calculated. The second drive mechanism drives the camera to move in order to achieve the adjustment of the back focal length.
[0052] Optionally, the current position and direction of movement of the second drive shaft can be determined, and a second movement distance can be determined based on the current magnification and the target magnification, combined with the current position and direction of movement of the shaft. The second movement distance can be calculated by the following formula: D=p+x*((ab) / 0.01); where a is the target magnification; b is the current magnification; p is the current position of the shaft of the second drive mechanism; x is the direction of movement of the shaft of the second drive mechanism; and D is the third movement distance.
[0053] In this embodiment, the second moving distance in the moving distance of the drive mechanism is calculated to adjust the back intercept, thereby improving the accuracy of visual inspection.
[0054] In one embodiment, the travel distance of the computational drive mechanism includes:
[0055] S31, Obtain the absolute position of the first axis of the third drive axis when the lens magnification is the first magnification;
[0056] S32, Obtain the absolute position of the second axis of the third drive axis when the lens magnification is the second magnification;
[0057] S33, calculate the absolute position of the target magnification based on the target magnification, the absolute position of the first axis, and the absolute position of the second axis;
[0058] S34, the third moving distance in the moving distance is determined by the absolute position of the target magnification and the current position of the third drive shaft.
[0059] In this embodiment, when calculating the moving distance of the drive mechanism, the third moving distance of the third drive mechanism can be calculated. The third drive mechanism drives the lens to rotate in order to adjust the front focal length.
[0060] Optionally, the absolute position of the first axis of the third drive axis can be obtained when the lens magnification is at a first magnification, and the absolute position of the second axis of the third drive axis can be obtained when the lens magnification is at a second magnification. Then, the absolute position of the target magnification can be calculated based on the target magnification, the absolute position of the first axis, and the absolute position of the second axis, and the third moving distance in the moving distance can be determined by the absolute position of the target magnification and the current position of the axis of the third drive axis.
[0061] For example, the absolute position of the target magnification can be calculated using the following formula:
[0062] D = a * 0.5 * (p2 - p1) + 0.5 * (3 * p1 - p2); where a is the target magnification; p1 is the absolute position of the axis when the lens magnification is 1x (i.e., the absolute position of the first axis); p2 is the absolute position of the axis when the lens magnification is 3x (i.e., the absolute position of the second axis); and D is the absolute position of the target magnification.
[0063] Furthermore, the third travel distance can be determined by the difference between the absolute position of the target magnification and the current position of the third drive shaft.
[0064] In this embodiment, the third moving distance in the moving distance of the drive mechanism is calculated to adjust the front intercept, complete the automatic scaling, and thus ensure the consistency and repeatability of multiple stations.
[0065] In one embodiment, before acquiring a detection image of the object to be inspected and determining the current magnification based on the detection image, the method further includes:
[0066] S41, automatically expose the object to be inspected according to the target brightness;
[0067] S42, automatically focus on the object to be inspected after automatic exposure based on the target sharpness.
[0068] In this embodiment, before acquiring the inspection image of the object to be inspected, the object can be automatically exposed according to a set target brightness to increase its brightness. Furthermore, the automatically exposed object can be automatically focused according to a set target sharpness to improve the sharpness of the acquired image, facilitating subsequent automatic adjustments for visual inspection and thus enhancing the high precision of rapid adjustments.
[0069] In an exemplary embodiment, after acquiring a detection image of the object to be inspected and determining the current magnification based on the detection image, the method further includes:
[0070] S51, calculate the absolute value of the difference between the current mapping and the target mapping, and determine it as the absolute error;
[0071] S52, if the absolute error is greater than the preset error, calculate the moving distance of the drive mechanism;
[0072] S53, automatically adjust the drive mechanism according to the moving distance until the target mapping is reached and the automatic zoom is completed.
[0073] In one exemplary embodiment, the step of automatically adjusting the drive mechanism according to the travel distance until the target magnification is reached to complete the automatic magnification includes:
[0074] S61, control the first drive shaft to drive the camera and the lens to move the first moving distance as a whole;
[0075] S62, control the second drive shaft to drive the camera to move the second moving distance;
[0076] S63, control the third drive shaft to drive the lens to rotate and move by the third moving distance.
[0077] In this embodiment, the drive mechanism can be automatically adjusted according to the moving distance until the target magnification is reached and the automatic magnification is completed. This automatic adjustment can be performed multiple times until the difference between the current magnification and the target magnification meets the adjustment accuracy.
[0078] Specifically, when adjusting the drive mechanism, the three drive mechanisms can be adjusted separately according to the movement distance. For example, the first drive shaft can be controlled to move the camera and lens together to the target position of the first drive shaft according to the first movement distance, so as to adjust the working distance and complete the focusing; the second drive shaft can be controlled to move the camera to the target position of the second drive shaft according to the second movement distance, so as to adjust the back focal length; and the third drive shaft can be controlled to rotate to the target position of the third drive shaft according to the third movement distance, so as to adjust the front focal length.
[0079] In this embodiment, the front focal length, back focal length, working distance and focus are adjusted by using an automatic zoom adjustment device, thereby achieving the target magnification, so as to achieve high-precision and rapid adjustment and ensure consistency and repeatability across multiple stations.
[0080] According to another aspect of the embodiments of this application, an adjustment device for implementing the above-described automatic magnification adjustment method is also provided. Figure 3 This is a schematic diagram of an optional automatic zoom adjustment device according to an embodiment of this application, as shown below. Figure 3 As shown, the device may include:
[0081] Acquisition unit 302 is used to acquire detection images of the object to be inspected and determine the current magnification based on the detection images;
[0082] The determining unit 304 is used to calculate the absolute value of the difference between the current magnification and the target magnification, and determine it as the absolute difference.
[0083] The first calculation unit 306 is used to calculate the moving distance of the drive mechanism when the absolute difference is greater than a preset difference. The drive mechanism includes a first drive shaft for driving the camera and lens to move as a whole, a second drive shaft for driving the camera to move, and a third drive shaft for driving the lens to rotate.
[0084] The first adjustment unit 308 is used to automatically adjust the drive mechanism according to the moving distance until the target magnification is reached to complete the automatic magnification, wherein the moving distance includes the first moving distance of the first drive shaft, the second moving distance of the second drive shaft, and the third moving distance of the third drive shaft.
[0085] It should be noted that the acquisition unit 302 in this embodiment can be used to execute the above step S102, the determination unit 304 in this embodiment can be used to execute the above step S104, the first calculation unit 306 in this embodiment can be used to execute the above step S106, and the first adjustment unit 308 in this embodiment can be used to execute the above step S108.
[0086] The above modules acquire detection images of the object to be inspected and determine the current magnification based on the detection images. The absolute value of the difference between the current magnification and the target magnification is calculated and defined as the absolute difference. If the absolute difference is greater than a preset difference, the movement distance of the drive mechanism is calculated. The drive mechanism includes a first drive shaft for moving the camera and lens as a whole, a second drive shaft for moving the camera, and a third drive shaft for rotating the lens. The drive mechanism is automatically adjusted according to the movement distance until the target magnification is reached, completing the automatic zoom. The movement distance includes the first movement distance of the first drive shaft, the second movement distance of the second drive shaft, and the third movement distance of the third drive shaft. By automatically adjusting the three drive mechanisms, the first drive mechanism moves the camera and lens as a whole to achieve working distance adjustment and focusing; the second drive mechanism moves the camera to achieve back focal length adjustment; and the third drive mechanism rotates the lens to achieve front focal length adjustment. This achieves high-precision and rapid adjustment while ensuring consistency and repeatability across multiple workstations.
[0087] In one exemplary embodiment, the computing unit includes:
[0088] The acquisition module is used to obtain the fitting function between the magnification and the working distance;
[0089] The first determining module is used to determine the first distance of the fitting function at the target magnification value, wherein the first distance is the working distance from the lens to the object under inspection when the magnification is the target magnification;
[0090] The second determining module is used to determine the second distance of the fitting function at the current magnification value, wherein the second distance is the working distance from the lens to the object under inspection when the magnification is the current magnification;
[0091] The third determining module is used to determine the third distance of the fitting function at the set multiplier value, wherein the set multiplier is obtained by removing the set error from the target multiplier;
[0092] The fourth determining module is used to determine the first moving distance in the moving distance based on the first distance, the second distance and the third distance.
[0093] In one exemplary embodiment, the computing unit includes:
[0094] The fifth determining module is used to determine the current position and direction of movement of the second drive shaft;
[0095] The sixth determining module is used to determine the second moving distance in the moving distance based on the current magnification and the target magnification, combined with the current position of the axis and the moving direction.
[0096] In one exemplary embodiment, the computing unit includes:
[0097] The first acquisition module is used to acquire the absolute position of the first axis of the third drive axis when the lens magnification is the first magnification.
[0098] The second acquisition module is used to acquire the absolute position of the second axis of the third drive axis when the lens magnification is the second magnification.
[0099] The seventh determining module is used to calculate the absolute position of the target magnification based on the target magnification, the absolute position of the first axis, and the absolute position of the second axis;
[0100] The eighth determining module is used to determine the third moving distance in the moving distance by using the absolute position of the target magnification and the current position of the third drive shaft.
[0101] In one exemplary embodiment, the apparatus further includes:
[0102] An automatic exposure unit is used to automatically expose the object to be inspected based on the target brightness;
[0103] An autofocus unit is used to automatically focus on the object to be inspected after automatic exposure based on the target sharpness.
[0104] In one exemplary embodiment, the apparatus further includes:
[0105] The second calculation unit is used to calculate the absolute value of the difference between the current mapping and the target mapping, and determine it as the absolute error.
[0106] The third calculation unit is used to calculate the moving distance of the drive mechanism when the absolute error is greater than the preset error.
[0107] The second adjustment unit is used to automatically adjust the drive mechanism according to the moving distance until the target mapping is reached and the automatic scaling is completed.
[0108] In one exemplary embodiment, the first adjustment unit includes:
[0109] The first control module is used to control the first drive shaft to move the camera and the lens as a whole by the first moving distance;
[0110] The second control module is used to control the second drive shaft to drive the camera to move the second moving distance;
[0111] The third control module is used to control the third drive shaft to drive the lens to rotate and move by the third moving distance.
[0112] It should be noted that the examples and scenarios implemented by the above modules and corresponding steps are the same, but are not limited to the content disclosed in the above embodiments. It should be noted that the above modules, as part of the device, can run in a hardware environment, and can be implemented by software or hardware. The hardware environment includes a network environment.
[0113] According to another aspect of the embodiments of this application, a storage medium is also provided. Optionally, in this embodiment, the storage medium can be used to execute program code for any of the automatic zoom adjustment methods described above in the embodiments of this application.
[0114] Optionally, in this embodiment, the storage medium is configured to store program code for performing the following steps:
[0115] S1: Acquire the detection image of the object to be inspected, and determine the current magnification based on the detection image.
[0116] S2, calculate the absolute value of the difference between the current multiplier and the target multiplier, and determine it as the absolute difference.
[0117] S3. If the absolute difference is greater than the preset difference, calculate the moving distance of the drive mechanism. The drive mechanism includes a first drive shaft for driving the overall movement of the camera and lens, a second drive shaft for driving the movement of the camera, and a third drive shaft for driving the rotation of the lens.
[0118] S4, automatically adjust the drive mechanism according to the moving distance until the target magnification is reached to complete the automatic magnification, wherein the moving distance includes the first moving distance of the first drive shaft, the second moving distance of the second drive shaft, and the third moving distance of the third drive shaft.
[0119] Optionally, specific examples in this embodiment can refer to the examples described in the above embodiments, and will not be repeated in this embodiment.
[0120] The computer-readable storage medium may include, but is not limited to, any type of disk, including floppy disks, optical disks, DVDs, CD-ROMs, microdrives, as well as magneto-optical disks, ROMs, RAMs, EPROMs, EEPROMs, DRAMs, VRAMs, flash memory devices, magnetic cards or optical cards, nanosystems (including molecular memory ICs), or any type of medium or device suitable for storing instructions and / or data.
[0121] According to another aspect of the embodiments of this application, an electronic device for implementing the above-described automatic zoom adjustment method is also provided. The electronic device may be a server, a terminal, or a combination thereof.
[0122] Figure 4 This is a schematic diagram of the structure of an optional electronic device according to an embodiment of this application, such as... Figure 4 As shown, it includes a processor 402, a communication interface 404, a memory 406, and a communication bus 408. The processor 402, communication interface 404, and memory 406 communicate with each other via the communication bus 408.
[0123] Memory 406 is used to store computer programs;
[0124] When processor 402 executes a computer program stored in memory 406, it performs the following steps:
[0125] S1: Acquire the detection image of the object to be inspected, and determine the current magnification based on the detection image.
[0126] S2, calculate the absolute value of the difference between the current multiplier and the target multiplier, and determine it as the absolute difference.
[0127] S3. If the absolute difference is greater than the preset difference, calculate the moving distance of the drive mechanism. The drive mechanism includes a first drive shaft for driving the overall movement of the camera and lens, a second drive shaft for driving the movement of the camera, and a third drive shaft for driving the rotation of the lens.
[0128] S4, automatically adjust the drive mechanism according to the moving distance until the target magnification is reached to complete the automatic magnification, wherein the moving distance includes the first moving distance of the first drive shaft, the second moving distance of the second drive shaft, and the third moving distance of the third drive shaft.
[0129] Optionally, the communication bus can be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 4 The symbol is represented by a single thick line, but this does not indicate that there is only one bus or one type of bus. The communication interface is used for communication between the aforementioned electronic device and other devices.
[0130] The memory may include RAM, or nonvolatile memory, such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.
[0131] As an example, the memory 406 described above may include, but is not limited to, the acquisition unit 302, the determination unit 304, the first calculation unit 306, and the first adjustment unit 308 from the automatic zoom adjustment device described above. Furthermore, it may include, but is not limited to, other module units from the automatic zoom adjustment device described above, which will not be elaborated upon in this example.
[0132] The processors mentioned above can be general-purpose processors, including but not limited to: CPU (Central Processing Unit), NP (Network Processor), etc.; they can also be DSP (Digital Signal Processor), ASIC (Application Specific Integrated Circuit), FPGA (Field-Programmable Gate Array), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0133] Optionally, specific examples in this embodiment can refer to the examples described in the above embodiments, and will not be repeated here.
[0134] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.
[0135] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.
[0136] In the several embodiments provided in this application, it should be understood that the disclosed apparatus can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some service interface; the indirect coupling or communication connection between devices or units may be electrical or other forms.
[0137] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0138] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0139] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage device (CMD). Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a memory and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned memory includes various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.
[0140] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, which may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, etc.
[0141] The foregoing description is merely an exemplary embodiment of this disclosure and should not be construed as limiting the scope of this disclosure. Any equivalent changes and modifications made in accordance with the teachings of this disclosure shall still fall within the scope of this disclosure. Those skilled in the art will readily conceive of embodiments of this disclosure upon considering the specification and practicing the disclosure herein. This application is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not described herein. The specification and embodiments are to be considered exemplary only, and the scope and spirit of this disclosure are defined by the claims.
[0142] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0143] Those skilled in the art will readily understand that the above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for automatically adjusting magnification, characterized in that, include: Acquire a detection image of the object to be inspected, and determine the current magnification based on the detection image; Calculate the absolute value of the difference between the current magnification and the target magnification, and determine it as the absolute difference; If the absolute difference is greater than a preset difference, the moving distance of the drive mechanism is calculated. The drive mechanism includes a first drive shaft for moving the camera and lens as a whole, a second drive shaft for moving the camera, and a third drive shaft for rotating the lens. The drive mechanism is automatically adjusted according to the moving distance until the target magnification is reached to complete the automatic magnification. The moving distance includes the first moving distance of the first drive shaft, the second moving distance of the second drive shaft, and the third moving distance of the third drive shaft. The first moving distance is calculated based on a fitting function between the magnification and the working distance; Determine the current position and direction of movement of the second drive shaft; Based on the current magnification and the target magnification, and in combination with the current position of the axis and the direction of movement, a second movement distance is determined from the movement distance; The third moving distance is determined based on the target magnification, the absolute position of the target magnification, and the current position of the third drive shaft. The moving distance of the computational drive mechanism includes: Obtain the absolute position of the first axis of the third drive axis when the lens magnification is the first magnification; Obtain the absolute position of the second axis of the third drive axis when the lens magnification is the second magnification; The absolute position of the target magnification is calculated based on the target magnification, the absolute position of the first axis, and the absolute position of the second axis. The third travel distance is determined by comparing the absolute position of the target magnification with the current position of the third drive shaft.
2. The automatic zoom adjustment method as described in claim 1, characterized in that, The moving distance of the computational drive mechanism includes: Obtain the fitting function between the magnification and the working distance; Determine a first distance of the fitting function at the target magnification value, wherein the first distance is the working distance from the lens to the object under inspection when the magnification is the target magnification; Determine a second distance of the fitting function at the current magnification value, wherein the second distance is the working distance from the lens to the object under inspection when the magnification is the current magnification; Determine the third distance of the fitted function at a set multiplier value, wherein the set multiplier is obtained by removing a set error from the target multiplier; The first moving distance is determined based on the first distance, the second distance, and the third distance.
3. The automatic zoom adjustment method as described in claim 1, characterized in that, Before acquiring a detection image of the object to be inspected and determining the current magnification based on the detection image, the method further includes: The object to be inspected is automatically exposed based on the target brightness; The object to be inspected is automatically focused based on the target sharpness after automatic exposure.
4. The automatic zoom adjustment method as described in claim 1, characterized in that, After acquiring a detection image of the object to be inspected and determining the current magnification based on the detection image, the method further includes: Calculate the absolute value of the difference between the current mapping and the target mapping, and determine it as the absolute error; If the absolute error is greater than a preset error, the moving distance of the drive mechanism is calculated; The drive mechanism is automatically adjusted according to the moving distance until the target mapping is reached, thus completing the automatic zoom.
5. The automatic zoom adjustment method according to any one of claims 1-4, characterized in that, The step of automatically adjusting the drive mechanism according to the moving distance until the target magnification is reached to complete the automatic magnification includes: Control the first drive shaft to move the camera and lens together by the first moving distance; Control the second drive shaft to move the camera by the second moving distance; The third drive shaft is controlled to rotate and move the lens by the third moving distance.
6. An automatic zoom adjustment device, performing the automatic zoom adjustment method as described in claim 1, characterized in that, include: The acquisition unit is used to acquire a detection image of the object to be inspected and to determine the current magnification based on the detection image. A determining unit is used to calculate the absolute value of the difference between the current magnification and the target magnification, and determine it as the absolute difference. The first calculation unit is used to calculate the moving distance of the drive mechanism when the absolute difference is greater than a preset difference. The drive mechanism includes a first drive shaft for driving the camera and lens to move as a whole, a second drive shaft for driving the camera to move, and a third drive shaft for driving the lens to rotate. The first adjustment unit is used to automatically adjust the drive mechanism according to the moving distance until the target magnification is reached and the automatic magnification is completed. The moving distance includes the first moving distance of the first drive shaft, the second moving distance of the second drive shaft, and the third moving distance of the third drive shaft.
7. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored program, wherein the program, when executed, performs the method of any one of claims 1 to 5.
8. An electronic device comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor is configured to execute the method of any one of claims 1 to 5 through the computer program.
Citation Information
Patent Citations
High-resolution microscopic visual imaging device and control method
CN104410775A
Confocal-based rapid and accurate automatic focusing chip appearance detection device and method
CN118464799A
Automatic zoom ray machine device
CN217213409U
KR1018180610000B1