A closed-loop automatic focusing method and system for lithium battery film burr detection

CN122921944APending Publication Date: 2026-10-16NANJING HUASHI INTELLIGENT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611416536.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-14
Publication Date
2026-10-16

AI Technical Summary

Technical Problem

[0003]现有锂电薄膜毛刺检测中的自动对焦方法通常依赖单一清晰度评价值进行搜索判断,容易受到材料反光、表面纹理、灰尘污染以及局部缺陷等因素影响,产生虚假清晰度峰值,导致焦点定位不准确,固定步长搜索方式难以兼顾对焦速度与定位精度,容易出现跨越最佳焦点或搜索时间过长的问题,缺少对搜索过程中的峰值有效性验证以及局部区域精细补偿机制,在复杂工业环境下容易出现误停、焦点偏移以及自动对焦失败等情况,难以满足锂电薄膜毛刺检测对高精度、高稳定性成像的需求

Benefits of technology

本发明,通过自动搜索最佳成像焦点,使工业相机能够在毛刺检测过程中始终保持较高边缘清晰度,降低因离焦造成的毛刺边缘模糊、尺寸测量偏差以及缺陷漏检问题,提高细小毛刺、尖刺及缺口等微小缺陷的识别准确性,根据不同采样位置对应的清晰度评价值自动确定对焦方向及移动策略,通过检测图像反馈实时调整对焦轴运动过程,无需操作人员手动调节镜头焦距,减少人工经验差异,提高设备调试效率及运行一致性,采用由初始采样、方向搜索、局部精细搜索组成的多阶段搜索方式,在较大范围内快速定位焦点区域,并在候选区域内进行精细定位,相比全程小步搜索方式减少采图次数,提高自动对焦速度,同时保证最终焦点定位精度;

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122921944A_ABST
    Figure CN122921944A_ABST
Patent Text Reader

Abstract

The present application belongs to the technical field of lithium battery thin film burr detection, and particularly relates to a closed-loop automatic focusing method and system for lithium battery thin film burr detection. The present application, through candidate position determination and subsequent continuous image definition verification mechanism, does not directly take the first appearing definition peak as the final focus point, further judges whether there is a higher response after the peak, improves the reliability of automatic focusing, does not need to fix the focus point position in advance, but acquires image definition information in real time according to the current detection area and completes focus point search, so as to adapt to different equipment assembly errors, different material thickness changes and focal length changes after maintenance adjustment, improve the applicability of the lithium battery thin film burr detection equipment under different production conditions, do not need to change the existing burr detection hardware structure, can be directly integrated into the existing lithium battery thin film, pole piece or diaphragm visual detection equipment, and improve the intelligent level of the equipment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of lithium battery thin film burr detection technology, specifically relating to a closed-loop automatic focusing method and system for lithium battery thin film burr detection. Background Technology

[0002] Lithium-ion batteries, as crucial energy storage devices in the new energy field, involve multiple processes in their manufacturing, including electrode preparation, separator processing, film slitting, winding, and stacking. During the processing of lithium-ion battery films, electrodes, and separators, defects such as burrs, spikes, wire drawing, notches, and localized warping are easily generated at the material edges due to factors such as mechanical cutting, material stretching, equipment wear, and fluctuations in process parameters. These defects are typically small in size, and some burrs are elongated structures distributed along the material edges, significantly impacting the safety and reliability of subsequent battery assembly. Therefore, in the production of lithium-ion battery materials, machine vision inspection is usually required for online detection of material edge defects to achieve automatic identification and quality control of burrs. Existing lithium-ion battery film burr detection equipment typically uses industrial cameras, lenses, and light source components to acquire images of the material edge areas and extracts edge features through image processing algorithms to achieve burr detection.

[0003] Existing autofocus methods for lithium battery thin film burr detection typically rely on a single sharpness evaluation value for search and judgment. This is easily affected by factors such as material reflection, surface texture, dust contamination, and local defects, resulting in false sharpness peaks and inaccurate focus positioning. Fixed step size search methods struggle to balance focusing speed and positioning accuracy, often leading to issues such as exceeding the optimal focus or excessively long search times. Furthermore, they lack verification of peak validity during the search process and fine compensation mechanisms for local areas. In complex industrial environments, they are prone to accidental stops, focus shifts, and autofocus failures, making it difficult to meet the high-precision and high-stability imaging requirements of lithium battery thin film burr detection. Summary of the Invention

[0004] The purpose of this invention is to provide a closed-loop autofocus method and system for detecting burrs in lithium-ion battery films. Through a closed-loop search and peak verification mechanism, it can achieve rapid and accurate autofocus during the detection of burrs in lithium-ion battery films, thereby improving the clarity of the detected images and the reliability of defect identification.

[0005] The specific technical solution adopted by this invention is as follows: A closed-loop autofocus method for detecting burrs in lithium battery thin films, comprising: Obtain the image sampling position corresponding to the burr detection area of ​​the lithium battery thin film, and control the focus axis to move to the initial imaging position; Acquire detection images of the focus axis at the initial imaging position and at multiple sampling positions offset from the initial imaging position, and obtain the sharpness evaluation value corresponding to each detection image; The current focus direction is determined based on the sharpness evaluation value corresponding to each detected image, and a search control command corresponding to the current focus direction is generated. The focus axis is moved according to the search control command. During the movement of the focus axis, the detection image is continuously acquired, and the sharpness evaluation value corresponding to the sampled position is updated according to the sharpness evaluation value corresponding to the detection image. Based on the updated sharpness evaluation value, the candidate position corresponding to the sharpness peak is determined. When the candidate position meets the preset filtering conditions, the local search area corresponding to the candidate position is determined. Control the focus axis to make fine movements within the local search area, and acquire the detection images corresponding to multiple fine movement positions within the local search area, and acquire the sharpness evaluation value corresponding to the detection image at each fine movement position; Based on the sharpness evaluation value corresponding to the detection image at each fine movement position and the sharpness evaluation value corresponding to the detection images acquired continuously after the candidate position is determined, the fine movement position is verified, and the optimal imaging focus position is determined according to the verification result. The focusing axis is then controlled to move to the optimal imaging focus position to complete the automatic focusing in the lithium battery thin film burr detection process.

[0006] In a preferred embodiment, obtaining the image sampling position corresponding to the lithium battery thin film burr detection area and controlling the focus axis to move to the initial imaging position includes: Acquire the current position data of the lithium battery film in the burr detection station, and determine the target detection area to be inspected for burrs based on the current position data; Obtain the installation position parameters between the industrial camera and the focusing axis, determine the corresponding image acquisition area based on the target detection area, and determine the image sampling position of the industrial camera based on the installation position parameters between the industrial camera and the focusing axis. The initial movement position corresponding to the focus axis is obtained based on the image sampling position, and the focus axis movement command is generated based on the initial movement position. The focus axis is moved to the initial position according to the focus axis movement command, so that the imaging area of ​​the industrial camera corresponds to the target detection area, and the initial imaging position is obtained.

[0007] In a preferred embodiment, detection images are acquired at the initial imaging position and at multiple sampling positions offset from the initial imaging position, and a sharpness evaluation value is acquired for each detection image, including: The initial sampling reference for the focus axis is determined based on the initial imaging position, and multiple offset sampling positions are set along the movement direction of the focus axis according to the initial sampling reference. The focusing axis is controlled to move sequentially to the initial imaging position and each offset sampling position, and the detection image corresponding to the lithium battery thin film burr detection area is acquired after the focusing axis reaches the corresponding position. The image data corresponding to each detected image is obtained, and the sharpness is calculated based on the image data to obtain the sharpness evaluation value corresponding to each detected image.

[0008] In a preferred embodiment, the current focus direction is determined based on the sharpness evaluation value corresponding to each detected image, and a search control command corresponding to the current focus direction is generated, including: The sharpness evaluation value corresponding to each detected image is used to obtain the sampling position and the sharpness evaluation value corresponding to each sampling position, and the sharpness evaluation values ​​are arranged according to the focus axis movement direction corresponding to the sampling position. Based on the arranged sharpness evaluation values, determine the direction and magnitude of sharpness change between different sampling positions, and determine the target movement direction of the focus axis based on the direction of sharpness change; The search movement mode corresponding to the focus axis is determined based on the target's movement direction and the magnitude of the sharpness change, and search control commands are generated in conjunction with the target's movement direction.

[0009] In a preferred embodiment, the focus axis is moved according to a search control command. During the movement of the focus axis, detection images are continuously acquired, and the sharpness evaluation value corresponding to the sampled position is updated based on the sharpness evaluation value corresponding to the detection image, including: According to the search control command, the focus axis is controlled to move along the current focus direction to a new sampling position, and the detection image corresponding to the lithium battery film burr detection area is obtained after the focus axis reaches the new sampling position. The sharpness of the detected image corresponding to the new sampling position is calculated to obtain the sharpness evaluation value corresponding to the new sampling position; The new sampling location and its corresponding sharpness evaluation value are merged with the sharpness evaluation values ​​corresponding to the already sampled locations, and the sharpness evaluation value corresponding to each sampling location obtained in the current search process is updated.

[0010] In a preferred embodiment, candidate locations corresponding to sharpness peaks are determined based on the updated sharpness evaluation values. When a candidate location meets preset filtering conditions, a local search region corresponding to the candidate location is determined, including: Obtain the updated sharpness evaluation value for each sampling position, sort the sharpness evaluation values ​​for each sampling position in descending order, and select the sampling position corresponding to the first sharpness evaluation value as the candidate position. Determine whether the sharpness evaluation value corresponding to the candidate position meets the preset peak judgment condition; When a candidate position meets the preset peak value judgment condition, the local search area is determined based on the candidate position and the adjacent sampling positions corresponding to the candidate position. When a candidate position does not meet the preset peak judgment condition, the focus axis movement direction is re-determined based on the sharpness evaluation value corresponding to each sample position after the update, and a corresponding search control command is generated to re-judge the candidate position.

[0011] In a preferred embodiment, the focus axis is controlled to make fine movements within a local search area, and detection images corresponding to multiple fine movement positions within the local search area are acquired. A sharpness evaluation value is obtained for the detection image at each fine movement position, including: The focus axis is determined by the local search area, which contains multiple fine movement positions. Control the focusing axis to move sequentially to each fine movement position, and acquire the detection image corresponding to the lithium battery thin film burr detection area after the focusing axis moves to the corresponding fine movement position; The sharpness of the detected image corresponding to each fine movement position is calculated to obtain the sharpness evaluation value of the detected image at each fine movement position.

[0012] In a preferred embodiment, the fine movement position is verified based on the sharpness evaluation value corresponding to the detection image at each fine movement position and the sharpness evaluation value corresponding to the detection images acquired consecutively after the candidate position is determined. Based on the verification result, the optimal imaging focus position is determined, and the focusing axis is controlled to move to the optimal imaging focus position to complete the automatic focusing process in the lithium battery thin film burr detection process, including: The sharpness evaluation values ​​corresponding to the detected images at each fine movement position are sorted in descending order, and the sharpness evaluation value at the top is taken as the target sharpness evaluation value. After determining the candidate location, obtain the sharpness evaluation value corresponding to each detection image acquired consecutively, and compare it with the target sharpness evaluation value; When the target sharpness evaluation value is higher than the sharpness evaluation value of each detection image acquired consecutively after the candidate position is determined, the candidate position is determined to meet the focus confirmation condition, and the fine movement position corresponding to the target sharpness evaluation value is determined as the optimal imaging focus position. The focus axis is controlled to move to the optimal imaging focus position to complete the automatic focusing in the lithium battery thin film burr detection process. When the target sharpness evaluation value is lower than the sharpness evaluation value of each detection image acquired consecutively after the candidate position is determined, the fine movement position corresponding to the target sharpness evaluation value does not meet the focus confirmation condition, and the focus search position is re-determined based on the sharpness evaluation values ​​corresponding to multiple movement positions within the local search area.

[0013] The present invention also provides a closed-loop autofocus system for detecting burrs in lithium-ion battery films, used in the aforementioned closed-loop autofocus method for detecting burrs in lithium-ion battery films, comprising: The initial imaging position module is used to acquire the image sampling position corresponding to the lithium battery thin film burr detection area and control the focus axis to move to the initial imaging position. The sharpness evaluation module is used to acquire detection images of the focus axis at the initial imaging position and at multiple sampling positions offset from the initial imaging position, and to acquire the sharpness evaluation value corresponding to each detection image. The search control instruction module determines the current focus direction based on the sharpness evaluation value corresponding to each detected image and generates a search control instruction corresponding to the current focus direction. The sharpness evaluation update module is used to control the focus axis to move according to the search control command, continuously acquire detection images during the movement of the focus axis, and update the sharpness evaluation value corresponding to the sampled position according to the sharpness evaluation value corresponding to the detection image. The local search region module is used to determine the candidate position corresponding to the sharpness peak based on the updated sharpness evaluation value. When the candidate position meets the preset filtering conditions, the local search region corresponding to the candidate position is determined. The fine movement module is used to control the focus axis to move finely within the local search area, and to acquire the detection images corresponding to multiple fine movement positions within the local search area, and to acquire the sharpness evaluation value corresponding to the detection image at each fine movement position. The imaging focus module is used to verify the fine movement position based on the sharpness evaluation value corresponding to the detection image at each fine movement position and the sharpness evaluation value corresponding to the detection images acquired continuously after the candidate position is determined. Based on the verification result, the optimal imaging focus position is determined, and the focusing axis is controlled to move to the optimal imaging focus position to complete the automatic focusing in the lithium battery thin film burr detection process.

