A visual inspection system and adaptive focusing method and apparatus therefor

By using an adaptive focusing method, the area of ​​interest is determined and the photosensitive area of ​​the imaging device is adjusted, thus solving the focusing accuracy and efficiency problems of end mills. This achieves fast and accurate adaptive focusing, meeting the cycle time requirements of online inspection.

CN121509813BActive Publication Date: 2026-07-07XIAMEN TUNGSTEN CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
XIAMEN TUNGSTEN CO LTD
Filing Date
2025-11-13
Publication Date
2026-07-07

AI Technical Summary

Technical Problem

Existing technologies cannot effectively solve the focusing problem of end mills in the visual inspection of micro-sized and complex three-dimensional structures, especially the focusing accuracy and efficiency of end mills. Traditional methods are difficult to achieve fast, accurate and robust adaptive focusing.

Method used

By using an adaptive focusing method, the area of ​​interest is determined and the photosensitive area of ​​the imaging device is adjusted. Multiple focusing evaluation algorithms are used to calculate the optimal focusing position, shorten focusing time, and ensure clear imaging of key parts.

Benefits of technology

It achieves fast, accurate, and robust adaptive focusing for end mills, meeting the cycle time requirements of online inspection and improving inspection efficiency and accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121509813B_ABST
    Figure CN121509813B_ABST
Patent Text Reader

Abstract

The application discloses a visual detection system and an adaptive focusing method and device thereof. The adaptive focusing method comprises the following steps: controlling an imaging device to collect an initial image of a tool located at a pre-focusing position; preprocessing the initial image to obtain a preprocessed image and extracting a tool parameter; determining a region of interest according to the tool parameter; determining a light-sensing region of a light-sensing chip of the imaging device according to the coordinates and size of the region of interest; adjusting the position relationship between the tool and the imaging device according to a preset focusing search strategy, and controlling the imaging device to collect an image of the region of interest according to the light-sensing region; calculating a focusing evaluation value of the image of the region of interest, and determining the position relationship when the focusing evaluation value is the largest as an optimal focusing position relationship; and controlling the imaging device to collect a global image of the tool located at the optimal focusing position. By using the above technical scheme, the performance and applicability of the visual detection equipment can be improved, and adaptive focusing can be quickly, accurately and robustly completed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of visual inspection adaptive focusing technology, and in particular to a visual inspection system and its adaptive focusing method and apparatus. Background Technology

[0002] With the continuous improvement of industrial automation, machine vision-based automatic inspection systems are gradually replacing traditional manual microscope inspection and becoming the mainstream technology solution in this field. However, achieving fully automated and highly reliable visual inspection still faces a series of severe technical challenges. One of the core difficulties lies in how to achieve fast, accurate, and stable focusing of the inspection image, especially for precision tools with micro-sized and complex three-dimensional structures such as end mills. End mills are characterized by small cutting diameters (commonly ranging from 0.1 mm to tens of millimeters), complex helical flute structures, and free-form surfaces on the rake and flank faces. This makes the surface of the end mill not a flat imaging plane, but a complex three-dimensional structure with height differences.

[0003] Traditional global single-focusing methods cannot meet the requirement of simultaneous clear imaging of the entire cutting edge area. Conventional passive focusing functions based on contrast and gradient (such as the Tenengrad function, Brenner function, variance function, etc.) often exhibit flat evaluation curves, indistinct peaks, and even local extrema when dealing with the low-texture, highly reflective metal surfaces of end mills, leading to decreased focusing accuracy or search failure. To find the precise focus, a global search strategy (such as hill-climbing algorithm) is often required, which involves numerous motor steps and long processing times, making it difficult to meet the cycle time requirements of online inspection. Setting the search step size too large can easily miss the true focus, while setting it too small will prolong the focusing time. Most existing focusing algorithms are designed for macroscopic, textured workpieces or rely on expensive high-depth-of-field optical systems. For precision tools such as end mills with micro-sized, complex three-dimensional structures, there is still a lack of a dedicated method that can quickly, accurately, and robustly achieve adaptive focusing.

[0004] Therefore, for precision cutting tools such as end mills with micro-sized and complex three-dimensional structures, how to quickly, accurately, and robustly complete adaptive focusing and improve the performance and applicability of vision inspection equipment has become an urgent technical problem to be solved. Summary of the Invention

[0005] This invention provides a visual inspection system and its adaptive focusing method and apparatus to improve the performance and applicability of visual inspection equipment, and to complete adaptive focusing quickly, accurately and robustly.

[0006] According to one aspect of the present invention, an adaptive focusing method for a visual inspection system is provided, comprising:

[0007] Move the cutting tool to the pre-focus position of the imaging device and control the imaging device to acquire the initial image of the cutting tool;

[0008] The initial image is preprocessed to obtain a preprocessed image, and the parameters of the cutting tool are extracted from the preprocessed image;

[0009] Based on the parameters of the cutting tool, a portion of the preprocessed image is determined as the region of interest;

[0010] The photosensitive area of ​​the photosensitive chip of the imaging device is determined based on the coordinates and size of the region of interest.

[0011] According to a preset focus search strategy, the positional relationship between the cutting tool and the imaging device is adjusted, and under each positional relationship, the imaging device is controlled to acquire an image of the region of interest based on the photosensitive area;

[0012] Calculate the focus evaluation value of the image of the region of interest under each of the aforementioned positional relationships, and determine the positional relationship with the maximum focus evaluation value as the optimal focus positional relationship;

[0013] Under the optimal focusing position relationship, the imaging device is controlled to acquire a global image of the cutting tool; wherein, the global image is used for defect detection and analysis of the cutting tool.

[0014] Optionally, the initial image is preprocessed to obtain a preprocessed image, and the parameters of the cutting tool in the preprocessed image are extracted, including:

[0015] The initial image is subjected to grayscale thresholding and image morphology processing to obtain a preprocessed image;

[0016] Identify the cutting edge region of the tool in the preprocessed image;

[0017] The parameters of the cutting tool are extracted based on the cutting edge region of the cutting tool in the preprocessed image.

[0018] Optionally, the imaging device includes a first imaging device; wherein the first imaging device is used to capture an image of the end face of the cutting tool;

[0019] The adaptive focusing method includes:

[0020] Move the cutting tool to the first pre-focus position of the first imaging device, and control the first imaging device to acquire an initial image of the end face of the cutting tool;

[0021] The initial end face image is preprocessed to obtain a preprocessed end face image, and the end face parameters of the tool are extracted from the preprocessed end face image.

[0022] Based on the end face parameters of the cutting tool, a portion of the preprocessed end face image is determined as the first region of interest;

[0023] Based on the coordinates and size of the first region of interest, the first photosensitive area of ​​the photosensitive chip of the first imaging device is determined;

[0024] According to the first preset focus search strategy, the positional relationship between the cutting tool and the end face of the first imaging device is adjusted, and under each end face positional relationship, the first imaging device is controlled to acquire an image of the first region of interest based on the first photosensitive area;

[0025] Calculate the end-face focus evaluation value of the image of the first region of interest under each end-face position relationship, and determine the end-face position relationship when the end-face focus evaluation value is the maximum as the optimal end-face focus position relationship.

[0026] Under the optimal focusing position relationship of the end face, the first imaging device is controlled to acquire a global image of the end face of the tool; wherein, the global image of the end face is used to perform defect detection and analysis on the end face of the tool.

[0027] Optionally, the end face parameters of the tool include the angular position of the cutting edge;

[0028] Before determining a portion of the preprocessed end-face image as the first region of interest, the method further includes:

[0029] Determine the tool end face template based on the end face parameters of the tool;

[0030] According to a preset image processing strategy, the angular position relationship between the pre-processed end face image and the tool end face template is adjusted, and under each angular position relationship, the angle matching value between the pre-processed end face image and the tool end face template is calculated.

[0031] Based on the angular position relationship when the angular matching value is at its maximum, determine the deviation angle between the angular position of the cutting edge of the tool and the reference axis direction of the image coordinate system.

[0032] The cutting tool is rotated according to the deviation angle so that at least a portion of the cutting edge is parallel to the reference axis direction of the image coordinate system.

[0033] Optionally, the imaging device includes a second imaging device; wherein the second imaging device is used to capture images of the circumferential surface of the cutting tool;

[0034] The adaptive focusing method further includes:

