Workpiece rapid measurement method and system based on machine vision
By using a polarization-encoded optical screen and a dual-camera system, combined with polarization phase difference and rotation angle data, a closed workpiece contour curve is generated, solving the problem of non-closed workpiece contours in existing technologies and enabling accurate and rapid measurement of workpiece dimensions.
Patent Information
- Application Number
- CN202611695749.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-30
- Publication Date
- 2026-11-27
AI Technical Summary
Existing machine vision measurement methods are prone to interference in areas with strong reflectivity, weak texture, or large changes in edge curvature on the workpiece surface. Spot center positioning and phase calculation are easily affected. Local incident angle estimation relies on grayscale distribution or pre-calibrated spatial relationships, resulting in incomplete workpiece contour extraction. In particular, boundary points are missing at straight edges, arc edges, or corners, causing deviations in the fitting of geometric primitive parameters and making it impossible to stably reflect the actual size of the workpiece.
A polarization-encoded light screen is used to generate an array of light spots with different polarization states. Combined with the synchronous acquisition of dual cameras and the rotation angle data of the workpiece support platform, discrete point clouds are generated through polarization phase difference and spatial triangulation constraints. Tangential extension is performed along the edge of the workpiece to obtain a closed curve and extract the workpiece size data.
It enables workpiece size measurement in areas with highlights and texture variations, reduces interference from spot center positioning and phase calculation, reduces point cloud stitching deviation, reduces the impact of discrete point cloud sparsity and edge noise, ensures continuous closure of closed curves along the actual edge direction, and makes geometric element parameter fitting closer to the actual contour, thereby improving the accuracy and stability of measurement.
Smart Images