[0014] And, a closed-loop autofocus terminal for detecting burrs in lithium battery thin films, comprising: One or more processors; A storage device on which one or more programs are stored; When one or more programs are executed by one or more processors, the one or more processors implement a closed-loop autofocus method for detecting burrs in lithium-ion battery films.

[0015] The technical effects achieved by this invention are as follows: This invention enables industrial cameras to maintain high edge sharpness throughout the burr detection process by automatically searching for the optimal imaging focus. This reduces problems such as blurred burr edges, dimensional measurement deviations, and missed defects caused by defocusing, and improves the accuracy of identifying minute defects such as small burrs, spikes, and notches. The focusing direction and movement strategy are automatically determined based on the sharpness evaluation value corresponding to different sampling positions. The focusing axis movement is adjusted in real time through feedback from the detected images, eliminating the need for operators to manually adjust the lens focal length, reducing differences in human experience, and improving equipment debugging efficiency and operational consistency. The multi-stage search method consisting of initial sampling, direction search, and local fine search quickly locates the focus area over a large range and performs fine positioning within the candidate area. Compared with the small-step search method throughout the process, this reduces the number of image acquisitions, increases the autofocus speed, and ensures the final focus positioning accuracy. This invention, through candidate position determination and subsequent continuous image sharpness verification mechanism, does not directly take the first sharpness peak as the final focus, but further judges whether there is a higher response after the peak, thereby reducing the misjudgment of local peaks caused by factors such as film reflection, material texture, contaminated areas, and local burr protrusions, and improving the reliability of automatic focusing. It does not require pre-fixing the focus position, but acquires image sharpness information in real time based on the current detection area and completes the focus search. Therefore, it can adapt to different equipment assembly errors, different material thickness variations, and focal length variations after maintenance and adjustment, improving the applicability of lithium battery film burr detection equipment under different production conditions. It achieves closed-loop automatic focusing only through image acquisition by an industrial camera, sharpness evaluation calculation, and focus axis motion control, without changing the existing burr detection hardware structure. It can be directly integrated into existing lithium battery film, electrode, or separator visual inspection equipment, improving the intelligence level of the equipment. Attached Figure Description

[0016] Figure 1 This is a flowchart of the method provided by the present invention; Figure 2 This is a system module diagram provided by the present invention. Detailed Implementation

[0017] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings.

[0018] Many specific details are set forth in the following description in order to provide a full understanding of the invention. However, the invention may also be practiced in other ways different from those described herein, and those skilled in the art can make similar extensions without departing from the spirit of the invention. Therefore, the invention is not limited to the specific embodiments disclosed below.

[0019] Secondly, the term "an embodiment" or "embodiment" as used herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The phrase "in a preferred embodiment" appearing in different places throughout this specification does not necessarily refer to the same embodiment, nor is it a single or selective embodiment that mutually excludes other embodiments.

[0020] Furthermore, the present invention will be described in detail with reference to the schematic diagrams. When describing the embodiments of the present invention in detail, the schematic diagrams are merely examples for ease of explanation and should not limit the scope of protection of the present invention.

[0021] Please see the appendix Figure 1 As shown, a closed-loop autofocus method for detecting burrs in lithium battery thin films is provided, comprising: S1. Obtain the image sampling position corresponding to the lithium battery thin film burr detection area, and control the focus axis to move to the initial imaging position; S2. Acquire detection images of the focus axis at the initial imaging position and at multiple sampling positions offset from the initial imaging position, and acquire the sharpness evaluation value corresponding to each detection image. S3. Determine the current focus direction based on the sharpness evaluation value corresponding to each detected image, and generate a search control command corresponding to the current focus direction; S4. Control the focus axis to move according to the search control command, continuously acquire detection images during the movement of the focus axis, and update the sharpness evaluation value corresponding to the sampled position according to the sharpness evaluation value corresponding to the detection image. S5. Determine the candidate position corresponding to the sharpness peak based on the updated sharpness evaluation value. When the candidate position meets the preset filtering conditions, determine the local search area corresponding to the candidate position. S6. Control the focus axis to make fine movements within the local search area, and acquire the detection images corresponding to multiple fine movement positions within the local search area, and acquire the sharpness evaluation value corresponding to the detection image at each fine movement position. S7. Based on the sharpness evaluation value corresponding to the detection image at each fine movement position and the sharpness evaluation value corresponding to the detection images continuously acquired after determining the candidate position, the fine movement position is verified, and the optimal imaging focus position is determined based on the verification result. The focusing axis is controlled to move to the optimal imaging focus position to complete the automatic focusing in the lithium battery thin film burr detection process.

[0022] As described in steps S1 to S7 above, to address the issue of focus shift caused by material thickness variations, equipment assembly errors, and changes in detection distance during lithium-ion battery film burr detection, the image sampling position corresponding to the lithium-ion battery film burr detection area is obtained. The focus axis is then moved to the initial imaging position, aligning the industrial camera's imaging area with the area to be detected. After initial positioning, images are acquired at the initial imaging position and multiple sampling positions offset from it, obtaining detection images at different focal lengths. Each detection image undergoes sharpness evaluation processing to obtain sharpness evaluation values ​​corresponding to different sampling positions. These sharpness evaluation values ​​characterize the image edges, textures, and details at the current focus position. The sharpness of the image is assessed; a higher sharpness evaluation value indicates that the current focal length position is closer to the true image focus. Based on the sharpness evaluation values ​​corresponding to multiple sampling positions, the direction of sharpness improvement is determined, thereby determining the current movement direction of the focusing axis and generating corresponding search control commands. This allows the focusing axis to automatically adjust its movement direction based on actual imaging feedback results, without relying on fixed-direction searches, improving the adaptability of the autofocus process to different material conditions and equipment installation errors. During the movement of the focusing axis according to the search control commands, new detection images are continuously acquired, and the sharpness evaluation value corresponding to the new sampling position is calculated. The new sampling position and corresponding sharpness evaluation value are updated and fused with the data corresponding to the existing sampling positions, enabling real-time acquisition of the current image. The system analyzes the sharpness distribution at different locations within the search range to achieve closed-loop search control based on real-time image feedback. When the updated sharpness evaluation value reaches the peak region, candidate positions corresponding to the sharpness peak are determined based on the sharpness evaluation values ​​corresponding to multiple sampling positions. The validity of the candidate positions is then judged. If a candidate position meets preset screening conditions, it indicates that the current area may contain a true imaging focus. A local search area is then determined based on the candidate position and its adjacent sampling positions. If a candidate position does not meet the screening conditions, the focus direction is readjusted to continue the search. This avoids the system from stopping at an incorrect peak position due to material texture, reflection, contamination, or local defects. After determining the local search area, the focus axis is controlled to perform fine focusing within the local search area. The system moves at a distance smaller than the previous search step size, acquiring detection images corresponding to multiple fine-grained movement positions and calculating the sharpness evaluation value for each position to achieve high-precision localization of candidate focus areas. The validity of the peak position obtained through fine-grained search is verified by comparing the sharpness evaluation value corresponding to the fine-grained movement position with the sharpness evaluation values ​​of subsequently acquired images. If no higher sharpness evaluation value appears at subsequent acquired positions, the current peak position is considered the true focus position and is designated as the optimal imaging focus position. The focus axis is then moved to this position to complete autofocus. If a higher sharpness evaluation value appears at a subsequent position, the current peak is considered potentially a local false peak, and the search process continues.Until the optimal focus is obtained, the industrial camera maintains high edge sharpness throughout the burr detection process by automatically searching for the best imaging focus. This reduces burr edge blurring, dimensional measurement deviations, and missed defects caused by defocusing, improving the accuracy of identifying minute defects such as small burrs, spikes, and notches. The camera automatically determines the focus direction and movement strategy based on the sharpness evaluation value corresponding to different sampling positions, and adjusts the focus axis movement in real time through image feedback. This eliminates the need for manual lens focal length adjustment by operators, reducing human experience differences and improving equipment debugging efficiency and operational consistency. A multi-stage search method consisting of initial sampling, direction search, and local fine search is employed to quickly locate the focus area over a large range and perform fine positioning within candidate areas. Compared to a full-process small-step search method, this reduces the number of image acquisitions, increases autofocus speed, and ensures final focus positioning accuracy. The system employs a fixed image sharpness verification mechanism, which does not directly use the first sharpness peak as the final focus. Instead, it further determines whether a higher response exists after the peak, thereby reducing misjudgments of local peaks caused by factors such as film reflection, material texture, contaminated areas, and local burr protrusions. This improves the reliability of automatic focusing. It eliminates the need for pre-fixing the focus position, instead acquiring image sharpness information in real-time based on the current detection area and completing the focus search. Therefore, it can adapt to different equipment assembly errors, variations in material thickness, and focal length changes after maintenance and adjustments, enhancing the applicability of lithium battery film burr detection equipment under different production conditions. Closed-loop automatic focusing is achieved solely through image acquisition by an industrial camera, sharpness evaluation calculation, and focus axis motion control. It requires no changes to the existing burr detection hardware structure and can be directly integrated into existing lithium battery film, electrode, or separator visual inspection equipment, improving the equipment's intelligence level.

[0023] In a preferred embodiment, obtaining the image sampling position corresponding to the lithium battery thin film burr detection area and controlling the focus axis to move to the initial imaging position includes: S101. Obtain the current position data of the lithium battery film in the burr detection station, and determine the target detection area to be detected based on the current position data. S102. Obtain the installation position parameters between the industrial camera and the focusing axis, determine the corresponding image acquisition area based on the target detection area, and determine the image sampling position corresponding to the industrial camera by combining the installation position parameters between the industrial camera and the focusing axis. S103. Obtain the initial movement position corresponding to the focus axis based on the image sampling position, and generate a focus axis movement command based on the initial movement position; S104. Control the focus axis to move to the initial moving position according to the focus axis movement command, so that the imaging area of ​​the industrial camera corresponds to the target detection area, and obtain the initial imaging position.