[0035] The tool is controlled to rotate according to a preset tool rotation strategy, and after each tool rotation, the second imaging device is controlled to acquire a global image of the tool's circumferential surface; wherein each global image of the circumferential surface is used to detect and analyze defects on the circumferential surface of the tool.

[0036] Optionally, the imaging device includes a second imaging device; wherein the second imaging device is used to capture images of the circumferential surface of the cutting tool;

[0037] The adaptive focusing method includes:

[0038] Move the cutting tool to the second pre-focus position of the second imaging device, and control the second imaging device to acquire an initial image of the circumferential surface of the cutting tool;

[0039] The initial image of the circumferential surface is preprocessed to obtain a preprocessed image of the circumferential surface, and the circumferential surface parameters of the tool are extracted from the preprocessed image of the circumferential surface.

[0040] Based on the circumferential parameters of the cutting tool, a portion of the preprocessed circumferential image is determined as the second region of interest.

[0041] The second photosensitive area of ​​the photosensitive chip of the second imaging device is determined based on the coordinates and size of the second area of ​​interest.

[0042] According to the second preset focus search strategy, the positional relationship between the cutting tool and the peripheral surface of the second imaging device is adjusted, and under each peripheral surface positional relationship, the second imaging device is controlled to acquire an image of the second region of interest based on the second photosensitive area;

[0043] Calculate the circumferential focus evaluation value of the image of the second region of interest under each of the circumferential positional relationships, and determine the circumferential positional relationship when the circumferential focus evaluation value is the maximum as the optimal circumferential focus positional relationship.

[0044] Under the optimal focusing position relationship of the circumferential surface, the tool is controlled to rotate according to a preset tool rotation strategy, and after each tool rotation, the second imaging device is controlled to acquire a global image of the circumferential surface of the tool; wherein, each global image of the circumferential surface is used to perform defect detection and analysis on the circumferential surface of the tool.

[0045] Optionally, the imaging device includes a second imaging device; wherein the second imaging device is used to capture images of the circumferential surface of the cutting tool;

[0046] The adaptive focusing method further includes:

[0047] Based on the end face parameters of the tool, determine the tool circumferential template;

[0048] Based on the tool peripheral surface template, a portion of the tool peripheral surface template is determined as the second region of interest;

[0049] The second photosensitive area of ​​the photosensitive chip of the second imaging device is determined based on the coordinates and size of the second area of ​​interest.

[0050] According to the second preset focus search strategy, the positional relationship between the cutting tool and the peripheral surface of the second imaging device is adjusted, and under each peripheral surface positional relationship, the second imaging device is controlled to acquire an image of the second region of interest based on the second photosensitive area;

[0051] Calculate the circumferential focus evaluation value of the image of the second region of interest under each of the circumferential positional relationships, and determine the circumferential positional relationship when the circumferential focus evaluation value is the maximum as the optimal circumferential focus positional relationship.

[0052] Under the optimal focusing position relationship of the circumferential surface, the tool is controlled to rotate according to a preset tool rotation strategy, and after each tool rotation, the second imaging device is controlled to acquire a global image of the circumferential surface of the tool; wherein, each global image of the circumferential surface is used to perform defect detection and analysis on the circumferential surface of the tool.

[0053] Optionally, according to a preset focus search strategy, the positional relationship between the cutting tool and the imaging device is adjusted, and under each positional relationship, the imaging device is controlled to acquire an image of the region of interest based on the photosensitive area, including:

[0054] Within the first focusing stroke, the positional relationship between the cutting tool and the imaging device is adjusted by the first step length as the first positional relationship, so that the first positional relationship traverses the entire first focusing stroke, and under each first positional relationship, the imaging device is controlled to acquire an image of the region of interest according to the photosensitive area;

[0055] Calculate the focus evaluation value of the image of the region of interest under each of the first positional relationships, and determine the second focus travel corresponding to the peak value of the focus evaluation value; wherein the second focus travel is less than the first focus travel.

[0056] Within the second focusing stroke, the positional relationship between the tool and the imaging device is adjusted by a second step length to form a second positional relationship, which traverses the entire second focusing stroke. Under each second positional relationship, the imaging device is controlled to acquire an image of the region of interest based on the photosensitive area; wherein, the second step length is smaller than the first step length.

[0057] Calculate the focus evaluation value of the image of the region of interest under each of the aforementioned positional relationships, and determine the positional relationship with the maximum focus evaluation value as the optimal focus positional relationship, including:

[0058] Calculate the focus evaluation value of the image of the region of interest under each of the second positional relationships, and determine the positional relationship in which the focus evaluation value is maximized within the second focus travel as the optimal focus positional relationship.

[0059] Optionally, calculating the focus evaluation value of the image of the region of interest includes:

[0060] Based on various focus evaluation algorithms, the focus evaluation value of the image of the region of interest is calculated respectively;

[0061] The focus evaluation values ​​obtained under each of the focus evaluation algorithms are weighted and fused to obtain a comprehensive focus evaluation value.

[0062] Optionally, the focus evaluation algorithm includes a gradient focus evaluation algorithm and a variance focus evaluation algorithm.

[0063] According to another aspect of the present invention, an adaptive focusing device for a visual inspection system is provided for performing the adaptive focusing method of the visual inspection system described in any embodiment of the present invention;

[0064] The adaptive focusing device includes:

[0065] The pre-focusing module is used to move the cutting tool to the pre-focusing position of the imaging device and control the imaging device to acquire the initial image of the cutting tool.

[0066] A preprocessing module is used to preprocess the initial image to obtain a preprocessed image and extract the parameters of the cutting tool from the preprocessed image;

[0067] The focus determination module is used to determine a portion of the preprocessed image as the region of interest based on the parameters of the cutting tool.

[0068] A photosensitive determination module is used to determine the photosensitive area of ​​the photosensitive chip of the imaging device based on the coordinates and size of the area of ​​interest.

[0069] The focus search module is used to adjust the positional relationship between the cutting tool and the imaging device according to a preset focus search strategy, and under each positional relationship, control the imaging device to acquire an image of the region of interest according to the photosensitive area;

[0070] An adaptive module is used to calculate the focus evaluation value of the image of the region of interest under each of the aforementioned positional relationships, and to determine the positional relationship when the focus evaluation value is maximized as the optimal focus positional relationship.

[0071] A global acquisition module is used to control the imaging device to acquire a global image of the cutting tool under the optimal focusing position relationship; wherein the global image is used for defect detection and analysis of the cutting tool.

[0072] According to another aspect of the present invention, a visual inspection system is provided, comprising: an imaging device, a motion device, and a controller;

[0073] The imaging device is used to acquire images of the tool to be focused;

[0074] The motion device is used to drive the cutting tool and / or the imaging device to move;

[0075] The controller is electrically connected to the imaging device and the motion device respectively, and the controller is used to execute the adaptive focusing method of the visual detection system according to any embodiment of the present invention.

[0076] The technical solution of this invention, by adaptively determining the region of interest and then determining the photosensitive area of ​​the photosensitive chip based on the region of interest, enables the imaging device to read and transmit only pixel data within the region of interest. This significantly reduces the data volume of a single frame image, improves image acquisition and processing speed, and allows the imaging device to acquire images at a higher frame rate. This greatly shortens the focusing time, which is beneficial for meeting the cycle time requirements of online automatic defect detection. Thus, focusing search can be performed with a smaller step size without affecting the cycle time requirements of online automatic defect detection, facilitating fast, accurate, and robust adaptive focusing. The adaptive focusing method of the vision inspection system provided by this invention can solve the accuracy and efficiency problems of focusing on precision tools with micro-sized, complex three-dimensional structures, such as end mills. It can also achieve precise focusing on specific areas, ensuring clear imaging of critical parts.

[0077] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description

[0078] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0079] Figure 1 This is a schematic diagram of the structure of a visual inspection system provided in Embodiment 1 of the present invention;

[0080] Figure 2 This is a flowchart of an adaptive focusing method for a visual inspection system provided in Embodiment 2 of the present invention;

[0081] Figure 3 This is a flowchart of an adaptive focusing method for a visual inspection system provided in Embodiment 3 of the present invention;

[0082] Figure 4 This is a flowchart of an adaptive focusing method for a visual inspection system provided in Embodiment 4 of the present invention;

[0083] Figure 5 This is a schematic diagram of the structure of an adaptive focusing device for a visual inspection system provided in Embodiment 5 of the present invention. Detailed Implementation

[0084] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.

[0085] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0086] It should also be noted that the implementation methods provided in the embodiments of the present invention can be combined with each other without contradiction.

