A method, system and device for constructing an industrial vision intelligent agent based on a workflow full life cycle driving, and a storage medium

CN123015423APending Publication Date: 2026-10-30COBO TECHNOLOGY (SUZHOU) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611146595.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-30
Publication Date
2026-10-30

AI Technical Summary

Technical Problem

[0005]本发明旨在解决现有工业视觉系统中成像硬件参数游离于工程生命周期之外、调机高度依赖人工经验、运行期光学漂移缺乏自诊断与自补偿手段、参数优化经验无法沉淀复用的技术问题,提供一种基于工作流全生命周期驱动的工业视觉智能体构建方法、系统、设备及存储介质

Benefits of technology

[0018]本发明将光源通道电流、光源频闪脉宽、相机曝光时间、相机增益与液态变焦镜头调焦电压等成像硬件参数与算法参数统一纳入工作流参数集合,使长期依赖人工经验的调光、对焦与参数整定过程转化为可自动执行、可记录、可回溯的成像寻优子工作流,明显缩短新产品导入阶段的现场调机时间,降低对专业调试人员的依赖;借助基准标定块的灰阶差值与清晰度评价值构成的双通道物理量监测,配合运行判定合格率统计,能够在生产中把光照漂移、离焦漂移与来料变化相互区分,避免盲目调参或整线停机排查;逐通道执行的等比调整在检测间隙内自动恢复各光源通道的基线光通量贡献,使发光二极管光衰、镜头污染等缓变劣化被持续抵消,检测指标长期保持稳定;以净偏移比例作为光学退化程度的量化度量并据此触发重新寻优,使版本演化由被动响应转变为主动调度,配合按参数层级选择的回放比较与交替实拍比较,版本切换的正确性得到同条件对比数据的支撑;寻优轨迹、补偿记录与最优光学配方沉淀入知识库并被后续同类任务继承,寻优所需的评估次数随工程积累不断减少,工业视觉平台由此获得持续成长能力。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123015423A_ABST
    Figure CN123015423A_ABST
Patent Text Reader

Abstract

The present application relates to the field of industrial machine vision, and discloses a kind of industrial vision intelligent agent construction method, system, equipment and storage medium based on work flow full life cycle driving.The method comprises: imaging hardware parameters and algorithm parameters are unified as work flow parameter set and written into work flow file, and its change is added to evolution record together with performance data;Optimization sub-work flow of imaging is executed, and optimal optical formula and baseline data are obtained by interval determination, focusing optimization, channel current optimization and algorithm parameter fine adjustment;In running, according to the gray scale difference of reference calibration block, definition evaluation value and qualified rate attribution drift, isometric adjustment, focusing recovery or parameter optimization is respectively executed;When net deviation ratio exceeds limit, new version is generated by re-optimization, and switching or rollback is selected after parameter level selection, channel comparison and comparison;Optimal optical formula is stored in knowledge base for subsequent task inheritance, and full life cycle autonomous management of imaging parameters is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of industrial machine vision technology, and in particular to a method, system, device and storage medium for constructing industrial vision intelligent agents based on a workflow-driven full lifecycle. Background Technology

[0002] Industrial machine vision systems are widely used in positioning, measurement, identification, and defect detection in industries such as electronics manufacturing, new energy, automotive parts, and semiconductors. Existing industrial vision software generally adopts a graphical workflow editing method to organize the inspection process, connecting functional modules such as image acquisition, template positioning, spot analysis, and character recognition into an executable inspection project, and can save parameters such as camera exposure and gain in the project file and load them with the project.

[0003] However, the management of imaging hardware parameters in such systems remains at the static storage level: light source channel current, flicker pulse width, focusing parameters, etc., still rely on manual adjustments by debugging personnel based on experience. The debugging process itself is neither recorded nor reused, and the introduction of new products often requires several hours of repeated on-site trials. After entering the production operation stage, slowly changing factors such as LED light decay, lens contamination, and temperature drift of liquid zoom lenses continuously alter imaging conditions. Existing systems can usually only be manually checked after the detection indicators have significantly deteriorated. It is difficult to distinguish between illumination drift, defocus drift, and changes in incoming materials, and there is also a lack of means to automatically compensate during production breaks. In addition, although constant light control devices can maintain the brightness of the light source with the help of independent photometric probes, their feedback is outside the scope of vision engineering. The compensation behavior does not generate traceable version records and cannot be coordinated with the verification, rollback, and knowledge reuse mechanisms of the detection process.

[0004] Therefore, there is a need for a method to construct an industrial vision intelligent agent that integrates imaging hardware parameters into the unified management of the entire workflow lifecycle and has the ability to self-diagnose drift, self-compensate, and evolve versions. Summary of the Invention

[0005] This invention aims to solve the technical problems in existing industrial vision systems, such as imaging hardware parameters being detached from the engineering lifecycle, machine adjustment being highly dependent on human experience, lack of self-diagnosis and self-compensation methods for optical drift during operation, and the inability to accumulate and reuse parameter optimization experience. It provides a method, system, device, and storage medium for constructing an industrial vision intelligent agent based on a workflow-driven full lifecycle.

[0006] The technical solution adopted in this invention is as follows:

[0007] A method for constructing an industrial vision intelligent agent based on a workflow-driven full lifecycle is proposed and applied to an industrial vision intelligent agent system. The system includes a workflow planning module, a workflow verification module, an industrial vision operation module, a workflow repository, a knowledge base, an industrial camera, a programmable light source controller, a multi-channel LED light source, a liquid zoom lens, and a reference calibration block. The multi-channel LED light source includes multiple independently adjustable light source channels. The reference calibration block surface has high-reflectivity high-grayscale areas, low-reflectivity low-grayscale areas, and alternating black and white edge pattern areas. The method includes the following steps: receiving industrial inspection tasks and generating task objects; and jointly defining the imaging hardware parameters of the image acquisition tool and the algorithm parameters of each algorithm tool. The workflow parameters are set and written to the workflow file. Imaging hardware parameters include light source channel current, light source flicker pulse width, camera exposure time, camera gain, and liquid zoom lens focusing voltage. Each imaging hardware parameter and algorithm parameter has its upper and lower limits and adjustment step size recorded. Each change in the workflow parameter set, along with corresponding performance data, is appended to the workflow evolution record in chronological order. The imaging optimization sub-workflow is executed, sequentially determining the optimization range, focusing, channel current, and fine-tuning the algorithm parameters. This determines the optimal optical formula composed of the imaging hardware parameter values ​​and the optimal values ​​for the algorithm parameters, generating a new version of the formal workflow and recording baseline data, which includes at least the baseline current of each light source channel. During operation, grayscale difference and sharpness evaluation value are extracted frame by frame, and the operation pass rate is calculated. The grayscale difference is the difference between the average grayscale value of the high grayscale area and the average grayscale value of the low grayscale area. The sharpness evaluation value is the mean squared Sobel gradient of the edge pattern area. The operation pass rate is the ratio of the number of workpieces that pass the judgment to the total number of inspected workpieces. Drift attribution is performed based on grayscale difference, sharpness evaluation value, and operation pass rate. When it is determined to be illumination drift, the current of each light source channel is adjusted proportionally according to the change of grayscale difference relative to the baseline under single-channel illumination state to restore the baseline luminous flux contribution of each light source channel. When it is determined to be defocus drift, focus restoration is performed. When it is determined to be due to changes in incoming materials or algorithm parameters, algorithm parameter optimization is generated. The net offset ratio is defined as the absolute value of the difference between the current current of the light source channel and the baseline current, divided by the baseline current. When the net offset ratio of any light source channel reaches the preset offset threshold, or the current of any light source channel reaches the upper limit of the value, or the offset of the focusing voltage of the liquid zoom lens relative to the value in the optimal optical formula reaches the preset offset ratio, the imaging optimization sub-workflow is re-executed to generate a new version of the formal workflow. The verification channel is selected according to the parameter level involved in the version change for version comparison, and version switching or rollback is performed based on the comparison results. The optimal optical formula is associated with the workpiece material category code and surface type category code in the task object and stored in the knowledge base for subsequent industrial inspection tasks to inherit and narrow the optimization range, forming a closed loop of the entire workflow lifecycle.

[0008] Furthermore, the task objects include the detection target, workpiece material category code, surface type category code, workpiece moving speed, pixel equivalent, and cycle time requirements. Pixel equivalent is the object surface size corresponding to a single pixel. The workflow file also includes a running configuration, which includes setting the camera gamma factor to 1, disabling the camera's automatic exposure and automatic gain functions, driving the light source in constant current mode, and ensuring the upper limit of the light source channel current is within the LED's rated linear range. The workflow planning module retrieves historical optical recipes from the knowledge base based on the task objects. The retrieval criteria are that the workpiece material category code and surface type category code are consistent with the task objects. Among the historical optical recipes that meet the retrieval criteria, the one with the highest historical imaging quality evaluation value is selected as the inherited optical recipe. When the number of historical optical recipes that meet the retrieval criteria is 0, the optical recipe is determined by the imaging optimization sub-workflow. The workflow planning module generates a workflow blueprint. The blueprint includes Tool node types, Tool connection relationships, recommended algorithm parameters, inherited optical recipes, preset values ​​for light source flicker pulse width, camera exposure time equal to the sum of the preset values ​​for light source flicker pulse width and preset margin, and the lowest camera gain. The preset values ​​for light source flicker pulse width are determined based on the workpiece movement speed and pixel equivalent, ensuring that the workpiece displacement on the image during flicker is less than one pixel. The camera exposure window completely covers the light source flicker pulse, and camera exposure and light source flicker are synchronously triggered by the same hardware trigger signal. The workflow verification module sequentially performs Tool existence checks, Tool input / output connection relationship checks, parameter value range checks, motion blur constraint checks, and industrial communication configuration checks on the workflow blueprint. After successful verification, the first version of the formal workflow is generated and stored in the workflow repository. The knowledge base also associates and stores the effective current range, imaging optimization trajectory, compensation records, and version evolution relationships of each light source channel.

[0009] Further, the optimization interval determination includes: performing a current scan on each light source channel individually, illuminating only the scanned light source channel, increasing the current by adjustment steps starting from the lower limit of the value, and determining the current interval where the average gray level of the high gray level area falls into the preset gray level band as the effective current interval of the scanned light source channel. The preset gray level band is the single-channel target gray level band, which is calculated by adjusting the target gray level range of the high gray level area according to the number of light source channels under the full channel illumination state; when the inherited optical formula exists and the knowledge base records the corresponding effective current interval, the effective current interval is read and a single-channel illumination acquisition is performed once at the midpoint of the interval for verification; when the inherited optical formula exists... The optimization interval is the intersection of the interval centered on the light source channel current in the inherited optical formula and the effective current interval with a width equal to the effective current interval width multiplied by a preset narrowing ratio. In other cases, the optimization interval is the effective current interval. When the light source channel current reaches the upper limit and the average gray level of the high gray level area is lower than the preset gray level band lower limit, a graded relaxation is performed: first, the light source flicker pulse width is relaxed to the maximum value allowed by the motion blur constraint, the camera exposure time is kept as the sum of the light source flicker pulse width and the preset margin, and then the camera gain is increased step by step. After each relaxation, the motion blur constraint check is re-performed. When the camera gain reaches the upper limit, an optical scheme change prompt is generated.