Figure CN123175134A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of machine vision measurement technology, specifically to a method and system for rapid workpiece measurement based on machine vision. Background Technology
[0002] In machine vision measurement, non-contact rapid acquisition of workpiece dimensions typically employs structured light projection, laser scanning, or multi-camera stereo matching. Structured light projection projects light spots, stripes, or coded patterns onto the workpiece surface, using a camera to capture pattern deformation and reconstructing surface point coordinates based on triangulation principles. Laser scanning uses line or point lasers to scan the workpiece surface point by point, acquiring a contour point cloud. Multi-camera stereo matching obtains 3D information by matching image features from different viewpoints. However, these methods are susceptible to interference in areas with strong reflectivity, weak texture, or significant edge curvature variations on the workpiece surface. Spot center positioning, phase calculation, and feature matching are easily affected. Local incident angle estimation relies on grayscale distribution or pre-defined spatial relationships, and changes in surface material can introduce incident angle deviations. When the workpiece platform rotates, discrepancies exist in time synchronization and spatial coordinate consistency between multi-camera acquisition and rotation angle acquisition, affecting the consistency of point cloud stitching from different viewpoints. Regarding workpiece contour extraction, discrete point clouds often exhibit missing, sparse, or noisy areas at workpiece edges. Direct boundary fitting of the point cloud results in curves that fail to close at edges, or the closed curves deviate from the actual contour. An incomplete contour makes the extraction of dimensions such as length, width, aperture, and angle unreliable, especially for workpieces with straight edges, rounded edges, or corners. Missing boundary points cause deviations in the fitting of geometric primitive parameters, making it impossible to stably reflect the actual dimensions of the workpiece. Existing methods usually rely on increasing scan coverage or interpolating and smoothing the point cloud, but when the amount of missing edge points is large, the interpolation direction is inconsistent with the actual edge direction, making it difficult to obtain a closed and continuous contour curve. Summary of the Invention
[0003] To address the issues in existing machine vision measurements, such as the influence of surface reflection and material variations on the estimation of local incident angles, and the incomplete closure of discrete point clouds at workpiece edges, a machine vision-based rapid workpiece measurement method and system are provided. This method utilizes a polarization-encoded optical screen to generate an array of light spots with different polarization states. The local incident angle is obtained from the polarization phase difference between adjacent light spots. Spatial triangulation is then performed using simultaneous acquisition data from dual cameras and the rotation angle data of the workpiece support platform to generate a discrete point cloud. Finally, the discrete point cloud is tangentially extended along the workpiece edge to obtain a closed curve of the workpiece contour, thus achieving non-contact and rapid workpiece size measurement.
[0004] To achieve the above objectives, the present invention provides the following technical solution: a machine vision-based rapid workpiece measurement method, comprising:
[0005] A rotatable polarization-encoded light screen is set on the workpiece support platform, and a first light spot array and a second light spot array with different polarization states are projected onto the surface of the workpiece to be tested placed on the workpiece support platform.
[0006] The first and second spot array images of the surface of the workpiece under test are simultaneously acquired by the first and second cameras arranged around the workpiece support platform, and the rotation angle data of the workpiece support platform is obtained.
[0007] Based on the polarization phase difference between adjacent spots in the first spot array image and the second spot array image, the local incident angle data of each spot on the surface of the workpiece under test is determined.
[0008] Based on the local incident angle data and the rotation angle data, spatial triangulation constraints are applied to the center points of adjacent light spots to generate a discrete point cloud on the surface of the workpiece to be tested.
[0009] The discrete point cloud is tangentially extended along the edge of the workpiece to be measured to obtain a closed curve of the workpiece contour, and the workpiece size data is extracted from the closed curve of the workpiece contour.
[0010] Preferably, determining the local incident angle data of each light spot on the surface of the workpiece under test based on the polarization phase difference between adjacent light spots in the first light spot array image and the second light spot array image includes:
[0011] Polarization channel separation is performed on the first spot array image and the second spot array image respectively to obtain horizontal polarization sub-image, vertical polarization sub-image, left-handed polarization sub-image and right-handed polarization sub-image;
[0012] In the horizontal polarization sub-map and the vertical polarization sub-map, multiple sampling rings are arranged radially with the center of the light spot as the origin of the polar coordinates.
[0013] The polarization phase difference is obtained by calculating the difference in grayscale variation period between the horizontal polarization sub-image and the vertical polarization sub-image on the same sampling ring.
[0014] The polarization phase difference is corrected based on the difference in spot ellipticity between the left-handed and right-handed polarimetric diagrams to obtain the local incident angle data.
[0015] Preferably, the step of simultaneously acquiring a first spot array image and a second spot array image of the surface of the workpiece under test using a first camera and a second camera arranged around the workpiece support platform, and obtaining the rotation angle data of the workpiece support platform, includes:
[0016] The first camera and the second camera are arranged at a 90-degree angle with the center of the workpiece support platform as the center, and the optical axis makes a 45-degree angle with the plane of the workpiece support platform.
[0017] Send a synchronization trigger pulse to the first camera and the second camera so that they can acquire the first spot array image and the second spot array image at the same exposure time;
[0018] An annular coding strip is set at the edge of the workpiece support platform. The first camera and the second camera simultaneously acquire the annular coding strip to obtain a first coding strip image and a second coding strip image.
[0019] The rotation angle data is obtained by querying the displacement difference of the coded marks in the first coded band image and the second coded band image and the pre-stored circumferential spacing lookup table.
[0020] Preferably, the step of performing spatial triangulation constraints on the center points of adjacent light spots based on the local incident angle data and the rotation angle data to generate a discrete point cloud of the surface of the workpiece to be tested includes:
[0021] Based on the rotation angle data, the center of the light spot in the second light spot array image is transformed to the first camera coordinate system to obtain a unified set of light spot centers;
[0022] The normal ray of each spot in the unified spot center set is generated using the local incident angle data;
[0023] For adjacent spot center points in the unified spot center set, a matching pair is constructed, and the matching pair is constrained by the shortest common perpendicular segment of the two normal rays;
[0024] Calculate the midpoint of the common perpendicular segment of the two normal rays in the matching pair, and use the midpoint of the common perpendicular segment as a point in the discrete point cloud.
[0025] Preferably, the step of tangentially extending the discrete point cloud along the edge of the workpiece to obtain a closed curve of the workpiece contour includes:
[0026] Boundary points located at the edge of the workpiece under test are extracted from the discrete point cloud, and the boundary points are sorted according to the distance between adjacent points to obtain a boundary point sequence;
[0027] Select the last three boundary points at both ends of the boundary point sequence, and generate the tangential extension direction based on the last three boundary points;
[0028] Extend both ends of the boundary point sequence along the tangential extension direction to the boundary of the workpiece support platform plane to obtain two closed endpoints;
[0029] By sequentially connecting the boundary point sequence and the two closed endpoints, the closed curve of the workpiece contour is obtained.
[0030] Preferably, the step of extracting workpiece dimension data from the closed curve of the workpiece contour includes:
[0031] The closed curve of the workpiece contour is resampled with equal arc length to obtain a sequence of contour sampling points;
[0032] Calculate the included angle formed by every three adjacent sampling points in the contour sampling point sequence, and mark the sampling points whose included angle is less than a preset angle as corner points;
[0033] The curve segment between adjacent corner points is matched with the pre-stored geometric primitives to obtain the geometric primitive parameters corresponding to the curve segment.
[0034] The length, width, hole diameter, and angular dimensions of the workpiece to be tested are output based on the geometric primitive parameters.
[0035] Preferably, the step of setting a rotatable polarization-encoded light screen on the workpiece support platform and projecting a first light spot array and a second light spot array with different polarization states onto the surface of the workpiece to be tested placed on the workpiece support platform includes:
[0036] The polarization-encoded optical screen is mounted on a rotating bracket above the workpiece support platform. The polarization-encoded optical screen includes orthogonal polarizers and replaceable masks.
[0037] A horizontally polarized cross array is generated through the cross slit in the replaceable mask, and the horizontally polarized cross array is used as the first spot array through the orthogonal polarizer.
[0038] A vertically polarized ring array is generated through the annular slit in the replaceable mask, and the vertically polarized ring array is used as the second spot array through the orthogonal polarizer.
[0039] The rotating bracket is driven to rotate step by step, so that the first light spot array and the second light spot array are alternately projected onto the surface of the workpiece to be tested.
[0040] Preferably, the step of performing polarization channel separation on the first spot array image and the second spot array image respectively to obtain a horizontal polarization sub-image, a vertical polarization sub-image, a left-handed polarization sub-image, and a right-handed polarization sub-image includes:
[0041] A four-quadrant polarizing beam splitter is set in front of the lenses of the first camera and the second camera to split the incident light into four polarized beams.
[0042] The four polarized lights are imaged onto four regions of the same image sensor after passing through horizontal, vertical, left-handed, and right-handed narrowband filters, respectively.
[0043] Dark current subtraction and spot connectivity labeling were performed on the images of the four regions respectively to obtain four sets of labeled connected components;
[0044] The four sets of marked connected components are output as the horizontal polarization sub-graph, the vertical polarization sub-graph, the left-handed polarization sub-graph, and the right-handed polarization sub-graph according to their polarization states.
[0045] Preferably, the step of calculating the midpoint of the common perpendicular segment of the two normal rays in the matching pair, and using the midpoint of the common perpendicular segment as a point in the discrete point cloud, includes:
[0046] Calculate the length of the common perpendicular segment of the two normal rays in the matching pair, and use the length of the common perpendicular segment as the confidence weight of the matching pair;
[0047] Obtain the midpoint of the common perpendicular segment, and then perform a weighted average of the midpoints of the common perpendicular segment according to the confidence weight to obtain the coordinates of the weighted point;
[0048] When the length of the common perpendicular segment exceeds the preset length, the weighted point coordinates corresponding to the matching pair are removed from the discrete point cloud.
[0049] The retained weighted point coordinates are stitched together according to the rotation angle data to obtain the discrete point cloud.
[0050] Preferably, the present invention also includes a machine vision-based rapid workpiece measurement system, including a memory, a processor, and a computer program stored in the memory and running on the processor, wherein the processor, when executing the computer program, implements the steps of the machine vision-based rapid workpiece measurement method described above.
[0051] The technical effects and advantages provided by the present invention in the above technical solution are as follows:
[0052] A polarization-encoded optical screen generates a horizontally polarized cross array and a vertically polarized ring array using interchangeable masks, and alternately projects a first spot array and a second spot array onto the surface of the workpiece under test. After the first and second cameras synchronously acquire images of the spot arrays, the images are subjected to four-quadrant polarization beam splitting to obtain horizontal, vertical, left-handed, and right-handed polarization sub-images. Sampling rings are set with the spot center as the origin of polar coordinates in the horizontal and vertical polarization sub-images, and the polarization phase difference is obtained by calculating the period difference of gray-level changes. The polarization phase difference is then corrected by the difference in spot ellipticity between the left-handed and right-handed polarization sub-images to obtain local incident angle data. The local incident angle estimation does not depend on a single gray-level threshold or a fixed calibration surface, and the polarization phase difference is less affected by changes in surface reflection intensity and material, resulting in reduced incident angle deviations in highlight, texture, and edge regions. Local incident angle data and workpiece platform rotation angle data jointly constrain the center points of adjacent light spots. Discrete point clouds are generated by using the midpoint of the common perpendicular segment of the normal ray. The dual-camera viewpoints and rotation angles are used within the same coordinate frame, reducing point cloud stitching deviation and anomalies caused by synchronization deviation or reflection interference in the discrete point cloud. Boundary points located at the edge of the workpiece under test are extracted from the discrete point cloud and sorted according to the distance between adjacent points. Tangential extension directions are generated at both ends of the boundary point sequence based on the last three boundary points. These two ends are extended to the plane boundary of the workpiece platform to obtain closed endpoints. The boundary point sequence and closed endpoints are connected sequentially to form the closed curve of the workpiece contour. The closed curve of the workpiece contour is resampled with equal arc length. Corner points with an angle less than a preset angle between three adjacent sampling points are marked. The curve segments between adjacent corner points are shape-matched with pre-stored geometric primitives to obtain geometric primitive parameters and output length, width, aperture, and angular dimension data. Edge tangential extension uses the direction of adjacent points at the end of the boundary point sequence to determine the extension direction, without relying on the external point cloud of the boundary or artificial extension rules. When the workpiece edge points are missing or sparse, the closed curve is continuously closed along the actual edge direction. When extracting dimensions from the closed curve, missing edge endpoints will not be misjudged as contour endpoints. The geometric primitive parameters of straight lines, arcs and corner points are fitted more closely to the actual contour, and the influence of sparse discrete point clouds and edge noise on the dimensional results is reduced. Attached Figure Description
[0053] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this invention. For those skilled in the art, other drawings can be obtained based on these drawings.
[0054] Figure 1 This is a flowchart of a rapid workpiece measurement method based on machine vision;
[0055] Figure 2 This is a flowchart of the process for generating discrete point clouds from a light spot array. Detailed Implementation
[0056] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0057] See Figure 1 This invention provides a rapid workpiece measurement method based on machine vision. The method includes: setting a rotatable polarization-encoded light screen on a workpiece support platform; projecting a first light spot array and a second light spot array with different polarization states onto the surface of a workpiece to be measured placed on the workpiece support platform; synchronously acquiring images of the first light spot array and the second light spot array on the surface of the workpiece to be measured using a first camera and a second camera arranged around the workpiece support platform, and obtaining rotation angle data of the workpiece support platform; determining the local incident angle data of each light spot on the surface of the workpiece to be measured based on the polarization phase difference between adjacent light spots in the first light spot array image and the second light spot array image; performing spatial triangulation constraints on the center points of adjacent light spots based on the local incident angle data and the rotation angle data to generate a discrete point cloud on the surface of the workpiece to be measured; tangentially extending the discrete point cloud along the edge of the workpiece to be measured to obtain a closed curve of the workpiece contour, and extracting workpiece size data from the closed curve of the workpiece contour.
[0058] The polarization-encoded optical screen changes the polarization state of the light spot array during rotation. The first and second cameras simultaneously acquire two images of the light spot array from different perspectives. The polarization phase difference between adjacent light spots reflects the change in the incident angle of the light spot on the surface of the workpiece. Combined with the rotation angle data, spatial triangulation constraints are applied to the center points of adjacent light spots to reconstruct a discrete point cloud. The discrete point cloud is then tangentially extended at the edges to form a closed contour curve of the workpiece. The dimensional data of the workpiece is extracted from this closed contour curve.
[0059] In the specific implementation, polarization channels are separated for the first and second spot array images respectively, resulting in horizontal, vertical, left-handed, and right-handed polarization sub-images. A four-quadrant polarization beam splitter is placed in front of the lenses of the first and second cameras, splitting the incident light into four polarized beams. These four polarized beams are then imaged onto four regions of the same image sensor after passing through horizontal, vertical, left-handed, and right-handed narrowband filters, respectively. The four regions of the image sensor correspond one-to-one with the horizontal, vertical, left-handed, and right-handed polarization directions. Dark current subtraction and spot connectivity marking are performed on the images of the four regions of the image sensor, resulting in four sets of marked connected regions. These four sets of marked connected regions are then output as horizontal, vertical, left-handed, and right-handed polarization sub-images according to their polarization states.
[0060] Dark current subtraction includes: acquiring dark current images of four regions of the image sensor corresponding to the four-quadrant polarizing beam splitter under no-light conditions, and subtracting the pre-calibrated dark current images from the images of each of the four regions of the image sensor. Spot connectivity labeling includes: binarizing the images of the four regions of the image sensor after dark current subtraction, labeling pixels with grayscale values higher than a preset spot threshold as foreground pixels, and labeling the foreground pixels with connected components to obtain four sets of labeled connected components. Each set of labeled connected components contains the spot position and spot contour under the corresponding polarization state.
[0061] In both the horizontal and vertical polarization sub-images, multiple sampling rings are radially arranged with the spot center as the origin of the polar coordinate system. For each spot in both the horizontal and vertical polarization sub-images, the spot center is identified, and multiple sampling rings with different radii are arranged around the spot with the spot center as the origin of the polar coordinate system. The radius of the sampling rings increases sequentially outward from the spot center, and the radial spacing between the sampling rings is equal. For the same sampling ring, grayscale sampling is performed along the ring direction in the horizontal polarization sub-image to obtain a horizontal grayscale sequence, and grayscale sampling is performed along the ring direction in the vertical polarization sub-image to obtain a vertical grayscale sequence. Periodic analysis is performed on the horizontal and vertical grayscale sequences respectively to obtain the horizontal grayscale change period and the vertical grayscale change period. The difference between the horizontal and vertical grayscale change periods is calculated to obtain the polarization phase difference.
[0062] Periodic analysis of horizontal and vertical grayscale sequences includes: performing a Fast Fourier Transform (FFT) on the horizontal grayscale sequence and taking the frequency corresponding to the peak value in the amplitude spectrum as the horizontal grayscale variation period; performing a FFT on the vertical grayscale sequence and taking the frequency corresponding to the peak value in the amplitude spectrum as the vertical grayscale variation period. The polarization phase difference is the absolute difference between the horizontal and vertical grayscale variation periods.
[0063] The polarization phase difference is corrected based on the difference in spot ellipticity between the left-hand and right-hand polarization sub-images to obtain local incident angle data. For each spot in both the left-hand and right-hand polarization sub-images, the second moment of the connected region of the spot is calculated. The major and minor axes of the spot are obtained from these second moments, and the spot ellipticity is the ratio of the major to minor axes. The difference between the spot ellipticity in the left-hand and right-hand polarization sub-images is calculated. This difference is multiplied by a preset ellipticity correction coefficient to obtain the ellipticity correction amount. The polarization phase difference is added to the ellipticity correction amount to obtain the corrected polarization phase difference, which is then used as the local incident angle data.
[0064] In practice, the polarization-encoded optical screen is mounted on a rotating support above the workpiece support platform. The polarization-encoded optical screen comprises orthogonal polarizers and a replaceable mask. The orthogonal polarizers are located below the replaceable mask, and the workpiece support platform is located below the orthogonal polarizers. The replaceable mask has cross-shaped slits and annular slits. The cross-shaped slits are two orthogonal rectangular light-transmitting slots, with their intersection point located at the center of the replaceable mask. The annular slits are concentric annular light-transmitting slots, with their center coinciding with the center of the replaceable mask.
[0065] A replaceable mask is installed in the mask slot of a polarization-encoded optical screen. A parallel light source is positioned on the top surface of the polarization-encoded optical screen. The beam emitted by the parallel light source covers the entire slit area of the replaceable mask. The beam emitted by the parallel light source passes sequentially through the replaceable mask and orthogonal polarizers before being projected towards the workpiece support stage. When the cross slit of the replaceable mask is in the optical path, the cross slit spatially modulates the parallel beam, forming a cross-shaped light spot distribution. After passing through the orthogonal polarizers, the cross-shaped light spot transforms into a horizontally polarized cross array, which serves as the first light spot array. When the replaceable mask rotates to the point where the annular slit is in the optical path, the annular slit spatially modulates the parallel beam, forming an annular light spot distribution. After passing through the orthogonal polarizers, the annular light spot transforms into a vertically polarized annular array, which serves as the second light spot array.
[0066] The rotating support is driven by a stepper motor. The stepper motor is connected to the rotating shaft of the rotating support via a coupling. The controller sends stepping pulses to the stepper motor, which rotates at a preset step angle, driving the rotating support to rotate step by step. The rotating support drives the polarization-encoding optical screen to rotate around its vertical axis. Each time the polarization-encoding optical screen rotates by one step angle, the crosshair and annular slits of the replaceable mask alternately align with the optical path. The first and second light spot arrays are alternately projected onto the surface of the workpiece under test. When the crosshair is aligned with the optical path, the surface of the workpiece receives the first light spot array. When the annular slit is aligned with the optical path, the surface of the workpiece receives the second light spot array. The alternating projection frequency is consistent with the stepping pulse frequency.
[0067] The first and second cameras are arranged at a 90-degree angle with the center of the workpiece support platform. The optical axis of both cameras forms a 45-degree angle with the plane of the workpiece support platform. The first and second cameras are mounted on camera mounts, respectively. These mounts are arranged along a circumference centered on the center of the workpiece support platform, with a central angle of 90 degrees between them. The first and second cameras are at the same height. A four-quadrant polarizing beam splitter is positioned in front of the lenses of both cameras. The center of the four-quadrant polarizing beam splitter is aligned with the center of the workpiece support platform. The fields of view of both cameras cover the entire upper surface area of the workpiece support platform.
[0068] Synchronous trigger pulses are sent to the first and second cameras. These pulses are generated by an external trigger controller, which contains programmable logic devices. The programmable logic devices generate two synchronous trigger pulses with the same rising edge. The first synchronous trigger pulse is transmitted to the trigger input interface of the first camera via a first signal line. The second synchronous trigger pulse is transmitted to the trigger input interface of the second camera via a second signal line. The first and second cameras begin exposure at the rising edge of the synchronous trigger pulses, acquiring the first and second spot array images at the same exposure time. The exposure time is pre-set by the internal registers of both cameras and is identical. At the same exposure time, both cameras simultaneously complete image readout. The first spot array image is the spot array image acquired by the first camera, and the second spot array image is the spot array image acquired by the second camera.
[0069] A ring-shaped coded strip is set at the edge of the workpiece support platform. The ring-shaped coded strip is a coded pattern printed on the circumferential side of the workpiece support platform. The ring-shaped coded strip consists of multiple coded marks, evenly distributed along the circumference. The coded marks are alternating black and white rectangular strips, with the long side of the rectangle parallel to the rotation axis of the workpiece support platform. While capturing images of the light spot array on the surface of the workpiece under test, the first and second cameras simultaneously include the ring-shaped coded strip at the edge of their fields of view. The first camera acquires the ring-shaped coded strip to obtain a first coded strip image, and the second camera acquires the ring-shaped coded strip to obtain a second coded strip image. The first coded strip image contains a segment of the ring-shaped coded strip within the field of view of the first camera. The second coded strip image contains a segment of the ring-shaped coded strip within the field of view of the second camera. The imaging positions of the coded marks differ between the first and second coded strip images.
[0070] The rotation angle data is obtained by querying the displacement difference of the coded marks in the first and second coded strip images against a pre-stored circumferential spacing lookup table. The pre-stored circumferential spacing lookup table is stored in the memory of the workpiece rapid measurement system. The pre-stored circumferential spacing lookup table contains multiple entries, each recording the displacement difference of the coded marks and the corresponding rotation angle value. During the query, the edge of the rectangular strip of the coded mark is detected in the first coded strip image to obtain the position of the first coded mark. The edge of the rectangular strip of the coded mark is detected in the second coded strip image to obtain the position of the second coded mark. The difference between the positions of the first and second coded marks is the displacement difference of the coded marks. The displacement difference is compared with the entries in the pre-stored circumferential spacing lookup table, and the entry that most closely matches the displacement difference is found. The rotation angle value in the corresponding entry is then read as the rotation angle data.
[0071] See Figure 2 The process involves transforming the spot centers in the second spot array image to the first camera coordinate system based on rotation angle data, resulting in a unified set of spot centers. The spot centers in the second spot array image are then back-projected onto the second camera coordinate system using the second camera calibration parameters and the second camera imaging model, forming spot center direction vectors in the second camera coordinate system. Based on the rotation matrix and translation vector corresponding to the rotation angle data, these direction vectors are transformed to the first camera coordinate system, forming spot center direction vectors in the first camera coordinate system. The spot centers in the first spot array image are then back-projected onto the first camera coordinate system using the first camera calibration parameters, forming spot center direction vectors in the first camera coordinate system. Finally, the spot center direction vectors of the first spot array image and the transformed second spot array image are merged to obtain a unified set of spot centers. Each element in the unified set of spot centers contains the direction vector of the spot center in the first camera coordinate system and the corresponding sequence number of the spot center.
[0072] Normal rays for each spot in a unified set of spot centers are generated using local incident angle data. For each spot in the unified set of spot centers, the direction vector of the corresponding surface normal in the first camera coordinate system is calculated based on the direction vector of the spot center in the first camera coordinate system and the local incident angle data. The surface normal direction vector is obtained by rotating the spot center direction vector around the horizontal axis of the first camera coordinate system by the angle corresponding to the local incident angle data. Normal rays are constructed with the first camera optical center as the starting point and the surface normal direction vector as the direction. The parametric equations of the normal rays are determined by the coordinates of the first camera optical center and the surface normal direction vector.
[0073] Matching pairs are constructed for adjacent spot center points in a unified spot center set. The method for determining adjacent spot center points is as follows: In the unified spot center set, the angle between the direction vector of each spot center and the direction vector of other spot centers is calculated. Spot center points with an angle smaller than a preset neighborhood angle threshold are determined as adjacent spot center points. The preset neighborhood angle threshold is set based on the angular spacing of adjacent spots in the spot array, and is set to 1.5 times the angular spacing of adjacent spots in the spot array. For each spot center, all its adjacent spot center points are traversed to form candidate matching pairs. For each candidate matching pair, the length of the common perpendicular segment between the two normal rays is calculated. The length of the common perpendicular segment between the two normal rays is obtained by calculating the shortest distance between two skew lines. The candidate matching pair with the smallest common perpendicular segment length is selected as the valid matching pair corresponding to that spot center. In this way, each spot center in the unified spot center set forms a valid matching pair with one adjacent spot center.
[0074] Calculate the midpoint of the common perpendicular segment of the two normal rays in an effective matching pair, and treat the midpoint of the common perpendicular segment as a point in the discrete point cloud. For the two normal rays in an effective matching pair, solve for the common perpendicular of the two normal rays. The intersection of the common perpendicular with the first normal ray is the endpoint of the first common perpendicular segment, and the intersection of the common perpendicular with the second normal ray is the endpoint of the second common perpendicular segment. The average of the coordinates of the endpoints of the first and second common perpendicular segments is the coordinate of the midpoint of the common perpendicular segment.
[0075] Calculate the length of the common perpendicular segment of the two normal rays in a valid matching pair, and use this length as the confidence weight of the valid matching pair. For each spot center, if the spot center appears in multiple valid matching pairs, collect the midpoints of the common perpendicular segments of the spot center in multiple valid matching pairs. Calculate a weighted average of the midpoints of the common perpendicular segments according to the confidence weights to obtain the weighted point coordinates of the spot center. The weighted average is calculated as follows:
[0076]
[0077] in, The weighted coordinates of the center of the light spot; This indicates the number of valid matching pairs involved at the center of the light spot; Indicates the first The length of the common perpendicular segment of a valid matching pair The corresponding effective matching pair is the first one involving the light spot center. One valid matching pair; Indicates the first Coordinates of the midpoint of the common perpendicular segment of each valid matching pair; This represents the summation operation. The confidence weights corresponding to each valid matching pair are: The shorter the length of the perpendicular segment, the greater the confidence weight.
[0078] When the length of the common perpendicular segment of a valid matching pair exceeds a preset length, the weighted point coordinates corresponding to that valid matching pair are removed from the discrete point cloud. The preset length is set to 0.5 times the center distance between adjacent spots in the spot array. The center distance between adjacent spots in the spot array is determined by the cross slit spacing or annular slit spacing of the replaceable mask. For valid matching pairs whose common perpendicular segment length exceeds the preset length, this valid matching pair is not included in the weighted average, and the midpoint of the common perpendicular segment corresponding to this valid matching pair is not included as a point in the discrete point cloud.
[0079] The retained weighted point coordinates are stitched together according to the rotation angle data to obtain a discrete point cloud. For the weighted point coordinates obtained under different rotation angle data, the weighted point coordinates are transformed from the first camera coordinate system to the workpiece bearing platform coordinate system according to the rotation matrix and translation vector corresponding to the rotation angle data. The transformed weighted point coordinates under all rotation angle data are merged to form a discrete point cloud. Each point in the discrete point cloud contains three-dimensional coordinates in the workpiece bearing platform coordinate system.
[0080] Boundary points located at the edge of the workpiece under test are extracted from the discrete point cloud. The boundary point extraction method is as follows: for each point in the discrete point cloud, the maximum principal curvature of each point in its local neighborhood is calculated. Points with a maximum principal curvature greater than a preset curvature threshold are marked as boundary points. The preset curvature threshold is set according to the surface curvature distribution of the workpiece under test.
[0081] The boundary points are sorted according to the distance between adjacent points to obtain a boundary point sequence. The sorting process includes: selecting a starting boundary point from the set of boundary points, searching for the boundary point in the remaining set that is closest to the starting boundary point as the next boundary point, and repeating the search process until all boundary points are sorted.
[0082] Select the last three boundary points at each end of the boundary point sequence. For the first end of the boundary point sequence, take the first, second, and third boundary points, and fit a straight line through these three boundary points. The direction vector of this straight line is used as the tangential extension direction of the first end. For the second end of the boundary point sequence, take the last three boundary points, the second to last, and the third to last, and fit a straight line through these three boundary points. The direction vector of this straight line is used as the tangential extension direction of the second end.
[0083] Extend the first end of the boundary point sequence along the tangential extension direction of the first end to the boundary of the workpiece support platform plane, obtaining the first closed endpoint. Extend the second end of the boundary point sequence along the tangential extension direction of the second end to the boundary of the workpiece support platform plane, obtaining the second closed endpoint.
[0084] By sequentially connecting the first closed endpoint, each boundary point in the boundary point sequence, and the second closed endpoint, the closed curve of the workpiece contour is obtained. The connection method is to connect adjacent points with straight line segments.
[0085] The closed curve of the workpiece contour is resampled using equal arc lengths to obtain a sequence of contour sampling points. Equal arc length resampling includes: calculating the total arc length of the closed curve; dividing the total arc length by a preset number of sampling points to obtain the sampling arc length interval; starting from any point on the closed curve, taking one point along the curve at every sampling arc length interval until returning to the starting point, thus obtaining the sequence of contour sampling points. The preset number of sampling points is set according to the complexity of the closed curve of the workpiece contour.
[0086] Calculate the angle formed by every three adjacent sampling points in the contour sampling point sequence. For the r-th sampling point in the sequence, take the preceding and following sampling points, and calculate the angle between the vector from the preceding sampling point to the r-th sampling point and the vector from the r-th sampling point to the following sampling point. Mark sampling points with angles less than a preset angle as corner points. The preset angle is set to 120 degrees. When the angle is less than 120 degrees, the r-th sampling point is marked as a corner point.
[0087] The curve segment between adjacent corner points is shape-matched with pre-stored geometric primitives to obtain the corresponding geometric primitive parameters. The pre-stored geometric primitives include line segments, arcs, and circular hole contours. Shape matching involves: for a curve segment between adjacent corner points, sampling multiple points from the curve segment, performing least-squares fitting between the coordinates of the sampled points and the pre-stored geometric primitives, and calculating the fitting error. The pre-stored geometric primitive with the smallest fitting error is selected as the geometric primitive type corresponding to the curve segment, and the fitted parameters are used as the geometric primitive parameters. The geometric primitive parameters include line length, arc radius, center coordinates, and circular hole diameter.
[0088] The system outputs the length, width, hole diameter, and angular dimensions of the workpiece under test based on the geometric primitive parameters. The length of the workpiece is the length of the straight line segment geometric primitive between adjacent corner points. The width of the workpiece is the perpendicular distance between another pair of parallel straight line segment geometric primitives. The hole diameter of the workpiece is the diameter of the circular hole geometric primitive. The angular dimensions of the workpiece are the included angles between adjacent straight line segment geometric primitives.
[0089] In practical implementation, the machine vision-based rapid workpiece measurement system includes a memory, a processor, and a computer program stored in the memory and running on the processor. The memory and processor are connected via a data bus. The memory stores the computer program, rotation control parameters of the polarization-encoded screen, calibration parameters of the first and second cameras, a pre-stored circumferential spacing lookup table, pre-stored geometric primitive parameters, the first spot array image acquired by the first camera, the second spot array image acquired by the second camera, the first coded band image, the second coded band image, horizontal polariton diagrams, vertical polariton diagrams, left-handed polariton diagrams, right-handed polariton diagrams, local incident angle data, rotation angle data, a unified set of spot centers, normal ray data, coordinates of the midpoint of the common perpendicular segment, weighted point coordinates, discrete point cloud, boundary point sequence, workpiece contour closed curve, contour sampling point sequence, geometric primitive parameters, and workpiece dimension data. The processor calls the computer program in the memory to execute the steps of the machine vision-based rapid workpiece measurement method.
[0090] The processor controls the rotation of the polarization-encoded optical screen. It sends stepping pulses and direction signals to the stepper motor driver. The stepper motor driver drives the rotating support to rotate step by step according to the stepping pulses and direction signals. The rotating support drives the polarization-encoded optical screen to rotate around its vertical axis. The processor controls the rotation angle and speed of the polarization-encoded optical screen by controlling the number and frequency of the stepping pulses. The rotation control parameters of the polarization-encoded optical screen include the total number of stepping pulses, the stepping pulse frequency, and the rotation direction. The total number of stepping pulses determines the total number of steps the rotating support rotates. The stepping pulse frequency determines the rotation speed of the rotating support. The rotation direction signal determines the rotation direction of the rotating support. According to a preset alternating projection cycle, the processor alternately controls the cross slit and annular slit of the replaceable mask to align with the optical path. When the cross slit is aligned with the optical path, the processor activates the parallel light source, and the surface of the workpiece receives the first light spot array. When the annular slit is aligned with the optical path, the processor activates the parallel light source, and the surface of the workpiece receives the second light spot array. After the first light spot array is projected, the processor controls the rotating support to rotate by one step angle, aligning the annular slit with the optical path. After the second light spot array is projected, the processor controls the rotating bracket to rotate by one step angle so that the cross slit is aligned with the light path.
[0091] The processor performs synchronous acquisition control of the first and second cameras. The processor sends a synchronous trigger command to an external trigger controller. The programmable logic device in the external trigger controller generates a first synchronous trigger pulse and a second synchronous trigger pulse. The first synchronous trigger pulse is transmitted to the trigger input interface of the first camera via a first signal line. The second synchronous trigger pulse is transmitted to the trigger input interface of the second camera via a second signal line. The rising edges of the first and second synchronous trigger pulses are time-aligned. The first camera begins exposure after receiving the rising edge of the first synchronous trigger pulse, and the second camera begins exposure after receiving the rising edge of the second synchronous trigger pulse. The exposure times of the first and second cameras are pre-written by the processor through the camera control interface. The first camera acquires a first spot array image and a first coded strip image at the same exposure time. The second camera acquires a second spot array image and a second coded strip image at the same exposure time. The first camera sends the first spot array image and the first coded strip image to the processor. The second camera sends the second spot array image and the second coded strip image to the processor.
[0092] The processor performs calculations on local incident angle data and rotation angle data. It separates the polarization channels of the first and second spot array images, obtaining horizontal, vertical, left-handed, and right-handed polarization sub-images. The processor performs dark current subtraction and spot connectivity labeling on the images of the four regions, obtaining four sets of labeled connected components. The processor sets multiple sampling rings radially in the horizontal and vertical polarization sub-images, with the spot center as the origin of the polar coordinates. The processor calculates the difference in grayscale variation periods between the horizontal and vertical polarization sub-images on the same sampling ring, obtaining the polarization phase difference. The processor corrects the polarization phase difference based on the difference in spot ellipticity between the left-handed and right-handed polarization sub-images, obtaining local incident angle data. The processor detects the rectangular edges of the coded markers in the first coded strip image, obtaining the position of the first coded marker. The processor detects the rectangular edges of the coded markers in the second coded strip image, obtaining the position of the second coded marker. The processor calculates the difference between the first and second coded marker positions, obtaining the displacement difference of the coded marker. The processor queries the pre-stored circumferential spacing lookup table, reads the rotation angle value corresponding to the displacement difference of the coded mark, and obtains the rotation angle data.
[0093] The processor executes spatial triangulation constraints to generate a discrete point cloud. Based on rotation angle data, the processor transforms the center of the light spots in the second light spot array image to the first camera coordinate system, obtaining a unified set of light spot centers. The processor uses local incident angle data to generate the normal ray for each light spot in the unified set of light spot centers. The processor constructs effective matching pairs for adjacent light spot center points in the unified set of light spot centers. The processor calculates the length of the common perpendicular segment of the two normal rays in the effective matching pair and uses this length as the confidence weight of the effective matching pair. The processor obtains the midpoint of the common perpendicular segment and performs a weighted average of the midpoints according to the confidence weight to obtain the weighted point coordinates. When the length of the common perpendicular segment exceeds a preset length, the processor removes the weighted point coordinates corresponding to the effective matching pair from the discrete point cloud. The processor stitches the remaining weighted point coordinates according to the rotation angle data to obtain the discrete point cloud. During stitching, the processor generates a rotation matrix and translation vector based on the rotation angle data, transforming the weighted point coordinates from the first camera coordinate system to the workpiece support platform coordinate system. The transformation formula is as follows:
[0094]
[0095] in, This represents the three-dimensional coordinate vector of the weighted point coordinates in the workpiece bearing platform coordinate system; This represents a rotation matrix generated from rotation angle data; the rotation matrix is in three rows and three columns. This represents the three-dimensional coordinate vector of the weighted point coordinates in the first camera coordinate system. This represents the translation vector generated from the rotation angle data, arranged in a 3x3 grid. The rotation matrix and translation vector are obtained by calibrating the pose relationship between the first camera coordinate system and the workpiece support platform coordinate system. Specifically, a calibration plate with known 3D coordinates is set in the first camera coordinate system, and the 3D coordinates of corresponding points on the calibration plate are measured in the workpiece support platform coordinate system. The rotation matrix and translation vector are then solved through the coordinate transformation relationship between corresponding points. When the rotation angle data is different, the rotation matrix and translation vector are updated according to the rotation state of the workpiece support platform corresponding to the rotation angle data.
[0096] The processor performs tangential extension and workpiece dimension data extraction. It extracts boundary points located at the edge of the workpiece from the discrete point cloud and sorts these points according to their spacing, obtaining a boundary point sequence. The processor selects the last three boundary points at each end of the boundary point sequence and generates a tangential extension direction based on these points. The processor extends the boundary point sequence along the tangential extension direction to the boundary of the workpiece support platform plane, obtaining two closed endpoints. The processor connects the boundary point sequence and the two closed endpoints sequentially to obtain the workpiece contour closed curve. The processor performs equal-arc-length resampling on the workpiece contour closed curve to obtain a contour sampling point sequence. The processor calculates the angle formed by every three adjacent sampling points in the contour sampling point sequence and marks sampling points with angles smaller than a preset angle as corner points. The processor performs shape matching between the curve segments between adjacent corner points and pre-stored geometric primitives to obtain the corresponding geometric primitive parameters. The processor outputs the length, width, aperture, and angular dimension data of the workpiece based on the geometric primitive parameters. The length of the workpiece is the length of the geometric primitive segment of the straight line between adjacent corner points. The width of the workpiece to be measured is the perpendicular distance between another pair of parallel straight line segment geometric primitives. The diameter of the hole in the workpiece to be measured is the diameter of the circular hole geometric primitive. The angular dimensions of the workpiece to be measured are the included angles between adjacent straight line segment geometric primitives.
[0097] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application.
Claims
1. A rapid workpiece measurement method based on machine vision, characterized in that, include: A rotatable polarization-encoded light screen is set on the workpiece support platform, and a first light spot array and a second light spot array with different polarization states are projected onto the surface of the workpiece to be tested placed on the workpiece support platform. The first and second spot array images of the surface of the workpiece under test are simultaneously acquired by the first and second cameras arranged around the workpiece support platform, and the rotation angle data of the workpiece support platform is obtained. Based on the polarization phase difference between adjacent spots in the first spot array image and the second spot array image, the local incident angle data of each spot on the surface of the workpiece under test is determined. Based on the local incident angle data and the rotation angle data, spatial triangulation constraints are applied to the center points of adjacent light spots to generate a discrete point cloud on the surface of the workpiece to be tested. The discrete point cloud is tangentially extended along the edge of the workpiece to be measured to obtain a closed curve of the workpiece contour, and the workpiece size data is extracted from the closed curve of the workpiece contour.
2. The machine vision-based rapid workpiece measurement method according to claim 1, characterized in that, The step of determining the local incident angle data of each light spot on the surface of the workpiece under test based on the polarization phase difference between adjacent light spots in the first light spot array image and the second light spot array image includes: Polarization channel separation is performed on the first spot array image and the second spot array image respectively to obtain horizontal polarization sub-image, vertical polarization sub-image, left-handed polarization sub-image and right-handed polarization sub-image; In the horizontal polarization sub-map and the vertical polarization sub-map, multiple sampling rings are arranged radially with the center of the light spot as the origin of the polar coordinates. The polarization phase difference is obtained by calculating the grayscale change period difference between the horizontal polarization sub-image and the vertical polarization sub-image on the same sampling ring. The polarization phase difference is corrected based on the difference in spot ellipticity between the left-handed and right-handed polarization diagrams to obtain the local incident angle data.
3. The machine vision-based rapid workpiece measurement method according to claim 1, characterized in that, The process of simultaneously acquiring first and second spot array images of the surface of the workpiece under test using a first camera and a second camera arranged around the workpiece support platform, and obtaining rotation angle data of the workpiece support platform, includes: The first camera and the second camera are arranged at a 90-degree angle with the center of the workpiece support platform as the center, and the optical axis makes a 45-degree angle with the plane of the workpiece support platform. Send a synchronization trigger pulse to the first camera and the second camera so that they can acquire the first spot array image and the second spot array image at the same exposure time; An annular coding strip is set at the edge of the workpiece support platform. The first camera and the second camera simultaneously acquire the annular coding strip to obtain a first coding strip image and a second coding strip image. The rotation angle data is obtained by querying the displacement difference of the coded marks in the first coded band image and the second coded band image and the pre-stored circumferential spacing lookup table.
4. The machine vision-based rapid workpiece measurement method according to claim 1, characterized in that, The step of generating a discrete point cloud of the workpiece surface by performing spatial triangulation constraints on the center points of adjacent light spots based on the local incident angle data and the rotation angle data includes: Based on the rotation angle data, the center of the light spot in the second light spot array image is transformed to the first camera coordinate system to obtain a unified set of light spot centers; The normal ray of each spot in the unified spot center set is generated using the local incident angle data; For adjacent spot center points in the unified spot center set, a matching pair is constructed, and the matching pair is constrained by the shortest common perpendicular segment of the two normal rays; Calculate the midpoint of the common perpendicular segment of the two normal rays in the matching pair, and use the midpoint of the common perpendicular segment as a point in the discrete point cloud.
5. The machine vision-based rapid workpiece measurement method according to claim 1, characterized in that, The step of tangentially extending the discrete point cloud along the edge of the workpiece to obtain a closed contour curve of the workpiece includes: Boundary points located at the edge of the workpiece under test are extracted from the discrete point cloud, and the boundary points are sorted according to the distance between adjacent points to obtain a boundary point sequence; Select the last three boundary points at both ends of the boundary point sequence, and generate the tangential extension direction based on the last three boundary points; Extend both ends of the boundary point sequence along the tangential extension direction to the boundary of the workpiece support platform plane to obtain two closed endpoints; By sequentially connecting the boundary point sequence and the two closed endpoints, the closed curve of the workpiece contour is obtained.
6. The machine vision-based rapid workpiece measurement method according to claim 1, characterized in that, The step of extracting workpiece dimension data from the closed curve of the workpiece contour includes: The closed curve of the workpiece contour is resampled with equal arc length to obtain a sequence of contour sampling points; Calculate the included angle formed by every three adjacent sampling points in the contour sampling point sequence, and mark the sampling points whose included angle is less than a preset angle as corner points; The curve segment between adjacent corner points is matched with the pre-stored geometric primitives to obtain the geometric primitive parameters corresponding to the curve segment. The length, width, hole diameter, and angular dimensions of the workpiece to be tested are output based on the geometric primitive parameters.
7. The machine vision-based rapid workpiece measurement method according to claim 1, characterized in that, The step of setting a rotatable polarization-encoded light screen on the workpiece support platform and projecting a first light spot array and a second light spot array with different polarization states onto the surface of the workpiece to be tested placed on the workpiece support platform includes: The polarization-encoded optical screen is mounted on a rotating bracket above the workpiece support platform. The polarization-encoded optical screen includes orthogonal polarizers and replaceable masks. A horizontally polarized cross array is generated through the cross slit in the replaceable mask, and the horizontally polarized cross array is used as the first spot array through the orthogonal polarizer. A vertically polarized ring array is generated through the annular slit in the replaceable mask, and the vertically polarized ring array is used as the second spot array through the orthogonal polarizer. The rotating bracket is driven to rotate step by step, so that the first light spot array and the second light spot array are alternately projected onto the surface of the workpiece to be tested.
8. The machine vision-based rapid workpiece measurement method according to claim 2, characterized in that, The step of performing polarization channel separation on the first spot array image and the second spot array image respectively to obtain a horizontal polarization sub-image, a vertical polarization sub-image, a left-handed polarization sub-image, and a right-handed polarization sub-image includes: A four-quadrant polarizing beam splitter is set in front of the lenses of the first camera and the second camera to split the incident light into four polarized beams. The four polarized lights are imaged onto four regions of the same image sensor after passing through horizontal, vertical, left-handed, and right-handed narrowband filters, respectively. Dark current subtraction and spot connectivity labeling were performed on the images of the four regions respectively to obtain four sets of labeled connected components; The four sets of marked connected components are output as the horizontal polarization sub-graph, the vertical polarization sub-graph, the left-handed polarization sub-graph, and the right-handed polarization sub-graph according to their polarization states.
9. The machine vision-based rapid workpiece measurement method according to claim 4, characterized in that, The step of calculating the midpoint of the common perpendicular segment of the two normal rays in the matching pair, and using the midpoint of the common perpendicular segment as a point in the discrete point cloud, includes: Calculate the length of the common perpendicular segment of the two normal rays in the matching pair, and use the length of the common perpendicular segment as the confidence weight of the matching pair; Obtain the midpoint of the common perpendicular segment, and then perform a weighted average of the midpoints of the common perpendicular segment according to the confidence weight to obtain the coordinates of the weighted point; When the length of the common perpendicular segment exceeds the preset length, the weighted point coordinates corresponding to the matching pair are removed from the discrete point cloud. The retained weighted point coordinates are stitched together according to the rotation angle data to obtain the discrete point cloud.
10. A machine vision-based rapid workpiece measurement system, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the machine vision-based rapid workpiece measurement method according to any one of claims 1 to 9.