[0087] Example 1

[0088] Figure 1 This is a schematic diagram of the structure of a visual inspection system provided in Embodiment 1 of the present invention, with reference to... Figure 1 The visual inspection system includes an imaging device 20, a motion device 30, and a controller. Figure 1(Not shown in the image). Imaging device 20 is used to acquire an image of the tool 10 to be focused; motion device 30 is used to drive the tool 10 and / or imaging device 20 to move; controller is electrically connected to imaging device 20 and motion device 30 respectively. Figure 1 (Not shown in the diagram), the controller is used to execute the adaptive focusing method of the visual inspection system provided in any embodiment of the present invention.

[0089] For example, the imaging device 20 includes a high-resolution industrial camera, a telecentric lens, and a matching ring light source or coaxial light source, which can be used to acquire high-definition images of the tool 10 to be focused. The imaging device 20 can be driven by a controller, under the control of the controller, the imaging device 20 can acquire images of the tool 10.

[0090] In an optional embodiment, the imaging device 20 includes a first imaging device 21 and a second imaging device 22. The first imaging device 21 can be disposed on the end face side of the tool 10 and can be used to capture the end face of the tool 10 and acquire an image of the end face of the tool 10. The second imaging device 22 can be disposed on the peripheral side of the tool 10 and can be used to capture the peripheral surface of the tool 10 and acquire an image of the peripheral surface of the tool 10.

[0091] For example, the motion device 30 may include a first motor 31 for driving the tool 10 to perform axial focusing motion along the X-axis, a second motor 32 for driving the tool 10 to perform vertical focusing motion along the Z-axis, and an electrically controlled rotary table 33 for clamping the tool 10 and controlling the rotation angle of the tool 10. The electrically controlled rotary table 33 includes grippers 34 for fixing the tool 10. The first motor 31, the second motor 32, and the electrically controlled rotary table 33 may be driven by a controller. Under the control of the controller, the first motor 31, the second motor 32, and the electrically controlled rotary table 32 may drive the tool 10 to move.

[0092] The controller may include, but is not limited to, an industrial computer, and may have a built-in image acquisition card. The controller is capable of running specialized image processing algorithms and focus control logic, is responsible for processing the image data acquired by the imaging device 20, and sends control commands to the motion device 30 based on the processing results.

[0093] The visual inspection system may also include a bracket 40 for fixing the imaging device 20. When the imaging device 20 includes a first imaging device 21 and a second imaging device 22, the bracket 40 may include a first bracket 41 for fixing the first imaging device 21 and a second bracket 42 for fixing the second imaging device 22. In addition, the visual inspection system may also include a base 50 for supporting the imaging device 20, the motion device 30, and the bracket 40.

[0094] The visual inspection system provided in Embodiment 1 of the present invention can be used to execute the adaptive focusing method of the visual inspection system provided in any embodiment of the present invention. It has the functional modules and beneficial effects of executing the adaptive focusing method of the visual inspection system provided in the embodiments of the present invention. For the contents not described in detail in the embodiments of the visual inspection system, please refer to the following description of the adaptive focusing method of the visual inspection system, which will not be repeated here.

[0095] Example 2

[0096] Figure 2 This is a flowchart of an adaptive focusing method for a vision inspection system provided in Embodiment 2 of the present invention. This embodiment is applicable to machine vision defect detection of precision cutting tools with micro-sized, complex three-dimensional structures, such as end mills. The method can be executed by an adaptive focusing device of the vision inspection system, which can be implemented in hardware and / or software and can be configured in the controller of the vision inspection system. Figure 2 As shown, the adaptive focusing method includes:

[0097] S1001. Move the cutting tool to the pre-focus position of the imaging device and control the imaging device to acquire the initial image of the cutting tool.

[0098] The pre-focusing position is a fixed focusing distance pre-set by the imaging device. For example, when the imaging device includes a fixed-focus lens, the pre-focusing position can be the fixed focal length position of the fixed-focus lens, but it is not limited to this. When the imaging device includes a first imaging device and a second imaging device that capture images of the knife from different angles, the pre-focusing position includes a first pre-focusing position applicable to the first imaging device and a second pre-focusing position applicable to the second imaging device. In one embodiment, when moving the knife to the pre-focusing position of the imaging device, it is sufficient to move the knife to either the first pre-focusing position applicable to the first imaging device or the second pre-focusing position applicable to the second imaging device.

[0099] For example, refer to Figure 1 First, the tool 10 to be focused can be fixed on the motion device 30 and clamped by the gripper 34. Then, the motion device 30 is controlled to move the tool 10 to the pre-focus position within the field of view of the imaging device 20. After the tool 10 is moved to the pre-focus position, the imaging device 20 is controlled to acquire the initial image of the tool 10. Due to the depth of field limitation of the imaging device 20 and the initial position deviation, the initial image is usually in a defocused and blurred state.

[0100] In other alternative implementations, the imaging device can be moved by a motion device so that the blade is positioned in the pre-focus position of the imaging device.

[0101] S1002. Preprocess the initial image to obtain a preprocessed image, and extract the tool parameters from the preprocessed image.

[0102] Preprocessing refers to image operations and transformations performed on the initial image. For example, preprocessing may include image optimization to improve image quality for subsequent analysis and application; preprocessing may also include image analysis to extract useful information from the image. Tool parameters include, but are not limited to, the tool's cutting diameter, number of cutting edges, and helix angle.

[0103] In one optional embodiment, the initial image is preprocessed, including normalization, to eliminate the effects of uneven illumination. In another optional embodiment, the preprocessing of the initial image may further include grayscale thresholding and image morphology processing.

[0104] For example, after preprocessing the initial image, a preprocessed image can be obtained. Then, the cutting edge region of the tool in the preprocessed image can be identified, and the tool parameters can be extracted based on the cutting edge region of the tool in the preprocessed image. In one embodiment, the highly reflective area in the preprocessed image can be extracted as the cutting edge region, and the contrast between the cutting edge and other areas can be enhanced. This facilitates the identification of the cutting edge region and the extraction of tool parameters.

[0105] S1003. Based on the tool parameters, determine a portion of the preprocessed image as the region of interest.

[0106] The area of ​​interest refers to the area that needs to be identified, analyzed and evaluated in real time during the adaptive focusing process. Areas other than the area of ​​interest can be ignored during the adaptive focusing process. In an optional implementation, the area of ​​interest includes key parts that need to be inspected for defects, such as the rake face, flank face or specific cutting edge area.

[0107] For example, based on the parameters of the cutting tool, the positional information such as the location of the cutting edge area in the preprocessed image can be determined, thereby identifying one or more key areas that need to be inspected for defects, which are the areas of interest.

[0108] S1004. Determine the photosensitive area of ​​the image sensor chip of the imaging device based on the coordinates and size of the area of ​​interest.

[0109] The photosensitive area refers to the region within the image sensor chip of an imaging device used for sensing light and reading data. The imaging device only collects and transmits pixel data from the photosensitive area, and does not collect or transmit pixel data outside the photosensitive area. The photosensitive area is equivalent to the viewfinder of the imaging device; the imaging device only captures the content within the viewfinder.

[0110] For example, the coordinate range of the region of interest in the image coordinate system can be determined based on its coordinates and size. Then, according to the proportional relationship between the image coordinate system and the photosensitive chip coordinate system, the coordinate range of the region of interest in the image coordinate system can be converted to the coordinate range of the photosensitive chip coordinate system. The area containing the converted coordinate range is the photosensitive area. For instance, the coordinates of a certain position of the region of interest can be determined in the preprocessed image, and then the coordinate range of the region of interest in the image coordinate system can be determined based on its size. Through the imaging protocol inside the imaging device, the coordinate range of the region of interest in the image coordinate system can be converted to the coordinate range of the photosensitive chip coordinate system to determine the photosensitive area.

[0111] For example, when the preprocessed image includes a region of interest, the photosensitive chip of the imaging device may include a photosensitive region; when the preprocessed image includes multiple regions of interest, the photosensitive chip of the imaging device may include multiple photosensitive regions, that is, the photosensitive chip may include one or more photosensitive regions.

[0112] S1005. According to the preset focus search strategy, adjust the positional relationship between the tool and the imaging device, and under each positional relationship, control the imaging device to acquire the image of the area of ​​interest according to the photosensitive area.