[0010] Furthermore, focus optimization includes: placing the current of each light source channel at the midpoint of its respective optimization interval; when the inherited optical formula exists, taking the liquid zoom lens focusing voltage in the inherited optical formula as the center, evaluating the sharpness evaluation value point by point within a preset local range with fine step intervals; when the maximum value of the sharpness evaluation value is located at the endpoint of the preset local range, switching to full-range search; the full-range search first traverses the entire value range of the liquid zoom lens focusing voltage with coarse step intervals to determine the peak center, and then evaluates point by point within a coarse step interval on each side of the peak center with fine step intervals; all voltage points are... The focus is adjusted unidirectionally from the low voltage direction. When the target value is exceeded, the focus is first reversed by a preset amount and then moved forward again. Multiple frames are continuously collected at each voltage point and the average of the sharpness evaluation values ​​is taken. The voltage with the largest average sharpness evaluation value is used as the focus optimization result. The focus recovery is centered on the current liquid zoom lens focusing voltage and evaluated point by point in a preset local range with fine step distances. The recovery process is performed step by step in the detection gap between adjacent workpieces. The liquid zoom lens focusing voltage is changed only once in each detection gap. The workpiece detection frame is collected when the liquid zoom lens focusing voltage remains stable.

[0011] Furthermore, the channel current optimization includes: arranging initial combinations of current for each light source channel within the optimization interval using a 3-level orthogonal array adapted to the number of light source channels; the three levels for each light source channel are the lower endpoint, midpoint, and upper endpoint of the optimization interval; acquiring sample images for each initial combination, where the sample images are images of sample workpieces with pre-labeled target and background areas; and evaluating the initial combination only when the 99.5th percentile gray values ​​of the target area, background area, and high grayscale area are all less than or equal to the maximum quantization value multiplied by a preset saturation margin ratio. The imaging quality evaluation value is calculated as the absolute value of the difference between the average gray level of the target area and the average gray level of the background area divided by the standard deviation of the gray level of the background area. Combinations exceeding the saturation margin condition are included in the training sample with a preset penalty value as the imaging quality evaluation value. When all initial combinations exceed the saturation margin condition, the optimization interval is multiplied by a preset reduction ratio and the channel current optimization is re-executed. The channel current of each light source is linearly normalized to the 0-1 interval according to the optimization interval. A Gaussian process regression surrogate model is established using the evaluated combinations and imaging quality evaluation values ​​as training samples. In each round, a preset number of candidate combinations are regenerated by Latin hypercube sampling. The candidate combination with the largest expected improvement value is selected as the next set of combinations to be evaluated according to the expected improvement criterion, until the increment of the maximum imaging quality evaluation value in two consecutive rounds is less than the preset convergence threshold or the cumulative number of evaluations reaches the preset upper limit. After convergence, when the maximum imaging quality evaluation value is lower than the preset quality lower limit or the average gray level of the target area is lower than the preset target gray level lower limit, the channel current optimization is re-executed after relaxing in a graded relaxation order.

[0012] Furthermore, the fine-tuning of algorithm parameters includes: dividing the sample workpieces into an optimization set and a validation set according to a preset division ratio; performing two rounds of item-by-item search on the algorithm parameters of each algorithm tool in the tool topology order on the optimization set, taking the maximum sample recognition rate as the criterion. The sample recognition rate is the ratio of the number of sample workpieces whose judgment results match the pre-known category to the total number of sample workpieces. When the maximum value of the sample recognition rate corresponds to a continuous value interval, the midpoint of the interval is taken; verifying the sample recognition rate on the validation set, if the verification result reaches the preset pass line, entering baseline calibration; if the verification result is lower than the preset pass line, expanding the sample workpieces and... The algorithm parameters are re-tuned, and an optimization failure message is generated when the number of retry attempts reaches the preset maximum number of retries. Before baseline calibration, a linear area verification is performed: the 99.5th percentile gray value of the high grayscale area is less than or equal to the maximum quantization value multiplied by the preset saturation margin ratio, and the average gray value of the low grayscale area is greater than the preset low grayscale lower limit. If either condition is exceeded, the entire optimization range is multiplied by the preset reduction ratio and the channel current optimization is re-executed. The baseline data also includes the baseline mean and standard deviation of the grayscale difference under the full channel illumination state, the baseline value of the grayscale difference and the baseline value of the sharpness evaluation value under the single channel illumination state of each light source channel.

[0013] Furthermore, drift attribution is performed in a fixed priority order of illumination, focus, and process. The grayscale extraction region for grayscale difference is the center of both the high and low grayscale areas, with a distance from the region boundary greater than the preset maximum blur radius. An exponentially weighted moving average control chart is used to monitor the grayscale difference under full-channel illumination. When the control chart exceeds the limit, it is determined to be illumination drift. When the grayscale difference is within the control limit and the sharpness evaluation value is below the lower threshold, it is determined to be defocus drift. The lower threshold is the baseline value of the sharpness evaluation value multiplied by the preset sharpness ratio. When both the grayscale difference and the sharpness evaluation value are within their respective limits and the operation judgment pass rate exceeds the operation judgment... When determining the baseline band for the pass rate, the cause is judged to be changes in incoming materials or algorithm parameters. The baseline band for the pass rate is determined based on the pass rate statistics at the initial stage of production. Proportional adjustment includes: individually flashing and acquiring calibration frames for each channel within the detection gap between adjacent workpieces to obtain the current value of the grayscale difference under single-channel illumination. For each light source channel, the adjusted light source channel current is equal to the unadjusted light source channel current multiplied by the ratio of the baseline value of the grayscale difference under single-channel illumination to the current value of the grayscale difference under single-channel illumination. The adjustment result is limited to the upper and lower limits of the value range. After compensation, the grayscale difference under full-channel illumination is remeasured, and the remeasured value is compared with... Compensation is considered complete when the baseline mean deviation is within 3%. If the deviation still exceeds 3% after three repetitions, algorithm parameter optimization suggestions are generated. After compensation, the pass rate is recalculated. If the pass rate exceeds the baseline, algorithm parameter optimization suggestions are generated again. When the range of compensation ratios for each light source channel is less than the preset consistency threshold, common optical path attenuation is identified, and a maintenance prompt is generated. In version comparison, version changes involving only algorithm parameters are compared using playback. That is, two versions of algorithm parameters are run in parallel on the continuously saved production images, and images with different judgment results are manually reviewed. Version changes involving optical formulas are also compared. Alternating real-shot comparison is adopted, that is, two consecutive acquisitions are triggered within the detection window of the same workpiece, and imaging and judgment are performed according to two versions of optical formula respectively. If the interval between the two triggers is greater than the larger of the preset stabilization time of the liquid zoom lens and the establishment time of the light source current, and the detection window duration is less than the duration required for two acquisitions, or if the workpiece displacement within the interval between the two triggers causes the target area to deviate beyond the preset positioning tolerance, the two versions are applied alternately for each group of workpieces in the preset group. After rollback, automatic re-optimization under the same trigger condition is paused within the preset suppression period and maintenance prompts are generated. After the version switch is completed, the baseline data is re-recorded and the operation judgment pass rate baseline band is rebuilt.

[0014] An industrial vision intelligent agent system includes a workflow planning module, a workflow verification module, an industrial vision operation module, a workflow evolution management module, a workflow repository, a knowledge base, an industrial camera, a programmable light source controller, a multi-channel LED light source, a liquid zoom lens, and a reference calibration block. The programmable light source controller supports switching the light source channel current and the light source flicker pulse width frame by frame according to the trigger sequence. The industrial vision intelligent agent system is configured to execute the above-mentioned industrial vision intelligent agent construction method based on the full life cycle driven by the workflow.

[0015] An electronic device includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the steps of the above-described method for constructing an industrial visual intelligent agent based on a workflow-driven full lifecycle.

[0016] A computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the above-described method for constructing an industrial vision intelligent agent based on a workflow-driven full lifecycle.

[0017] By adopting the above technical solution, the present invention has produced the following beneficial effects:

[0018] This invention integrates imaging hardware parameters and algorithm parameters, such as light source channel current, light source flicker pulse width, camera exposure time, camera gain, and liquid zoom lens focusing voltage, into a unified workflow parameter set. This transforms the long-standing manual experience-dependent processes of light adjustment, focusing, and parameter tuning into an automated, recordable, and traceable imaging optimization sub-workflow, significantly shortening on-site setup time during new product introduction and reducing reliance on professional debugging personnel. By utilizing dual-channel physical quantity monitoring composed of grayscale difference and sharpness evaluation value from the benchmark calibration block, combined with operational pass rate statistics, it is possible to distinguish between illumination drift, defocus drift, and incoming material changes during production, avoiding blind parameter adjustments or complete line shutdowns for troubleshooting. The proportional adjustment performed channel by channel automatically restores the baseline luminous flux contribution of each light source channel within the detection interval, continuously offsetting the gradual degradation such as LED light decay and lens contamination, and keeping the detection indicators stable over a long period of time. The net offset ratio is used as a quantitative measure of the degree of optical degradation and triggers re-optimization accordingly, transforming version evolution from a passive response to an active scheduling. Combined with playback comparison selected according to parameter level and alternating real-world comparison, the correctness of version switching is supported by comparative data under the same conditions. The optimization trajectory, compensation records, and optimal optical formula are deposited into the knowledge base and inherited by subsequent similar tasks. The number of evaluations required for optimization is continuously reduced with engineering accumulation, thereby enabling the industrial vision platform to achieve continuous growth. Attached Figure Description

[0019] Figure 1 This is a schematic diagram of the imaging optical path and reference calibration block arrangement of the industrial vision intelligent agent system in this embodiment of the invention;

[0020] Figure 2 This is a schematic diagram of the surface layout and grayscale extraction area setting of the reference calibration block in an embodiment of the present invention;

[0021] Figure 3 This is a schematic diagram illustrating the linear relationship between grayscale difference and irradiance, and the principle of additive common-mode offset cancellation in an embodiment of the present invention.

[0022] Figure 4 This is a timing diagram showing the synchronization of the hardware trigger signal, the light source strobe pulse, and the camera exposure window in an embodiment of the present invention.

[0023] Figure 5 This is a schematic diagram of the focus optimization process in an embodiment of the present invention, wherein (a) is a full-range coarse scan and peak area fine scan curve of the sharpness evaluation value as the focusing voltage of the liquid zoom lens changes, and (b) is a schematic diagram of the hysteresis characteristics and unidirectional approach setting method of the liquid zoom lens.

[0024] Figure 6 This is a curve illustrating the convergence process of channel current optimization in an embodiment of the present invention.

