An online size detection and error compensation method based on machine vision
Patent Information
- Application Number
- CN202611015974.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-09
- Publication Date
- 2026-08-28
AI Technical Summary
[0002]现有机器视觉在线尺寸检测方案仅采用单一采集光路获取工件图像序列开展边缘轮廓提取与尺寸度量计算,工位照明光线强度、色温持续波动会改变工件表面成像灰度分布,环境温度变化引发相机、工件热形变造成像素空间标定坐标偏移,工件自身表面反射差异、纹理凹凸起伏会让边缘灰度跃变边界模糊,全部干扰因素叠加后直接生成固定的初始尺寸度量参数,整套流程不区分各类干扰带来的尺寸偏差成因,原始检测数值始终携带稳定存在的系统性测量误差,在线检测输出数据一致性较差
1、本发明通过调节照明入射角度实现工件全域均匀照度成像,搭配双光路分批次曝光采集多方位图像构建完整图像序列;逐像素识别灰度跳变边缘像素并依托采集方位-空间映射关系完成三维轮廓标定,沿尺寸特征配对空间关键特征点计算得到初始尺寸度量;通过比对尺寸数值与标准区间上下边界区分正向、负向偏差,结合预设偏离阈值划分轻度、重度偏差并绑定生成标准化误差识别标识,可完整、分层捕获尺寸偏差的产生方向、偏差幅度与偏离严重等级,解决传统单光路成像边缘模糊、偏差类型无法细分的缺陷。
Smart Images