[0024] As described in steps S101 to S104 above, the current position data of the lithium battery film in the burr detection station is obtained. This current position data represents the position of the lithium battery film relative to the coordinate system of the detection equipment. The current position data can be obtained through a position detection component installed on the conveying mechanism. For example, an encoder installed on the conveying roller, traction roller, or servo motor can collect the motion displacement data of the conveying mechanism. The encoder converts the rotation angle of the conveying roller into the distance the film moves along the conveying direction. Simultaneously, the edge position of the lithium battery film can be obtained through an industrial vision positioning module installed at the entrance of the detection station. The vision positioning module acquires an image of the film entering the detection area, identifies the film edge contour, and obtains the film edge. In addition to the position coordinates in the camera coordinate system, the station coordinate information in the equipment control system can be combined to fuse the displacement data acquired by the encoder with the visual positioning results to obtain the current position data of the lithium battery film. For example, the lithium battery film moves towards the burr detection station via a conveyor roller. The encoder connected to the conveyor roller outputs a fixed number of pulse signals for each rotation. The control system calculates the film's movement distance based on the number of pulses. When the visual positioning module at the entrance of the detection station detects that the left edge of the film has entered the field of view, it acquires the offset distance between the film edge and the camera center. Combining the conveyor displacement data with the edge offset data yields the current two-dimensional position data of the lithium battery film in the detection station, such as determining the film length. The angular position is 1500mm from the reference point of the inspection station, and the width position is 20mm from the center line of the equipment. Inspection area rules are pre-defined based on the characteristics of burr generation locations in the lithium battery film. For example, for slit lithium battery films, burrs mainly occur at the cut edges on both sides of the film. Therefore, a certain width area near the edge is determined as the target inspection area based on the current position data of the film edge. Alternatively, the model, width, and cutting position of the current lithium battery film can be obtained based on production process parameters, and the target area is determined according to the inspection area configuration corresponding to different models. For example, when inspecting electrode material with a width of 200mm, the left and right edge positions obtained through visual positioning are used to determine the target area, with a distance of 2mm from each edge. The area within the range is defined as the target detection area, which serves as the object for subsequent burr detection and autofocusing by the industrial camera. This ensures that the autofocus process is always focused on the actual lithium battery film area entering the inspection station, improving the accuracy of subsequent focus search. By acquiring the current position data of the lithium battery film in the inspection station in real time and determining the target detection area based on the current position data, the problem of the camera acquisition area deviating from the actual detection area due to material transport offset, equipment installation error, or changes in the position of materials of different specifications can be avoided. This ensures that the autofocus process is based on the accurate detection position, improving the effectiveness of focus search and adapting to the lithium battery film inspection needs under different position states during continuous production. The installation position parameters between the industrial camera and the focusing axis are obtained. These parameters describe the positional relationship between the optical center of the industrial camera, the focal direction of the lens, and the direction of movement of the focusing axis. These parameters can be obtained during the equipment assembly and calibration process. After the equipment is installed, a standard calibration plate is placed at the corresponding position in the burr detection station. Images of the calibration plate are captured by the industrial camera. The field of view of the industrial camera is determined based on the known dimensional information on the calibration plate. By controlling the movement of the focusing axis at different distances and recording the position with the highest image sharpness, the offset between the zero point position of the focusing axis and the actual focal plane is determined, thereby obtaining... To obtain the installation position parameters between the industrial camera and the focusing axis, for example, during equipment calibration, a standard planar calibration plate is fixed on the testing platform. Images of the calibration plate are acquired using the industrial camera, and the position of the calibration plate's center point in the camera coordinate system is identified. The focusing axis is controlled to move from 0mm to multiple positions such as 5mm, 10mm, and 15mm, acquiring images at each position. By comparing the image sharpness at different positions, the optimal focus point corresponding to the 10mm position is determined. Thus, the offset parameter from the zero point of the focusing axis to the actual focus point is 10mm. Based on the target detection area size and the industrial camera's field of view, the required... The image area to be covered, for example, the target detection area is a region 100mm long and 2mm wide at the edge of the thin film, while the single field of view coverage of the industrial camera is 20mm, requires dividing the area into multiple continuous acquisition areas according to the conveying direction, or adjusting the camera position so that the target area is located at the center of the field of view. Combining the installation position parameters between the industrial camera and the focusing axis, the spatial position corresponding to the target detection area is converted into the image sampling position in the industrial camera coordinate system. For example, through installation calibration, it is found that the center of the industrial camera is offset by 5mm in the horizontal direction and 3mm in the vertical direction relative to the center of the focusing axis. Then, based on the center position coordinates of the target detection area, this offset is compensated to obtain the position that the industrial camera needs to acquire, so that the center of the target detection area coincides with the imaging center of the camera, and finally the image sampling position corresponding to the industrial camera is determined. By obtaining the installation position parameters between the industrial camera and the focusing axis and combining them with the target detection area to determine the image sampling position, the position deviation generated during the equipment assembly process can be compensated, so that the camera field of view accurately covers the lithium battery thin film burr detection area, improving the consistency of the image acquisition position and avoiding the problem of automatic focus search area offset due to camera installation error. The initial movement position of the focusing axis is obtained based on the image sampling position. This process is completed based on the industrial camera imaging model and equipment calibration parameters. Since the image sampling position mainly describes the detection area of ​​the camera in the horizontal space direction, and the focusing axis is mainly responsible for adjusting the distance between the camera and the lithium battery film, the initial movement position in the Z-axis direction needs to be determined based on the working distance between the target detection area and the camera lens. For example, if the standard working distance between the lens and the detection platform is recorded as 50mm during equipment calibration, and the current lithium battery film thickness and installation height detection results indicate that the film surface is 48mm above the detection platform, then the initial movement position of the focusing axis needs to be adjusted to approximately 50mm from the film surface based on the distance difference between the two, so that the lens is within the effective imaging range. The standard focal length position can be obtained by reading the historical calibration parameters of the equipment, and then compensation is made based on the film height offset in the current position data. For example, the standard focal length position is... If the Z-axis coordinate is 100mm and the current material height is detected to be 1mm lower than the standard height, the initial movement position is adjusted to 101mm to keep the distance between the lens and the material surface consistent. After determining the initial movement position, a focus axis movement command is generated based on this position. The movement command includes control information such as movement direction, movement distance, and target position. For example, when the current focus axis position is 95mm and the determined initial movement position is 101mm, the control system generates a movement command of 6mm in the positive direction and sends the command to the motor drive module. The drive module then controls the lead screw motor or linear motor to move the focus axis to the target position. By automatically obtaining the initial movement position of the focus axis based on the image sampling position and generating corresponding motion control commands, the autofocus process can automatically establish the initial focus position based on the current detection conditions without the need for manual pre-adjustment of the focus length, thus improving the degree of automation. At the same time, it provides a reliable starting point for multi-position sampling and closed-loop search. After receiving the focus axis movement command, the control system sends the command to the motion controller. The motion controller controls the drive mechanism to move the focus axis along the lens optical axis to the designated position based on the target position. During the movement, the motion controller acquires position data from the encoder in real time and compares the actual position with the target position. Movement stops when the actual position reaches the target position range. For example, if the initial target position is 101mm on the Z-axis, the motion controller controls the motor to move the focus axis from 95mm to 101mm. During the movement, the encoder provides real-time feedback on the current position. When the feedback position reaches the range of 100.98mm to 101.02mm, the target position is considered reached, and movement stops. By detecting the real-time image captured by the industrial camera, it is determined whether the target detection area is within the effective area of ​​the image. For example, by identifying the edge of the thin film... If the target detection area is not located in the center of the image, and the edge position deviates from the preset range, compensation is made by adjusting the position of the conveyor mechanism or the camera sampling position until the target detection area enters the field of view of the industrial camera. After the position matching is completed, the position of the focusing axis at this time is taken as the initial imaging position. For example, after the position adjustment, the edge of the lithium battery film in the image acquired by the industrial camera is located in the center of the image, and the target burr detection area is completely covered in the effective area of ​​the image. Then, the current focusing axis coordinates are recorded as the initial imaging position. By controlling the focusing axis to move to the initial moving position and verifying the correspondence between the industrial camera imaging area and the target detection area, it can be ensured that the acquired images all come from the correct detection area, improving the stability of the autofocus process. By recording the initial imaging position as the search benchmark, focus search can be performed around the actual detection position, reducing the search range and improving focusing efficiency and accuracy.

[0025] In a preferred embodiment, detection images are acquired at the initial imaging position and at multiple sampling positions offset from the initial imaging position, and a sharpness evaluation value is acquired for each detection image, including: S201. Determine the initial sampling reference of the focusing axis based on the initial imaging position, and set multiple offset sampling positions along the movement direction of the focusing axis according to the initial sampling reference. S202, control the focusing axis to move sequentially to the initial imaging position and each offset sampling position, and acquire the detection image corresponding to the lithium battery thin film burr detection area after the focusing axis reaches the corresponding position; S203. Obtain the image data corresponding to each detected image, and perform sharpness calculation processing based on the image data to obtain the sharpness evaluation value corresponding to each detected image.

[0026] As described in steps S201 to S203 above, after obtaining the initial imaging position, this initial imaging position is used as a spatial reference point in the direction of the focusing axis. The initial sampling reference is determined based on the current position coordinates of the focusing axis. This initial sampling reference represents the initial distance between the industrial camera and the lithium battery film detection surface. It can be obtained by reading the position data fed back by the focusing axis encoder. For example, when the focusing axis is driven by a linear motor, the motion controller reads the position pulses output by the encoder in real time and calculates the actual position of the focusing axis based on the movement distance corresponding to each encoder pulse. If the encoder feeds back the current focusing axis position as Z-axis coordinate 100mm, then Z=100mm is used as the initial sampling reference. To improve the reliability of the initial sampling reference, it can also be corrected by combining the image sharpness result corresponding to the initial imaging position. That is, a detection image is acquired at the initial imaging position, and a sharpness evaluation value is calculated for this image. If the sharpness evaluation value is within a preset effective range, the current initial sampling reference is maintained. If the sharpness evaluation value is too low, the initial sampling reference is compensated according to the equipment calibration parameters. For example, the sharpness evaluation value range of a normal burr detection image is obtained through multiple equipment adjustments beforehand. Between 80 and 120, when the sharpness evaluation value calculated from the image acquired at the initial position is 95, it indicates that the initial imaging position meets the sampling requirements. The current Z-axis position is used as the initial sampling reference. If the sharpness evaluation value is only 50, it is considered that the initial position deviates from the effective focus area, and the sampling reference needs to be adjusted according to the historical focal length compensation value. The sampling interval and number of samples are determined based on the focusing range of the autofocus device, the depth of field range of the lens, and the detection accuracy requirements of the lithium battery thin film. The sampling interval can be set according to the actual focusing accuracy of the device. For example, if the minimum movement accuracy of the focusing axis is 0.5μm, the sampling interval can be set to 10. The sampling range can be set according to the lens depth of field, from μm to 50μm. For example, if the effective clear imaging range of the lens is ±200μm, multiple offset positions can be set on both sides of the initial sampling reference. For instance, when the initial sampling reference is Z=100mm, the sampling range is set to ±200μm on both sides of the initial position, and the sampling interval is 50μm, then four offset sampling positions are set along the positive direction: Z=100.05mm, 100.10mm, 100.15mm, and 100.20mm, and along the negative direction: Z=99.95mm, 99.90mm, 99.85mm, and 99.90mm.Nine initial sampling positions are formed by using four offset sampling positions at 80mm and a central sampling position at Z=100mm. This allows the autofocus algorithm to establish a sharpness variation sampling area near the initial focus. By establishing an initial sampling reference for the focus axis based on the initial imaging position and setting multiple offset sampling positions around this reference, the focus shift problem caused by directly using a fixed focal length position for searching can be avoided. This allows the sampling range to adapt to different equipment installation states, different material thicknesses, and different detection environments. At the same time, by sampling at multiple positions, the trend of image sharpness change during focal length changes can be obtained, improving the accuracy of the initial autofocus search. The focusing axis motion path is generated based on the initial sampling position sequence. The motion path includes the center position and the movement sequence between multiple offset positions. In order to reduce the impact of motion error on the image acquisition results, the control system usually controls the focusing axis movement in a way that expands from near to far or from the center to both sides. For example, if the initial sampling position sequence includes Z=100mm, 99.95mm, 99.90mm, 100.05mm, 100.10mm, the control system first controls the focusing axis to move to the Z=100mm position. After confirming that the encoder feedback position has reached the target position, the industrial camera is triggered to acquire the image. Then, the focusing axis is controlled to move to Z=99.95mm. After reaching 95mm, wait for the position to stabilize before acquiring the image. This process is repeated for all sampling positions. During the focus axis movement control, the motion controller generates motion commands based on the difference between the target position and the current position. For example, if the current focus axis position is 100mm and it needs to move to 99.90mm, the control system generates a control command to move 0.10mm in the negative direction and controls the motor to run according to the set speed. When the encoder feedback position reaches 99.90mm and the position change is less than a set threshold for multiple consecutive cycles (e.g., less than 1μm within 5 consecutive sampling cycles), the focus axis is considered to have stabilized and reached the corresponding sampling position. Afterwards, the industrial camera receives the acquisition trigger signal and acquires image data within the current field of view according to the preset exposure time, gain parameters, and resolution parameters. Exposure time and gain parameters can be obtained through equipment calibration. For example, under the current light source brightness conditions, after multiple tests, it was determined that an exposure time of 500μs and a gain of 1.5x can ensure significant grayscale changes in the film edge area. Therefore, the same imaging parameters are used to acquire images at each sampling position to avoid the impact of different exposure conditions on the sharpness evaluation results. For example, when the detection area is the edge of a lithium battery film cut, the industrial camera acquires the first edge image at Z=100mm, and at Z=99mm... A second edge image is acquired at Z=0.95mm, and a third edge image is acquired at Z=100.05mm. All images contain the same thin film edge region, thus allowing the focus change trend to be determined by comparing the image sharpness at different focal lengths. By controlling the focus axis to move sequentially according to preset sampling positions and acquiring the corresponding detection image at each position, a correspondence between different focal lengths and image sharpness can be established. The optimal focus position can be determined based on actual imaging feedback. At the same time, by acquiring images after the position is stable, the impact of motion vibration, mechanical inertia, and positional errors on the autofocus results can be reduced, improving detection stability. Image data is acquired for each detection image. This data includes pixel information, grayscale information, and edge texture information within the target detection area. After the industrial camera acquires the data, each detection image is converted into a digital image matrix, where each pixel corresponds to a grayscale value. For example, if the industrial camera acquires a grayscale image with a resolution of 1920×1200 pixels, the image data includes grayscale values ​​corresponding to 1920×1200 pixels. Each grayscale value ranges from 0 to 255, where 0 represents black and 255 represents white. The effective detection area is extracted from the complete image based on the target detection area, avoiding the influence of background areas on sharpness calculations. For example, if the complete image size is 1920×1200 pixels... Since the edge region of the lithium battery film is located within a 200×800 pixel area on the left side of the image, only this 200×800 pixel area is extracted as the sharpness calculation area. Sharpness is then calculated based on the extracted image data. Sharpness evaluation can be performed using the degree of gradient change at the image edges. The basic principle is that in a sharp image, details such as burrs and film outlines show significant gray-scale changes, while in a defocused image, the edge transition area expands and gray-scale changes weaken. Therefore, the sharpness evaluation value is obtained by statistically analyzing the degree of gray-scale change between adjacent pixels within the detection area. For example, comparing the gray-scale values ​​of adjacent pixels in a certain detection area, if two adjacent pixels at a certain location have gray values ​​of 50 and 150 respectively, then... If the grayscale difference is 100, and the grayscale values ​​of adjacent pixels in another region are 90 and 110 respectively, then the grayscale difference is 20. Since the former has a more significant grayscale change, the corresponding image has higher sharpness. In actual calculation, the grayscale change values ​​of multiple pixels within the detection region are accumulated to obtain the sharpness evaluation value corresponding to the image. For example, if the cumulative grayscale change value of 1000 effective edge pixels in the first image is 95000, the corresponding cumulative value in the second image is 120000, and the corresponding cumulative value in the third image is 80000, then the second image has the highest sharpness evaluation value, indicating that the focal length position of the second image is closer to the optimal focus. To avoid the influence of noise in a single region, the detection region can be further optimized. The image is divided into multiple sub-regions, and the sharpness evaluation value is calculated separately for each sub-region. Then, the evaluation results of multiple sub-regions are combined. For example, if the burr detection area is divided into 5 regions, the sharpness evaluation values ​​obtained are 90, 95, 100, 98, and 97 respectively. The sharpness evaluation value of the current image is then obtained by combining the evaluation values ​​of multiple regions. Finally, the sharpness evaluation value corresponding to each detected image is obtained, and a data correspondence between sampling position and sharpness evaluation value is established. For example, Z=99.90mm corresponds to a sharpness evaluation value of 80, Z=99.95mm corresponds to a sharpness evaluation value of 110, Z=100mm corresponds to a sharpness evaluation value of 140, Z=100.05mm corresponds to a sharpness evaluation value of 170, and Z=100.A 10mm focal length corresponds to a sharpness evaluation value of 120. By processing the sharpness of inspection images acquired at different focal lengths, visual image information is converted into comparable sharpness evaluation values. This allows the autofocus process to perform focus searching based on objective image quality feedback, eliminating the need for manual observation. Furthermore, by performing local sharpness calculations on burr detection areas, it can highlight imaging changes at film edges and in areas with minute defects, improving the accuracy of determining the optimal focus position.