[0025] Figure 7 This is a schematic diagram of the drift monitoring and compensation process during the operation phase in an embodiment of the present invention, wherein (a) is the exponentially weighted moving average monitoring curve of gray level difference, and (b) is the curve of the change of net offset ratio of each light source channel with the operation time.

[0026] Figure 8 This is a timing diagram of the alternating real-shot comparison in an embodiment of the present invention.

[0027] In the diagram: 1. Industrial camera; 2. Liquid zoom lens; 3. Multi-channel LED light source; 4. Workpiece; 5. Conveyor line; 6. Reference calibration block; 7. Field of view; 8. Programmable light source controller; 9. Hardware trigger signal; 61. High grayscale area; 62. Low grayscale area; 63. Edge pattern area; 64. Grayscale extraction area. Detailed Implementation

[0028] To make the objectives, technical solutions, and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only for explaining the present invention and are not intended to limit the present invention; where there is no conflict, the technical features of the various embodiments can be combined with each other.

[0029] like Figure 1 As shown, the industrial vision intelligent agent system of this embodiment includes an industrial camera 1, a liquid zoom lens 2, a multi-channel LED light source 3, a workpiece 4, a conveyor line 5, a reference calibration block 6, and a programmable light source controller 8 in terms of hardware. Figure 1The diagram also shows the field of view 7 and the transmission path of the hardware trigger signal 9. The industrial camera 1 uses a global shutter, 8-bit quantization area array camera with a resolution of 2448 pixels × 2048 pixels. The gamma factor is set to 1, and both automatic exposure and automatic gain functions are disabled to ensure that the grayscale output operates within the linear response range. The liquid zoom lens 2 is mounted on the imaging optical axis of the industrial camera 1. Its optical power is controlled by the focusing voltage of the liquid zoom lens, which ranges from 0 volts to 70 volts, with a coarse step of 2 volts and a fine step of 0.2 volts. The preset stabilization time required to achieve optical stability after voltage changes is 25 milliseconds. The multi-channel LED light source 3 is a ring light source, divided into four independently adjustable current light source channels along the circumference, covering illumination sectors at 0 degrees, 90 degrees, 180 degrees, and 270 degrees respectively. The current of the light source channels ranges from 0 mA to 1000 mA, with an adjustment step of 1 mA. The light-emitting diode (LED) is driven by a programmable light source controller 8 in a constant-current manner. The light source current settling time is approximately 50 microseconds. The programmable light source controller 8 supports frame-by-frame switching of the light source channel current and the light source flicker pulse width according to the trigger sequence. The hardware trigger signal 9 is generated by a photoelectric switch on the conveyor line 5 and is sent to the programmable light source controller 8, where it is split into two paths to trigger the exposure of the industrial camera 1 and the flicker of the multi-channel LED light source 3, respectively. The two paths originate from the same trigger signal, thus fixing the timing relationship between the exposure window and the flicker pulse. The industrial camera 1 transmits images via a gigabit Ethernet interface, and the total time for exposure, readout, and transmission of a single frame is approximately 35 milliseconds. On the software side, the industrial vision intelligent agent system includes a workflow planning module, a workflow verification module, an industrial vision operation module, a workflow evolution management module, a workflow repository, and a knowledge base. Each module is deployed in software form on the edge industrial control computer. As an optional implementation, the workflow planning module and the knowledge base can also be deployed on a cloud server, allowing the edge side to operate independently based on the existing formal workflow when the network is interrupted.

[0030] The reference calibration block 6 is fixedly installed on a bracket within the field of view 7, separated from the workpiece detection area, and shares the same light source and lens optical path with the workpiece 4. Since the reference calibration block 6 and the workpiece 4 are subject to the same light source aging, lens contamination and ambient temperature effects, the change in grayscale response on the reference calibration block 6 can represent the drift state of the entire optical link, providing a stable reference independent of incoming materials for drift attribution during operation.

[0031] like Figure 2As shown, the reference calibration block 6 is a diffuse reflection calibration plate with constant surface reflectivity. In this embodiment, a sandblasted ceramic calibration plate is used. Its surface has a high-grayscale area 61 with high reflectivity, a low-grayscale area 62 with low reflectivity, and a black and white alternating edge pattern area 63. The diffuse reflectivity of the high-grayscale area 61 is approximately 90%, and that of the low-grayscale area 62 is approximately 10%. Both areas are rectangular regions of 120 pixels × 200 pixels in the image. The edge pattern area 63 is 180 pixels × 200 pixels in the image, containing black and white stripes with a period of 60 pixels, with each black and white stripe occupying 30 pixels. Grayscale extraction areas 64 are respectively set in the high-grayscale area 61 and the low-grayscale area 62. The grayscale extraction area 64 is a 60-pixel × 60-pixel square area at the center of each area, with a distance of 30 pixels from the area boundary, which is greater than the preset maximum diffusion radius. The preset maximum blur radius is the maximum defocus blur radius that occurs when the focusing voltage of the liquid zoom lens varies across its entire range. It is determined by the grayscale profile of the black and white boundary in the edge pattern area 63: the number of pixels that the grayscale crosses as it rises from 10% to 90% of the low value on the profile is taken as the edge diffusion width, and half of this width is the blur radius under that focusing voltage. In this embodiment, the blur radius determined at the furthest point where the focusing voltage deviates from the optimal value is 12 pixels. The reason why the grayscale extraction area 64 is located at the center of each area and maintains a distance of 30 pixels from the area boundary is that defocusing causes the grayscale of each pixel to redistribute within the blur circle. When the blur circle does not cross the grayscale area boundary, the redistribution of grayscale within the area does not change the average grayscale of the area. The optimization interval is determined before focus optimization, at which point the focusing voltage has not yet been set. This method ensures that the average grayscale measurement of the high grayscale area during the current scanning phase is independent of the focusing state. Defocus drift during the operation phase is detected when the sharpness evaluation value drops to the lower threshold. At this point, the blur radius is much smaller than 30 pixels, and the grayscale difference is also independent of the focusing state. Drift attribution is therefore performed according to a fixed priority order of illumination, focusing, and process. The stripe period is set to 60 pixels, and its half-period of 30 pixels is greater than the preset maximum blur radius of 12 pixels, ensuring that the edge diffusion width can be measured under all focusing voltages.

[0032] The grayscale difference is defined as the difference between the average grayscale value of the high grayscale area 61 and the average grayscale value of the low grayscale area 62.

[0033] (1)

[0034] In the formula, ΔG represents the grayscale difference, GH represents the average grayscale of the grayscale extraction region 64 within the high grayscale region 61, and GL represents the average grayscale of the grayscale extraction region 64 within the low grayscale region 62. All three are expressed in grayscale levels. Within the camera's linear response range, the average grayscale of the two grayscale regions and the irradiance satisfy the following:

[0035] (2)

[0036] (3)

[0037] In the formula, E represents the irradiance generated by the light source on the surface of the reference calibration block 6. In this embodiment, the relative value is established with the irradiance corresponding to the optimal optical formula as 1; k represents the comprehensive photoelectric conversion coefficient including lens transmittance, sensor quantum efficiency and circuit gain, that is, the number of gray levels generated per unit relative irradiance; ρH and ρL represent the diffuse reflectance of the high gray level region 61 and the low gray level region 62, respectively; D represents the additive common-mode bias composed of the sensor dark level and uniform stray light, in gray level units. Subtracting equation (2) from equation (3), we get:

[0038] (4)

[0039] Figure 3 This relationship is given, with the horizontal axis representing the relative value of irradiance and the vertical axis representing the grayscale value. The response lines of the high grayscale region 61 and the low grayscale region 62 have the same intercept. In this embodiment, the additive common-mode bias is approximately 20 gray levels, and the overall photoelectric conversion coefficient is approximately 178 gray levels. When the relative irradiance value is 1, the average grayscale value of the high grayscale region is approximately 180 gray levels, the average grayscale value of the low grayscale region is approximately 38 gray levels, and the grayscale difference is approximately 142 gray levels. The difference between the two response lines is proportional to the irradiance. The additive common-mode bias is canceled out during the difference process, and the proportional adjustment can therefore be directly performed according to the ratio of the grayscale difference without the need for separate measurement and subtraction of the dark level. The uniform component of ambient stray light that is independent of reflectivity is also canceled out. Combined with short pulse flicker and short exposure, the residual influence of ambient light can be ignored. As an optional implementation, in situations with strong ambient light, dark frames can be periodically acquired when the light source is off, and the grayscale value of the dark frames can be subtracted from the average grayscale value of the two grayscale regions before calculating the grayscale difference.

[0040] The sharpness rating is used to characterize the image sharpness of the edge pattern region 63, and is calculated using the Tenengrad gradient function, i.e., the mean squared Sobel gradient of the edge pattern region:

[0041] (5)

[0042] In the formula, F represents the sharpness evaluation value; Ω represents the evaluation area within the edge pattern region 63; N represents the total number of pixels within the evaluation area Ω; (i,j) represents the row and column coordinates of the pixel; Gx(i,j) and Gy(i,j) represent the horizontal and vertical gradients obtained by convolving the image with the Sobel operator, respectively. The unit of the sharpness evaluation value is the square of the gray level. The reason for using the mean squared gradient to measure sharpness is that the gradient at the edge of the black and white stripes is sensitive to defocus blur, and the squaring operation amplifies the response difference caused by changes in focus; for stripe patterns with a half-period much larger than the blur scale, the sharpness evaluation value is approximately inversely proportional to the equivalent blur scale, and the blur radius can be inferred from the sharpness evaluation value. The entire calculation involves only two 3×3 convolutions and one summation, which can be completed within a single frame period, meeting the real-time requirements of frame-by-frame monitoring. The sharpness rating changes with light intensity. When the light dims, the edge gradient shrinks as a whole, and the sharpness rating decreases accordingly. Therefore, drift attribution during operation is performed in a fixed priority order of light, focus, and process. Light drift is eliminated or compensated first, and the decrease in sharpness rating can be reliably attributed to defocusing.

[0043] During the task creation phase, the user inputs the industrial inspection task through the human-machine interface, and the industrial vision intelligent agent system generates the task object. Taking the laser-engraved character detection of an anodized aluminum shell as an example, the task object includes: the detection target is the detection of missing and misprinted characters; the workpiece material category code is AL-ANOD-02; the surface type category code is MATT-01; the workpiece moving speed is 200 mm / s; the pixel equivalent is 0.05 mm / pixel; and the cycle time requirement is 120 pieces per minute. The pixel equivalent is the object surface size corresponding to a single pixel, obtained by dividing the pixel size by the optical magnification, and is saved with the workflow file. The imaging hardware parameters of the image acquisition tool and the algorithm parameters of each algorithm tool are jointly defined as the workflow parameter set and written into the workflow file. The workflow file adopts JSON (JavaScript Object Notation) format, but XML, YAML, or binary serialization format can also be used as an optional implementation. Examples of registered imaging hardware parameters are as follows: The lower limit for the light source channel current is 0 mA, the upper limit is 1000 mA, and the adjustment step is 1 mA; the lower limit for the light source flicker pulse width is 10 microseconds, and the upper limit is 500 microseconds; the lower limit for the camera exposure time is 20 microseconds, and the upper limit is 1000 microseconds; the lower limit for the camera gain is 0 dB, the upper limit is 24 dB, and the adjustment step is 6 dB; the lower limit for the liquid zoom lens focusing voltage is 0 volts, and the upper limit is 70 volts. Each change in the workflow parameter set, along with the corresponding performance data, is appended to the workflow evolution record in chronological order. Each record includes a timestamp, parameter name, value before modification, value after modification, and performance data such as the current imaging quality evaluation value, sample recognition rate, or operation pass rate. The reason for using the append method instead of overwriting the historical records is that the complete parameter trajectory is not only the data source for subsequent tasks to inherit the optical formula, but also the basis for fault backtracking and version rollback. Overwriting and saving would cause the intermediate process to be lost, making it impossible to accumulate tuning experience based on this.