Figure CN122657221A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of machine vision technology, and in particular to an online size detection and error compensation method that integrates machine vision. Background Technology
[0002] Existing machine vision online dimension inspection solutions only use a single acquisition optical path to obtain workpiece image sequences for edge contour extraction and dimension measurement calculation. The continuous fluctuation of the intensity and color temperature of the workstation lighting will change the grayscale distribution of the workpiece surface imaging. Changes in ambient temperature will cause thermal deformation of the camera and workpiece, resulting in pixel spatial calibration coordinate shifts. Differences in the reflection of the workpiece surface and the unevenness of the texture will cause the edge grayscale jumps and blur the boundaries. After all the interference factors are superimposed, a fixed initial dimension measurement parameter is directly generated. The entire process does not distinguish the causes of dimension deviation caused by various interferences. The original detection values always carry a stable and existing systematic measurement error, resulting in poor consistency of online detection output data.
[0003] Existing machine vision dimensional inspection systems use a fixed preset reference dimensional range as the sole criterion for qualification. During the batch online production of workpieces, the environment and workpiece surface features will continuously change with the production time. The system cannot collect relevant features such as lighting, temperature, and surface texture in real time to adaptively correct the reference dimensional range. Measurement errors caused by various interferences will accumulate and amplify with each batch of inspections. The workpiece dimensional qualification criteria will always be out of touch with the real-time working conditions. Under long-term continuous online inspection conditions, the dimensional inspection accuracy and the adaptability of the judgment criterion will continue to decline, resulting in insufficient reliability of the inspection results. Summary of the Invention
[0004] This invention provides an online size detection and error compensation method that integrates machine vision to solve the problems mentioned in the background art.
[0005] To achieve the above objectives, the present invention provides an online size detection and error compensation method integrating machine vision, comprising: Pt.1 Extract edge contour data from the image sequence of the target object, and generate the initial size measurement parameters of the target object based on the edge contour data; Pt.2. Compare the initial size measurement parameter with the preset reference size range. When the initial size measurement parameter exceeds the preset reference size range, obtain the deviation direction and deviation magnitude, and generate an error identification mark. Pt.3 When the error identification flag indicates a deviation, environmental parameters and surface attribute parameters are acquired, a compensation adjustment direction is determined based on the environmental parameters and surface attribute parameters, compensation is applied to the initial size measurement parameters according to the compensation adjustment direction, and a compensated size measurement parameter is generated. Pt.4. The compensated size measurement parameters are fused with the preset reference size range to update the preset reference size range, and the updated preset reference size range is used as the judgment criterion for subsequent detection.
[0006] In a preferred embodiment, the image sequence of the target object includes: Illumination light is projected onto the workstation where the target object is located. The incident angle of the illumination light is adjusted so that the illumination light forms a uniform illuminance distribution on the surface of the target object. The target object under the uniform illuminance distribution is used as the object to be collected. In the collection environment where the object to be collected is located, a collection optical path corresponding to the incident direction of the illumination light is selected, and the collection optical path is used as the collection posture; Trigger the exposure operation according to the acquisition posture, record the target object image generated by the exposure operation, and use the target object image as the first orientation image; The acquisition optical path is switched, and the exposure operation is repeated under the switched acquisition optical path to obtain a second azimuth image. The first azimuth image and the second azimuth image constitute the image sequence.
[0007] In a preferred embodiment, the step of extracting edge contour data from the image sequence of the target object and generating initial size measurement parameters of the target object based on the edge contour data includes: Edge detection is performed on the images in the image sequence to extract the pixel positions in the image where the gray value changes abruptly, and the pixel positions where the gray value changes abruptly are used as edge pixels. The image position of the edge pixel in the image is obtained, and the calibration position of the edge pixel in the actual space is determined according to the mapping relationship between the image position and the acquisition orientation corresponding to the image to which the edge pixel belongs, and the calibration position is used as the edge contour data. Traverse the calibration positions in the edge contour data along the size feature direction of the target object, select pairs of calibration positions that are in relative positions along the size feature direction, and use the pairs of calibration positions as key feature point pairs; Obtain the spatial distance between the two calibration positions contained in the key feature point pair, and use the spatial distance as the initial size measurement parameter of the target object.
[0008] In a preferred embodiment, comparing the initial size measurement parameter with a preset reference size range, and when the initial size measurement parameter exceeds the preset reference size range, obtaining the deviation direction and deviation magnitude, and generating an error identification identifier, includes: Read the upper and lower bound values of the preset reference size range, and use the upper and lower bound values as a reference boundary pair; The initial size metric parameter is compared with the upper bound value in the reference boundary pair to obtain the upper position of the initial size metric parameter relative to the upper bound value; The initial size metric parameter is compared with the lower bound value in the reference boundary pair to obtain the lower position of the initial size metric parameter relative to the lower bound value; When the upper position indicates that the initial size measurement parameter is higher than the upper limit value, the deviation direction is determined as the positive deviation direction; When the lower position indicates that the initial size measurement parameter is lower than the lower boundary value, the deviation direction is determined to be a negative deviation direction; The deviation direction is defined as either the positive deviation direction or the negative deviation direction. When the deviation direction is a positive deviation direction, the upper distance between the initial size measurement parameter and the upper limit value is obtained, and the upper distance is used as the deviation amplitude; When the deviation direction is a negative deviation direction, the lower distance between the lower boundary value and the initial size measurement parameter is obtained, and the lower distance is used as the deviation amplitude.
[0009] In a preferred embodiment, the step of comparing the initial size measurement parameter with a preset reference size range, and when the initial size measurement parameter exceeds the preset reference size range, obtaining the deviation direction and deviation magnitude, and generating an error identification identifier, further includes: Obtain the deviation of the initial size measurement parameter from the preset reference size range, and read the preset degree judgment threshold, which includes the deviation degree distinction boundary; The deviation magnitude is compared with the deviation degree distinction boundary. When the deviation magnitude is within the deviation degree distinction boundary, a slight deviation indicator is generated. When the deviation magnitude is outside the deviation degree distinction boundary, a severe deviation indicator is generated; The deviation direction is combined with the slight deviation identifier to generate a slight error identification identifier, and the deviation direction is combined with the severe deviation identifier to generate a severe error identification identifier.
[0010] In a preferred embodiment, the step of acquiring environmental parameters and surface property parameters when the error identification flag indicates a deviation includes: Read the output light intensity parameters and color temperature parameters of the light source at the workstation where the target object is located, and use the output light intensity parameters and color temperature parameters as lighting status information; Spectral intensity distribution features are extracted from the lighting state information, and these spectral intensity features are used as ambient light features. The ambient temperature value of the workstation where the target object is located is read, and the ambient temperature value is combined with the ambient light characteristics to generate an environmental parameter characterization.
[0011] In a preferred embodiment, the step of acquiring environmental parameters and surface property parameters when the error identification marker indicates a deviation further includes: From the image sequence, an image region covering the surface area of the target object is selected, and the brightness values of the pixels within the image region are read to obtain the pixel brightness distribution of the target object. The pixel brightness distribution is used as the surface reflection feature. The brightness values of adjacent pixels in the pixel brightness distribution are compared to determine the difference, and a brightness difference sequence between adjacent pixels is obtained. The brightness difference sequence is used as a surface texture feature. The positions of the extreme brightness values in the pixel brightness distribution are calibrated to obtain the extreme brightness value positions. The span between the extreme brightness value positions is measured to obtain the span between the extreme brightness value positions. The span is used as a surface undulation feature. The surface reflection features, surface texture features, and surface undulation features are combined to obtain the surface attribute parameters of the target object.
[0012] In a preferred embodiment, the step of determining the compensation adjustment direction based on the environmental parameters and the surface property parameters, applying compensation to the initial size measurement parameters according to the compensation adjustment direction, and generating compensated size measurement parameters includes: Illumination intensity and ambient temperature are extracted from the environmental parameters, and surface reflectance and surface undulation amplitude are extracted from the surface property parameters. The exposure parameters of the target object during image acquisition are obtained. The exposure parameters include exposure duration and gain value. The exposure duration characterization value and gain characterization value are extracted from the exposure parameters. The first compensation component is determined by the following relationship between the light intensity characterization value, the surface reflectance characterization value, and the exposure time characterization value: ; in, This is the first compensation component. The light intensity characterization value is... This is the surface reflectivity characterization value. This is the value representing the exposure duration. This is the preset spectral distribution coefficient of the light source; The second compensation component is determined by the following relationship between the ambient temperature characterization value, the surface undulation amplitude characterization value, and the gain characterization value: ; in, This is the second compensation component. The temperature difference between the ambient temperature value and the preset reference temperature value. This is a characterization value for the surface undulation amplitude. The gain characterization value is... The preset temperature gain coupling coefficient; The direction of the combination of the first compensation component and the second compensation component is taken as the compensation adjustment direction; Based on the compensation adjustment direction, the first compensation component and the second compensation component are applied to the initial size measurement parameter, and the initial size measurement parameter after applying the first compensation component and the second compensation component is used as the compensated size measurement parameter.
[0013] In a preferred embodiment, fusing the compensated dimensional measurement parameters with the preset reference dimensional range includes: Read the upper and lower bound values of the preset reference size range, with the upper bound value as the upper limit of the range and the lower bound value as the lower limit of the range; Obtain the upper limit difference between the compensated size measurement parameter and the upper limit of the range, and obtain the lower limit difference between the compensated size measurement parameter and the lower limit of the range; When both the upper limit difference and the lower limit difference are within the preset fusion allowable range, the compensated size metric parameter is used as the metric value to be fused. The metric value to be merged is merged with the upper limit of the range and the lower limit of the range according to a preset weight ratio. The merged upper limit of the range is used as the updated upper limit of the range, and the merged lower limit of the range is used as the updated lower limit of the range. The updated preset reference size range is formed by the updated upper limit and the updated lower limit.
[0014] In a preferred embodiment, updating the preset reference size range and using the updated preset reference size range as the criterion for subsequent detection includes: Read the upper and lower bound values of the updated preset reference size range, and use the upper bound value as the upper limit of the updated range and the lower bound value as the lower limit of the updated range. Compare the updated upper limit of the range with the updated lower limit of the range. When the updated upper limit of the range is greater than the updated lower limit of the range and the change in the upper limit between the updated upper limit of the range and the upper limit of the range before the update is within a preset allowable range, and the change in the lower limit between the updated lower limit of the range and the lower limit of the range before the update is within a preset allowable range, the updated preset reference size range is confirmed as a valid update range. The effective update range is set as the current effective size range, and the current effective size range is used to replace the original preset reference size range as the judgment benchmark for target object size detection. The newly acquired size measurement parameters of the target object to be tested are compared with the upper and lower bounds of the current effective size range, and the size qualification status of the target object to be tested is determined according to the comparison result.
[0015] Compared with the prior art, the present invention has the following beneficial effects: 1. This invention achieves uniform illumination imaging across the entire workpiece by adjusting the incident angle of illumination, and constructs a complete image sequence by acquiring multi-directional images in batches using dual-light-path exposure; it identifies grayscale transition edge pixels pixel by pixel and completes three-dimensional contour calibration based on the acquisition orientation-space mapping relationship, and calculates the initial size measurement by pairing key spatial feature points along the size features; it distinguishes positive and negative deviations by comparing the size values with the upper and lower boundaries of the standard interval, and classifies mild and severe deviations by combining preset deviation thresholds and binding them to generate standardized error identification marks, which can completely and hierarchically capture the direction of generation of size deviation, deviation amplitude and deviation severity level, and solve the defects of traditional single-light-path imaging such as blurred edges and inability to distinguish deviation types.
[0016] 2. Existing machine vision inspection compensation schemes can only make independent corrections for a single interference source among illumination, temperature, and surface morphology, and cannot handle the systematic measurement drift caused by the coupling and superposition of multiple factors. This invention innovatively constructs a two-set coupled compensation component collaborative correction model: the first compensation component is calculated based on illumination intensity, workpiece reflectivity, and exposure time to offset optical imaging errors, and the second compensation component is calculated based on temperature difference, surface undulation, and camera gain to offset thermal deformation and surface morphology errors. The two components are fused to determine a unified compensation adjustment direction and synchronously correct the initial size value, thereby eliminating the composite measurement error caused by the superposition of multiple types of interference in one go and significantly reducing the system drift of long-term online inspection.
[0017] 3. This invention performs weighted fusion updates on the effective dimensional data after dual-component coupling compensation, combined with differentiated fusion weights for mild / severe deviation matching, and the original reference dimensional range. After the updated range undergoes dual validity verification of upper and lower limits and range variation amplitude, it replaces the original fixed judgment benchmark. This enables the inspection qualification standard to be adaptively and dynamically adjusted according to on-site lighting, temperature, and workpiece surface conditions, avoiding the problems of accumulated errors in the traditional constant reference range with production batches and the judgment standard deviating from real-time conditions. This continuously ensures the dimensional measurement accuracy and judgment adaptability of batch online inspections, and improves the reliability of long-term continuous inspection results. Attached Figure Description
[0018] Figure 1 This is a flowchart illustrating an online size detection and error compensation method integrating machine vision, provided in an embodiment of the present invention. Figure 2 A schematic diagram of the three-dimensional geometric layout of a multi-optical path acquisition station for an online size detection and error compensation method integrating machine vision, provided in an embodiment of the present invention; Figure 3 This is a diagram showing the relationship between edge pixel extraction of an image sequence and projection mapping in three-dimensional actual space, provided by an embodiment of the present invention, for an online size detection and error compensation method that integrates machine vision.
[0019] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0020] It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
[0021] This application provides an online size detection and error compensation method integrating machine vision. The execution entity of this online size detection and error compensation method integrating machine vision includes, but is not limited to, at least one of the following electronic devices that can be configured to execute the method provided in this application: a server, a terminal, etc. In other words, the online size detection and error compensation method integrating machine vision can be executed by software or hardware installed on a terminal device or a server device. The server includes, but is not limited to, a single server, a server cluster, a cloud server, or a cloud server cluster. The server can be an independent server or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms.
[0022] Reference Figure 1The diagram shown is a flowchart illustrating an online size detection and error compensation method integrating machine vision according to an embodiment of the present invention. In this embodiment, the online size detection and error compensation method integrating machine vision includes: Pt.1 Extract edge contour data from the image sequence of the target object, and generate the initial size measurement parameters of the target object based on the edge contour data; In this embodiment of the invention, the image sequence of the target object includes: Illumination light is projected onto the workstation where the target object is located. The incident angle of the illumination light is adjusted so that the illumination light forms a uniform illuminance distribution on the surface of the target object. The target object under the uniform illuminance distribution is used as the object to be collected. In the collection environment where the object to be collected is located, a collection optical path corresponding to the incident direction of the illumination light is selected, and the collection optical path is used as the collection posture; Trigger the exposure operation according to the acquisition posture, record the target object image generated by the exposure operation, and use the target object image as the first orientation image; The acquisition optical path is switched, and the exposure operation is repeated under the switched acquisition optical path to obtain a second azimuth image. The first azimuth image and the second azimuth image constitute the image sequence.
[0023] The step of extracting edge contour data from the image sequence of the target object and generating initial size measurement parameters of the target object based on the edge contour data includes: Edge detection is performed on the images in the image sequence to extract the pixel positions in the image where the gray value changes abruptly, and the pixel positions where the gray value changes abruptly are used as edge pixels. The image position of the edge pixel in the image is obtained, and the calibration position of the edge pixel in the actual space is determined according to the mapping relationship between the image position and the acquisition orientation corresponding to the image to which the edge pixel belongs, and the calibration position is used as the edge contour data. Traverse the calibration positions in the edge contour data along the size feature direction of the target object, select pairs of calibration positions that are in relative positions along the size feature direction, and use the pairs of calibration positions as key feature point pairs; Obtain the spatial distance between the two calibration positions contained in the key feature point pair, and use the spatial distance as the initial size measurement parameter of the target object.
[0024] Before performing online inspection, the acquisition system must be set up and calibrated in advance. The acquisition system consists of two industrial area array cameras, each fixed on a rigid bracket. The angle between the optical axis of the two cameras and the normal to the workpiece inspection plane is a fixed angle; for example, one camera's optical axis is at -30 degrees to the normal, and the other at +30 degrees. Each camera is equipped with a telecentric lens, which has a constant magnification within the working distance and a distortion rate of less than 0.1%. A uniform backlight or ring light source is set at the workpiece station to ensure uniform illumination on the workpiece surface. Calibration uses a high-precision ceramic checkerboard calibration plate, the dimensions of which have been metrologically certified. During calibration, the calibration plate is placed on the same plane as the workpiece surface to be measured, and the camera exposure and gain are adjusted to make the calibration plate image clear. Then, at least fifteen sets of calibration plate images in different poses are acquired. Using calibration functions from the vision library, the intrinsic parameter matrix of each camera is calculated, including focal length, principal point coordinates, and radial and tangential distortion coefficients. Simultaneously, the extrinsic parameter matrix of each camera is calculated, including rotation and translation vectors, thus obtaining the relative pose relationship between the two cameras. After calibration, the reprojection error is calculated. If the error is greater than 0.1 pixels, recalibration is performed until the accuracy requirements are met. For reprojection errors of 0.1~0.2 pixels: only the camera's three-axis fine-tuning knobs are adjusted, and 5 sets of calibration board images are locally reacquired for secondary calibration; for reprojection errors > 0.2 pixels: the original calibration parameters are cleared, and 15 sets of calibration board images are fully acquired for complete recalibration. The calibration results are saved to the system configuration file for subsequent online detection.
[0025] Directional lighting is output to the built-in lighting equipment at the workstation. The placement and tilt angle of the lighting equipment are continuously adjusted until the amount of light received by the entire outer surface area of the workpiece reaches the preset uniform illuminance threshold. After the light uniform coverage process is completed, the workpiece is fixed as the object to be collected.
[0026] By comparing the current light projection angle of the lighting equipment, a dedicated acquisition light path is formed by the combination of the lens and the photosensitive component. The lens placement angle and the fixed position of the photosensitive element corresponding to this light path are locked to form a standardized acquisition posture.
[0027] Maintain the locked acquisition posture without displacement, initiate the exposure action of the photosensitive component, and completely preserve the complete workpiece image generated after the photosensitive component receives light. Name this image the first orientation image.
[0028] Adjust the combination and placement of the lens and photosensitive component, replace the new acquisition optical path, and repeat the photosensitive component exposure action while maintaining a uniform illumination threshold. Completely preserve the workpiece image generated by this exposure and name it the second-position image.
[0029] The acquired first and second azimuth images are uniformly archived and bound. In actual inspection scenarios, a third and fourth acquisition optical path can be added according to the workstation space size and inspection accuracy requirements to acquire the corresponding third and fourth azimuth images. The first, second, and any additional acquired azimuth images together constitute an image sequence of the target object. This image sequence covers two or more azimuth image sets. The more azimuth images there are, the more complete the edge contour coverage and the more stable the size measurement results. There are no strict restrictions on the acquisition order of each azimuth image, but it must be ensured that each azimuth image undergoes spatial mapping based on the same calibration parameters.
[0030] During image acquisition, if any single image in the first or second orientation image fails to acquire, is severely overexposed or underexposed, or has missing edge contour data exceeding a predetermined proportion due to instantaneous fluctuations in the light source, lens surface contamination, camera trigger signal delay, or data transmission packet loss, the system immediately identifies this abnormal state and initiates degradation processing logic. Under degradation processing logic, the system marks the failed orientation image and suspends subsequent repeated acquisition attempts in that orientation. Only the successfully acquired single orientation image is used as the sole data source. Edge contour data is extracted based on this single orientation image, and the edge pixel coordinates are mapped to the calibration position in actual space according to the camera projection matrix corresponding to the single image. When only a single orientation image remains, the system abandons the size calculation method relying on dual-field-of-view triangulation reconstruction and instead uses a simplified single-path compensation model to perform size measurement. This simplified single-path compensation model only extracts the illumination intensity and ambient temperature characterization values from the environmental parameters, ignoring the surface texture and surface undulation features from the surface attribute parameters. A first-order linear correction is applied to the initial size measurement parameters, and the correction coefficient is determined by the single-path compensation coefficient obtained in advance through calibration experiments.
[0031] When only a single azimuth image exists, the system abandons the size calculation method relying on dual-field-of-view triangulation and instead uses a simplified single-path compensation model to perform size measurement. This simplified single-path compensation model extracts only the illumination intensity and ambient temperature values from the environmental parameters, ignoring surface texture and surface undulation features from the surface attribute parameters. A first-order linear correction is applied to the initial size measurement parameters, with the correction coefficient determined by the single-path compensation coefficients obtained through pre-calibration experiments. The formula for the first-order linear correction using the single-path model is: C single =k×E+m×ΔT, Where C singleΔT represents the total compensation value for a single optical path, k is the single optical path compensation coefficient for illumination, and m is the single optical path compensation coefficient for temperature. k and m are obtained by least-squares fitting calibration of the standard calibration block under multi-gradient illumination and temperature conditions, k∈[0.00001,0.00005], m∈[0.0005,0.002]; ΔT represents the temperature difference between the current station ambient temperature characterization value and the system preset reference temperature value; the material and surface roughness of the standard calibration block used for calibration are consistent with the target workpiece to be measured. After calibration, the two sets of coefficients are permanently stored in the system configuration file. In degraded mode, the first-order linear compensation correction of the initial size measurement parameters is directly called.
[0032] In degraded mode, the overall inspection cycle of the detection system is reduced, but the inspection process remains continuous to ensure uninterrupted online inspection. Once the system successfully acquires two or more qualified azimuth images consecutively, it automatically exits degraded mode and switches back to standard multi-path detection mode. Degraded mode is triggered when three or more consecutive frames of acquired images are unqualified (overexposed / underexposed / edge loss > 30%). If only a single frame is damaged, the valid dual-path data from the previous frame is retained, and degraded mode is not switched. Degraded mode can last for a maximum of 100 frames; if two qualified images cannot be acquired within 100 frames, a hardware malfunction alarm is reported.
[0033] Before performing edge detection, the pixel equivalent is pre-calculated based on the calibration board image. The pixel equivalent is calculated as follows: the number of pixels between adjacent grid points of known actual length on the calibration board is read, and the known actual length is divided by the number of pixels to obtain the actual physical size value corresponding to a single pixel. This pixel equivalent serves as the unified benchmark for all subsequent spatial distance conversions. The preset grayscale transition judgment threshold is set to a grayscale difference between adjacent pixels greater than forty grayscale levels. All adjacent pixels in the image along the horizontal and vertical directions are traversed. When the grayscale difference between adjacent pixels exceeds forty grayscale levels, the pixel position is determined to be an edge pixel. After conversion using the pixel equivalent, this grayscale difference threshold corresponds to an edge positioning deviation in actual space of no more than 0.02 millimeters.
[0034] After obtaining the image coordinates of edge pixels in the image, distortion correction is first performed on the image coordinates using the corresponding camera calibration parameters to obtain distortion-free image coordinates. Then, based on the projection matrix of the acquisition orientation (obtained by multiplying the intrinsic and extrinsic parameter matrices), the distortion-free image coordinates are mapped to planar coordinates in the world coordinate system. If there are height variations on the workpiece surface, a depth map of the workpiece surface is pre-obtained using structured light or laser scanning, and the planar coordinates and depth values are combined to synthesize the three-dimensional calibration position in actual space. For dual-camera stereo measurement, the epipolar constraints of both cameras can be used simultaneously for three-dimensional reconstruction to obtain more accurate spatial coordinates. All calculated three-dimensional spatial coordinate points are uniformly used as edge contour data.
[0035] The preset pairing distance threshold is set to 0.5 mm. During the traversal, two sets of calibration positions located relative to each other in the direction of the workpiece's dimensional features are selected sequentially. The spatial straight-line distance between the two sets of calibration positions is calculated. If the distance value is less than 0.5 mm, the two sets of calibration positions are paired as a key feature point pair. If the distance value is greater than or equal to 0.5 mm, the pair is skipped and the traversal of subsequent calibration positions continues until all traversals are completed, and all key feature point pairs that meet the distance condition are selected.
[0036] The physical interval distance between two spatial calibration positions of a single set of key feature points is measured with reference to the unified length measurement standard of real-world space. This physical interval distance is directly used as the initial size measurement parameter of the target object.
[0037] Pt.2. Compare the initial size measurement parameter with the preset reference size range. When the initial size measurement parameter exceeds the preset reference size range, obtain the deviation direction and deviation magnitude, and generate an error identification mark. In this embodiment of the invention, comparing the initial size measurement parameter with a preset reference size range, and when the initial size measurement parameter exceeds the preset reference size range, obtaining the deviation direction and deviation magnitude, and generating an error identification identifier, includes: Read the upper and lower bound values of the preset reference size range, and use the upper and lower bound values as a reference boundary pair; The initial size metric parameter is compared with the upper bound value in the reference boundary pair to obtain the upper position of the initial size metric parameter relative to the upper bound value; The initial size metric parameter is compared with the lower bound value in the reference boundary pair to obtain the lower position of the initial size metric parameter relative to the lower bound value; When the upper position indicates that the initial size measurement parameter is higher than the upper limit value, the deviation direction is determined as the positive deviation direction; When the lower position indicates that the initial size measurement parameter is lower than the lower boundary value, the deviation direction is determined to be a negative deviation direction; The deviation direction is defined as either the positive deviation direction or the negative deviation direction. When the deviation direction is a positive deviation direction, the upper distance between the initial size measurement parameter and the upper limit value is obtained, and the upper distance is used as the deviation amplitude; When the deviation direction is a negative deviation direction, the lower distance between the lower boundary value and the initial size measurement parameter is obtained, and the lower distance is used as the deviation amplitude.
[0038] The step of comparing the initial size measurement parameter with a preset reference size range, and obtaining the deviation direction and deviation magnitude when the initial size measurement parameter exceeds the preset reference size range, and generating an error identification mark, further includes: Obtain the deviation of the initial size measurement parameter from the preset reference size range, and read the preset degree judgment threshold, which includes the deviation degree distinction boundary; The deviation magnitude is compared with the deviation degree distinction boundary. When the deviation magnitude is within the deviation degree distinction boundary, a slight deviation indicator is generated. When the deviation magnitude is outside the deviation degree distinction boundary, a severe deviation indicator is generated; The deviation direction is combined with the minor deviation indicator to generate a minor error identification indicator, and the deviation direction is combined with the major deviation indicator to generate a major error identification indicator. After the system identifies the major error identification indicator, it simultaneously triggers an audible and visual alarm on the host computer, activates the production line diversion and rejection mechanism, and automatically saves all images, environmental parameters, and compensation parameters of the workpiece to the defective product database. When five consecutive workpieces show major deviations, a temporary production line stoppage verification reminder is triggered.
[0039] Retrieve two fixed values corresponding to the preset reference size range that have been pre-entered in the local storage area of the system. The larger value is fixed as the upper limit value, and the smaller value is fixed as the lower limit value. Bind and store the two sets of values to form a complete reference boundary pair.
[0040] Retrieve the initial size measurement parameters of the target object obtained by converting edge contour data, compare the length value corresponding to the initial size measurement parameters with the upper bound value stored in the reference boundary, and record the size correspondence between the initial size measurement parameters and the upper bound value after comparison. This correspondence is uniformly named the upper position.
[0041] Retrieve the initial size measurement parameters of the target object obtained by converting edge contour data, compare the length value corresponding to the initial size measurement parameters with the lower bound value stored in the reference boundary, and record the size correspondence between the initial size measurement parameters and the lower bound value after comparison. This correspondence is uniformly named the lower position state.
[0042] Read the numerical correspondence recorded in the upper position state. When the recorded value of the initial size measurement parameter is greater than the upper limit value, fix the deviation direction corresponding to the current working condition as the positive deviation direction.
[0043] Read the numerical correspondence recorded in the position below. When the recorded value of the initial size measurement parameter is less than the lower limit value, fix the deviation direction corresponding to the current working condition as the negative deviation direction.
[0044] The positive or negative deviation direction determined will be stored separately as the deviation direction corresponding to this detection, without adding other types of orientation determination results.
[0045] The confirmed positive deviation direction is read as the judgment benchmark. The length difference between the corresponding value of the initial size measurement parameter and the upper limit value is measured according to the unified length measurement standard of the real scene. This length difference is uniformly named the upper gap and is directly defined as the deviation amplitude corresponding to this test.
[0046] The confirmed negative deviation direction is read as the judgment benchmark. The length difference between the lower limit value and the corresponding value of the initial size measurement parameter is measured according to the unified length measurement standard of the real scene. This length difference is uniformly named the lower gap and is directly defined as the deviation amplitude corresponding to this test.
[0047] Retrieve the deviation range value calculated in the previous process step, and retrieve the preset degree judgment threshold that has been pre-entered in the local storage unit of the equipment. The preset degree judgment threshold stores a single fixed-length value as the boundary for distinguishing the degree of deviation. This boundary value is preset according to the maximum small deviation standard allowed for batch production of the workpiece.
[0048] The fixed length value for distinguishing the degree of deviation is set to 0.02 mm. The length value corresponding to the deviation range is compared with this 0.02 mm boundary value. When the deviation range is less than or equal to 0.02 mm, it is judged as a slight deviation. The system generates a slight deviation label, which is then stored independently along with all the dimensional data corresponding to this test.
[0049] The complete deviation amplitude value is retrieved and compared with the fixed length value corresponding to the deviation degree distinction boundary. When the deviation amplitude is greater than 0.02 mm, it is judged as a severe deviation, and the system generates a severe deviation label. This boundary value is preset according to the maximum allowable small deviation standard for batch production of the workpiece. The severe deviation label is independently stored and bound to all dimensional data corresponding to this inspection.
[0050] The deviation direction code determined in the previous process is retrieved and bound to the minor deviation identifier code generated this time. After the two sets of codes are integrated, a complete minor error identification identifier is formed. The minor error identification identifier is archived separately for subsequent compensation logic retrieval.
[0051] The storage code corresponding to the deviation direction determined in the previous process is retrieved and bound to the severe deviation identifier code generated this time. After the two sets of codes are integrated, a complete severe error identification identifier is formed. The severe error identification identifier is archived separately for subsequent compensation logic retrieval.
[0052] If the initial size falls within the preset reference size range, the initial size measurement parameters are output directly, and Pt.3 and Pt.4 are not executed.
[0053] Pt.3 When the error identification indicator indicates a deviation, environmental parameters and surface attribute parameters are acquired, a compensation adjustment direction is determined based on the environmental parameters and surface attribute parameters, compensation is applied to the initial size measurement parameters according to the compensation adjustment direction, and a compensated size measurement parameter is generated. In this embodiment of the invention, when the error identification marker indicates a deviation, acquiring environmental parameters and surface attribute parameters includes: Read the output light intensity parameters and color temperature parameters of the light source at the workstation where the target object is located, and use the output light intensity parameters and color temperature parameters as lighting status information; Spectral intensity distribution features are extracted from the lighting state information, and these spectral intensity features are used as ambient light features. The ambient temperature value of the workstation where the target object is located is read, and the ambient temperature value is combined with the ambient light characteristics to generate an environmental parameter characterization.
[0054] The step of acquiring environmental parameters and surface attribute parameters when the error identification flag indicates a deviation further includes: From the image sequence, an image region covering the surface area of the target object is selected, and the brightness values of the pixels within the image region are read to obtain the pixel brightness distribution of the target object. The pixel brightness distribution is used as the surface reflection feature. The brightness values of adjacent pixels in the pixel brightness distribution are compared to determine the difference, and a brightness difference sequence between adjacent pixels is obtained. The brightness difference sequence is used as a surface texture feature. The positions of the extreme brightness values in the pixel brightness distribution are calibrated to obtain the extreme brightness value positions. The span between the extreme brightness value positions is measured to obtain the span between the extreme brightness value positions. The span is used as a surface undulation feature. The surface reflection features, surface texture features, and surface undulation features are combined to obtain the surface attribute parameters of the target object.
[0055] The step of determining the compensation adjustment direction based on the environmental parameters and the surface property parameters, applying compensation to the initial size measurement parameters according to the compensation adjustment direction, and generating compensated size measurement parameters includes: Illumination intensity and ambient temperature are extracted from the environmental parameters, and surface reflectance and surface undulation amplitude are extracted from the surface property parameters. The exposure parameters of the target object during image acquisition are obtained. The exposure parameters include exposure duration and gain value. The exposure duration characterization value and gain characterization value are extracted from the exposure parameters. The first compensation component is determined by the following relationship between the light intensity characterization value, the surface reflectance characterization value, and the exposure time characterization value: ; in, This is the first compensation component. The light intensity characterization value is... This is the surface reflectivity characterization value. This is the value representing the exposure duration. The light source spectral distribution coefficient is a preset value, which is obtained through calibration using a standard calibration block, and the value range of the light source spectral distribution coefficient is [value missing]. ; The second compensation component is determined by the following relationship between the ambient temperature characterization value, the surface undulation amplitude characterization value, and the gain characterization value: ; in, This is the second compensation component. The temperature difference between the ambient temperature value and the preset reference temperature value. This is a characterization value for the surface undulation amplitude. The gain characterization value is... The temperature gain coupling coefficient is a preset value, which is obtained through calibration using a standard calibration block, and the value range of the temperature gain coupling coefficient is [value missing]. ; A positive C1 indicates that the initial size is too large and requires a subtraction correction; a negative C1 indicates that the initial size is too small and requires an addition correction; C2 is positive when ΔT > 0 (ambient temperature is higher than the reference temperature), and negative when ΔT < 0; the final total compensation offset C total =C1+C2, and the size adjustment is uniformly performed according to the positive or negative of the total offset.
[0056] The direction of the combination of the first compensation component and the second compensation component is taken as the compensation adjustment direction; Based on the compensation adjustment direction, the first compensation component and the second compensation component are applied to the initial size measurement parameter, and the initial size measurement parameter after applying the first compensation component and the second compensation component is used as the compensated size measurement parameter.
[0057] The workstation is equipped with a light sensor to collect the corresponding values of light intensity and color temperature of the continuously output light source in real time. The two sets of real-time collected values are collected and stored in a unified manner, and the two sets of collected values are fixedly named as lighting status information.
[0058] By comparing the collected values corresponding to the output light intensity parameters and color temperature parameters stored in the internal lighting status information, the intensity records corresponding to different wavelengths of light are divided into segments, and all light intensity records corresponding to all wavelengths are collected to form a complete spectral intensity distribution feature. The collected spectral intensity distribution feature is fixed as the ambient lighting feature.
[0059] The workstation's built-in temperature acquisition module collects fixed values of the air temperature in the workpiece placement area in real time. The real-time ambient temperature values are then packaged and bound together with the collected ambient light characteristics for unified storage, forming a complete environmental parameter representation.
[0060] The first and second orientation images contained within the previously acquired and stored image sequence of the target object are retrieved. A fixed image area completely encompassing the entire outer surface of the workpiece is defined as the image region according to the image boundary corresponding to the workpiece's physical contour. The brightness storage values of all pixels within the image region are read point by point, and the brightness storage values corresponding to all pixels are summarized to form a pixel brightness distribution. The pixel brightness distribution is then subjected to the following quantization processing: First, the arithmetic mean of the brightness values of all pixels within the image region is calculated and recorded as the average brightness value; then, the average brightness value of a standard whiteboard image under the same lighting conditions is obtained as the reference reflectance brightness value. The average brightness value of the workpiece surface is divided by the reference reflectance brightness value, and the resulting ratio is defined as the surface reflectivity characterization value R. The resulting pixel brightness distribution and surface reflectivity characterization value R are combined and stored as surface reflectance features.
[0061] Following a fixed pixel arrangement within the image region, brightness values corresponding to each pair of adjacent pixels are extracted sequentially. The difference between two sets of brightness values is recorded and archived separately. All difference records corresponding to adjacent pixels are arranged in order of pixel arrangement to form a brightness difference sequence. Statistical quantization is performed on this brightness difference sequence: the average absolute value of all brightness differences in the sequence is calculated to obtain the average adjacent brightness difference value, which characterizes the overall severity of surface texture. The average adjacent brightness difference value is stored separately as a surface texture feature value to aid in determining surface condition, but it is not included in the numerical calculation of the first and second compensation components.
[0062] The system iterates through all stored pixel brightness values in the pixel brightness distribution, selecting pixels whose values reach the preset upper and lower brightness thresholds. These pixels are then recorded with their fixed coordinates within the image to form extreme brightness positions. The distance between each pair of extreme brightness positions is measured according to a standardized image length measurement to obtain the span between these positions. The following quantitative statistics are then applied to all spans: the arithmetic mean of all spans is calculated, and this mean is multiplied by a pixel equivalent conversion factor to convert it into a length value in actual physical space. The result is recorded as the surface undulation feature characterization value H. This H value, in millimeters, is directly used in the subsequent calculation of the second compensation component.
[0063] The three sets of feature records—surface reflection features, surface texture features, and surface undulation features—that were previously stored separately are packaged, bound, and archived together. Specifically, the surface reflectivity characterization value R is extracted from the surface reflection features. This R value is determined by the ratio of pixel brightness distribution to the reference reflectivity value of a standard white board and is dimensionless. The surface undulation amplitude characterization value H is extracted from the surface undulation features. This H value is calculated by multiplying the average span of brightness extreme value locations by the pixel equivalent, and the unit is millimeters. The surface texture feature value is only used as an auxiliary state record and does not participate in the calculation of compensation component values. After the three sets of features are packaged and bound, a complete surface attribute parameter representation of the target object is generated.
[0064] Retrieve the previously integrated environmental parameter representations, separate the ambient light characteristics and ambient temperature values stored within the environmental parameter representations, extract the corresponding light intensity records to form light intensity representation values, extract the corresponding temperature records to form ambient temperature representation values, retrieve the previously integrated surface attribute parameter representations, separate the surface reflection characteristics and surface undulation characteristics stored within the surface attribute parameter representations, extract the corresponding reflectance records to form surface reflectivity representation values, and extract the corresponding undulation interval records to form surface undulation amplitude representation values.
[0065] Retrieve the complete exposure parameters stored by the photosensitive component during the image acquisition stage. The exposure parameters contain fixed values corresponding to the exposure duration and gain recorded throughout the acquisition process. Separate the two types of records within the exposure parameters, extract the exposure duration record to form the exposure duration characterization value, and extract the gain record to form the gain characterization value.
[0066] Before performing online dimensional inspection, the spectral distribution coefficient α of the light source and the temperature gain coupling coefficient β must be calibrated. Calibration uses a standard calibration block, which has a known standard length and a surface material and roughness similar to the target object. During calibration, the standard calibration block is placed at the workstation, and images of the calibration block are acquired under multiple preset light intensity levels and multiple preset ambient temperature conditions. Simultaneously, the actual light intensity, surface reflectivity, exposure time, ambient temperature, surface undulation amplitude, and gain values are recorded for each condition. For each set of acquired parameters, the deviation between the initial dimensional measurement parameters and the known standard size of the calibration block is calculated, and this deviation is used as the compensation target. Using the light source spectral distribution coefficient α and the temperature gain coupling coefficient β as the fitting parameters, the least squares method is used to fit the two sets of compensation component relationships. This ensures that the calculated value of α multiplied by the product of the light intensity and surface reflectivity, divided by the exposure time, is closest to the deviation caused by light factors. Similarly, the calculated value of β multiplied by the product of the temperature difference and surface undulation amplitude, divided by the gain, is closest to the deviation caused by temperature and surface morphology factors. After fitting, the specific values of α and β are obtained. After calibration, the values of α and β are stored in the system configuration file and used consistently in subsequent tests until recalibration occurs due to system hardware changes. To ensure compensation stability and system robustness, the calibration result of α must be within the range of 0.7 to 1.3, and the calibration result of β must be within the range of 0.5 to 1.5. If the calibrated values exceed these ranges, the hardware status must be checked and recalibration performed. For a typical configuration using an industrial area scan camera and a telecentric lens, after multiple experimental measurements, the typical calibration value of β is approximately 1.05. This value can be used as the initial default value, but during the system installation and commissioning phase, it is still necessary to perform precise measurements according to the above calibration procedure to ensure compensation accuracy.
[0067] The system retrieves pre-recorded fixed values of the light source spectral distribution coefficient from the device's local storage unit. The recorded values corresponding to the illumination intensity, surface reflectivity, and exposure time are then sequentially superimposed and converted. The surface reflectivity value R is derived from the surface reflection characteristics in the surface attribute parameter representation, and its specific value is determined by the ratio of the pixel brightness distribution to the reference reflectivity value of the standard white board. After the complete conversion, a first compensation component is generated to offset illumination imaging deviations.
[0068] The system retrieves pre-recorded fixed values for the reference temperature and temperature gain coupling coefficient from the device's local storage. It then sequentially performs numerical superposition and conversion on the recorded values corresponding to the temperature difference, surface undulation amplitude, and gain. The surface undulation amplitude value H is derived from the surface undulation features in the surface attribute parameter representation; its specific value is calculated by multiplying the average span of the brightness extreme value positions by the pixel equivalent, in millimeters. After the complete conversion, a second compensation component is generated to offset the imaging deviation caused by temperature and surface undulation.
[0069] The correction offset direction corresponding to the first compensation component and the correction offset direction corresponding to the second compensation component are read synchronously. The two sets of offset directions are merged and aggregated according to a unified size measurement benchmark to form a unified adjustment offset standard. This unified adjustment offset standard is fixedly named the compensation adjustment direction.
[0070] According to the unified adjustment offset standard corresponding to the compensation adjustment direction completed by the collection, the correction value corresponding to the first compensation component and the correction value corresponding to the second compensation component are synchronously superimposed on the value corresponding to the initial size measurement parameter of the target object obtained in the previous calculation. After the superposition correction operation is completed, a new size value is obtained, which is uniformly named the compensated size measurement parameter.
[0071] The light intensity characterization value is taken from the real-time light intensity acquisition data of the workstation light source recorded in the environmental light characteristics extracted from the integrated environmental parameter characterization.
[0072] The surface reflectivity characterization value is taken from the reflection record data corresponding to the workpiece pixel brightness distribution recorded by the surface reflection features extracted from the integrated surface attribute parameter characterization.
[0073] The exposure duration characterization value is taken from the exposure duration acquisition record data extracted from the exposure parameters retained by the photosensitive component during the image acquisition stage.
[0074] The spectral distribution coefficient of the light source is a fixed correction value that is pre-entered into the local storage unit of the equipment and adapted to the type of lighting source at the workstation.
[0075] The generation logic of the first compensation component is used to uniformly offset the dimensional measurement offset caused by three types of imaging conditions: station illumination intensity, workpiece surface reflectivity, and camera exposure time.
[0076] Read the fixed value of the spectral distribution coefficient of the light source, and perform numerical multiplication on the acquisition records corresponding to the light intensity characterization value, surface reflectance characterization value, and exposure time characterization value in sequence. Then, multiply the result of the multiplication with the fixed value of the spectral distribution coefficient of the light source. After the operation is completed, output the first compensation component.
[0077] The ambient temperature characterization value is taken from the real-time ambient temperature data of the workstations, which is extracted from the integrated environmental parameter characterization.
[0078] The preset reference temperature value is a fixed temperature value that is pre-entered into the device's local storage unit and adapted to standard testing conditions.
[0079] The surface undulation amplitude characterization value is taken from the brightness extreme value span record data of the surface undulation features recorded by the integrated surface attribute parameter characterization.
[0080] The gain characterization value is taken from the gain acquisition record data extracted from the exposure parameters retained by the photosensitive component during the image acquisition stage.
[0081] The temperature gain coupling coefficient is a fixed correction value pre-recorded in the device's local storage unit and adapted to the camera's image sensor.
[0082] The generation logic of the second compensation component is used to uniformly offset the dimensional measurement offset caused by three types of working conditions: station temperature deviation, workpiece surface unevenness, and camera photosensitive gain.
[0083] The temperature difference record is obtained by comparing the collected ambient temperature characterization value with the preset fixed value of the reference temperature. The collected records corresponding to the temperature difference record, the surface fluctuation amplitude characterization value, and the gain characterization value are multiplied in sequence. Then, the result of the multiplication is multiplied with the fixed value of the temperature gain coupling coefficient. After the operation is completed, the second compensation component is output.
[0084] The first compensation component carries the size correction offset information corresponding to illumination imaging interference, and the second compensation component carries the size correction offset information corresponding to temperature and surface morphology interference.
[0085] The logic for generating the compensation adjustment direction is used to integrate the correction offset standards corresponding to the two types of disturbances, providing a unified correction benchmark for the initial size measurement parameters.
[0086] Read the offset correction direction records of the first compensation component and the second compensation component, merge and archive the two sets of offset records according to a unified size measurement standard, and the unified offset standard after merging and archiving is the compensation adjustment direction.
[0087] The compensation correction logic is used to eliminate measurement errors in the initial dimensional parameters caused by various environmental and workpiece surface interferences, according to the offset standard recorded in the compensation adjustment direction. It retrieves the initial dimensional parameters of the target object generated earlier, along with the deviation direction determined earlier. When the deviation direction is positive, it indicates that the initial dimensional parameter is greater than the upper limit of the preset reference dimensional range, and the actual workpiece size is too large. In this case, the first compensation component value and the second compensation component value are added together, and the sum is subtracted from the initial dimensional parameter to obtain the compensated dimensional parameter. When the deviation direction is negative, it indicates that the initial dimensional parameter is less than the lower limit of the preset reference dimensional range, and the actual workpiece size is too small. In this case, the first compensation component value and the second compensation component value are added together, and then added to the initial dimensional parameter to obtain the compensated dimensional parameter. The above compensation rules ensure that the compensated dimensional parameter always approaches the median of the preset reference dimensional range. After the compensation correction is completed, the compensated dimensional parameter is obtained.
[0088] After compensation is completed, the compensated dimensional measurement parameters are compared again with the original preset reference dimensional range. If the compensated dimensional still exceeds the range, it is marked as an uncorrectable out-of-tolerance workpiece. The Pt.4 reference range fusion update process is skipped, and only dimensional data and defective labels are output. It does not participate in the baseline adaptive update.
[0089] Pt.4. The compensated size measurement parameters are fused with the preset reference size range to update the preset reference size range, and the updated preset reference size range is used as the judgment criterion for subsequent detection.
[0090] In this embodiment of the invention, the step of fusing the compensated size measurement parameters with the preset reference size range includes: Read the upper and lower bound values of the preset reference size range, with the upper bound value as the upper limit of the range and the lower bound value as the lower limit of the range; Obtain the upper limit difference between the compensated size measurement parameter and the upper limit of the range, and obtain the lower limit difference between the compensated size measurement parameter and the lower limit of the range; When both the upper limit difference and the lower limit difference are within the preset fusion allowable range, the compensated size metric parameter is used as the metric value to be fused. The metric value to be merged is combined with the upper limit of the range and the lower limit of the range according to a preset weight ratio. The upper limit of the range after merging is used as the upper limit of the updated range, and the lower limit of the range after merging is used as the lower limit of the updated range. The updated preset reference size range is formed by the updated upper limit and the updated lower limit.
[0091] The step of updating the preset reference size range, and using the updated preset reference size range as the judgment criterion for subsequent detection, includes: Read the upper and lower bound values of the updated preset reference size range, and use the upper bound value as the upper limit of the updated range and the lower bound value as the lower limit of the updated range. The updated upper limit and the updated lower limit are compared. If the updated upper limit is greater than the updated lower limit, and the change in the upper limit between the updated upper limit and the previous upper limit is within a preset allowable range, and the change in the lower limit between the updated lower limit and the previous lower limit is within a preset allowable range, then the updated preset reference size range is confirmed as a valid update range. If the updated range does not meet the validity conditions, this fusion update is abandoned, and the effective size range of the previous round is retained; an anomaly flag is added, uploaded to the host computer, and the current operating condition interference is recorded. A single fusion verification failure only abandons this update; if five consecutive fusion verifications fail, the system automatically lowers the fusion weight fluctuation limit (the allowable range is increased by 2 times) and retryes once; if the retry still fails, the baseline is locked and a long-term operating condition anomaly is reported.
[0092] The effective update range is set as the current effective size range, and the current effective size range is used to replace the original preset reference size range as the judgment benchmark for target object size detection. The newly acquired size measurement parameters of the target object to be tested are compared with the upper and lower bounds of the current effective size range, and the size qualification status of the target object to be tested is determined according to the comparison result.
[0093] Retrieve two sets of fixed length values corresponding to the complete preset reference size range stored in the system storage area. The set with the larger value is fixedly defined as the upper limit of the range, and the set with the smaller value is fixedly defined as the lower limit of the range.
[0094] The interval length between the corresponding value of the compensated size measurement parameter and the corresponding value of the upper limit of the range is calculated using the unified real-scene length measurement standard and recorded as the upper limit difference. The interval length between the corresponding value of the compensated size measurement parameter and the corresponding value of the lower limit of the range is calculated using the unified real-scene length measurement standard and recorded as the lower limit difference.
[0095] The default fusion allowable range is set to a length interval of ±0.015 mm. The length interval between the compensated dimensional measurement parameter and the upper limit of the range is recorded as the upper limit difference, and the length interval between the compensated dimensional measurement parameter and the lower limit of the range is recorded as the lower limit difference. The current compensated dimensional measurement parameter will only be used as the measurement value to be fused in subsequent fusion updates if both the upper limit difference and the lower limit difference are within the ±0.015 mm range. If either the upper limit difference or the lower limit difference exceeds this range, the fusion operation will be abandoned, the original default reference size range will remain unchanged, and the fusion abandonment event will be recorded for system log review.
[0096] The error identification flag is retrieved, and the weighting ratio for this fusion is determined based on the type of error identification flag. When the error identification flag is a minor error flag, it indicates that the current dimensional deviation is small, and the reliability of the historical reference dimensional range is high. The first weighting ratio is used for fusion: the original upper and lower limits of the range each retain 70% weight, and the metric to be fused accounts for 30% weight. The length value corresponding to the metric to be fused is multiplied by 0.3, the original upper limit of the range is multiplied by 0.7, and the two products are added together to obtain the updated upper limit of the range; the length value corresponding to the metric to be fused is multiplied by 0.3, the original lower limit of the range is multiplied by 0.7, and the two products are added together to obtain the updated lower limit of the range. When the error identification flag is a major error flag, it indicates that the current dimensional deviation is large, the reliability of the historical reference dimensional range is reduced, and the compensated measurement value is more valuable. The second weighting ratio is used for fusion: the original upper and lower limits of the range each retain 40% weight, and the metric to be fused accounts for 60% weight. The length value corresponding to the metric to be fused is multiplied by 0.6, and the original upper limit of the range is multiplied by 0.4. The products of these two multiplications are added together to obtain the updated upper limit of the range. Similarly, the length value corresponding to the metric to be fused is multiplied by 0.6, and the original lower limit of the range is multiplied by 0.4. The products of these two multiplications are added together to obtain the updated lower limit of the range. Through this differentiated weight fusion method, the update range of the reference size is smaller when there is a slight deviation, maintaining the stability of the historical benchmark. The update range of the reference size is larger when there is a severe deviation, enabling the judgment benchmark to respond quickly to changes in working conditions. The system can have multiple weight configuration tables built-in, which can be pre-entered according to the workpiece accuracy level. In addition to the basic weights of 7:3 for slight deviation and 4:6 for severe deviation, a weight of 2:8 is added for extremely severe deviation (enabled when the deviation range is >0.05mm). All weight parameters are stored in the system's configurable register, supporting on-site manual modification and persistent saving.
[0097] The two sets of values, the upper limit and the lower limit of the updated range generated by merging, are bound and archived. The two sets of values are then combined to form the updated preset reference size range.
[0098] Retrieve the two sets of length values contained in the updated preset reference size range after the previous process integration is completed. The larger value is fixedly named the upper limit of the updated range, and the smaller value is fixedly named the lower limit of the updated range.
[0099] The upper and lower limits of the original range stored before the update are retrieved. The length interval between the updated upper limit and the original upper limit is calculated using a standardized real-scene length measurement method to obtain the upper limit change. Similarly, the length interval between the updated lower limit and the original lower limit is calculated using the same standardized real-scene length measurement method to obtain the lower limit change. The preset allowable change range is set to 5% of the length of each of the upper and lower limits of the original reference size range, and the absolute value of this change must not exceed 0.02 mm. The length interval between the updated upper limit and the original upper limit is used as the upper limit change, and the length interval between the updated lower limit and the original lower limit is used as the lower limit change. The updated preset reference size range is considered a valid update range only when all three of the following conditions are met: First, the updated upper limit value is greater than the updated lower limit value; second, the upper limit change is simultaneously less than 5% of the original upper limit length and its absolute value is less than 0.02 mm; third, the lower limit change is simultaneously less than 5% of the original lower limit length and its absolute value is less than 0.02 mm. If any one of the three conditions is not met, the update will be abandoned, the effective size range of the previous round will be retained, and an anomaly flag will be generated and uploaded to the host computer to record the interference situation of this working condition.
[0100] The valid updated range, after validity verification, replaces the original size range data in the storage area and names it the current effective size range. The device retrieves the newly generated size measurement parameters for subsequent target object detection and compares them sequentially with the upper limit and lower limit of the updated range stored within the current effective size range. If the value of the new size measurement parameter is within the two sets of boundary value intervals, the size of the target object is determined to be in a qualified state. If the value of the new size measurement parameter exceeds the two sets of boundary value intervals, the size of the target object is determined to be in a non-qualified state. The current effective size range is used throughout the process to replace the initially entered preset reference size range to complete all subsequent workpiece size determination work.
[0101] This embodiment uses a standard shaft-type workpiece as the inspection object. The nominal diameter of the workpiece is 25.000 mm, and the preset reference size range is set to 24.980 mm to 25.020 mm. The ambient light intensity at the inspection station is set to 500 lux, and a continuous sinusoidal fluctuation of ±300 lux is applied during the inspection process. The ambient temperature cycles between 22 and 32 degrees Celsius for 20 minutes. The workpiece surface is ground, and the surface roughness Ra value is 0.8 micrometers. The image acquisition system uses two industrial area scan cameras, each equipped with a telecentric lens, with a calibrated pixel equivalent of 0.015 mm per pixel.
[0102] To verify the technical effectiveness of this invention, three sets of control experiments were conducted simultaneously. The first set used the traditional single-path uncompensated method, acquiring only a single-azimuth image and directly outputting the initial size measurement parameters without performing any error compensation or baseline updates. The second set used a single-factor illumination compensation method, linearly correcting the size measurement values based solely on changes in illumination intensity, without considering temperature, surface undulations, or dynamic baseline updates. The third set used the dual-component hierarchical compensation and dynamic baseline update method of this invention, fully executing all steps described in claims 1 to 10.
[0103] One thousand shaft-type workpieces were continuously inspected under conditions of light intensity fluctuations of ±300 lux and temperature cyclical changes from 22 to 32 degrees Celsius. The measurement results of each experimental group are as follows: In the first group, under the traditional single-path uncompensated method, the dimensional measurement error was distributed between 0.040 mm and 0.080 mm, with an average of approximately 0.060 mm; In the second group, under the single-factor light compensation method, the error was reduced to between 0.025 mm and 0.045 mm, with an average of approximately 0.035 mm. The light factor was partially corrected, but the errors caused by temperature and surface fluctuations were still significant; In the third group, under the dual-component graded compensation and dynamic reference update method of this invention, the dimensional measurement error did not exceed 0.012 mm, with an average of approximately 0.008 mm.
[0104] Typical operating condition data for each experimental group are recorded as follows: Table of relevant data for each experimental group under different working conditions First compensation component in the table The calculation uses the formula Where α is 0.95, E is the light intensity, R is the surface reflectivity, and T is the exposure time. Second compensation component The calculation uses the formula Where β takes the value of 1.05, is the temperature difference between the environmental temperature characterization value and the preset reference temperature value of 25 degrees Celsius, H is the surface fluctuation amplitude characterization value, and G is the gain characterization value. The size before correction is the initial size measurement parameter, and the size after correction is the compensated size measurement parameter. The qualification criterion is that the corrected size is in the range from 24.980 mm to 25.020 mm.
[0105] The data in Table 1 show that under three typical working conditions of low illumination and high temperature, standard illumination and normal temperature, and high illumination and low temperature, after the two-component graded compensation of the present invention, the dimensional deviations are all controlled within ±0.008 mm, and all are determined as qualified. For comparison, the first group with no compensation method is determined as unqualified under all three working conditions, with a maximum deviation of 0.073 mm; the second group with single-factor illumination compensation method is barely qualified only under the working condition of standard illumination and normal temperature, and still unqualified under the working conditions of low illumination and high temperature and high illumination and low temperature, which indicates that single illumination compensation cannot effectively deal with the complex working conditions with coupled changes of temperature and illumination.
[0106] Aiming at the batch error fluctuation after dynamic reference update, 1000 shaft workpieces are divided into ten batches according to the detection sequence, with 100 pieces in each batch, and the standard deviation of dimensional measurement error in each batch is counted. For the first group with no compensation method, the inter-batch error fluctuation range is 38% to 72%, and the mean standard deviation is 0.043 mm; for the third group adopting the dynamic reference update method of the present invention, the inter-batch error fluctuation range is reduced to 8% to 16%, the mean standard deviation is reduced to 0.010 mm, and the batch error fluctuation is reduced by 72%. The result shows that dynamic reference update can continuously track the change of working conditions, effectively suppress the cumulative amplification of error with detection batches, and ensure the dimensional accuracy stability of long-term continuous online detection.
[0107] The specific values used in this embodiment are only set for verifying the technical effects of the present invention, and do not constitute a limitation on the protection scope of the present invention. In practical applications, each parameter can be adjusted according to the specific detection object, precision requirements and working conditions.
[0108] In actual production, the algorithm threshold parameters can be adjusted according to different types of workpieces to be measured. The adaptation rules for special-shaped / rectangular thin-walled workpieces are as follows: when the radius of curvature of the workpiece edge is less than 0.1 mm, the gray level jump judgment threshold is lowered to 20 gray levels; when the thickness of the thin-walled workpiece is less than 1 mm, the pairing distance threshold of key feature points is lowered to 0.2 mm; for large-sized workpieces (total overall dimension > 100 mm), the allowable fusion interval can be expanded to ±0.03 mm, and the stability of online dimension detection for multiple types of workpieces is ensured through differentiated parameter adaptation. In practical applications, each parameter can be adjusted according to the specific detection object, precision requirements and working conditions.
[0109] Reference Figure 2The diagram shown is a schematic representation of the three-dimensional geometric layout of a multi-path acquisition station for an online size detection and error compensation method integrating machine vision, provided by an embodiment of the present invention.
[0110] In the optical path setup of the multi-path backlight reflection imaging system, the uniform adjustment of global illumination and the coplanar calibration of the bidirectional acquisition field of view rely on non-contact high-precision stereo vision measurement technology. Specifically, the uniform backlight field at the workstation is represented as a parallel light source surface with high collimation and backlight transmission. The workpiece to be measured (an axial type) is placed on the axis-aligned positioning fixture of the workstation support platform. Its edges are covered by two telecentric cameras (1) positioned at a 30° angle on the left and 2 positioned at a 30° angle on the right, forming a symmetrically distributed, convergent acquisition posture. The spatial intersection of the acquisition optical axes converges to the geometric centroid of the workpiece cross-section. The symmetry of their angle is achieved through joint calibration using a polar coordinate rotation platform and a laser interferometer: by adjusting the three-dimensional fine-tuning knobs on the rigid cantilever base of the camera, the changes in the reprojection matrix and extrinsic translation vector of the calibration plate in the coordinate system of the two camera films are recorded. An angular symmetry check was performed on the acquisition optical axes of the left and right channels. The overlap of the projected fields of view of the two channels on the vertical reference normal was measured using a Euclidean epipolar distance metric. This distance value was added as a geometric centering calibration term to the initial parameter matrix of the multi-path reconstruction algorithm. During parameter configuration, the tilt angles of the acquisition optical axes of the left and right cameras relative to the reference normal were set. and The nominal value is 30°, and the field of view height overlap deviation is controlled within 0.5 times the pixel spacing between adjacent cameras.
[0111] Reference Figure 3 The figure shown is a diagram illustrating the relationship between edge pixel extraction of an image sequence and projection mapping in three-dimensional actual space, provided by an embodiment of the present invention for an online size detection and error compensation method that integrates machine vision.
[0112] In the calibration calculation of mapping two-dimensional pixel edge coordinates to the actual physical size space, the consistency calibration of gray-level jump points relies on the geometric constraints of the binocular epipolar lines and Zhang's camera calibration algorithm. Specifically, the gray-level jump trajectory in the image coordinate system is represented as a gray-level space surface composed of a two-dimensional discrete pixel set and a local gradient tensor. The two-dimensional calibration sampling points are processed by a distortion inverse tangential correction processor to eliminate geometric deformation, forming a set of correction points under an ideal perspective projection model. Matching of corresponding edge pixels between the two camera fields of view is achieved by calculating the change in the distance between the fundamental matrix and the epipolar line: epipolar projection is performed on the edge feature sampling points of the left camera, and the search and epipolar distance divergence changes of the corresponding matching points within the scan line threshold window of the right camera are recorded. The reconstructed three-dimensional feature point set in the physical space undergoes the same matching verification. The reprojection error between sampling points is measured using the root mean square (RMS) reprojection distance, which is added as a distortion residual correction factor to the calibration results of the camera intrinsic and extrinsic parameter matrices. During parameter configuration, the epipolar search threshold width is set to 0.5% of the image resolution width, and the corner point determination radius of the checkerboard calibration board is set to 1.2 times the distance between adjacent pixels.
[0113] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the present invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the present invention.
[0114] This application embodiment can acquire and process relevant data based on artificial intelligence technology. Artificial intelligence is the theory, method, technology, and application system that uses digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to obtain optimal results.
[0115] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention.
Claims
1. A method for online size detection and error compensation integrating machine vision, characterized in that, The method includes: Pt.1 Extract edge contour data from the image sequence of the target object, and generate the initial size measurement parameters of the target object based on the edge contour data; Pt.
2. Compare the initial size measurement parameter with the preset reference size range. When the initial size measurement parameter exceeds the preset reference size range, obtain the deviation direction and deviation magnitude, and generate an error identification mark. Pt.3 When the error identification flag indicates a deviation, environmental parameters and surface attribute parameters are acquired, a compensation adjustment direction is determined based on the environmental parameters and surface attribute parameters, compensation is applied to the initial size measurement parameters according to the compensation adjustment direction, and a compensated size measurement parameter is generated. Pt.
4. The compensated size measurement parameters are fused with the preset reference size range to update the preset reference size range, and the updated preset reference size range is used as the judgment criterion for subsequent detection.
2. The online size detection and error compensation method integrating machine vision as described in claim 1, characterized in that, The image sequence of the target object includes: Illumination light is projected onto the workstation where the target object is located. The incident angle of the illumination light is adjusted so that the illumination light forms a uniform illuminance distribution on the surface of the target object. The target object under the uniform illuminance distribution is used as the object to be collected. In the collection environment where the object to be collected is located, a collection optical path corresponding to the incident direction of the illumination light is selected, and the collection optical path is used as the collection posture; Trigger the exposure operation according to the acquisition posture, record the target object image generated by the exposure operation, and use the target object image as the first orientation image; The acquisition optical path is switched, and the exposure operation is repeated under the switched acquisition optical path to obtain a second azimuth image. The first azimuth image and the second azimuth image constitute the image sequence.
3. The online size detection and error compensation method integrating machine vision as described in claim 2, characterized in that, The step of extracting edge contour data from the image sequence of the target object and generating initial size measurement parameters of the target object based on the edge contour data includes: Edge detection is performed on the images in the image sequence to extract the pixel positions in the image where the gray value changes abruptly, and the pixel positions where the gray value changes abruptly are used as edge pixels. The image position of the edge pixel in the image is obtained, and the calibration position of the edge pixel in the actual space is determined according to the mapping relationship between the image position and the acquisition orientation corresponding to the image to which the edge pixel belongs, and the calibration position is used as the edge contour data. Traverse the calibration positions in the edge contour data along the size feature direction of the target object, select pairs of calibration positions that are in relative positions along the size feature direction, and use the pairs of calibration positions as key feature point pairs; Obtain the spatial distance between the two calibration positions contained in the key feature point pair, and use the spatial distance as the initial size measurement parameter of the target object.
4. The online size detection and error compensation method integrating machine vision as described in claim 1, characterized in that, The step of comparing the initial size measurement parameter with a preset reference size range, and when the initial size measurement parameter exceeds the preset reference size range, obtaining the deviation direction and deviation magnitude, and generating an error identification identifier, includes: Read the upper and lower bound values of the preset reference size range, and use the upper and lower bound values as a reference boundary pair; The initial size metric parameter is compared with the upper bound value in the reference boundary pair to obtain the upper position of the initial size metric parameter relative to the upper bound value; The initial size metric parameter is compared with the lower bound value in the reference boundary pair to obtain the lower position of the initial size metric parameter relative to the lower bound value; When the upper position indicates that the initial size measurement parameter is higher than the upper limit value, the deviation direction is determined as the positive deviation direction; When the lower position indicates that the initial size measurement parameter is lower than the lower boundary value, the deviation direction is determined to be a negative deviation direction; The deviation direction is defined as either the positive deviation direction or the negative deviation direction. When the deviation direction is a positive deviation direction, the upper distance between the initial size measurement parameter and the upper limit value is obtained, and the upper distance is used as the deviation amplitude; When the deviation direction is a negative deviation direction, the lower distance between the lower boundary value and the initial size measurement parameter is obtained, and the lower distance is used as the deviation amplitude.
5. The online size detection and error compensation method integrating machine vision as described in claim 4, characterized in that, The step of comparing the initial size measurement parameter with a preset reference size range, and obtaining the deviation direction and deviation magnitude when the initial size measurement parameter exceeds the preset reference size range, and generating an error identification mark, further includes: Obtain the deviation of the initial size measurement parameter from the preset reference size range, and read the preset degree judgment threshold, which includes the deviation degree distinction boundary; The deviation magnitude is compared with the deviation degree distinction boundary. When the deviation magnitude is within the deviation degree distinction boundary, a slight deviation indicator is generated. When the deviation magnitude is outside the deviation degree distinction boundary, a severe deviation indicator is generated; The deviation direction is combined with the slight deviation identifier to generate a slight error identification identifier, and the deviation direction is combined with the severe deviation identifier to generate a severe error identification identifier.
6. The online size detection and error compensation method integrating machine vision as described in claim 1, characterized in that, When the error identification flag indicates a deviation, the acquisition of environmental parameters and surface attribute parameters includes: Read the output light intensity parameters and color temperature parameters of the light source at the workstation where the target object is located, and use the output light intensity parameters and color temperature parameters as lighting status information; Spectral intensity distribution features are extracted from the lighting state information, and these spectral intensity features are used as ambient light features. The ambient temperature value of the workstation where the target object is located is read, and the ambient temperature value is combined with the ambient light characteristics to generate an environmental parameter characterization.
7. The online size detection and error compensation method integrating machine vision as described in claim 6, characterized in that, The step of acquiring environmental parameters and surface attribute parameters when the error identification flag indicates a deviation further includes: From the image sequence, an image region covering the surface area of the target object is selected, and the brightness values of the pixels within the image region are read to obtain the pixel brightness distribution of the target object. The pixel brightness distribution is used as the surface reflection feature. The brightness values of adjacent pixels in the pixel brightness distribution are compared to determine the difference, and a brightness difference sequence between adjacent pixels is obtained. The brightness difference sequence is used as a surface texture feature. The positions of the extreme brightness values in the pixel brightness distribution are calibrated to obtain the extreme brightness value positions. The span between the extreme brightness value positions is measured to obtain the span between the extreme brightness value positions. The span is used as a surface undulation feature. The surface reflection features, surface texture features, and surface undulation features are combined to obtain the surface attribute parameters of the target object.
8. The online size detection and error compensation method integrating machine vision as described in claim 7, characterized in that, The step of determining the compensation adjustment direction based on the environmental parameters and the surface property parameters, applying compensation to the initial size measurement parameters according to the compensation adjustment direction, and generating compensated size measurement parameters includes: Illumination intensity and ambient temperature are extracted from the environmental parameters, and surface reflectance and surface undulation amplitude are extracted from the surface property parameters. The exposure parameters of the target object during image acquisition are obtained. The exposure parameters include exposure duration and gain value. The exposure duration characterization value and gain characterization value are extracted from the exposure parameters. The first compensation component is determined by the following relationship between the light intensity characterization value, the surface reflectance characterization value, and the exposure time characterization value: ; in, This is the first compensation component. The light intensity characterization value is... This is the surface reflectivity characterization value. This is the value representing the exposure duration. This is the preset spectral distribution coefficient of the light source; The second compensation component is determined by the following relationship between the ambient temperature characterization value, the surface undulation amplitude characterization value, and the gain characterization value: ; in, This is the second compensation component. The temperature difference between the ambient temperature value and the preset reference temperature value. This is a characterization value for the surface undulation amplitude. The gain characterization value is... The preset temperature gain coupling coefficient; The direction of the combination of the first compensation component and the second compensation component is taken as the compensation adjustment direction; Based on the compensation adjustment direction, the first compensation component and the second compensation component are applied to the initial size measurement parameter, and the initial size measurement parameter after applying the first compensation component and the second compensation component is used as the compensated size measurement parameter.
9. The online size detection and error compensation method integrating machine vision as described in claim 1, characterized in that, The step of fusing the compensated size measurement parameters with the preset reference size range includes: Read the upper and lower bound values of the preset reference size range, with the upper bound value as the upper limit of the range and the lower bound value as the lower limit of the range; Obtain the upper limit difference between the compensated size measurement parameter and the upper limit of the range, and obtain the lower limit difference between the compensated size measurement parameter and the lower limit of the range; When both the upper limit difference and the lower limit difference are within the preset fusion allowable range, the compensated size metric parameter is used as the metric value to be fused. The metric value to be merged is merged with the upper limit of the range and the lower limit of the range according to a preset weight ratio. The merged upper limit of the range is used as the updated upper limit of the range, and the merged lower limit of the range is used as the updated lower limit of the range. The updated preset reference size range is formed by the updated upper limit and the updated lower limit.
10. The online size detection and error compensation method integrating machine vision as described in claim 9, characterized in that, The step of updating the preset reference size range, and using the updated preset reference size range as the judgment criterion for subsequent detection, includes: Read the upper and lower bound values of the updated preset reference size range, and use the upper bound value as the upper limit of the updated range and the lower bound value as the lower limit of the updated range. Compare the updated upper limit of the range with the updated lower limit of the range. When the updated upper limit of the range is greater than the updated lower limit of the range and the change in the upper limit between the updated upper limit of the range and the upper limit of the range before the update is within a preset allowable range, and the change in the lower limit between the updated lower limit of the range and the lower limit of the range before the update is within a preset allowable range, the updated preset reference size range is confirmed as a valid update range. The effective update range is set as the current effective size range, and the current effective size range is used to replace the original preset reference size range as the judgment benchmark for target object size detection. The newly acquired size measurement parameters of the target object to be tested are compared with the upper and lower bounds of the current effective size range, and the size qualification status of the target object to be tested is determined according to the comparison result.