[0113] Among them, the preset focus search strategy refers to the strategy of pre-setting the focus travel according to the imaging device, and then sequentially acquiring images of different focus positions within the focus travel at a specific step size to find the best focus position.

[0114] For example, by controlling a motion device, the cutting tool or imaging device can be moved according to a preset focus search strategy. At each position (i.e., each step position), the imaging device is controlled to only sense and read data from the sensed area, and transmit the data within that area, without reading or transmitting data outside the sensed area. This allows the imaging device to acquire only pixel data within the area of ​​interest. This reduces the amount of image data acquired at each step position, enabling the imaging device to acquire images at a higher frame rate, thus improving focusing speed, accuracy, and reliability.

[0115] In one embodiment, when the focus position changes, the distance between the tool and the imaging device changes, and the photosensitive area of ​​the photosensitive chip can be adaptively adjusted according to the distance change, so that the imaging device can acquire only pixel data within the area of ​​interest at different step positions.

[0116] S1006. Calculate the focus evaluation value of the image of the region of interest under each positional relationship, and determine the positional relationship with the maximum focus evaluation value as the optimal focus positional relationship.

[0117] The focus rating, also known as the sharpness rating, quantifies the sharpness of an image. The focus rating is positively correlated with image sharpness; a higher focus rating indicates a sharper image, resulting in sharper edges, richer details, and higher contrast.

[0118] For example, pixel data of the region of interest image under each positional relationship can be acquired, and one or more evaluation methods such as gradient function, statistical function, and frequency domain function can be used to evaluate the image sharpness of the region of interest. When the focus evaluation value is the highest, the image sharpness of the region of interest is the highest. At this time, the positional relationship between the tool and the imaging device can be the optimal focus positional relationship, that is, at the optimal focus positional relationship, the imaging device can acquire a clear image of the tool.

[0119] In an optional embodiment, calculating the focus evaluation value of the image of the region of interest includes: calculating the focus evaluation value of the image of the region of interest separately according to multiple focus evaluation algorithms; and weighting and fusing the focus evaluation values ​​obtained from each focus evaluation algorithm to obtain a comprehensive focus evaluation value. The focus evaluation algorithms are used to quantify the sharpness of the image, including but not limited to evaluation methods such as gradient functions, statistical functions, and frequency domain functions. The focus evaluation value can be calculated using these algorithms.

[0120] For example, based on images of the region of interest acquired by an imaging device, two or more focus evaluation algorithms are used to calculate focus evaluation values ​​separately. The focus evaluation values ​​obtained from different focus evaluation algorithms for the same image are then normalized and weighted and fused to obtain a comprehensive focus evaluation value. In one embodiment, a gradient function (such as the Tenengrad function) sensitive to high-frequency details and a variance function sensitive to edges but with better noise resistance can be used to measure the sharpness of the image of the region of interest acquired by the imaging device. Then, after normalization, weights are assigned to the focus evaluation values ​​obtained from the two algorithms according to detection requirements, and the fused values ​​yield a comprehensive focus evaluation value. This effectively overcomes the problem of a flat or multi-peaked single function curve caused by the low texture and high reflectivity of the cutting tool surface, improving focusing accuracy and anti-interference capability.

[0121] S1007. Under the optimal focusing position relationship, control the imaging device to acquire a global image of the tool; wherein, the global image is used for defect detection and analysis of the tool.

[0122] For example, by controlling a motion device to move the cutting tool or imaging device, the positional relationship between the cutting tool and the imaging device can be optimized for focusing. The imaging device is controlled to sense and read data from all areas of the image sensor, and transmits this data, enabling the imaging device to acquire a global image of the cutting tool—that is, to acquire pixel data from the area of ​​interest as well as areas outside the area of ​​interest. Subsequent defect detection and analysis can then detect and analyze the complete image of the cutting tool to identify defects at various locations on the tool.

[0123] In determining the optimal focus position relationship, the focus evaluation value of the image of the area of ​​interest is used. That is, under the optimal focus position relationship, the image clarity of the area of ​​interest can be guaranteed at least, which is conducive to ensuring clear imaging of the key parts of the tool and to the detection of defects in the key parts.

[0124] The adaptive focusing method of the vision inspection system provided in Embodiment 2 of this invention adaptively determines the region of interest and, based on this region, determines the photosensitive area of ​​the photosensitive chip. This allows the imaging device to read and transmit only pixel data within the region of interest, significantly reducing the data volume of a single frame image, improving image acquisition and processing speed, and enabling the imaging device to acquire images at a higher frame rate. This greatly shortens the focusing time, which is beneficial for meeting the cycle time requirements of online automatic defect detection. Thus, focusing search can be performed with a smaller step size without affecting the cycle time requirements of online automatic defect detection, facilitating fast, accurate, and robust adaptive focusing. The adaptive focusing method of the vision inspection system provided in Embodiment 2 of this invention can solve the accuracy and efficiency problems of focusing on precision tools with micro-sized, complex three-dimensional structures, such as end mills, and can also achieve precise focusing on specific areas, ensuring clear imaging of critical parts.

[0125] Example 3

[0126] Figure 3 This is a flowchart of an adaptive focusing method for a vision inspection system provided in Embodiment 3 of the present invention. This embodiment adds the content of performing attitude correction before focusing to finely correct the angular position of the tool. Figure 3 As shown, the method includes:

[0127] S2001. Move the cutting tool to the first pre-focusing position of the first imaging device and control the first imaging device to acquire the initial image of the cutting tool's end face.

[0128] For example, the cutting tool or the first imaging device can be moved by a motion device, so that the cutting tool is located at the first pre-focusing position of the first imaging device, at which time the first imaging device is located on the end face side of the cutting tool.

[0129] S2002. Preprocess the initial end face image to obtain a preprocessed end face image, and extract the end face parameters of the tool from the preprocessed end face image; wherein, the end face parameters of the tool include the angular position of the cutting edge of the tool.

[0130] The preprocessing of the initial image of the end face can be referred to the description of the preprocessing of the initial image above. The similarities between the present invention and the above embodiments will not be described again in the third embodiment of the present invention, and only the differences will be explained.

[0131] S2003. Determine the tool end face template based on the tool end face parameters.

[0132] The tool end face template is an image or matrix used to match or identify the tool end face. The tool end face template can be manually created according to requirements, or it can be extracted from the standard end face image of a standard tool, or it can be learned from a data model.

[0133] For example, based on the tool's end-face parameters, adaptive matching based on prior knowledge is performed on the preprocessed image of the tool's end face, which can automatically select the most matching tool end-face template from a pre-stored template library. The tool end-face template includes a cutting edge contour. In one embodiment, the cutting edge contour extracted from the preprocessed image can be adaptively matched with the cutting edge contour of the tool end-face template in the template library to obtain the most matching tool end-face template.

[0134] S2004. According to the preset image processing strategy, adjust the angular position relationship between the end face preprocessed image and the tool end face template, and calculate the angle matching value between the end face preprocessed image and the tool end face template under each angular position relationship.

[0135] The preset image processing strategy refers to pre-setting an angle range and, within that range, sequentially rotating the pre-processed end-face image or the tool end-face template with a specific step size to adjust the angular position relationship between the cutting edge of the tool in the pre-processed end-face image and the tool end-face template. The angle matching value, also known as the attitude matching degree, quantifies the consistency between the angular position of the cutting edge in the pre-processed end-face image and the angular position of the cutting edge in the tool end-face template. Specifically, at least a portion of the cutting edge in the tool end-face template is parallel to the reference axis direction of the image coordinate system.

[0136] The angle matching value and the consistency between the cutting edge's angular position in the preprocessed end face image and the cutting edge's angular position in the tool end face template are positively correlated. When the angle matching value is at its maximum, the cutting edge's angular position in the preprocessed image is almost identical to the cutting edge's angular position in the tool end face template, meaning that the cutting edge in the preprocessed image can be parallel to the corresponding cutting edge in the tool end face template.

[0137] S2005. Based on the angle position relationship when the angle matching value is at its maximum, determine the deviation angle between the cutting edge position of the tool and the reference axis direction of the image coordinate system.

[0138] Before adjusting the angular position relationship, the angular position of the cutting edge in the pre-processed end face image is the actual angular position of the cutting edge of the tool. At least part of the cutting edge in the tool end face template is parallel to the reference axis direction of the image coordinate system. The deviation angle is equal to the difference angle between the angular position of the cutting edge in the pre-processed end face image and the corresponding angular position of the cutting edge in the tool end face template before adjusting the angular position relationship between the pre-processed end face image and the tool end face template, according to the preset image processing strategy.