[0044] The workflow planning module retrieves historical optical recipes from the knowledge base based on the task object. The retrieval criteria are that both the workpiece material category code and surface type category code are consistent with the task object. The historical optical recipe with the highest historical imaging quality evaluation value among those meeting the retrieval criteria is selected as the inherited optical recipe. When the number of historical optical recipes meeting the retrieval criteria is 0, the optical recipe is determined by the subsequent imaging optimization sub-workflow. The workflow blueprint generated by the workflow planning module includes, in addition to Tool node types, Tool connection relationships, recommended algorithm parameters, and inherited optical recipes, the preset value of the light source flicker pulse width, camera exposure time, and camera gain determined based on motion blur constraints. Under flicker illumination conditions, the image displacement of the workpiece during flicker should be less than one pixel, and the preset value of the light source flicker pulse width must satisfy:

[0045] (6)

[0046] In the formula, tp represents the preset value of the light source flicker pulse width, e represents the pixel equivalent, and v represents the workpiece moving speed. In this embodiment, the pixel equivalent is 0.05 mm / pixel, and the workpiece moving speed is 200 mm / s. From the above formula, the upper limit of the preset value of the light source flicker pulse width is 250 microseconds, so we take 200 microseconds; the preset margin is 40 microseconds and is symmetrically distributed before and after the light source flicker pulse. The camera exposure time is equal to the sum of the preset value of the light source flicker pulse width and the preset margin, i.e., 240 microseconds; the camera gain is set to the lowest level of 0 dB. Figure 4 As shown, after a fixed delay of approximately 40 microseconds following the rising edge of hardware trigger signal 9, the camera exposure window opens and remains open for 240 microseconds. The light source strobe pulse illuminates 20 microseconds after the exposure window opens and remains open for 200 microseconds. The exposure window completely covers the light source strobe pulse. The camera exposure and the light source strobe are synchronously triggered by the same hardware trigger signal. The camera exposure time is set as a follower variable that varies with the light source strobe pulse width and is not used as an independent optimization variable. Under strobe illumination, the image signal quantity is determined by the product of the light source channel current and the light source strobe pulse width. After the exposure window completely covers the light pulse, continuing to extend the exposure time does not increase the effective signal; it only accumulates additional ambient light and dark current. The follower exposure time also reduces the number of optimization variables and avoids confusion between the effects of current, pulse width, and exposure on the total exposure quantity.

[0047] The workflow verification module sequentially performs the following checks on the workflow blueprint: Tool existence check, Tool input / output connection relationship check, parameter value range check, motion fuzz constraint check, and industrial communication configuration check. The motion fuzz constraint check verifies that the workpiece displacement on the image during strobe light is less than one pixel and confirms that the light source strobe pulse width is less than or equal to the camera exposure time. The remaining checks confirm Tool installation and version compatibility, adjacent Tool data type matching, all parameters being between their upper and lower limits, and the output interface configuration being valid. After successful verification, the first version of the official workflow is generated and stored in the workflow repository.

[0048] The first step in the imaging optimization sub-workflow is determining the optimization interval. A current scan is performed individually for each light source channel: only the scanned channel is illuminated, and the current is increased in adjustment steps starting from the lower limit. The change in the average grayscale value of the high grayscale region (61) with the current is recorded. The current interval where the average grayscale value of the high grayscale region falls within the preset grayscale band is determined as the effective current interval for the scanned light source channel. The preset grayscale band is the single-channel target grayscale band, calculated from the target grayscale range of the high grayscale region under full-channel illumination according to the number of light source channels. During the calculation, the additive common-mode bias is first subtracted from the upper and lower limits of the target grayscale range, then divided equally according to the number of light source channels, and finally the additive common-mode bias is added. The reason for this calculation is that the irradiance generated by each light source channel is linearly superimposed, and its corresponding grayscale signal components are therefore equally divided according to the number of channels; while the additive common-mode bias is formed by the sensor's dark level and uniform stray light, existing in both single-channel and full-channel illumination states, and does not superimpose with the number of channels. In this embodiment, with all channels illuminated, the target grayscale range for the high grayscale area is set to 160 to 200 grayscale levels, the additive common-mode bias is 20 grayscale levels, and the number of light source channels is 4, resulting in a preset grayscale band of 55 to 65 grayscale levels. If no conversion is made and a single channel is directly adjusted according to the target grayscale of all channels, the grayscale of the high grayscale area will rise to above 580 grayscale levels after all 4 channels are illuminated simultaneously, resulting in clipping. Once the baseline falls into the clipping area, the proportional relationship between grayscale difference and irradiance becomes invalid, and proportional adjustment and drift monitoring will be based on distorted data. In this embodiment, the effective current ranges obtained from the scanning of each channel are as follows: Channel 1: 226 mA to 290 mA; Channel 2: 247 mA to 318 mA; Channel 3: 216 mA to 278 mA; and Channel 4: 263 mA to 338 mA. Each channel is scanned from 0 mA until the average grayscale value in the high grayscale area exceeds the upper limit of the preset grayscale band. The scanning endpoint for each channel is 290 mA to 338 mA. Assuming approximately 35 milliseconds per current point, the total current scan for the four channels is approximately 40 seconds. When the inherited optical formula exists and the knowledge base records the corresponding effective current range, the effective current range is directly read, and a single-channel illumination acquisition is performed once at the midpoint of the read range for each channel for verification. When the average grayscale value in the high grayscale area falls within the preset grayscale band, that range is used; when it exceeds it, the current scan is re-executed. This verification is used to capture situations where historical ranges become invalid due to changes in the light source, working distance, etc. The optimization interval is then determined as follows: when the inherited optical formula exists, the optimization interval is the intersection of the interval centered on the current of the light source channel in the inherited optical formula and the effective current interval with a width equal to the width of the effective current interval multiplied by a preset narrowing ratio, and the effective current interval. The preset narrowing ratio is 0.3, and the optimization interval width of channel 1 is 19.2 mA; in other cases, the optimization interval is the effective current interval.

[0049] When the current of any light source channel reaches its upper limit and the average gray level in the high grayscale region is still lower than the preset lower limit of the grayscale band, a graded relaxation is performed: first, the light source flicker pulse width is relaxed to the maximum value allowed by the motion blur constraint, and the camera exposure time is simultaneously maintained as the sum of the light source flicker pulse width and the preset margin; if the gray level is still insufficient after the pulse width is relaxed to the appropriate level, the camera gain is increased step by step in 6 dB increments. In this embodiment, the light source flicker pulse width can be relaxed from 200 microseconds to 250 microseconds allowed by the motion blur constraint, and the camera exposure time becomes 290 microseconds accordingly. After each relaxation, the motion blur constraint check is re-performed, and the relaxation result is written into the workflow evolution record. When the camera gain reaches its upper limit, an optical scheme change prompt is generated, prompting the replacement of a light source with higher luminous flux or a shorter working distance. The reason why the camera gain is placed at the end of the relaxation order is that increasing the gain will simultaneously amplify the sensor noise, and the increase in the grayscale standard deviation of the background area will directly lower the image quality evaluation value. The gain is only activated after other means of improving brightness have been exhausted.

[0050] Focus optimization is performed after the optimization range is determined. At this time, the current of each light source channel is placed at the midpoint of its respective optimization range to obtain evaluation conditions with moderate and stable brightness. When the inherited optical formula exists, the sharpness evaluation value is evaluated point by point within a preset local range with fine step intervals, centered on the liquid zoom lens focusing voltage in the inherited optical formula. The preset local range is 2 volts on both sides of the center. When the maximum value of the sharpness evaluation value is located at the endpoint of the preset local range, it indicates that the true peak value is outside this range, and the search is switched to full range. The full range search is divided into two rounds: In the first round, the entire range of the liquid zoom lens focusing voltage from 0 volts to 70 volts is traversed with a coarse step interval of 2 volts, collecting a total of 36 voltage points, with the voltage with the largest sharpness evaluation value as the center of the peak area; In the second round, within a range of 4 volts on both sides of the peak area center, the evaluation is performed point by point with fine step intervals of 0.2 volts, collecting a total of 21 voltage points. See also Figure 5 In (a), the coarse scan curve exhibits a single-peak shape, with the peak center located near 34 volts. The fine scan improves the voltage resolution within the peak area by 10 times, resulting in a final focus optimization result of 34.2 volts, corresponding to a sharpness evaluation value of approximately 1100. The sharpness evaluation value at the furthest deviation of the focusing voltage from the optimal value drops to approximately 120, about 11% of the peak value. Based on the inverse relationship between the sharpness evaluation value and the blur scale, combined with edge diffusion width calibration, the defocus blur radius at this point is approximately 12 pixels, which is the preset maximum blur radius. Each voltage point waits for 25 milliseconds to stabilize after voltage setting and acquires 5 frames, with a single point taking approximately 200 milliseconds. The total time for searching the 57 voltage points across the entire range is approximately 11 seconds. All voltage points approach the setting unidirectionally from the low voltage direction: when the target voltage is higher than the current voltage, it is directly boosted to the target voltage; when the target voltage is lower than the current voltage, it is first reduced to a preset backoff amount of 2 volts below the target voltage, and then boosted forward to the target voltage. See [link to relevant documentation]. Figure 5In (b), the optical power of the liquid zoom lens forms a hysteresis loop during the voltage boosting and deboosting processes. The difference in optical power corresponding to the same voltage in the two directions is about 0.5 diopters, which is about 5% of the optical power adjustment range. Based on a voltage sensitivity of about 0.56 diopters per volt near the peak area, this is equivalent to a voltage deviation of about 1 volt, which is 5 times that of a fine step of 0.2 volts. Unidirectional approach ensures that the optical power state of each voltage point falls on the boost curve, and the sharpness evaluation value of each voltage point can be repeatedly compared. The average of the sharpness evaluation values ​​of 5 consecutively collected frames at each voltage point is taken to suppress false peaks caused by single-frame noise. The two-round structure of first coarse scanning to determine the peak area and then fine scanning to refine the positioning is adopted because when there is severe defocus, the sharpness evaluation value curve is almost flat far from the peak area. Climbing-type searches lack directional information in the flat area, and a single false drop may stop prematurely. Full-range coarse scanning structurally eliminates these two types of failure modes.

