Visual on-line detection device for appearance defects of permanent magnet steel

CN122836066APending Publication Date: 2026-09-29ANHUI ASTROMAGNET CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611183524.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-05
Publication Date
2026-09-29

AI Technical Summary

Technical Problem

[0003]在现有的永磁磁钢视觉在线检测技术中,通常采用固定式相机配合传送带,或采用简单的多轴机械臂预设固定轨迹进行走走停停的单工位拍照,然而,永磁磁钢具有形状复杂多样(多面体、瓦片形、异形倒角)、表面常附有高反光金属镀层(如镀锌、镀镍)的物理特性,现有的动态视觉检测设备在实际工业高节拍运行过程中,暴露出以下显著的技术瓶颈:

Benefits of technology

1.本发明的永磁磁钢外观缺陷视觉在线检测装置,通过设置了获取相机实时工作距离与平行度偏差角构建的几何离焦倾向模型,以及获取物理偏移量与定位误差构建的视场对准偏差模型,解决了背景技术中动态扫描时因机构振动、导轨形变及机械公差导致的严重离焦与检测盲区问题,不仅从根本上避免了图像边缘因超出景深而发生的光学离焦模糊,还能动态预测并抵消视野偏移风险,确保永磁磁钢微小缺陷不漏检,大幅提升了动态视觉扫描的精度与可靠性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122836066A_ABST
    Figure CN122836066A_ABST
Patent Text Reader

Abstract

The present application belongs to the technical field of visual defect detection, and particularly relates to a visual on-line detection device for appearance defects of permanent magnet steel, which comprises a visual detection device, a multi-axis motion mechanism capable of sliding up and down and moving left and right on the visual detection device, a visual detection mechanism installed on the multi-axis motion mechanism, and a controller, wherein the visual detection mechanism comprises a camera and a light source; the controller is configured to perform the following operations: acquiring a real-time working distance of the camera and a dynamic parallelism deviation angle between a target surface of the camera and a workpiece surface, constructing a geometric defocus tendency model to output a geometric defocus tendency coefficient; acquiring a real-time physical offset between a swing axis and a center of a camera field of view and a repetitive positioning space error of the multi-axis motion mechanism, and constructing a field of view alignment deviation model to output a field of view alignment deviation coefficient; and the problems of serious defocus and detection blind area caused by mechanism vibration, guide rail deformation and mechanical tolerance during dynamic scanning in the background technology are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of visual defect detection technology, specifically an online visual detection device for appearance defects of permanent magnet steel. Background Technology

[0002] Permanent magnet steel (such as neodymium iron boron magnets) is a core basic component in high-end manufacturing fields such as new energy vehicles, wind power generation, and precision servo motors. Its surface appearance quality (such as chipping, cracks, coating peeling, scratches, and other defects) directly determines the magnetic circuit performance and corrosion resistance life of the final product.

[0003] In existing online visual inspection technologies for permanent magnet steel, fixed cameras are typically used in conjunction with conveyor belts, or simple multi-axis robotic arms are used to take photos at a single station by moving along a fixed trajectory. However, permanent magnet steel has complex and diverse shapes (polyhedrons, tile shapes, irregular chamfered edges) and its surface is often coated with highly reflective metallic coatings (such as zinc plating and nickel plating). Existing dynamic visual inspection equipment has revealed the following significant technical bottlenecks during actual high-speed industrial operation: First, during the dynamic scanning process where the camera slides up and down or moves left and right with the mechanism, the actual working distance of the camera and the parallelism of the target surface will shift dynamically in real time due to workpiece placement tolerance, slight vibration of the conveyor belt and deformation of the guide rail. Existing technology lacks a perception and compensation mechanism for this instantaneous geometric deviation, which can easily lead to severe optical defocusing and blurring of the image edges due to exceeding the depth of field, resulting in missed detection of minor defects.

[0004] Secondly, due to the mechanical assembly clearance and spatial repeatability error of the multi-axis motion mechanism, during high-speed continuous attitude change detection, there is often an asynchronous physical offset between the motion axis of the mechanism and the center of the camera's field of view. This transient offset, combined with macroscopic mechanical jitter, often causes the target defect area to be squeezed to the edge of the field of view, or even to leave the effective field of view, resulting in a detection blind zone.

[0005] Finally, the high reflectivity of the magnetic steel surface is extremely sensitive to the illumination angle. Existing light source control systems are often in an open-loop isolated state with the camera motion system. When the camera posture changes or the mechanism tilts slightly, the azimuth angle of the light source fails to achieve perfect synchronization, resulting in a sharp drop in illumination uniformity and the formation of high-intensity light spots (overexposure) or shadows (underexposure) in the center of the workpiece surface or in high-frequency defect areas, completely covering up the real defects on the surface.

[0006] Therefore, the present invention provides an online visual inspection device for appearance defects of permanent magnet steel. Summary of the Invention

[0007] In order to overcome the shortcomings of the prior art, at least one technical problem raised in the background art is solved.

[0008] The technical solution adopted by the present invention to solve its technical problem is: the permanent magnet steel appearance defect visual online detection device of the present invention includes a visual detection device, a multi-axis motion mechanism disposed on the visual detection device and capable of sliding up and down and moving left and right, a visual detection mechanism mounted on the multi-axis motion mechanism, and a controller. The visual detection mechanism includes a camera and a light source. The controller is used to perform the following operations: S11: Obtain the real-time working distance of the camera and the dynamic parallelism deviation angle between the camera target surface and the workpiece surface, and construct a geometric defocus tendency model to output the geometric defocus tendency coefficient. S12: Obtain the real-time physical offset between the swing axis and the camera's field of view center and the repeatability spatial error of the multi-axis motion mechanism, and construct a field of view alignment deviation model to output the field of view alignment deviation coefficient. S13: Obtain the incident azimuth angle error of the light source and the uniformity coefficient of the light source illuminance, construct a lighting quality attenuation model to output the lighting quality attenuation coefficient; S14: Obtain the depth-of-field boundary sharpness loss rate, highlight area ratio, and highlight area normalized center distance. Combine the geometric defocus tendency coefficient and illumination quality attenuation coefficient to construct a multi-domain coupled imaging fidelity model to output the overall imaging fidelity. S15: Based on the overall image fidelity, the field of view alignment deviation coefficient, and the current actual viewing angle of the camera, a camera angle optimization model is constructed to output the target camera viewing angle. Combined with the deviation between the camera's real-time working distance and the ideal focusing reference distance, as well as the real-time physical offset, it is converted into multi-degree-of-freedom control commands to drive the multi-axis motion mechanism to adjust its spatial position and attitude.

[0009] The beneficial effects of this invention are as follows: 1. The permanent magnet steel appearance defect visual online detection device of the present invention solves the serious defocus and detection blind zone problems caused by mechanism vibration, guide rail deformation and mechanical tolerance during dynamic scanning in the background technology by setting up a geometric defocus tendency model constructed by acquiring the real-time working distance of the camera and the parallelism deviation angle, and a field of view alignment deviation model constructed by acquiring the physical offset and positioning error. It not only fundamentally avoids the optical defocus blurring caused by the image edge exceeding the depth of field, but also dynamically predicts and offsets the risk of field of view offset, ensuring that no small defects of permanent magnet steel are missed, and greatly improves the accuracy and reliability of dynamic visual scanning.

[0010] 2. The permanent magnet steel appearance defect visual online detection device of the present invention, by setting up an illumination quality attenuation model constructed by acquiring parameters such as the azimuth angle error of the light source, and constructing a multi-domain coupled imaging fidelity model by combining indicators such as the proportion of the highlight area and the sharpness loss rate, realizes real-time quantitative evaluation of complex lighting environments and overall imaging quality. Targeting the high reflectivity of the magnet steel surface, it treats optical defocus damage and illumination quality damage as orthogonal dimensions for spatial fusion, which can keenly capture and quantify the degree to which local highlights or underexposure cover up real defects, ensuring that the best illumination quality is always maintained in high-speed dynamic detection, and providing comprehensive and realistic comprehensive evaluation data support for the subsequent precise orientation adjustment of the camera. Attached Figure Description

[0011] The invention will now be further described with reference to the accompanying drawings.

[0012] Figure 1 This is a perspective view of the present invention; Figure 2 This is a schematic diagram of the up-and-down movement of the visual inspection mechanism in this invention; Figure 3 This is a schematic diagram of the swinging of the visual inspection mechanism in this invention; Figure 4 This is the overall control flowchart of the visual inspection device in this invention; Figure 5 This is a flowchart of the geometric defocus tendency model construction process in this invention; Figure 6 This is a flowchart of the field-of-view alignment deviation model construction process in this invention; Figure 7 This is a flowchart of the lighting quality attenuation model construction process in this invention; Figure 8 This is a flowchart of the multi-domain coupled imaging fidelity model construction process in this invention; Figure 9 This is a flowchart of the camera angle optimization model construction and execution in this invention.

[0013] In the diagram: 1. Visual inspection equipment; 2. Multi-axis motion mechanism; 3. Visual inspection mechanism. Detailed Implementation

