A precise positioning method for the position of a workpiece on a machine tool and a vision system
Through image acquisition and splicing technology, combined with fill light devices, the rapid and accurate positioning of the workpiece on the machine tool is achieved, solving the problems of positioning uncertainty and inefficiency in the prior art, and is especially suitable for the precise positioning of large workpieces.
Patent Information
- Application Number
- CN202110858443.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-07-28
- Publication Date
- 2025-08-01
- Estimated Expiration
- 2041-07-28
AI Technical Summary
The existing workpiece positioning methods on machine tools have problems such as uncertainty in the worker level, low positioning accuracy, and low efficiency, making it difficult to achieve fast and accurate positioning.
The image information of the workpiece is collected through the image acquisition device, pixel coordinates are obtained, and the correlation information between the camera coordinate system and the machine tool coordinate system is used to determine the precise position of the workpiece in the machine tool coordinate system. Combined with the fill light device and image splicing technology, the rapid and accurate positioning of the workpiece is achieved.
It realizes rapid and accurate positioning of workpieces on machine tools, improves positioning accuracy and efficiency, especially the positioning process of large workpieces without manual movement, saving time.
Smart Images

Figure CN113538583B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of workpiece processing equipment, and specifically, to a precise positioning method for the position of a workpiece on a machine tool and a vision system. Background Art
[0002] Nowadays, mechanized processing is applied in more and more fields. With the development of society, the precision requirements for the products processed by machine tools in various industries are getting higher and higher. To improve the processing precision of workpieces, it is necessary to first obtain the precise positioning of the workpiece on the machine tool and then perform subsequent operations.
[0003] In the existing technologies, the positioning of a workpiece on a machine tool includes the following three methods: 1. Direct alignment method for positioning: When using the direct alignment method for positioning, a dial indicator, a scribing needle or visual inspection, etc. are used to directly align the design datum of the processed surface of the workpiece on the machine tool to obtain the correct position; 2. Scribing alignment method for positioning: The scribing alignment method for positioning is to use a scribing needle on the machine tool to align the workpiece according to the pre-scribed line segments at the processing area on the blank or semi-finished product to obtain the correct position; 3. Using a fixture for positioning: Using a fixture for positioning is a method of directly using the positioning elements on the fixture to make the workpiece obtain the correct position. Since the relative positions of the positioning elements of the fixture with the machine tool and the tool have been pre-adjusted, it is not necessary to adjust them one by one when positioning the workpiece.
[0004] The following problems exist in the above three positioning methods:
[0005] (1) The direct alignment method depends on the level of the alignment worker, and there is a large uncertainty in the actual workpiece positioning operation;
[0006] (2) The scribing alignment method for positioning is limited by the scribing accuracy and the alignment accuracy, resulting in low positioning accuracy of the workpiece;
[0007] (3) Using a fixture for positioning requires placing the workpiece at a specific position for positioning, which takes time and results in low positioning efficiency. Summary of the Invention
[0008] The technical solution of the present invention is as follows:
[0009] A precise positioning method for the position of a workpiece on a machine tool, used to associate a workpiece to be measured with the coordinate system of the machine tool, includes the following steps:
[0010] S1: Provide an image acquisition device having a relative position relationship with the machine tool;
[0011] S2: Collect the workpiece to be measured through the image acquisition device at a plurality of points to obtain the image information of the workpiece to be measured on the machine tool this time;
[0012] S3: Obtain the pixel coordinate information of the image of the workpiece to be measured through the image information of the workpiece to be measured in the step S2;
[0013] S4: Obtain the mutual relationship between the pixel coordinate system of the image of the workpiece to be measured and the machine tool coordinate system through the associated information between the camera coordinate system and the machine tool coordinate system, and the associated information between the coordinate information of the image of the workpiece to be measured and the camera coordinate system where the image acquisition device is located;
[0014] S5: Determine the precise positioning information of the position of the workpiece in the machine tool coordinate system.
[0015] In this technical solution, the workpiece to be measured is placed on the machine tool, and the image acquisition device acquires the image information of the workpiece to be measured. Then, obtain the pixel coordinate information of the image information of the workpiece to be measured. Then, according to the associated information between the camera coordinate and the machine tool coordinate, and the associated information between the pixel coordinate system of the image of the workpiece to be measured and the camera coordinate system where the image acquisition device is located, obtain the mutual relationship between the pixel coordinate system of the image of the workpiece to be measured and the machine tool coordinate system. Finally, determine the positioning information of the position of the workpiece to be measured and the machine tool coordinate system; the technical solution of the present invention can simply and quickly obtain the positioning information of the precise position between the workpiece to be measured and the machine tool coordinate system, which is convenient for the next operation of the workpiece to be measured on the machine tool.
[0016] On the basis of the above solution and as a preferred solution of the above solution: in the step S2, the image acquisition device acquires the image information of the workpiece to be measured on the machine tool by single-point position acquisition of the workpiece to be measured.
[0017] In this technical solution, for small workpieces, the image acquisition device can obtain the complete image information of the workpiece to be measured by single-point position image acquisition.
[0018] On the basis of the above solution and as a preferred solution of the above solution: in the step S2, the image acquisition device acquires the image information of the workpiece to be measured on the machine tool by multi-point position acquisition of the workpiece to be measured;
[0019] The step S3 further includes an image stitching process, and the image stitching process is to stitch the image information acquired at multiple points in the step S2, extract the contour information of the workpiece to be measured, and obtain the pixel coordinate information of the image of the workpiece to be measured.
[0020] In this technical solution, when dealing with large workpieces to be measured, the image acquisition device acquires the image information of the workpiece at multiple points, then splices and extracts the contours of the acquired image information to obtain the complete contour information of the workpiece to be measured, obtains the pixel coordinate information of the image information of the workpiece to be measured, and then, based on the correlation information between the camera coordinate system and the machine tool coordinate system, and the correlation information between the pixel coordinate system of the image of the workpiece to be measured and the camera coordinate system where the image acquisition device is located, obtains the mutual relationship between the pixel coordinate system of the image of the workpiece to be measured and the machine tool coordinate system, and finally determines the positioning information of the position of the workpiece to be measured and the machine tool coordinate system; moreover, for the positioning of the workpiece to be measured in the present invention, only the workpiece to be measured needs to be placed on the machine tool, and there is no need to move the workpiece into a specific position, saving the time for manually moving large workpieces for positioning, and the positioning method provided by the present invention can achieve positioning quickly and accurately.
[0021] On the basis of the above solution and as a preferred solution of the above solution: Before step S4, it further includes:
[0022] At least a first positioning point and a second positioning point are set on the workpiece to be measured within the image range of the workpiece to be measured at the first acquisition point, and the first positioning point serves as the reference origin of the machine tool coordinate system.
[0023] Step S4 further includes: [[ID=I0]]
[0024] Based on the pixel center point coordinates of the first positioning point and the second positioning point, the deflection angle of the camera coordinate system relative to the machine tool coordinate system is obtained, so as to obtain the accurate positioning information of the workpiece in the machine tool coordinate system including the position and the angle.
[0025] In this technical solution, the deflection angle of the camera coordinate system relative to the machine tool coordinate system is obtained through two fixed points, and then the angular relationship between the camera coordinate system and the machine tool coordinate system is determined. Further, the angular relationship of the workpiece in the machine tool coordinate system is determined, further improving the accuracy of the positioning of the position of the workpiece on the machine tool.
[0026] On the basis of the above solution and as a preferred solution of the above solution: Step S4 further includes:
[0027] Based on the image information of the workpiece to be measured at the first acquisition point, the pixel coordinates of the image center in the pixel coordinate system are obtained;
[0028] Based on the known distance that the machine tool moves between the first positioning point and the second positioning point and the distance between the pixel coordinates of the first positioning point and the second positioning point corresponding thereto in the image, the scale of the image is obtained;
[0029] Based on the coordinate offset between the pixel coordinates of the first positioning point and the pixel coordinates of the image center point in the image and the scale of the image, the offset between the origin of the camera coordinate system and the reference origin of the machine tool coordinate system is obtained;
[0030] When the image acquisition device acquires the image information of the workpiece to be measured through single-point acquisition, according to the mutual relationship between the pixel coordinate system of the first acquisition point image of the image acquisition device and its corresponding camera coordinate system, and the mutual relationship between the camera coordinate system and the machine tool coordinate system, the mutual relationship between the pixel coordinate system of the first acquisition point image and the machine tool coordinate system is obtained. Furthermore, the pixel coordinate system and the machine tool coordinate system are associated to determine the precise positioning information including the position and angle of the workpiece to be measured in the machine tool coordinate system;
[0031] When the image acquisition device acquires the image information of the workpiece to be measured through multi-point acquisition, according to the mutual relationship between the pixel coordinate system of the first acquisition point image of the image acquisition device and its corresponding camera coordinate system, and the mutual relationship between the camera coordinate system and the machine tool coordinate system, the mutual relationship between the pixel coordinate system of the first acquisition point image and the machine tool coordinate system is obtained. Then, through the splicing process, the pixel coordinate systems of the other acquisition point images except the first acquisition point are converted into the pixel coordinate system of the first acquisition point image, so as to obtain the global pixel coordinate system of the entire workpiece splicing image. Furthermore, the pixel coordinate system and the machine tool coordinate system are associated to determine the precise positioning information including the position and angle of the workpiece to be measured in the machine tool coordinate system.
[0032] In this technical solution, the relevant data information required for associating the workpiece to be measured with the machine tool coordinate system, and the collection method of the relevant data information.
[0033] On the basis of the above solution and as a preferred solution of the above solution: The conversion formula between the pixel coordinate system and the camera coordinate system is as follows:
[0034]
[0035] Among them, S: The scale length of the image;
[0036] (u0, v0): The coordinates of the image coordinate origin in the pixel coordinate system of the image;
[0037] (u, v): The pixel point coordinates in the workpiece image;
[0038] (X c , Y c ): The coordinates in the camera coordinate system corresponding to the pixel point of the workpiece image.
[0039] In this technical solution, specifically, the pixel coordinates of the image center point in this pixel coordinate system are obtained according to the image size of the first acquisition point, and the scale length of the image is obtained according to the known distance of the movement of the machine tool between two positioning points and the distance between the corresponding positioning point pixel center coordinates in the image. The specific formula for the conversion between the pixel coordinate system and the camera coordinate system.
[0040] Based on the above solution and as a preferred solution of the above solution: The coordinate transformation formula between the camera coordinate system and the machine tool coordinate system is as follows:
[0041]
[0042] Where, (X, Y): The machine tool coordinates corresponding to the pixel points of the workpiece image;
[0043] (X c , Y c ): The coordinates in the camera coordinate system corresponding to the pixel points of the workpiece image.
[0044] θ: The deflection angle of the camera coordinate system relative to the machine tool coordinate system;
[0045] (U, V): The actual offset between the camera coordinate system and the machine tool coordinate system.
[0046] In this technical solution, the specific formula for the conversion between the camera coordinate system and the machine tool coordinate system.
[0047] Based on the above solution and as a preferred solution of the above solution:
[0048] Step S1 further includes: setting an industrial light source and a polarizer for illuminating the workpiece to be measured;
[0049] Step S2 further includes: the industrial light source irradiates the workpiece to be measured unidirectionally or multi-directionally at a certain angle to highlight the edge features of the workpiece to be measured, so as to be applicable to the imaging occasion of large-size workpieces to reduce the reflection phenomenon of metal workpieces; the polarizer installed on the lens weakens or eliminates the interference of astigmatism, reflection, glare, etc.
[0050] In this technical solution, the combined use of the industrial light source and the polarizer can eliminate the reflection phenomenon of the workpiece to a certain extent, avoiding the adverse impact on the later image processing caused by the reflection of the workpiece.
[0051] Refer to Figure 1 As shown, the splicing method in the specific step S3 of this embodiment is an image splicing method based on the homography transformation matrix to realize image splicing. The image splicing method based on the homography transformation matrix includes the following steps:
[0052] Q1: Use the sift feature extraction algorithm to extract the feature points of adjacent images;
[0053] Q2: Use the KNN matching algorithm to perform feature matching on the feature points in adjacent images;
[0054] Q3: Use the RANSAC algorithm to purify the feature matching pairs and eliminate the wrong matching pairs;
[0055] Q4: Then, calculate the homography transformation matrix of the two images based on the feature matching pairs after purification.
[0056] Q5: Project the second image onto the first image according to the homography transformation matrix of the two images to complete the stitching of the two images. Repeat the above operation steps to finally obtain the complete workpiece stitching image.
[0057] In this technical solution, the image stitching method using the homography transformation matrix stitches the images of the workpiece to be measured collected at multiple positions by the image acquisition device to obtain the complete workpiece image information.
[0058] Based on the above solution and as the preferred solution of the above solution: It further includes:
[0059] For the workpiece with unclear features, the following methods are used to add feature points: A1: Place some feature blocks near the overlapping area of the image to increase the feature points of the image, which is used to improve the accuracy and speed of image stitching; A2: Directly add some feature points on the surface of the workpiece in the overlapping area of the image with a marker pen, which is used for the image stitching scenario where the workpiece surface can be scribed, to improve the stitching speed and accuracy of the image; A3: Project pictures on the surface of the workpiece using a projector to increase the feature points of the workpiece image, reduce the workload of the operator, and improve the stitching speed and accuracy of the image.
[0060] In this technical solution, in the image stitching scenario where the workpiece surface can be scribed, the operator can use a marker pen to add feature points on the surface of the overlapping area of the workpiece image to improve the stitching speed and accuracy of the image; project pictures on the surface of the workpiece using a projector to increase the feature points of the workpiece image, reduce the workload of the operator, and improve the stitching speed and accuracy of the image; place some feature blocks near the overlapping area of the image to increase the feature points of the image, which is used to improve the accuracy and speed of image stitching; by using different methods to increase the feature points of the image in different application scenarios, the stitching speed and accuracy of the image can be improved.
[0061] Based on the above solution and as the preferred solution of the above solution: Before the S2 step, there is a preprocessing process for improving the clarity of the image information. The preprocessing process includes at least one of the following steps:
[0062] M1: Image denoising, which is used to eliminate or suppress the influence of noise on the image and realize the smoothing of the image.
[0063] M2: Image enhancement, which is used to enhance the contrast of the image to make the image clearer.
[0064] M3: Image correction, which is used to correct the distortion of the image.
[0065] In this technical solution, preprocessing collects images of the workpiece to be measured at multiple points by an image acquisition device and performs optimization processing. The image denoising step eliminates or suppresses the influence of noise on the image to obtain a smooth image. The image enhancement step enhances the contrast of the image to obtain a clear image. The image correction step is used to correct the distortion of the image, and finally, smooth, clear, and accurate workpiece image information is obtained.
[0066] A machine tool includes a machine tool body, and further includes: an image acquisition device and a processor for controlling the machine tool to drive it to perform vector motion. The processor executes a method for accurately positioning the position of a workpiece on the machine tool. A machine tool also includes a supplementary lighting device. The supplementary lighting device includes a moving bracket and a light source. The light source is installed on the moving bracket, and the moving bracket is placed at a suitable position on the machine tool for the light source to perform supplementary lighting on the workpiece to be measured.
[0067] In this technical solution, the method for accurately positioning the position of a workpiece on a machine tool can quickly and accurately position the position of the workpiece on the machine tool. A supplementary lighting device is added outside the machine tool, and the light source irradiates on the workpiece, highlighting the edge features of the workpiece to be measured, which is convenient for the image acquisition device to collect the image information of the workpiece to be measured.
[0068] A storage medium storing computer-readable instructions, when the computer-readable instructions are executed by one or more processors, cause the one or more processors to execute a method for accurately positioning the position of a workpiece on a machine tool.
[0069] A vision system includes:
[0070] An image receiving module: for receiving the multi-point image information of the workpiece to be measured collected at multiple points by the image acquisition device and sending the multi-point image information of the workpiece to be detected on the machine tool operation table obtained thereby;
[0071] An image stitching module: for stitching these image information and then extracting the contour information of the workpiece to obtain the pixel coordinate information of the workpiece image;
[0072] An association module: for obtaining the mutual relationship between the pixel coordinate system of the workpiece image and the machine tool coordinate system according to the association information between the camera coordinate and the machine tool coordinate and the association information between the pixel coordinate system of the workpiece image and the camera coordinate system where the image acquisition device is located;
[0073] A positioning information determination module: determining the accurate positioning information of the workpiece in the machine tool coordinate system including at least one of position and angle.
[0074] In this technical solution, the image receiving module in the vision system receives the images of the workpiece to be measured collected at multiple points by the image acquisition device, and transmits them to the image stitching module for stitching the image information to obtain the complete contour information of the workpiece, and obtains the pixel coordinate system of the workpiece image. Then, through the association module, the pixel coordinate system is associated with the camera coordinate system, and then the camera coordinate system is associated with the machine tool coordinate system. Finally, through the positioning information determination module, the positioning information of the workpiece in the machine tool coordinate system is determined, and the precise positioning of the workpiece on the machine tool is completed.
[0075] Compared with the prior art, the present invention has the following beneficial effects:
[0076] 1. Place the workpiece to be measured on the machine tool. The image acquisition device acquires the image information of the workpiece to be measured, and then obtains the pixel coordinate information of the image information of the workpiece to be measured. Then, according to the association information between the camera coordinate and the machine tool coordinate, and the association information between the pixel coordinate system of the image of the workpiece to be measured and the camera coordinate system where the image acquisition device is located, the mutual relationship between the pixel coordinate system of the image of the workpiece to be measured and the machine tool coordinate system is obtained, and finally the positioning information of the position of the workpiece to be measured and the machine tool coordinate system is determined. The technical solution of the present invention can simply and quickly obtain the positioning information of the precise position between the workpiece to be measured and the machine tool coordinate system, which is convenient for the next operation of the workpiece to be measured on the machine tool.
[0077] 2. When dealing with large workpieces to be measured, the image acquisition device acquires the image information of the workpiece at multiple points, and then stitches and extracts the contour of the collected image information to obtain the complete contour information of the workpiece to be measured. Obtain the pixel coordinate information of the image information of the workpiece to be measured. Then, according to the association information between the camera coordinate and the machine tool coordinate, and the association information between the pixel coordinate system of the image of the workpiece to be measured and the camera coordinate system where the image acquisition device is located, the mutual relationship between the pixel coordinate system of the image of the workpiece to be measured and the machine tool coordinate system is obtained, and finally the positioning information of the position of the workpiece to be measured and the machine tool coordinate system is determined. And for the positioning of the workpiece to be measured in the present invention, only need to place the workpiece to be measured on the machine tool, without moving the workpiece into a specific position, saving the time of manually moving large workpieces for positioning, and the positioning method provided by the present invention can quickly and accurately achieve positioning.
[0078] 3. In the image stitching scenario where images can be written on the surface of the workpiece, the operator can use a marker pen to add feature points on the surface of the overlapping area of the workpiece image to improve the speed and accuracy of image stitching; use a projector to project pictures on the surface of the workpiece, thereby increasing the feature points of the workpiece image, reducing the workload of the operator, and improving the speed and accuracy of image stitching; place some feature blocks near the overlapping area of the image, thereby increasing the feature points of the image, and being used to improve the accuracy and speed of image stitching; by using different methods in different application scenarios to increase the feature points of the image, the speed and accuracy of image stitching can be improved.
[0079] 4. Pretreatment: The image acquisition device acquires images of the workpiece to be measured at multiple points and performs optimization processing. The image denoising step eliminates or suppresses the influence of noise on the image to obtain a smooth image. The image enhancement step enhances the contrast of the image to obtain a clear image. The image correction step is used to correct the distortion of the image. Finally, smooth, clear, and accurate workpiece image information is obtained.
[0080] 5. In the vision system, the image receiving module receives the images of the workpiece to be measured acquired by the image acquisition device at multiple points, transmits them to the image stitching module for image information stitching to obtain complete workpiece contour information, and obtains the pixel coordinate system of the workpiece image. Then, through the association module, the pixel coordinate system is associated with the camera coordinate system, and then the camera coordinate system is associated with the machine tool coordinate system. Finally, through the positioning information determination module, the position of the workpiece in the machine tool coordinate system is determined, and the accurate positioning of the workpiece on the machine tool is completed.
[0081] 6. A supplementary lighting device is added outside the machine tool. The light source irradiates the workpiece to be measured, highlighting the edge features of the workpiece to be measured, facilitating the image acquisition device to collect the image information of the workpiece to be measured. BRIEF DESCRIPTION OF THE DRAWINGS
[0082] By reading the following detailed description of the non-limiting embodiments with reference to the accompanying drawings, other features, objects, and advantages of the present invention will become more apparent:
[0083] Figure 1 It is a flowchart of the method for accurately positioning the position of the workpiece on the machine tool according to the present invention;
[0084] Figure 2 It is a flowchart of the image stitching method of the homography transformation matrix according to the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0085] The present invention will be described in detail below with reference to specific embodiments. The following embodiments will help those skilled in the art to further understand the present invention, but do not limit the present invention in any form. It should be noted that those of ordinary skill in the art can make several changes and improvements without departing from the concept of the present invention. These all belong to the protection scope of the present invention.
[0086] For better illustration of the present invention, the following is combined with the attached Figure 1-2 The present invention is described in detail.
[0087] Embodiment 1:
[0088] A method for accurately positioning the position of a workpiece on a machine tool, used to associate the workpiece to be measured with the coordinate system of the machine tool, includes the following steps:
[0089] S1: Provide an image acquisition device having a relative positional relationship with the machine tool; in this embodiment, the image acquisition device is an industrial camera. Before the industrial camera acquires the image of the workpiece to be measured, at least a first positioning point and a second positioning point will be set on the workpiece within the range of the first image, and the first positioning point will be used as the origin of the machine tool coordinates; then the industrial camera will be adjusted to a height where the photographing field of view is at least large enough to include the first positioning point and the second positioning point.
[0090] In this embodiment, the specific parameters of the camera are that the field of view of the image is 500mm×500mm, the distance between the camera and the object to be measured is 500mm, and the measurement accuracy of the image should reach 0.05mm; the camera is Basler_acA2440-75uc: the frame rate reaches 75fps, the resolution is 5 million pixels (2448px×2048px), the chip size is 8.4mm×7.1mm, the chip type is CMOS, the interface is usb3.0, and it is a color camera; the lens is ML-M0822UR: an 8mm lens, the object distance is 580mm, and the field of view is 660×500mm. If the 1 / 5 sub-pixel edge detection algorithm is used, the horizontal measurement accuracy of the workpiece image can reach 0.054mm / px, while the vertical measurement accuracy can reach 0.048mm / px.
[0091] In this embodiment, step S1 further includes: setting an industrial light source and a polarizer for illuminating the workpiece to be measured.
[0092] S2: Use the image acquisition device to collect the workpiece to be measured at a single point to obtain the image information of the workpiece to be measured on the machine tool this time; step S2 further includes: the industrial light source irradiates the workpiece to be measured unilaterally or multilaterally at a certain angle to highlight the edge features of the workpiece to be measured, so as to adapt to the imaging occasion of the workpiece to be measured and reduce the reflection phenomenon of metal workpieces; and a polarizer is installed on the lens to weaken or eliminate the interference of astigmatism, reflection, glare, etc. The combined use of the industrial light source and the polarizer can, to a certain extent, eliminate the reflection phenomenon of the workpiece and avoid the adverse impact on the later image processing caused by the workpiece reflection. In other embodiments, lighting from above the workpiece to be measured can also be used. This method uses a large backlight to illuminate the entire surface of the metal workpiece, avoiding the problem of uneven image brightness caused by reflection. Specifically, in this embodiment, the industrial light source used is an LED strip light source, with a light source size of 600mm×50mm, which is mostly used to irradiate the workpiece to be measured unilaterally or multilaterally at a certain angle to highlight the edge features of the workpiece to be measured and is suitable for the imaging occasion of large-sized workpieces. Here, multiple light sources are used to illuminate the workpiece to be measured from the side to reduce the reflection phenomenon of metal workpieces.
[0093] S3: Obtain the pixel coordinate information of the workpiece image to be measured through the workpiece image information in step S2.
[0094] In this embodiment, to address the situation where the image information collected by the image information acquisition device is not clear due to external environment problems of the image acquisition device or the machine tool itself during image stitching, a preprocessing process is provided before step S4 to improve the clarity of the image information. The preprocessing process includes the following steps:
[0095] M1: Image denoising, which is used to eliminate or suppress the influence of noise on the image and achieve image smoothing;
[0096] M2: Image enhancement, which is used to enhance the contrast of the image and make the image clearer;
[0097] M3: Image correction, which is used to correct the distortion of the image.
[0098] In this embodiment, the preprocessing optimizes the image of the workpiece collected at a single point (the first acquisition point) by the image acquisition device. The image denoising step eliminates or suppresses the influence of noise on the image to obtain a smooth image. The image enhancement step enhances the contrast of the image to obtain a clear image. The image correction step is used to correct the distortion of the image. Finally, smooth, clear and accurate workpiece image information is obtained.
[0099] In this embodiment, the image denoising is an image denoising method based on morphological processing. Since noise brings great obstacles and influences to subsequent image processing, it is necessary to effectively suppress or eliminate the noise of the image to achieve the smooth effect of the image. Morphological processing eliminates the noise of the image on the basis of retaining the image contour, mainly including four basic operations: erosion, dilation, opening operation and closing operation. Erosion and dilation are basic morphological operators, both of which are processed for the white part in the image. Among them, the principle of erosion is to first define a convolution kernel, convolve the kernel with the image, calculate the minimum value of the pixel points in the kernel coverage area and assign the minimum value to the pixel specified by the reference point, so that the highlight area in the image gradually decreases, while dilation is the opposite. It should be noted that in this invention, the method of first performing an opening operation on the workpiece image and then a closing operation is used to remove the noise points on the image without affecting the edge information of the image. It is worth mentioning that the opening operation is erosion followed by dilation, and the closing operation is dilation followed by erosion. In other embodiments, the image denoising uses an image denoising method based on a filtering algorithm, such as mean filtering, Gaussian filtering and median filtering, etc. By comparing the denoising effects of different filters, the most suitable filtering algorithm for this image processing scenario is selected; and other processing methods that can eliminate image noise are within the protection scope of this invention.
[0100] In this embodiment, the image enhancement is an image enhancement method based on histogram equalization. This method mainly aims at the problems of sparse feature points in the workpiece image and uneven brightness caused by side lighting of the light source. The present invention performs adaptive histogram equalization on the workpiece image, calculates the local histogram of the image, and then redistributes the image brightness to enhance the contrast of the image and obtain more image details, making the image clearer.
[0101] S4: Obtain the mutual relationship between the pixel coordinate system of the workpiece image to be measured and the machine tool coordinate system through the association information between the camera coordinate system and the machine tool coordinate system, and the association information between the coordinate information of the workpiece image to be measured and the camera coordinate system where the image acquisition device is located;
[0102] In this embodiment, step S4 further includes:
[0103] Obtain the pixel coordinates of the image center in the pixel coordinates according to the image information of the workpiece to be measured at the first acquisition point;
[0104] Obtain the scale of the image according to the known distance of the movement of the machine tool between the first positioning point and the second positioning point and the distance between the pixel coordinates of the corresponding first positioning point and the second positioning point in the image;
[0105] Obtain the offset between the origin of the camera coordinate system and the reference origin of the machine tool coordinate system according to the coordinate offset between the pixel coordinates of the first positioning point in the image and the pixel coordinates of the image center point, and the scale of the image;
[0106] According to the mutual relationship between the pixel coordinate system of the image at the first acquisition point of the image acquisition device and its corresponding camera coordinate system, and the mutual relationship between the camera coordinate system and the machine tool coordinate system, obtain the mutual relationship between the pixel coordinate system of the image at the first acquisition point and the machine tool coordinate system, and then associate the pixel coordinate system with the machine tool coordinate system to determine the precise positioning information including the position and angle of the workpiece to be measured in the machine tool coordinate system;
[0107] In this embodiment, specifically in step S4, the conversion formula between the pixel coordinate system and the camera coordinate system is as follows:
[0108]
[0109] where S: the scale length of the image; (u0, v0): the coordinates of the image coordinate origin in the pixel coordinate system of the image; (u, v): the pixel point coordinates in the workpiece image; (X c , Y c ): the coordinates in the camera coordinate system corresponding to the pixel points of the workpiece image.
[0110] The coordinate transformation formula between the camera coordinate system and the machine tool coordinate system is as follows:
[0111]
[0112] where (X, Y) are the machine tool coordinates corresponding to the pixel points of the workpiece image; (X c , Y c ) are the coordinates in the camera coordinate system corresponding to the pixel points of the workpiece image; θ is the deflection angle of the camera coordinate system relative to the machine tool coordinate system; (U, V) is the actual offset between the camera coordinate system and the machine tool coordinate system.
[0113] During the actual use process on a machine tool with a cutting head: Use the cutting head to drill a round hole in the workpiece and set the machine tool coordinates at this time as the origin. Control the cutting head to move a distance of w in the positive Y-axis direction and then drill a second round hole, and then move the cutting head back to the position when the first hole was drilled. Then control the cutting head to move in the Z-axis direction to a height where the field of view of the camera can include the two round holes (the camera collects the image information of the workpiece to be measured at the first acquisition position), and use the camera to take three consecutive photos at the current position. The pixel coordinates of the center of the first round hole in the corresponding images are detected as P1(u1, v1), P2(u2, v2), P3(u3, v3) respectively, and the pixel coordinates of the center of the second round hole are Q1(u4, v4), Q2(u5, v5), Q3(u6, v6) respectively. Then, by taking the average value, it can be obtained that when the machine tool coordinates are (0, 0), the pixel coordinates of the center of the first round hole in the image are P0(u p , v p ) = ((u1 + u2 + u3) / 3, (v1 + v2 + v3) / 3), and the pixel coordinates of the center of the second round hole are Q0(u Q , v Q ) = ((u4 + u5 + u6) / 3, (v4 + v5 + v6) / 3). According to the ratio between the actual distance between the centers of the two round holes and the pixel distance between the corresponding pixel coordinates in the image, the scale length of the image can be obtained as: And according to the pixel offset between the pixel coordinates of the center of the first round hole in the image and the center of the image, as well as the scale length of the image, the actual offset between the camera coordinate system and the machine tool coordinate system can be obtained as (U, V) = D (P,Q) ((u P - u / 2), (v P - v / 2)). Then, according to the pixel coordinates of the two round holes, the deflection angle w of the camera coordinate system relative to the machine tool coordinate system can be obtained as w = arctan((u Q - u P ) / (v Q - v P ))), so that the mutual relationship between the camera coordinate system and the machine tool coordinate system can be obtained, and the conversion relationship between the two is as follows:
[0114]
[0115] In this embodiment, w is set according to the actual situation.
[0116] S5: Determine the precise positioning information of the workpiece in the machine tool coordinate system. Substitute the known parameters into the matrix formula in step S4 to obtain the precise positioning information including the position and angle of the workpiece to be measured in the machine tool coordinate system.
[0117] Embodiment 2:
[0118] A method for precise positioning of the position of a workpiece on a machine tool, used to associate the workpiece to be measured with the coordinate system of the machine tool, includes the following steps:
[0119] S1: Provide an image acquisition device having a relative position relationship with the machine tool; in this embodiment, the image acquisition device is an industrial camera. Before the industrial camera acquires the image of the workpiece to be measured, at least a first positioning point and a second positioning point are first set on the workpiece within the range of the first image, and the first positioning point is used as the origin of the machine tool coordinates; then the industrial camera is adjusted to a height where the photographing field of view is at least large enough to include the first positioning point and the second positioning point.
[0120] In this embodiment, the specific parameters of the camera are that the field of view of the image is 500mm × 500mm, the distance between the camera and the object to be measured is 500mm, and the measurement accuracy of the image should reach 0.05mm; the camera is Basler_acA2440 - 75uc: the frame rate reaches 75fps, the resolution is 5 million pixels (2448px × 2048px), the chip size is 8.4mm × 7.1mm, the chip type is CMOS, the interface is usb3.0, and it is a color camera; the lens is ML - M0822UR: an 8mm lens, the object distance is 580mm, and the field of view is 660 × 500mm. If a 1 / 5 sub - pixel edge detection algorithm is used, the horizontal measurement accuracy of the workpiece image can reach 0.054mm / px, and the vertical measurement accuracy can reach 0.048mm / px.
[0121] Step S1 in this embodiment further includes: setting an industrial light source and a polarizing mirror for illuminating the workpiece to be measured.
[0122] S2: Multiply - point collect the workpiece to be measured through the image acquisition device to obtain the multi - point image information of the workpiece to be detected on the machine tool console; there is no need for manual movement of the workpiece position, and only the industrial camera needs to move on the machine tool to collect the workpiece image information.
[0123] Step S2 further includes: the industrial light source irradiates the workpiece to be measured unidirectionally or multi-directionally at a certain angle to highlight the edge features of the workpiece to be measured, so as to adapt to the imaging occasion of the workpiece to be measured and reduce the specular reflection phenomenon of metal workpieces; and a polarizer is installed on the lens to weaken or eliminate the interference of astigmatism, specular reflection, glare, etc. The combined use of the industrial light source and the polarizer can, to a certain extent, eliminate the specular reflection phenomenon of large workpieces and avoid the adverse image caused by the specular reflection of large workpieces on the subsequent image processing. In other embodiments, lighting can also be performed from above the workpiece to be measured. This method uses a large backlight source to illuminate the entire surface of the metal workpiece, avoiding the problem of uneven image brightness caused by specular reflection. Specifically, in this embodiment, the industrial light source used is an LED strip light source with a light source size of 600 mm × 50 mm, which is mostly used to irradiate the workpiece to be measured unidirectionally or multi-directionally at a certain angle to highlight the edge features of the workpiece to be measured and is suitable for the imaging occasion of large-sized workpieces. Here, multiple light sources are used to illuminate the workpiece to be measured from the side, thereby reducing the specular reflection phenomenon of metal workpieces.
[0124] In other embodiments, for workpieces with unclear features, the following methods are used to add feature points: A1: Place some feature blocks near the overlapping area of the image to increase the feature points of the image, which is used to improve the accuracy and speed of image stitching; A2: Directly add some feature points on the surface of the workpiece in the image overlapping area with a marker pen, which is used for the image stitching scenario where the workpiece surface can be scribbled on, to improve the stitching speed and accuracy of the image; A3: Use a projector to project pictures on the surface of the workpiece to increase the feature points of the workpiece image, reduce the workload of the operator, and improve the stitching speed and accuracy of the image. In the image stitching scenario where the workpiece surface is scribbled on, the operator can use a marker pen to add feature points on the surface of the image overlapping area of the workpiece to improve the stitching speed and accuracy of the image; use a projector to project pictures on the surface of the workpiece to increase the feature points of the workpiece image, reduce the workload of the operator, and improve the stitching speed and accuracy of the image; place some feature blocks near the overlapping area of the image to increase the feature points of the image, which is used to improve the accuracy and speed of image stitching; by using different methods to add feature points in different application scenarios, the stitching speed and accuracy of the image can be improved. It should be noted that the application scenario of method A1 for adding feature points is for smooth metal workpieces with unclear features. Some feature blocks can be placed near the overlapping area of the image to increase the feature points of the image, which can, to a certain extent, improve the accuracy and speed of the image stitching algorithm; and this method is applicable to the image stitching scenario where marks cannot be scribbled on the workpiece surface or the object cannot touch the workpiece surface, and the feature blocks can also be reused to save costs.
[0125] S3: Stitch the image information in Step S2, and then extract the contour information of the workpiece to obtain the pixel coordinate information of the workpiece image. In this embodiment, the stitching method is an image stitching method based on a homography transformation matrix, and the image stitching method based on the homography transformation matrix includes the following steps:
[0126] Q1: Use the sift feature extraction algorithm to extract the feature points of adjacent images;
[0127] Q2: Use the KNN matching algorithm to perform feature matching on the feature points in adjacent images;
[0128] Q3: Use the RANSAC algorithm to purify the feature matching pairs and eliminate the incorrect matching pairs;
[0129] Q4: Then calculate the homography transformation matrix of the two images according to the purified feature matching pairs,
[0130] Q5: Project the second image onto the first image according to the homography transformation matrix of the two images to complete the stitching of the two images. Repeat the above operation steps to finally obtain the complete stitched image of the workpiece. The image stitching method based on the homography transformation matrix stitches the images of the workpiece to be measured collected at multiple points by the image acquisition device to obtain the complete workpiece image information.
[0131] In this embodiment, to address the situation where the image information collected by the image information acquisition device is not clear due to external environment or the problems of the machine tool itself during image stitching, a preprocessing process is provided before Step S4 to improve the clarity of the image information. The preprocessing process includes the following steps:
[0132] M1: Image denoising, which is used to eliminate or suppress the influence of noise on the image and achieve image smoothing;
[0133] M2: Image enhancement, which is used to enhance the contrast of the image and make the image clearer;
[0134] M3: Image correction, which is used to correct the distortion of the image.
[0135] The preprocessing optimizes the images of the workpiece to be measured collected at multiple points by the image acquisition device. The image denoising step eliminates or suppresses the influence of noise on the image to obtain a smooth image. The image enhancement step enhances the contrast of the image to obtain a clear image. The image correction step is used to correct the distortion of the image. Finally, smooth, clear and accurate workpiece image information is obtained.
[0136] In this embodiment, image denoising is an image denoising method based on morphological processing. Since noise poses a great obstacle and impact on subsequent image processing, it is necessary to effectively suppress or eliminate the noise in the image to achieve a smooth effect of the image. Morphological processing eliminates the noise in the image while preserving the image contour, mainly including four basic operations: erosion, dilation, opening operation, and closing operation. Erosion and dilation are basic morphological operators, both of which are applied to the white part of the image. Among them, the principle of erosion is to first define a convolution kernel, convolve the kernel with the image, calculate the minimum value of the pixel points in the area covered by the kernel, and assign this minimum value to the pixel specified by the reference point, so that the highlighted area in the image gradually decreases, while dilation is the opposite. It should be noted that the method adopted in the present invention is to perform an opening operation on the workpiece image first and then a closing operation to remove the noise points on the image without affecting the edge information of the image. It should be noted that the opening operation is erosion followed by dilation, and the closing operation is dilation followed by erosion. In other embodiments, the image denoising method adopted is an image denoising method based on a filtering algorithm, such as mean filtering, Gaussian filtering, and median filtering, etc. By comparing the denoising effects of different filters, the most suitable filtering algorithm for this image processing scenario is selected; and other processing methods capable of eliminating image noise are within the protection scope of the present invention.
[0137] Image enhancement is an image enhancement method based on histogram equalization. This method mainly aims at the problems of sparse feature points in the workpiece image and uneven brightness caused by side lighting of the light source. The present invention performs adaptive histogram equalization on the workpiece image, calculates the local histogram of the image, and then redistributes the image brightness to enhance the contrast of the image and obtain more image details, making the image clearer.
[0138] Image correction is an image correction method based on camera calibration. In actual operation, first, the camera takes multiple photos of the same calibration board from different angles and heights, collects about ten calibration board images, and then calibrates the camera according to Zhang Zhengyou's calibration method using the pixel coordinates of the corner points in each image and the physical coordinates of each corner point in the world coordinate system, thereby obtaining the internal and external parameter matrices of the camera and the distortion coefficient of the lens. Finally, the workpiece image is corrected for distortion according to the internal parameter matrix and the distortion coefficient.
[0139] There are splicing errors during the splicing of image information. Therefore, the present invention also includes a method for detecting splicing errors. First, the ratio of the actual length of a cell in the image to the number of pixels it occupies is collected through a standard checkerboard as the scale of the image. Then, the pixel value of the side to be measured is obtained from the spliced image of the workpiece, and the true length is calculated according to the scale. By splicing the workpiece images with calibration plates placed in the overlapping area, the sub-pixel corner coordinates at the splicing of the calibration plates are extracted using the corner detection algorithm, the number of pixels occupied by the cells at the splicing is calculated, and the theoretical length of the cells at the splicing is calculated according to the scale of the image, and the difference is obtained by comparing with the actual length of the cells, so as to obtain the splicing error of the image.
[0140] S4: According to the correlation information between the camera coordinates and the machine tool coordinates, and the correlation information between the pixel coordinate system of the workpiece image and the camera coordinate system where the image acquisition device is located, obtain the mutual relationship between the pixel coordinate system of the workpiece image and the machine tool coordinate system;
[0141] Step S4 further includes:
[0142] According to the image information of the workpiece to be measured at the first acquisition point, obtain the pixel coordinates of the image center in the pixel coordinate system;
[0143] According to the known distance that the machine tool moves between the first positioning point and the second positioning point and the distance between the pixel coordinates of the first positioning point and the second positioning point corresponding thereto in the image, obtain the scale of the image;
[0144] According to the coordinate offset between the pixel coordinates of the first positioning point and the pixel coordinates of the image center in the image, and the scale of the image, obtain the offset between the origin of the camera coordinate system and the reference origin of the machine tool coordinate system;
[0145] According to the mutual relationship between the pixel coordinate system of the image at the first acquisition point of the image acquisition device and its corresponding camera coordinate system, and the mutual relationship between the camera coordinate system and the machine tool coordinate system, obtain the mutual relationship between the pixel coordinate system of the image at the first acquisition point and the machine tool coordinate system, and then convert the pixel coordinate systems of the images at other acquisition points except the first acquisition point into the pixel coordinate system of the image at the first acquisition point through the splicing process, so as to obtain the global pixel coordinate system of the spliced image of the entire workpiece, and further associate the pixel coordinate system with the machine tool coordinate system to determine the precise positioning information including the position and angle of the workpiece to be measured in the machine tool coordinate system.
[0146] In this embodiment, specifically in step S4, the conversion formula between the pixel coordinate system and the camera coordinate system is as follows:
[0147]
[0148] where, S: scale length of the image; (u0, v0): coordinates of the origin of the image coordinate system in the pixel coordinate system of the image; (u, v): pixel coordinates of a point in the workpiece image; (X c , Y c ): coordinates in the camera coordinate system corresponding to the pixel point of the workpiece image.
[0149] The coordinate transformation formula between the camera coordinate system and the machine tool coordinate system is as follows:
[0150]
[0151] where, (X, Y): machine tool coordinates corresponding to the pixel point of the workpiece image; (X c , Y c ): coordinates in the camera coordinate system corresponding to the pixel point of the workpiece image; θ: deflection angle of the camera coordinate system relative to the machine tool coordinate system; (U, V): actual offset between the camera coordinate system and the machine tool coordinate system.
[0152] During the actual use process on a machine tool with a cutting head: Use the cutting head to drill a round hole in the workpiece and set the machine tool coordinates at this time as the origin. Control the cutting head to move a distance of w in the positive Y-axis direction and then drill a second round hole, and then move the cutting head back to the position when the first hole was drilled. Then control the cutting head to move in the Z-axis direction to a height where the camera's field of view can include the two round holes (preferably the height at which the camera takes the first image of the workpiece), and use the camera to take three consecutive photos at the current position. The pixel coordinates of the center of the first round hole in the corresponding images are detected as P1(u1, v1), P2(u2, v2), P3(u3, v3) respectively, and the pixel coordinates of the center of the second round hole are Q1(u4, v4), Q2(u5, v5), Q3(u6, v6) respectively. Then, by taking the average, when the machine tool coordinates are (0, 0), the pixel coordinates of the center of the first round hole in the image are P0(u p , v p ) = ((u1 + u2 + u3) / 3, (v1 + v2 + v3) / 3), and the pixel coordinates of the center of the second round hole are Q0(u Q , v Q ) = ((u4 + u5 + u6) / 3, (v4 + v5 + v6) / 3). The scale length of the image can be obtained from the ratio of the actual distance between the centers of the two round holes and the pixel distance between the corresponding pixel coordinates in the image: And according to the pixel offset between the pixel coordinates of the center of the first round hole in the image and the center of the image, and the scale length of the image, the actual offset between the camera coordinate system and the machine tool coordinate system can be obtained as (U, V) = D (P,Q) ((u P - u / 2), (vP -v2. Then, based on the pixel coordinates of the two round holes, the deflection angle w of the camera coordinate system relative to the machine tool coordinate system can be obtained as w = arctan((u Q -u P ) / (v Q -v P ))), thereby the mutual relationship between the camera coordinate system and the machine tool coordinate system can be obtained, and the conversion relationship between the two is as follows:
[0153]
[0154] In this embodiment, w is set according to the actual situation.
[0155] S5: Determine the precise positioning information of the workpiece in the machine tool coordinate system including position and angle. Substitute the known parameters into the matrix formula according to the matrix formula in step S4, and the precise positioning information of the workpiece in the machine tool coordinate system including position and angle can be obtained.
[0156] The actual usage process of this embodiment on a machine tool with a cutting head: Use the cutting head to drill a round hole on the workpiece as the first positioning point, and set the machine tool coordinate at this time as the origin. Control the cutting head to move a distance of w in the positive Y-axis direction and then drill a second round hole as the second positioning point, and then move the cutting head back to the position when the first hole was drilled. Then control the cutting head to move in the Z-axis direction to a height where the field of view of the camera can include the two round holes (preferably the camera collects the image information of the workpiece to be measured at the first acquisition point), and use the camera to take three consecutive photos at the current position. The pixel coordinates of the center of the first round hole in the detected corresponding images are P1(u1, v1), P2(u2, v2), P3(u3, v3) respectively, and the pixel coordinates of the center of the second round hole are Q1(u4, v4), Q2(u5, v5), Q3(u6, v6) respectively. Then, by taking the average value, when the machine tool coordinate is (0, 0), the pixel coordinates of the center of the first round hole in the image are P0(u p , v p ) = ((u1 + u2 + u3) / 3, (v1 + v2 + v3) / 3), and the pixel coordinates of the center of the second round hole are Q0(u Q , v Q ) = ((u4 + u5 + u6) / 3, (v4 + v5 + v6) / 3). According to the ratio of the actual distance between the centers of the two round holes and the pixel distance between the corresponding pixel coordinates in the image, the scale length of the image can be obtained as: The pixel coordinates of the center point of the image in the pixel coordinate system are (u0, v0) = (u / 2, v / 2). According to the pixel offset between the pixel coordinates of the first round hole in the image and the center point of the image, and the scale length of the image, the actual offset between the camera coordinate system and the machine tool coordinate system can be obtained as (U, V) = (S × (u P - u0), S × (v P - v0)). Then, according to the pixel coordinates of the two round holes, the deflection angle θ of the camera coordinate system relative to the machine tool coordinate system can be obtained as θ = arctan((u Q - u P ) / (v Q - v P ))). Thus, the mutual relationship between the camera coordinate system and the machine tool coordinate system can be obtained, and the coordinate transformation formula between the two is as follows:
[0157]
[0158] (X, Y): The machine tool coordinates corresponding to the pixel points of the workpiece image; (X c , Y c ): The coordinates in the camera coordinate system corresponding to the pixel points of the workpiece image; θ: The deflection angle of the camera coordinate system relative to the machine tool coordinate system; (U, V): The actual offset between the camera coordinate system and the machine tool coordinate system.
[0159] Combined with the imaging principle of the camera, according to the image scale S and the coordinates (u0, v0) of the image coordinate origin in the pixel coordinate system, the mutual relationship between the camera coordinates (X c , Y c ) and the pixel coordinates (u, v) of the first image can be obtained, and the coordinate transformation formula is as follows:
[0160]
[0161] According to the mutual relationship between the pixel coordinate system of the first image and its corresponding camera coordinate system, and the mutual relationship between the camera coordinate system and the machine tool coordinate system, the mutual relationship between the pixel coordinate system of the first image and the machine tool coordinate system can be obtained, so as to associate the pixel coordinate system of the entire workpiece mosaic image with the machine tool coordinate system. The coordinate transformation formula between the two is as follows:
[0162]
[0163] Furthermore, the following formula can be obtained:
[0164]
[0165] Set w = 200mm to test the formula of this embodiment;
[0166] (1) Use a cutting head to drill a round hole in the steel plate, and set the machine coordinates at this time as the origin (0, 0).
[0167] (2) Control the cutting head to perform a vector movement in the positive Y-axis direction, and drill a second round hole at the position where the machine coordinates are (0, 200).
[0168] (3) Move the cutting head back to the position where the first hole was drilled again, and then control the cutting head to move in the Z-axis direction to a height where the field of view of the camera can include the two round holes. Continuously take pictures 3 times at the current position using the camera, and detect the sub-pixel coordinates of the centers of the two round holes in the three images.
[0169] By comparing the pixel coordinates extracted from each image, it can be found that the pixel coordinates extracted for the same point are not exactly the same. Therefore, the average value of the pixel coordinates is taken here.
[0170] (4) By detecting the pixel coordinates and taking the average value, the sub-pixel coordinates of the center of the first round hole in the image are obtained as (592.514, 770.605), the sub-pixel coordinates of the center of the second round hole are (585.474, 355.287), and the sub-pixel corner coordinates of the upper left corner of the steel plate are (19.545, 51.587). According to the sub-pixel coordinates of the centers of the first and second round holes, the pixel distance between the two points can be obtained as 415.37766 px, and the actual distance between the two points is 200 mm. The scale S of the image can be obtained as 0.4815 mm / px, and the deflection angle θ of the machine coordinate system relative to the camera coordinate system can also be obtained as θ = arctan(7.04 / 415.318) = 0.97°. Given that the size of the image is (605, 806), the center point coordinates (u0, v0) of the image = (302.5, 403). The offset of the center point of the first round hole to the center point of the image can be obtained as (290.014, 367.605). Then, according to the scale of the image, the offset (U, V) of the machine coordinate system relative to the camera coordinate system can be obtained as (139.642, 177.002). Substitute S = 0.4815 mm / px, (u0, v0) = (302.5, 403), (U, V) = (139.642, 177.002), and θ = 0.97° into the following transformation formula between the machine coordinates and the image pixel coordinates:
[0171]
[0172] Get:
[0173]
[0174] (5) Verification: Substitute the pixel coordinates (592.514, 770.605) of the center of the first round hole into the coordinate transformation formula to obtain the machine coordinates (-0.017, -0.052); substitute the pixel coordinates (585.474, 355.287) of the center of the second round hole into the coordinate transformation formula to obtain the machine coordinates (-0.021, 200.016); substitute the pixel coordinates (19.545, 51.587) of the corner point at the upper left corner of the steel plate into the coordinate transformation formula to obtain the machine coordinates (-269.984, 350.830). Control the cutting head to move to the position with the machine coordinates (-269.984, 350.830), and it is found that the cutting head is just above the upper left corner of the steel plate. Therefore, the coordinate transformation formula between the image pixel coordinates and their corresponding machine coordinates proposed in this paper is established.
[0175] In addition, a third hole can be drilled on the workpiece within the image range and the machine coordinates at this time can be recorded. Use the image acquisition device to continuously take pictures of these three round holes, detect the pixel coordinates of the centers of the round holes and take the average value. The pixel coordinates of the first and second round holes are used to calculate the coordinate transformation formula between the image pixel coordinates and the machine coordinates. Substitute the pixel coordinates of the third hole into the formula to obtain the corresponding machine coordinates, and compare them with the recorded machine coordinates to further verify the accuracy of the coordinate transformation formula. Drill a fourth hole on the workpiece outside the image range and record the machine coordinates at this time. Collect the workpiece image information by multi-point image acquisition of the workpiece and perform image stitching. Detect the pixel coordinates of the centers of the four round holes on the stitched image. Substitute the pixel coordinates of the fourth round hole into the above coordinate transformation formula to obtain the corresponding machine coordinates, and then compare them with the recorded machine coordinates to verify whether the coordinate transformation formula is applicable to the stitched image of the entire workpiece.
[0176] It should be noted that the first positioning point and the second positioning point are feature points marked on the workpiece to be measured. In this embodiment, the first positioning point and the second positioning point are round hole-shaped structures. In other embodiments, they can also be corner points or intersection points. Such positioning features usually occupy multiple pixels, and their edges are smooth and blurred. However, the pixel area occupied by a positioning feature cannot be used as the coordinates of the positioning point. Usually, it is necessary to calculate the coordinates corresponding to the center position of the positioning feature area or the position where the gray level change of the positioning feature area is the strongest. The gray level distribution feature of the pixel area occupied by a positioning feature shows that the gray level change is the strongest at the center, and it will weaken as the distance from the center increases. This embodiment uses a sub-pixel positioning algorithm to achieve precise positioning of the positioning feature, and the prerequisite condition of this algorithm is that the positioning target is not a single pixel point, but must be composed of pixel points with a certain gray level distribution and distribution shape.
[0177] Implementation steps of the sub-pixel positioning algorithm:
[0178] (1) Coarse positioning: Use the Shi-Tomasi corner detection algorithm to find a pixel within the pixel region occupied by the positioning feature as the target range of the fixed-point coordinates. The center of this pixel can be used as the coordinate with pixel-level accuracy of the positioning point, thereby achieving coarse positioning of the positioning point.
[0179] (2) Determine the search area: To improve accuracy and reduce computational complexity, taking the pixel determined by the original coarse positioning as the center, add M pixels to the left and right columns respectively, and add N pixels to the top and bottom rows respectively, to form a rectangular search area with a width of 2M + 1 pixels and a height of 2N + 1 pixels.
[0180] (3) Fine positioning: Select a suitable sub-pixel subdivision algorithm according to the characteristics of pixel gray-scale change and distribution within the search area for fine positioning to obtain the coordinates of the positioning point with sub-pixel accuracy. Sub-pixel subdivision algorithms include several algorithms, moment estimation methods, and interpolation methods; geometric methods include the centroid method and the gray-scale centroid method; moment estimation methods include the spatial moment method, the gray-scale moment method, and the orthogonal moment method; interpolation methods include linear interpolation, curve interpolation, and polynomial interpolation.
[0181] Using the sub-pixel positioning algorithm, the coordinates of two positioning features with sub-pixel accuracy in the image information can be detected to achieve precise positioning of the positioning features; the preferred method is to take multiple images at the same position, and the coordinates of the positioning point obtained are the average of the sub-pixel coordinates of the positioning point obtained from multiple images. Then consider the case where the positioning feature in this embodiment is a circular hole feature. If we want to find the center of the circular hole feature as the positioning point coordinates to achieve precise positioning, we need to use the template matching algorithm to find a target area (usually a rectangle) to achieve coarse positioning, then obtain the contour of the circular hole through the contour extraction algorithm, and then use the sub-pixel edge detection technology to further extract the sub-pixel points of the edge. Finally, use the robust least squares circle fitting method to calculate the coordinates of the center of the circular hole feature with sub-pixel accuracy.
[0182] It should be noted that before obtaining the image scale, in order to ensure equal-precision imaging of the workpiece to be measured, the collected image needs to be corrected for distortion, and the imaging plane of the camera should be parallel to the measured plane. In this embodiment, the method of calibrating the camera parameters is used to establish a mathematical model of a non-distorted zoom plane projection parallel to the measurement plane, thereby realizing equal-precision mapping of pixel points and eliminating image distortion.
[0183] In addition, the image can also be corrected for distortion according to the internal parameter matrix and distortion coefficient of the camera obtained by calibration, and then the Euler angle sequence transformation is performed on the external parameter matrix to obtain the deflection angles of the camera coordinate system relative to the machine tool coordinate system in the X, Y, and Z axis directions. Through the two-degree-of-freedom fine-tuning device, the deflection angles in the X and Y axis directions are both less than the threshold value, so that the optical center of the camera is perpendicular to the measured plane, thereby realizing the alignment of the camera.
[0184] Embodiment Three:
[0185] This embodiment provides a machine tool, which includes a machine tool body, an image acquisition device for controlling the machine tool to drive it to perform vector motion, and a processor. The processor executes the precise positioning method for the position of the workpiece on the machine tool in Embodiment One or Embodiment Two above. The precise positioning method for the position of the workpiece on the machine tool can enable the rapid and precise positioning of the position of the workpiece on the machine tool. It is worth mentioning that a machine tool also includes a supplementary lighting device. The supplementary lighting device includes a moving bracket and a light source. The light source is installed on the moving bracket. The moving bracket is placed at a suitable position on the machine tool for the light source to perform supplementary lighting on the workpiece to be measured. The supplementary lighting device is added outside the machine tool. The light source irradiates on the workpiece, highlighting the edge features of the workpiece to be measured, which is convenient for the image acquisition device to collect the image information of the workpiece to be measured.
[0186] Embodiment Four:
[0187] This embodiment provides a storage medium storing computer-readable instructions. When the computer-readable instructions are executed by one or more processors, the one or more processors execute the precise positioning method for the position of the workpiece on the machine tool in Embodiment One or Embodiment Two above. The storage medium in this embodiment can be connected to the control system of the existing machine tool, enabling the existing machine tool to achieve the precise positioning of the position of the workpiece on the machine tool.
[0188] Embodiment Five:
[0189] This embodiment provides a vision system, including: an image receiving module: used to receive the multi-point images of the workpiece to be measured collected by the image acquisition device, and send the multi-point image information of the workpiece to be detected on the machine tool operation table obtained thereby; an image stitching module: used to stitch these image information, and then extract the contour information of the workpiece to obtain the pixel coordinate information of the workpiece image; a correlation module: used to obtain the mutual relationship between the pixel coordinate system of the workpiece image and the machine tool coordinate system according to the correlation information between the camera coordinate and the machine tool coordinate, and the correlation information between the pixel coordinate system of the workpiece image and the camera coordinate system where the image acquisition device is located; a positioning information determination module: determine the precise positioning information of the workpiece in the machine tool coordinate system including at least one of the position and the angle. In the vision system, the image receiving module receives the images of the workpiece to be measured collected by the image acquisition device at multiple points, transmits them to the image stitching module for image information stitching to obtain the complete contour information of the workpiece, and obtains the pixel coordinate system of the workpiece image. Then, through the correlation module, the pixel coordinate system is correlated with the camera coordinate system, and then the camera coordinate system is correlated with the machine tool coordinate system. Finally, through the positioning information determination module, the workpiece is determined in the machine tool coordinate system to complete the precise positioning of the workpiece on the machine tool. It should be noted that the vision system in this embodiment has a processor for providing arithmetic processing for each module of the vision system. It is worth mentioning that a vision system in this embodiment can be integrated into a program and embedded in the control system of the existing machine tool, so that the existing machine tool can realize the precise positioning of the workpiece on the machine tool.
[0190] The specific embodiments of the present invention have been described above. It should be understood that the present invention is not limited to the above specific embodiments, and for the combined embodiments of one or more of the above embodiments, those skilled in the art can make various changes, modifications or combinations within the scope of the claims, which does not affect the essence of the present invention. Without conflict, the embodiments of the present application and the features in the embodiments can be combined with each other arbitrarily.
Claims
1. A precise positioning method for the position of a workpiece on a machine tool, which is used to associate the workpiece to be measured with the coordinate system of the machine tool, characterized in that Including the following steps: S1: Provide an image acquisition device having a relative positional relationship with the machine tool; S2: Through the image acquisition device, collect the workpiece to be measured at several points to obtain the image information of the workpiece to be measured on the machine tool this time; S3: Through the image information of the workpiece to be measured in step S2, obtain the pixel coordinate information of the image of the workpiece to be measured; In step S2, the image acquisition device collects the workpiece to be measured at a single point to obtain the image information of the workpiece to be measured on the machine tool this time, and the single point is the first acquisition point; At least a first positioning point and a second positioning point are set on the workpiece to be measured within the image range collected at the first acquisition point, and the first positioning point serves as the reference origin of the machine tool coordinate system; S4 includes: According to the image information of the workpiece to be measured collected at the first acquisition point, obtain the pixel coordinates of the image center in pixel coordinates; According to the known distance between the first positioning point and the second positioning point on the machine tool and the distance between the corresponding first positioning point and the second positioning point pixel coordinates in the image, obtain the scale of the image; According to the coordinate offset between the pixel coordinates of the first positioning point and the pixel coordinates of the image center point in the image, and the scale of the image, obtain the offset between the origin of the camera coordinate system and the reference origin of the machine tool coordinate system; When the image acquisition device collects the image information of the workpiece to be measured at a single point, according to the mutual relationship between the pixel coordinate system of the first acquisition point image of the image acquisition device and its corresponding camera coordinate system, and the mutual relationship between the camera coordinate system and the machine tool coordinate system, obtain the mutual relationship between the pixel coordinate system of the first acquisition point image and the machine tool coordinate system, and then associate the pixel coordinate system with the machine tool coordinate system to determine the precise positioning information including the position and angle of the workpiece to be measured in the machine tool coordinate system; Or, In step S2, the image acquisition device collects the workpiece to be measured at multiple points to obtain the image information of the workpiece to be measured on the machine tool this time. The multiple points include the first acquisition point and other acquisition points. At least a first positioning point and a second positioning point are set on the workpiece to be measured within the image range collected at the first acquisition point, and the first positioning point serves as the reference origin of the machine tool coordinate system; step S3 further includes an image stitching process, and the image stitching process is to stitch the image information collected at multiple points in step S2, extract the contour information of the workpiece to be measured, and obtain the pixel coordinate information of the image of the workpiece to be measured; S4 includes: According to the image information of the workpiece to be measured collected at the first acquisition point, obtain the pixel coordinates of the image center in pixel coordinates; According to the known distance that the machine tool moves between the first positioning point and the second positioning point and the distance between the corresponding first positioning point and the second positioning point pixel coordinates in the image, obtain the scale of the image; According to the coordinate offset between the pixel coordinates of the first positioning point and the pixel coordinates of the image center point in the image, and the scale of the image, obtain the offset between the origin of the camera coordinate system and the reference origin of the machine tool coordinate system; When the image acquisition device acquires the image information of the workpiece to be measured through multi-point acquisition, according to the mutual relationship between the pixel coordinate system of the first acquisition point image of the image acquisition device and its corresponding camera coordinate system, and the mutual relationship between the camera coordinate system and the machine tool coordinate system, the mutual relationship between the pixel coordinate system of the first acquisition point image and the machine tool coordinate system is obtained. Then, through the splicing process, the pixel coordinate systems of other acquisition point images except the first acquisition point are converted into the pixel coordinate system of the first acquisition point image, so as to obtain the global pixel coordinate system of the entire workpiece splicing image. Furthermore, the pixel coordinate system is associated with the machine tool coordinate system to determine the accurate positioning information of the workpiece to be measured in the machine tool coordinate system, including position and angle.
2. The precise positioning method for the position of the workpiece on the machine tool according to claim 1, characterized in that The conversion formula between the pixel coordinate system and the camera coordinate system is as follows: = Among them, : The scale length of the image; , : The coordinates of the origin of the image coordinates in the pixel coordinate system of the image; , : Pixel point coordinates in the workpiece image; , : Coordinates in the camera coordinate system corresponding to the pixel points of the workpiece image.
3. The precise positioning method of the workpiece position on the machine tool according to claim 1, characterized in that The coordinate transformation formula between the camera coordinate system and the machine tool coordinate system is as follows: = Among them, : The deflection angle of the camera coordinate system relative to the machine tool coordinate system; : The offset between the camera coordinate system and the machine tool coordinate system; , : The machine tool coordinates corresponding to the pixel points of the workpiece image; , : Coordinates in the camera coordinate system corresponding to the pixel points of the workpiece image.
4. The accurate positioning method for the position of the workpiece on the machine tool according to claim 1, characterized in that Step S1 further includes: setting an industrial light source and a polarizer for illuminating the workpiece to be measured. Step S2 further includes: the industrial light source irradiates the workpiece to be measured unilaterally or multilaterally at a certain angle to highlight the edge features of the workpiece to be measured, so as to be applicable to the imaging occasion of large-size workpieces and reduce the reflection phenomenon of metal workpieces; the polarizer installed on the lens weakens or eliminates the interference of astigmatism, reflection, and glare.
5. The precise positioning method of the workpiece position on the machine tool according to claim 1, characterized in that, The splicing method in step S3 is an image splicing method based on a homography transformation matrix to realize image splicing. The image splicing method based on the homography transformation matrix includes the following steps: Q1: Use the sift feature extraction algorithm to extract the feature points of adjacent images. Q2: Use the KNN matching algorithm to perform feature matching on the feature points in adjacent images. Q3: Use the RANSAC algorithm to purify the feature matching pairs and eliminate the wrong matching pairs. Q4: Then calculate the homography transformation matrix of the two images according to the purified feature matching pairs. Q5: Project the second image onto the first image according to the homography transformation matrix of the two images to complete the splicing of the two images. Repeat the above operation steps to finally obtain the complete workpiece splicing image.
6. The precise positioning method of the workpiece position on the machine tool according to claim 1, characterized in that, It further includes: For the workpiece with unclear features, the following methods are used to add feature points: A1: Place some feature blocks near the overlapping area of the image to increase the feature points of the image, so as to improve the accuracy and speed of image splicing; A2: Directly add some feature points on the surface of the workpiece in the image overlapping area with a marker pen, which is used for the image splicing scenario where the workpiece surface can be scribed, to improve the splicing speed and accuracy of the image; A3: Use a projector to project a pattern on the surface of the workpiece, thereby increasing the feature points of the workpiece image, reducing the workload of the operator, and improving the splicing speed and accuracy of the image.
7. The precise positioning method for the position of a workpiece on a machine tool according to claim 1, characterized in that, Before step S4, there is a preprocessing process for improving the quality of the image information. The preprocessing process includes the following steps: M1: Image denoising, which is used to eliminate or suppress the influence of noise on the image and realize the smoothing of the image. M2: Image enhancement, which is used to enhance the contrast of the image and make the image clearer. M3: Image correction, which is used to correct the distortion of images.
8. A machine tool, comprising a machine tool body, characterized in that, It further includes: An image acquisition device and a processor for controlling the machine tool to drive it to perform vector motion. The processor executes the precise positioning method of the workpiece on the machine tool as described in any one of claims 1-7. It further includes a supplementary lighting device, which includes a moving bracket and a light source. The light source is installed on the moving bracket, and the moving bracket is placed at a suitable position on the machine tool for the light source to supplement light to the workpiece to be measured.
9. A storage medium storing computer-readable instructions, characterized in that, When the computer-readable instructions are executed by one or more processors, the one or more processors are caused to execute the precise positioning method of the workpiece on the machine tool as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Positioning method and positioning device for workpiece
CN102721364A
Machine vision positioning method for element surface mounting
CN104729406A