[0139] S2006. Based on the deviation angle, rotate the tool so that at least a portion of the tool's cutting edge is parallel to the reference axis direction of the image coordinate system.

[0140] For example, at least a portion of the cutting edge in the tool end face template is parallel to the reference axis direction of the image coordinate system. By rotating the tool according to the deviation angle, the cutting edge of the tool can be made parallel to the corresponding cutting edge in the tool end face template. That is, at least a portion of the cutting edge of the tool can be made parallel to the reference axis direction of the image coordinate system. In this way, the angular position of the cutting edge of the tool can be corrected, avoiding the tilt of the final acquired end face global image caused by tool clamping error, which would affect subsequent defect detection and analysis.

[0141] S2007. Based on the tool parameters, determine a portion of the pre-processed end face image as the first region of interest.

[0142] In one embodiment, the pre-processed end-face image located at the initial corner position can be rotated according to the deviation angle, so that at least a portion of the blade's corner position in the rotated pre-processed end-face image is parallel to the reference axis direction of the image coordinate system. Then, based on the tool parameters, a portion of the pre-processed end-face image is determined as the first region of interest. This helps ensure that the content presented within the first region of interest corresponds to the content presented by the posture-corrected physical tool, avoiding angular deviations between the two that could affect the accuracy of the subsequent first photosensitive area.

[0143] In other embodiments, a portion of the tool end face template can be determined as the first region of interest based on the tool end face template. For example, a key region can be pre-set in the tool end face template, which can serve as the first region of interest. The parallelism between the cutting edge of the physical tool after attitude correction and the corresponding cutting edge in the tool end face template ensures that the content presented within the first region of interest corresponds to the content presented by the physical tool after attitude correction, avoiding angular deviations that could affect the accuracy of the subsequent first photosensitive area.

[0144] S2008. Determine the first photosensitive area of ​​the photosensitive chip of the first imaging device based on the coordinates and size of the first area of ​​interest.

[0145] S2009. According to the first preset focus search strategy, adjust the positional relationship between the cutting tool and the end face of the first imaging device, and under each end face positional relationship, control the first imaging device to acquire an image of the first area of ​​interest according to the first photosensitive area.

[0146] S2010. Calculate the end-face focus evaluation value of the image of the first region of interest under each end-face position relationship, and determine the end-face position relationship with the maximum end-face focus evaluation value as the optimal end-face focus position relationship.

[0147] S2011. Under the optimal focusing position relationship of the end face, control the first imaging device to acquire a global image of the end face of the tool; wherein, the global image of the end face is used to perform defect detection and analysis on the end face of the tool.

[0148] Specifically, the adaptive focusing method of the vision inspection system provided in the third embodiment of the present invention can adaptively focus on the end face of the tool, and before focusing on the end face of the tool, the rotation angle of the tool can be precisely corrected so that at least part of the cutting edge direction of the tool end face can be parallel to the reference axis of the image coordinate system of the first imaging device. This can improve the efficiency and accuracy of the focusing process, ensure the accuracy and consistency of subsequent focusing evaluation, and overcome the problem of inaccurate focusing evaluation caused by imaging tilt due to size error and clamping error.

[0149] For example, an appropriate angle range can be adaptively selected based on the end face parameters of the tool (e.g., the number, arrangement, and symmetry of the cutting edges). Then, the tool end face template is rotated within this angle range in preset small steps (e.g., 0.1°). Simultaneously, algorithms such as normalized cross-correlation matching and edge matching are used to calculate the angle matching value between the tool end face template and the pre-processed end face image at each step position. After traversing the entire angle range, the rotation angle at which the angle matching value is maximized is determined. This rotation angle is the deviation angle between the cutting edge's angular position and the reference axis direction of the image coordinate system. The electrically controlled rotary table in the motion control device drives the tool to rotate, and the rotation angle is the deviation angle between the cutting edge's angular position and the reference axis direction of the image coordinate system. This compensates for the deviation between the cutting edge's angular position and the reference axis direction of the image coordinate system, ensuring that the cutting edge direction of the tool end face is precisely adjusted to be parallel to the reference axis of the image coordinate system. In this way, it can be ensured that during the adaptive focusing process on the end face of the tool, and when the first imaging device is controlled to acquire a global image of the end face of the tool under the optimal focusing position relationship of the end face, at least part of the cutting edge of the tool is parallel to the reference axis direction of the image coordinate system. This can improve the efficiency and accuracy of the focusing process, ensure the accuracy and consistency of subsequent focusing evaluation, and overcome the problem of inaccurate focusing evaluation caused by imaging tilt due to size error and clamping error.

[0150] The adaptive focusing method of the vision inspection system provided in Embodiment 3 of the present invention can solve the problem of inaccurate focusing evaluation caused by clamping tilt by correcting the tool's posture before focusing, thereby improving the efficiency and accuracy of the focusing process and ensuring the accuracy and consistency of subsequent focusing evaluation. In subsequent steps, it can obtain defect images with rich details and clear edges, laying the foundation for high-reliability defect identification.

[0151] In an optional embodiment, the imaging device includes a second imaging device; wherein the second imaging device is used to capture the circumferential surface of the tool; after controlling the first imaging device to acquire a global image of the tool's end face under the optimal focusing position relationship of the end face, the adaptive focusing method further includes: controlling the tool to rotate according to a preset tool rotation strategy, and controlling the second imaging device to acquire a global image of the tool's circumferential surface after each tool rotation; wherein each global image of the circumferential surface is used to perform defect detection and analysis on the circumferential surface of the tool.

[0152] The preset tool rotation strategy involves rotating the tool within a specific rotation range (e.g., 180°) with a specific rotation step (e.g., 10°) so that the second imaging device can capture global images of the tool's circumferential surface at different rotation angles, thereby enabling defect detection and analysis of the tool's complete circumferential surface.

[0153] For example, when performing adaptive focusing on different cutting tools, the total length (including the cutting edge and shank) of different tools varies significantly. Therefore, adaptive focusing on the tool's end face is necessary before visual inspection. However, the diameter (thickness) of different tools varies less, so adaptive focusing on the tool's circumference is not required before visual inspection. Under the optimal focusing position relationship of the end face, after the first imaging device acquires a global image of the tool's end face, the tool can be directly controlled to be positioned at a fixed focusing position of the second imaging device. This fixed focusing position is then used as the optimal focusing position, and the second imaging device acquires global images of the circumference of the tool at different rotation angles to perform defect detection and analysis on the circumference of the tool at different locations. This improves the speed of visual inspection of cutting tools while maintaining image clarity.

[0154] Based on the above embodiments, while moving the tool to the first pre-focus position of the first imaging device, the tool can also be positioned at the fixed focus position of the second imaging device (also known as the optimal focus position of the second imaging device). Thus, under the optimal focus position relationship of the end face, after controlling the first imaging device to acquire a global image of the tool's end face, the second imaging device can be directly controlled to acquire a global image of the circumferential surface of the tool rotated to different rotation angles, without needing to move the tool and / or the position of the second imaging device according to its focal length.

[0155] In another optional embodiment, the imaging device includes a second imaging device; wherein the second imaging device is used to capture the circumferential surface of the tool; the adaptive focusing method further includes: moving the tool to a second pre-focusing position of the second imaging device, controlling the second imaging device to acquire an initial image of the circumferential surface of the tool; preprocessing the initial circumferential surface image to obtain a preprocessed circumferential surface image, and extracting the circumferential surface parameters of the tool in the preprocessed circumferential surface image; determining a portion of the preprocessed circumferential surface image as a second region of interest based on the circumferential surface parameters of the tool; determining a second photosensitive area of ​​the photosensitive chip of the second imaging device based on the coordinates and size of the second region of interest; and performing a second preset focusing search. The algorithm employs a search strategy to adjust the positional relationship between the cutting tool and the circumferential surface of the second imaging device. Under each circumferential surface positional relationship, the second imaging device is controlled to acquire an image of the second region of interest based on the second photosensitive area. The circumferential focusing evaluation value of the image of the second region of interest under each circumferential surface positional relationship is calculated, and the circumferential surface positional relationship with the maximum circumferential focusing evaluation value is determined as the optimal circumferential focusing positional relationship. Under the optimal circumferential focusing positional relationship, the cutting tool is controlled to rotate according to a preset cutting tool rotation strategy, and after each cutting tool rotation, the second imaging device is controlled to acquire a global image of the cutting tool's circumferential surface. The global images of each circumferential surface are used for defect detection and analysis of the cutting tool's circumferential surface.