[0027] In a preferred embodiment, the current focus direction is determined based on the sharpness evaluation value corresponding to each detected image, and a search control command corresponding to the current focus direction is generated, including: S301. Obtain the sampling position and the sharpness evaluation value corresponding to each sampling position based on the sharpness evaluation value corresponding to each detection image, and arrange the sharpness evaluation values ​​according to the focus axis movement direction corresponding to the sampling position. S302. Determine the direction and magnitude of sharpness change between different sampling positions based on the arranged sharpness evaluation values, and determine the target movement direction of the focus axis based on the direction of sharpness change. S303. Determine the search movement mode corresponding to the focus axis based on the target movement direction and the magnitude of sharpness change, and generate search control commands in conjunction with the target movement direction.

[0028] As described in steps S301 to S303 above, the actual position data of the focus axis during each image acquisition is read, and this position data is associated with the sharpness evaluation value of the corresponding detected image. The sampling position data can be obtained by the position feedback unit in the focus axis motion control module. For example, the motor movement distance can be obtained by an encoder installed on the focus axis drive motor, and the actual focal length position can be calculated by combining the zero point position of the focus axis. When the focus axis is controlled to move to a certain sampling position, the motion controller records the current position feedback value and establishes a data number for the detected image acquired at that position, binding the two together. For example, during the initial sampling process, the focus axis is controlled to move to Z-axis positions of 99.80mm, 99.85mm, 99.90mm, 99.95mm, 100.00mm, 100.05mm, 100.10mm, 100.15mm, and 100.20mm respectively, and the corresponding detected images are acquired respectively. The corresponding evaluation value is obtained through sharpness calculation processing, thus forming the corresponding relationship: Z=99.80mm corresponds to sharpness. A resolution rating of 60 corresponds to a Z=99.85mm resolution rating of 80, a Z=99.90mm resolution rating of 110, a Z=99.95mm resolution rating of 140, a Z=100.00mm resolution rating of 170, a Z=100.05mm resolution rating of 200, a Z=100.10mm resolution rating of 150, a Z=100.15mm resolution rating of 100, and a Z=100.20mm resolution rating of 70. Since the focus axis moves along a fixed direction, the sampling positions need to be sorted according to the actual direction of movement of the focus axis to ensure that the trend of sharpness evaluation value changes is consistent with the direction of spatial movement. For example, when the search direction is set to move from the negative direction to the positive direction, the positions are arranged in ascending order of Z-axis coordinates, i.e., 99.80mm, 99.90mm, 99.95mm, 100.00mm, 100.05mm, 100.10mm, 100.15mm, 100.The 20mm sequence corresponds to sharpness evaluation values ​​of 60, 80, 110, 140, 170, 200, 150, 100, and 70. When the search direction moves from positive to negative, the sequence is reversed, resulting in sharpness evaluation values ​​of 70, 100, 150, 200, 170, 140, 110, 80, and 60. This gives the sharpness evaluation values ​​a clear spatial order of change, making it easier to determine whether sharpness is gradually increasing or decreasing in the current direction of movement. By binding the sampling position of the detected image to the sharpness evaluation value and arranging the data according to the direction of focus axis movement, discretely acquired image data can be converted into focus change data with spatial order. This accurately identifies the trend of sharpness change, avoids incorrect judgment of the search direction due to chaotic sampling order, and improves the reliability of autofocus control. Based on the sorted sharpness evaluation values, the sharpness change between adjacent sampling positions is judged. The direction of sharpness change indicates whether the image sharpness improves or decreases when moving from one sampling position to an adjacent one. The magnitude of sharpness change indicates the magnitude of the change in the sharpness evaluation value. This is determined by sequentially comparing the sharpness evaluation values ​​corresponding to two adjacent sampling positions. When the evaluation value of the later position is higher than that of the earlier position, the direction is determined as the direction of sharpness improvement; when the evaluation value of the later position is lower than that of the earlier position, the direction is determined as the direction of sharpness decrease. For example, after arranging the sharpness evaluation values ​​from the negative to the positive direction along the focus axis, the resulting sharpness evaluation value sequence is 60, 80, 110, 140, 170, 200, 150. First, comparing the positions Z=99.80mm and Z=99.85mm, the sharpness rating increases from 60 to 80, indicating improved sharpness as the camera moves in the positive direction. Continuing to compare the positions 99.85mm and 99.90mm, the rating increases from 80 to 110, still indicating improved sharpness. Next, comparing the positions 100.05mm and 100.10mm, the rating decreases from 200 to 150, indicating that sharpness begins to decline beyond these positions. The magnitude of the sharpness change is obtained by comparing the difference between the ratings at the two positions. For example, an increase from 60 to 80 represents a change of 20, an increase from 170 to 200 represents a change of 30, and a decrease from 200 to 150 represents a change of 50. By continuously comparing the changes at multiple adjacent positions, the approximate direction of the sharpness peak within the current sampling area can be determined. For example, if the sharpness evaluation value continuously increases as the focus axis moves from the negative to the positive direction, and then begins to decrease after reaching 100.05mm, it indicates that the true focus position is likely located near 100.05mm. Therefore, the current focus direction should continue to search in the positive direction until the peak position is further confirmed. When determining the target movement direction, it can be judged based on the sharpness improvement trend. If the sharpness evaluation value increases at multiple consecutive sampling positions while moving in the positive direction, then the positive direction is determined as the target movement direction. If the sharpness evaluation value increases while moving in the negative direction, then the negative direction is determined as the target movement direction. If both sides increase... If an improvement trend is observed, the direction with the larger improvement in sharpness is selected. For example, if the positive direction shows three consecutive changes of 10, 15, and 30, and the negative direction shows three consecutive changes of 5, 8, and 12, it indicates that the sharpness improvement in the positive direction is more significant. Therefore, the positive direction is selected as the target movement direction. By analyzing the direction and magnitude of sharpness changes between different sampling positions, the autofocus process can determine the search direction based on actual image feedback, rather than blindly moving in a fixed direction, thus improving focus search efficiency. By combining the magnitude of sharpness changes to determine the improvement trend, erroneous direction judgments caused by noise, reflection, or local texture changes at a single sampling point can be reduced, improving adaptability to complex lithium battery thin film detection environments. The appropriate search movement mode is selected based on the target's movement direction and the magnitude of sharpness changes. Search movement modes include fast search mode and fine search mode. Fast search mode is used to quickly approach the target area when the current focus position is far from the optimal focus area. Fine search mode is used for precise localization within a small area after approaching the peak area. The search movement mode is determined based on the magnitude of sharpness changes and the distance between the current sampling position and the peak area. For example, if the sharpness evaluation value continuously increases after moving along the target direction, and the changes between adjacent positions are significant (e.g., consecutive increases of 20, 30, 40), it indicates that the current position is still far from the optimal focus area. During the optimal focus area phase, a large-step fast search mode is selected, for example, controlling the focus axis to move 50μm each time. When the improvement in sharpness evaluation value gradually decreases, for example, the continuous change range decreases from 30 to 10 and then to 3, it indicates that the sharpness peak area is approaching. Then, switch to a small-step fine search mode, for example, controlling the focus axis to move 5μm to 10μm each time. The judgment of the search movement mode can be achieved based on a pre-set sharpness change threshold. This threshold is derived from the equipment debugging process. For example, by acquiring 100 sets of normal glitch detection images, the sharpness change range is calculated at different focal length positions, and the average change in the area far from the focus is statistically obtained. The change amplitude is greater than 20, while the change amplitude near the focus area is less than 10. Therefore, when the change amplitude is greater than 20, a fast search mode is entered; when it is less than 10, a fine search mode is entered; and between 10 and 20, the current mode is maintained. After determining the search movement mode, a search control command is generated based on the target movement direction. The search control command includes the movement direction, movement distance, and movement step size information, and is sent to the focus axis motion control module. For example, when the target movement direction is positive and the search movement mode is fast search mode, a control command is generated to move 50μm along the positive direction. When the target movement direction is still positive, but the fine search mode is entered, a control command is generated to move 50μm along the positive direction. Upon receiving a control command to move 10μm in the positive direction, the motion control module drives the focusing axis to move to the next sampling position and continues to acquire images to calculate the sharpness evaluation value. By dynamically selecting the search movement mode based on the target movement direction and the magnitude of sharpness change, it can automatically switch between large-area rapid positioning and local high-precision search. Compared with the fixed step size focusing method, it can reduce the search time and avoid the problem of crossing the real focus due to excessive step size. By generating a closed-loop search control command containing direction and step size information, the focusing axis can continuously adjust its movement state according to the real-time imaging results, improving the accuracy and stability of the autofocus process.

[0029] In a preferred embodiment, the focus axis is moved according to a search control command. During the movement of the focus axis, detection images are continuously acquired, and the sharpness evaluation value corresponding to the sampled position is updated according to the sharpness evaluation value corresponding to the detection image, including: S401. Control the focusing axis to move along the current focusing direction to a new sampling position according to the search control command, and obtain the detection image corresponding to the lithium battery film burr detection area after the focusing axis reaches the new sampling position. S402. Perform sharpness calculation processing on the detection image corresponding to the new sampling position to obtain the sharpness evaluation value corresponding to the new sampling position; S403. Merge the new sampling location and its corresponding sharpness evaluation value with the sharpness evaluation value corresponding to the already sampled location, and update the sharpness evaluation value corresponding to each sampling location obtained during the current search process.