[0014] To make the technical means, creative features, objectives and effects of this invention easier to understand, the invention will be further described below in conjunction with specific embodiments.

[0015] The permanent magnet appearance defect visual online detection device of the present invention includes a visual detection device 1, a multi-axis motion mechanism 2 disposed on the visual detection device 1 and capable of sliding up and down and moving left and right, a visual detection mechanism 3 mounted on the multi-axis motion mechanism 2, and a controller. The visual detection mechanism 3 includes a camera and a light source. The controller is used to perform the following operations: S11: Obtain the real-time working distance of the camera and the dynamic parallelism deviation angle between the camera target surface and the workpiece surface, and construct a geometric defocus tendency model to output the geometric defocus tendency coefficient. S12: Obtain the real-time physical offset between the swing axis and the camera's field of view center and the repeatability spatial error of the multi-axis motion mechanism 2, and construct a field of view alignment deviation model to output the field of view alignment deviation coefficient. S13: Obtain the incident azimuth angle error of the light source and the uniformity coefficient of the light source illuminance, construct a lighting quality attenuation model to output the lighting quality attenuation coefficient; S14: Obtain the depth-of-field boundary sharpness loss rate, highlight area ratio, and highlight area normalized center distance. Combine the geometric defocus tendency coefficient and illumination quality attenuation coefficient to construct a multi-domain coupled imaging fidelity model to output the overall imaging fidelity. S15: Based on the overall image fidelity, the field of view alignment deviation coefficient and the current actual viewing angle of the camera, a camera angle optimization model is constructed to output the target camera viewing angle. Combined with the deviation between the camera's real-time working distance and the ideal focusing reference distance, as well as the real-time physical offset, it is converted into multi-degree-of-freedom control commands to drive the multi-axis motion mechanism 2 to adjust its spatial position and attitude.

[0016] A multi-axis motion mechanism 2 is mounted on the vision inspection device 1, enabling the camera to slide vertically and move horizontally in space. For example, the multi-axis motion mechanism 2 can consist of multiple linear guides and sliders, driven by stepper motors or servo motors to achieve linear movement of the camera in the X, Y, and Z directions. The vision inspection mechanism 3 is mounted on the multi-axis motion mechanism 2. Its core components are a camera and a light source. The camera is responsible for acquiring images of the permanent magnet surface. For example, an industrial-grade area array camera can be used, connected to the controller via a USB or GigE interface. The light source can be a ring LED light source or a strip LED light source, powered by an external power supply. The controller is configured to perform a series of operations to achieve real-time perception and optimization of image quality. For example, the controller can be an embedded system or an industrial PC, running preset vision algorithms and control logic.

[0017] The first operation performed by the controller is to acquire the real-time working distance of the camera and the dynamic parallelism deviation angle between the camera target surface and the workpiece surface, and to construct a geometric defocus tendency model to output a geometric defocus tendency coefficient. The real-time working distance can be obtained in various ways; for example, a laser displacement sensor can be installed next to the camera to measure the distance from the leading edge of the camera lens to the workpiece surface in real time. The dynamic parallelism deviation angle can be acquired by installing a dual-axis tilt sensor on the camera housing, which can measure the camera's pitch and roll angles in real time, and then calculate the parallelism deviation between the camera target surface and the workpiece surface through geometric calculations. The geometric defocus tendency model then quantifies the defocus risk caused by geometric factors based on these acquired parameters.

[0018] The second operation performed by the controller is to acquire the real-time physical offset between the swing axis center and the camera's field of view center, and the repeatability spatial error of the multi-axis motion mechanism 2. This allows for the construction of a field-of-view alignment deviation model to output a field-of-view alignment deviation coefficient. The real-time physical offset can be obtained by fixing a calibration target with feature points within the camera's field of view. The controller uses a vision algorithm to calculate the pixel offset of the image center relative to the target origin in real time and converts it into a physical distance. The repeatability spatial error can be obtained by performing multiple repeatability tests on the multi-axis motion mechanism 2 and recording the spatial coordinates of the camera at different positions using external high-precision measuring equipment (such as a laser interferometer or coordinate measuring machine), then statistically analyzing the dispersion of these coordinates. In another implementation, an optical reference sphere can be fixed on the vision inspection device 1. The camera captures images of the reference sphere at different control cycles and calculates its spatial coordinates, statistically analyzing the variances in the X, Y, and Z directions to obtain the three-dimensional spatial repeatability standard deviation. The field-of-view alignment deviation model then uses these parameters to evaluate the degree to which the target area deviates from the camera's field of view center. For example, this model could be a function based on the offset and error range, outputting a coefficient representing the alignment deviation.

[0019] The third operation performed by the controller is to acquire the incident azimuth error of the light source and the light source illuminance uniformity coefficient, and to construct a lighting quality attenuation model to output the lighting quality attenuation coefficient. The incident azimuth error of the light source can be obtained by installing an encoder on the rotation axis of the light source, reading the actual angle of the light source in real time, and comparing it with a preset ideal angle. In another implementation, multiple photosensitive sensors can be placed on the workpiece surface to indirectly estimate the azimuth angle of the light source by analyzing the differences in light intensity at different locations. The light source illuminance uniformity coefficient can be obtained by arranging multiple miniature illuminance meters on the workpiece surface, directly reading the illuminance values ​​at each point, and then calculating the ratio of the lowest illuminance at the edge to the illuminance at the center. In another implementation, grayscale analysis can be performed on the acquired image to calculate the average grayscale value of different regions in the image and evaluate its uniformity. The lighting quality attenuation model then quantifies the impact of lighting conditions on image quality based on these parameters. For example, this model could be an attenuation function that considers angular deviation and insufficient uniformity.

[0020] The fourth operation performed by the controller is to acquire the depth-of-field boundary sharpness loss rate, highlight area ratio, and normalized center distance of the highlight area. Combined with the geometric defocus tendency coefficient and illumination quality attenuation coefficient, a multi-domain coupled imaging fidelity model is constructed to output the overall imaging fidelity. The depth-of-field boundary sharpness loss rate is obtained by the controller applying the Laplacian operator to the region of interest at the image edge to calculate the gradient variance and then comparing it with the baseline sharpness template. The highlight area ratio is obtained by the controller performing threshold segmentation on the image, extracting overexposed areas with grayscale values ​​greater than a set threshold, and calculating the ratio of their pixel count to the total number of pixels in the image. The normalized center distance of the highlight area is obtained by the controller extracting the centroid coordinates of the highlight area, calculating its Euclidean distance to the geometric center of the image, and then normalizing it by dividing by the half-diagonal pixel length of the image. The multi-domain coupled imaging fidelity model then integrates the acquired indicators and coefficients to output a comprehensive fidelity reflecting the overall imaging quality. For example, this model could be a function based on weighted averaging or nonlinear fusion, integrating impairment factors from different dimensions.

[0021] The fifth operation performed by the controller is to construct a camera angle optimization model based on the overall imaging fidelity, the field-of-view alignment deviation coefficient, and the camera's current actual viewing angle, outputting the target camera viewing angle to drive the multi-axis motion mechanism 2 for attitude adjustment. The camera's current actual viewing angle can be obtained in real time by combining the encoder readings of the multi-axis motion mechanism 2 with the mechanism's kinematic model. In another implementation, an inertial measurement unit (IMU) can be installed on the camera to acquire the camera's attitude information in real time. The camera angle optimization model then uses these inputs to calculate the target camera viewing angle that optimizes the imaging quality. For example, this model could be an optimization algorithm based on feedback control theory, dynamically adjusting the target angle according to the current imaging quality and field-of-view alignment. The controller then converts the target camera viewing angle into displacement and rotation control commands, driving the multi-axis motion mechanism 2 to perform up-and-down sliding and left-and-right movement via a multi-axis servo driver, thereby achieving adaptive attitude adjustment closed-loop control of the camera's attitude. For example, the controller can decompose the target angle into displacements along the X, Y, and Z axes and rotations around each axis, then send these quantities to the servo driver to drive the corresponding motors for precise movement.

[0022] This application acquires the camera working distance and dynamic parallelism deviation angle in real time and constructs a geometric defocus tendency model, which enables quantitative perception of this instantaneous geometric shape deviation. This provides a data foundation for subsequent precise attitude adjustment and effectively avoids the problem of image defocusing and blurring that easily occurs when the camera working distance and target surface parallelism are affected by workpiece placement tolerance and mechanism vibration, as is the case in the prior art.

[0023] In addition, in the prior art, the mechanical error of the multi-axis motion mechanism 2 often causes the target defect area to deviate from the field of view, or even generate a detection blind zone. This application, by acquiring the physical offset between the swing axis and the center of the camera's field of view and the repeatability spatial error of the multi-axis motion mechanism 2 in real time, and constructing a field of view alignment deviation model, can dynamically assess and predict the risk of field of view offset, ensuring that the target area is always within the effective detection field of view, and significantly improving the reliability of detection.