[0051] Channel current optimization uses the current of four light source channels as the optimization variables. First, an initial combination is arranged using a 3-level orthogonal array adapted to the number of light source channels. In this embodiment, there are 4 light source channels, and a 9x4 3-level orthogonal array is selected. The three levels of each light source channel are the lower endpoint, midpoint, and upper endpoint of the optimization interval, forming 9 initial combinations. For each initial combination, the programmable light source controller 8 sends the current of the four channels and then acquires sample images. The sample images are images acquired from sample workpieces with pre-marked target and background areas. In this embodiment, the target area is the area where the laser-engraved characters are located, and the background area is the uniform oxide film area surrounding the characters. The initial combination participates in the evaluation only when the 99.5th percentile grayscale values ​​of the target area, background area, and high grayscale area are all less than or equal to the maximum quantization value multiplied by the preset saturation margin ratio. In this embodiment, the camera uses 8-bit quantization, the maximum quantization value is 255, the preset saturation margin ratio is 0.9, and the criterion threshold is 229.5 grayscale levels. The 99.5% quantile grayscale value, rather than the maximum grayscale value, is used as the criterion. This is because individual hot pixels or local specular highlights can distort the maximum grayscale value, causing reasonable combinations to be misjudged as saturated. The quantile grayscale value is robust to isolated outliers. High grayscale areas are included in the criterion because the high grayscale areas of the reference calibration block 6 are usually brighter than the workpiece surface; verifying only the workpiece area cannot prevent clipping of the reference calibration block during optimization. Combinations meeting the conditions are calculated using the following formula to determine the image quality evaluation value:

[0052] (7)

[0053] In the formula, Q represents the imaging quality evaluation value, μt represents the average gray level of the target area, μb represents the average gray level of the background area, and σb represents the standard deviation of the gray level of the background area. The units of the latter three are all gray levels, and the imaging quality evaluation value is a dimensionless quantity. The numerator of this index is the contrast between the target and the background, and the denominator is the background clutter level. The ratio form has scale invariance. Simply increasing the brightness makes the numerator and denominator increase proportionally, and the imaging quality evaluation value remains basically unchanged. The optimization will not drift towards the saturation boundary. In this embodiment, the average gray level of the target area under the optimal optical formula is about 68 gray levels, the average gray level of the background area is about 109 gray levels, and the standard deviation of the gray level of the background area is about 6.0 gray levels. Substituting into formula (7), the imaging quality evaluation value is about 6.8. Combinations that exceed the saturation margin condition are included in the training samples with a preset penalty value of 0 as the imaging quality evaluation value instead of being discarded: if discarded, the surrogate model has no observation information in the saturated area, and the expected improvement criterion will repeatedly sample the unknown area; after the penalty value is included, the predicted mean of the saturated area is suppressed, and sampling is naturally avoided. When all initial combinations exceed the saturation margin condition, the optimization interval is multiplied by a preset reduction ratio of 0.8 and the channel current optimization is re-executed. This applies to cases where the output coverage inherits the overall brighter situation of the interval.

[0054] Then, iterative optimization begins. The current of each light source channel is linearly normalized to the 0-1 interval according to the optimization interval. Normalization eliminates the differences in the width of each channel interval, making the kernel function of the surrogate model have comparable length scales in all dimensions. A Gaussian Process Regression surrogate model is established using the evaluated combinations and imaging quality evaluation values ​​as training samples. The Matern kernel is selected as the kernel function, and the kernel hyperparameters are estimated by maximizing marginal likelihood. In each round, Latin hypercube sampling regenerates a preset number of 1000 candidate combinations within the normalized optimization interval space. Each round of resampling ensures that the candidate distribution covers the entire space and is not fixed to the same grid. For each candidate combination, the expected improvement value is calculated according to the expected improvement criterion.

[0055] (8)

[0056] (9)

[0057] In the formula, EI(x) represents the expected improvement value of candidate combination x; x represents a candidate combination consisting of four normalized source channel currents; m(x) and s(x) represent the predicted mean and standard deviation of the Gaussian process regression surrogate model at candidate combination x, respectively; Q* represents the maximum imaging quality evaluation value among the currently evaluated combinations; u is an intermediate variable; Φ(u) and φ(u) represent the cumulative distribution function and probability density function of the standard normal distribution, respectively; the expected improvement value is 0 when s(x) equals 0. The candidate combination with the largest expected improvement value is selected as the next set of combinations to be evaluated. After distributing parameters, collecting sample images, and calculating the imaging quality evaluation value, the results are added to the training samples to update the surrogate model. The iteration termination condition is that the increment of the maximum imaging quality evaluation value in two consecutive rounds is less than the preset convergence threshold of 0.05, or the cumulative number of evaluations reaches the preset upper limit of 60 times. See also Figure 6 The horizontal axis represents the number of evaluations, and the vertical axis represents the maximum image quality rating up to the current level. The first nine evaluations correspond to the initial combination of a 3-level orthogonal array, and subsequent evaluations are given by the desired improvement criteria. Without narrowing the optimization interval, convergence occurred in approximately 52 evaluations, with the maximum image quality rating reaching approximately 6.8. After inheriting the optical formula and narrowing the optimization interval by a preset narrowing ratio of 0.3, convergence to the same level occurred in approximately 18 evaluations, reducing the number of evaluations by approximately 65%. Each evaluation includes current transmission, image acquisition, and proxy model update, taking approximately 1.5 seconds, for a total of approximately 80 seconds across 52 evaluations.

[0058] After convergence, workpiece-side verification is performed: When the maximum imaging quality evaluation value is lower than the preset quality lower limit of 3.0, or the average gray level of the target area is lower than the preset target gray level lower limit of 60 gray levels, the channel current optimization is re-executed after relaxation in the order of graded relaxation. The reason for adding workpiece-side verification is that graded relaxation is triggered by the gray level of the reference calibration block 6 in the optimization interval determination stage. The reference calibration block 6 is a high reflectivity diffuse reflection surface. Low reflectivity workpieces such as black rubber and dark oxide film may still be severely underexposed even when the reference calibration block responds normally. Such cases are identified by workpiece-side verification and trigger relaxation. If the verification still fails after the camera gain is relaxed to the upper limit, an optical scheme change prompt is generated and the process is transferred to manual processing.

[0059] Algorithm parameter fine-tuning is performed after the optimal optical formula is determined. Under the optimal optical formula, sample images of all sample workpieces are re-acquired and saved. The sample workpieces include good and defective samples, and their categories are known in advance. In this embodiment, 120 good samples and 80 defective samples are used, divided into an optimization set and a validation set according to a preset ratio of 7:3, i.e., 140 samples in the optimization set and 60 samples in the validation set. On the sample images in the optimization set, the algorithm parameters of each algorithm tool are searched in two rounds according to the Tool topology order: each algorithm parameter is selected point by point within its value range according to the adjustment step. For each value selected, the detection process is run on all sample images in the optimization set, and the sample recognition rate is calculated. The sample recognition rate is the ratio of the number of sample workpieces whose judgment results match the known categories to the total number of sample workpieces. The value with the highest sample recognition rate is taken. When the maximum sample recognition rate corresponds to a continuous value interval, the midpoint of that interval is taken, because the parameter at the midpoint of the platform is furthest from the performance degradation boundaries on both sides, thus having the greatest tolerance to incoming material fluctuations. The reason for executing two rounds in the Tool topology order is that changes in the parameters of the upstream positioning Tool will affect the input of the downstream detection Tool. The downstream parameters determined in the first round may deviate from the optimal after the upstream parameters are updated. The second round verifies all parameters with the updated upstream state, eliminating the coupling bias caused by the single-round order. In this embodiment, each algorithm Tool registers 12 algorithm parameters, with 20 value points for each parameter based on the adjustment step size. The two rounds of item-by-item search involve approximately 480 evaluations. Each evaluation runs the detection process on 140 optimization set images, with each image taking approximately 15 milliseconds. The total fine-tuning of the algorithm parameters takes approximately 17 minutes. After the item-by-item search is completed, the sample recognition rate is verified on the validation set sample images. When the verification result reaches the preset pass threshold of 98%, baseline calibration is performed. If it is lower than the preset pass threshold, the sample workpieces are expanded and the algorithm parameter fine-tuning is re-executed. When the number of repetitions reaches the preset maximum of 3 retries, an optimization failure prompt is generated and the process is transferred to manual processing. The independent validation set is used to discover parameter values ​​that are overfitted to the optimization set, avoiding overestimation of generalization ability.

[0060] Before baseline calibration, a linear region verification is performed: Under optimal optical formulation, the 99.5th percentile gray value of the high grayscale region of the calibration block is less than or equal to 229.5 gray levels, and the average gray level of the low grayscale region is greater than the preset low grayscale lower limit by 30 gray levels. The preset low grayscale lower limit is set to be 20 gray levels higher than the additive common-mode bias, so that the low grayscale region still has a measurable grayscale signal above the bias; these two conditions respectively ensure that the high grayscale region has a saturation margin and the low grayscale region is higher than the dark background, that is, both grayscale regions are simultaneously within the linear response window, which is the premise that the grayscale difference and irradiance are proportional; if either condition is exceeded, the entire optimization interval is multiplied by the preset downsizing ratio of 0.8 and the channel current is returned for optimization. After successful verification, the optimal optical formula and algorithm parameters are written into the workflow, generating the second version of the formal workflow and storing it in the workflow repository. Subsequently, 500 frames of steady-state images are continuously collected to record baseline data, taking approximately 18 seconds. Under full-channel illumination, the baseline mean of the grayscale difference is 142.0 gray levels, with a standard deviation of 1.2 gray levels. Under individual channel flicker conditions, the baseline grayscale difference values ​​for channels 1 to 4 are 36.1, 35.4, 35.8, and 34.7 gray levels, respectively. The sum of the baseline grayscale difference values ​​for the four channels equals the average baseline value across all channels, along with the irradiance. The physical relationship of linear superposition is consistent; the baseline value of the sharpness evaluation value is 1100; the baseline currents of the four channels are 262 mA, 281 mA, 249 mA, and 293 mA, respectively, all within their respective effective current ranges; in the single-channel illumination state, the average gray levels of the high grayscale areas of the four channels are 60.6, 59.8, 60.3, and 59.0 gray levels, respectively, all falling within the preset grayscale band of 55 to 65 gray levels. After the grayscale signal components are superimposed and combined with the additive common-mode bias, the total grayscale level is approximately 180, which is within the target grayscale range of 160 to 200 gray levels for the entire channel. According to the above steps, the entire imaging optimization sub-workflow of this embodiment is automatically completed within approximately 20 minutes.

[0061] During industrial operation, the industrial vision module executes inspections according to the current version's official workflow and continuously saves the most recently preset 2000 production images and their judgment results. For each frame, while completing the workpiece judgment, the grayscale difference and sharpness evaluation value under full-channel illumination are extracted. The grayscale difference is monitored using an exponentially weighted moving average control chart, and the exponentially weighted moving average of frame t is recursively calculated using the following formula:

