Camera calibration method, machine tool and medium
By using a camera calibration method based on machine tool motion and workpiece self-features, and utilizing the machine tool kinematic model and workpiece circular hole, efficient and accurate calibration of camera intrinsic parameters and hand-eye extrinsic parameters is achieved. This solves the problems of calibration error and drift monitoring in existing technologies and improves the convenience and accuracy of the calibration process.
Patent Information
- Application Number
- CN202611659349.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-26
- Publication Date
- 2026-11-24
AI Technical Summary
Existing camera calibration methods rely on calibration boards, which have manufacturing and clamping position errors. They also cannot achieve efficient and accurate calibration of camera intrinsic and extrinsic parameters without the use of calibration boards and special measuring instruments, and lack drift monitoring methods.
By using a camera calibration method based on machine tool motion and workpiece self-features, and utilizing the feedback coordinates and kinematic model of each axis of the machine tool, combined with the circular hole of the workpiece itself as a target, a three-stage solution method of rotation and translation decoupling is adopted to obtain the intrinsic parameters of the camera and the extrinsic parameters of the hand and eye. The coordinates of the center of the circular hole in the machine tool coordinate system are determined by probe contact measurement, thereby realizing the drift monitoring of the calibration results.
It enables efficient calibration of camera intrinsic parameters and hand-eye extrinsic parameters in the same setup, avoids mutual compensation of errors, and can monitor the drift of calibration results in real time, thus improving the convenience and accuracy of the calibration process.
Smart Images