[0024] To address the sensitivity of permanent magnet steel to illumination angles due to its high reflectivity, existing light source control systems and camera motion systems are typically in an open-loop isolated state, leading to uneven illumination or the appearance of highlights / shadows. This application achieves real-time monitoring and evaluation of the illumination environment by obtaining the incident azimuth angle error of the light source and the uniformity coefficient of the light source illuminance, and constructing an illumination quality attenuation model. This provides a basis for the coordinated adjustment of the light source and camera attitude, thereby ensuring that the best illumination quality is maintained during dynamic detection and preventing defects from being masked.

[0025] This application constructs a multi-domain coupled imaging fidelity model by obtaining the depth-of-field boundary sharpness loss rate, the highlight area ratio, and the normalized center distance of the highlight area, and combining them with the geometric defocus tendency coefficient and the illumination quality attenuation coefficient. This model comprehensively evaluates the sharpness of optical imaging, the uniformity of illumination, and the influence of highlight reflection, providing a comprehensive imaging quality index. Compared with existing methods that may only focus on a single image quality parameter, the comprehensive fidelity evaluation of this application is more comprehensive and accurate, and can more realistically reflect the imaging quality.

[0026] The geometric defocus tendency model is as follows: The axial position deviation between the camera's real-time working distance and the ideal focusing reference distance, as well as the angular attitude deviation between the dynamic parallelism deviation angle and the maximum allowable parallelism error, are extracted. The deviation features of the above two dimensions are normalized based on their corresponding tolerance boundaries, and then nonlinearly mapped and fused with preset weight coefficients to output a geometric defocus tendency coefficient that characterizes the degree of optical defocus risk caused by spatial geometric pose deviation.

[0027] The geometric defocus tendency model is as follows:

[0028] in, The geometric defocus tendency coefficient is dimensionless. The real-time working distance of the camera, with dimensions of The readings are obtained in real time by the multi-turn absolute encoder built into the Z-axis servo motor that drives the multi-axis motion mechanism 2 to slide up and down. The ideal focusing reference distance, with dimensions of ; The theoretical depth-of-field tolerance boundary, with dimensions of ; The dynamic parallelism deviation angle has the dimension of . The pitch and roll angles are read by a dual-axis tilt sensor mounted on the camera housing and then calculated through geometric projection. The maximum permissible parallelism error has the following dimensions: ; and All are normalized weight coefficients, dimensionless, and satisfy the following conditions: .

[0029] This geometric defocus tendency model aims to quantify the degree to which an imaging system deviates from the ideal focus state due to geometric factors (such as working distance and attitude). It integrates multiple influencing factors through a mathematical expression and outputs a dimensionless coefficient that reflects the tendency of the image to become out of focus. The model can be constructed using mathematical formulas based on physical optics principles, or it can be obtained through machine learning methods combined with a large amount of experimental data for training and optimization.

[0030] Camera real-time working distance This refers to the actual distance between the front surface of the camera lens and the surface of the workpiece being inspected. Its accurate measurement is crucial for assessing the defocus state. In addition to being obtained in real time through the multi-turn absolute encoder built into the Z-axis servo motor or an external laser displacement sensor, it can also be measured using the triangulation method, which utilizes two sensors with known distances or one sensor and a known reference point.

[0031] The multi-turn absolute encoder built into the Z-axis servo motor is a sensor integrated within the servo motor. It can provide real-time and accurate feedback on the rotation angle and number of turns of the motor shaft, thereby calculating the precise position of the motion mechanism connected to the motor (such as the Z-axis). This is typically achieved using photoelectric or magnetic encoder disks combined with a multi-turn counting mechanism, maintaining position information even after power failure. An external laser displacement sensor is a non-contact measurement device that emits a laser beam and receives the reflected light, accurately measuring the distance to a target object based on principles such as time of flight or phase difference. It can be mounted externally to a camera or multi-axis motion mechanism 2, performing distance measurement independently of the motor. Besides laser displacement sensors, eddy current sensors or capacitive sensors can also be used to measure distance by sensing metallic objects or changes in dielectric constant, but these are generally suitable for closer distances or measurements of specific materials.

[0032] Ideal focusing reference distance This refers to the working distance, determined during the system design or calibration phase, that enables the camera to obtain images with optimal sharpness. This distance is typically preset based on the camera lens's focal length, depth of field range, typical workpiece dimensions, and inspection requirements. Theoretical depth of field tolerance boundary. This refers to the maximum allowable deviation range of the camera's working distance while maintaining acceptable image sharpness. Beyond this boundary, image sharpness will significantly decrease. This boundary is typically determined by optical parameters such as the camera lens's focal length, aperture, pixel size, and acceptable blur diameter, and can be calculated using optical formulas. Dynamic parallelism deviation angle. This refers to the real-time tilt angle between the camera target surface (image sensor plane) and the surface of the workpiece being inspected. Ideally, the two should remain perfectly parallel. Deviations in this angle can cause inconsistent image clarity in different areas.

[0033] A dual-axis tilt sensor mounted on a camera housing is a sensor capable of measuring the tilt angle of an object along two orthogonal axes. Typically based on MEMS (Micro-Electro-Mechanical Systems) technology, it determines the tilt angle by detecting the components of gravitational acceleration in different directions. It can be directly mounted on the camera body to acquire the camera's attitude information in real time. Geometric projection calculation refers to using geometric principles to combine the attitude information such as pitch and roll angles read by the sensor with the relative positional relationship between the camera and the workpiece to calculate the actual parallelism deviation angle between the camera target surface and the workpiece surface. This usually involves three-dimensional coordinate transformation and vector operations, with a maximum permissible parallelism error. This refers to the maximum permissible tilt angle between the camera target surface and the workpiece surface while ensuring image quality meets inspection requirements. Exceeding this angle will result in unacceptable defocus blur; this error value is typically set based on actual inspection accuracy requirements and optical system performance. Normalized weighting coefficient. and The coefficients are used to adjust the contribution of different influencing factors (such as distance deviation and angle deviation) in the geometric defocus tendency model to the final defocus tendency coefficient. They are dimensionless and sum to 1, ensuring that the relative importance of each factor can be flexibly configured. These coefficients can be set by expert experience or optimized by experimental data, for example, by minimizing the error between the actual defocus degree and the model output.

[0034] hyperbolic tangent function It is an sigmoid function whose range is typically between -1 and 1 (or scaled to 0 to 1). In geometric defocus tendency models, it is used to map the weighted and squared distance and angle deviation terms to a finite, smoothly varying range, thus outputting a dimensionless geometric defocus tendency coefficient. This nonlinear mapping helps to smoothly reflect the increase in defocus risk, avoiding abrupt changes or insensitive regions that might occur with linear models.

[0035] The controller acquires the real-time working distance of the camera and the dynamic parallelism deviation angle between the camera target surface and the workpiece surface, and constructs a geometric defocus tendency model based on this to output the geometric defocus tendency coefficient. Specifically, the controller first acquires the real-time working distance of the camera through a multi-turn absolute encoder built into the Z-axis servo motor or an external laser displacement sensor. and compare it with the preset ideal focus reference distance. The distance deviation is compared and quantified. Simultaneously, the controller reads the camera's pitch and roll angles using a dual-axis tilt sensor mounted on the camera housing, and then calculates the dynamic parallelism deviation angle between the camera target surface and the workpiece surface through geometric projection. and compare it with the maximum permissible parallelism error The distance and angle deviations are compared and quantified. Subsequently, the controller normalizes these quantified distance and angle deviations using weighting coefficients. and Weight the values ​​and substitute them into the hyperbolic tangent function. In the process, the geometric defocus tendency coefficient is calculated. This coefficient can reflect in real time and quantitatively the degree to which the current imaging system deviates from the ideal focus state due to geometric factors (working distance and attitude), providing key input for subsequent image fidelity assessment and camera attitude adjustment. In this way, this solution can dynamically sense and quantify the instantaneous geometric shape deviation between the camera and the workpiece, thus laying the foundation for solving the problem of severe optical defocus blurring at the image edges due to exceeding the depth of field.

[0036] The field-of-view alignment deviation model is as follows: Based on the statistical distribution characteristics of the repetitive positioning spatial error of the multi-axis motion mechanism 2, a statistical confidence contraction mechanism is introduced to dynamically constrain the effective radius of the camera's physical field of view at the current working distance, thereby obtaining the dynamic effective field of view boundary. A relative proportional mapping relationship between the real-time physical offset and the dynamic effective field of view boundary is established, and through nonlinear saturation evaluation logic, a field of view alignment deviation coefficient is output to characterize the severity of the deviation of the camera's field of view center from the target detection area.

[0037] The field-of-view alignment deviation model is as follows:

[0038] in, is the field alignment deviation coefficient, which is dimensionless; This is the real-time physical offset, with dimensions of ; Let be the effective radius of the camera's physical field of view at the current working distance, with dimensions . ; Let be the standard deviation of the repeatability spatial error, with dimensions . ; The statistical confidence contraction coefficient is dimensionless and is used to transform the macroscopic repetitive positioning spatial error into a dynamic microscopic boundary contraction constraint on the effective radius of the physical field of view. The minimum effective boundary constant of the system, which is used to prevent the denominator from approaching zero, has the following dimensions: ,and .