[0062] (10)

[0063] In the formula, Z(t) represents the exponentially weighted moving average of frame t, t represents the frame number, ΔG(t) represents the grayscale difference of frame t, λ represents the weighting coefficient, which is 0.2, and Z(0) is the baseline mean of the grayscale difference. The control chart is centered on the baseline mean of the grayscale difference, and the control limit half-width is calculated according to the following formula:

[0064] (11)

[0065] In the formula, h represents the half-width of the control limit, and σ0 represents the standard deviation of the grayscale difference obtained from baseline calibration. The asymptotic standard deviation of the exponentially weighted moving average statistic is less than the standard deviation of the original data. When λ is 0.2, the square root term is approximately 0.333, therefore h is approximately equal to 1.2 gray levels, and the control limit is from 140.8 gray levels to 143.2 gray levels. If three times the original standard deviation is directly used as the half-width, the control limit will be magnified by approximately three times, and slow light decay drift will not trigger an alarm for a long time. In addition, σ0 must be the calibration value of the steady-state data during the baseline period. Mixing in drift period data will increase the standard deviation and dull the control chart. The sharpness evaluation value is the baseline value of 1100 multiplied by the preset sharpness ratio of 0.8, i.e., 880, as the lower limit threshold. The operational pass rate is the ratio of the number of workpieces that pass the test to the total number of workpieces tested. After production begins, within a preset baseline of 2000 workpieces, the pass rate sequence is calculated by grouping workpieces into preset statistical windows of 200 workpieces each. In this embodiment, the mean of the sequence is 0.986. The operational pass rate baseline band is centered on the mean of the sequence, and the half-width of the band is calculated according to the proportional control chart and is taken as the larger of the half-width and the preset minimum bandwidth of 0.01.

[0066] (12)

[0067] In the formula, B represents the half-width of the baseline band for the pass rate, p̄ represents the mean of the pass rate sequence, and n represents the number of workpieces in the preset statistical window. Substituting the sequence mean of 0.986 with the statistical window of 200 workpieces, we get a half-width of approximately 0.025, which is greater than the preset minimum bandwidth of 0.01. Therefore, we take 0.025, and the baseline band for the pass rate is 0.961 to 1. The reason for using a proportional control chart to determine the half-width is that the pass rate is a skewed proportional data with values ​​close to 1. Directly applying a normal three-standard-deviation bandwidth can easily shrink the data to the thousandths level, and even normal fluctuations will frequently result in false alarms.

[0068] Drift attribution is performed in a fixed priority order: lighting, focus, and process. See also Figure 7In (a), the horizontal axis represents the running time, and the vertical axis represents the exponentially weighted moving average of the grayscale difference: As the light decay of the LEDs and lens contamination accumulate, the monitoring curve decreases at a rate of approximately 1 grayscale level per 100 hours. After running for approximately 120 hours, it exceeds the control lower limit of 140.8 grayscale levels, which is determined to be illumination drift, and a proportional adjustment is performed. After the adjustment is completed, the monitoring curve returns to near the baseline mean, and thereafter drift and compensation alternate, exhibiting a sawtooth pattern. The proportional adjustment involves sequentially flashing each channel individually within the detection gap between adjacent workpieces and acquiring calibration frames to obtain the current value of the grayscale difference under the single-channel illumination state of each light source channel. In this embodiment, the cycle time is 500 milliseconds per piece, the detection window is approximately 280 milliseconds, the detection interval is approximately 220 milliseconds, and the single-frame calibration acquisition, including current switching and image readout, takes approximately 35 milliseconds. The total calibration frames for the four channels are approximately 140 milliseconds, which can be completed within one detection interval. For production lines with higher cycle times and detection intervals shorter than the time required for channel-by-channel calibration, the calibration of each channel is distributed across multiple detection intervals according to a preset calibration cycle. In this embodiment, the preset calibration cycle is 60 seconds, meaning that the calibration of one channel is completed within one detection interval every 60 seconds. During this period, frame-by-frame monitoring of the grayscale difference of all channels remains continuous. After obtaining the current value of the grayscale difference of each channel, the current for each light source channel is adjusted according to the following formula:

[0069] (13)

[0070] In the formula, c represents the light source channel number, Ic(t) represents the light source channel current before adjustment of channel c, Ic(t+1) represents the light source channel current after adjustment of channel c, ΔG0,c represents the baseline value of grayscale difference in the single-channel lit state of channel c, and ΔGc(t) represents the current value of grayscale difference in the single-channel lit state of channel c. The adjustment result is limited to the upper and lower limits of the value of this channel. The reason for measuring and adjusting each channel separately is that the aging rate of the light-emitting diodes in each channel has individual differences, and the effect of lens contamination on different illumination directions is not uniform. After each channel restores its own baseline luminous flux contribution, the light distribution ratio between each illumination sector is maintained in the state of optimal optical formula setting, and the light distribution ratio determines the contrast structure between defects and background. Taking the first compensation in this embodiment as an example, the gray level difference of the entire channel is reduced from 142.0 gray level to 140.8 gray level. The gray level difference of channels 1 to 4 under single-channel illumination state is reduced to 35.81 gray level, 35.10 gray level, 35.55 gray level and 34.35 gray level respectively. Substituting into equation (13), the adjustment ratios of each channel are 1.008, 1.009, 1.007 and 1.010 respectively. The adjusted currents are 264 mA, 284 mA, 251 mA and 296 mA respectively. After compensation, the gray level difference under the illumination state of the entire channel is re-measured. When the deviation of the re-measured value from the baseline mean is within 3%, the compensation is determined to be completed and production continues. When the deviation exceeds 3%, the adjustment is repeated. When the deviation still exceeds 3% after 3 repetitions, it indicates that there is an anomaly in the optical path that cannot be described by the proportional model. The algorithm parameter optimization suggestions are generated and manual inspection is requested. The time of each compensation, the proportional coefficient of each channel, and the adjusted current are all added to the workflow evolution record. After compensation, the pass rate is recalculated within a preset number of 200 workpieces to be checked. If the pass rate exceeds the baseline, algorithm parameter optimization suggestions are generated. The compensation ratio of each light source channel is also used for attenuation source diagnosis. The compensation ratio is the ratio of the current current of the channel to its baseline current, and the range is the difference between the maximum and minimum values ​​of the compensation ratios of the four channels. When the range is less than the preset consistency threshold of 0.05, each channel attenuates approximately proportionally. The attenuation comes from the common optical path, which is judged as common optical path attenuation, and a maintenance prompt covering the cleaning of the lens and the reference calibration block is generated. When the range reaches the preset consistency threshold, it is judged as differential aging of the light source channel. The maintenance prompt lists two cleaning objects, the lens and the reference calibration block. Since the contamination of the reference calibration block itself and the lens contamination are both common-mode attenuation in the grayscale response, the range alone cannot distinguish between the two. Listing them together can avoid missed detection.

[0071] When the grayscale difference is within the control limits and the sharpness evaluation value is below the lower threshold of 880, it is considered defocus drift, and focus restoration is performed. Temperature drift in liquid zoom lenses is the main source of defocus drift; for every 10-degree Celsius change in ambient temperature, the optical power drift can reach 0.5% to 1% of full scale. Based on the inverse relationship between the sharpness evaluation value and the blur scale, when the sharpness evaluation value drops from the baseline value of 1100 to the lower threshold of 880, the corresponding blur radius is approximately 1 pixel, which is much smaller than the 30-pixel distance between the grayscale extraction area and the area boundary. In this state, the grayscale difference remains independent of the focus state. Focus recovery is performed point-by-point within a preset local range, centered on the current focusing voltage of the liquid zoom lens, with fine step increments of 0.2 volts on either side of the center. The voltage setting follows a unidirectional approach. The recovery process is executed step-by-step within the detection gaps of adjacent workpieces. The focusing voltage of the liquid zoom lens is changed only once within each detection gap. After a 25-millisecond stabilization period, 5 calibration frames are acquired and the average sharpness evaluation value is calculated. The single-point time is approximately 200 milliseconds, which falls within a detection gap of approximately 220 milliseconds. A local search is completed in approximately 10.5 seconds across 21 detection gaps using 21 voltage points. Workpiece detection frames are always acquired while the focusing voltage of the liquid zoom lens remains stable, ensuring that production decisions are not affected by the search process. The voltage with the highest average sharpness evaluation value is used as the focusing voltage after recovery, restoring the sharpness evaluation value to above the lower threshold. If the sharpness evaluation value is still below the lower threshold after the local search is completed, a maintenance prompt is generated and handled according to the cause of material changes or algorithm parameter issues. The restored focusing voltage and its offset are added to the workflow evolution record. After the restoration is completed, the pass rate is recalculated within the preset number of 200 workpieces to be checked.

[0072] When both the grayscale difference and the sharpness evaluation value are within their respective limits and the operation judgment pass rate exceeds the baseline band of the operation judgment pass rate, it is determined that the problem is due to changes in incoming materials or algorithm parameters. The workflow planning module generates algorithm parameter optimization suggestions in conjunction with the workflow evolution record. After verification by the workflow verification module, the system is tested by playing back the comparison channel.

[0073] The net offset ratio of any light source channel is defined as the absolute value of the difference between the current current of that channel and the baseline current, divided by the baseline current of that channel:

[0074] (14)

[0075] In the formula, rc represents the net offset ratio of channel c, Ic represents the current of channel c, and Ic,0 represents the baseline current of channel c. When the net offset ratio of any light source channel reaches the preset offset threshold of 0.2, or the current of any light source channel reaches its upper limit, or the offset of the focusing voltage of the liquid zoom lens relative to the value in the optimal optical formula reaches the preset offset ratio of 0.05 (3.5 volts) of its adjustment range, it indicates that the degradation of the optical system is close to the boundary of the compensation method. At the most recent planned shutdown window, the imaging optimization sub-workflow is automatically re-executed to generate the N+1th version of the formal workflow, where N is the current version number. All historical versions are saved in append mode. See also Figure 7 In (b), the horizontal axis represents the running time, and the vertical axis represents the net offset ratio. Each proportional adjustment increases the current of each channel, and the net offset ratio increases in a stepwise manner. The growth rates of the four channels are not the same, reflecting differentiated aging. In this embodiment, compensation occurs approximately once every 120 hours. The adjustment ratios for each compensation of channels 1 to 4 are approximately 1.008, 1.009, 1.007, and 1.010, respectively. After a total of 19 compensations and approximately 2280 hours of operation, the compensation ratios of channels 1 to 4 are approximately 1.163, 1.186, 1.142, and 1.208, respectively. The net offset ratio of channel 4 is the first to reach the preset offset threshold of 0.2, triggering re-optimization. At this time, the range of the compensation ratios of the four channels is 0.066, reaching the preset consistency threshold of 0.05, which is determined to be differentiated aging of the light source channels. During the waiting period for planned downtime, temporary relaxation is implemented in the order of graded relaxation to keep the grayscale difference of the entire channel within the control limit. The temporary relaxation is written into the workflow evolution record and reset after the re-optimization is completed. This bridging mechanism ensures that the production line will not stop due to the exhaustion of compensation capacity during the window period of several hours to tens of hours between triggering and execution.