[0156] For example, after adaptive focusing on the end face of the tool, adaptive focusing can also be performed on the circumferential surface of the tool. Since attitude correction has already been performed before adaptive focusing on the end face, no further attitude correction is needed before adaptive focusing on the circumferential surface. After obtaining the optimal focus position relationship on the circumferential surface, the tool can be controlled to rotate at a set step size, and global images of the circumferential surface can be acquired at different rotation angles to perform defect detection and analysis on the circumferential surface at different positions of the tool.

[0157] Based on the above embodiments, while moving the tool to the first pre-focus position of the first imaging device, the tool can also be positioned at the second pre-focus position of the second imaging device. Thus, under the optimal focusing position relationship of the end face, after controlling the first imaging device to acquire a global image of the tool's end face, the second imaging device can be directly controlled to acquire an initial image of the tool's circumferential surface, without needing to move the tool and / or the second imaging device according to its second pre-focus position before acquiring the initial image of the tool's circumferential surface.

[0158] In other alternative embodiments, a tool circumferential template can be determined based on the tool's end face parameters; and a portion of the tool circumferential template can be designated as a second region of interest based on the tool circumferential template.

[0159] For example, the complete parameters of the tool can be determined based on the end face parameters of the tool, thereby determining the tool's circumferential template. Then, based on the tool's circumferential template, a portion of the template is determined as the second region of interest. In one embodiment, a key region can be pre-set in the tool's circumferential template, which can serve as the second region of interest. Thus, the second region of interest can be determined directly through the tool's end face parameters, eliminating the need to move the tool to the second pre-focusing position of the second imaging device, control the second imaging device to acquire the initial image of the tool's circumferential surface, or preprocess the initial image to obtain a preprocessed image and extract the tool's circumferential parameters from it. This improves the adaptive focusing efficiency of the tool's circumferential surface.

[0160] Example 4

[0161] Figure 4 This is a flowchart of an adaptive focusing method for a visual inspection system provided in Embodiment 4 of the present invention. This embodiment adds optional content for a preset focus search strategy. Figure 4 As shown, the method includes:

[0162] S3001. Move the cutting tool to the pre-focus position of the imaging device and control the imaging device to acquire the initial image of the cutting tool.

[0163] S3002. Preprocess the initial image to obtain a preprocessed image, and extract the tool parameters from the preprocessed image.

[0164] S3003. Based on the tool parameters, determine a portion of the preprocessed image as the region of interest.

[0165] S3004. Determine the photosensitive area of ​​the image sensor chip of the imaging device based on the coordinates and size of the area of ​​interest.

[0166] S3005. Within the first focusing stroke, the positional relationship between the cutting tool and the imaging device is adjusted using the first step length as the first positional relationship, so that the first positional relationship traverses the entire first focusing stroke, and under each first positional relationship, the imaging device is controlled to acquire an image of the area of ​​interest based on the photosensitive area.

[0167] S3006. Calculate the focus evaluation value of the image of the region of interest under each first positional relationship, and determine the second focus travel corresponding to the peak value of the focus evaluation value; wherein the second focus travel is less than the first focus travel.

[0168] S3007. Within the second focusing stroke, the positional relationship between the cutting tool and the imaging device is adjusted by the second step length as the second positional relationship, so that the second positional relationship traverses the entire second focusing stroke, and under each second positional relationship, the imaging device is controlled to acquire the image of the area of ​​interest according to the photosensitive area; wherein, the second step length is less than the first step length.

[0169] S3008. Calculate the focus evaluation value of the image of the region of interest under each second positional relationship, and determine the positional relationship with the maximum focus evaluation value within the second focus travel as the optimal focus positional relationship.

[0170] S3009. Under the optimal focusing position relationship, control the imaging device to acquire a global image of the tool; wherein, the global image is used for defect detection and analysis of the tool.

[0171] The first focusing stroke is a coarse focusing stroke, in which the first step is relatively long; the second focusing stroke is located within the first focusing stroke, and the second focusing stroke is a fine focusing stroke, in which the second supplement is relatively small.

[0172] For example, firstly, a larger step size is used to quickly traverse the first focusing stroke. Based on the focusing evaluation values ​​obtained within the first focusing stroke, the rising range of the focusing evaluation values ​​is located, and the range where the global peak is located is determined, which is the second focusing stroke. Then, a smaller second step size is used to traverse the second focusing stroke, performing a fine search to accurately find the positional relationship when the focusing evaluation value is maximum, which is the optimal focusing positional relationship.

[0173] The adaptive focusing method of the visual inspection system provided in Embodiment 4 of the present invention adopts an improved adaptive hill-climbing search strategy. During the search process, the focusing range and focusing step size are dynamically adjusted according to the changing trend of the focusing evaluation value. This allows for the rapid and accurate finding of the global maximum value of the focusing evaluation value, avoiding being limited to local maximum values. Furthermore, it can minimize electrode movement and image acquisition while ensuring the finding of the optimal focusing position relationship, thus balancing speed and accuracy and further improving focusing efficiency and accuracy.

[0174] Optionally, the adaptive focusing method further includes: determining a third focusing stroke based on the focusing evaluation value of the image of the region of interest under each second positional relationship, wherein the third focusing stroke is shorter than the second focusing stroke; within the third focusing stroke, adjusting the positional relationship between the tool and the imaging device with a third step size as the third positional relationship, so that the third positional relationship traverses the entire third focusing stroke, and under each third positional relationship, controlling the imaging device to acquire an image of the region of interest based on the photosensitive area; wherein the third step size is shorter than the second step size; calculating the focusing evaluation value of the image of the region of interest under each third positional relationship, and determining the positional relationship with the maximum focusing evaluation value within the third focusing stroke as the optimal focusing positional relationship. This further improves focusing accuracy, enabling precise focusing for micro-sized, complex three-dimensional structures such as end mills.

[0175] Example 5

[0176] Figure 5 This is a schematic diagram of the adaptive focusing device of a visual inspection system provided in Embodiment 5 of the present invention. Figure 5 As shown, the adaptive focusing device includes:

[0177] The pre-focusing module 051 is used to move the cutting tool to the pre-focusing position of the imaging device and control the imaging device to acquire the initial image of the cutting tool.

[0178] The preprocessing module 052 is used to preprocess the initial image to obtain a preprocessed image and extract the tool parameters from the preprocessed image;

[0179] The focus determination module 053 is used to determine a portion of the preprocessed image as the region of interest based on the tool parameters;

[0180] The photosensitive determination module 054 is used to determine the photosensitive area of ​​the photosensitive chip of the imaging device based on the coordinates and size of the area of ​​interest.

[0181] The focus search module 055 is used to adjust the positional relationship between the tool and the imaging device according to the preset focus search strategy, and under each positional relationship, control the imaging device to acquire the image of the area of ​​interest according to the photosensitive area;

[0182] The adaptive module 056 is used to calculate the focus evaluation value of the image of the region of interest under each positional relationship, and determine the positional relationship with the maximum focus evaluation value as the optimal focus positional relationship;

[0183] The global acquisition module 057 is used to control the imaging device to acquire a global image of the tool under the optimal focusing position relationship; the global image is used for defect detection and analysis of the tool.

[0184] Optionally, the preprocessing module 052 includes:

[0185] The image processing unit is used to perform grayscale thresholding and image morphology processing on the initial image to obtain a preprocessed image.

[0186] A region recognition unit is used to identify the cutting edge region of the tool in the preprocessed image;

[0187] The parameter extraction unit is used to extract the parameters of the tool based on the cutting edge region of the tool in the preprocessed image.

[0188] Optionally, the imaging device includes a first imaging device; wherein the first imaging device is used to image the end face of the cutting tool;

[0189] The pre-focusing module 051 includes a first pre-focusing unit (not shown in the figure), which is used to move the tool to the first pre-focusing position of the first imaging device and control the first imaging device to acquire an initial image of the end face of the tool.

[0190] The preprocessing module 052 includes a first preprocessing unit (not shown in the figure), which is used to preprocess the initial end face image to obtain a preprocessed end face image and extract the end face parameters of the tool in the preprocessed end face image;

[0191] The attention determination module 053 includes a first attention determination unit (not shown in the figure), which is used to determine a portion of the end face preprocessed image as the first attention area based on the end face parameters of the tool.