[0039] Field of view alignment deviation coefficient This is a dimensionless index used to quantify the alignment between the camera's field of view and the target workpiece. This coefficient directly reflects the degree to which the center of the camera's field of view deviates from the target area; a larger value indicates a higher degree of deviation and a worse alignment effect. This coefficient serves as an important input to the subsequent camera angle optimization model, guiding the multi-axis motion mechanism 2 to adjust its attitude to ensure that the detection area remains within the effective range of the camera's field of view. Real-time physical offset... This refers to the instantaneous physical distance between the actual center of the camera's field of view and the preset or ideal center of the detection area during the detection process. This offset is caused by factors such as the mechanical error of the multi-axis motion mechanism 2 and the workpiece placement tolerance. The real-time physical offset is then obtained. The methods may include: setting specific reference markers within the camera's field of view, using image processing algorithms to calculate in real time the pixel distance between the marker's position in the image and the image center, and then converting it into actual physical distance using pixel equivalents.

[0040] Physical field of view effective radius The effective radius of the physical field of view refers to the radius of the physical area that the camera can clearly and effectively capture an image of at the current camera working distance. This radius determines the actual detection range that the camera can cover in a single shot. The radius of the camera can be determined in the following ways: During the system calibration phase, by photographing a calibration board of known size and combining it with the camera's intrinsic parameters and the current working distance, the actual field of view of the camera in physical space can be calculated, and thus its radius can be obtained; or, the physical field of view can be theoretically calculated using optical simulation software based on the camera lens parameters, sensor size, and working distance.

[0041] Standard deviation of repeatability spatial error This is a statistical measure of the dispersion of the final positioning accuracy of a multi-axis motion mechanism 2 when repeatedly executing the same motion commands. The standard deviation reflects the randomness and uncertainty of the mechanism's motion. The standard deviation of the repeatability positioning spatial error is obtained. The method may include: installing a high-precision displacement sensor or laser tracker at the end of the multi-axis motion mechanism 2, recording the three-dimensional coordinate data of its end position after the mechanism repeatedly moves to the same target position multiple times, and performing statistical analysis on these data to calculate the standard deviation in the X, Y, and Z directions, and then comprehensively obtaining the spatial repeatability standard deviation.

[0042] Statistical confidence level shrinkage coefficient This is a dimensionless parameter that transforms the macroscopic spatial error of repeated positioning into a dynamic microscopic boundary contraction constraint on the effective radius of the physical field of view. This coefficient reflects the degree of conservative estimation of the effective radius of the field of view when considering the uncertainties of mechanism motion. Statistical confidence contraction coefficient. The determination of the coefficient can be based on: statistical analysis of long-term operating data of the multi-axis motion mechanism 2, combined with a specific confidence level (e.g., 95% or 99%), and using statistical methods to determine a suitable coefficient to ensure that, in most cases, the actual detection area will not exceed the effective field of view after contraction; or, it can be determined empirically by experimental verification, adjusting the coefficient under different motion modes and load conditions until the system can stably avoid detection blind spots.

[0043] To prevent mathematical singularities such as the denominator of the formula approaching zero or becoming negative under extreme conditions of extremely large mechanical errors or excessive confidence contraction, a maximum value function is introduced into the model. and the system's minimum effective boundary constant ( When the dynamic micro-boundary contraction constraint When the value is too large and the remaining effective field of view tends to collapse, the denominator will be safely truncated. This ensures the alignment deviation coefficient of the field of view. Output a stable maximum penalty value to ensure that the control system does not experience computational overflow or logical inversion.

[0044] By constructing a field-of-view alignment deviation model, a quantitative assessment of the camera's field-of-view alignment status was achieved, providing crucial deviation feedback for subsequent attitude adjustments. The core of this model lies in the introduction of a dynamic micro-boundary contraction constraint mechanism, which uses the standard deviation of the repeated positioning spatial error... With statistical confidence level shrinkage coefficient Multiplication, with respect to the effective radius of the physical field of view Real-time correction is performed, which effectively eliminates uncontrollable random jitter interference caused by mechanical assembly clearances and repetitive positioning errors during high-speed dynamic operation of the multi-axis motion mechanism 2, thus improving the effective radius of the field of view. The definition is more in line with the actual usable range in a dynamic operating environment, that is, the smallest effective area that the camera's field of view can reliably cover after considering the uncertainty of the mechanism's motion.

[0045] Based on this, using real-time physical offset With the corrected effective radius The ratio is used to map the output field-of-view alignment deviation coefficient through the arctangent function. The use of the arctangent function enables the coefficient to sensitively reflect the degree to which the center of the camera's field of view deviates from the target area. It provides high sensitivity when the offset is small and saturated output when the offset is large, avoiding over-response. Through this mathematical modeling method that transforms macroscopic mechanical errors into microscopic field of view constraints, the system can perceive the risk of field of view offset caused by the movement gap of the mechanism in real time, thus providing accurate deviation input for subsequent closed-loop attitude control.

[0046] This field of view alignment deviation coefficient Overall image fidelity and the camera's current actual field of view. The inputs are combined into the camera angle optimization model, enabling the multi-axis motion mechanism 2 to perform adaptive attitude adjustment based on a comprehensive state assessment, ensuring that the detection area of ​​the permanent magnet is always in the best imaging and alignment state.

[0047] By constructing a field-of-view alignment deviation model, a statistical confidence shrinkage coefficient is introduced. and the standard deviation of the spatial error of repeatability For the effective radius of the physical field of view Dynamic correction is performed, thereby achieving precise quantitative evaluation of the camera's field of view alignment. This dynamic constraint mechanism enables the system to perceive and compensate for the risk of field of view offset caused by mechanical jitter and errors in real time, effectively avoiding the problems of blind spots and target areas leaving the field of view. It can continuously maintain good alignment between the camera's field of view and the workpiece inspection area, significantly improving the stability, reliability and inspection coverage of dynamic visual inspection, and ensuring comprehensive and accurate detection of surface defects of permanent magnet steel.

[0048] Real-time physical offset and the standard deviation of the spatial error of repeatability The methods for obtaining it are as follows: A calibration target is fixed in front of the camera. The controller's vision algorithm calculates the pixel offset of the image center relative to the target origin in real time, and multiplies it by the pixel equivalent to convert it into a real-time physical offset. ; By using an optical reference sphere fixed on visual inspection device 1 or a laser tracker, and with the help of a camera, capturing images at different control cycles, the spatial coordinates are calculated. The variances in the X, Y, and Z directions are statistically analyzed to obtain the standard deviation of three-dimensional spatial repeatability. .

[0049] When encountering a physical condition during dynamic scanning where the mechanical assembly clearance and spatial repetitive positioning error of the multi-axis motion mechanism 2 cause a transient physical offset between the mechanism's motion axis and the camera's field of view, resulting in the target defect area being removed from the effective field of view and creating a detection blind zone, the controller executes the following steps: S41: The controller extracts the field of view alignment deviation coefficient and compares the field of view alignment deviation coefficient with the preset field of view offset safety threshold; S42: When the field of view alignment deviation coefficient in step S41 is greater than the preset field of view offset safety threshold, the controller extracts the real-time physical offset and decomposes the real-time physical offset into X-axis displacement compensation and Y-axis displacement compensation. S43: The controller generates a planar anti-deviation displacement command based on the X-axis displacement compensation amount and Y-axis displacement compensation amount obtained in step S42, and sends the planar anti-deviation displacement command to the multi-axis servo driver that drives the multi-axis motion mechanism 2. S44: The multi-axis servo driver drives the multi-axis motion mechanism 2 to perform rigid displacement compensation action to control the left and right movement of the camera according to the planar anti-deviation displacement command received in step S43. S45: Achieves the effect of offsetting the risk of field of view shift and relocking the target defect area within the effective radius of the camera's physical field of view, thereby fundamentally preventing the missed detection of small defects due to their departure from the field of view boundary.

[0050] When the multi-axis motion mechanism 2 performs high-speed dynamic scanning, the mechanical assembly clearance and spatial repetitive positioning error often overlap, causing a transient physical offset between the center of the mechanism's motion axis and the center of the camera's field of view. This results in the target defect area being removed from the effective field of view, creating a detection blind zone. To solve this problem, the controller executes the following physical compensation logic: First, the controller extracts the field-of-view alignment deviation coefficients output by the field-of-view alignment deviation model in real time. It is then compared with the field-of-view offset safety threshold preset inside the controller, and the field-of-view alignment deviation coefficient is determined. When the field of view offset exceeds the safety threshold, the anti-deviation protection mechanism is triggered.

[0051] Subsequently, the controller immediately extracts the real-time physical offset obtained through the visual algorithm. The displacement is then decomposed into X-axis and Y-axis displacement compensation values ​​in physical space to generate a planar anti-deviation displacement command. The controller sends this planar anti-deviation displacement command to the multi-axis servo driver that drives the multi-axis motion mechanism 2.