[0076] Version changes are verified using a different verification channel based on the level of parameters involved. Version changes involving only algorithm parameters are compared using playback: the algorithm parameters of versions N and N+1 are run in parallel on 2000 production images that are continuously saved. Both versions use identical input images, and images with differing judgments are manually reviewed. The number of correct judgments for the differing images is counted. Version changes involving optical formulations cannot be compared on the same historical image because a single camera can only image with one set of imaging hardware parameters at a time; therefore, alternating real-world shooting comparisons are used. Figure 8As shown, two consecutive acquisitions are triggered within the detection window of the same workpiece: the first frame is imaged according to the Nth version of the optical formula and the Nth version of the algorithm parameters are run; the second frame is imaged according to the N+1th version of the optical formula and the N+1th version of the algorithm parameters are run. The programmable light source controller 8 switches the light source channel current and the light source flicker pulse width frame by frame between the two frames according to the trigger sequence. The interval between the two triggers is greater than the larger of the preset stabilization time of 25 milliseconds for the liquid zoom lens and the light source current establishment time of 50 microseconds. When the focusing voltage values ​​of the two versions are consistent, this interval only needs to be the light source current establishment time, which is shortened from 25 milliseconds to 50 microseconds, that is, shortened to about 1 / 500. In this embodiment, the workpiece moving speed is 200 mm / s. The interval of 25 milliseconds corresponds to a workpiece displacement of 5 mm, or 100 pixels, which exceeds the preset positioning tolerance of 80 pixels. Therefore, it is downgraded to applying the two versions alternately in groups of 50 workpieces in the preset group. If the focusing voltage of the two versions is consistent, the interval of 50 microseconds corresponds to a displacement of only about 0.2 pixels, and the pairing comparison of the same workpiece in two frames can be performed directly. After continuously performing a preset comparison of 500 workpieces, workpieces with discrepancies in the judgment results are manually reviewed, and the number of correctly judged workpieces is counted. If the number of discrepancies is less than the preset minimum discrepancy of 20 workpieces, the alternating comparison is extended. If the number of discrepancies is still less than 20 after reaching the preset maximum comparison of 2000 workpieces, the detection effects of the two versions are deemed equivalent, and version N is maintained. If the number of correctly judged workpieces in version N+1 is greater than or equal to that in version N, the system switches to version N+1; otherwise, it maintains version N and rolls back.

[0077] After rollback, the current re-optimization is marked as a failure and written to the workflow evolution record. Automatic re-optimization initiated under the same trigger condition is suspended for 72 hours within a preset suppression period, while a light source or lens replacement prompt is generated. The reason for setting the suppression period is that rollback implies the physical degradation that triggered re-optimization still exists, and re-optimization can no longer provide a better optical formula. Without suppression, the system will oscillate between triggering and rollback. The suppression period allows time for manual replacement of the light source or cleaning of the lens. Automatic triggering resumes after the preset suppression period expires or maintenance is confirmed. If the operational pass rate exceeds the operational pass rate baseline after the switch and manual review confirms an increase in misjudgments, rollback to version N and perform failure marking and suppression as described above. After the version switch is completed, baseline data is re-recorded, and the operational pass rate baseline is rebuilt. This is because the grayscale difference baseline, sharpness evaluation value baseline, and pass rate level under the new optical formula have all changed; using the old baseline will immediately generate false alarms.

[0078] During the knowledge accumulation phase, the optimal optical formula, along with the workpiece material category code, surface type category code, effective current range of each light source channel, imaging optimization trajectory, channel-by-channel compensation records, and version evolution relationship, is stored in the knowledge base. When the workflow planning module receives a new task object with the same workpiece material category code and surface type category code, it inherits the optical formula, reads the effective current range, determines the optimization range with a preset narrowing ratio of 0.3, and performs local fine scanning with the inherited focusing voltage as the center for focusing optimization. Figure 6 The comparison shows that inheritance reduces the number of channel current optimization evaluations from approximately 52 to approximately 18, the number of voltage points for focus optimization from 57 to 21, simplifies current scanning from point-by-point scanning to 4 single-point verifications, and reduces the time spent on imaging hardware parameter-related steps from approximately 2 minutes to approximately 30 seconds. The overall time of the imaging optimization sub-workflow is reduced from approximately 20 minutes to approximately 18 minutes, with the approximately 17 minutes spent on algorithm parameter fine-tuning remaining unchanged with optical recipe inheritance. Compared to the several hours typically required for manual tuning of imaging hardware parameters, all of the above steps are completed automatically by the platform. As the number of similar optical recipes in the knowledge base increases, the inheritance hit rate continues to rise, thus forming a closed-loop workflow lifecycle encompassing task creation, workflow planning, workflow verification, imaging optimization, industrial operation, workflow evolution, knowledge accumulation, and replanning.

[0079] This invention also provides an industrial vision intelligent agent system, including a workflow planning module, a workflow verification module, an industrial vision operation module, a workflow evolution management module, a workflow repository, a knowledge base, an industrial camera, a programmable light source controller, a multi-channel LED light source, a liquid zoom lens, and a reference calibration block. Each module and device is configured to execute the aforementioned industrial vision intelligent agent construction method based on the entire workflow lifecycle. The workflow evolution management module is responsible for appending, retrieving, and maintaining version relationships of workflow evolution records. Each software module can be deployed on the same edge industrial control computer, or a cloud-edge collaborative approach can be adopted, with the workflow planning module and knowledge base deployed in the cloud and the remaining modules deployed at the edge. Task objects and workflow blueprints are transmitted between the cloud and the edge.

[0080] This invention also provides an electronic device, including a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, it implements the steps of the above-described method for constructing an industrial visual intelligent agent based on a workflow-driven full lifecycle. The processor can be a general-purpose processor or a graphics processor configured for inference acceleration of the algorithm tool. This invention also provides a computer-readable storage medium storing a computer program. When the computer program is executed by the processor, it implements the steps of the above-described method. The computer-readable storage medium can be a non-volatile storage medium such as magnetic storage, optical disk, flash memory, or solid-state drive.

[0081] In addition to the above embodiments, the present invention has several optional implementations. The number of light source channels in the multi-channel LED light source can be 2, 6, or 8. When the number of light source channels changes, a 3-level orthogonal array capable of accommodating the corresponding number of factors is used to arrange the initial combination. The preset grayscale band is calculated according to the actual number of light source channels. The edge pattern area of ​​the benchmark calibration block can be replaced with a checkerboard pattern. The high grayscale area and the low grayscale area can be expanded to multiple grayscale steps of 3 or more levels. The comprehensive photoelectric conversion coefficient and the additive common-mode bias are estimated simultaneously through least squares fitting. In addition to the Tenengrad gradient function, the sharpness evaluation value can also be calculated using the Brenner gradient function or the grayscale variance function, as long as the selected function decreases monotonically with the degree of defocus. The surrogate model can use radial basis function interpolation or a tree-shaped Parzen estimator to replace Gaussian process regression. The generation of candidate combinations can use Sobol sequences to replace Latin hypercube sampling. The monitoring of grayscale difference can use a cumulative sum control chart to replace the exponentially weighted moving average control chart. When the camera quantization bit depth is 10 bits or 12 bits, the maximum quantization value is taken as 1023 or 4095 respectively. These alternatives do not change the core concept of this invention.

[0082] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A method for constructing an industrial vision intelligent agent based on a workflow-driven full lifecycle, applied to an industrial vision intelligent agent system. The industrial vision intelligent agent system includes a workflow planning module, a workflow verification module, an industrial vision operation module, a workflow repository, a knowledge base, an industrial camera, a programmable light source controller, a multi-channel LED light source, a liquid zoom lens, and a reference calibration block. The multi-channel LED light source includes multiple light source channels with independently adjustable current. The surface of the reference calibration block is provided with a high-reflectivity high-grayscale area, a low-reflectivity low-grayscale area, and a black-and-white alternating edge pattern area. The method is characterized in that... The process includes the following steps: receiving industrial inspection tasks and generating task objects; defining the imaging hardware parameters of the image acquisition tool and the algorithm parameters of each algorithm tool as a workflow parameter set and writing it into a workflow file; the imaging hardware parameters include the light source channel current, light source flicker pulse width, camera exposure time, camera gain, and liquid zoom lens focusing voltage; registering the upper limit, lower limit, and adjustment step for each imaging hardware parameter and algorithm parameter; and appending each change in the workflow parameter set along with the corresponding performance data to the workflow evolution record in chronological order; executing the imaging optimization sub-workflow, sequentially determining the optimization interval, focusing optimization, channel current optimization, and algorithm parameter fine-tuning to determine the optimal optical formula composed of the combination of imaging hardware parameter values ​​and the optimal values ​​of the algorithm parameters, generating a new version of the formal workflow. Record baseline data, which includes at least the baseline current of each light source channel. During industrial operation, extract grayscale difference and sharpness evaluation value frame by frame, and calculate the operation judgment pass rate. The grayscale difference is the difference between the average grayscale of the high grayscale area and the average grayscale of the low grayscale area. The sharpness evaluation value is the mean square of the Sobel gradient calculated for the edge pattern area. The operation judgment pass rate is the ratio of the number of workpieces with qualified judgment results to the total number of inspected workpieces. Perform drift attribution based on grayscale difference, sharpness evaluation value and operation judgment pass rate. When it is determined to be illumination drift, perform proportional adjustment of the current of each light source channel based on the change of grayscale difference relative to the baseline under single channel illumination state to restore the baseline luminous flux contribution of each light source channel. When it is determined to be defocus drift, perform focus restoration. When it is determined to be due to changes in incoming materials or algorithm parameters, generate algorithm parameter optimization suggestions. The net offset ratio is defined as the absolute value of the difference between the current current of the light source channel and the baseline current, divided by the baseline current. When the net offset ratio of any light source channel reaches the preset offset threshold, or the current of any light source channel reaches the upper limit of the value, or the offset of the focusing voltage of the liquid zoom lens relative to the value in the optimal optical formula reaches the preset offset ratio, the imaging optimization sub-workflow is re-executed to generate a new version of the formal workflow. The verification channel is selected according to the parameter level involved in the version change for version comparison, and version switching or rollback is performed based on the comparison results. The optimal optical formula is associated with the workpiece material category code and surface type category code in the task object and stored in the knowledge base for subsequent industrial inspection tasks to inherit and narrow the optimization range, forming a closed loop of the entire workflow lifecycle.