Figure CN123160683A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of CNC machine tool technology, specifically to a camera calibration method, machine tool, and medium based on machine tool motion and workpiece self-features. Background Technology
[0002] Multi-axis CNC machine tools have a camera installed between the spindle and the workpiece, which can complete tool setting, workpiece alignment, and contour measurement in a single setup. To convert the image to the machine tool coordinate system, the camera's intrinsic parameters and the camera's extrinsic parameters relative to the spindle flange must first be obtained. Thermal deformation of the machine tool, tool changes, and collisions will all cause these parameters to change, and the frequency and ease of calibration directly affect the usability of in-machine measurement.
[0003] Existing calibration methods mostly rely on calibration boards. The operator clamps a checkerboard or dot array to a fixed position on the worktable, and the spindle drives the camera to photograph the calibration board in multiple poses. Intrinsic parameters and extrinsic parameters are then calculated from the known patterns on the calibration board. Manufacturing errors of the calibration board itself and clamping pose errors will affect the calibration results; the calibration board and the workpiece compete for workspace, requiring machine downtime during calibration; and the repeatability of on-site calibration depends on manual operation.
[0004] Another approach involves solving for intrinsic and extrinsic parameters in two stages: first, calibrating the intrinsic parameters in the laboratory, and then calibrating the extrinsic parameters at a fixed position on the worktable. This step-by-step solution requires sufficient motion excitation in each stage. When the spindle rotation range is limited or the relative motion between the camera and the turntable is insufficient, the correction amount for the intrinsic parameters is considerable, and the errors of the intrinsic and extrinsic parameters compensate for each other. Visual calibration without a calibration plate is often used in situations where the camera is fixedly mounted; the spindle-following camera and workpiece features are not included in the observation; circular holes are usually only used for tool setting and not as calibration targets; the calibrated parameters lack drift monitoring, and inaccuracies can only be discovered after the fact due to machining deviations.
[0005] Therefore, the technical problem that needs to be solved is how to obtain the camera's intrinsic parameters, hand-eye extrinsic parameters, and extrinsic parameters under the acquisition pose simultaneously in the same clamping operation, without using calibration plates and special measuring instruments, and without relying on the prior dimensions and pose of the reference object, using the machine tool motion as the excitation and the circular hole of the workpiece itself as the target, and how to monitor the drift of the calibration results. Summary of the Invention
[0006] In view of the above problems, this application provides a camera calibration method, machine tool and medium based on machine tool motion and workpiece self-features.
[0007] According to the first aspect of this application, a camera calibration method based on machine tool motion excitation and workpiece self-features is provided. The machine tool includes a spindle, a rotary table, and a camera clamped on the spindle. The rotary table includes a B-axis and a C-axis, with the C-axis mounted on the B-axis and tilting as the B-axis rotates. The spindle is configured to perform linear feed along the X-axis, Y-axis, and Z-axis of the machine tool. The method includes: loading the intrinsic prior of the camera and the kinematic model of the machine tool, the kinematic model giving the pose of the spindle flange in the machine tool coordinate system; moving the spindle along at least one of the X-axis, Y-axis, and Z-axis according to a preset pose sequence, and / or rotating at least one of the B-axis and C-axis; and, at each preset pose in the preset pose sequence, the camera acquires the image of the fixed workpiece on the C-axis worktable. The reference image of the fixed reference object is used, but the size and pose of the fixed reference object are unknown. Based on the feedback coordinates and kinematic model of each axis of the machine tool, the camera pose in the machine tool coordinate system under each preset pose sequence is determined. Using the camera pose in the machine tool coordinate system under each preset pose as the known excitation and the reference image under that preset pose as the observation, the camera's intrinsic parameters, the camera's extrinsic parameters relative to the spindle flange, and the three-dimensional coordinates of the fixed reference object in the machine tool coordinate system are used as joint unknowns. The intrinsic parameters and extrinsic parameters are obtained by solving in three stages according to rotation and translation decoupling. In the first stage, the reference image under the pose where the spindle does not move and at least one of the B-axis and C-axis rotates is used to refine the camera's intrinsic parameter prior, thus obtaining the refined intrinsic parameters. In the second stage, the reference image under the pose where the spindle does not move and at least one of the B-axis and C-axis rotates is used to refine the camera's intrinsic parameter prior, thus obtaining the refined intrinsic parameters. The reference image and the camera pose in the machine coordinate system are given in a pose where the B-axis and C-axis do not rotate and the main spindle moves along at least one of the X-axis, Y-axis, and Z-axis directions. Initial values of the hand-eye extrinsic parameters are coarsely obtained. The third stage aims to optimize the intrinsic parameters, initial values of the hand-eye extrinsic parameters, and 3D coordinates by jointly refining the reprojection residuals of all reference images in the preset pose sequence. This yields the camera's intrinsic parameters, hand-eye extrinsic parameters, and 3D coordinates. The reprojection residual for each preset pose is the difference between the 3D coordinates of the fixed reference object in that preset pose, projected onto the reference image in the machine coordinate system using the refined intrinsic parameters and the camera pose in the machine coordinate system, and the image point of the fixed reference object in the reference image. The deviation is determined by the following steps: After the workpiece is loaded, the camera acquires an image of the workpiece in the acquisition pose. The circular hole of the workpiece is identified in the image, and the imaging point of the center of the circular hole in the workpiece image is determined according to the vanishing pole method. The acquisition pose is the pose of the camera in the machine tool coordinate system when acquiring the workpiece image. The probe of the machine tool contacts multiple points on the edge of the circular hole, and the machine tool coordinates at each contact time are recorded. The coordinates of the center of the circular hole in the machine tool coordinate system are determined according to the machine tool coordinates at each contact time. The imaging point of the center of the circular hole in the workpiece image is paired with the coordinates of the center of the circular hole in the machine tool coordinate system to form the correspondence between the imaging point of the center of the circular hole and the three-dimensional coordinates of the center of the hole. According to the intrinsic parameters of the camera, the extrinsic parameters of the camera in the machine tool coordinate system in the acquisition pose are solved.The camera's intrinsic parameters, hand-eye extrinsic parameters, and extrinsic parameters in the machine tool coordinate system under the acquisition pose are used as the camera calibration results.
[0008] According to a second aspect of this application, a machine tool is also provided, comprising a machine tool body, a spindle, a rotary table, a camera, and a CNC system; the rotary table includes a B-axis and a C-axis, the C-axis being mounted on the B-axis and tilting as the B-axis rotates, the B-axis being arranged about the Y-axis direction of the machine tool, and the C-axis being arranged about the Z-axis direction of the machine tool; the spindle is configured to perform linear feed along the X-axis, Y-axis, and Z-axis directions of the machine tool; the camera is mounted on the spindle; the CNC system is configured to perform the steps of the camera calibration method based on machine tool motion excitation and workpiece self-features according to embodiments of this application.
[0009] According to a third aspect of this application, a computer-readable storage medium is also provided, on which a computer program or instructions are stored, wherein when the computer program or instructions are executed by a processor, the steps of the camera calibration method based on machine tool motion excitation and workpiece self-features according to the embodiments of this application are implemented.
[0010] According to a fourth aspect of this application, a computer program product is also provided, including a computer program or instructions, which, when executed by a processor, implement the steps of the camera calibration method based on machine tool motion excitation and workpiece self-features according to embodiments of this application.
[0011] According to some embodiments of this application, the feedback coordinates and kinematic model of each axis of the machine tool are used as known excitations, and the image of a fixed reference object with unknown size and pose is used as the observation. The intrinsic parameters of the camera, the extrinsic parameters of hand and eye, and the three-dimensional coordinates of the reference object are all treated as joint unknowns. The solution is performed in three stages with rotation and translation decoupling: the intrinsic parameters are refined under pure rotation frame pairs, the extrinsic parameters of hand and eye are coarsely solved under pure translation frame pairs, and the two are jointly optimized under the weighted projection target of all poses. This avoids the problem of mutual compensation of intrinsic and extrinsic parameter errors in the step-by-step solution, and also avoids directly applying non-variables to all unknowns. Linear optimization is dependent on initial values; after the workpiece is loaded, the workpiece's own circular hole is used as the target, and the vanishing pole method separates the imaging point of the circle center from the center of the projected ellipse. The probe contact fixes the hole center to the machine tool coordinate system. The two-dimensional and three-dimensional correspondence between the two makes the solution of the acquired pose extrinsic parameters independent of additional calibration plates and manual point selection; field-level calibration and workpiece-level calibration are completed in the same clamping. The calibration process does not require special measuring instruments. The size and pose of the reference object are not included in the prior. The re-inspection reprojection residual and the re-measurement contact deviation make the drift of the calibration result detectable and trigger automatic recalibration. Attached Figure Description
[0012] The above-mentioned contents, other objects, features and advantages of this application will become clearer from the following description of embodiments with reference to the accompanying drawings, in which:
[0013] Figure 1 A flowchart illustrating a camera calibration method based on machine tool motion and workpiece self-features according to an embodiment of this application is shown.
[0014] Figure 2 A schematic diagram of the structure of a machine tool according to an embodiment of this application is shown. Detailed Implementation
[0015] The embodiments of this application will now be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of this application. In the following detailed description, numerous specific details are set forth to provide a thorough understanding of the embodiments of this application for ease of explanation. However, it will be apparent that one or more embodiments may be implemented without these specific details. Furthermore, descriptions of well-known structures and technologies are omitted in the following description to avoid unnecessarily obscuring the concepts of this application.
[0016] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the scope of this application. The terms “comprising,” “including,” etc., as used herein indicate the presence of the stated features, steps, operations, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, or components.
[0017] All terms used herein (including technical and scientific terms) have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein are to be interpreted in a manner consistent with the context of this specification, and not in an idealized or overly rigid way.
[0018] To facilitate understanding, the following terms are explained first, with each term given its meaning, source, and destination: meaning refers to the object or quantity referred to by the term, source refers to the location where the object or quantity is generated and input, and destination refers to its use in subsequent steps.
[0019] The machine tool body refers to the mechanical structure that supports the spindle and rotary table; the spindle refers to the component that performs linear feed and clamps tools, probes, or cameras; the rotary table refers to a swing-rotation worktable with B-axis and C-axis, wherein the B-axis is set around the Y-axis of the machine tool, and the C-axis is set around the Z-axis of the machine tool and mounted on the B-axis. The geometric relationships of the above components are derived from the mechanical structure of the machine tool, and their destination is the kinematic model loaded in step S110 and... Figure 1 The application scenarios shown. The spindle flange refers to the positioning surface at the front end of the spindle used to install tools, probes or cameras. Its position is uniquely determined by the feedback coordinates of each axis and the kinematic model. It is the reference datum for hand-eye extrinsic parameters. Its location is given by equations (1) and (5).
[0020] The machine tool coordinate system takes the mechanical zero point of each feed axis as the origin and the direction of each guide rail as the coordinate axis direction; the camera coordinate system takes the optical center of the camera as the origin and the optical axis direction as the depth direction; the pixel coordinate system takes the column direction and row direction of the image as the coordinate axis direction. The definitions of the three coordinate systems are derived from the geometric structure of the machine tool and the camera, and their destination is the unified reference for homogeneous transformation and projection calculation. Pose refers to the homogeneous transformation composed of rotation matrix and translation vector, which is used to transform a point in one coordinate system to another coordinate system, where the rotation matrix is an orthogonal matrix and the determinant is 1. Homogeneous coordinates refer to the coordinate form of representing two-dimensional points with three-dimensional vectors and three-dimensional points with four-dimensional vectors, and their destination is the pole solution of equation (4) and the back projection of equation (8); normalization refers to dividing the homogeneous coordinate by its last non-zero component to make that component 1, and the first two components after normalization are the pixel coordinates.
[0021] Intrinsic parameters refer to the pixel focal length, principal point coordinates, and distortion coefficients that describe the imaging geometry of the camera; intrinsic parameter priors refer to the intrinsic parameter values that were already held before calibration, which are derived from the camera's factory nominal values, laboratory calibration values, or the results of the last field calibration, and include uncertainty; refined intrinsic parameters refer to the intrinsic parameters obtained after the a priori correction of the intrinsic parameters in the first stage. The destination of the three is the projection calculation of equations (2a), (3), and (6). Hand-eye extrinsic parameters refer to the pose of the camera coordinate system relative to the main axis flange, which are derived from the joint optimization of equation (3) and are derived from the pose synthesis of equation (1) and the initial value of step S170; the initial value of hand-eye extrinsic parameters refers to the hand-eye extrinsic parameters obtained from the coarse solution in the second stage. The acquisition pose refers to the pose of the camera in the machine tool coordinate system when acquiring the image of the workpiece. The acquisition pose extrinsic parameter refers to the pose parameter of the pose, which is obtained from the solution of equation (6) and is returned to the output of equation (8) and step S180. The intrinsic parameter and the hand-eye extrinsic parameter do not change with the acquisition pose, but the acquisition pose extrinsic parameter changes with the spindle position.
[0022] The kinematic model refers to the analytical model composed of structural constants, the directions of each axis and the geometric relationship of adjacent axes. It takes feedback coordinates as input and the main spindle flange pose as output. It originates from the loading in step S110 and is resolved by the positive solution of equations (1) and (5). Feedback coordinates refer to the coordinate readings given by the encoders or grating rulers of each axis. They originate from the latch of the CNC system and are resolved by the kinematic model. The preset pose sequence index is the set of poses arranged before the setting. It is divided into pure rotation group, pure translation group and mixed group according to the motion form. It originates from the arrangement in step S120 and is resolved by the three-stage solution in step S140. The known excitation refers to the camera pose as the known input and the observation refers to the image coordinates as the measured input. Both originate from steps S120 and S130 and are resolved by the joint solution of equation (3).
[0023] The fixed reference object is an object whose position, size, and pose are not known in advance during the calibration process. It is a workpiece blank or general part clamped on the C-axis worktable and is removed by the acquisition of reference object images. The reference object image refers to the image acquired by the fixed reference object under each preset pose. The three-dimensional coordinate refers to the position of the reference feature on the fixed reference object in the machine tool coordinate system. It is listed together with the intrinsic parameter and the manual-eye extrinsic parameter as a joint unknown. The joint unknown refers to the set of variables to be solved together. It is set in step S140 and is removed by the optimization of equation (3). The reprojection residual refers to the pixel deviation between the three-dimensional point after projection by the intrinsic parameter, distortion coefficient, and camera pose and the measured image point. The weighted sum of squares refers to the sum of the squares of the residuals after weighting by the reciprocal of the variance of each observation noise. The three stages refer to the three solution stages of fine-tuning the intrinsic parameter, coarse solution of the manual-eye extrinsic parameter, and joint optimization. It is set in step S140 and removed by the calibration results of the intrinsic parameter and the manual-eye extrinsic parameter.
[0024] The homography matrix refers to the two-dimensional projective transformation matrix of a point on the same plane between two images. It is obtained from the same image point in step S140 and is resolved by the inverse solution of the intrinsic parameters of equations (2) and (2a). The epipolar constraint refers to the geometric constraint that the image point of the same spatial point in two frames is coplanar with the optical center of the two frames. It is obtained from the pure translation frame pair and is resolved by the solution of the initial values of the hand-eye extrinsic parameters. The orthogonal constraint refers to the constraint that the rotation matrix is an orthogonal matrix and the determinant is 1. It is obtained from the parameterization of the pose and is resolved by the solution of equation (6) and the orthogonalization of the rotation matrix.
[0025] The workpiece image refers to the image captured by the camera in the acquisition pose after the workpiece is loaded; the circular hole refers to the hole of the workpiece itself, which is derived from the existing process holes, center holes or pin holes on the workpiece, and is removed by image recognition and contact measurement; the hole contour refers to the projection of the edge of the circular hole in the image. Subpixel ellipse fitting refers to the process of extracting the edge points of the hole contour with subpixel accuracy and fitting an ellipse, which is derived from step S150 and removed by the quadratic curve matrix of the projected ellipse; the projected ellipse refers to the imaging ellipse of the hole contour in the image; the quadratic curve matrix refers to the coefficient matrix of the quadratic curve represented by a third-order symmetric matrix. The vanishing line refers to the projection line of the plane where the hole is located in the image, which is derived from the normal of the hole plane and the acquisition pose, and is removed by equation (4); the pole refers to the pole of the quadratic curve about a straight line, and the pole and the pole are dual to each other; the vanishing line pole method refers to the method of determining the center imaging point of the circle by the pole of the projected ellipse about the vanishing line, and is removed by the image point in step S170.
[0026] The center imaging point refers to the imaging point of the center of the circular hole in the image, which is derived from equation (4) and removed from the image point in step S170; the image point refers to the pixel coordinates involved in the pose solution; the three-dimensional point refers to the machine tool coordinates involved in the pose solution, which is derived from equation (5); the correspondence refers to the pairing between the image point and the three-dimensional point of the same circular hole, which is derived from step S170 and removed from equation (6). The vanishing line can be obtained by projecting the normal of the hole plane through the acquired pose. When the hole plane is unknown, it is obtained by finding the intersection point of the images of two pairs of approximately parallel hole edge lines. When the difference between the two exceeds the set value, the result of the parallel line pair is used.
[0027] The probe refers to the trigger-type probe that is clamped on the spindle and used for contact measurement; the probe tip calibration position refers to the position of the probe tip relative to the spindle flange, which is derived from the probe's factory parameters and clamping status, and is derived from equation (5); the hole edge refers to the edge of the hole opening; the contact point refers to the contact position between the probe tip and the hole edge; the hole center refers to the intersection of the axis of the hole and the hole opening plane; the hole opening plane refers to the plane at the upper end of the hole, which is derived from the fitting of all contact points, and is derived from the calculation of the vanishing line and the output of the hole diameter; the least squares circle fitting refers to the circle fitting that minimizes the sum of the squares of the radial deviations of each contact point from the fitted circle, which is derived from step S160, and is derived from the hole center coordinates and the hole diameter.
[0028] The re-inspection cycle refers to the time interval between two drift re-inspections or the interval between the number of processed parts; the re-inspection image refers to the fixed reference image collected according to the re-inspection cycle; the re-inspection reprojection residual refers to the residual calculated according to the re-inspection image and formula (7); the residual threshold refers to the upper limit allowed by the re-inspection reprojection residual; the re-measurement contact deviation refers to the physical deviation between the coordinates obtained by the probe re-measurement of the hole center and the coordinates of the hole center calculated from the re-inspection image; the contact deviation threshold refers to the upper limit allowed by the re-measurement contact deviation; the drift judgment value refers to the judgment quantity given by formula (9); automatic recalibration refers to the process of automatically re-executing the field-level and workpiece-level calibration when the drift judgment value is greater than zero; the drift log refers to the data file that records the changes in external parameters before and after recalibration. The above terms all originate from the field maintenance of the calibration results and are removed from steps S7.1 to S7.5.
[0029] The machine tool body, spindle, rotary table, camera, and CNC system constitute the aforementioned machine tool. The CNC system refers to the control device that executes the methods of the embodiments of this application; its origin is the configuration of the machine tool, and its destination is the latching of feedback coordinates and the writing of calibration results. A computer-readable storage medium refers to a medium that stores computer programs or instructions, which, when executed by a processor, implement the aforementioned methods; a processor refers to a device that executes programs or instructions. The meanings of the above terms, as commonly understood in the art, originate from the configuration of the machine tool and computer system, and their destination is the aforementioned machine tool, storage medium, and program product.
[0030] like Figure 1 and Figure 2As shown, the camera calibration method based on machine tool motion and workpiece self-features according to the embodiments of this application may include steps S110 to S180.
[0031] In step S110, the intrinsic prior of the camera and the kinematic model of the machine tool are loaded. The kinematic model gives the pose of the spindle flange in the machine tool coordinate system.
[0032] In some embodiments, the intrinsic prior is loaded in the form of pixel focal length, principal point coordinates and distortion coefficients, along with initial uncertainties for each item. These uncertainties are used in the third stage to determine the weight of each observation and constrain the correction amount of the intrinsic parameters, so that the intrinsic parameters revert to the prior values instead of diverging when there are insufficient observations.
[0033] In some embodiments, the kinematic model is loaded in the form of a structural constant table, which provides the direction vector of each feed axis, the offset and included angle between adjacent axes, and the installation pose of the spindle flange relative to the final stage rotary axis. After loading, the pose of the spindle flange in the machine coordinate system can be solved by any set of feedback coordinates.
[0034] In some embodiments, intrinsic priors and kinematic models are loaded together by version number and timestamp. After loading, the applicable models and temperature ranges of the two are checked. If they are not applicable, a prompt is given and subsequent steps are terminated.
[0035] In some embodiments, the loaded intrinsic priors are stored in the form of a third-order intrinsic matrix, with the pixel focal length and principal point coordinates of the matrix placed in diagonal elements, and the distortion coefficients stored in radial and tangential groups; the inverse of the intrinsic matrix is pre-calculated and cached according to pose number during loading.
[0036] In step S120, the main spindle is moved along at least one of the X-axis, Y-axis and Z-axis directions according to a preset pose sequence, and / or at least one of the B-axis and C-axis is rotated. Under each preset pose in the preset pose sequence, the camera acquires a reference object image of a fixed reference object located on the C-axis worktable. The size and pose of the fixed reference object are unknown.
[0037] In some embodiments, the preset pose sequences are grouped and arranged according to the motion type: the pure rotation group keeps the main axis in place and rotates only along the B-axis and / or C-axis to multiple angles, with an interval of not less than 15 degrees between each angle; the pure translation group locks the B-axis and C-axis and moves only along the X-axis, Y-axis, or Z-axis, with a baseline of not less than 10 millimeters between each pose; the mixed group combines both types of motion. The three groups of poses are acquired in the order of pure rotation, then pure translation, and finally mixed motion.
[0038] In some embodiments, the acquisition process under each preset pose is as follows: wait for each axis to be in position and stabilize, determine stabilization based on the position error and vibration amplitude, trigger the camera to expose at 130° and simultaneously freeze the feedback coordinates and image timestamps of each axis; bind each frame of reference object image to the feedback coordinates at the same time.
[0039] In some embodiments, the fact that the size and pose of the fixed reference object are unknown means that the geometric parameters of the reference object are not included in any calculation, and the clamping position and orientation of the reference object on the worktable are not used as known inputs. Its three-dimensional coordinates, intrinsic parameters, and extrinsic parameters are used as joint unknowns. Therefore, the reference object can be the casting texture of the workpiece blank or a general-purpose part clamped on the worktable.
[0040] In some embodiments, the preset pose sequence is verified by field of view coverage before acquisition: the approximate position of the fixed reference object is projected onto the image plane of each preset pose by the initial estimation of the kinematic model and hand-eye extrinsic parameters, and poses in which the reference object falls on the edge of the field of view or is occluded by the main axis or turntable are eliminated, so that the projection distribution of the poses involved in the solution on the image plane covers the four quadrants of the field of view.
[0041] In step S130, the camera pose in the machine tool coordinate system is determined according to the feedback coordinates and kinematic model of each axis of the machine tool.
[0042] In some embodiments, the feedback coordinates of the X-axis, Y-axis, Z-axis, B-axis and C-axis are read for each preset pose, and the pose of the main spindle flange in the preset pose is obtained by the forward kinematics model. Then, the flange pose is multiplied by the hand-eye extrinsic parameters of the camera relative to the main spindle flange to obtain the pose of the camera in the preset pose. The hand-eye extrinsic parameters take the initial estimate value when the first execution is performed, and take the optimization result after joint optimization.
[0043] In some embodiments, the first The camera's pose in the machine tool coordinate system under a preset pose is obtained by multiplying the pose of the spindle flange in that pose by the hand-eye extrinsic parameter using a homogeneous transformation, i.e.:
[0044] (1)
[0045] In equation (1), For the first The camera's pose in the machine tool coordinate system under a preset pose is a fourth-order homogeneous transformation matrix, whose rotation part is a third-order orthogonal right-hand matrix and whose translation part is in millimeters. The position of the spindle flange in the machine tool coordinate system under the same preset pose is determined by the feedback coordinates. Obtained using the forward kinematics model; , is the eye-hand extrinsic parameter of the camera coordinate system relative to the main axis flange, and is the only unknown in equation (1), which is obtained by step S140; The X, Y, Z, B, and C axes are the feedback coordinates under the preset pose. Equation (1) shows that the camera pose is not estimated from the image, but is analytically given by the kinematic relationship of the machine tool itself, and its accuracy depends on the encoder reading and structural constants; the obtained The destination is the reprojection calculation of equation (3).
[0046] In some embodiments, the reading of feedback coordinates and the acquisition of the image are frozen at the same time, and the time delay between the two does not exceed half of the image exposure time; for a high-speed rotating C-axis, the C-axis is brought to a stop before exposure during acquisition.
[0047] In some embodiments, the camera poses under each preset pose are synthesized one pose at a time according to formula (1), and written into the pose index table according to the pose number; before synthesis, poses with positioning errors exceeding the set value or missing feedback coordinates are removed, so that the pose index table, reference image and feedback coordinates correspond one-to-one.
[0048] In step S140, using the camera's pose in the machine tool coordinate system under each preset pose as the known excitation and the reference image under that preset pose as the observation, the camera's intrinsic parameters, the camera's hand-eye extrinsic parameters relative to the spindle flange, and the three-dimensional coordinates of the fixed reference object in the machine tool coordinate system are taken as joint unknowns. The intrinsic parameters and hand-eye extrinsic parameters are obtained by solving in three stages according to rotation-translation decoupling. Specifically, in the first stage, the reference image under the pose where the spindle does not move and at least one of the B-axis and C-axis rotates is used to refine the camera's intrinsic parameter prior, obtaining the refined intrinsic parameters. In the second stage, the reference image under the pose where the B-axis and C-axis do not rotate and the spindle moves along at least one of the X-axis, Y-axis, and Z-axis directions is used. The initial values of hand-eye extrinsic parameters are coarsely obtained from the reference object image under the given pose and the camera pose under the given pose in the machine tool coordinate system. In the third stage, the weighted sum of squares of the reprojection residuals of all reference object images under the given pose in the given pose sequence is used as the objective. The intrinsic parameters, initial values of hand-eye extrinsic parameters, and three-dimensional coordinates are jointly optimized and refined to obtain the camera's intrinsic parameters, hand-eye extrinsic parameters, and three-dimensional coordinates. The reprojection residual under each given pose is the deviation between the three-dimensional coordinates of the fixed reference object under the given pose, after being projected onto the reference object image under the given pose by the refined intrinsic parameters and the camera pose under the given pose in the machine tool coordinate system, and the image point of the fixed reference object in the reference object image.
[0049] In some embodiments, the homography matrix of the first stage is solved by direct linear transformation based on the corresponding imaging points of the fixed reference object in two frames, and mismatches are eliminated by random sampling consensus algorithm; the inverse solution of the intrinsic parameter correction is constrained by the image of the absolute quadratic curve, which only uses the rotation matrix and homography matrix between frame pairs, and does not require the three-dimensional coordinates of the fixed reference object, nor the translation between the camera and the reference object.
[0050] In some embodiments, the two frames of a pure rotation frame pair satisfy a homography relation, and the homography matrix is formed by the conjugate of the intrinsic parameter matrix and the inter-frame rotation matrix, i.e.:
[0051] (2)
[0052] In equation (2), For the first The homography matrix of a pure rotation frame pair is obtained by direct linear transformation of the corresponding imaging points of the fixed reference object in the two frames of reference object images, and is a third-order matrix. Let be the intrinsic parameter matrix of the camera, and its upper triangular elements are the pixel focal length and principal point coordinates, which are the quantities to be corrected in equation (2). The rotation matrix of the camera between the two frames is derived from the current estimates of the flange pose and hand-eye extrinsic parameters of the two frames according to Equation (1); This is the inverse of the intrinsic parameter matrix. Equation (2) holds true when the camera rotates purely around its own optical center between two frames, or when the working distance of the fixed reference object is much greater than the radius of rotation, in which case the translation between the two frames can be ignored; if the condition is not met, it is calculated according to equation (2a). The place where equation (2) is located is to put and Combine the equations to determine the correction factor for the inverse internal reference.
[0053] In some embodiments, when there is also translation caused by the radius of rotation between two frames, the homography matrix induced by the plane where the fixed reference object is located takes the general form, that is:
[0054] (2a)
[0055] In equation (2a), The translation vector of the camera between the two frames is derived from the difference in flange pose between the two frames and the hand-eye extrinsic parameters, in millimeters. The unit normal of the plane containing the fixed reference object in the camera coordinate system of the first frame has a length of 1 and is a dimensionless quantity; This is the distance from the plane to the optical center of the first frame camera, in millimeters; , and The meaning is the same as in equation (2). When The magnitude is much smaller than When the translation term approaches zero, equation (2a) degenerates into equation (2). In this embodiment, equation (2a) is used as the complete constraint of the first stage, and equation (2) is used as the simplified form under pure rotation conditions and the criterion for frame pair screening.
[0056] In some embodiments, the frame pairs in the second stage are taken from a pure translation group, and the relative motion between the camera and the fixed reference is pure translation. After fixing the fine-tuning intrinsic parameters, the rotation matrix and translation direction of the relative motion are decomposed from the epipolar constraints established by the same imaging points, and then combined with the difference in the spindle flange pose of the two frames to obtain the initial values of the hand-eye extrinsic parameters. The scale of translation between the two frames is given by the coordinate reading of the machine tool, and frame pairs with a baseline of less than five millimeters are not included in the initial value solution.
[0057] In some embodiments, the third stage uses the intrinsic parameters to be optimized, the hand-eye extrinsic parameters, and the three-dimensional coordinates of the fixed reference object as variables, and iterates according to the Levenberg-Marquardt method. The weights are taken as the reciprocals of the variances of each observation noise, and the corrections to the intrinsic parameters and the hand-eye extrinsic parameters are set with regularization terms based on the uncertainties of the first two stages. During the iteration, a robust kernel is applied to the reprojection residuals, and the scale of the kernel is estimated according to the median of the residuals, so that individual mis-extracted imaging points do not deviate from the overall solution.
[0058] In some embodiments, the third stage treats the intrinsic parameters, hand-eye extrinsic parameters, and the three-dimensional coordinates of the fixed reference object as unknowns, and uses the sum of squared reprojection residuals of the reference features under all preset poses as the objective function, i.e.:
[0059] (3)
[0060] In equation (3), For reference features In the Measured pixel coordinates in the frame reference image, in pixels; This is a projection function, whose inputs are, in order, intrinsic parameters. Distortion coefficient Camera pose With three-dimensional points The output is the projected pixel coordinates; For reference features Three-dimensional coordinates in the machine tool coordinate system, in millimeters, and... , Both are optimization variables in equation (3); The lens distortion coefficient is given by the intrinsic prior; Let f be the Euclidean norm of the difference between pixel coordinates, and its square is the reprojection residual. This indicates the range of all preset poses. With all reference features Summation; Indicates to , and Find the minimum. The destination of equation (3) is the iterative solution in the third stage and the residual audit of equation (7).
[0061] In some embodiments, when the number of frame pairs in the pure rotation group is insufficient, or the rotation angle between two frames is less than ten degrees, the correction amount of the intrinsic parameters is not considerable. In this case, the first stage is skipped and the second and third stages are directly entered with the intrinsic parameter prior values. When the baseline of the pure translation group is less than five millimeters, the translation component of the hand-eye extrinsic parameters is not considerable. In this case, the excitation is supplemented by the hybrid group pose.
[0062] In some embodiments, the three stages are connected in series according to the data flow: the input of the first stage is the first set of reference object images and intrinsic priors, and the output is the refined intrinsic parameters; the input of the second stage is the second set of reference object images, the refined intrinsic parameters, and the camera pose of each frame, and the output is the initial values of the hand-eye extrinsic parameters; the input of the third stage is all reference object images, the refined intrinsic parameters, the initial values of the hand-eye extrinsic parameters, and the initial values of the three-dimensional coordinates of the reference features derived from the above poses, and the output is the intrinsic parameters, the hand-eye extrinsic parameters, and the three-dimensional coordinates. The input and output of the three stages correspond one-to-one with equations (2), (2a), and (3).
[0063] In step S150, after the workpiece is loaded, the camera acquires the workpiece image in the acquisition pose, identifies the circular hole of the workpiece itself in the workpiece image, and determines the imaging point of the center of the circular hole in the workpiece image according to the vanishing pole method. Here, the acquisition pose is the pose of the camera in the machine tool coordinate system when acquiring the workpiece image.
[0064] In some embodiments, after the workpiece is loaded, it is clamped on the C-axis worktable according to the positioning surface. The camera 130 moves with the spindle 110 to the acquisition position. The acquisition position can be any spindle position within the field of view where the circular hole is located. The circular hole is taken from the existing process hole, center hole or pin hole on the workpiece, and no additional hole needs to be machined for calibration.
[0065] In some embodiments, the process of identifying a circular hole is as follows: the region of interest is defined according to the approximate location of the circular hole, sub-pixel edge extraction is performed on the hole contour within the region and edge points that do not belong to the circular hole are removed, and then ellipse fitting is performed on the remaining edge points to obtain the quadratic curve matrix of the projected ellipse of the hole contour.
[0066] In some embodiments, the vanishing line is obtained by projecting the plane containing the hole into the workpiece image: the equation of the plane containing the hole is determined by the pose of the camera 130 in the acquisition pose and the normal of the hole plane, and the plane is projected onto the image to obtain the homogeneous coordinates of the vanishing line; the imaging point of the circle center is calculated according to the pole of the projection ellipse about the vanishing line, and the pole coordinates are normalized to obtain the pixel coordinates.
[0067] In some embodiments, there are two feasible paths for calculating the vanishing line: one is to project the plane as a straight line on the image according to the normal of the orifice plane and the acquisition pose; the other is to take two pairs of approximately parallel line segments on the edge of the orifice, and the images of the two parallel lines intersect at a vanishing point on the image. The line connecting the two vanishing points is the vanishing line. When the orifice plane can be determined by contact measurement, the former is preferred; otherwise, the latter is used. When the difference between the vanishing lines of the two paths is less than a set value, the average of the two is taken.
[0068] In some embodiments, the imaging point of the center of the circular hole in the image is the pole of the projection ellipse about the vanishing line of the hole plane, and the pole and the epipolar line are dual to each other, that is:
[0069] (4)
[0070] In equation (4), The quadratic curve matrix of the projected ellipse of the orifice contour is a third-order symmetric matrix constructed from the coefficients of the sub-pixel ellipse fitting. The vanishing line of the plane containing the orifice in the workpiece image is represented by a third-order homogeneous vector, which originates from the normal of the orifice plane through the acquired pose and intrinsic parameter projection. Let be the imaging point of the center of the circular hole in the workpiece image, represented by a third-order homogeneous vector, which is the quantity obtained by equation (4); The inverse of the quadratic curve matrix; symbol This indicates that the two ends differ by a non-zero scaling factor, meaning the projections are equal. The geometric meaning of equation (4) is that the pole of the line connecting the two tangents to the projection ellipse drawn through the vanishing line is the image of the center of the circle. Therefore, the image of the center of the circle is not the center of the projection ellipse. When the vanishing line is located at infinity, the pole degenerates into the center of the ellipse. The destination of equation (4) is the image point of equation (6).
[0071] In step S160, the probe of the machine tool contacts multiple points on the edge of the circular hole, and the machine tool coordinates at each contact time are recorded. The coordinates of the center of the circular hole in the machine tool coordinate system are determined based on the machine tool coordinates at each contact time.
[0072] In some embodiments, the position of the probe tip relative to the spindle flange, i.e. the probe tip calibration position, is determined by the factory parameters and clamping status of the probe 150, and is re-measured by a tool setter or the contact measurement function of the machine tool itself before calibration; the probe tip is a ruby ball, the radius of which is known, and the contact determination is based on the trigger signal of the probe 150.
[0073] In some embodiments, the probe 150 sequentially contacts multiple contact points on the edge of the hole, the number of contact points being an integer greater than or equal to three, and in some feasible ways being six to eight and evenly distributed on the edge of the hole; the contact direction of each contact point is along the normal of the edge of the hole, and the feedback coordinates of each axis at the moment of contact are frozen and recorded.
[0074] In some embodiments, the process of determining the center coordinates of the hole is as follows: the coordinates of each needle tip center in the machine tool coordinate system are obtained according to the feedback coordinates and kinematic model at each contact time; the coordinates of all needle tip centers are fitted to the orifice plane and projected; a circle is fitted to the projection point on the orifice plane; the center of the fitted circle is the coordinate of the center of the hole in the machine tool coordinate system; and the difference between the radius of the fitted circle and the radius of the probe 150 is the hole diameter.
[0075] In some embodiments, the coordinates of the needle tip center in the machine tool coordinate system are obtained by multiplying the spindle flange pose at the moment of contact with the needle tip calibration position, that is:
[0076] (5)
[0077] In equation (5), For the first The coordinates of the probe tip center at each contact point in the machine tool coordinate system are a four-dimensional homogeneous vector, with the first three components in millimeters. For the first Feedback coordinates of each axis of the machine tool at each contact moment; The position of the spindle flange in the machine tool coordinate system at the moment of contact is obtained from the feedback coordinates according to the forward kinematics model. The calibrated position of the probe tip relative to the spindle flange is determined by factory parameters and clamping conditions and is re-measured before contact. Equation (5) shows that the spatial position of the contact point is entirely given by the machine tool readings and is independent of the image; The destination is the three-dimensional point of the orifice circle fitting in step S160 and equation (6).
[0078] In some embodiments, the rules for arranging and removing abnormal contact points are as follows: contact points are evenly distributed on the edge of the hole and cover at least three quadrants; the same contact point is repeatedly contacted twice and the median of the coordinates is taken; when the difference between the two readings exceeds a set value, the point is determined to be invalid and retested; when the number of valid contact points is less than three, the hole center solution is terminated.
[0079] In step S170, the imaging point of the center of the circular hole in the workpiece image is paired with the coordinates of the center of the circular hole in the machine tool coordinate system to form the correspondence between the imaging point of the center of the circular hole and the three-dimensional coordinates of the center of the hole. According to the intrinsic parameters of the camera, the extrinsic parameters of the camera in the machine tool coordinate system under the acquisition pose are solved.
[0080] In some embodiments, the imaging point of the center of the circle is taken as the image point, and the coordinates of the center of the hole in the machine tool coordinate system are taken as the three-dimensional point. The two form a two-dimensional and three-dimensional correspondence. One circular hole provides two equations. The external parameters under the acquired pose contain six unknowns. Therefore, at least three circular holes are required. When there are more than three circular holes, the solution is obtained by least squares.
[0081] In some embodiments, the objective function is the weighted sum of squares of the deviations between each 3D point and the corresponding image point after projection by intrinsic and extrinsic parameters, with the weights being the reciprocal of the image point extraction accuracy. The rotation matrix in the extrinsic parameters remains orthogonal and has a positive determinant during the solution process. The initial value is the product of the spindle flange pose and the hand-eye extrinsic parameters. The solution is iterated using the Levenberg-Marquardt method.
[0082] In some embodiments, the objective function for acquiring pose extrinsic parameters is the weighted sum of squares of the deviations between each 3D point projected through intrinsic parameters and the corresponding image point, i.e.:
[0083] (6)
[0084] In equation (6), To collect the extrinsic parameters of the camera in the machine tool coordinate system under pose, it is a fourth-order homogeneous transformation matrix, that is, the unknown quantity in equation (6); For the first The pixel coordinates of the imaging point at the center of each circular hole are obtained by solving equation (4); The coordinates of the center of the hole in the machine tool coordinate system are given in millimeters and are obtained by formula (5). The confidence weight for this observation is a dimensionless positive number, which is adjusted according to the extraction accuracy of the center imaging point and the aperture size. and The intrinsic distortion coefficients of the camera are taken from the result of step S140. The projection function is the same as that in equation (3); Indicates to Find the minimum. The destination of equation (6) is the calibration result of step S180 and the residual audit of equation (7).
[0085] In some embodiments, when there are fewer than three identifiable circular holes on the workpiece, the spindle 110 is moved to another acquisition pose to acquire the workpiece image again while keeping the workpiece stationary. The image points under multiple acquisition poses are paired with the same set of three-dimensional points, and the acquisition pose extrinsic parameters are solved jointly according to the multi-view pose.
[0086] In some embodiments, before solving, the pairings are initially screened according to the reprojection residuals: the product of the spindle flange pose and the hand-eye extrinsic parameter is used as the initial value of the extrinsic parameter, the initial reprojection residuals of each pairing are calculated, and the pairings with residuals exceeding the set value are eliminated. Then, robust iteration is performed according to formula (6). After the iteration converges, outlier pairings are eliminated again according to the median scale of the residuals and the solution is solved again.
[0087] In step S180, the camera's intrinsic parameters, hand-eye extrinsic parameters, and camera extrinsic parameters in the machine tool coordinate system under the acquisition pose are used as the camera's calibration results.
[0088] In some embodiments, the calibration results are output in the form of a parameter table: the intrinsic parameters include pixel focal length, principal point coordinates and distortion coefficients; the extrinsic parameters include the rotation matrix and translation vector of the camera coordinate system relative to the spindle flange; the extrinsic parameters of the acquisition pose include the rotation matrix and translation vector of the camera in the acquisition pose; the parameter table includes the covariance of each parameter, the workpiece clamping status and the calibration timestamp.
[0089] In some embodiments, part or all of the calibration results are written into the CNC system: hand-eye extrinsic parameters and intrinsic parameters are written into the parameter area shared by the computing device and the CNC system, and the acquired pose extrinsic parameters are written into the measurement parameter area corresponding to the current workpiece; after writing, the data is read back for comparison, and if the readback values are inconsistent, a prompt is given and the previous version is retained.
[0090] In some embodiments, if the accuracy index of the calibration result does not meet the set conditions, it is not written into the CNC system. Instead, the items with excessive residuals and the corresponding preset poses are output for the operator to check the camera clamping status, the probe tip calibration position, or the visibility of the fixed reference object.
[0091] In some embodiments, the root mean square residual of the reprojection of the calibration results is obtained by taking the square root of the average of the sum of squares of the residuals of all observations, i.e.:
[0092] (7)
[0093] In equation (7), The root mean square residual of the reprojection of the calibration results, in pixels, is the accuracy index. The total number of observations involved in the audit is the sum of the number of reference feature observations and the number of workpiece-level circular hole observations. and For the first The meanings of the observed image points and three-dimensional points are the same as those in equation (6); Taking in reference object observation In workpiece-level observation, the extrinsic parameters of the pose are acquired. It represents the square root. Equation (7) is in pixels, and its destination is the precision index of step S180, the input of equation (9) and equation (10).
[0094] In some embodiments, the three-dimensional coordinates of the image point in the machine tool coordinate system are obtained by intersecting the camera system ray determined by the image point with the upper surface of the workpiece, that is:
[0095] , (8)
[0096] In equation (8), It is a homogeneous vector of pixel coordinates of image points, with the third component being 1; This represents the ray direction of the image point in the camera coordinate system. The unit normal of the workpiece's upper surface in the camera coordinate system has a length of 1 and is obtained by transforming the aperture plane measured in step S160 through the acquired pose extrinsic parameters. This is the directed distance from the camera's optical center to the plane, in millimeters; This is a ray parameter, which is the distance from the intersection point along the ray to the optical center, in millimeters; To collect pose extrinsic parameters; Let be the three-dimensional coordinates of the image point in the machine tool coordinate system, in millimeters. Equation (8) first calculates the intersection point of the ray and the upper surface of the workpiece, then... Transforming to the machine tool coordinate system avoids the inconsistency caused by directly substituting the height in the machine tool coordinate system into the back projection of the camera system; Equation (8) is used for the accuracy verification of the calibration results and the online application of the calibration results.
[0097] In some embodiments, the accuracy of the calibration results is verified according to formulas (7) and (8). When the difference between the converted three-dimensional coordinates and the contact measurement results exceeds the set value, the calibration results are marked as pending verification and prompted for recalibration.
[0098] According to the camera calibration method based on machine tool motion and workpiece self-features in this application, the feedback coordinates and kinematic model of each axis of the machine tool are used as known excitations, and the image of a fixed reference object with unknown size and pose is used as the observation. The intrinsic parameters of the camera, the extrinsic parameters of hand and eye, and the three-dimensional coordinates of the reference object are all treated as joint unknowns. The solution is performed in three stages with rotation and translation decoupling: the intrinsic parameters are refined under pure rotation frame pairs, the extrinsic parameters of hand and eye are coarsely solved under pure translation frame pairs, and the two are jointly optimized under the weighted projection target of all poses. This avoids the problem of mutual compensation of intrinsic and extrinsic parameter errors in the step-by-step solution, and also avoids direct The dependence on initial values when performing nonlinear optimization on all unknowns; after the workpiece is loaded, the circular hole of the workpiece itself is used as the target, and the vanishing pole method separates the imaging point of the center of the circle from the center of the projected ellipse. The probe contacts and fixes the center of the hole to the machine tool coordinate system. The two-dimensional and three-dimensional correspondence between the two makes the solution of the acquired pose extrinsic parameters independent of additional calibration plates and manual point selection; field-level calibration and workpiece-level calibration are completed in the same clamping. The calibration process does not require special measuring instruments. The size and pose of the reference object are not included in the prior. The re-inspection reprojection residual and the re-measurement contact deviation make the drift of the calibration result detectable and trigger automatic recalibration.
[0099] According to some embodiments of this application, the steps of determining the camera's pose in the machine tool coordinate system under each preset pose sequence based on the feedback coordinates and kinematic model of each axis of the machine tool include steps S2.1 to S2.4.
[0100] In step S2.1, for each preset pose in the preset pose sequence, the feedback coordinates of each axis of the machine tool are obtained, including the feedback coordinates of the X-axis, Y-axis, Z-axis, B-axis and C-axis.
[0101] In some embodiments, the acquisition of feedback coordinates is frozen at the same time as image acquisition: when the camera 130 exposes, it outputs a trigger signal. After receiving the trigger signal, the CNC system latches the coordinate readings of the X-axis, Y-axis, Z-axis, B-axis and C-axis. The latched values are bound to the image frame number, so that each frame of the reference image corresponds to a unique set of feedback coordinates.
[0102] In step S2.2, according to the kinematic model and the feedback coordinates of each axis of the machine tool, the position of the spindle flange in the machine tool coordinate system under the preset position is determined.
[0103] In some embodiments, the kinematic model is multiplied step by step in a series chain: the translation component of the main shaft is obtained from the feedback coordinates of the X-axis, Y-axis, and Z-axis and the guide direction of each linear axis; the attitude and position of the main shaft flange are obtained from the feedback coordinates of the B-axis and C-axis and the direction and position of the two rotary axes; and the installation posture of the main shaft flange relative to the final rotary axis is then incorporated.
[0104] In step S2.3, the initial estimate of the hand-eye extrinsic parameters of the camera relative to the spindle flange is obtained.
[0105] In some embodiments, the initial estimate of the hand-eye extrinsic parameters is taken as the designed mounting pose of the camera 130 on the main axis 110, and its uncertainty is given according to the installation tolerance. When the camera 130 is re-clamped or replaced, a coarse registration is first performed on the frame pairs of the pure translation group, and the coarse registration result is used as the initial estimate.
[0106] In step S2.4, the pose of the spindle flange in the machine coordinate system under the preset pose is multiplied by the initial estimated value of the hand-eye extrinsic parameters to obtain the pose of the camera in the machine coordinate system under the preset pose.
[0107] In some embodiments, the flange pose and the hand-eye extrinsic parameters are both represented by homogeneous transformation matrices. The product of the two is the camera pose in the machine tool coordinate system. The multiplication order is first the hand-eye extrinsic parameters, then the flange pose. After multiplication, an index is established according to the pose number so that the reference image, feedback coordinates, flange pose and camera pose correspond one-to-one.
[0108] According to some embodiments of this application, the camera pose in the machine tool coordinate system under each preset pose is taken as the known excitation, and the reference image under the preset pose is taken as the observation. The camera's intrinsic parameters, the camera's hand-eye extrinsic parameters relative to the spindle flange, and the three-dimensional coordinates of the fixed reference object in the machine tool coordinate system are taken as joint unknowns. The intrinsic parameters and hand-eye extrinsic parameters are obtained by solving in three stages according to rotation and translation decoupling. The steps include steps S3.1 to S3.3.
[0109] In step S3.1, the first stage, a reference object image is acquired in a preset pose sequence where the principal axis does not move and at least one of the B-axis and C-axis rotates, as the first set of reference object images; based on the imaging points of the fixed reference objects in the first set of reference object images, the homography matrix between frame pairs in the first set of reference object images is calculated; based on the homography matrix between frame pairs and the rotation matrix between the frame pairs, the intrinsic parameter correction amount of the camera is solved inversely; the intrinsic parameter correction amount is superimposed on the intrinsic parameter prior to obtain the refined intrinsic parameters.
[0110] In some embodiments, any two frames in the first set of reference images constitute a frame pair, and the principal axis between the preset poses corresponding to the two frames does not move. The relative motion between the camera and the fixed reference is a pure rotation. Under pure rotation, the homography matrix only contains the rotation matrix and intrinsic parameters, and does not contain translation. Therefore, the combination of the homography matrix and the inter-frame rotation matrix only constrains the intrinsic parameters, and the intrinsic and extrinsic parameters are thus decoupled.
[0111] In some embodiments, the rotation matrix between frame pairs is derived from the current estimate of the flange pose of the two frames and the hand-eye extrinsic parameters, and the intrinsic parameter correction is solved by weighted least squares according to equation (2a); frame pairs whose ratio of translation to working distance exceeds a set value do not participate in the inverse solution, and this criterion is the applicable boundary of equations (2) and (2a).
[0112] In step S3.2, the second stage, a reference object image is obtained in the preset pose sequence where the B-axis and C-axis do not rotate and the main axis moves along at least one of the X-axis, Y-axis and Z-axis directions, which is used as the second set of reference object images; the fine-tuning intrinsic parameters are fixed, and the initial values of the hand-eye extrinsic parameters are solved using epipolar constraints based on the imaging point of the fixed reference object in the second set of reference object images and the pose of the camera in the machine tool coordinate system under that pose.
[0113] In some embodiments, the B-axis and C-axis do not rotate, so that the relative motion between the camera and the fixed reference is a pure translation, and the epipolar geometry degenerates into a constraint on the translation direction. After fixing the fine-tuning intrinsic parameters, the relative rotation and translation direction decomposed from the epipolar constraint are combined with the difference in the flange pose of the two frames to obtain the initial values of the hand-eye extrinsic parameters. Frame pairs with a baseline of less than five millimeters are not included in the solution.
[0114] In some embodiments, the initial values of the hand-eye extrinsic parameters are solved separately as follows: the relative rotation given by the epipolar constraint should be consistent with the rotation of the difference between the two frame flange poses, thereby solving for the rotation of the camera relative to the spindle flange; the relative translation direction and the translation of the difference between the flange poses are combined to solve for the translation of the camera relative to the spindle flange, thus obtaining the initial values of the hand-eye extrinsic parameters.
[0115] In step S3.3, the third stage, with the weighted sum of squares of the reprojection residuals of all reference object images under the preset pose sequence as the target, and with the initial values of the refined intrinsic parameters and the hand-eye extrinsic parameters as the initial values, the camera's intrinsic parameters, hand-eye extrinsic parameters and three-dimensional coordinates are jointly optimized to obtain the camera's intrinsic parameters, hand-eye extrinsic parameters and three-dimensional coordinates.
[0116] In some embodiments, the reprojection residual is the pixel deviation between the three-dimensional coordinates of the fixed reference object projected onto the image by the camera pose with the intrinsic parameters and the measured imaging point, and the weighted sum of squares is weighted by the inverse of the variance of each observation noise. The joint optimization starts with the initial values of the refined intrinsic parameters and hand-eye extrinsic parameters, iterates according to the Levenberg-Marquardt method, and sets regularization terms according to the uncertainty of the first two stages.
[0117] In some embodiments, the solution of equation (3) adopts an alternating strategy: first, fix the three-dimensional coordinates to solve the intrinsic parameters and the hand-eye extrinsic parameters, then fix the intrinsic parameters and the hand-eye extrinsic parameters to solve the three-dimensional coordinates. After alternating for two rounds, the entire variables are iterated as a whole, so that the target value of equation (3) decreases monotonically. The correction amount of the intrinsic parameters and the hand-eye extrinsic parameters is applied with a regularization term according to the prior uncertainty of the intrinsic parameters to avoid divergence when the excitation is insufficient.
[0118] According to some embodiments of this application, after the workpiece is loaded, the camera acquires the workpiece image in the acquisition pose, identifies the circular hole of the workpiece itself in the workpiece image, and determines the imaging point of the center of the circular hole in the workpiece image according to the extinction pole method, including steps S4.1 to S4.5.
[0119] In step S4.1, after the workpiece is loaded, the camera acquires the workpiece image in the acquisition pose.
[0120] In some embodiments, the workpiece is clamped on the C-axis worktable according to the positioning surface, and the spindle 110 carries the camera 130 to move to the acquisition pose so that the circular hole is located in the middle region of the field of view; after each axis stops, exposure is triggered, and the feedback coordinates of the pose are bound to the image frame number. The accurate value of the acquisition pose is solved by subsequent steps.
[0121] In step S4.2, the circular hole of the workpiece itself is identified in the workpiece image, and the outline of the hole is fitted with a subpixel ellipse to obtain the quadratic curve matrix of the projected ellipse of the hole outline.
[0122] In some embodiments, the region of interest is first defined according to the approximate location of the circular hole. Subpixel edge extraction is performed within the region according to the gray-level gradient. Edge segments whose length and curvature do not conform to the hole outline are removed. Then, closed and approximately circular edge groups are selected according to connectivity. The result is written as a quadratic curve matrix with the sum of squared algebraic distance as the objective and discriminant constraints are applied.
[0123] In step S4.3, determine the homogeneous coordinates of the vanishing line of the plane containing the opening of the circular hole.
[0124] In some embodiments, the vanishing line is the projection line of the plane where the orifice is located in the image: the equation of the orifice plane is transformed to the camera coordinate system according to the acquisition pose, and then projected into a straight line on the image according to the intrinsic parameters, and its homogeneous coordinates are the vanishing line.
[0125] In some embodiments, the orifice plane is obtained by fitting all contact points in step S160. The normal of the orifice plane and the coordinates of the orifice center are transformed to the camera coordinate system by the acquired pose extrinsic parameters and then projected as the vanishing line. When the orifice plane parameters are unavailable, the vanishing point is obtained by the images of two pairs of approximately parallel orifice edge lines, and the line connecting the two vanishing points is the vanishing line.
[0126] In step S4.4, the homogeneous coordinates of the imaging point of the center of the circular hole in the workpiece image are calculated based on the quadratic curve matrix and the homogeneous coordinates of the vanishing line, taking the imaging point of the center of the circular hole in the workpiece image as the pole of the projection ellipse about the vanishing line.
[0127] In some embodiments, the pole of a quadratic curve about a straight line is equal to the product of the quadratic curve matrix and the homogeneous coordinates of the straight line.
[0128] In some embodiments, the quadratic curve matrix in equation (4) is constructed according to the coefficients of the fitted ellipse, and the homogeneous coordinates of the vanishing line are obtained by the projection of the orifice plane. After substituting the two into equation (4), the quadratic curve matrix is inverted. When the condition number of the quadratic curve matrix exceeds the set value, the pseudo-inverse is used, and the pole is marked in the calibration result as being given by the pseudo-inverse.
[0129] In step S4.5, the homogeneous coordinates of the imaging point of the center of the circular hole in the workpiece image are normalized to obtain the pixel coordinates of the imaging point of the center of the circular hole in the workpiece image.
[0130] In some embodiments, normalization refers to dividing the homogeneous coordinates by the third component to make the third component a unit value. The normalized horizontal and vertical components are the pixel coordinates of the center imaging point. When the third component is close to zero, it is determined that the pole is located at infinity, and the center of the projection ellipse is used instead, and a prompt is given.
[0131] According to some embodiments of this application, the steps of having a machine tool probe contact multiple points on the edge of a circular hole, recording the machine tool coordinates at each contact time, and determining the coordinates of the center of the circular hole in the machine tool coordinate system based on the machine tool coordinates at each contact time include steps S5.1 to S5.5.
[0132] In step S5.1, the probe of the machine tool sequentially contacts multiple contact points on the edge of the circular hole to obtain multiple contact points, and the number of multiple contact points is an integer greater than or equal to 3.
[0133] In some embodiments, after the probe 150 is inserted into the spindle 110, the probe tip calibration position is re-measured, and then the contact points are arranged according to the visibility of the aperture and the aperture edge: six to eight contact points are taken and evenly distributed on the aperture edge, the contact direction is along the normal of the aperture edge, and the contact force and contact speed are set according to the specifications of the probe 150.
[0134] In step S5.2, record the calibrated position of the probe tip relative to the spindle flange at each contact point and the feedback coordinates of each axis of the machine tool at each contact moment.
[0135] In some embodiments, the needle tip calibration position is determined by the factory parameters and clamping status of the probe 150. Before calibration, the position is re-measured using a tool setter or the contact measurement function of the machine tool 100 and saved along with the probe number. The feedback coordinates at the moment of contact are frozen when the trigger signal arrives, and the frozen value is bound to the contact point number.
[0136] In step S5.3, the position of the spindle flange in the machine tool coordinate system at each contact moment is determined based on the feedback coordinates and kinematic model of each axis of the machine tool at each contact moment.
[0137] In some embodiments, the method for determining the spindle flange pose is the same as in step S2.2: the rotation matrix and translation vector of the flange are obtained by forward kinematics calculation of the X-axis, Y-axis, Z-axis, B-axis and C-axis feedback coordinates frozen at the moment of contact; during the contact period, the B-axis and C-axis are locked, and the spindle only moves slightly along the Z-axis, thereby checking the coplanarity of the contact point.
[0138] In step S5.4, the position of the spindle flange in the machine tool coordinate system at each contact moment is multiplied by the calibrated position of the probe tip relative to the spindle flange to obtain the coordinates of each contact point in the machine tool coordinate system.
[0139] In some embodiments, the needle tip calibration position is represented by the pose of the needle tip ball center relative to the spindle flange, which is multiplied by the flange pose to give the coordinates of the ball center in the machine tool coordinate system; the contact point coordinates are taken from the ball center coordinates, and the radius deviation between the ball center and the hole edge is corrected according to the hole diameter during fitting.
[0140] In some embodiments, the needle tip calibration position in equation (5) is represented by homogeneous transformation, which is multiplied by the flange pose at the moment of contact to obtain the coordinates of the needle tip center in the machine tool coordinate system; the center coordinates are then subtracted from the radius of the needle tip along the contact direction to obtain the position of the contact point on the edge of the hole.
[0141] In step S5.5, based on the coordinates of each contact point in the machine tool coordinate system, the orifice circle of the circular hole is fitted to obtain the coordinates of the center of the circular hole in the machine tool coordinate system.
[0142] In some embodiments, before fitting, the orifice plane is fitted to all contact points, the contact points are projected onto the plane and then least squares circle fitting is performed; the center of the fitted circle is the coordinate of the orifice center, the difference between the fitted radius and the radius of the needle tip ball is the orifice diameter, and the radial deviation of each contact point gives the roundness residual.
[0143] According to some embodiments of this application, the imaging point of the center of the circular hole in the workpiece image is paired with the coordinates of the center of the circular hole in the machine tool coordinate system to form a correspondence between the imaging point of the center of the circular hole and the three-dimensional coordinates of the center of the hole. The steps of solving the extrinsic parameters of the camera in the machine tool coordinate system under the acquisition pose according to the intrinsic parameters of the camera include steps S6.1 to S6.4.
[0144] In step S6.1, the imaging point of the center of the circular hole in the workpiece image is taken as the image point, and the coordinates of the center of the circular hole in the machine tool coordinate system are taken as the three-dimensional point.
[0145] In some embodiments, the image points are taken from the normalized pixel coordinates of step S4.5, and the three-dimensional points are taken from the hole center coordinates obtained by fitting in step S5.5; the image points and three-dimensional points of the same circular hole use the same number, and the number is transferred between the workpiece image and the contact measurement.
[0146] In step S6.2, the image points are paired with the three-dimensional points to form a correspondence between the imaging point of the center of the circular hole and the three-dimensional coordinates of the hole center.
[0147] In some embodiments, the pairing results are stored in a list, each item containing the pixel coordinates of the image point, the machine tool coordinates of the 3D point, and the number of the circular hole; one circular hole provides two equations, and the extrinsic parameters under the acquisition pose contain six unknowns, so at least three circular holes are required; if there are not enough circular holes, keep the workpiece stationary and change the acquisition pose to acquire more.
[0148] In step S6.3, the extrinsic parameters of the camera in the machine tool coordinate system under the acquired pose are taken as the quantities to be determined, and the objective function is constructed with the goal of minimizing the deviation between the three-dimensional point and the image point after being projected onto the workpiece image through the intrinsic and extrinsic parameters of the camera.
[0149] In some embodiments, the objective function is the weighted sum of squares of the deviations between each 3D point and the corresponding image point after projection by intrinsic and extrinsic parameters, with the weights being the reciprocal of the image point extraction accuracy; the rotation matrix of the extrinsic parameters is parameterized as a rotation vector or a unit quaternion, and remains orthogonal during iteration.
[0150] In some embodiments, the weights in equation (6) The weight is adjusted based on the aperture of the circular hole and the extraction accuracy of the center imaging point. The larger the aperture and the clearer the edge, the higher the weight. The weight remains unchanged during iteration to avoid coupling between the weight and the residual.
[0151] In step S6.4, under the constraint that the rotation matrix in the extrinsic parameters is an orthogonal matrix and the determinant is positive 1, the objective function is solved to obtain the extrinsic parameters of the camera in the machine tool coordinate system under the acquisition pose.
[0152] In some embodiments, the solution is solved iteratively using the Levenberg-Marquardt method, with the initial value being the product of the spindle flange pose and the hand-eye extrinsic parameters; the orthogonality of the rotation matrix and the constraint that the determinant is positive 1 are automatically satisfied during parameterization, and orthogonalization is performed again after iteration; after solving, misidentified circular holes are removed by reprojection residuals and the solution is resolved.
[0153] In some embodiments, after solving, the root mean square residual of the reprojection of the workpiece-level observation is calculated according to equation (7). When the residual exceeds the set value, the pair with the largest residual is removed one by one and the solution is recalculated. The number of pairs removed does not exceed one-third of the total number of pairs.
[0154] According to some embodiments of this application, the method further includes steps S7.1 to S7.5.
[0155] In step S7.1, according to the preset re-inspection cycle, the camera acquires re-inspection images of the fixed reference object, and the re-inspection reprojection residual is calculated based on the re-inspection images.
[0156] In some embodiments, the re-inspection cycle is set by time or by the number of processed pieces, for example, every 100 pieces processed, every eight hours, or after each tool change; during re-inspection, the camera 130 returns to a preset pose used in the field-level calibration and acquires a re-inspection image of a fixed reference object, the computation of which is less than that of a complete calibration.
[0157] In step S7.2, the retest contact deviation is obtained. The retest contact deviation is the physical deviation between the center coordinates of the hole obtained by the probe of the machine tool retesting the center of the hole and the hole coordinates calculated from the retest image.
[0158] In some embodiments, the re-measurement contact deviation is the difference between the coordinates obtained by the probe 150 re-measurement of the hole center and the coordinates of the same circular hole calculated from the re-inspection image according to the calibration results, in millimeters; it measures the consistency between the machine tool coordinates and the image coordinates, and complements the re-projection residual of the re-inspection, which measures the consistency of the calibration parameters.
[0159] In step S7.3, the larger of the difference between the re-projection residual and the preset residual threshold, and the difference between the re-measurement contact deviation and the preset contact deviation threshold, is determined as the drift judgment value.
[0160] In some embodiments, the residual threshold and the contact deviation threshold are set according to the accuracy class of the machine tool 100 and the tolerance of the workpiece, and are separated from the algorithm code in the form of a configuration file.
[0161] In some embodiments, the drift determination value is taken as the larger of the two deviations after conversion to the same dimension, namely:
[0162] (9)
[0163] In equation (9), This is the time for re-inspection; The reprojection residual calculated from the re-examined image, in pixels; Image equivalent, which is the length of one pixel on the surface of the workpiece, in millimeters per pixel; and These are the re-projection residuals converted to millimeters and their thresholds, respectively. This is the residual threshold, expressed in pixels. For retesting contact deviation, the unit is millimeters; This is the contact deviation threshold, in millimeters. The drift determination value is in millimeters. Equation (9) first converts the two terms to the same dimension and then takes the larger one, avoiding a direct comparison between pixels and millimeters; If the result is greater than zero, the calibration result is determined to be drifted, and its destination is the automatic recalibration trigger condition in step S7.4.
[0164] In step S7.4, if the drift determination value is greater than zero, automatic recalibration is triggered. Automatic recalibration includes re-executing the three-stage solution to complete the field-level recalibration, and re-executing the round hole identification, probe contact and external parameter solution after the workpiece is loaded to complete the workpiece-level recalibration.
[0165] In some embodiments, automatic recalibration does not involve disassembling parts or changing tools: on-site recalibration re-executes steps S120 to S140, and workpiece-level recalibration re-executes steps S150 to S170, with both recalibrations completed in the same clamping; if recalibration fails, the parameters of the previous version are retained and a prompt is output.
[0166] In step S7.5, the changes in extrinsic parameters before and after recalibration are written into the drift log.
[0167] In some embodiments, the drift log records the changes in intrinsic parameters, hand-eye extrinsic parameters, and acquisition pose extrinsic parameters before and after each recalibration in chronological order, and includes the re-inspection reprojection residual, re-measurement contact deviation, and drift judgment value; when the change increases monotonically over time and exceeds the set slope, an early warning is output.
[0168] In some embodiments, the measurement uncertainty of the calibration result is synthesized from three components: machine tool contact measurement, calibration residual, and characteristic repositioning, namely:
[0169] (10)
[0170] In equation (10), The combined measurement uncertainty is expressed in millimeters. The uncertainty of machine tool contact measurement is expressed in millimeters and originates from the positioning accuracy of the machine tool and the repeatability of the probe. The reprojection residual after calibration is, i.e., the residual of equation (7). The unit is pixels; Image equivalent, in millimeters per pixel. The calibration residual is converted to millimeters. The uncertainty of visual feature relocalization is expressed in millimeters. It represents the square root.
[0171] This application also provides a machine tool. The following will be combined with... Figure 2 The machine tool is described in detail.
[0172] Figure 2 A schematic diagram of the structure of a machine tool according to an embodiment of this application is shown.
[0173] like Figure 2 As shown, the machine tool 100 according to an embodiment of this application includes a machine tool body 101, a spindle 110, a rotary table 120, a camera 130, and a numerical control system 140.
[0174] The rotary table 120 includes a B-axis 122 and a C-axis 121. The C-axis is mounted on the B-axis and tilts as the B-axis rotates. The B-axis is positioned around the Y-axis of the machine tool, and the C-axis is positioned around the Z-axis of the machine tool. The spindle 110 is configured to perform linear feed along the X-axis, Y-axis, and Z-axis of the machine tool. The camera 130 is mounted on the spindle 110. A calibration reference is clamped on the C-axis worktable, and a probe is clamped on the spindle 110. The CNC system 140 is configured to execute the steps of the camera calibration method based on machine tool motion excitation and workpiece self-features according to the embodiments of this application.
[0175] The technical effects of the machine tool in this embodiment are similar to those of the camera calibration method based on machine tool motion excitation and workpiece self-features, and will not be described in detail here.
[0176] An electronic device according to embodiments of this application includes a processor that can perform various appropriate actions and processes based on a program stored in a read-only memory or a program loaded from a storage portion into a random access memory. The processor may include, for example, a general-purpose microprocessor, an instruction set processor and / or an associated chipset and / or a dedicated microprocessor. The processor may also include onboard memory for caching purposes. The processor may include a single processing unit or multiple processing units for executing different steps of the method flow according to embodiments of this application.
[0177] Random access memory (RAM) stores various programs and data required for the operation of the electronic device. The processor, read-only memory (ROM), and RAM are interconnected via a bus. The processor executes various steps of the method flow according to embodiments of this application by executing programs stored in the ROM and / or RAM. It should be noted that the programs may also be stored in one or more memories other than ROM and RAM. The processor may also execute various steps of the method flow according to embodiments of this application by executing programs stored in said one or more memories.
[0178] According to embodiments of this application, the electronic device may further include an input / output interface, which is also connected to a bus. The electronic device may also include one or more of the following components connected to the input / output interface: an input section including a keyboard, mouse, etc.; an output section including a cathode ray tube, liquid crystal display, etc., and a speaker, etc.; a storage section including a hard disk, etc.; and a communication section including a network interface card, such as a local area network card, modem, etc. The communication section performs communication processing via a network such as the Internet. A drive is also connected to the input / output interface as needed. Removable media, such as disks, optical disks, magneto-optical disks, semiconductor memories, etc., are installed on the drive as needed so that computer programs read from them can be installed into the storage section as needed.
[0179] Embodiments of this application also provide a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or it may exist independently and not assembled into the device / apparatus / system. The computer-readable storage medium carries one or more programs, which, when executed, implement the method according to the embodiments of this application.
[0180] According to embodiments of this application, the computer-readable storage medium can be a non-volatile computer-readable storage medium, such as including but not limited to: portable computer disks, hard disks, random access memory, read-only memory, erasable programmable read-only memory, portable compact disk read-only memory, optical storage devices, magnetic storage devices, or any suitable combination thereof. In embodiments of this application, the computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. For example, according to embodiments of this application, the computer-readable storage medium may include the read-only memory, and / or random access memory, and / or one or more memories other than read-only memory and random access memory described above.
[0181] Embodiments of this application also include a computer program product comprising a computer program containing program code for performing the methods shown in the flowchart. When the computer program product is run on a computer system, the program code is used to cause the computer system to implement the methods provided in the embodiments of this application.
[0182] In one embodiment, the computer program may rely on tangible storage media such as optical storage devices or magnetic storage devices. In another embodiment, the computer program may also be transmitted and distributed as signals over a network medium, and downloaded and installed via a communication component, and / or installed from a removable medium. The program code contained in the computer program can be transmitted using any suitable network medium, including but not limited to: wireless, wired, etc., or any suitable combination thereof.
[0183] In embodiments of this application, the computer program can be downloaded and installed from a network via a communication component, and / or installed from a removable medium. When the computer program is executed by a processor, it performs the functions defined in the system of this application embodiment. According to embodiments of this application, the systems, devices, apparatuses, modules, units, etc., described above can be implemented by computer program modules.
[0184] According to embodiments of this application, program code for executing the computer programs provided in the embodiments of this application can be written in any combination of one or more programming languages. Specifically, these computational programs can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. The program code can be executed entirely on the user's computing device, partially on the user's device, partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0185] Those skilled in the art will understand that the features described in the various embodiments of this application can be combined and / or combined in various ways, even if such combinations or combinations are not explicitly described in this application. In particular, the features described in the various embodiments of this application can be combined and / or combined in various ways without departing from the spirit and teachings of this application. All such combinations and / or combinations fall within the scope of this application.
Claims
1. A camera calibration method based on machine tool motion excitation and workpiece self-characteristics, characterized in that, The machine tool includes a spindle, a rotary table, and a camera mounted on the spindle. The rotary table includes a B-axis and a C-axis, the C-axis being mounted on the B-axis and tilting as the B-axis rotates. The spindle is configured to perform linear feed along the X-axis, Y-axis, and Z-axis directions of the machine tool. The method includes: The intrinsic prior of the camera and the kinematic model of the machine tool are loaded, and the kinematic model gives the pose of the spindle flange in the machine tool coordinate system; The main axis is moved along at least one of the X-axis, Y-axis and Z-axis directions according to a preset pose sequence, and / or at least one of the B-axis and C-axis is rotated. Under each preset pose in the preset pose sequence, the camera acquires a reference object image of a fixed reference object located on the C-axis worktable. The size and pose of the fixed reference object are unknown. Based on the feedback coordinates of each axis of the machine tool and the kinematic model, the pose of the camera in the machine tool coordinate system is determined under each preset pose in the preset pose sequence; Using the camera's pose in the machine tool coordinate system at various preset poses as known excitations, and the reference object image at the preset pose as the observation, the camera's intrinsic parameters, the camera's extrinsic parameters relative to the spindle flange, and the three-dimensional coordinates of the fixed reference object in the machine tool coordinate system are taken as joint unknowns. A three-stage solution using rotation-translation decoupling is employed to obtain the intrinsic parameters and the extrinsic parameters. Specifically, in the first stage, the reference object image at a pose where the spindle is stationary and at least one of the B-axis and C-axis is rotated is used to refine the camera's intrinsic parameter priors, obtaining the refined intrinsic parameters. In the second stage, the reference object image at a pose where the B-axis and C-axis are stationary and the spindle is along at least one of the X-axis, Y-axis, and Z-axis directions is used. The initial values of hand-eye extrinsic parameters are coarsely obtained from the reference object image under the moving pose and the pose of the camera under the machine tool coordinate system under that pose. In the third stage, the weighted sum of squares of the reprojection residuals of all reference object images under the preset poses in the preset pose sequence is used as the target to jointly optimize the refined intrinsic parameters, the initial values of hand-eye extrinsic parameters, and the three-dimensional coordinates to obtain the intrinsic parameters of the camera, the hand-eye extrinsic parameters, and the three-dimensional coordinates. The reprojection residual under each preset pose is the deviation between the three-dimensional coordinates of the fixed reference object under that preset pose, after being projected onto the reference object image under that preset pose by the refined intrinsic parameters and the pose of the camera under that preset pose in the machine tool coordinate system, and the image point of the fixed reference object in the reference object image. After the workpiece is loaded, the camera acquires an image of the workpiece in the acquisition pose. The circular hole of the workpiece is identified in the workpiece image, and the center of the circular hole is determined as the imaging point in the workpiece image according to the vanishing pole method. The acquisition pose is the pose of the camera in the machine tool coordinate system when acquiring the workpiece image. The machine tool probe contacts multiple points on the edge of the circular hole, and the machine tool coordinates at each contact time are recorded. The coordinates of the center of the circular hole in the machine tool coordinate system are determined based on the machine tool coordinates at each contact time. Pair the imaging point of the center of the circular hole in the workpiece image with the coordinates of the center of the circular hole in the machine tool coordinate system to form a correspondence between the imaging point of the center of the circular hole and the three-dimensional coordinates of the center of the hole. According to the intrinsic parameters of the camera, solve the extrinsic parameters of the camera in the machine tool coordinate system under the acquisition pose. The camera's intrinsic parameters, the hand-eye extrinsic parameters, and the camera's extrinsic parameters in the machine tool coordinate system under the acquisition pose are used as the camera's calibration results.
2. The camera calibration method based on machine tool motion excitation and workpiece self-features according to claim 1, characterized in that, The steps for determining the camera's pose in the machine tool coordinate system under each preset pose in the preset pose sequence, based on the feedback coordinates of each axis of the machine tool and the kinematic model, include: For each preset pose in the preset pose sequence, the feedback coordinates of each axis of the machine tool are obtained, including the feedback coordinates of the X-axis, Y-axis, Z-axis, B-axis and C-axis; According to the kinematic model, based on the feedback coordinates of each axis of the machine tool, the position of the spindle flange in the machine tool coordinate system under the preset position is determined; Obtain initial estimates of the hand-eye extrinsic parameters of the camera relative to the spindle flange; The position of the spindle flange in the machine tool coordinate system under the preset position is multiplied by the initial estimate of the hand-eye extrinsic parameters to obtain the position of the camera in the machine tool coordinate system under the preset position.
3. The camera calibration method based on machine tool motion excitation and workpiece self-features according to claim 1, characterized in that, The steps for obtaining the intrinsic parameters and the extrinsic parameters by taking the camera's pose in the machine tool coordinate system at each preset pose as the known excitation, and the reference object image at that preset pose as the observation, and taking the camera's intrinsic parameters, the camera's extrinsic parameters relative to the spindle flange, and the three-dimensional coordinates of the fixed reference object in the machine tool coordinate system as joint unknowns, and solving them in a three-stage process of rotation and translation decoupling, include: In the first stage, reference images are acquired in the preset pose sequence where the principal axis is stationary and at least one of the B-axis and C-axis is rotated, serving as the first set of reference images. Based on the imaging points of the fixed reference objects in the first set of reference images, the homography matrix between frame pairs in the first set of reference images is calculated. Based on the homography matrix between the frame pairs and the rotation matrix between the frame pairs, the intrinsic parameter correction of the camera is solved inversely. The intrinsic parameter correction is then superimposed on the intrinsic parameter prior to obtain the refined intrinsic parameters. In the second stage, a reference object image is acquired in the preset pose sequence where the B-axis and C-axis do not rotate and the main axis moves along at least one of the X-axis, Y-axis, and Z-axis directions, as the second set of reference object images; the fine-tuning intrinsic parameters are fixed, and the initial values of the hand-eye extrinsic parameters are solved using epipolar constraints based on the imaging point of the fixed reference object in the second set of reference object images and the pose of the camera in the machine tool coordinate system under that pose; In the third stage, the weighted sum of squares of the reprojection residuals of all reference object images under the preset pose sequence is used as the target. The camera's intrinsic parameters, the hand-eye extrinsic parameters, and the three-dimensional coordinates are jointly optimized using the initial values of the refined intrinsic parameters and the hand-eye extrinsic parameters. The camera's intrinsic parameters, the hand-eye extrinsic parameters, and the three-dimensional coordinates are obtained. The reprojection residual under each preset pose is the deviation between the three-dimensional coordinates of the fixed reference object under that preset pose, after being projected onto the reference object image under that preset pose using the camera's intrinsic parameters and the camera's pose in the machine tool coordinate system, and the image point of the fixed reference object in the reference object image. The pose of the camera under the preset pose in the machine tool coordinate system in the third stage is obtained by multiplying the pose of the spindle flange under that preset pose in the machine tool coordinate system with the hand-eye extrinsic parameters to be optimized.
4. The camera calibration method based on machine tool motion excitation and workpiece self-features according to claim 1, characterized in that, After the workpiece is loaded, the camera acquires an image of the workpiece in a specific acquisition pose. The steps include identifying the circular hole within the workpiece image and determining the imaging point of the center of the circular hole in the workpiece image using the vanishing pole method. After the workpiece is loaded, the camera captures an image of the workpiece in the acquisition pose. The circular hole of the workpiece itself is identified in the workpiece image, and the outline of the hole is fitted with a subpixel ellipse to obtain the quadratic curve matrix of the projected ellipse of the hole outline. Determine the homogeneous coordinates of the vanishing line of the plane containing the opening of the circular hole; The homogeneous coordinates of the imaging point of the center of the circular hole in the workpiece image are determined by taking the pole of the projection ellipse about the vanishing line, based on the quadratic curve matrix and the homogeneous coordinates of the vanishing line. Normalize the homogeneous coordinates of the imaging point of the center of the circular hole in the workpiece image to obtain the pixel coordinates of the imaging point of the center of the circular hole in the workpiece image.
5. The camera calibration method based on machine tool motion excitation and workpiece self-features according to claim 1, characterized in that, The steps of contacting multiple points on the edge of the circular hole with a probe of the machine tool, recording the machine tool coordinates at each contact moment, and determining the coordinates of the center of the circular hole in the machine tool coordinate system based on the machine tool coordinates at each contact moment include: The probe of the machine tool sequentially contacts multiple contact points on the edge of the circular hole to obtain multiple contact points, and the number of the multiple contact points is an integer greater than or equal to 3; Record the calibrated position of the probe tip relative to the spindle flange at each contact point and the feedback coordinates of each axis of the machine tool at each contact moment; Based on the feedback coordinates of each axis of the machine tool at each contact moment and the kinematic model, the position and orientation of the spindle flange in the machine tool coordinate system at each contact moment are determined. Multiply the position of the spindle flange in the machine tool coordinate system at each contact moment by the calibrated position of the probe tip relative to the spindle flange to obtain the coordinates of each contact point in the machine tool coordinate system. Based on the coordinates of each contact point in the machine tool coordinate system, the orifice circle of the circular hole is fitted to obtain the coordinates of the center of the circular hole in the machine tool coordinate system.
6. The camera calibration method based on machine tool motion excitation and workpiece self-features according to claim 1, characterized in that, The steps of pairing the imaging point of the center of the circular hole in the workpiece image with the coordinates of the center of the circular hole in the machine tool coordinate system to establish the correspondence between the imaging point of the center of the circular hole and the three-dimensional coordinates of the center of the hole, and solving the extrinsic parameters of the camera in the machine tool coordinate system under the acquisition pose according to the intrinsic parameters of the camera, include: The center of the circular hole is used as the image point in the workpiece image, and the coordinates of the center of the circular hole in the machine tool coordinate system are used as the three-dimensional point. The image points are paired with the three-dimensional points to form a correspondence between the center imaging point of the circular hole and the three-dimensional coordinates of the hole center; The objective function is constructed with the extrinsic parameters of the camera in the machine tool coordinate system under the acquisition pose as the quantity to be determined, and the objective is to minimize the deviation between the three-dimensional point and the image point after being projected onto the workpiece image through the intrinsic and extrinsic parameters of the camera. Under the constraint that the rotation matrix in the extrinsic parameters is an orthogonal matrix and the determinant is positive 1, the objective function is solved to obtain the extrinsic parameters of the camera in the machine tool coordinate system under the acquisition pose.
7. The camera calibration method based on machine tool motion excitation and workpiece self-features according to any one of claims 1 to 6, characterized in that, Also includes: According to a pre-set re-inspection cycle, the camera acquires re-inspection images of the fixed reference object, and the re-inspection reprojection residual is calculated based on the re-inspection images; The retest contact deviation is obtained, which is the physical deviation between the hole center coordinates obtained by the probe of the machine tool retesting the hole center and the hole coordinates calculated from the retest image; The larger of the difference between the re-projection residual and the preset residual threshold, and the difference between the re-measurement contact deviation and the preset contact deviation threshold, is determined as the drift judgment value. If the drift determination value is greater than zero, automatic recalibration is triggered. The automatic recalibration includes re-executing the three-stage solution to complete the field-level recalibration, and re-executing the round hole identification, probe contact and external parameter solution after the workpiece is loaded to complete the workpiece-level recalibration. Write the changes in the extrinsic parameters before and after recalibration into the drift log.
8. A machine tool, characterized in that, Includes the machine tool body, spindle, rotary table, camera, and CNC system; The rotary table includes a B-axis and a C-axis. The C-axis is mounted on the B-axis and tilts as the B-axis rotates. The B-axis is positioned about the Y-axis of the machine tool, and the C-axis is positioned about the Z-axis of the machine tool. The spindle is configured to feed linearly along the X-axis, Y-axis and Z-axis of the machine tool; The camera is mounted on the main shaft; The CNC system is configured to perform the steps of the camera calibration method based on machine tool motion excitation and workpiece self-features according to any one of claims 1 to 7.
9. A computer-readable storage medium having a computer program or instructions stored thereon, characterized in that, When the computer program or instructions are executed by the processor, they implement the steps of the camera calibration method based on machine tool motion excitation and workpiece self-features according to any one of claims 1 to 7.
10. A computer program product, comprising a computer program or instructions, characterized in that, When the computer program or instructions are executed by the processor, they implement the steps of the camera calibration method based on machine tool motion excitation and workpiece self-features according to any one of claims 1 to 7.
