RGB-D camera depth image restoration method based on color image combination
Technical Field
The invention belongs to the field of depth image restoration, and relates to an RGB-D depth image restoration method combining color images.
Background
With the development of vision technology, more and more kinds of cameras are applied to display scenes, for example: the common color camera is used for face recognition, the CCD camera is used for obstacle detection, and the Kinect is used for human skeleton tracking and the like. The common two-dimensional plane camera can acquire scene two-dimensional information, and for a three-dimensional display space, the two-dimensional plane camera obviously cannot meet the requirements of practical application. This situation is primarily improved with the advent of RGB-D cameras, such as Kinect published by microsoft, which is very convenient for acquiring depth information while acquiring color images of a scene. With the development of microsoft kinect (natal), the depth camera attracts more and more people's eyes, and can be used in the fields of human body tracking, three-dimensional reconstruction, human-computer interaction, SLAM and the like. However, the depth image obtained by the RGB-D camera generally contains many holes, and the depth information cannot be directly applied to the real application, which greatly affects the application range of the RGB-D camera.
Therefore, an effective depth image restoration method is needed to solve the problem that depth image information obtained by RGB-D has holes and cannot be directly used.
Disclosure of Invention
In view of the above, an object of the present invention is to provide a depth image restoration method for an RGB-D camera combined with a color image, which provides an effective depth image restoration method for solving the problem that depth image information obtained by RGB-D has holes and cannot be directly used.
In order to achieve the purpose, the invention provides the following technical scheme:
a depth image restoration method of an RGB-D camera combining color images comprises the following steps:
s1: calibrating the color camera and the depth camera by adopting a classical Zhang calibration method to obtain internal and external parameters of the camera;
s2: realizing the coordinate alignment of the color camera and the depth camera according to the pinhole imaging principle and the coordinate transformation;
s3: respectively acquiring a scene color image and a depth image, and binarizing the depth image according to a depth threshold method;
s4: judging the size of a depth image hole connected domain to determine that a hole exists;
s5: performing expansion operation on the depth image to obtain a cavity neighborhood;
s6: calculating the variance of the depth values of the pixel points in the cavity field, and dividing the cavity into a shielding cavity and an in-plane cavity according to the variance;
s7: repairing the two types of cavities by adopting color consistency and field similarity according to different cavity types;
s8: and filtering the repaired image by adopting a local filtering method, and removing noise while ensuring the originality of the depth value.
Further, the step S2 specifically includes the following steps:
s21: the rotation matrix R of the color camera is obtained in step S1rgbAnd translation vector TrgbRotation matrix R of depth camerairAnd translation vector Tir(ii) a Let P be a point in the world coordinate system, PrgbAnd PirRespectively, obtaining a relation formula by a pinhole imaging model according to projection coordinate points of P under the color camera and the depth camera:
Prgb=RrgbP+Trgb
Pir=RirP+Tir
s22: let prgbAnd pirThe projection coordinates of the point on the RGB image plane and the depth image plane are respectively represented by an internal reference matrix A of the camerargbAnd AirObtaining:
prgb=ArgbPrgb
pir=AirPir
s23: the coordinates of the depth camera are different from the coordinates of the RGB camera, PrgbAnd PirA rotation matrix R and a translation matrix T are used for being related, and the relationship between the rotation matrix R and the translation matrix T is as follows:
Prgb=RPir+T
s24: cancelling P by the S21 equation yields:
s25: the corresponding terms of simultaneous S23 and S24 equations are equal to obtain R and T:
s26: and (3) combining equations S22 and S23 to finally obtain the corresponding relation between the color image pixel point and the depth image pixel point as follows:
further, the step S3 specifically includes the following steps:
s31: simultaneously acquiring a scene image according to the aligned color camera and depth camera;
s32: the original depth data are quantized, the depth values are converted into gray levels of 0-255, and the quantization formula is as follows:
where depth is the depth value after quantization, DpFor each pixel point's depth value, DmaxIs the maximum depth value;
s33: and carrying out binarization on the obtained depth image according to a depth threshold value method, wherein a formula is expressed as follows:
wherein I (x, y) is the binarized image, depth (x, y) represents the depth value of the pixel point after quantization, DthrTo a binarized depth threshold.
Further, the step S4 specifically includes: after binarization processing of S3, judging the size of a cavity connected domain to distinguish space-time cavities and noise points; if the connected domain is judged to be a hole, continuing the subsequent processing; if not, the subsequent processing is not performed.
Further, the step S5 specifically includes the following steps:
s51: expanding operation H for the cavity judged at S4ep;
S52: obtaining void field HnpThe expression is as follows:
Hnp=Hep-Ho
wherein HoIs a hollow region.
Further, the step S6 specifically includes the following steps:
s61: according to the hole neighborhood obtained in S5, calculating the variance delta of the depth values of the quantized pixel points in the neighborhooddepthThe calculation formula is as follows:
wherein D
iThe depth value of the i pixel points in the hollow domain is represented,
representing the average value of depth values of the cavity field, i representing the number of pixel points, and N representing the total number of pixel points of the cavity field;
s62: neighborhood variance Δ calculated using S61depthAnd a void determination threshold value deltathBy comparison, if the depth variance Δ of the hole neighborhood isdepthLess than ΔthDetermining the hollow in the plane if the number is larger than or equal to deltathThen the occlusion hole is determined.
Further, the step S7 specifically includes: for the cavity judged to be in-plane, namely the cavity is generated by not reflecting infrared light in the object plane, because the cavity exists in a plane, the depth value of the cavity area is similar to the depth of the adjacent pixel points, and the repairing is carried out by utilizing the depth value alignment of the field pixel points; and for the holes judged to be shielded, the holes are generated due to mutual shielding of objects, and for the hole repairing, color images are used for repairing, namely, the depth values of pixel points in the hole neighborhood and the pixel points in the hole area, which have the color close to that of the color images, are found out for repairing.
Further, the step S8 specifically includes: because the hole repaired by the S7 still has fine noise, in order to ensure the originality of the depth data as much as possible and remove the noise, the local upper edge filtering method is adopted to perform image filtering.
The invention has the beneficial effects that: according to the method, the cavities are divided into two types according to a cavity neighborhood variance threshold method, the combined color image is used for repairing the cavities by respectively adopting domain similarity and color consistency, and the images after the cavities are repaired are subjected to noise removal by adopting a local filtering method. Compared with the traditional rough restoration method adopting the bilateral filtering algorithm, the method ensures the effectiveness of the restoration of the depth image and simultaneously ensures the originality of the depth image information as much as possible.
Drawings
In order to make the object, technical scheme and beneficial effect of the invention more clear, the invention provides the following drawings for explanation:
FIG. 1 is a system flow diagram of the present invention;
FIG. 2 is a schematic diagram of hole neighborhood calculation;
FIG. 3 is a schematic diagram of the formation of a blocking void.
Detailed Description
Preferred embodiments of the present invention will be described in detail below with reference to the accompanying drawings.
FIG. 1 is a system flow chart of the present invention, as shown in FIG. 1, a method for repairing RGB-D camera depth image of combined color image, which comprises the steps of firstly realizing the alignment of coordinates of a color camera and a depth camera, carrying out binarization on the quantized depth image according to a depth threshold method, obtaining a cavity neighborhood through expansion operation, calculating a neighborhood variance to judge the type of the cavity, respectively repairing different cavities by adopting domain similarity and color consistency, and finally carrying out image filtering by adopting a local bilateral filtering method.
The method specifically comprises the following steps:
s1: calibrating the color camera and the depth camera by adopting a classical Zhang calibration method to obtain internal and external parameters of the camera;
s2: realizing the coordinate alignment of the color camera and the depth camera according to the pinhole imaging principle and the coordinate transformation;
s3: respectively acquiring a scene color image and a depth image, and binarizing the depth image according to a depth threshold method;
s4: judging the size of a depth image hole connected domain to determine that a hole exists: after binarization processing of S3, judging the size of a cavity connected domain to distinguish space-time cavities and noise points; if the connected domain is judged to be a hole, continuing the subsequent processing; if not, the subsequent processing is not performed.
S5: performing expansion operation on the depth image to obtain a cavity neighborhood;
s6: calculating the variance of the depth values of the pixel points in the cavity field, and dividing the cavity into a shielding cavity and an in-plane cavity according to the variance;
s7: repairing the two types of cavities by adopting color consistency and field similarity according to different cavity types;
for the cavity judged to be in-plane, namely the cavity is generated by not reflecting infrared light in the object plane, because the cavity exists in a plane, the depth value of the cavity area is similar to the depth of the adjacent pixel points, and the repairing is carried out by utilizing the depth value alignment of the field pixel points; for the holes judged to be blocked, the holes are generated due to mutual blocking of the objects, as shown in fig. 3, the holes are repaired by using the color images, that is, the depth values of the pixel points in the vicinity of the holes and in the holes, which are closer to the color of the color images, are found for repairing.
S8: filtering the repaired image by adopting a local filtering method, and removing noise while ensuring the originality of the depth value;
because the hole repaired by the S7 still has fine noise, in order to ensure the originality of the depth data as much as possible and remove the noise, the local upper edge filtering method is adopted to perform image filtering.
Step S2 specifically includes the following steps:
s21: the rotation matrix R of the color camera is obtained in step S1rgbAnd translation vector TrgbRotation matrix R of depth camerairAnd translation vector Tir(ii) a Let P be a point in the world coordinate system, PrgbAnd PirRespectively, obtaining a relation formula by a pinhole imaging model according to projection coordinate points of P under the color camera and the depth camera:
Prgb=RrgbP+Trgb
Pir=RirP+Tir
s22: let pgbrAnd pirThe projection coordinates of the point on the RGB image plane and the depth image plane are respectively represented by an internal reference matrix A of the camerargbAnd AirObtaining:
prgb=ArgbPrgb
pir=AirPir
s23: the coordinates of the depth camera are different from the coordinates of the RGB camera, PrgbAnd PirA rotation matrix R and a translation matrix T are used for being related, and the relationship between the rotation matrix R and the translation matrix T is as follows:
Prgb=RPir+T
s24: cancelling P by the S21 equation yields:
s25: the corresponding terms of simultaneous S23 and S24 equations are equal to obtain R and T:
s26: combining the equations S22 and S23 to obtain the final colorThe corresponding relation between the image pixel point and the depth image pixel point is as follows:
step S3 specifically includes the following steps:
s31: simultaneously acquiring a scene image according to the aligned color camera and depth camera;
s32: the original depth data are quantized, the depth values are converted into gray levels of 0-255, and the quantization formula is as follows:
where depth is the depth value after quantization, DpFor each pixel point's depth value, DmaxIs the maximum depth value;
s33: and carrying out binarization on the obtained depth image according to a depth threshold value method, wherein a formula is expressed as follows:
wherein I (x, y) is the binarized image, depth (x, y) represents the depth value of the pixel point after quantization, DthrTo a binarized depth threshold.
Step S5 specifically includes the following steps:
s51: expanding operation H for the cavity judged at S4ep;
S52: obtaining void field HnpThe expression is as follows:
Hnp=Hep-Ho
wherein HoIs a hollow region. As shown in fig. 2, a 3 × 3 cross-shaped structural element is used to perform an expansion operation on the hole, and the original hole image is subtracted from the expanded image to obtain a hole neighborhood.
Step S6 specifically includes the following steps:
s61: obtaining a hole neighborhood according to S5Calculating the variance delta of the depth value after the quantization of the pixel points in the neighborhooddepthThe calculation formula is as follows:
wherein D
iThe depth value of the i pixel points in the hollow domain is represented,
representing the average value of depth values of the cavity field, i representing the number of pixel points, and N representing the total number of pixel points of the cavity field;
s62: neighborhood variance Δ calculated using S61depthAnd a void determination threshold value deltathBy comparison, if the depth variance Δ of the hole neighborhood isdepthLess than ΔthDetermining the hollow in the plane if the number is larger than or equal to deltathThen the occlusion hole is determined.
Finally, it is noted that the above-mentioned preferred embodiments illustrate rather than limit the invention, and that, although the invention has been described in detail with reference to the above-mentioned preferred embodiments, it will be understood by those skilled in the art that various changes in form and detail may be made therein without departing from the scope of the invention as defined by the appended claims.