[0030] As described in steps S401 to S403 above, after generating the search control command, the control system reads the movement direction, movement distance, and movement step size information from the search control command and sends the control command to the focus axis motion control module. The focus axis motion control module includes a motion controller, a driver, and a position feedback unit. The motion controller is used to parse the search control command, the driver is used to control the motor operation, and the position feedback unit is used to detect the actual movement position of the focus axis. For example, if the current focus axis position is Z=100.00mm, the determined target movement direction is the positive direction, and it is determined that the current search mode is fast, then the search control command includes control information for a 50μm movement in the positive direction. The motion controller converts the command into motor operating pulses, driving the focusing axis to move from Z=100.00mm to Z=100.05mm. During motor operation, the position feedback unit collects encoder feedback data in real time. For example, each encoder pulse represents a 0.5μm movement of the focusing axis, so a target movement of 50μm requires 100 movement pulses. The motion controller determines the movement distance based on the cumulative number of pulses. When the cumulative number of pulses reaches 100, the motor stops. Simultaneously, to avoid mechanical inertia causing a deviation in the actual stopping position, position feedback data continues to be read after the focusing axis stops. For example, the position is maintained at Z=100.05mm for five consecutive readings, and each time... If the positional change is less than 1μm, it is determined that the focusing axis has stabilized at the new sampling position. After confirming the stabilization of the focusing axis, the motion controller sends an image acquisition trigger signal to the industrial camera. The industrial camera acquires images according to the preset acquisition parameters, including exposure time, light source brightness, image resolution, and acquisition area range. These parameters are derived from the equipment initialization calibration process. For example, by acquiring multiple images of the lithium battery film edge, it was determined that when the light source brightness is 80%, the exposure time is 500μs, and the camera gain is 1.2 times, the burr area at the film edge has a significant grayscale change. Therefore, this set of parameters is used as the fixed acquisition parameters in the autofocus process. During the acquisition process, to avoid... To prevent background areas from affecting sharpness calculations, the corresponding image region is extracted based on the coordinates of the target detection area. For example, an industrial camera captures a complete image of 1920×1200 pixels, while the lithium battery film burr detection area is located in the image coordinate range of X=200 to 600 and Y=300 to 900. In this case, a 400×600 pixel area is cropped from the complete image as the detection image. For example, if the current focus axis has completed initial sampling and the sharpness improvement direction is known to be positive, the control system first sends a search command to move 50μm, moving the focus axis to Z=100.05mm. After stabilization, the first new detection image is captured, and then the next search command is executed to move to Z=100.At a focal length of 10mm, a second new detection image is acquired. By continuously acquiring images at different focal length positions, and controlling the focus axis to continuously move along the current direction of sharpness improvement according to search control commands, and acquiring a detection image after each movement position stabilizes, the autofocus process can continuously expand the search range according to the actual imaging state, avoiding focus shift caused by setting a fixed focal length all at once. By confirming the actual position of the focus axis through position feedback, the influence of mechanical errors, vibrations, and motion inertia on the sampling results can be reduced, improving the accuracy of focus determination. After acquiring the detection image corresponding to the new sampling position, the pixel data corresponding to the detection image is read, and the effective area containing the edge burr features of the lithium battery film is extracted according to the preset detection area. The image data is acquired by outputting a digital image from an industrial camera. Each pixel corresponds to a grayscale value. For example, the pixel grayscale range of an 8-bit grayscale industrial camera is 0 to 255, where 0 represents the lowest brightness and 255 represents the highest brightness. Since burr detection mainly focuses on the fine structure of the film edge, the entire image is not directly calculated. Instead, the area containing the edge contour is selected for processing. For example, if the size of the complete detection image is 1920×1200 pixels, and the burr edge area is found to be 500×300 pixels through target area localization, then only... A 500×300 pixel region was used for sharpness calculation. The extracted image region underwent sharpness calculation processing, employing a sharpness evaluation method based on edge gradient changes. The principle is that the sharper the image, the more obvious the grayscale changes at burr edges, thin film contours, etc., and the greater the difference between pixels. Conversely, the more blurred the image, the wider the edge transition range, and the smoother the grayscale changes. Therefore, the sharpness evaluation value is obtained by statistically analyzing the degree of grayscale change between adjacent pixels. For example, within a certain detection area, if two adjacent pixels are selected, with the first pixel having a grayscale value of 50 and the second pixel having a grayscale value of 150, the grayscale difference between them is 100. In another area, the first pixel has a grayscale value of 90 and the second pixel has a grayscale value of 110, resulting in a grayscale difference of 20. Since... The first group of grayscale changes is more obvious, therefore the corresponding area has higher clarity. In the actual calculation process, the grayscale changes between multiple pixels within the detection area are accumulated. For example, in the detection image corresponding to the new sampling position Z=100.05mm, a total of 5000 groups of grayscale changes between adjacent pixels are counted, and the total grayscale change value is 160000. This 160000 is then used as the basic clarity evaluation data for this detection image. To reduce the influence of local noise, the detection area can also be divided into multiple sub-regions for separate calculation. For example, a 500×300 pixel area can be divided into 5 sub-regions, and the clarity evaluation data calculated for each sub-region are 32000, 34000, 31000, 33000, and 30000 respectively. The data from these five regions are then processed to obtain a total sharpness evaluation value of 160,000. The maximum sharpness evaluation value among all sharpness evaluation values ​​during the current search process is taken as a reference value. The evaluation value of each sampling position is converted into data within a uniform range. For example, if the current maximum sharpness evaluation value is 200,000, and the new sampling position calculates to 160,000, then 160,000 and 200,000 are proportionally converted to obtain a corresponding evaluation result of 80%. The sharpness evaluation value corresponding to the new sampling position is then obtained. For example, if the current focus axis moves to Z=100.05mm, the original sharpness data obtained through image calculation is 160,000. After normalization, a sharpness evaluation value of 80 is obtained. When moving to Z=100...At the 10mm position, the calculated original data is 180,000, corresponding to a sharpness evaluation value of 90. This indicates that the image sharpness still improves after continuing to move in the current direction. By performing sharpness calculation processing on the detection images acquired at each new sampling position, the visual imaging effect under different focal lengths can be converted into quantitative evaluation data. This allows the autofocus process to adjust the search strategy based on objective image feedback. By performing local sharpness calculation on the burr detection area, the impact of minor burr edge changes on the evaluation results can be enhanced, improving the ability to locate the focal point for imaging small defects in lithium battery thin films. After obtaining the sharpness evaluation value corresponding to the new sampling location, the sampled dataset already saved during the current search process is read. The sampled dataset includes the sampling location, the corresponding detection image number, and the sharpness evaluation value. For example, before performing this step, the already saved sampled data includes sharpness evaluation value 110 for Z=99.90mm, sharpness evaluation value 140 for Z=99.95mm, and sharpness evaluation value 170 for Z=100.00mm. During the current search process, a new sampling location Z=100.05mm is added, corresponding to a sharpness evaluation value of 200. The new sampling location data is matched with the existing data. If the new sampling location does not exist in the existing data... If there is sampled data, a new data record is directly added. If the new sampling position already exists, the latest calculated sharpness evaluation value replaces the old value. For example, if the new Z=100.05mm position did not exist before, a record with Z=100.05mm and a sharpness evaluation value of 200 is added to the existing data, forming a new dataset where 99.90mm corresponds to 110, 99.95mm to 140, 100.00mm to 170, and 100.05mm to 200. If, due to motion and repeated sampling, an image at the Z=100.05mm position is acquired again, the original record's sharpness evaluation value will be 200, and the new calculation result will be used. If the value is 205, then the original data at 200 is deleted and updated to 205 to ensure that the database retains the latest detection results. The updated sampled data is reordered according to the spatial position of the focus axis to maintain the continuity of the sharpness change trend between different positions. For example, if the new sampling position is Z=100.10mm, then the updated data, sorted by position, will be: Z=99.90mm, evaluation value 110; Z=99.95mm, evaluation value 140; Z=100.00mm, evaluation value 170; Z=100.05mm, evaluation value 200; Z=100.10mm, evaluation value 190. The sharpness change trend in the current search process is re-established based on the updated data. The sharpness curve is used to determine whether the peak position has been reached. For example, when the new data causes the sharpness evaluation value to drop from 200 to 190, it means that the possible optimal focus area has been exceeded. At this time, the local search stage can be entered based on the continuous downward trend. If the new data continues to increase to 220, it means that the current direction is still close to the optimal focus and the search needs to continue. By dynamically merging the sharpness evaluation value corresponding to the new sampling position with the historical sampling data, the sharpness change trend throughout the entire search process can be grasped in real time, avoiding misjudgment caused by relying solely on the most recent sampling result. By saving the complete correspondence between sampling position and sharpness evaluation, the stability and accuracy of autofocus are improved.

[0031] In a preferred embodiment, candidate positions corresponding to sharpness peaks are determined based on the updated sharpness evaluation values. When a candidate position meets preset filtering conditions, a local search region corresponding to the candidate position is determined, including: S501. Obtain the sharpness evaluation value corresponding to each sampling position after the update, and sort the sharpness evaluation values ​​corresponding to each sampling position in descending order, and select the sampling position corresponding to the first sharpness evaluation value as the candidate position. S502. Determine whether the sharpness evaluation value corresponding to the candidate position meets the preset peak judgment condition. When a candidate position meets the preset peak value judgment condition, the local search area is determined based on the candidate position and the adjacent sampling positions corresponding to the candidate position. When a candidate position does not meet the preset peak judgment condition, the focus axis movement direction is re-determined based on the sharpness evaluation value corresponding to each sample position after the update, and a corresponding search control command is generated to re-judge the candidate position.

[0032] As described in steps S501 to S502 above, after the data update is completed, multiple sampling positions and their corresponding sharpness evaluation values ​​from the current search process are extracted. Therefore, the current sharpness dataset is read. The sharpness evaluation value data comes from the output result of the sharpness calculation processing of the detection image corresponding to each sampling position, including the sampling position coordinates, the detection image number, and the corresponding sharpness evaluation value. For example, in the current search process, multiple positions along the Z-axis have been sampled, resulting in data including a sharpness evaluation value of 60 for Z=99.80mm, a sharpness evaluation value of 85 for Z=99.85mm, and a sharpness evaluation value of 85 for Z=99.80mm. The sharpness evaluation values ​​are calculated as follows: Z=90mm corresponds to a sharpness evaluation value of 120; Z=99.95mm corresponds to a sharpness evaluation value of 160; Z=100.00mm corresponds to a sharpness evaluation value of 190; Z=100.05mm corresponds to a sharpness evaluation value of 220; Z=100.10mm corresponds to a sharpness evaluation value of 170; and Z=100.15mm corresponds to a sharpness evaluation value of 110. The sharpness evaluation values ​​for all sampling positions are read, and a sharpness evaluation dataset for the current search period is established. All sharpness evaluation values ​​are compared one by one, and the maximum value is selected as the first sorting position. Then, the search continues from the remaining evaluation values ​​to find the lowest sharpness evaluation value. The values ​​are sorted sequentially. For example, if the evaluation value set is 60, 85, 120, 160, 190, 220, 170, 110, the maximum value is 220. The corresponding value Z=100.05mm is placed first. After removing 220, the remaining evaluation values ​​are 60, 85, 120, 160, 190, 170, 110, with the maximum value being 190. Z=100.00mm is placed second. The comparison continues, resulting in 170, 160, 120, 110, 85, 60, which are then sorted sequentially. The final evaluation value sorting result is 220, 190, 170, 160, 120, 19 ... The values ​​0, 110, 85, and 60 correspond to the following position sorting results: 100.05mm, 100.00mm, 100.10mm, 99.95mm, 99.90mm, 100.15mm, 99.85mm, and 99.80mm. After sorting, the sampling position corresponding to the sharpness evaluation value at the top of the sort is selected as the candidate position. Since the top position represents the position with the highest image sharpness in the current sampled data, this position is taken as the potential best imaging focus position. For example, if the highest sharpness evaluation value in the sorting result is 220, the corresponding sampling position is Z=100.05mm, then Z=100.0.05mm is determined as the current candidate position, and its corresponding sharpness evaluation value of 220 is used as the candidate peak evaluation data. By uniformly sorting the sharpness evaluation values ​​corresponding to all updated sampling positions, errors caused by judging the focus position based on a single sampling result can be avoided. This allows the candidate position to be determined based on complete search data. By selecting the position corresponding to the highest current sharpness evaluation value as the candidate position, the possible best imaging area can be quickly locked, providing a target range for fine local search and improving autofocus efficiency. After determining the candidate positions, the sharpness evaluation value corresponding to the candidate position and the sharpness evaluation value corresponding to the adjacent sampling positions are read. A judgment is then made based on preset peak judgment conditions, including local maximum conditions, peak prominence conditions, and continuous trend confirmation conditions. These conditions can be obtained through the equipment calibration process by collecting multiple normal lithium-ion battery film samples, performing a complete focus search at different focal lengths, and recording the sharpness evaluation value corresponding to the true optimal focus position and the changes in evaluation values ​​at adjacent positions. Statistical analysis yields effective peak characteristics. For example, in 100 sets of normal test data, the sharpness evaluation value at the true focus position is typically more than 10% higher than that at adjacent sampling positions; therefore, a peak value is set. The key condition is that the sharpness evaluation value of the candidate position is at least 10% higher than the average evaluation value of adjacent positions. To avoid false peaks caused by single-point noise, a continuous trend confirmation condition is set, that is, there must be at least one sampling position before and after the candidate position, and the sharpness evaluation value must continuously increase before the candidate position and begin to decrease after the candidate position. To determine whether the candidate position is a local maximum, the evaluation value corresponding to the candidate position is compared with the evaluation values ​​of adjacent sampling positions. For example, if the evaluation value of the candidate position Z=100.05mm is 220, the evaluation value of its preceding sampling position Z=100.00mm is 190, and the evaluation value of its following sampling position Z=100.10mm is 170, then 220 is higher than both 190 and 170, satisfying the local maximum condition. The next step is to determine... The prominence of peak values ​​is assessed by, for example, calculating the difference between the candidate position's evaluation value of 220 and the average of the evaluation values ​​of two adjacent positions. The evaluation values ​​of the two adjacent positions are 190 and 170, with an average of 180. The candidate position's evaluation value of 220 is 40 higher than 180, which is greater than the preset prominence threshold of 18. Therefore, the peak prominence condition is met. The trend of sharpness change is also assessed. For example, if the evaluation value increases from 120 to 160 and then to 190 before the candidate position, it indicates a continuous increase in sharpness as the candidate position moves. After the candidate position, the value decreases from 220 to 170, indicating a decrease in sharpness beyond the candidate position. Therefore, the trend confirmation condition is met. When all these conditions are met, the candidate position is considered to correspond to the true sharpness peak area. If any... If a condition is not met, the current candidate position is considered to be a false peak and the search needs to continue. For example, if the evaluation value of the candidate position is 220, but the evaluation values ​​of the positions before and after it are 218 and 215 respectively, with only a slight difference, it means that the peak is not obvious and may be affected by noise. The peak prominence condition is not met and the search process needs to continue. By setting peak judgment conditions to perform secondary verification of the candidate position, false high evaluation values ​​caused by local reflection, material texture or image noise during the autofocus process can be avoided, which may lead to erroneous stopping. This improves the accuracy of the best focus position judgment. By combining local peak characteristics and sharpness change trends for comprehensive judgment, it can adapt to the industrial inspection environment where there are complex textures and minor defects on the surface of lithium battery films. Once a candidate position meets the peak detection criteria, the spatial coordinates of the focus axis corresponding to the candidate position and the coordinates of its adjacent sampling positions are read. The local search area is determined based on these positions. The local search area is used to limit the fine-grained movement range, concentrating the search near the location that may contain the true optimal focus. The nearest effective sampling positions on both sides of the candidate position are obtained, and the spatial range between these two sampling positions is used as the initial local search area. For example, if the current candidate position is Z=100.05mm, the previous sampling position is Z=100.00mm, and the next sampling position is Z=100.10mm, then the initial local search area is determined to be the range between Z=100.00mm and Z=100.10mm. To improve peak positioning accuracy, an extension range can be set based on the interval between the candidate position and adjacent positions. For example, if the current adjacent sampling interval is 50μm, then the range is extended forward and backward by 50μm from the candidate position of 100.05mm, forming a local search area from Z=100.00mm to Z=100.10mm. If the adjacent sampling interval is large, such as 10... If the step size is 0 μm, the fine search step size can be further reduced, dividing the region into multiple fine movement positions. For example, within the local search region Z = 100.00 mm to 100.10 mm, setting a fine movement interval of 10 μm will generate positions of 100.00 mm, 100.01 mm, 100.02 mm, 100.03 mm, 100.04 mm, 100.05 mm, 100.06 mm, 100.07 mm, 100.08 mm, 100.09 mm, and 100.10 mm. Eleven fine-position movement allows the search to be precisely located near the candidate peak without having to retrace the entire focus range. By determining the local search area based on the candidate position and its adjacent sampling positions, the autofocus process can be transformed from a coarse-range search to a fine-range search, improving focus positioning accuracy while ensuring search efficiency. Since the local search area is derived from actual sharpness variation data rather than a fixed set range, it can adapt to different lenses, different material thicknesses, and different equipment installation errors, thus improving the versatility of the autofocus method. When a candidate position does not meet the peak judgment condition, all currently collected sampling positions and their corresponding sharpness evaluation values ​​are retained, and the sharpness change trend is re-analyzed. The sharpness evaluation values ​​corresponding to each sampling position are rearranged based on the updated sampling data, and the sharpness changes in different directions are compared. For example, if the current highest evaluation value position is Z=100.05mm, but the evaluation values ​​before and after it are 218 and 215 respectively, the difference from the candidate value 220 is small, and the peak prominence condition is not met, the system determines that this position may belong to a plateau area or a noise fluctuation area. At this time, the complete data is reread, for example, Z=99.90mm evaluation value 120, Z=99.95mm evaluation value 150, Z=100.00mm evaluation value 180, Z=100.05mm evaluation value 220, Z=100.10mm evaluation value 218, Z=100.15mm evaluation value 240. It is found that the sharpness still improves after continuing to move in the positive direction, therefore the target movement is redefined. The direction of movement is positive. The search mode is determined based on the new change in sharpness. For example, if the sharpness at the new location increases from 220 to 240, the change is 20, indicating that the peak area has not yet been reached. In this case, the fast search mode is maintained. If the change decreases to 5, the fine search mode is switched. New search control commands are generated based on the redefined direction of movement and search mode. For example, a fast search command is generated to move 50μm in the positive direction. The focus axis is then controlled to continue moving to the new sampling position. The image acquisition, sharpness calculation, and candidate position judgment process continues until the peak judgment condition is met. By re-executing the search direction judgment when the candidate position does not meet the peak judgment condition, the autofocus algorithm can be prevented from stopping prematurely due to abnormal peaks, thus improving the anti-interference capability in complex industrial environments. By continuously adjusting the search strategy using existing sampling data, the autofocus process has dynamic correction capabilities, which can effectively adapt to the sharpness curve fluctuations caused by surface reflection, contamination, and texture changes of lithium battery films.