2. The method according to claim 1, characterized in that, The task objects include the detection target, workpiece material category code, surface type category code, workpiece moving speed, pixel equivalent, and cycle time requirements. Pixel equivalent is the object surface size corresponding to a single pixel. The workflow file also includes the running configuration, which includes setting the camera gamma factor to 1, disabling the camera's automatic exposure and automatic gain functions, driving the light source in constant current mode, and ensuring the upper limit of the light source channel current is within the LED's rated linear range. The workflow planning module retrieves historical optical recipes from the knowledge base based on the task objects. The retrieval criteria are that the workpiece material category code and surface type category code are consistent with the task objects. Among the historical optical recipes that meet the retrieval criteria, the one with the highest historical imaging quality evaluation value is selected as the inherited optical recipe. When the number of historical optical recipes that meet the retrieval criteria is 0, the optical recipe is determined by the imaging optimization sub-workflow. The workflow planning module generates a workflow blueprint, which includes... The workflow includes Tool node type, Tool connection relationship, recommended algorithm parameters, inherited optical formula, preset value of light source flicker pulse width, camera exposure time equal to the sum of the preset value of light source flicker pulse width and preset margin, and minimum camera gain. The preset value of light source flicker pulse width is determined based on the workpiece moving speed and pixel equivalent, so that the displacement of the workpiece on the image during flicker is less than 1 pixel. The camera exposure window completely covers the light source flicker pulse. The camera exposure and light source flicker are synchronously triggered by the same hardware trigger signal. The workflow verification module performs Tool existence check, Tool input and output connection relationship check, parameter value range check, motion blur constraint check, and industrial communication configuration check on the workflow blueprint in sequence. After the verification is passed, the first version of the formal workflow is generated and stored in the workflow repository. The knowledge base also stores the effective current range of each light source channel, imaging optimization trajectory, compensation record, and version evolution relationship.

3. The method according to claim 2, characterized in that, The optimization interval determination includes: performing a current scan on each light source channel individually, illuminating only the scanned light source channel, increasing the current by adjustment steps starting from the lower limit of the value, and determining the current interval where the average gray level of the high gray level area falls into the preset gray level band as the effective current interval of the scanned light source channel. The preset gray level band is the single-channel target gray level band, which is calculated by adjusting the target gray level range of the high gray level area according to the number of light source channels under the full channel illumination state; when the inherited optical formula exists and the knowledge base records the corresponding effective current interval, the effective current interval is read and a single-channel illumination acquisition is performed once at the midpoint of the interval for verification; when the inherited optical formula exists, the optimization interval is determined by... The optimal range is the intersection of the range centered on the light source channel current in the inherited optical formula, with a width equal to the effective current range width multiplied by a preset narrowing ratio, and the effective current range. In other cases, the optimal range is the effective current range. When the light source channel current reaches its upper limit and the average gray level in the high grayscale area is lower than the preset grayscale band lower limit, a graded relaxation is performed: first, the light source flicker pulse width is relaxed to the maximum value allowed by the motion blur constraint, the camera exposure time is kept to be the sum of the light source flicker pulse width and the preset margin, and then the camera gain is increased step by step. After each relaxation, the motion blur constraint check is re-performed. When the camera gain reaches its upper limit, an optical scheme change prompt is generated.

4. The method according to claim 3, characterized in that, Focus optimization includes: placing the current of each light source channel at the midpoint of its respective optimization interval; when the inherited optical formula exists, taking the liquid zoom lens focusing voltage in the inherited optical formula as the center, evaluating the sharpness evaluation value point by point within a preset local range with fine step increments; when the maximum value of the sharpness evaluation value is located at the endpoint of the preset local range, switching to full-range search; the full-range search first traverses the entire value range of the liquid zoom lens focusing voltage with coarse step increments to determine the peak center, and then evaluates point by point within a coarse step increment range on both sides of the peak center with fine step increments; all voltage points start from low The voltage direction is set to approach in one direction. When it exceeds the target value, it first retreats by a preset amount and then approaches in the forward direction. Multiple frames are continuously collected for each voltage point and the average of the sharpness evaluation value is taken. The voltage with the largest average sharpness evaluation value is used as the focus optimization result. The focus recovery is centered on the current liquid zoom lens focusing voltage and evaluated point by point in a preset local range with fine step distances. The recovery process is performed step by step in the detection gap between adjacent workpieces. The liquid zoom lens focusing voltage is changed only once in each detection gap. The workpiece detection frame is collected when the liquid zoom lens focusing voltage remains stable.

5. The method according to claim 3, characterized in that, Channel current optimization includes: arranging initial combinations of current for each light source channel within the optimization interval using a 3-level orthogonal array adapted to the number of light source channels. The three levels for each light source channel are the lower, middle, and upper endpoints of the optimization interval. Sample images are acquired for each initial combination. These sample images are images of sample workpieces from pre-labeled target and background areas. The initial combination is evaluated only when the 99.5th percentile gray values ​​of the target area, background area, and high grayscale area are all less than or equal to the maximum quantization value multiplied by a preset saturation margin ratio. An imaging quality evaluation value is calculated, which is the absolute value of the difference between the average gray value of the target area and the average gray value of the background area divided by the standard deviation of the background area's gray value. Combinations exceeding the saturation margin condition are included in the training samples with a preset penalty value as their imaging quality evaluation value. When all initial combinations exceed the saturation margin condition, the optimization interval is multiplied by a preset reduction ratio and the channel current optimization is re-executed. The channel current of each light source is linearly normalized to the 0-1 interval according to the optimization interval. A Gaussian process regression surrogate model is established using the evaluated combinations and imaging quality evaluation values ​​as training samples. In each round, a preset number of candidate combinations are regenerated by Latin hypercube sampling. The candidate combination with the largest expected improvement value is selected as the next set of combinations to be evaluated according to the expected improvement criterion, until the increment of the maximum imaging quality evaluation value in two consecutive rounds is less than the preset convergence threshold or the cumulative number of evaluations reaches the preset upper limit. After convergence, when the maximum imaging quality evaluation value is lower than the preset quality lower limit or the average gray level of the target area is lower than the preset target gray level lower limit, the channel current optimization is re-executed after relaxing in a graded relaxation order.

6. The method according to claim 5, characterized in that, Algorithm parameter fine-tuning includes: dividing the sample workpieces into an optimization set and a validation set according to a preset division ratio; performing two rounds of item-by-item search on the algorithm parameters of each algorithm tool in the tool topology order on the optimization set, taking the maximum sample recognition rate as the criterion. The sample recognition rate is the ratio of the number of sample workpieces whose judgment results match the pre-known category to the total number of sample workpieces. When the maximum value of the sample recognition rate corresponds to a continuous value interval, the midpoint of the interval is taken; verifying the sample recognition rate on the validation set, if the verification result reaches the preset pass line, entering baseline calibration; if the verification result is lower than the preset pass line, expanding the sample workpieces and re-executing. The algorithm parameters are fine-tuned, and an optimization failure prompt is generated when the number of repetitions reaches the preset retry limit. Before baseline calibration, a linear area verification is performed: the 99.5th percentile gray value of the high gray level area is less than or equal to the maximum quantization value multiplied by the preset saturation margin ratio, and the average gray level of the low gray level area is greater than the preset low gray level limit. If either of these conditions is exceeded, the entire optimization range is multiplied by the preset reduction ratio and the channel current optimization is re-executed. The baseline data also includes the baseline mean and standard deviation of the gray level difference under the full channel illumination state, the baseline value of the gray level difference under the single channel illumination state of each light source channel, and the baseline value of the sharpness evaluation value.

7. The method according to claim 6, characterized in that, Drift attribution is performed in a fixed priority order of illumination, focus, and process. The grayscale extraction area for grayscale difference is the center of the high grayscale area and the low grayscale area, respectively, and the distance from the area boundary is greater than the preset maximum blur radius. An exponentially weighted moving average control chart is used to monitor the grayscale difference under the illumination state of all channels. When the control chart exceeds the limit, it is judged as illumination drift. When the grayscale difference is within the control limit and the sharpness evaluation value is lower than the lower limit threshold, it is judged as defocus drift. The lower limit threshold is the baseline value of the sharpness evaluation value multiplied by the preset sharpness ratio. When both the grayscale difference and sharpness evaluation values ​​are within their respective limits, but the operational pass rate exceeds the operational pass rate baseline, it is determined that the issue is due to changes in incoming materials or algorithm parameters. The operational pass rate baseline is determined based on the pass rate statistics at the initial stage of production. Proportional adjustment includes: individually flashing and acquiring calibration frames channel by channel within the detection gap between adjacent workpieces to obtain the current grayscale difference value of each light source channel under single-channel illumination. For each light source channel, the adjusted light source channel current is equal to the original light source channel current multiplied by the ratio of the baseline grayscale difference value under single-channel illumination to the current grayscale difference value under single-channel illumination. The adjustment result is limited to between the upper and lower limits of the value range. After compensation, the grayscale difference under the full channel illumination state is retested. When the deviation between the retested value and the baseline mean is within 3%, the compensation is considered complete. If the deviation still exceeds 3% after 3 repetitions, the algorithm parameter optimization suggestion is generated. After the compensation is completed, the running judgment pass rate is recalculated. If it exceeds the running judgment pass rate baseline, the algorithm parameter optimization suggestion is generated. When the range of the compensation ratio of each light source channel is less than the preset consistency threshold, it is judged as common optical path attenuation and a maintenance prompt is generated. In the version comparison, only the version change involving algorithm parameters is compared by playback. That is, two versions of algorithm parameters are run in parallel on the production image that is saved in a rolling manner, and the images with different judgment results are manually reviewed. For version changes involving optical formulations, an alternating real-world comparison method is used. This involves triggering two consecutive acquisitions within the detection window of the same workpiece, imaging and judging according to the two versions of the optical formulation respectively. If the interval between the two triggers is greater than the larger of the preset stabilization time of the liquid zoom lens and the light source current establishment time, and the detection window duration is less than the duration required for two acquisitions, or if the workpiece displacement within the interval between the two triggers causes the target area to deviate beyond the preset positioning tolerance, the two versions are applied alternately grouped according to the number of workpieces in the preset group. After rollback, automatic re-optimization under the same trigger condition is paused within the preset suppression period, and maintenance prompts are generated. After the version switch is completed, baseline data is re-recorded and the operational judgment pass rate baseline band is rebuilt.

8. An industrial vision intelligent agent system, characterized in that, The system includes a workflow planning module, a workflow verification module, an industrial vision operation module, a workflow evolution management module, a workflow repository, a knowledge base, an industrial camera, a programmable light source controller, a multi-channel LED light source, a liquid zoom lens, and a reference calibration block. The programmable light source controller supports switching the light source channel current and the light source flicker pulse width frame by frame according to the trigger sequence. The industrial vision intelligent agent system is configured to execute the industrial vision intelligent agent construction method based on the full life cycle of workflow as described in any one of claims 1 to 7.

9. An electronic device, characterized in that, It includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the steps of the industrial vision intelligent agent construction method based on workflow full lifecycle driving as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, A computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the industrial vision intelligent agent construction method based on workflow-driven full lifecycle as described in any one of claims 1 to 7.