[0192] The photosensitive determination module 054 includes a first photosensitive determination unit (not shown in the figure), which is used to determine the first photosensitive area of ​​the photosensitive chip of the first imaging device according to the coordinates and size of the first area of ​​interest;

[0193] The focus search module 055 includes a first focus search unit (not shown in the figure), which is used to adjust the positional relationship between the cutting tool and the end face of the first imaging device according to the first preset focus search strategy, and control the first imaging device to acquire an image of the first area of ​​interest according to the first photosensitive area under each end face positional relationship.

[0194] The adaptive module 056 includes a first adaptive unit (not shown in the figure), which is used to calculate the end-face focus evaluation value of the image of the first region of interest under each end-face position relationship, and determine the end-face position relationship when the end-face focus evaluation value is the maximum as the optimal end-face focus position relationship.

[0195] The global acquisition module 057 includes a first global acquisition unit (not shown in the figure), which is used to control the first imaging device to acquire a global image of the end face of the tool under the optimal focusing position relationship of the end face; wherein, the global image of the end face is used to perform defect detection and analysis on the end face of the tool.

[0196] Based on the above embodiments, the end face parameters of the tool include the angular position of the cutting edge;

[0197] The adaptive focusing device further includes: an attitude correction module (not shown in the figure), used to determine the tool end face template according to the tool end face parameters; adjust the angular position relationship between the pre-processed end face image and the tool end face template according to a preset image processing strategy, and calculate the angle matching value between the pre-processed end face image and the tool end face template under each angular position relationship; determine the deviation angle between the angular position of the tool's cutting edge and the reference axis direction of the image coordinate system according to the angular position relationship when the angle matching value is the maximum; and rotate the tool according to the deviation angle so that at least a portion of the cutting edge of the tool is parallel to the reference axis direction of the image coordinate system.

[0198] Based on the above embodiments, the imaging device includes a second imaging device; wherein the second imaging device is used to photograph the circumferential surface of the cutting tool;

[0199] The global acquisition module 057 is also used to control the first imaging device to acquire a global image of the end face of the tool under the optimal focusing position relationship of the end face, and then control the tool to rotate according to a preset tool rotation strategy. After each tool rotation, it controls the second imaging device to acquire a global image of the circumferential surface of the tool. The global images of each circumferential surface are used to detect and analyze defects on the circumferential surface of the tool.

[0200] Based on the above embodiments, the imaging device includes a second imaging device; wherein the second imaging device is used to capture images of the circumferential surface of the cutting tool;

[0201] The pre-focusing module 051 also includes a second pre-focusing unit (not shown in the figure), which is used to move the tool to the second pre-focusing position of the second imaging device and control the second imaging device to acquire an initial image of the tool's circumferential surface.

[0202] The preprocessing module 052 also includes a second preprocessing unit (not shown in the figure), which is used to preprocess the initial peripheral image to obtain a peripheral preprocessed image and extract the peripheral parameters of the tool in the peripheral preprocessed image;

[0203] The attention determination module 053 also includes a second attention determination module unit (not shown in the figure), which is used to determine a portion of the preprocessed image of the circumferential surface as the second attention area based on the circumferential surface parameters of the tool.

[0204] The photosensitive determination module 054 further includes a second photosensitive determination module unit (not shown in the figure), which is used to determine the second photosensitive area of ​​the photosensitive chip of the second imaging device according to the coordinates and size of the second area of ​​interest;

[0205] The focus search module 055 also includes a second focus search module unit (not shown in the figure), which is used to adjust the positional relationship between the tool and the peripheral surface of the second imaging device according to the second preset focus search strategy, and control the second imaging device to acquire the image of the second area of ​​interest according to the second photosensitive area under each peripheral surface positional relationship;

[0206] The adaptive module 056 also includes a second adaptive unit (not shown in the figure), which is used to calculate the peripheral focus evaluation value of the image of the second region of interest under each peripheral positional relationship, and determine the peripheral positional relationship when the peripheral focus evaluation value is the maximum as the optimal peripheral focus positional relationship.

[0207] The global acquisition module 057 also includes a second global acquisition unit (not shown in the figure), which is used to control the rotation of the tool according to a preset tool rotation strategy under the optimal focusing position relationship on the circumferential surface, and control the second imaging device to acquire a global image of the tool's circumferential surface after each tool rotation; wherein, each global image of the circumferential surface is used to perform defect detection and analysis on the circumferential surface of the tool.

[0208] In other alternative implementations, the second focus determination module unit is used to determine the tool circumferential template based on the tool end face parameters, and to determine a portion of the tool circumferential template as the second focus area; in this case, the second pre-focusing unit and the second pre-processing unit may not be required.

[0209] Optionally, the focus search module 055 includes:

[0210] The first search unit is used to adjust the positional relationship between the cutting tool and the imaging device by a step length within the first focusing stroke, so that the first positional relationship traverses the entire first focusing stroke, and under each first positional relationship, control the imaging device to acquire an image of the area of ​​interest based on the photosensitive area.

[0211] The search refinement unit is used to calculate the focus evaluation value of the image of the region of interest under each first positional relationship, and determine the second focus travel corresponding to the peak value of the focus evaluation value; wherein, the second focus travel is less than the first focus travel.

[0212] The second search unit is used to adjust the positional relationship between the tool and the imaging device with a second step length within the second focusing stroke, so that the second positional relationship traverses the entire second focusing stroke, and under each second positional relationship, controls the imaging device to acquire an image of the region of interest based on the photosensitive area; wherein, the second step length is less than the first step length.

[0213] The adaptive module 056 is also used to calculate the focus evaluation value of the image of the region of interest under each second positional relationship, and to determine the positional relationship with the maximum focus evaluation value within the second focus stroke as the optimal focus positional relationship.

[0214] Optionally, the adaptive module 056 is further configured to calculate the focus evaluation value of the image of the region of interest under different positional relationships according to multiple focus evaluation algorithms; to perform weighted fusion of the focus evaluation values ​​obtained under each focus evaluation algorithm to obtain a comprehensive focus evaluation value; and to determine the positional relationship with the maximum comprehensive focus evaluation value as the optimal focus positional relationship. In one embodiment, the focus evaluation algorithm includes a gradient focus evaluation algorithm and a variance focus evaluation algorithm.

[0215] The adaptive focusing device of the visual inspection system provided in Embodiment 5 of the present invention can execute the adaptive focusing method of the visual inspection system provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the method.

[0216] Note that the above description is merely a preferred embodiment of the present invention and the technical principles employed. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and various obvious changes, readjustments, and substitutions can be made without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments, and may include many other equivalent embodiments without departing from the concept of the present invention, the scope of which is determined by the scope of the appended claims.

Claims

1. An adaptive focusing method for a visual inspection system, characterized in that, include: The cutting tool is moved to the first pre-focus position of the first imaging device, and the first imaging device is controlled to acquire an initial image of the end face of the cutting tool; wherein, the first imaging device is used to capture the end face of the cutting tool. The initial end face image is preprocessed to obtain a preprocessed end face image, and the end face parameters of the tool are extracted from the preprocessed end face image; wherein, the end face parameters of the tool include the angular position of the cutting edge of the tool; Determine the tool end face template based on the end face parameters of the tool; According to a preset image processing strategy, the angular position relationship between the pre-processed end face image and the tool end face template is adjusted, and under each angular position relationship, the angle matching value between the pre-processed end face image and the tool end face template is calculated. Based on the angular position relationship when the angular matching value is at its maximum, determine the deviation angle between the angular position of the cutting edge of the tool and the reference axis direction of the image coordinate system. Based on the deviation angle, the cutting tool is rotated so that at least a portion of the cutting edge is parallel to the reference axis direction of the image coordinate system; Based on the end face parameters of the cutting tool, a portion of the preprocessed end face image is determined as the first region of interest; Based on the coordinates and size of the first region of interest, the first photosensitive area of ​​the photosensitive chip of the first imaging device is determined; According to the first preset focus search strategy, the positional relationship between the cutting tool and the end face of the first imaging device is adjusted, and under each end face positional relationship, the first imaging device is controlled to acquire an image of the first region of interest based on the first photosensitive area; Calculate the end-face focus evaluation value of the image of the first region of interest under each end-face position relationship, and determine the end-face position relationship when the end-face focus evaluation value is the maximum as the optimal end-face focus position relationship; under the optimal end-face focus position relationship, control the first imaging device to acquire a global image of the end face of the tool; wherein, the global end-face image is used to perform defect detection and analysis on the end face of the tool.