[0033] In a preferred embodiment, the focus axis is controlled to make fine movements within a local search area, and detection images corresponding to multiple fine movement positions within the local search area are acquired. A sharpness evaluation value is acquired for the detection image at each fine movement position, including: S601. Determine multiple fine movement positions of the focus axis within the local search area based on the local search area; S602, control the focusing axis to move sequentially to each fine movement position, and acquire the detection image corresponding to the lithium battery film burr detection area after the focusing axis moves to the corresponding fine movement position; S603. Perform sharpness calculation processing on the detection image corresponding to each fine movement position to obtain the sharpness evaluation value corresponding to the detection image at each fine movement position.

[0034] As described in steps S601 to S603 above, after determining that the candidate position meets the peak judgment condition, the spatial coordinates corresponding to the candidate position and the spatial range corresponding to the adjacent sampling positions on both sides of the candidate position are obtained. This range is used as the local search area. For example, after the aforementioned large-step search, the candidate position is determined to be Z=100.05mm, the previous sampling position of the candidate position is Z=100.00mm, and the next sampling position is Z=100.10mm. Then, the range between Z=100.00mm and Z=100.10mm is determined as the local search area. The local search area is determined according to the positioning accuracy of the current autofocus device, the lens depth of field range, and the burr detection focusing accuracy requirements. During the equipment debugging phase, the focus axis is controlled to acquire images of the lithium battery film edge at different moving distances. The repeatability error of the optimal focal position under different moving distances is compared. When the moving step size is 20μm, the repeatability error is 15μm; when the moving step size is 10μm, the repeatability error decreases to 5μm; and when the moving step size is 5μm, the repeatability error decreases to 2μm, but the number of samplings increases. Therefore, based on the detection accuracy and equipment cycle time requirements, the local search step size is set to the range of 5μm to 20μm. For example, 10μm can be selected as the fine moving interval based on the actual equipment accuracy. Based on the determined local search range and fine moving interval, the local area is then... Discretely divide the region to generate multiple fine-grained movement positions. For example, if the local search area ranges from Z=100.00mm to Z=100.10mm, and the fine-grained movement interval is set to 10μm (0.01mm), then starting from the initial position of the local search area, a movement position is set every 0.01mm, resulting in Z=100.00mm, Z=100.01mm, Z=100.02mm, Z=100.03mm, Z=100.04mm, Z=100.05mm, Z=100.06mm, Z=100.07mm, Z=100.08mm, Z=100.09mm, and Z=100.10mm. There are a total of 11 fine-tuning positions. To improve the search density near the peak, non-uniform fine-tuning positions can be set according to the sharpness evaluation value corresponding to the candidate position. For example, when the candidate position Z=100.05mm corresponds to an evaluation value of 220, while the adjacent positions Z=100.04mm and Z=100.06mm correspond to evaluation values ​​of 215 and 218 respectively, it indicates that the change near the candidate position is relatively slow, so a 10μm interval is maintained. If the evaluation values ​​of the adjacent positions are 180 and 150 respectively, it indicates that the sharpness change is significant, so the interval is further reduced near the candidate position, for example, a 5μm interval is set at Z=100.045mm, 100.050mm, and 100.06mm.By adding sampling points at the 0.55mm position, the fine-grained movement position is dynamically determined based on actual sharpness variation characteristics. This ensures that the potential optimal focus position is covered within the local search area, while avoiding invalid sampling. By determining multiple fine-grained movement positions based on the local search area and the device's focusing accuracy, the search process can be concentrated near candidate peaks for high-precision positioning. Compared to full-range scanning, this reduces the number of samples and improves autofocus speed. By adjusting the fine-grained sampling density according to actual sharpness variations, the positioning accuracy near peaks can be improved, reducing the problem of missing optimal focus positions due to excessively large sampling intervals. The system reads a list of fine-grained movement positions and generates motion control commands based on the spatial distance between the current and target positions. The motion control process is executed by a motion controller. The motion controller calculates the required movement distance based on the current position data fed back from the focus axis encoder and controls the drive motor to complete the movement. For example, if the current focus axis position is Z=100.00mm, and the fine-grained movement position list includes 100.00mm, 100.01mm, 100.02mm, 100.03mm, 100.04mm, and 100.05mm, then the system maintains the current position Z=100.00mm for image acquisition, generates a control command to move to Z=100.01mm, and controls the motor to move in the positive direction. The motion controller moves 0.01mm. When the encoder feedback position reaches Z=100.01mm, the motion controller continues to determine the stable position. For example, if the position feedback value is within the range of Z=100.01mm±1μm for 5 consecutive reads, the focusing axis is considered stable, and the industrial camera is triggered to acquire images. During image acquisition at each fine movement position, the exposure parameters, light source parameters, and image acquisition area of ​​the industrial camera are kept consistent to ensure that the images acquired at different positions only differ in focal length and are not affected by changes in imaging parameters. For example, if the exposure time is set to 500μs, the light source brightness to 80%, and the camera gain to 1.2 times during the autofocus initialization phase, then all fine movement positions will use the same parameters. The parameters are collected, and the image acquisition process includes the industrial camera receiving the acquisition trigger signal sent by the motion controller, exposing the edge area of ​​the lithium battery film within the current field of view, converting the optical image into digital image data, and sending it to the industrial control computer for storage. To ensure consistency of the detection area, based on the determined target detection area coordinates, the same area is extracted from each complete image as the burr detection image. For example, if the industrial camera acquires images with a resolution of 2048×1536 pixels, and the target burr area is located at image coordinates X=300 to 700 and Y=400 to 900, then after each fine movement position is acquired, this 400×500 pixel area is extracted as the detection image. For example, in the local search area Z... Eleven fine-tuning positions are set within the range of Z=100.00mm to Z=100.10mm. The focus axis is sequentially moved to each position, and eleven detection images are acquired for each position. These are the images corresponding to Z=100.00mm (Image 1), Z=100.01mm (Image 2), ..., Z=100.10mm (Image 11). By controlling the focus axis to move to multiple fine-tuning positions sequentially while maintaining consistent image acquisition parameters, image data corresponding to continuous focal length changes within the local search area can be obtained, improving the positioning resolution of the optimal focus position. Acquiring images after position stabilization detection can reduce the impact of motion jitter and mechanical errors on the sharpness evaluation results, thereby improving the reliability of the autofocus results. The detection image data corresponding to each precise movement position is read. This image data includes pixel grayscale information, edge texture information, and structural feature information within the target detection area. For example, if a 500×500 pixel detection area image is acquired at Z=100.00mm, this image contains 250,000 pixels, each corresponding to a grayscale value in the range of 0 to 255. Effective region extraction processing is performed on the detection image, retaining only the area containing the edge burr features of the lithium battery film to reduce the influence of the background area. For example, if the complete detection area is 500×500 pixels, and the burr edges are concentrated in the middle 200×400 pixel range, this area is extracted as the sharpness calculation area. Then, based on the image... The sharpness evaluation value is calculated based on the degree of edge variation within the region. When the image is in optimal focus, the fuzzy edges are sharper, and the grayscale changes between adjacent pixels are more pronounced. When the image is out of focus, the edges diffuse, and the grayscale changes between adjacent pixels decrease. The grayscale values ​​of adjacent pixels are read; for example, if two adjacent pixels at one edge have grayscale values ​​of 40 and 180 respectively, the grayscale difference is 140. At another edge, two adjacent pixels have grayscale values ​​of 90 and 120 respectively, resulting in a grayscale difference of 30. Since the first set of changes is more pronounced, the corresponding sharpness is higher. The grayscale changes of all valid pixel pairs within the detection region are accumulated to obtain the sharpness evaluation data corresponding to that location. For example, the image at Z=100.00mm is statistically analyzed to obtain the... With a cumulative effective pixel grayscale change value of 150,000, a cumulative value of 210,000 for the image at Z=100.05mm, and a cumulative value of 170,000 for the image at Z=100.10mm, it indicates that the image at Z=100.05mm has the richest edge information and the highest clarity. To reduce the impact of local noise, the detection area can be divided into multiple sub-regions, and the clarity evaluation value can be calculated separately for each sub-region. For example, a 200×400 pixel detection area can be divided into four 100×200 pixel areas, and the clarity evaluation values ​​for these areas can be calculated as 52,000, 53,000, 51,000, and 54,000 respectively. The total evaluation value of 210,000 is then obtained by summing the evaluation values ​​of the four areas. By binding the sharpness evaluation result corresponding to each fine-grained movement position with its spatial location, fine-grained search data is formed. For example, the corresponding relationships are: Z=100.00mm, sharpness evaluation value 150; Z=100.01mm, sharpness evaluation value 165; Z=100.02mm, sharpness evaluation value 180; Z=100.03mm, sharpness evaluation value 195; Z=100.04mm, sharpness evaluation value 210; Z=100.05mm, sharpness evaluation value 230; Z=100.06mm, sharpness evaluation value 220; Z=100.07mm, sharpness evaluation value 190. Therefore, the position with the highest sharpness within the local search area can be determined as Z=100.By evaluating the sharpness of the detection images corresponding to multiple finely moving positions within a local search area (0.05mm), the focus positioning accuracy can be improved, enabling the optimal imaging position to be accurately identified within a small spatial range. Furthermore, by employing a sharpness evaluation method targeting the edge burr characteristics of lithium-ion battery films, the impact of edge structural changes such as small burrs and sharp points on the evaluation results can be enhanced, improving the consistency and stability of imaging quality before burr detection.

[0035] In a preferred embodiment, the fine movement position is verified based on the sharpness evaluation value corresponding to the detection image at each fine movement position and the sharpness evaluation value corresponding to the detection images acquired consecutively after the candidate position is determined. Based on the verification result, the optimal imaging focus position is determined, and the focusing axis is controlled to move to the optimal imaging focus position to complete the automatic focusing process in the lithium battery thin film burr detection process, including: S701. Sort the sharpness evaluation values ​​corresponding to the detected images at each fine movement position in descending order, and take the sharpness evaluation value at the top as the target sharpness evaluation value. S702. Obtain the sharpness evaluation value corresponding to each detection image acquired consecutively after determining the candidate position, and compare it with the target sharpness evaluation value. When the target sharpness evaluation value is higher than the sharpness evaluation value of each detection image acquired consecutively after the candidate position is determined, the candidate position is determined to meet the focus confirmation condition, and the fine movement position corresponding to the target sharpness evaluation value is determined as the optimal imaging focus position. The focus axis is controlled to move to the optimal imaging focus position to complete the automatic focusing in the lithium battery thin film burr detection process. When the target sharpness evaluation value is lower than the sharpness evaluation value of each detection image acquired consecutively after the candidate position is determined, the fine movement position corresponding to the target sharpness evaluation value does not meet the focus confirmation condition, and the focus search position is re-determined based on the sharpness evaluation values ​​corresponding to multiple movement positions within the local search area.

