Digital rubbing method for curved surface object based on RGB-D camera
By acquiring point clouds through RGB-D cameras and performing normal vector estimation and offset angle calculations, digital printing of curved surface objects is realized, which solves the problem that existing technology cannot handle curved surface objects and achieves high-precision digital printing effects. .
Patent Information
- Application Number
- CN202410736643.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-07
- Publication Date
- 2024-08-30
Smart Images

Figure CN118570389A
Abstract
Description
Technical Field
[0001] The invention relates to the field of digital rubbing, and in particular to a method for performing contactless digital rubbing by using an image processing technology after acquiring an RGB-D image of a curved surface object by an RGB-D camera. Background Art
[0002] As an ancient traditional art, rubbing can copy the text and patterns on cultural relics such as stone tablets and bronzes. The core operation is: soak thin paper in advance and apply it on the rubbing object, use a brush to knock it to fit the rubbing object, and after the paper is dry, use a brush to dip ink and evenly apply it on the paper to obtain a rubbing of the object. Although this manual rubbing technique can ensure the accuracy of rubbing, it has the disadvantages of complex production, easy to be contaminated by ink, high requirements for weather and light environment, time-consuming and labor-intensive.
[0003] How to make high-precision rubbings without damaging cultural relics is a difficult problem. With the development of computer image processing technology and computer vision technology, the method of obtaining cultural relic rubbings by processing images has received widespread attention.
[0004] The current methods involving digital rubbing are:
[0005] Application number: 201410484510.0, title: A method for extracting digital rubbings of stone tablets and stone carvings based on three-dimensional data scanning. The invention patent discloses: using a three-dimensional data scanner to scan stone tablets and stone carvings to establish a 3D model, and proposing a technical solution of using the 3D model to generate a depth map, and then processing the depth map to obtain digital rubbings; this method has a good effect on smooth and flat stone tablets and stone carvings, but cannot rub stone tablets and stone carvings with uneven surfaces and curvatures;
[0006] Application number: 201810601869.X, title: Invention patent for digital rubbing production method, system and storage medium based on triangular mesh model discloses: a technical solution for generating digital rubbings by calculating the vertex height of the three-dimensional mesh of the rubbing object, which is also only applicable to planar rubbing objects;
[0007] Application number: 202311392491.4, name: The invention patent of the method and device for generating digital rubbings of planar inscriptions based on laser point cloud discloses: a technical solution for digitally rubbing the grayscale image calculated by point cloud computing. This method can only be used for rubbing flat objects, but not for rubbing curved objects.
[0008] In summary, the existing digital rubbing solutions are all aimed at digital rubbing of objects with relatively flat surfaces such as stone tablets, but do not solve the problem of how to digitally rubbing objects with curved surfaces such as cylinders. Summary of the invention
[0009] The present invention aims to overcome the above-mentioned shortcomings of the prior art and provides a digital rubbing method for curved objects based on an RGB-D camera. The present invention comprises the following steps:
[0010] A method for digital rubbing of curved surface objects based on an RGB-D camera, using an RGB-D camera to photograph a rubbing object, using an RGB image and a depth image to generate a point cloud, estimating a normal vector of the point cloud, using the point cloud normal vector and the Z axis to calculate the point cloud offset angle, classifying, rotating and translating the point cloud according to the offset angle, and projecting the adjusted point cloud to generate a digital rubbing; specifically comprising the following steps:
[0011] Step 1: Use an RGB-D camera to shoot the rubbing object to generate an RGB image and a depth image, where the height of the RGB image is H and the width is W, and the unit is pixel;
[0012] Step 2: Use Zhang Zhengyou's chessboard calibration method to obtain the RGB-D camera intrinsic parameter matrix M;
[0013] Step 3: Calculate the 3D point cloud PCD of the RGB image and depth image;
[0014] Step 4: For each coordinate point p in the three-dimensional point cloud PCD i Perform normal vector estimation to obtain the normal vector set V;
[0015] Step 5: Calculate each normal vector in the set V The angle g with the Z axis i , stored in the set G;
[0016] Step 6: Calculate the coordinates of each point p i The offset angle between the coordinate axis and the coordinate axis is classified according to the offset angle to obtain set B t ;
[0017] Step 7: Traverse set B t , for set B t Point p in tj Perform rotation and translation to obtain set C t ;
[0018] Step 8: Set C t Perform two-dimensional projection to obtain the digital rubbing P.
[0019] Furthermore, in step 2, where f x =f / d x , f y =f / d y , f is the focal length of the camera, in millimeters, d xis the width of a single pixel in the x direction, in millimeters per pixel, d y is the width of a single pixel in the y direction, in millimeters per pixel; (c x ,c y ) represents the image center coordinates.
[0020] Furthermore, in step 3, the three-dimensional point cloud PCD is calculated according to formula (1) = {p i =(x i ,y i ,z i ),cl i =(r i ,g i ,b i )|i=1,2,…,H×W};
[0021]
[0022] Among them, (x i ,y i ,z i ) represents the three-dimensional coordinates of the i-th point; (u i ,v i ) represents the coordinates of the i-th pixel in the RGB image; (r i ,g i ,b i ) represents the coordinates (u i ,v i ) pixel value of the pixel at ; M -1 represents the inverse matrix of the camera intrinsic parameter matrix M; d i Denotes the coordinates in the depth image (u i ,v i ) is the pixel value of the pixel at .
[0023] Furthermore, in step 4, the normal vector set i=1,2,…,H×W}; The specific process of step 4 is as follows:
[0024] Step 4.1: Calculate each point p in the point cloud PCD according to formula (2): i To the remaining points p r The distance between ir , where r = 1, 2, ..., W × H, and i ≠ r, select d ir The smallest Q points constitute the set PC i ={pc ij =(x ij ,y ij ,z ij )|j=1,2,…,Q};
[0025]
[0026] Among them, (x i ,y i ,z i ) represents point p i The coordinates of (x r ,y r ,z r ) represents point p r The coordinates of
[0027] Step 4.2: According to formula (3), the set PC i Point pc in ij Perform plane fitting and denote the fitting plane as M i , M i Satisfy condition A i X i =0;
[0028]
[0029] in, Represents the collection PC i The average coordinates of all points in i ,b i ,c i ) represents the fitting plane M i The normal vector of
[0030] Step 4.3: For matrix A i Perform singular value decomposition A i =U i D i V i T , and calculate D i The minimum value among the diagonal elements in is the matrix A i The minimum eigenvalue of the minimum eigenvalue, the eigenvector corresponding to the minimum eigenvalue is the coordinate point p i The corresponding normal vector is denoted as Then all and p i Constitute the set V.
[0031] Furthermore, in step 5, each normal vector in the set V is calculated according to formula (4): Angle g with the Z axis i , stored in the set G = {(p i ,g i )|i=1,2,…,H×W}, the calculation formula is:
[0032]
[0033] in, Indicates p i The corresponding normal vector is, express The mold length.
[0034] Furthermore, the specific process of step 6 is as follows:
[0035] Step 6.1: Calculate d from step 4.1 ir , for each point p in the set G i Select d ir The smallest K points are taken as p i The bias calculation point p ik , p ik The corresponding angle in the set G is denoted by g ik , forming the set U i ={(p ik ,d ik ,g ik )|k=1,2,3,…,K};
[0036] Step 6.2: Traverse the set U i , calculate point p according to formula (5) i The offset angle gt i , forming a set Y = {(p i ,gt i )|i=1,2,…,H×W};
[0037]
[0038] Among them, avg means calculating the average value of the set elements, s, m, l respectively represent the short distance threshold, medium distance threshold, and long distance threshold, and the unit is millimeter;
[0039] Step 6.3: Set point p in set Y i Divided into e categories, e ≥ 18, the points in the tth category constitute set B t , t=1,2,…,e, as shown in formula (6);
[0040]
[0041] Among them, p tj Indicates B t The jth point in gt tj Indicates p tj Corresponding offset angle, n t Indicates B t The number of coordinate points in .
[0042] Furthermore, the specific process of step 7 is as follows:
[0043] Step 7.1: According to formula (3), t Fit a plane to all points in the image and calculate the normal vector to the fitted plane The fitting plane satisfies condition A i X i =0;
[0044] Step 7.2: Calculate the point cloud rotation matrix RM according to formula (7) t ;
[0045]
[0046] in, sinθ>0, express The modulus of θ represents the normal vector The angle with the unit vector in the positive direction of the Z axis;
[0047] Step 7.3: Calculate set B according to formula (8) t The point (x tj ,y tj ,z tj )The rotated coordinates (rx tj ,ry tj ,rz tj ), forming a set C t ;
[0048]
[0049] Furthermore, the specific process of step 8 is as follows:
[0050] Step 8.1: According to formula (9), C t The three-dimensional point cloud coordinates (rx tj ,ry tj ,rz tj ) is converted to the corresponding two-dimensional coordinates (u tj ,v tj ), find the corresponding three-dimensional coordinate (rx tj ,ry tj ,rz tj ) corresponding to the pixel value (r tj ,g tj ,b tj ), all (u tj ,v tj ) and (r tj ,g tj ,b tj ) constitutes the set D t ={((u tj ,v tj ),(r tj ,gtj ,b tj ))|j=1,2,…,n t};
[0051]
[0052] Step 8.2: Generate a blank image P of size W×H with all pixel values (0,0,0) according to equation (10). t All pixel values (r tj ,g tj ,b tj ) is assigned to the coordinates (u tj ,v tj ) corresponding to the pixel.
[0053] By adopting the above technology, compared with the prior art, the beneficial effects of the present invention are as follows:
[0054] The present invention generates a point cloud by using an RGB image and a Depth image obtained by an RGB-D camera. For each point in the point cloud, its K neighboring points are used as offset angle calculation points. The offset angle of the point is obtained by performing an average weighted summation according to the angle between the offset angle calculation point and the coordinate axis according to the distance. Compared with directly calculating the angle according to the normal vector, the error caused by the normal vector estimation can be effectively eliminated. The calculated offset angle is classified into intervals, and the point cloud of each interval is rotationally corrected. The point cloud is unfolded into a plane point cloud, so that objects with curved surfaces such as cylinders can be digitally printed. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] Figure 1 The rubbing object image is selected for the embodiment of the present invention.
[0056] Figure 2 This is the three-dimensional point cloud image processed by step 3 of the present invention.
[0057] Figure 3 This is the normal vector estimation image processed by step 4 of the present invention.
[0058] Figure 4 This is the point cloud classification image processed by step 6 of the present invention.
[0059] Figure 5 This is the digital rubbing image processed by step 8 of the present invention. DETAILED DESCRIPTION
[0060] The specific implementation of the curved surface digital rubbing method based on RGB-D camera of the present invention is described in detail below with reference to embodiments.
[0061] Step 1: Use an RGB-D camera to shoot the rubbing object to generate an RGB image and a depth image, where the height of the RGB image is H and the width is W, and the unit is pixel. In this embodiment, the rubbing object is as follows: Figure 1 As shown;
[0062] Step 2: Use Zhang Zhengyou's chessboard calibration method to obtain the RGB-D camera intrinsic parameter matrix:
[0063] where f x =f / d x , f y =f / d y , f is the focal length of the camera, in millimeters, d x is the width of a single pixel in the x direction, in millimeters per pixel, d y is the width of a single pixel in the y direction, in millimeters per pixel; (c x ,c y ) represents the image center coordinates;
[0064] Step 3: Calculate the 3D point cloud PCD of the RGB image and the depth image according to formula (1) = {p i =(x i ,y i ,z i ),cl i =(r i ,g i ,b i )|i=1,2,…,H×W};
[0065]
[0066] Among them, (x i ,y i ,z i ) represents the three-dimensional coordinates of the i-th point; (u i ,v i ) represents the coordinates of the i-th pixel in the RGB image; (r i ,g i ,b i ) represents the coordinates (u i ,v i ) pixel value of the pixel at ; M -1 represents the inverse matrix of the camera intrinsic parameter matrix M; d i Denotes the coordinates in the depth image (u i ,v i ) pixel value of the pixel at the position; in this example, the three-dimensional point cloud PCD calculated is as follows Figure 2 As shown;
[0067] Step 4: For each coordinate point p in the three-dimensional point cloud PCD i Perform normal vector estimation to obtain a normal vector set This example uses this method to calculate the normal vector as follows Figure 3 As shown, the specific operations are:
[0068] Step 4.1: Calculate each point p in the point cloud PCD according to formula (2): i To the remaining points p r The distance between ir , where r = 1, 2, ..., W × H, and i ≠ r, select d ir The smallest Q points constitute the set PC i ={pc ij =(x ij ,y ij ,z ij )|j=1,2,…,Q};
[0069]
[0070] Among them, (x i ,y i ,z i ) represents point p i The coordinates of (x r ,y r ,z r ) represents point p r The coordinates of
[0071] Step 4.2: According to formula (3), the set PC i Point pc in ij Perform plane fitting and record the fitting plane as M i , M i Satisfy condition A i X i =0;
[0072]
[0073] in, Represents the collection PC i The average coordinates of all points in i ,b i ,c i ) represents the fitting plane M i The normal vector of
[0074] Step 4.3: For the matrix A i Perform singular value decomposition A i =U i D i V i TAnd calculate D i The minimum value among the diagonal elements in is the matrix A i The minimum eigenvalue of the minimum eigenvalue, the eigenvector corresponding to the minimum eigenvalue is the coordinate point p i The corresponding normal vector is denoted as Then all and p i Constitute a set V;
[0075] Step 5: Calculate each normal vector in the set V according to formula (4) The angle g with the Z axis i , stored in the set G = {(p i ,g i )|i=1,2,…,H×W}, the calculation formula is:
[0076]
[0077] in, Indicates p i The corresponding normal vector is, express The module length;
[0078] Step 6: Calculate the coordinates of each point p i The offset angle between the coordinate axis and the coordinate axis is used for classification. In this example, the classification results are as follows: Figure 4 As shown, the specific steps are as follows:
[0079] Step 6.1: Calculate d from step 4.1 ir , for each point p in the set G i Select d ir The smallest K points are taken as p i The bias calculation point p ik , p ik The corresponding angle in the set G is denoted by g ik , forming the set U i ={(p ik ,d ik ,g ik )|k=1,2,3,…,K};
[0080] Step 6.2: Traverse the set U i , calculate point p according to formula (5) i The offset angle gt i , forming a set Y = {(p i ,gt i )|i=1,2,…,H×W};
[0081]
[0082] Among them, avg means calculating the average value of the set elements, s, m, l respectively represent the short distance threshold, medium distance threshold, and long distance threshold, and the unit is millimeter;
[0083] Step 6.3: Set the point p of the set Y i Divide into 18 categories, and the points in the tth category constitute set B t , t=1,2,…,18, as shown in formula (6);
[0084]
[0085] Among them, p tj Indicates B t The jth point in gt tj Indicates p tj Corresponding offset angle, n t Indicates B t The number of coordinate points in
[0086] Step 7: Traverse set B t , for set B t Point p in tj To perform rotation and translation, the specific operations are as follows:
[0087] Step 7.1: According to formula (3), t Fit a plane to all points in the image and calculate the normal vector to the fitted plane
[0088] Step 7.2: Calculate the point cloud rotation matrix RM according to formula (7) t ;
[0089]
[0090] in, sinθ>0, express The modulus of θ represents the normal vector The angle between the positive unit vector of the Z axis and the positive unit vector of the Z axis; Step 7.3: Calculate the set B according to formula (8) t The point (x tj ,y tj ,z tj )The rotated coordinates (rx tj ,ry tj ,rz tj ), forming a set C t ;
[0091]
[0092] Step 8: Set C tPerform two-dimensional projection to obtain a digital rubbing P. The digital rubbing obtained by this method in this example is as follows: Figure 5 As shown, the steps are as follows:
[0093] Step 8.1: According to formula (9), C t The three-dimensional point cloud coordinates (rx tj ,ry tj ,rz tj ) is converted to the corresponding two-dimensional coordinates (u tj ,v tj ), find the corresponding three-dimensional coordinate (rx tj ,ry tj ,rz tj ) corresponding to the pixel value (r tj ,g tj ,b tj ), all (u tj ,v tj ) and (r tj ,g tj ,b tj ) constitutes the set D t ={((u tj ,v tj ),(r tj ,g tj ,b tj ))|j=1,2,…,n t};
[0094]
[0095] Step 8.2: Generate a blank image P of size W×H with all pixel values (0,0,0) and set all D t All pixel values (r tj ,g tj ,b tj ) is assigned to the coordinates (u tj ,v tj ) corresponding to the pixel.
[0096] The contents described in the embodiments of this specification are merely an enumeration of implementation forms of the inventive concept. The protection scope of the present invention should not be regarded as limited to the specific forms described in the embodiments. The protection scope of the present invention also extends to equivalent technical means that can be conceived by those skilled in the art based on the inventive concept.
Claims
1. A method for digital rubbing of curved objects based on an RGB-D camera, characterized in that: Use an RGB-D camera to photograph the object to be rubbed, use the RGB image and depth image to generate a point cloud, estimate the normal vector of the point cloud, use the point cloud normal vector and Z axis to calculate the point cloud offset angle, classify the point cloud according to the offset angle, rotate and translate, and project the adjusted point cloud to generate a digital rubbing; The specific steps include: Step 1: Use an RGB-D camera to shoot the rubbing object to generate an RGB image and a depth image, where the height of the RGB image is H and the width is W, and the unit is pixel; Step 2: Use Zhang Zhengyou's chessboard calibration method to obtain the RGB-D camera intrinsic parameter matrix M; Step 3: Calculate the 3D point cloud PCD of the RGB image and depth image; Step 4: For each coordinate point p in the three-dimensional point cloud PCD i Perform normal vector estimation to obtain the normal vector set V; Step 5: Calculate each normal vector in the set V Angle g with the Z axis i , stored in the set G; Step 6: Calculate the coordinates of each point p i The offset angle between the coordinate axis and the coordinate axis is classified according to the offset angle to obtain set B t ; Step 7: Traverse set B t , for set B t Point p in tj Rotate and translate to get set C t ; Step 8: Set C t Perform two-dimensional projection to obtain the digital rubbing P.
2. The method for digital rubbing of curved surface objects based on an RGB-D camera according to claim 1, characterized in that: In the step 2, where f x =f / d x , f y =f / d y , f is the focal length of the camera, in millimeters, d x is the width of a single pixel in the x direction, in millimeters per pixel, d y is the width of a single pixel in the y direction, in millimeters per pixel; (c x ,c y ) represents the image center coordinates.
3. The method for digital rubbing of curved surface objects based on an RGB-D camera according to claim 2, characterized in that: In step 3, the three-dimensional point cloud PCD is calculated according to formula (1) i =(x i ,y i ,z i ),cl i =(r i ,g i ,b i )|i=1,2,…,H×W}; Among them, (x i ,y i ,z i ) represents the three-dimensional coordinates of the i-th point; (u i ,v i ) represents the coordinates of the i-th pixel in the RGB image; (r i ,g i ,b i ) represents the coordinates (u i ,v i ) pixel value of the pixel at ; M -1 represents the inverse matrix of the camera intrinsic parameter matrix M; d i Denotes the coordinates in the depth image (u i ,v i ) is the pixel value of the pixel at .
4. The method for digital rubbing of curved surface objects based on an RGB-D camera according to claim 3, characterized in that: In step 4, the normal vector set The specific process of step 4 is as follows: Step 4.1: Calculate each point p in the point cloud PCD according to formula (2): i To the remaining points p r The distance between ir , where r = 1, 2, ..., W × H, and i ≠ r, select d ir The smallest Q points constitute the set PC i ={pc ij =(x ij ,y ij ,z ij )|j=1,2,…,Q}; Among them, (x i ,y i ,z i ) represents point p i The coordinates of (x r ,y r ,z r ) represents point p r The coordinates of Step 4.2: According to formula (3), the set PC i Point pc in ij Perform plane fitting and denote the fitting plane as M i , M i Satisfy condition A i X i =0; in, Represents the collection PC i The average coordinates of all points in i ,b i ,c i ) represents the fitting plane M i The normal vector of Step 4.3: For the matrix A i Perform singular value decomposition A i =U i D i V i T , and calculate D i The minimum value among the diagonal elements in is the matrix A i The minimum eigenvalue of the minimum eigenvalue, the eigenvector corresponding to the minimum eigenvalue is the coordinate point p i The corresponding normal vector is denoted as Then all and p i Constitute the set V.
5. The method for digital rubbing of curved surface objects based on an RGB-D camera according to claim 4, characterized in that: In step 5, each normal vector in the set V is calculated according to formula (4): Angle g with the Z axis i , stored in the set G = {(p i ,g i )|i=1,2,…,H×W}, the calculation formula is: in, Indicates p i The corresponding normal vector is, express The mold length.
6. The method for digital rubbing of curved surface objects based on an RGB-D camera according to claim 5, characterized in that: The specific process of step 6 is as follows: Step 6.1: Calculate d from step 4.1 ir , for each point p in the set G i Select d ir The smallest K points are taken as p i The bias calculation point p ik , p ik The corresponding angle in the set G is denoted by g ik , forming the set U i ={(p ik ,d ik ,g ik )|k=1,2,3,…,K}; Step 6.2: Traverse the set U i , calculate point p according to formula (5) i The offset angle gt i , forming a set Y = {(p i ,gt i )|i=1,2,…,H×W}; Among them, avg means calculating the average value of the set elements, s, m, and l respectively represent the short-distance threshold, medium-distance threshold, and long-distance threshold, and the unit is millimeter; Step 6.3: Set point p in set Y i Divided into e categories, e ≥ 18, the points in the tth category constitute set B t , t=1,2,…,e, as shown in formula (6); Among them, p tj Indicates B t The jth point in gt tj Indicates p tj Corresponding offset angle, n t Indicates B t The number of coordinate points in .
7. The method for digital rubbing of curved surface objects based on RGB-D camera according to claim 6, characterized in that: The specific process of step 7 is as follows: Step 7.1: According to formula (3), t Fit a plane to all points in the image and calculate the normal vector to the fitted plane The fitting plane satisfies condition A i X i =0; Step 7.2: Calculate the point cloud rotation matrix RM according to formula (7) t ; in, express The modulus of θ represents the normal vector The angle with the unit vector in the positive direction of the Z axis; Step 7.3: Calculate set B according to formula (8) t The point (x tj ,y tj ,z tj )The rotated coordinates (rx tj ,ry tj ,rz tj ), forming a set C t ; 8. The method for digital rubbing of curved surface objects based on an RGB-D camera according to claim 7, characterized in that: The specific process of step 8 is as follows: Step 8.1: According to formula (9), C t The three-dimensional point cloud coordinates (rx tj ,ry tj ,rz tj ) is converted to the corresponding two-dimensional coordinates (u tj ,v tj ), find the corresponding three-dimensional coordinate (rx tj ,ry tj ,rz tj ) corresponding to the pixel value (r tj ,g tj ,b tj ), all (u tj ,v tj ) and (r tj ,g tj ,b tj ) constitutes the set D t ={((u tj ,v tj ),(r tj ,g tj ,b tj ))|j=1,2,…,n t }; Step 8.2: Generate a blank image P of size W×H with all pixel values (0,0,0) according to equation (10). t All pixel values (r tj ,g tj ,b tj ) is assigned to the coordinates (u tj ,v tj ) corresponding to the pixel.