2. The adaptive focusing method of the visual inspection system according to claim 1, characterized in that, The adaptive focusing method further includes: Move the cutting tool to the pre-focus position of the imaging device, and control the imaging device to acquire an initial image of the cutting tool; The initial image is subjected to grayscale thresholding and image morphology processing to obtain a preprocessed image; Identify the cutting edge region of the tool in the preprocessed image; Based on the cutting edge region of the tool in the preprocessed image, extract the parameters of the tool; Based on the parameters of the cutting tool, a portion of the preprocessed image is determined as the region of interest; The photosensitive area of ​​the photosensitive chip of the imaging device is determined based on the coordinates and size of the region of interest. According to a preset focus search strategy, the positional relationship between the cutting tool and the imaging device is adjusted, and under each positional relationship, the imaging device is controlled to acquire an image of the region of interest based on the photosensitive area; Calculate the focus evaluation value of the image of the region of interest under each of the aforementioned positional relationships, and determine the positional relationship with the maximum focus evaluation value as the optimal focus positional relationship; Under the optimal focusing position relationship, the imaging device is controlled to acquire a global image of the cutting tool; wherein, the global image is used for defect detection and analysis of the cutting tool.

3. The adaptive focusing method of the visual inspection system according to claim 1, characterized in that, The adaptive focusing method further includes: The tool is controlled to rotate according to a preset tool rotation strategy, and after each tool rotation, the second imaging device is controlled to acquire a global image of the tool's circumference. The second imaging device is used to capture images of the circumferential surface of the cutting tool; each of the global images of the circumferential surface is used to detect and analyze defects on the circumferential surface of the cutting tool.

4. The adaptive focusing method of the visual inspection system according to any one of claims 1-2, characterized in that, The adaptive focusing method further includes: The cutting tool is moved to the second pre-focus position of the second imaging device, and the second imaging device is controlled to acquire an initial image of the circumferential surface of the cutting tool; wherein, the second imaging device is used to capture the circumferential surface of the cutting tool; The initial image of the circumferential surface is preprocessed to obtain a preprocessed image of the circumferential surface, and the circumferential surface parameters of the tool are extracted from the preprocessed image of the circumferential surface. Based on the circumferential parameters of the cutting tool, a portion of the preprocessed circumferential image is determined as the second region of interest. The second photosensitive area of ​​the photosensitive chip of the second imaging device is determined based on the coordinates and size of the second area of ​​interest. According to the second preset focus search strategy, the positional relationship between the cutting tool and the peripheral surface of the second imaging device is adjusted, and under each peripheral surface positional relationship, the second imaging device is controlled to acquire an image of the second region of interest based on the second photosensitive area; Calculate the circumferential focus evaluation value of the image of the second region of interest under each of the circumferential positional relationships, and determine the circumferential positional relationship when the circumferential focus evaluation value is the maximum as the optimal circumferential focus positional relationship. Under the optimal focusing position relationship of the circumferential surface, the tool is controlled to rotate according to a preset tool rotation strategy, and after each tool rotation, the second imaging device is controlled to acquire a global image of the circumferential surface of the tool; wherein, each global image of the circumferential surface is used to perform defect detection and analysis on the circumferential surface of the tool.

5. The adaptive focusing method of the visual inspection system according to claim 1, characterized in that, The adaptive focusing method further includes: Based on the end face parameters of the tool, determine the tool circumferential template; Based on the tool peripheral surface template, a portion of the tool peripheral surface template is determined as the second region of interest; Based on the coordinates and dimensions of the second region of interest, the second photosensitive area of ​​the photosensitive chip of the second imaging device is determined; wherein, the second imaging device is used to photograph the circumferential surface of the cutting tool; According to the second preset focus search strategy, the positional relationship between the cutting tool and the peripheral surface of the second imaging device is adjusted, and under each peripheral surface positional relationship, the second imaging device is controlled to acquire an image of the second region of interest based on the second photosensitive area; Calculate the circumferential focus evaluation value of the image of the second region of interest under each of the circumferential positional relationships, and determine the circumferential positional relationship when the circumferential focus evaluation value is the maximum as the optimal circumferential focus positional relationship. Under the optimal focusing position relationship of the circumferential surface, the tool is controlled to rotate according to a preset tool rotation strategy, and after each tool rotation, the second imaging device is controlled to acquire a global image of the circumferential surface of the tool; wherein, each global image of the circumferential surface is used to perform defect detection and analysis on the circumferential surface of the tool.

6. The adaptive focusing method of the visual inspection system according to claim 2, characterized in that, According to a preset focus search strategy, the positional relationship between the cutting tool and the imaging device is adjusted, and under each positional relationship, the imaging device is controlled to acquire an image of the region of interest based on the photosensitive area, including: Within the first focusing stroke, the positional relationship between the cutting tool and the imaging device is adjusted by the first step length as the first positional relationship, so that the first positional relationship traverses the entire first focusing stroke, and under each first positional relationship, the imaging device is controlled to acquire an image of the region of interest according to the photosensitive area; Calculate the focus evaluation value of the image of the region of interest under each of the first positional relationships, and determine the second focus travel corresponding to the peak value of the focus evaluation value; wherein the second focus travel is less than the first focus travel. Within the second focusing stroke, the positional relationship between the tool and the imaging device is adjusted by a second step length to form a second positional relationship, which traverses the entire second focusing stroke. Under each second positional relationship, the imaging device is controlled to acquire an image of the region of interest based on the photosensitive area; wherein, the second step length is smaller than the first step length. Calculate the focus evaluation value of the image of the region of interest under each of the aforementioned positional relationships, and determine the positional relationship with the maximum focus evaluation value as the optimal focus positional relationship, including: Calculate the focus evaluation value of the image of the region of interest under each of the second positional relationships, and determine the positional relationship in which the focus evaluation value is maximized within the second focus travel as the optimal focus positional relationship.

7. An adaptive focusing device for a visual inspection system, characterized in that, The adaptive focusing device is used to perform the adaptive focusing method of the visual inspection system according to any one of claims 1-6; The adaptive focusing device includes: A pre-focusing module is used to move the cutting tool to a first pre-focusing position of the first imaging device and control the first imaging device to acquire an initial image of the end face of the cutting tool; wherein, the first imaging device is used to capture an image of the end face of the cutting tool. The preprocessing module is used to preprocess the initial end face image to obtain a preprocessed end face image, and extract the end face parameters of the tool from the preprocessed end face image; wherein, the end face parameters of the tool include the angular position of the cutting edge of the tool; The attitude correction module is used to determine the tool end face template based on the tool end face parameters; adjust the angular position relationship between the pre-processed end face image and the tool end face template according to a preset image processing strategy, and calculate the angle matching value between the pre-processed end face image and the tool end face template under each angular position relationship; determine the deviation angle between the angular position of the tool's cutting edge and the reference axis direction of the image coordinate system based on the angular position relationship when the angle matching value is the largest; and rotate the tool according to the deviation angle so that at least a portion of the cutting edge of the tool is parallel to the reference axis direction of the image coordinate system. The focus determination module is used to determine a portion of the preprocessed end face image as the first focus area based on the end face parameters of the tool. A photosensitive determination module is used to determine the first photosensitive area of ​​the photosensitive chip of the first imaging device based on the coordinates and size of the first area of ​​interest. The focus search module is used to adjust the positional relationship between the cutting tool and the end face of the first imaging device according to the first preset focus search strategy, and under each end face positional relationship, control the first imaging device to acquire an image of the first region of interest according to the first photosensitive area; An adaptive module is used to calculate the end-face focus evaluation value of the image of the first region of interest under each end-face position relationship, and determine the end-face position relationship when the end-face focus evaluation value is the maximum as the optimal end-face focus position relationship. A global acquisition module is used to control the first imaging device to acquire a global image of the end face of the cutting tool under the optimal focusing position relationship of the end face; wherein, the global image of the end face is used to perform defect detection and analysis on the end face of the cutting tool.

8. A visual inspection system, characterized in that, The visual inspection system includes a first imaging device, a motion device, and a controller; The first imaging device is used to photograph the end face of the cutting tool; The motion device is used to drive the cutting tool and / or the first imaging device to move; The controller is electrically connected to the first imaging device and the motion device respectively, and the controller is used to execute the adaptive focusing method of the visual detection system according to any one of claims 1-6.