[0036] As described in steps S701 to S702 above, the detected image corresponding to each fine movement position and the corresponding sharpness evaluation value are read. The sharpness evaluation value is bound and stored with the fine movement position to form fine search evaluation data. The fine search evaluation data includes focus axis position data, corresponding detected image number, and sharpness evaluation value. For example, after setting 11 fine movement positions within the local search area Z=100.00mm to Z=100.10mm, the sharpness evaluation value is calculated as follows: Z=100.00mm corresponds to a sharpness evaluation value of 150, Z=100.01mm corresponds to a sharpness evaluation value of 165, Z=100.02mm corresponds to a sharpness evaluation value of 180, and Z=100.10mm corresponds to a sharpness evaluation value of 180. The sharpness evaluation values ​​are calculated as follows: Z=0.03mm corresponds to a sharpness evaluation value of 205; Z=100.04mm corresponds to a sharpness evaluation value of 225; Z=100.05mm corresponds to a sharpness evaluation value of 240; Z=100.06mm corresponds to a sharpness evaluation value of 230; Z=100.07mm corresponds to a sharpness evaluation value of 210; Z=100.08mm corresponds to a sharpness evaluation value of 185; Z=100.09mm corresponds to a sharpness evaluation value of 160; and Z=100.10mm corresponds to a sharpness evaluation value of 145. The sharpness evaluation values ​​corresponding to all fine movement positions are read and compared and sorted according to their numerical values. The first sharpness evaluation value of 150 is used as the initial comparison value, and then the values ​​corresponding to other positions are read sequentially. When the value is read, if 165 is greater than 150, then 165 is moved to the front. The process continues, reading 180, 205, 225, and 240, moving the larger values ​​to the front of the sort. This forms a data sequence arranged from high to low: 240, 230, 225, 210, 205, 185, 180, 165, 160, 150, 145. After sorting, the sharpness evaluation value 240, which is the first value in the sorted result, is taken and designated as the target sharpness evaluation value. Simultaneously, the spatial position Z=100.05mm corresponding to this target sharpness evaluation value is read and used as the optimal candidate focal position for the current fine-grained search stage. It should be noted that the target sharpness... The sharpness evaluation value is not directly used as the final focus output, but rather as a benchmark value for judging peak stability. It is used to determine whether the position is only a local false peak or a true focus peak. For example, when an abnormally bright edge occurs at the Z=100.05mm position due to reflection from the thin film surface, this position may obtain a high evaluation value. However, the evaluation value may continue to rise during continuous movement. At this time, further verification is required. By sorting the sharpness evaluation values ​​corresponding to all fine movement positions in the local search area, the imaging position with the highest current sharpness can be quickly located, avoiding the focus mispositioning problem caused by a single judgment. It can be combined with the search process to determine whether the peak is stable, thereby improving the accuracy of autofocus results. After determining that a candidate position meets the peak judgment condition, the search does not stop immediately. Instead, the focus axis continues to move a preset distance along the current search direction, continuously acquiring detection images during the movement. These continuously acquired detection images originate from multiple sampling positions following the candidate position. For example, after determining the candidate position as Z=100.05mm, the focus axis continues to move to three positions: Z=100.06mm, Z=100.07mm, and Z=100.08mm, acquiring corresponding detection images for each. After acquiring each detection image, it is processed according to a sharpness calculation method to obtain the peak value. Based on the sharpness evaluation values, for example, if the candidate position Z=100.05mm corresponds to a target sharpness evaluation value of 240, and further acquisition yields Z=100.06mm (230), Z=100.07mm (210), and Z=100.08mm (190), a continuous sharpness evaluation sequence is formed after the candidate position. Comparing 240 and 230, since 240 is greater than 230, it indicates that the sharpness decreases after moving to Z=100.06mm. Comparing 240 and 210, since 240 is greater than 210, it indicates that the sharpness continues to decrease after further movement. Comparing 240 and 190, since 240 is greater than 190, it indicates that no higher evaluation value appeared after the candidate position. Through continuous comparison, it can be determined whether the candidate position is located near the peak of the sharpness change curve. To avoid the influence of random noise on a single comparison, the number of consecutive verifications can be set, for example, setting 3 to 5 consecutive sampling positions as the peak observation interval. When the target sharpness evaluation value is continuously higher than the evaluation values ​​corresponding to the subsequent 3 sampling positions, the current peak is considered to be stable. When the evaluation value of any subsequent sampling position is higher than the target sharpness evaluation value, the current peak is considered to be possibly not the final peak. If the target sharpness evaluation value is 240, but the evaluation value at a subsequent position Z=100.07mm reaches 250, it indicates that the sharpness is still improving. The current candidate position should be abandoned and the search should continue. By adding continuous sampling and sharpness comparison after the candidate peak position, false peaks caused by reflection on the lithium battery film surface, local burr protrusions, and material texture changes can be avoided, improving the reliability of the best focus judgment. It is not necessary to rescan the entire focal length range, but only to verify a small area after the candidate peak, thus reducing autofocus time while ensuring accuracy. When the sharpness evaluation values ​​of the acquired continuously detected images are all lower than the target sharpness evaluation value, it indicates that the image sharpness has not continued to improve after moving from the target position along the current direction. The target position is in the highest region of the sharpness evaluation curve, thus meeting the focus confirmation condition. For example, if the target sharpness evaluation value is determined to be 240, the corresponding fine movement position is Z=100.05mm. Continuing to acquire images at positions Z=100.06mm, Z=100.07mm, and Z=100.08mm, the corresponding evaluation values ​​are 230, 210, and 190, respectively. Since 240 is higher than 230, 210, and 190, Z=100.05mm is determined as the stable peak position. The spatial coordinates of the focus axis corresponding to this target sharpness evaluation value are read, and a focus positioning control command is generated. For example, if the current focus axis position is Z=100.08mm, and the most... If the optimal imaging focus position is Z=100.05mm, the motion controller calculates that it needs to move 0.03mm in the negative direction and controls the motor to drive the focusing axis to move. When the encoder feedback position reaches Z=100.05mm and the position error is controlled within the allowable range of the equipment, such as ±2μm, it is considered that the focusing axis has reached the optimal imaging focus position. The industrial camera maintains the current focus position to acquire the lithium battery film burr detection image and inputs the image into the subsequent burr recognition algorithm to achieve high-quality edge detection. By confirming the optimal focus position based on the subsequent downward trend of the peak value, it can avoid erroneous stops caused by the maximum value of a single point and improve the stability of autofocus. By controlling the focusing axis to return to the finally determined optimal imaging focus position, the industrial camera can acquire the burr detection image with the highest edge sharpness, improving the recognition ability of small burrs, sharp points and defect edges. When a higher sharpness evaluation value is found after a candidate position during the comparison process, it indicates that although the current target position has a high evaluation value, it is still in the sharpness improvement stage and does not meet the focus confirmation condition. For example, if the evaluation value of the position Z=100.05mm is determined to be 240, but further acquisition yields an evaluation value of 245 for Z=100.06mm and 255 for Z=100.07mm, it means that the image still becomes sharper after moving in the current direction, and Z=100.05mm is not the optimal focus position. In this case, the position corresponding to the current target sharpness evaluation value is canceled, and the sharpness evaluation values ​​corresponding to all fine movement positions within the local search area are reread. For example, data from 11 positions within the range of Z=100.00mm to Z=100.10mm are reread, the evaluation values ​​corresponding to the newly sampled positions are added to the existing data, and the data is re-sorted to determine the new position with the highest evaluation value. If the new highest evaluation value position is Z=100.07mm, then Z=100.07mm is taken as the new candidate position, and the continuous sampling and verification process after the candidate position continues. By cyclically executing the closed-loop process of candidate position determination, peak verification, and position correction, until a position that meets the focus confirmation condition is obtained or the preset number of searches is reached, for example, the maximum number of searches is set to 5. When a stable peak cannot be determined in 5 consecutive searches, a low confidence state is output, prompting the device to perform manual inspection or re-initialize the search. By setting a re-search mechanism after failing to meet the focus confirmation condition, the autofocus process can adapt to complex situations such as double-peak, multi-peak, and plateau-type sharpness curves, avoiding the algorithm from staying at a local peak position. By updating the search position through a closed loop, it can continuously approach the true best focus, improving the adaptability of the lithium battery thin film burr detection equipment under different materials and working conditions.

[0037] Please see the appendix Figure 2 As shown, the present invention also provides a closed-loop autofocus system for detecting burrs in lithium-ion battery films, used in the aforementioned closed-loop autofocus method for detecting burrs in lithium-ion battery films, comprising: The initial imaging position module is used to acquire the image sampling position corresponding to the lithium battery thin film burr detection area and control the focus axis to move to the initial imaging position. The sharpness evaluation module is used to acquire detection images of the focus axis at the initial imaging position and at multiple sampling positions offset from the initial imaging position, and to acquire the sharpness evaluation value corresponding to each detection image. The search control instruction module determines the current focus direction based on the sharpness evaluation value corresponding to each detected image and generates a search control instruction corresponding to the current focus direction. The sharpness evaluation update module is used to control the focus axis to move according to the search control command, continuously acquire detection images during the movement of the focus axis, and update the sharpness evaluation value corresponding to the sampled position according to the sharpness evaluation value corresponding to the detection image. The local search region module is used to determine the candidate position corresponding to the sharpness peak based on the updated sharpness evaluation value. When the candidate position meets the preset filtering conditions, the local search region corresponding to the candidate position is determined. The fine movement module is used to control the focus axis to move finely within the local search area, and to acquire the detection images corresponding to multiple fine movement positions within the local search area, and to acquire the sharpness evaluation value corresponding to the detection image at each fine movement position. The imaging focus module is used to verify the fine movement position based on the sharpness evaluation value corresponding to the detection image at each fine movement position and the sharpness evaluation value corresponding to the detection images acquired continuously after the candidate position is determined. Based on the verification result, the optimal imaging focus position is determined, and the focusing axis is controlled to move to the optimal imaging focus position to complete the automatic focusing in the lithium battery thin film burr detection process.

[0038] The aforementioned initial imaging position module is used to establish the initial spatial reference position for the autofocus process. This module acquires the position data of the lithium battery film in the burr detection station, including the position feedback information of the conveyor mechanism, encoder feedback data, and detection area coordinate information. Based on the current movement position of the lithium battery film, it determines the target area to be inspected for burrs. Combining the spatial relationship between the industrial camera installation position, the lens optical axis direction, and the focus axis movement direction, it calculates the image sampling position corresponding to the industrial camera and generates an initial movement control command for the focus axis based on this sampling position, causing the focus axis to move to the initial imaging position. For example, after the lithium battery film passes through the inspection station... When the film is in position, the encoder on the conveyor shaft reports that the current position of the film is 500mm away from the reference point. The system determines the edge area of ​​the film as 50mm after the current conveying position based on the preset detection area length. Combined with the installation offset parameters between the camera and the focusing shaft, the focusing shaft is moved to the corresponding height position so that the camera's field of view covers the target detection area. This ensures that the automatic focusing process is always aimed at the correct detection area, avoids the shift of the acquisition area due to changes in the material position, improves the effectiveness of the sharpness evaluation, realizes automatic positioning of the detection area and automatic establishment of the initial position of the focus search, reduces manual adjustment, and improves the rapid recovery capability after equipment changeover and maintenance. The sharpness evaluation module is used to acquire lithium battery thin film burr detection images at different focal length positions and convert the image sharpness into comparable evaluation data. This module controls the focus axis to move to the initial imaging position and multiple sampling positions offset from the initial position. After stabilizing at each position, the industrial camera is triggered to acquire the detection image and the sharpness calculation is performed on the detection image. Edge texture information within the burr detection area can be extracted. The sharpness evaluation value is obtained by statistically analyzing the degree of grayscale change between adjacent pixels, the degree of edge gradient change, or high-frequency detail information. For example, in the detection image acquired at a certain sampling position, the cumulative grayscale change value of adjacent pixels in the burr edge area is 180,000, while the corresponding cumulative value at another sampling position is 230,000. The latter image has more obvious edge features and a higher sharpness evaluation value. By establishing the correspondence between the focus axis position, the detection image, and the sharpness evaluation value, the sharpness of manually observed images is transformed into quantifiable data judgment, improving the objectivity and accuracy of the autofocus process. The search control instruction module is used to determine the subsequent focus search direction based on the sharpness evaluation results obtained in the initial sampling stage, and generate search instructions to control the movement of the focus axis. It reads the sharpness evaluation values ​​corresponding to different sampling positions and arranges them according to the direction of focus axis movement to form a sharpness change sequence. The optimal search direction is determined by judging the direction of sharpness evaluation value improvement. For example, if the initial sampling yields a sharpness evaluation value of 120 in the negative direction, 150 in the current position, and 180 in the positive direction, it means that the sharpness gradually improves when moving in the positive direction. The system determines the positive direction as the current search direction. If the evaluation value in the negative direction is higher, the search is adjusted to the negative direction. The search mode is determined according to the magnitude of sharpness change. When the sharpness change between adjacent positions is large, a larger movement step size is used to quickly approach the peak area. When the change is small, a smaller movement step size is used for precise search. This avoids the problems of low search efficiency or missing the best focus caused by fixed direction and fixed step size search, so that the autofocus process can be dynamically adjusted according to the actual image feedback. The sharpness evaluation update module is used to establish dynamically updated sharpness evaluation data during the continuous movement of the focus axis. According to the search control command, it controls the focus axis to move along the current search direction to a new sampling position. After each movement, a new detection image is acquired and the corresponding sharpness evaluation value is calculated. Then, the new position data and evaluation value are added to the existing sampling data to update the sharpness curve in the current search process. For example, the initial sampling obtains an evaluation value of 150 at the position of Z=100.00mm and an evaluation value of 220 at the position of Z=100.05mm. After continuing to search to the position of Z=100.10mm, an evaluation value of 240 is obtained. The system adds the new data to the original data list to form an evaluation curve corresponding to the continuous focal length change. Through continuous updates, the sharpness change trend in the current search area can be grasped in real time, and complete data support is provided for peak position judgment. This forms a closed-loop feedback control, so that the focusing process does not depend on a preset fixed path and can dynamically adjust the search process according to the actual imaging results, improving the adaptability in complex industrial environments. The local search region module is used to determine the location area where the best focus may exist based on the updated sharpness evaluation data and to establish a high-precision search range. This module selects the location corresponding to the highest sharpness evaluation value from all current sampling locations as a candidate location, and then determines whether the candidate location meets the peak screening conditions. For example, it determines whether the evaluation value corresponding to the candidate location is higher than the evaluation value corresponding to the adjacent sampling location, and whether the upward and downward trend of the evaluation value forms a stable peak. When the evaluation value of the candidate location is 240, and the evaluation values ​​of the two adjacent locations are 220 and 210 respectively, it indicates that the location may be in the sharpness peak area. Then, the local search region is determined based on the candidate location and the range of adjacent sampling locations. If the evaluation value of the candidate location is only slightly higher than the adjacent locations, such as 240, 238 and 239, it is considered that the peak is not obvious and the search process needs to be re-executed. The search range is further narrowed through the coarse search results, so that fine positioning is concentrated in the effective area, avoiding the time increase caused by full-stroke high-precision scanning, and reducing the problem of erroneous stop caused by local noise peaks. The fine-motion module is used to perform high-precision focus positioning within a local search area. This module determines multiple fine-motion positions based on the range of the local search area and the positioning accuracy of the device, and controls the focus axis to move point by point to acquire detection images. For example, if the local search area is 100.00mm to 100.10mm and the fine-motion interval of the focus axis is set to 0.01mm, then 11 fine-motion positions are generated, from 100.00mm to 100.10mm. The system acquires the corresponding image at each position in sequence and calculates the corresponding sharpness evaluation value. By increasing the sampling density near the candidate peak, a more accurate sharpness peak position can be obtained. Combining large-area fast search and local high-precision search improves the balance between autofocus speed and positioning accuracy, meeting the requirements for imaging quality of small edge defects in lithium battery thin film burr detection. The imaging focus module is used to finalize the sharpness evaluation results corresponding to the fine-grained movement positions and control the focus axis to move to the optimal imaging focus position. This module sorts the sharpness evaluation values ​​corresponding to the fine-grained movement positions, determines the position corresponding to the highest evaluation value as the target focus position, obtains the sharpness evaluation values ​​corresponding to the detection images acquired during continuous movement after the candidate position, and compares them with the target sharpness evaluation value. When the target sharpness evaluation value is consistently higher than the evaluation value of subsequent sampling positions, it indicates that the position is a stable peak position, and it is determined as the optimal imaging focus. For example, a fine search yields Z=100.05m. The highest evaluation value is 240. After moving to positions of 100.06mm, 100.07mm, and 100.08mm, the evaluation values ​​drop to 230, 215, and 190 respectively. Therefore, Z=100.05mm is determined to be the optimal focus position, and the focus axis is controlled to return to this position to complete focusing. If the evaluation value continues to rise, the search position is readjusted. The peak confirmation mechanism avoids the influence of false peaks and improves the reliability of focus determination. It can accurately find the true optimal focus under complex conditions such as reflection, material texture, and local burr protrusions, so that the subsequent burr detection image has higher edge clarity and detection stability. Through a closed-loop processing flow of initial positioning, clear quantification, direction search, data update, peak filtering, local fine search, and focus verification, the lithium battery thin film burr detection equipment achieves automated and high-precision focusing. Compared with manual focusing, it can reduce the dependence on equipment debugging and improve the imaging consistency and burr detection reliability of different equipment, different materials, and different production conditions.