[0052] Finally, the multi-axis servo driver drives the multi-axis motion mechanism 2 to perform rigid displacement compensation actions for the camera in the left, right, forward, and backward directions. This physical action can accurately offset the risk of transient field of view shift and re-lock the target defect area to the effective radius of the camera's physical field of view. This fundamentally prevents the missed detection of minute defects due to their deviation from the field of view boundary.

[0053] The lighting quality degradation model is as follows: A nonlinear attenuation trend term for illumination quality with the incident azimuth error of the light source as the independent variable is constructed, and the boundary of the attenuation process is fitted and constrained by the light source attenuation rate factor and the nonlinear attenuation shape factor. The collected light source illuminance uniformity coefficient is used as a dynamic feedback variable and fused with the nonlinear attenuation trend term for illumination quality to calculate and output the illumination quality attenuation coefficient, which characterizes the degree to which the current dynamic illumination environment deviates from the ideal illumination state.

[0054] The lighting quality degradation model is as follows:

[0055] in, The light quality attenuation coefficient is dimensionless. The uniformity coefficient of light source illuminance is dimensionless. It is obtained by directly reading the illuminance values ​​at each point from multiple miniature illuminance meters arranged at the four corners and center of the workpiece surface, and calculating the ratio of the lowest illuminance at the edge to the illuminance at the center. The incident azimuth angle error of the light source, with dimensions of It is obtained by calculating the absolute difference between the actual value of the encoder reading the independent light source rotation axis and the set angle; The decay rate factor is dimensionless. It is a nonlinear decay morphological factor, dimensionless and .

[0056] This lighting quality attenuation model aims to quantify the quality of the lighting environment in a visual inspection system, especially in dynamic inspection scenarios where lighting conditions fluctuate due to changes in the relative positions of the light source and the workpiece. It couples multiple parameters related to lighting quality through mathematical formulas to output a comprehensive lighting quality attenuation coefficient, which is used to assess the impact of current lighting conditions on image quality. This model is a key component for achieving adaptive adjustment of lighting conditions and image quality assessment.

[0057] Lighting quality degradation coefficient This is a dimensionless numerical value output by the model, ranging from [0,1], used to characterize the degree of attenuation of the current illumination conditions from the ideal state. The closer the value is to 0, the smaller the attenuation of illumination quality, the closer the illumination conditions are to the ideal state, and the smaller the negative impact on imaging; the closer the value is to 1, the more severe the attenuation of illumination quality, and the greater the negative impact on imaging. This coefficient serves as an important impairment input factor for subsequent multi-domain coupled imaging fidelity models, providing a quantitative basis for evaluating the overall imaging quality in the illumination dimension. Light source illuminance uniformity coefficient. It is a dimensionless parameter used to measure the uniformity of light distribution on the surface of a workpiece. It is obtained by using multiple miniature illuminance meters, such as photodiode arrays or miniature photoelectric sensors, pre-installed on the surface of the workpiece to read the illuminance values ​​at different locations (such as the four corners and the center) in real time.

[0058] The absolute difference between an encoder (e.g., a photoelectric encoder or a magnetic encoder) mounted on the rotating shaft of an independent light source can be calculated by reading its real-time position data and comparing it with a preset ideal incident angle.

[0059] decay rate factor and nonlinear decay morphology factor All are dimensionless parameters used to adjust the attenuation characteristics of the exponential function in the lighting quality attenuation model; attenuation rate factor. This determines how quickly the light quality deteriorates with increasing azimuth error; the larger the value, the faster the attenuation. (Nonlinear attenuation morphology factor) (and This controls the nonlinear shape of the attenuation curve, enabling the model to more accurately simulate the nonlinear effects that may occur during the actual light attenuation process. For example, attenuation is slow when the angle deviation is small, while attenuation is accelerated when the angle deviation is large. These factors are usually determined through experimental calibration or optimization based on empirical data so that the attenuation coefficient output by the model matches the actual perceived trend of light quality changes.

[0060] First, the light distribution on the workpiece surface is monitored in real time by multiple miniature illuminance meters arranged at the four corners and center of the workpiece surface, and the uniformity coefficient of the light source illuminance is calculated. This coefficient directly reflects whether there are areas of excessive brightness or darkness on the workpiece surface under the current lighting conditions, thus quantifying the potential negative impact of uneven lighting on imaging. Simultaneously, by reading the actual encoder value of the independent light source rotation axis and comparing it with the preset ideal angle, the incident azimuth angle error of the light source is obtained in real time. This error characterizes the degree of deviation between the light source orientation and the ideal detection angle, and is directly related to the highlights or shadows that may be generated on the surface of highly reflective workpieces.

[0061] Subsequently, these real-time acquired parameters are input into a preset exponential decay function, which utilizes a decay rate factor. and nonlinear decay morphology factor This method accurately simulates the nonlinear degradation process of illumination quality as azimuth error increases. In this way, the model can organically combine the two key factors of illuminance uniformity and light source angle deviation to generate a single, physically meaningful illumination quality degradation coefficient. The result of the calculation of this coefficient, i.e. It can dynamically reflect the comprehensive impact of the current lighting environment on image quality. This lighting quality attenuation model is closely integrated with the overall architecture of the visual online detection device for permanent magnet appearance defects. In the device, the multi-axis motion mechanism 2 is responsible for the up-down sliding and left-right movement of the camera, while the light source may also adjust its posture accordingly.

[0062] By sensing the dynamic changes of the light source (azimuth error) and its actual effect on the workpiece surface (illuminance uniformity) in real time, the system provides crucial illumination quality input for the subsequent multi-domain coupled imaging fidelity model. This enables the system to overcome the limitations of open-loop isolation between the light source and the camera motion system in traditional detection, achieving dynamic sensing and quantification of the illumination environment. This is achieved by using the illumination quality attenuation coefficient... By incorporating imaging fidelity assessment, the device can more accurately determine the reliability of the current image, thereby adjusting the attitude based on more comprehensive information in the camera angle optimization model. This ensures that high-quality images can be obtained under various dynamic detection conditions, avoiding missed or misjudged defects due to lighting issues.

[0063] Depth of field edge sharpness loss rate Highlight area percentage Distance from the normalization center of the high-light area The methods for obtaining it are as follows: The controller applies the Laplacian operator to the region of interest at the image edges to calculate the gradient variance, and then compares it with a benchmark sharp template to obtain the dimensionless depth-of-field edge sharpness loss rate. ; The controller performs threshold segmentation on the image to extract overexposed areas with grayscale values ​​greater than a set threshold, calculates the ratio of the number of pixels in these overexposed areas to the total number of pixels in the entire image, and obtains the dimensionless highlight area ratio. ; The controller extracts the centroid coordinates of the highlight area, calculates its Euclidean distance to the geometric center of the image, and normalizes it by dividing by the half-diagonal pixel length of the image to obtain the dimensionless normalized center distance of the highlight area. .

[0064] When encountering a physical condition where the highly reflective properties of permanent magnet surfaces are extremely sensitive to illumination angles, and camera movement causes a change in posture, resulting in the formation of high-intensity light spots or shadows on the workpiece surface due to the asynchronous azimuth angles of independent light sources, thus completely masking actual surface defects, the controller executes the following steps:

[0065] S61: The controller extracts the lighting quality attenuation coefficient and compares it with the set lighting quality failure warning threshold. S62: When the lighting quality attenuation coefficient in step S61 is greater than the set lighting quality failure warning threshold, the controller extracts the incident azimuth angle error of the light source and converts the incident azimuth angle error of the light source into a light source attitude deflection compensation command. S63: The controller sends the light source attitude deflection compensation command generated in step S62 to the independent light source rotation axis that controls the light source action. S64: The independent light source rotation axis performs a light source angle deflection action according to the light source attitude deflection compensation command received in step S63, so as to compensate for the light source incident azimuth angle error in physical space. S65: Achieves the effect of eliminating local overexposed or underexposed areas on the workpiece surface and maintaining the best lighting quality in high-speed dynamic inspection, ensuring that real surface defects are not covered by light spots.

[0066] Given the highly reflective nature of permanent magnet surfaces, if the azimuth angles of the independent light sources are not synchronized when the camera's posture changes due to the movement of the mechanism, high-intensity light spots or shadows can easily form on the workpiece surface, completely obscuring actual surface defects. To solve this lighting problem, the controller executes the following synchronization and attitude adjustment logic: The controller extracts the lighting quality attenuation coefficient from the lighting quality attenuation model in real time. And compare it with the set warning threshold for lighting quality failure. When the lighting quality degradation coefficient is detected... When the error exceeds the warning threshold, the controller extracts the incident azimuth error of the light source from the encoder. It is then directly converted into a light source attitude deflection compensation command.

[0067] Subsequently, the controller sends the light source attitude deflection compensation command to the drive motor of the independent light source rotation axis. Upon receiving the command, the independent light source rotation axis immediately executes the mechanical action of deflecting the light source angle, completely canceling the current incident azimuth angle error of the light source in physical space. .

[0068] Through this mechanical deflection action, the system achieves dynamic synchronization between the illumination angle and the camera posture, eliminating local overexposure or underexposure areas on the workpiece surface, and achieving the effect of maintaining the best lighting quality in high-speed dynamic inspection, ensuring that the actual defects such as chipping and cracks on the surface are not covered by the light spot.

[0069] The multi-domain coupled imaging fidelity model is as follows: The optical defocusing tendency coefficient and the depth-of-field boundary sharpness loss rate are correlated to construct the optical defocusing damage dimension feature. The illumination quality attenuation coefficient, the highlight area ratio, and the normalized center distance of the highlight area with a position penalty mechanism are correlated to construct the illumination quality damage dimension feature. Based on the set orthogonal constraint weight mechanism, the optical defocusing damage dimension feature and the illumination quality damage dimension feature are fused in a multi-dimensional space to finally output the overall imaging fidelity that comprehensively represents the current overall imaging quality.

[0070] The multi-domain coupled imaging fidelity model is as follows:

[0071] in, For overall image fidelity, dimensionless, with a value range of [value range missing]. ; and The positive constraint weights are dimensionless and satisfy the following conditions: Spatial mathematical fusion of orthogonal damage factors based on Euclidean norm.

[0072] This multi-domain coupled imaging fidelity model is a comprehensive mathematical model designed to quantify the overall image quality in a visual inspection system. By integrating multiple dimensions that affect imaging quality, such as optical defocus and illumination quality issues, it provides a single, quantifiable index to assess the reliability and usability of images. Its core concept is to unify complex imaging impairment factors into a single evaluation system, thereby providing data support for subsequent system optimization.

[0073] Geometric defocus tendency coefficient This reflects the deviation between the camera's real-time working distance and the ideal focusing reference distance, as well as the impact of the dynamic parallelism deviation angle on the geometric defocus of the image. In this model, it serves as a key input for evaluating optical defocusing damage, in conjunction with the depth-of-field boundary sharpness loss rate. Combined, the image detail loss caused by defocusing and the depth-of-field edge sharpness loss rate are quantified. This model directly quantifies the degree of sharpness loss caused by defocusing in image edge regions. In this model, it is correlated with the geometric defocus tendency coefficient. Multiplying these results in a more comprehensive optical defocusing impairment factor, used to evaluate an image's detail retention capability across the depth of field, and an illumination quality attenuation coefficient. This model characterizes the impact of light source incident azimuth angle error and light source illuminance uniformity on lighting quality. In this model, it serves as a key input for assessing lighting damage, along with the proportion of the highlight area. Distance from the normalization center of the high-light area Combined, the image information distortion caused by uneven lighting and overexposure of highlights is quantified, and the proportion of highlight area is determined. This model quantifies the proportion of highlight areas in an image caused by overexposure, and in this model, it is correlated with the illumination quality attenuation coefficient. Distance from the normalization center of the high-light area Combined, it is used to evaluate the negative impact of highlight regions on the overall image quality, especially the interference with defect detection, and the normalized center distance of the highlight region. This describes the relative position between the centroid of the highlight region in the image and the geometric center of the image. In this model, it is expressed as... The form of the weighted average weight in the calculation means that the closer the highlight area is to the image center, the greater its negative impact on image quality, and vice versa. This reflects the criticality of the highlight area's location to the detection effect, and the positive constraint weighting coefficients... and The geometric defocus damage factor and illumination quality damage factor are used to adjust the relative importance of each other in the calculation of overall image fidelity. They are dimensionless and sum to 1, allowing the system to flexibly adjust the degree of attention given to different types of damage according to the actual application scenario, workpiece characteristics, or inspection requirements. For example, for applications with extremely high requirements for edge sharpness, the geometric defocus damage factor and illumination quality damage factor can be appropriately increased. The weighting; for highly reflective workpieces, it may be necessary to increase The weighting of the damage factors is based on spatial mathematical fusion of orthogonal damage factors using the Euclidean norm. This fusion method treats geometric defocus damage factors and illumination quality damage factors as two mutually orthogonal vector components in two-dimensional space, and obtains a comprehensive damage metric by calculating their Euclidean norms. This method ensures that different types of damage do not simply add up or cancel each other out during fusion, but are quantified in a geometric distance manner, thus more accurately reflecting the overall performance degradation of the system under multiple damages. It avoids a single damage dimension being masked by other dimensions, ensuring that the comprehensive fidelity can fully reflect the imaging capability of the system.

[0074] By using the geometric defocus tendency coefficient With depth of field boundary sharpness loss rate Multiplication quantifies the direct damage to image quality caused by optical defocusing. This processing method effectively reflects the degree of loss of image edge details under specific working distances and parallelism deviations. Simultaneously, the model incorporates the illumination quality attenuation coefficient. Highlight area percentage and the distance of the normalization center in the high-light area Multiplication was performed to quantify the negative impact of uneven illumination and overexposure of highlights on image quality, including the introduction of normalized center distance in the highlight area. The reciprocal term effectively identifies the interference weights of the positional distribution of highlight regions in the field of view on image quality. These independent impairment factors are then weighted by positive constraints. and Weighted values ​​are applied, and orthogonal fusion is performed based on the Euclidean norm to generate the final overall image fidelity. This fusion approach treats optical defocusing damage and illumination quality damage as mutually orthogonal dimensions, ensuring that both types of damage are fully considered when evaluating overall image quality. This avoids situations where a single damage dimension is masked by other dimensions. The model fully utilizes real-time data obtained from geometric defocusing tendency models, illumination quality attenuation models, and methods for acquiring depth-of-field boundary sharpness loss rate, highlight area ratio, and normalized center distance of highlight areas. It integrates these scattered quality indicators into a unified, physically meaningful comprehensive fidelity value. This allows the system to dynamically perceive and evaluate image quality from multiple dimensions, providing a comprehensive and accurate quantitative basis for subsequent camera attitude adjustments. This effectively solves the problem that traditional methods cannot accurately quantify the overall fidelity of the imaging system.

[0075] The camera angle optimization model is as follows: The angular deviation between the pre-planned optical normal projection angle of the workpiece and the current actual viewing angle of the camera is used as the basic attitude adjustment guide; the overall imaging fidelity is introduced as a dynamic excitation factor to adaptively adjust the response sensitivity of attitude optimization; the field of view alignment deviation coefficient is used as a safety suppression factor to constrain the adjustment range under severe field of view deviation; and a nonlinear flexible limiting mechanism for large angular deviations is introduced to smooth the overall adjustment amount, and finally outputs the target camera viewing angle to guide the control execution.

[0076] The camera angle optimization model is as follows:

[0077] in, Let be the target camera's viewing angle, with dimensions . ; The current actual viewing angle, with dimensions of ; The optical normal projection angle pre-planned for the 3D model of the workpiece, with dimensions of ; The maximum attitude adjustment step size gain of the system, with dimensions of ; is the field deviation suppression coefficient, which is dimensionless.

[0078] Target camera view angle This refers to the desired observation angle that the camera should achieve after attitude adjustment. Its function is to provide a clear attitude adjustment target for the multi-axis motion mechanism 2, ensuring that the camera can inspect the workpiece surface at the optimal angle. Current actual viewing angle. This refers to the real-time observation angle of the camera before attitude adjustment. This angle can be obtained in various ways, such as by combining the encoder feedback value of the multi-axis motion mechanism 2 with the kinematic model.

[0079] Ideal optical normal projection angle This refers to the ideal observation angle pre-planned based on the 3D model of the workpiece, which makes the optical axis of the camera lens coincide as much as possible with the local normal direction of the workpiece surface. This angle can be obtained by offline path planning and angle calculation based on the CAD model.

[0080] Maximum attitude adjustment step gain of the system This is a scaling factor used to control the speed and amplitude of camera attitude adjustment. Its function is to limit the maximum angular change in a single adjustment to prevent excessively fast or overshooting movement of the mechanism. This gain can be empirically set based on the system's mechanical characteristics, response speed, and control accuracy requirements; or it can be dynamically adjusted through system identification and optimization algorithms to adapt to different detection scenarios. Field of view deviation suppression coefficient. It is a dimensionless parameter used to adjust the degree to which the field of view alignment deviation suppresses the attitude adjustment step size. Its function is to reduce the overall attitude adjustment step size by increasing the value of the denominator when the field of view alignment deviation is large, thereby avoiding the camera from making large adjustments when the field of view is seriously deviated, causing the target area to completely leave the field of view. This coefficient can be set empirically according to the requirements of field of view stability in actual applications.

[0081] Overall image fidelity It is a comprehensive quantitative indicator of camera image quality, and its value range is [value range missing]. In the camera angle optimization model, it affects the sensitivity of pose adjustment through a logarithmic function term; when the image quality is poor ( When the value is low, the absolute value of the logarithmic term increases, thereby prompting the system to make more aggressive attitude adjustments to improve image quality.

[0082] Field of view alignment deviation coefficient It is an indicator that quantifies the degree of physical offset between the camera's field of view center and the target area. In the camera angle optimization model, it suppresses the attitude adjustment step size through the denominator term. When the field of view alignment deviation is large ( When the value is high, the denominator term increases, resulting in a smaller attitude adjustment step size, in order to prevent over-adjustment when the field of view is inaccurate.

[0083] The controller first obtains the camera's current actual field of view. Simultaneously, based on the previously constructed geometric defocus tendency model, illumination quality attenuation model, and multi-domain coupled imaging fidelity model, the overall imaging fidelity is calculated in real time. This value reflects the overall quality of the current image, including sharpness and brightness uniformity. Furthermore, the controller also obtains the field-of-view alignment deviation coefficient based on the field-of-view alignment deviation model. This coefficient quantifies the degree of physical offset between the camera's field of view center and the target area. Ideal optical normal projection angle. The 3D model of the workpiece is pre-planned. The controller inputs these real-time acquired parameters into the camera angle optimization model to calculate the target camera's viewing angle. .

[0084] Logarithmic term in the model Able to determine the overall fidelity of the image The sensitivity of the dynamic adjustment of the pose is adjusted according to the quality of the image. When the fidelity is low, the absolute value of this item increases, and the system will increase the adjustment force to quickly improve the imaging effect.

[0085] At the same time, the denominator term A field deviation suppression coefficient was introduced. Alignment deviation coefficient with field of view The product of these factors, acting as a constraint factor on the attitude adjustment amplitude, automatically suppresses the attitude adjustment step size when the field-of-view alignment deviation is large. This prevents the target area from leaving the effective field of view due to blind attitude adjustments, ensuring the stability of the attitude adjustment process. Finally, the sinusoidal difference term... Not only does it clarify the direction of attitude adjustment, but it also utilizes the characteristics of the sine function to provide flexible adjustment when the angle deviation is large, avoiding the risk of overshoot or mechanical collision that may occur when the multi-axis motion mechanism 2 makes large-scale adjustments. This achieves smooth and precise convergence of the camera attitude. In this way, the controller can intelligently drive the multi-axis motion mechanism 2 to adjust the attitude according to the real-time imaging quality and field of view alignment, so that the camera always stays at the best observation angle, thus effectively solving the technical problem that the camera attitude is difficult to adaptively optimize in traditional detection.

[0086] The controller acquires the target camera's field of view. Then, the camera's real-time working distance was set. Ideal focus reference distance The difference As the Z-axis displacement compensation amount, the real-time physical offset The displacement compensation is decomposed into X-axis and Y-axis displacements, combined with the target camera's line-of-sight angle. The kinematics inverse kinematics module of the controller is uniformly converted into multi-axis displacement and rotation control commands. The multi-axis motion mechanism 2 is driven by the multi-axis servo driver to perform up-and-down sliding, left-and-right movement and angle deflection, so as to perform adaptive spatial displacement and attitude adjustment closed-loop control.

[0087] When encountering physical conditions such as the multi-axis motion mechanism 2 experiencing overshoot collision due to mechanical inertia during large-scale dynamic pose adjustment of the camera, or the servo motor current overload caused by instantaneous high load, the controller executes the following steps: S91: The controller extracts the target camera's viewing angle; S92: The controller extracts the real-time working distance of the camera and the ideal focusing reference distance, calculates the difference between the real-time working distance of the camera and the ideal focusing reference distance to generate the Z-axis displacement compensation amount, and at the same time, the controller extracts the real-time physical offset amount and decomposes the real-time physical offset amount into the X-axis displacement compensation amount and the Y-axis displacement compensation amount through spatial geometric projection. S93: The controller inputs the target camera viewing angle obtained in step S91, the Z-axis displacement compensation amount, X-axis displacement compensation amount and Y-axis displacement compensation amount generated in step S92 into the controller's inverse kinematics module, and converts them into multi-degree-of-freedom displacement and rotation control commands. S94: The controller sends the multi-degree-of-freedom displacement and rotation control commands generated in step S93 to the multi-axis servo driver that drives the multi-axis motion mechanism 2. S95: The multi-axis servo driver drives the multi-axis motion mechanism 2 to synchronously perform up-and-down sliding, left-and-right movement and angle deflection actions according to the multi-degree-of-freedom displacement and rotation control commands in step S94. S96: When performing a large-angle deflection action in step S95, the multi-axis motion mechanism 2 is subject to the physical constraint of the nonlinear flexible saturation limiting output generated by the sinusoidal difference term in the camera angle optimization model. This achieves the avoidance effect of suppressing the sudden response of the servo driver during large-amplitude attitude adjustment, preventing the multi-axis motion mechanism 2 from overshooting mechanical collisions and motor current overload, and ensuring that the camera converges smoothly and accurately to the best observation posture.

[0088] During large-scale dynamic attitude adjustment based on imaging fidelity, the multi-axis motion mechanism 2 is highly susceptible to overshoot collisions due to mechanical inertia, or current overload issues caused by instantaneous high loads on the servo motors. To ensure the physical safety of equipment operation, the controller executes the following multi-degree-of-freedom fusion control logic: First, the controller extracts the target camera's view angle from the output of the camera angle optimization model. Simultaneously, the controller extracts the camera's real-time working distance. Ideal focus reference distance Calculate the difference to generate the Z-axis displacement compensation amount and extract the real-time physical offset. The X-axis displacement compensation and Y-axis displacement compensation are decomposed.

[0089] Next, the controller sets the target camera's field of view angle as described above. The Z-axis, X-axis, and Y-axis displacement compensation values ​​are uniformly input to the internal inverse kinematics module. After homogeneous coordinate transformation, they are converted into multi-degree-of-freedom displacement and rotation control commands, which are then sent to the multi-axis servo driver. Based on these commands, the multi-axis servo driver drives the multi-axis motion mechanism 2 to synchronously execute up-and-down sliding, left-and-right movement, and angular deflection actions.

[0090] Specifically, when the multi-axis motion mechanism 2 performs the aforementioned large-angle deflection action, the camera angle optimization model incorporates a sinusoidal difference term. Due to physical constraints, when the angle deviation is too large, the output of the model at the bottom layer of the controller will automatically generate nonlinear flexible saturation limiting, which limits the instantaneous increment of the control command. This mechanism suppresses the sudden response of the servo driver during large-amplitude attitude adjustment from the bottom layer of the algorithm, successfully preventing the multi-axis motion mechanism 2 from overshooting mechanical collisions and motor current overload, and achieving the physical avoidance effect of ensuring that the camera converges smoothly, accurately and safely to the best observation attitude.

[0091] The core concept of this application lies in constructing a vision-based online inspection system with multi-dimensional real-time perception and adaptive closed-loop attitude adjustment capabilities. Addressing the severe defocusing and blurring issues caused by mechanism vibration, guide rail deformation, and workpiece placement tolerances during dynamic scanning, a "geometric defocusing tendency model" is constructed for real-time perception and quantification by acquiring the camera's real-time working distance and dynamic parallelism deviation angle. To address the issue of blind spots caused by mechanical assembly gaps and repetitive positioning errors leading to targets leaving the effective field of view, a "field of view alignment deviation model" is constructed by extracting physical offsets and positioning errors in real time, dynamically constraining the field of view boundary and driving the mechanism to perform rigid displacement compensation. Finally, to address the problem that the high reflectivity of magnetic steel surfaces easily generates light spots or shadows that obscure true defects during dynamic attitude adjustment, a "lighting quality attenuation model" and a "multi-domain coupled imaging fidelity model" are constructed to achieve quantitative feedback on complex lighting environments and synchronous deflection compensation of the light source attitude.

[0092] Finally, the aforementioned multi-dimensional damage factors and deviations are comprehensively input into the "camera angle optimization model" and transformed into multi-degree-of-freedom control commands. These commands drive the multi-axis motion mechanism to complete the closed-loop adjustment of spatial position and attitude in a flexible limiting manner. Through these technical means, not only are optical defocus and blind spots caused by mechanical dynamic errors fundamentally overcome, and the limitations of open-loop isolation between the light source and camera in traditional equipment are broken, but also overshoot collisions of the mechanism are successfully prevented. This ensures that the system can always maintain the best lighting quality and optimal observation attitude stably and accurately under high-speed continuous detection conditions, and significantly improves the comprehensiveness, accuracy and reliability of online detection of minute defects in permanent magnet steel.

[0093] The foregoing has shown and described the basic principles, main features, and advantages of the present invention. Those skilled in the art should understand that the present invention is not limited to the above embodiments. The embodiments and descriptions in the specification are merely illustrative of the principles of the invention. Various changes and modifications can be made to the invention without departing from its spirit and scope, and all such changes and modifications fall within the scope of the present invention as claimed. The scope of protection of the present invention is defined by the appended claims and their equivalents.

Claims

1. A visual online inspection device for appearance defects of permanent magnet steel, comprising a visual inspection device (1), a multi-axis motion mechanism (2) mounted on the visual inspection device (1) and capable of sliding up and down and moving left and right, a visual inspection mechanism (3) mounted on the multi-axis motion mechanism (2), and a controller, wherein the visual inspection mechanism (3) includes a camera and a light source; characterized in that: The controller is used to perform the following operations: S11: Obtain the real-time working distance of the camera and the dynamic parallelism deviation angle between the camera target surface and the workpiece surface, and construct a geometric defocus tendency model to output the geometric defocus tendency coefficient. S12: Obtain the real-time physical offset between the swing axis and the camera's field of view center and the repetitive positioning spatial error of the multi-axis motion mechanism (2), and construct a field of view alignment deviation model to output the field of view alignment deviation coefficient; S13: Obtain the incident azimuth angle error of the light source and the uniformity coefficient of the light source illuminance, construct a lighting quality attenuation model to output the lighting quality attenuation coefficient; S14: Obtain the depth-of-field boundary sharpness loss rate, highlight area ratio, and highlight area normalized center distance. Combine the geometric defocus tendency coefficient and illumination quality attenuation coefficient to construct a multi-domain coupled imaging fidelity model to output the overall imaging fidelity. S15: Based on the overall image fidelity, field of view alignment deviation coefficient and the current actual viewing angle of the camera, a camera angle optimization model is constructed to output the target camera viewing angle. Combined with the deviation between the real-time working distance of the camera and the ideal focusing reference distance, as well as the real-time physical offset, it is converted into multi-degree-of-freedom control commands to drive the multi-axis motion mechanism (2) to adjust its spatial position and attitude.

2. The visual online inspection device for appearance defects of permanent magnet steel according to claim 1, characterized in that: The geometric defocus tendency model is as follows: The axial position deviation between the camera's real-time working distance and the ideal focusing reference distance, as well as the angular attitude deviation between the dynamic parallelism deviation angle and the maximum allowable parallelism error, are extracted. The deviation features of the two dimensions are normalized based on their corresponding tolerance boundaries, and then nonlinearly mapped and fused with preset weight coefficients to output a geometric defocus tendency coefficient that characterizes the degree of optical defocus risk caused by spatial geometric pose deviation.

3. The visual online inspection device for appearance defects of permanent magnet steel according to claim 2, characterized in that: The field-of-view alignment deviation model is as follows: Based on the statistical distribution characteristics of the repetitive positioning spatial error of the multi-axis motion mechanism (2), a statistical confidence contraction mechanism is introduced to dynamically constrain the effective radius of the camera's physical field of view at the current working distance and obtain the dynamic effective field of view boundary; establish the relative proportional mapping relationship between the real-time physical offset and the dynamic effective field of view boundary, and output the field of view alignment deviation coefficient to characterize the severity of the deviation of the camera's field of view center from the target detection area through nonlinear saturation evaluation logic.

4. The visual online inspection device for appearance defects of permanent magnet steel according to claim 3, characterized in that: When encountering a physical condition during dynamic scanning where the mechanical assembly clearance and spatial repetitive positioning error of the multi-axis motion mechanism (2) cause a transient physical offset between the center of motion of the mechanism and the center of the camera's field of view, resulting in the target defect area being removed from the effective field of view and creating a detection blind zone, the controller executes the following steps: S41: The controller extracts the field of view alignment deviation coefficient and compares the field of view alignment deviation coefficient with the preset field of view offset safety threshold; S42: When the field of view alignment deviation coefficient in step S41 is greater than the preset field of view offset safety threshold, the controller extracts the real-time physical offset and decomposes the real-time physical offset into X-axis displacement compensation and Y-axis displacement compensation. S43: The controller generates a planar anti-deviation displacement command based on the X-axis displacement compensation amount and Y-axis displacement compensation amount obtained from the decomposition in step S42, and sends the planar anti-deviation displacement command to the multi-axis servo driver that drives the multi-axis motion mechanism (2). S44: The multi-axis servo driver drives the multi-axis motion mechanism (2) according to the planar anti-deviation displacement command received in step S43, and performs rigid displacement compensation action to control the left and right movement of the camera. S45: Achieves the effect of offsetting the risk of field of view shift and relocking the target defect area within the effective radius of the camera's physical field of view, thereby fundamentally preventing the missed detection of small defects due to their departure from the field of view boundary.

5. The visual online inspection device for appearance defects of permanent magnet steel according to claim 4, characterized in that: The lighting quality degradation model is as follows: A nonlinear attenuation trend term for illumination quality with the incident azimuth angle error of the light source as the independent variable is constructed, and the boundary of the attenuation process is fitted and constrained by the light source attenuation rate factor and the nonlinear attenuation shape factor. The collected light source illuminance uniformity coefficient is used as a dynamic feedback variable and fused with the nonlinear decay trend term of light quality to calculate and output a light quality decay coefficient that characterizes the degree to which the current dynamic lighting environment deviates from the ideal lighting state.

6. The visual online inspection device for appearance defects of permanent magnet steel according to claim 5, characterized in that: When encountering a physical condition where the highly reflective properties of permanent magnet surfaces are extremely sensitive to illumination angles, and camera movement causes a change in attitude, resulting in the formation of high-intensity light spots or shadows on the workpiece surface due to the asynchronous azimuth angles of independent light sources, thus completely masking actual surface defects, the controller executes the following steps: S61: The controller extracts the lighting quality attenuation coefficient and compares it with the set lighting quality failure warning threshold. S62: When the lighting quality attenuation coefficient in step S61 is greater than the set lighting quality failure warning threshold, the controller extracts the incident azimuth angle error of the light source and converts the incident azimuth angle error of the light source into a light source attitude deflection compensation command. S63: The controller sends the light source attitude deflection compensation command generated in step S62 to the independent light source rotation axis that controls the light source action. S64: The independent light source rotation axis performs a light source angle deflection action according to the light source attitude deflection compensation command received in step S63, so as to compensate for the light source incident azimuth angle error in physical space. S65: Achieves the effect of eliminating local overexposed or underexposed areas on the workpiece surface and maintaining the best lighting quality in high-speed dynamic inspection, ensuring that real surface defects are not covered by light spots.

7. The visual online inspection device for appearance defects of permanent magnet steel according to claim 6, characterized in that: The multi-domain coupled imaging fidelity model is as follows: The optical defocusing damage dimension is constructed by correlating the geometric defocusing tendency coefficient with the depth-of-field boundary sharpness loss rate. The lighting quality damage dimension is constructed by correlating the illumination quality attenuation coefficient, the highlight area ratio, and the normalized center distance of the highlight area with a position penalty mechanism. Based on the set orthogonal constraint weight mechanism, the optical defocusing damage dimension and the lighting quality damage dimension are fused in a multi-dimensional space to finally output the overall imaging fidelity, which comprehensively represents the current overall imaging quality.

8. The visual online inspection device for appearance defects of permanent magnet steel according to claim 7, characterized in that: The camera angle optimization model is as follows: The angular deviation between the pre-planned optical normal projection angle of the workpiece and the current actual viewing angle of the camera is used as the basic attitude adjustment guide; Imaging overall fidelity is introduced as a dynamic excitation factor to adaptively adjust the response sensitivity of attitude optimization; the field of view alignment deviation coefficient is used as a safety suppression factor to constrain the adjustment range under severe field of view deviation. A nonlinear flexible limiting mechanism is introduced to smooth the comprehensive adjustment amount for large angular deviations, and the final output is the target camera line of view angle used to guide the control execution.

9. The visual online inspection device for appearance defects of permanent magnet steel according to claim 8, characterized in that: When encountering physical conditions such as the camera overshooting collision due to mechanical inertia during large-scale dynamic posture adjustment, or the servo motor current overload caused by instantaneous high load, the controller performs the following steps: S91: Target camera viewing angle extracted by the controller; S92: The controller extracts the real-time working distance of the camera and the ideal focusing reference distance, calculates the difference between the real-time working distance of the camera and the ideal focusing reference distance to generate the Z-axis displacement compensation amount, and at the same time, the controller extracts the real-time physical offset amount and decomposes the real-time physical offset amount into the X-axis displacement compensation amount and the Y-axis displacement compensation amount through spatial geometric projection. S93: The controller inputs the target camera viewing angle obtained in step S91, the Z-axis displacement compensation amount, X-axis displacement compensation amount and Y-axis displacement compensation amount generated in step S92 into the controller's inverse kinematics module, and converts them into multi-degree-of-freedom displacement and rotation control commands. S94: The controller sends the multi-degree-of-freedom displacement and rotation control commands generated in step S93 to the multi-axis servo driver that drives the multi-axis motion mechanism (2); S95: The multi-axis servo driver drives the multi-axis motion mechanism (2) to synchronously perform up-and-down sliding, left-and-right movement and angle deflection actions according to the multi-degree-of-freedom displacement and rotation control commands in step S94. S96: When performing a large-angle deflection action in step S95, the multi-axis motion mechanism (2) is subject to the physical constraint of the nonlinear flexible saturation limiting output generated by the sinusoidal difference term in the camera angle optimization model. This achieves the avoidance effect of suppressing the sudden response of the servo driver during the large-amplitude attitude adjustment process, preventing the multi-axis motion mechanism (2) from overshooting mechanical collisions and motor current overload, and ensuring that the camera converges smoothly and accurately to the best observation posture.