[0039] And, a closed-loop autofocus terminal for detecting burrs in lithium battery thin films, comprising: One or more processors; A storage device on which one or more programs are stored; When one or more programs are executed by one or more processors, the one or more processors implement a closed-loop autofocus method for detecting burrs in lithium-ion battery films.

[0040] The above description is merely a preferred embodiment of the present invention. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention. Structures, devices, and operating methods not specifically described or explained in this invention are implemented according to conventional methods in the art unless otherwise specified or limited.

Claims

1. A closed-loop automatic focusing method for detecting burrs in lithium battery thin films, characterized in that, include: Obtain the image sampling position corresponding to the burr detection area of ​​the lithium battery thin film, and control the focus axis to move to the initial imaging position; Acquire detection images of the focus axis at the initial imaging position and at multiple sampling positions offset from the initial imaging position, and obtain the sharpness evaluation value corresponding to each detection image; The current focus direction is determined based on the sharpness evaluation value corresponding to each detected image, and a search control command corresponding to the current focus direction is generated. The focus axis is moved according to the search control command. During the movement of the focus axis, the detection image is continuously acquired, and the sharpness evaluation value corresponding to the sampled position is updated according to the sharpness evaluation value corresponding to the detection image. Based on the updated sharpness evaluation value, the candidate position corresponding to the sharpness peak is determined. When the candidate position meets the preset filtering conditions, the local search area corresponding to the candidate position is determined. Control the focus axis to make fine movements within the local search area, and acquire the detection images corresponding to multiple fine movement positions within the local search area, and acquire the sharpness evaluation value corresponding to the detection image at each fine movement position; Based on the sharpness evaluation value corresponding to the detection image at each fine movement position and the sharpness evaluation value corresponding to the detection images acquired continuously after the candidate position is determined, the fine movement position is verified, and the optimal imaging focus position is determined according to the verification result. The focusing axis is then controlled to move to the optimal imaging focus position to complete the automatic focusing in the lithium battery thin film burr detection process.

2. The closed-loop autofocusing method for detecting burrs in lithium battery thin films according to claim 1, characterized in that, Acquire the image sampling position corresponding to the lithium battery thin film burr detection area, and control the focus axis to move to the initial imaging position, including: Acquire the current position data of the lithium battery film in the burr detection station, and determine the target detection area to be inspected for burrs based on the current position data; Obtain the installation position parameters between the industrial camera and the focusing axis, determine the corresponding image acquisition area based on the target detection area, and determine the image sampling position of the industrial camera based on the installation position parameters between the industrial camera and the focusing axis. The initial movement position corresponding to the focus axis is obtained based on the image sampling position, and the focus axis movement command is generated based on the initial movement position. The focus axis is moved to the initial position according to the focus axis movement command, so that the imaging area of ​​the industrial camera corresponds to the target detection area, and the initial imaging position is obtained.

3. The closed-loop autofocus method for detecting burrs in lithium battery thin films according to claim 1, characterized in that, Acquire detection images at the initial imaging position and at multiple sampling positions offset from the initial imaging position along the focus axis, and obtain a sharpness evaluation value for each detection image, including: The initial sampling reference for the focus axis is determined based on the initial imaging position, and multiple offset sampling positions are set along the movement direction of the focus axis according to the initial sampling reference. The focusing axis is controlled to move sequentially to the initial imaging position and each offset sampling position, and the detection image corresponding to the lithium battery thin film burr detection area is acquired after the focusing axis reaches the corresponding position; The image data corresponding to each detected image is obtained, and the sharpness is calculated based on the image data to obtain the sharpness evaluation value corresponding to each detected image.

4. The closed-loop autofocusing method for detecting burrs in lithium battery thin films according to claim 1, characterized in that, The current focus direction is determined based on the sharpness evaluation value corresponding to each detected image, and a search control command corresponding to the current focus direction is generated, including: The sharpness evaluation value corresponding to each detected image is used to obtain the sampling position and the sharpness evaluation value corresponding to each sampling position, and the sharpness evaluation values ​​are arranged according to the focus axis movement direction corresponding to the sampling position. The direction and magnitude of sharpness change between different sampling positions are determined based on the sharpness evaluation values ​​after arrangement, and the target movement direction of the focus axis is determined based on the direction of sharpness change. The search movement mode corresponding to the focus axis is determined based on the target's movement direction and the magnitude of the sharpness change, and search control commands are generated in conjunction with the target's movement direction.

5. The closed-loop autofocus method for detecting burrs in lithium battery thin films according to claim 1, characterized in that, The focus axis is moved according to the search control command. During the movement of the focus axis, detection images are continuously acquired, and the sharpness evaluation value corresponding to the sampled position is updated according to the sharpness evaluation value corresponding to the detection image, including: According to the search control command, the focus axis is controlled to move along the current focus direction to a new sampling position, and the detection image corresponding to the lithium battery film burr detection area is obtained after the focus axis reaches the new sampling position. The sharpness of the detected image corresponding to the new sampling position is calculated to obtain the sharpness evaluation value corresponding to the new sampling position; The new sampling location and its corresponding sharpness evaluation value are merged with the sharpness evaluation values ​​corresponding to the already sampled locations, and the sharpness evaluation value corresponding to each sampling location obtained in the current search process is updated.

6. The closed-loop autofocus method for detecting burrs in lithium battery thin films according to claim 1, characterized in that, Based on the updated sharpness evaluation value, candidate locations corresponding to sharpness peaks are determined. When a candidate location meets preset filtering conditions, the corresponding local search area is determined, including: Obtain the updated sharpness evaluation value for each sampling position, sort the sharpness evaluation values ​​for each sampling position in descending order, and select the sampling position corresponding to the first sharpness evaluation value as the candidate position. Determine whether the sharpness evaluation value corresponding to the candidate position meets the preset peak judgment condition; When a candidate position meets the preset peak value judgment condition, the local search area is determined based on the candidate position and the adjacent sampling positions corresponding to the candidate position. When a candidate position does not meet the preset peak judgment condition, the focus axis movement direction is re-determined based on the sharpness evaluation value corresponding to each sample position after the update, and a corresponding search control command is generated to re-judge the candidate position.

7. The closed-loop autofocus method for detecting burrs in lithium battery thin films according to claim 1, characterized in that, The focus axis is controlled to move finely within a local search area, and detection images corresponding to multiple fine movement positions within the local search area are acquired. A sharpness evaluation value is obtained for the detection image at each fine movement position, including: The focus axis is determined by the local search area, which contains multiple fine movement positions. Control the focusing axis to move sequentially to each fine movement position, and acquire the detection image corresponding to the lithium battery film burr detection area after the focusing axis moves to the corresponding fine movement position; The sharpness of the detected image corresponding to each fine movement position is calculated to obtain the sharpness evaluation value of the detected image at each fine movement position.

8. The closed-loop autofocus method for detecting burrs in lithium battery thin films according to claim 1, characterized in that, Based on the sharpness evaluation value corresponding to the detected image at each fine movement position and the sharpness evaluation value corresponding to the continuously acquired detected images after determining the candidate position, the fine movement position is verified, and the optimal imaging focus position is determined according to the verification result. The focusing axis is then controlled to move to the optimal imaging focus position to complete the automatic focusing process in the lithium battery thin film burr detection process, including: The sharpness evaluation values ​​corresponding to the detected images at each fine movement position are sorted in descending order, and the sharpness evaluation value at the top is taken as the target sharpness evaluation value. After determining the candidate location, obtain the sharpness evaluation value corresponding to each detection image acquired consecutively, and compare it with the target sharpness evaluation value; When the target sharpness evaluation value is higher than the sharpness evaluation value of each detection image acquired consecutively after the candidate position is determined, the candidate position is determined to meet the focus confirmation condition, and the fine movement position corresponding to the target sharpness evaluation value is determined as the optimal imaging focus position. The focus axis is controlled to move to the optimal imaging focus position to complete the automatic focusing in the lithium battery thin film burr detection process. When the target sharpness evaluation value is lower than the sharpness evaluation value of each detection image acquired consecutively after the candidate position is determined, the fine movement position corresponding to the target sharpness evaluation value does not meet the focus confirmation condition, and the focus search position is re-determined based on the sharpness evaluation values ​​corresponding to multiple movement positions within the local search area.

9. A closed-loop autofocus system for detecting burrs in lithium-ion battery films, applied to the closed-loop autofocus method for detecting burrs in lithium-ion battery films according to any one of claims 1 to 8, characterized in that, include: The initial imaging position module is used to acquire the image sampling position corresponding to the lithium battery thin film burr detection area and control the focus axis to move to the initial imaging position. The sharpness evaluation module is used to acquire detection images of the focus axis at the initial imaging position and at multiple sampling positions offset from the initial imaging position, and to acquire the sharpness evaluation value corresponding to each detection image. The search control instruction module determines the current focus direction based on the sharpness evaluation value corresponding to each detected image and generates a search control instruction corresponding to the current focus direction. The sharpness evaluation update module is used to control the focus axis to move according to the search control command, continuously acquire detection images during the movement of the focus axis, and update the sharpness evaluation value corresponding to the sampled position according to the sharpness evaluation value corresponding to the detection image. The local search region module is used to determine the candidate position corresponding to the sharpness peak based on the updated sharpness evaluation value. When the candidate position meets the preset filtering conditions, the local search region corresponding to the candidate position is determined. The fine movement module is used to control the focus axis to move finely within the local search area, and to acquire the detection images corresponding to multiple fine movement positions within the local search area, and to acquire the sharpness evaluation value corresponding to the detection image at each fine movement position. The imaging focus module is used to verify the fine movement position based on the sharpness evaluation value corresponding to the detection image at each fine movement position and the sharpness evaluation value corresponding to the detection images acquired continuously after the candidate position is determined. Based on the verification result, the optimal imaging focus position is determined, and the focusing axis is controlled to move to the optimal imaging focus position to complete the automatic focusing in the lithium battery thin film burr detection process.

10. A closed-loop autofocus terminal for detecting burrs in lithium battery thin films, characterized in that, include: One or more processors; A storage device on which one or more programs are stored; When one or more programs are executed by one or more processors, the one or more processors implement the closed-loop autofocus method for detecting burrs in lithium-ion battery films as described in any one of claims 1 to 8.