CN108564604A - Binocular vision solid matching method and device based on plane restriction and triangulation - Google Patents
Binocular vision solid matching method and device based on plane restriction and triangulation Download PDFInfo
- Publication number
- CN108564604A CN108564604A CN201810252302.6A CN201810252302A CN108564604A CN 108564604 A CN108564604 A CN 108564604A CN 201810252302 A CN201810252302 A CN 201810252302A CN 108564604 A CN108564604 A CN 108564604A
- Authority
- CN
- China
- Prior art keywords
- area
- type
- parallax
- point
- segmented
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/30—Determination of transform parameters for the alignment of images, i.e. image registration
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/10—Segmentation; Edge detection
- G06T7/11—Region-based segmentation
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/10—Segmentation; Edge detection
- G06T7/136—Segmentation; Edge detection involving thresholding
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2207/00—Indexing scheme for image analysis or image enhancement
- G06T2207/10—Image acquisition modality
- G06T2207/10004—Still image; Photographic image
- G06T2207/10012—Stereo images
Landscapes
- Engineering & Computer Science (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Image Processing (AREA)
- Image Analysis (AREA)
Abstract
本发明实施例提供了一种基于平面约束和三角剖分的双目视觉立体匹配方法及装置。该方法包括:获取两个摄像机采集的左右图像,将任一幅作为参考图像;确定参考图像的支持点并计算视差;按预设方式分割参考图像;将各分割区域分为第一类和/或第二类分割区域;将每个第一类分割区域二次分割;根据每个子分割区域的支持点及视差,确定该区域内非支持点的视差;将每个第二类分割区域三角剖分;根据每个三角形区域的顶点及视差确定该区域内非支持点的视差搜索范围;将该范围对应的待匹配点与非支持点逐像素匹配,确定非支持点的视差。本发明能够对遮挡区域及大面积无纹理区域更准确地匹配。且缩小了小面积分割区域的视差搜索范围,提高了匹配效率。
Embodiments of the present invention provide a binocular vision stereo matching method and device based on plane constraints and triangulation. The method includes: obtaining left and right images collected by two cameras, and using any one as a reference image; determining support points of the reference image and calculating parallax; segmenting the reference image in a preset manner; dividing each segmented area into the first category and/or Or the second type of segmentation area; each first type of segmentation area is divided twice; according to the support points and parallax of each sub-segmentation area, the disparity of non-support points in the area is determined; each second type of segmentation area is triangulated According to the vertices and disparity of each triangular area, determine the disparity search range of unsupported points in the area; match the corresponding points in the range with unsupported points pixel by pixel, and determine the disparity of unsupported points. The present invention can more accurately match occluded areas and large-area non-textured areas. In addition, the parallax search range of the small-area segmentation area is reduced, and the matching efficiency is improved.
Description
技术领域technical field
本发明涉及计算机视觉技术领域,特别是涉及一种基于平面约束和三角剖分的双目视觉立体匹配方法及装置。The invention relates to the technical field of computer vision, in particular to a binocular vision stereo matching method and device based on plane constraints and triangulation.
背景技术Background technique
双目立体视觉主要包括四个步骤:双目摄像机标定、获取二维图像对、图像校正、双目视觉立体匹配。其中,双目视觉立体匹配包括:首先用双目摄像机或两个平行放置的摄像机同时拍摄同一物理场景,得到左右图像;然后找到场景中同一目标在左右图像中的投影点,称其为对应点;最后根据对应点的视差,即对应点在像素坐标系u轴方向的偏移量生成视差图。根据所生成的视差图以及相似三角形原理可进一步计算出所拍摄物理场景中所述目标与摄像机的实际距离,该过程也称为立体视觉深度计算。立体视觉深度计算被广泛应用在三维场景重建、移动机器人自主导航等实际应用中,同时在医学成像、工业检测等领域中的应用也越来也广泛。Binocular stereo vision mainly includes four steps: binocular camera calibration, acquisition of two-dimensional image pairs, image correction, and binocular vision stereo matching. Among them, binocular vision stereo matching includes: first, use a binocular camera or two parallel cameras to shoot the same physical scene at the same time to obtain left and right images; then find the projection point of the same target in the scene in the left and right images, which is called the corresponding point ;Finally, a disparity map is generated according to the disparity of the corresponding point, that is, the offset of the corresponding point in the u-axis direction of the pixel coordinate system. The actual distance between the target and the camera in the captured physical scene can be further calculated according to the generated disparity map and the principle of similar triangles. This process is also called stereo vision depth calculation. Stereo vision depth calculation is widely used in practical applications such as 3D scene reconstruction and autonomous navigation of mobile robots. At the same time, it is also widely used in medical imaging, industrial inspection and other fields.
目前常用的双目视觉立体匹配算法有:基于支持窗口的局部算法、基于图像切割或动态规划的全局算法、基于最小生成树的非局部匹配算法等。Currently commonly used binocular vision stereo matching algorithms include: local algorithms based on support windows, global algorithms based on image cutting or dynamic programming, non-local matching algorithms based on minimum spanning trees, etc.
由于所述左右图像从是从不同拍摄角度获得的,不可避免会有遮挡区域或大面积无纹理区域的存在。其中,遮挡区域是指只在一幅图像中可见,在另一幅图像中没有对应像素信息的区域,通常是由于拍摄角度不同而造成的。大面积无纹理区域通常是指那些没有明显特征点的区域,例如室内区域中的白色墙壁等。而上述立体匹配算法都是逐像素进行匹配的,因而对于遮挡区域的像素信息的缺失以及大面积无纹理区域在匹配时的二义性,上述立体匹配算法均不能很好地解决遮挡区域或大面积无纹理区域的匹配,会造成匹配错误率较高以及匹配效率较低。Since the left and right images are obtained from different shooting angles, it is inevitable that there will be occluded areas or large non-textured areas. Among them, the occluded area refers to an area that is only visible in one image and has no corresponding pixel information in another image, which is usually caused by different shooting angles. Large areas without texture usually refer to those areas without obvious feature points, such as white walls in indoor areas, etc. However, the above-mentioned stereo matching algorithms are all matched pixel by pixel. Therefore, for the lack of pixel information in occluded areas and the ambiguity in matching large areas without texture, the above-mentioned stereo matching algorithms cannot well solve the problem of occluded areas or large areas. The matching of areas with no texture will result in higher matching error rate and lower matching efficiency.
发明内容Contents of the invention
本发明实施例的目的在于提供一种基于平面约束和三角剖分的双目视觉立体匹配方法及装置,以降低双目视觉立体匹配的匹配错误率,并提高匹配效率。具体技术方案如下:The purpose of the embodiments of the present invention is to provide a binocular vision stereo matching method and device based on plane constraints and triangulation, so as to reduce the matching error rate of binocular vision stereo matching and improve matching efficiency. The specific technical scheme is as follows:
为达到上述目的,第一方面,本发明实施提供了一种基于平面约束和三角剖分的双目视觉立体匹配方法,该方法包括:In order to achieve the above object, in the first aspect, the implementation of the present invention provides a binocular vision stereo matching method based on plane constraints and triangulation, the method comprising:
获取两个平行放置的摄像机在同一时间分别采集的同一拍摄场景的左图像和右图像,并将其中任一幅作为参考图像,另一幅作为待匹配图像;Obtain the left image and the right image of the same shooting scene collected by two parallel cameras at the same time, and use any one of them as a reference image and the other as an image to be matched;
确定所述参考图像中的支持点,并计算各所述支持点的视差;其中,所述支持点为所述参考图像中的、在所述待匹配图像中有唯一且正确匹配点的像素点;Determining the support points in the reference image, and calculating the parallax of each of the support points; wherein, the support points are pixels in the reference image that have unique and correct matching points in the image to be matched ;
按照预设的图像分割方式,对所述参考图像进行分割,得到多个分割区域;将各所述分割区域划分为分割面积大于第一阈值的第一类分割区域,和/或分割面积不大于所述第一阈值的第二类分割区域;According to the preset image segmentation method, the reference image is segmented to obtain a plurality of segmented areas; each of the segmented areas is divided into the first type of segmented area whose segmented area is larger than the first threshold, and/or the segmented area is not larger than the second type of segmentation region of the first threshold;
针对每个第一类分割区域,执行:对该第一类分割区域进行第二次分割,将该第一类分割区域划分为多个第一类子分割区域;根据每个第一类子分割区域内的支持点和支持点的视差,拟合该第一类子分割区域的第一平面方程;根据所述第一平面方程,确定该第一类子分割区域内非支持点的视差;其中,所述多个第一类子分割区域分别对应于所述拍摄场景中不同的物理平面;For each first-type segmented area, perform: perform a second segment on the first-type segmented area, divide the first-type segmented area into a plurality of first-type sub-segmented areas; The support points in the region and the parallax of the support points are fitted to the first plane equation of the first type of sub-segmentation area; according to the first plane equation, the parallax of the non-support points in the first type of sub-segmentation area is determined; wherein , the plurality of first-type sub-divided regions respectively correspond to different physical planes in the shooting scene;
针对每个第二类分割区域,执行:对该第二类分割区域进行三角剖分,将该第二类分割区域划分为多个三角形区域;针对每个三角形区域内的每个非支持点,根据该三角形区域的各顶点和各顶点的视差确定该非支持点对应的第一视差搜索范围;将所述第一视差搜索范围内各视差对应的待匹配点与该非支持点进行逐像素匹配,确定该非支持点的视差;其中,所述各顶点均为支持点。For each second-type segmented area, execute: triangulate the second-type segmented area, divide the second-type segmented area into a plurality of triangular areas; for each non-support point in each triangular area, Determine the first parallax search range corresponding to the unsupported point according to the vertices of the triangular area and the parallax of each vertex; match the points to be matched corresponding to each parallax in the first parallax search range with the unsupported point pixel by pixel. , to determine the disparity of the non-support point; wherein, each of the vertices is a support point.
可选地,所述确定所述参考图像中的支持点,包括:Optionally, the determining the support points in the reference image includes:
以所述参考图像的左上角像素点作为起点,沿所述参考图像对应的像素坐标系的u轴和v轴,在所述参考图像中构建步长为预设步长的网格;将所述网格中的、除了位于所述参考图像边缘处的交点作为候选支持点;其中,u轴向右,v轴向下;Taking the pixel point at the upper left corner of the reference image as a starting point, along the u-axis and the v-axis of the pixel coordinate system corresponding to the reference image, construct a grid with a step size of a preset step size in the reference image; In the above grid, except the intersection point at the edge of the reference image as a candidate support point; wherein, the u axis is rightward, and the v axis is downward;
针对每个候选支持点,计算预先设置的该候选支持点对应的第二视差搜索范围内各视差对应的待匹配点的向量与该候选支持点的向量的距离;若计算得到的所述距离中小于第二阈值的各距离中,最小的距离的个数为1,则将该候选支持点作为支持点;其中,所述第二视差搜索范围内各视差对应的待匹配点的向量,以及所述该候选支持点的向量均根据预设尺寸的sobel算子计算得到。For each candidate support point, calculate the distance between the vector of the point to be matched and the vector of the candidate support point corresponding to each parallax in the second parallax search range corresponding to the candidate support point that is preset; if the calculated distance is small Among the distances of the second threshold, if the number of the smallest distance is 1, then the candidate support point is used as a support point; wherein, the vector of the point to be matched corresponding to each parallax in the second parallax search range, and the The vectors of the candidate support points are all calculated according to the sobel operator of the preset size.
可选地,所述按照预设的图像分割方式,对所述参考图像进行分割,得到多个分割区域,包括:Optionally, the reference image is segmented according to a preset image segmentation method to obtain a plurality of segmented regions, including:
按照均值偏移Meanshift图像分割方式,对所述参考图像进行分割,得到至少一个分割区域。The reference image is segmented according to the Meanshift image segmentation manner to obtain at least one segmented region.
可选地,所述对该第一类分割区域进行第二次分割,将该第一类分割区域划分为多个第一类子分割区域,包括:Optionally, performing a second segmentation on the first type of segmented area, dividing the first type of segmented area into multiple first type sub-segmented areas, including:
按照预设的平面拟合规则,拟合该第一类分割区域内的多个支持点子集对应的物理平面的平面方程;其中,所述多个支持点子集分别对应于所述拍摄场景中不同的物理平面;Fit the plane equation of the physical plane corresponding to the plurality of support point subsets in the first type of segmented area according to the preset plane fitting rule; wherein, the plurality of support point subsets respectively correspond to different physical plane;
在拟合得到的各所述物理平面中,若其中多个物理平面满足预设合并条件,则根据所述多个物理平面内的支持点和支持点的视差,拟合得到合并后物理平面的平面方程;根据合并后物理平面的平面方程和未被合并的物理平面的平面方程,计算各合并后物理平面、未被合并的物理平面间的交线,确定出所述多个第一类子分割区域;其中,所述预设合并条件为:所述多个物理平面中,任一物理平面与至少一个其他物理平面的距离小于第三阈值;Among the fitted physical planes, if multiple physical planes satisfy the preset merging condition, then according to the support points in the multiple physical planes and the parallax of the support points, the physical plane after fitting is obtained by fitting. Plane equation; according to the plane equation of the merged physical plane and the plane equation of the unmerged physical plane, calculate the intersection line between each merged physical plane and the unmerged physical plane, and determine the plurality of first-type sub-planes Segmenting an area; wherein, the preset merging condition is: among the plurality of physical planes, the distance between any physical plane and at least one other physical plane is less than a third threshold;
在拟合得到的各所述物理平面中,若其中任意两个物理平面不满足所述预设合并条件,则根据各所述物理平面的平面方程,计算各所述物理平面间的交线,确定出所述多个第一类子分割区域。Among the fitted physical planes, if any two of the physical planes do not satisfy the preset merging condition, the intersection line between the physical planes is calculated according to the plane equations of the physical planes, The plurality of first-type sub-divided regions are determined.
可选地,所述按照预设的平面拟合规则,拟合该第一类分割区域内的多个支持点子集对应的物理平面的平面方程,包括:Optionally, according to the preset plane fitting rules, fitting the plane equations of the physical planes corresponding to the plurality of support point subsets in the first type of segmented area includes:
S1、基于随机抽样一致性RANSAC算法,从该第一类分割区域内的当前支持点集Y中选取目标支持点子集O;其中,所述O为所述Y中、支持点个数最多的支持点子集;S1. Based on the random sampling consistency RANSAC algorithm, select a target support point subset O from the current support point set Y in the first type of segmented area; wherein, the O is the support with the largest number of support points in the Y set of ideas;
S2、根据所述O的支持点和支持点的视差,拟合所述O对应的物理平面的平面方程;S2. Fitting the plane equation of the physical plane corresponding to the O according to the support points of the O and the parallax of the support points;
S3、判断当前未拟合支持点子集Y-O的支持点个数是否少于预设比例的该第一类分割区域内的支持点个数;S3. Judging whether the number of support points of the currently unfit support point subset Y-O is less than the number of support points in the first type of segmented area of the preset ratio;
若所述Y-O的支持点个数不少于预设比例的该第一类分割区域内的支持点个数,则将所述Y-O作为该第一类分割区域内的当前支持点集,返回执行步骤S1;If the number of support points of the Y-O is not less than the number of support points in the first-type segmented area of the preset ratio, then use the Y-O as the current support point set in the first-type segmented area, and return to execute Step S1;
若所述Y-O的支持点个数少于预设比例的该第一类分割区域内的支持点个数,则将当前已拟合的物理平面的平面方程作为最终的拟合结果。If the number of support points of the Y-O is less than the number of support points in the first-type segmented area of the preset ratio, the plane equation of the currently fitted physical plane is used as the final fitting result.
可选地,所述根据每个第一类子分割区域内的支持点和支持点的视差,拟合该第一类子分割区域的第一平面方程,包括:Optionally, fitting the first plane equation of the first type of sub-segmentation area according to the support points in each first type of sub-segmentation area and the disparity of the support points includes:
设定第一类子分割区域的第一平面方程为:Set the first plane equation of the first type of sub-division area as:
d(u,v)=au+bv+cd(u,v)=au+bv+c
其中,d(u,v)表示第一类子分割区域内像素点(u,v)的视差,a,b,c为所述第一平面方程的待求解参数,通过以下公式求解所述a,b,c:Wherein, d(u, v) represents the disparity of the pixel point (u, v) in the first type of sub-division area, a, b, c are the parameters to be solved of the first plane equation, and the a is solved by the following formula ,b,c:
其中,ui表示第一类子分割区域内第i个支持点在所述参考图像对应的像素坐标系的u轴的坐标,vi表示第一类子分割区域内第i个支持点在所述参考图像对应的像素坐标系的v轴的坐标,u轴向右,v轴向下,i=1,...,m,m表示第一类子分割区域内的支持点个数,di表示第一类子分割区域内第i个支持点的视差。Among them, u i represents the coordinates of the u-axis of the i-th support point in the pixel coordinate system corresponding to the reference image in the first type of sub-segmentation area, and v i represents the i-th support point in the first type of sub-segmentation area. The coordinates of the v axis of the pixel coordinate system corresponding to the reference image, the u axis is right, the v axis is down, i=1,..., m, m represents the number of support points in the first type of sub-division area, d i represents the disparity of the i-th support point in the sub-segmentation area of the first type.
可选地,所述针对每个三角形区域内的每个非支持点,根据该三角形区域的各顶点和各顶点的视差确定该非支持点对应的第一视差搜索范围,包括:Optionally, for each unsupported point in each triangular area, determining the first parallax search range corresponding to the unsupported point according to each vertex of the triangular area and the disparity of each vertex includes:
针对每个三角形区域,根据该三角形区域内的各顶点和各顶点的视差,确定该三角形区域所在平面的第二平面方程;For each triangular area, according to each vertex in the triangular area and the parallax of each vertex, determine the second plane equation of the plane where the triangular area is located;
根据所述第二平面方程确定该非支持点的视差估计值;determining an estimated parallax value of the unsupported point according to the second plane equation;
所述第一视差搜索范围包括:所述各顶点的视差、将所述各顶点的视差加和减预设值后的视差、所述视差估计值以及该非支持点所述的预设邻域内的目标支持点的视差;其中,所述目标支持点的视差与根据所述第二平面方程确定的该目标支持点的视差估计值之差的绝对值不超过第四阈值。The first disparity search range includes: the disparity of each vertex, the disparity obtained by adding and subtracting a preset value from the disparity of each vertex, the estimated disparity value, and the preset neighborhood of the non-support point The disparity of the target support point; wherein, the absolute value of the difference between the disparity of the target support point and the estimated value of the disparity of the target support point determined according to the second plane equation does not exceed a fourth threshold.
可选地,所述将所述第一视差搜索范围内各视差对应的待匹配点与该非支持点进行逐像素匹配,确定该非支持点的视差,包括:Optionally, performing pixel-by-pixel matching of the points to be matched corresponding to each parallax in the first parallax search range with the non-support point to determine the parallax of the non-support point includes:
通过以下公式,确定该非支持点的视差:The non-support point is determined by the following formula Parallax for:
其中,为该非支持点的视差,dn表示所述该非支持点的视差估计值,表示所述第一视差搜索范围内的各视差,N表示所述第一视差搜索范围内的视差数,S表示所述参考图像的支持点集;表示的后验概率,通过以下公式计算:in, for the non-support point The disparity, d n represents the disparity estimated value of the non-support point, Represents each disparity within the first disparity search range, N represents the number of disparities within the first disparity search range, and S represents the support point set of the reference image; express The posterior probability of , calculated by the following formula:
其中,表示dn对应的待匹配点为所述非支持点的正确匹配点的概率,表示所述第一视差搜索范围内的各视差对应的匹配点为所述非支持点的正确匹配点的概率。in, Indicates that the point to be matched corresponding to d n is the non-support point The probability of the correct matching point of , Indicates that the matching points corresponding to each disparity within the first disparity search range are the non-support points The probability of the correct matching point of .
第二方面,本发明实施例提供了一种基于平面约束和三角剖分的双目视觉立体匹配装置,该装置包括:In the second aspect, an embodiment of the present invention provides a binocular vision stereo matching device based on plane constraints and triangulation, the device comprising:
获取模块,用于获取两个平行放置的摄像机在同一时间分别采集的同一拍摄场景的左图像和右图像,并将其中任一幅作为参考图像,另一幅作为待匹配图像;The obtaining module is used to obtain the left image and the right image of the same shooting scene collected by two parallel cameras at the same time, and any one of them is used as a reference image, and the other is used as an image to be matched;
确定模块,用于确定所述参考图像中的支持点,并计算各所述支持点的视差;其中,所述支持点为所述参考图像中的、在所述待匹配图像中有唯一且正确匹配点的像素点;A determining module, configured to determine the support points in the reference image, and calculate the disparity of each of the support points; wherein, the support points in the reference image are unique and correct in the image to be matched Pixels of matching points;
分割模块,用于按照预设的图像分割方式,对所述参考图像进行分割,得到多个分割区域;将各所述分割区域划分为分割面积大于第一阈值的第一类分割区域,和/或分割面积不大于所述第一阈值的第二类分割区域;A segmentation module, configured to segment the reference image according to a preset image segmentation method to obtain a plurality of segmented areas; divide each segmented area into a first type of segmented area whose segmented area is greater than a first threshold, and/or or a second type of segmented area whose segmented area is not greater than the first threshold;
第一执行模块,用于针对每个第一类分割区域,执行:对该第一类分割区域进行第二次分割,将该第一类分割区域划分为多个第一类子分割区域;根据每个第一类子分割区域内的支持点和支持点的视差,拟合该第一类子分割区域的第一平面方程;根据所述第一平面方程,确定该第一类子分割区域内非支持点的视差;其中,所述多个第一类子分割区域分别对应于所述拍摄场景中不同的物理平面;The first execution module is configured to, for each first-type segmented area, perform: performing a second segment on the first-type segmented area, and dividing the first-type segmented area into a plurality of first-type sub-segmented areas; The support points and the parallax of the support points in each first type of sub-segmentation area are fitted to the first plane equation of the first type of sub-segmentation area; according to the first plane equation, determine the first type of sub-segmentation area Parallax of non-support points; wherein, the plurality of first-type sub-segments respectively correspond to different physical planes in the shooting scene;
第二执行模块,用于针对每个第二类分割区域,执行:对该第二类分割区域进行三角剖分,将该第二类分割区域划分为多个三角形区域;针对每个三角形区域内的每个非支持点,根据该三角形区域的各顶点和各顶点的视差确定该非支持点对应的第一视差搜索范围;将所述第一视差搜索范围内各视差对应的待匹配点与该非支持点进行逐像素匹配,确定该非支持点的视差;其中,所述各顶点均为支持点。The second execution module is configured to, for each second-type segmented area, execute: perform triangulation on the second-type segmented area, and divide the second-type segmented area into a plurality of triangular areas; for each triangular area For each non-support point, determine the first parallax search range corresponding to the non-support point according to each vertex of the triangular area and the parallax of each vertex; the points to be matched corresponding to each parallax in the first parallax search range and the The non-support point is matched pixel by pixel to determine the disparity of the non-support point; wherein, each of the vertices is a support point.
第三方面,本发明实施例提供了一种电子设备,包括处理器、通信接口、存储器和通信总线,其中,处理器,通信接口,存储器通过通信总线完成相互间的通信;In a third aspect, an embodiment of the present invention provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory complete communication with each other through the communication bus;
存储器,用于存放计算机程序;memory for storing computer programs;
处理器,用于执行存储器上所存放的程序时,实现如上第一方面所述的基于平面约束和三角剖分的双目视觉立体匹配的方法步骤。The processor is configured to implement the method steps for binocular vision stereo matching based on plane constraints and triangulation as described in the first aspect when executing the program stored in the memory.
第四方面,本发明实施例提供了一种计算机可读存储介质,所述计算机可读存储介质中存储有指令,当其在计算机上运行时,使得计算机执行如上第一方面所述的基于平面约束和三角剖分的双目视觉立体匹配的方法步骤。In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, where instructions are stored in the computer-readable storage medium, and when the computer-readable storage medium is run on a computer, the computer executes the plane-based Method steps for binocular stereo matching with constraints and triangulation.
第五方面,本发明实施例提供了一种包含指令的计算机程序产品,当其在计算机上运行时,使得计算机执行如上第一方面所述的基于平面约束和三角剖分的双目视觉立体匹配的方法步骤。In the fifth aspect, the embodiment of the present invention provides a computer program product containing instructions, which, when run on a computer, enables the computer to perform binocular vision stereo matching based on plane constraints and triangulation as described in the first aspect above method steps.
本发明实施例提供的基于平面约束和三角剖分的双目视觉立体匹配方法及装置,将参考图像分割后,对面积较大的分割区域进行第二次分割,以确定出对应于不同物理平面的子分割区域;进一步根据子分割区域的支持点和支持点的视差拟合子分割区域的平面方程,并根据该平面方程确定子分割区域内非支持点的视差。同时,对面积较小的分割区域进行三角剖分,划分为多个三角形;进一步根据三角形的顶点和顶点的视差确定三角形内非支持点的第一视差搜索范围,并将该范围内各视差对应的待匹配点与该非支持点进行逐像素匹配,从而确定出该非支持点的视差。In the binocular vision stereo matching method and device based on plane constraints and triangulation provided by the embodiments of the present invention, after the reference image is segmented, the segmented area with a larger area is segmented a second time to determine the The sub-segmentation area; further fitting the plane equation of the sub-segmentation area according to the support points of the sub-segmentation area and the disparity of the support points, and determining the disparity of the non-support points in the sub-segmentation area according to the plane equation. At the same time, triangulate the smaller segmented area and divide it into multiple triangles; further determine the first parallax search range of non-support points in the triangle according to the apex of the triangle and the parallax of the apex, and correspond to each parallax in the range The point to be matched is matched pixel by pixel with the non-support point, so as to determine the disparity of the non-support point.
可见,本发明实施例,针对面积较大的分割区域的各子分割区域,基于平面约束的思想,通过各子分割区域的平面方程确定各子分割区域内所有非支持点的视差,能够实现对缺失像素信息的遮挡区域以及存在匹配二义性的大面积无纹理区域更为准确地且鲁棒性更好地匹配,从而降低了匹配错误率。并且本发明实施例,针对面积较小的分割区域进行三角剖分,根据三角形的顶点和顶点视差确定三角形内非支持点的视差搜索范围,极大缩小了非支持点的视差搜索范围,提高了匹配效率。It can be seen that in the embodiment of the present invention, for each sub-segmented area of a larger-area segmented area, based on the idea of plane constraints, the parallax of all non-support points in each sub-segmented area can be determined through the plane equation of each sub-segmented area, and the parallax can be realized. Occluded areas with missing pixel information and large textureless areas with matching ambiguity are more accurately and robustly matched, thereby reducing the matching error rate. And in the embodiment of the present invention, triangulation is carried out for the smaller segmented area, and the parallax search range of the unsupported points in the triangle is determined according to the vertices of the triangle and the parallax of the vertices, which greatly reduces the parallax search range of the unsupported points and improves the matching efficiency.
当然,实施本发明的任一产品或方法必不一定需要同时达到以上所述的所有优点。Of course, implementing any product or method of the present invention does not necessarily need to achieve all the above-mentioned advantages at the same time.
附图说明Description of drawings
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍。In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings that are required in the description of the embodiments or the prior art.
图1为本发明实施例提供的基于平面约束和三角剖分的双目视觉立体匹配方法的流程图;Fig. 1 is the flow chart of the binocular vision stereo matching method based on plane constraint and triangulation provided by the embodiment of the present invention;
图2为图1所示实施例的步骤S104中实现对该第一类分割区域进行第二次分割,将该第一类分割区域划分为多个第一类子分割区域的一种具体流程图;Fig. 2 is a specific flow chart for realizing the second segmentation of the first-type segmented area in step S104 of the embodiment shown in Fig. 1, and dividing the first-type segmented area into a plurality of first-type sub-segmented areas ;
图3为图2所示实施例中步骤S201的一种具体流程图;Fig. 3 is a kind of specific flowchart of step S201 in the embodiment shown in Fig. 2;
图4为本发明实施例提供的仿真实验结果图;Fig. 4 is the simulation experiment result figure that the embodiment of the present invention provides;
图5为本发明实施例提供的基于平面约束和三角剖分的双目视觉立体匹配装置的结构图;5 is a structural diagram of a binocular vision stereo matching device based on plane constraints and triangulation provided by an embodiment of the present invention;
图6为本发明实施例提供的一种电子设备的结构图。FIG. 6 is a structural diagram of an electronic device provided by an embodiment of the present invention.
具体实施方式Detailed ways
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only some, not all, embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by persons of ordinary skill in the art without making creative efforts belong to the protection scope of the present invention.
在双目视觉立体匹配时,为了降低遮挡区域和大面积无纹理区域的匹配错误率,并提高匹配效率,如图1所示,本发明提供了一种基于平面约束和三角剖分的双目视觉立体匹配方法,该方法包括:In binocular vision stereo matching, in order to reduce the matching error rate of occluded areas and large areas without texture, and improve the matching efficiency, as shown in Figure 1, the present invention provides a binocular vision system based on plane constraints and triangulation A visual stereo matching method, the method comprising:
S101,获取两个平行放置的摄像机在同一时间分别采集的同一拍摄场景的左图像和右图像,并将其中任一幅作为参考图像,另一幅作为待匹配图像。S101. Obtain the left image and the right image of the same shooting scene respectively collected by two parallel cameras at the same time, and use any one of them as a reference image and the other as an image to be matched.
为了模仿人的双眼在观看场景时产生的三维立体视觉,在计算机视觉中,可以获取两个平行放置的摄像机在同一时间分别采集的同一拍摄场景的左图像和右图像,以进一步找到该拍摄场景中的目标在左右图像中的投影点,也称为对应点,从而生成视差图。然后,通过相似三角形原理可以将视差图转换为包含摄像机与拍摄场景中各目标的深度信息,即摄像机与拍摄场景中各目标的实际距离的深度图,以进一步进行三维重建。In order to imitate the three-dimensional stereoscopic vision produced by human eyes when watching a scene, in computer vision, the left and right images of the same shooting scene collected by two parallel cameras at the same time can be obtained to further find the shooting scene. The projected points of the target in the left and right images, also known as corresponding points, generate a disparity map. Then, the disparity map can be converted into a depth map containing the depth information between the camera and each object in the shooting scene, that is, the actual distance between the camera and each object in the shooting scene, for further three-dimensional reconstruction.
本实施例中,也可以通过一个双目摄像机的两个摄像单元同时采集一拍摄场景的左右图像。In this embodiment, the left and right images of a shooting scene can also be collected simultaneously by two camera units of a binocular camera.
摄像机所采集的左图像或右图像均可以作为参考图像,若将其中一幅作为参考图像,那么另一幅就是待匹配图像。例如,将左图像作为参考图像,则本发明的目的就是确定出左图像中每个像素点的视差,生成左图像的视差图。在本实施例中,示例性地,将左图像作为参考图像,来详细描述各步骤。Either the left image or the right image collected by the camera can be used as a reference image, if one of them is used as a reference image, then the other is the image to be matched. For example, if the left image is used as a reference image, the purpose of the present invention is to determine the disparity of each pixel in the left image and generate a disparity map of the left image. In this embodiment, for example, each step is described in detail by taking the left image as a reference image.
S102,确定所述参考图像中的支持点,并计算各所述支持点的视差;其中,所述支持点为所述参考图像中的、在所述待匹配图像中有唯一且正确匹配点的像素点。S102. Determine the support points in the reference image, and calculate the disparity of each of the support points; wherein, the support points are those in the reference image that have unique and correct matching points in the image to be matched pixel.
本发明基于这样的观察:实际场景中的某个点通常不是孤立的,而是与其它一些点共存于同一个物理平面,对应地,参考图像中的某个像素点通常不是孤立的,而是与其它一些像素点共同对应于拍摄场景中的同一个物理平面。那么,基于平面约束的思想,如果能够准确地确定参考图像中每个像素点所对应的物理平面,就可以以平面为最小计算单元进行视差值填充,即可以根据像素点对应的物理平面的平面方程来确定该像素点的视差。因而,对于遮挡区域和大面积无纹理区域内的像素点的视差确定具有鲁棒性。The present invention is based on the observation that a certain point in the actual scene is usually not isolated, but coexists with other points on the same physical plane. Correspondingly, a certain pixel in the reference image is usually not isolated, but Together with some other pixels, it corresponds to the same physical plane in the shooting scene. Then, based on the idea of plane constraints, if the physical plane corresponding to each pixel in the reference image can be accurately determined, the disparity value can be filled with the plane as the smallest calculation unit, that is, the physical plane corresponding to the pixel can be Plane equation to determine the disparity of the pixel. Therefore, the disparity determination of pixels in occluded regions and large texture-free regions is robust.
基于上述观察,从另一角度来看,参考图像必然对应了拍摄场景中的至少一个物理平面。为了确定参考图像对应的物理平面的平面方程,本实施例中,可以预先确定出参考图像中的一些支持点,这些支持点是在待匹配图像中有唯一且正确匹配点的像素点,其视差值具有较好的鲁棒性,可以在后续计算中,用来拟合平面方程。Based on the above observation, from another perspective, the reference image must correspond to at least one physical plane in the shooting scene. In order to determine the plane equation of the physical plane corresponding to the reference image, in this embodiment, some support points in the reference image can be determined in advance. The difference has better robustness and can be used to fit the plane equation in subsequent calculations.
可以理解的是,参考图像中必然存在很多在待匹配图像中有唯一且正确匹配点的像素点,但本实施例中,并不需要将所有的这种像素点都确定出来,而是可以选择性地将这种像素点中的一部分确定为支持点。It can be understood that there must be many pixels in the reference image that have unique and correct matching points in the image to be matched, but in this embodiment, it is not necessary to determine all such pixels, but can be selected A part of such pixel points is determined as support points.
在一种实现方式中,确定所述参考图像中的支持点,可以包括以下步骤:In an implementation manner, determining the support points in the reference image may include the following steps:
S11,以所述参考图像的左上角像素点作为起点,沿所述参考图像对应的像素坐标系的u轴和v轴,在所述参考图像中构建步长为预设步长的网格;将所述网格中的、除了位于所述参考图像边缘处的交点作为候选支持点;其中,u轴向右,v轴向下。S11, using the upper left pixel point of the reference image as a starting point, constructing a grid with a preset step size in the reference image along the u-axis and v-axis of the pixel coordinate system corresponding to the reference image; Taking the intersection points in the grid except at the edge of the reference image as candidate support points; wherein, the u axis is rightward, and the v axis is downward.
可以理解,通过在参考图像中构建网格,将网格中的、除了位于参考图像边缘处的交点作为候选支持点,并进一步从候选支持点中确定出支持点的方式可以使支持点均匀地分布在参考图像中。当通过支持点和支持点的视差拟合平面方程时,每个平面内的支持点的分布比较均匀,且不同平面的支持点的密度比较相近,从而可以使拟合得到的平面方程更为准确。It can be understood that by constructing a grid in the reference image, using the intersection points in the grid except at the edge of the reference image as candidate support points, and further determining the support points from the candidate support points, the support points can be evenly distributed. distributed in the reference image. When fitting the plane equation through the support points and the parallax of the support points, the distribution of the support points in each plane is relatively uniform, and the density of the support points of different planes is relatively similar, so that the fitted plane equation can be more accurate .
例如,参考图像的尺寸为256×256,左上角像素点为(0,0),预设步长为5个像素,沿参考图像对应的像素坐标系的u轴和v轴,构建网格,则网格中交点处的像素点包括:网格第一行:(0,0),(0,5),(0,10),…,(0,255),网格第二行:(5,0),(5,5),(5,10),…,(5,255),…,网格最后一行:(255,0),(255,5),(255,10),…,(255,255)。在上述交点中,去除参考图像边缘处的交点后,其余交点处的像素点为候选支持点:网格第二行:(5,5),(5,10),…,(5,255),网格第三行:(10,5),(10,10),…,(10,255),…,网格最后一行:(255,5),(255,10),…,(255,255)。For example, the size of the reference image is 256×256, the upper left pixel point is (0, 0), the preset step size is 5 pixels, and the grid is constructed along the u-axis and v-axis of the pixel coordinate system corresponding to the reference image, Then the pixel points at the intersection points in the grid include: the first row of the grid: (0, 0), (0, 5), (0, 10), ..., (0, 255), the second row of the grid: ( 5, 0), (5, 5), (5, 10), ..., (5, 255), ..., grid last row: (255, 0), (255, 5), (255, 10), ..., (255, 255). In the above intersection points, after removing the intersection points at the edge of the reference image, the pixels at the remaining intersection points are candidate support points: the second row of the grid: (5, 5), (5, 10), ..., (5, 255) , the third row of the grid: (10, 5), (10, 10), ..., (10, 255), ..., the last row of the grid: (255, 5), (255, 10), ..., (255 , 255).
预设步长可以根据实际需要,或经验确定。The preset step size can be determined according to actual needs or experience.
S12,针对每个候选支持点,计算预先设置的该候选支持点对应的第二视差搜索范围内各视差对应的待匹配点的向量与该候选支持点的向量的距离;若计算得到的所述距离中小于第二阈值的各距离中,最小的距离的个数为1,则将该候选支持点作为支持点;其中,所述第二视差搜索范围内各视差对应的待匹配点的向量,以及所述该候选支持点的向量均根据预设尺寸的sobel算子计算得到。S12. For each candidate support point, calculate the distance between the vector of the point to be matched and the vector of the candidate support point corresponding to each disparity in the second disparity search range corresponding to the candidate support point that is preset; if the calculated Among the distances that are less than the second threshold, the number of the smallest distance is 1, and the candidate support point is used as a support point; wherein, the vector of the point to be matched corresponding to each parallax in the second parallax search range, And the vector of the candidate support point is calculated according to the sobel operator of the preset size.
视差是拍摄场景中的目标在左右图像上的两个投影点的横坐标的差值,例如,目标在左图像的投影点xl为(5,10),在右图像的投影点xr为(5,8),则xl的视差d(xl)=2。Parallax is the difference between the abscissas of the two projection points of the target in the shooting scene on the left and right images. For example, the projection point x l of the target on the left image is (5, 10), and the projection point x r on the right image is (5, 8), then the parallax d(x l )=2 of x l .
第二视差搜索范围包括了多个视差值,对于一个候选支持点来说,其对应的第二视差搜索范围内的每个视差值都与待匹配图像中的一个待匹配像素点(简称为待匹配点)对应。例如,对于候选支持点(5,255),其对应的第二视差搜索范围内的一个视差为2,则该视差2对应的待匹配点为(5,253)。The second disparity search range includes a plurality of disparity values. For a candidate support point, each disparity value in the corresponding second disparity search range is consistent with a pixel to be matched in the image to be matched (referred to as corresponding to the point to be matched). For example, for the candidate support point (5, 255), the corresponding disparity within the second disparity search range is 2, and the point to be matched corresponding to the disparity 2 is (5, 253).
本实施例中,第二视差搜索范围的最小值可以为0,最大值可以根据需要设定,如设定为参考图像的宽度的一半。例如,参考图像的宽度为256,则可以设定第二视差搜索范围为0~128。那么对于候选支持点(5,255)来说,其对应的第二视差搜索范围内各视差对应的待匹配点为:待匹配图像中的像素点(5,137),…,(5,255)。当然,可以理解的是,不同的候选支持点对应的第二视差搜索范围的最大值可以不同。In this embodiment, the minimum value of the second disparity search range may be 0, and the maximum value may be set as required, such as half the width of the reference image. For example, if the width of the reference image is 256, then the second disparity search range can be set as 0-128. Then for the candidate support point (5, 255), the points to be matched corresponding to each parallax in the corresponding second parallax search range are: pixel points (5, 137) in the image to be matched, ..., (5, 255 ). Of course, it can be understood that the maximum value of the second disparity search range corresponding to different candidate support points may be different.
sobel算子的预设尺寸可以根据实际需要设定,例如设定为3×3。第二阈值也可以根据经验设定,如设定为2。在步骤S12中,通过sobel算子计算得到候选支持点的向量和各待匹配点的向量之后,可以通过计算候选支持点的向量与各待匹配点的向量的距离,确定出候选支持点和各待匹配点之间的距离,如该距离可以是0、1、2等。距离越小,表示候选支持点与待匹配点越相似。进一步地,若计算出的各距离中最小的距离的个数为1,则说明候选支持点有唯一的正确匹配点,那么可以将该候选支持点作为支持点。反之,若计算出的各距离中最小的距离的个数大于1,则说明有多个待匹配点与候选支持点相似,即对候选支持点的匹配出现了二义性,那么该候选支持点不会被作为支持点。The preset size of the sobel operator can be set according to actual needs, for example, set to 3×3. The second threshold can also be set according to experience, for example, set to 2. In step S12, after the vectors of the candidate support points and the vectors of the points to be matched are obtained through the calculation of the sobel operator, the distances between the vectors of the candidate support points and the vectors of the points to be matched can be calculated to determine the candidate support points and the vectors of the points to be matched. The distance between the points to be matched, for example, the distance can be 0, 1, 2, etc. The smaller the distance, the more similar the candidate support point is to the point to be matched. Further, if the number of the smallest distance among the calculated distances is 1, it means that the candidate support point has the only correct matching point, and the candidate support point can be used as a support point. Conversely, if the number of the smallest distance among the calculated distances is greater than 1, it means that there are multiple points to be matched that are similar to the candidate support points, that is, there is ambiguity in the matching of the candidate support points, then the candidate support points Will not be used as a support point.
例如:候选支持点L1,其对应的待匹配点有5个,分别为R1-R5,第二阈值为2。如果候选支持点L1与待匹配点R1-R5的距离的分别为:0,1,3,2,1,则在小于第二阈值的各距离中(依次为0,1,1),最小的距离0的个数为1,那么候选支持点L1有唯一的正确匹配点R1,可以将候选支持点作为支持点。如果候选支持点L1与待匹配点R1-R5的距离的分别为:1,1,2,2,2,则在小于第二阈值的各距离中(依次为1,1),最小的距离1的个数为2,那么候选支持点L1的匹配出现了二义性,该候选支持点不会被作为支持点。For example: the candidate support point L1 has 5 corresponding points to be matched, namely R1-R5, and the second threshold is 2. If the distances between the candidate support point L1 and the points R1-R5 to be matched are: 0, 1, 3, 2, 1, then among the distances smaller than the second threshold (0, 1, 1 in sequence), the smallest If the number of distance 0 is 1, then the candidate support point L1 has the only correct matching point R1, and the candidate support point can be used as a support point. If the distances between the candidate support point L1 and the points to be matched R1-R5 are respectively: 1, 1, 2, 2, 2, then among the distances smaller than the second threshold (1, 1 in sequence), the minimum distance 1 The number of is 2, then the matching of the candidate support point L1 is ambiguous, and the candidate support point will not be used as a support point.
若将一个候选支持点作为支持点,则该支持点的视差就是该候选支持点的横坐标与其匹配点的横坐标的差值。If a candidate support point is used as a support point, the disparity of the support point is the difference between the abscissa of the candidate support point and the abscissa of the matching point.
S103,按照预设的图像分割方式,对所述参考图像进行分割,得到多个分割区域;将各所述分割区域划分为分割面积大于第一阈值的第一类分割区域,和/或分割面积不大于所述第一阈值的第二类分割区域。S103. Segment the reference image according to a preset image segmentation method to obtain a plurality of segmented regions; divide each segmented region into a first-type segmented region whose segmented area is greater than a first threshold, and/or segmented area The second type of segmented regions not greater than the first threshold.
对参考图像分割的目的在于,尽可能准确地分割出参考图像中对应不同物理平面的分割区域。在一种实现方式中,可以按照均值偏移Meanshift图像分割方式,对所述参考图像进行分割,得到多个分割区域。具体的,在分割过程中,可以针对参考图像的大小,和/或图像的其他属性,根据经验调整Meanshift分割中的颜色半径和空间半径,以使得分割结果尽可能准确。通常情况下,在针对图像大小这个属性调整颜色半径和空间半径时,如果图像相对较大,则颜色半径相对较小,空间半径相对较大。例如,针对大小为450×375的图像,可以将颜色半径设定为30,将空间半径设定为30;针对大小为128×128的图像,可以将颜色半径设定为40,将空间半径设定为20。The purpose of segmenting the reference image is to segment the segmented regions corresponding to different physical planes in the reference image as accurately as possible. In an implementation manner, the reference image may be segmented according to a Meanshift image segmentation manner to obtain multiple segmented regions. Specifically, during the segmentation process, the color radius and space radius in the Meanshift segmentation can be adjusted empirically for the size of the reference image and/or other attributes of the image, so as to make the segmentation result as accurate as possible. Normally, when adjusting the color radius and space radius for the attribute of image size, if the image is relatively large, the color radius is relatively small and the space radius is relatively large. For example, for an image with a size of 450×375, you can set the color radius to 30 and the space radius to 30; for an image with a size of 128×128, you can set the color radius to 40 and the space radius to Set at 20.
但是在实际的分割中,也可能会出现分割错误的情况,即不对应于拍摄场景中的同一平面的不同像素点可能被分割到同一分割区域中。分割区域的面积越大,出现这种错误的可能性越大。因而,本实施例中,可以根据经验设定一个第一阈值,以将面积大于第一阈值的第一类分割区域进行二次分割,并认为面积不大于第一阈值的第二类分割区域内的像素点都对应于同一平面。具体的,采用Meanshift分割参考图像时,第一阈值的设定与Meanshift分割中的颜色半径和空间半径有关。以上述例子为例:在图像大小为450×375,颜色半径为30且空间半径设定为30时,可以将第一阈值设定为800个像素点,即一个分割区域内的像素点个数若超过800个,则该分割区域为第一类分割区域。However, in actual segmentation, segmentation errors may also occur, that is, different pixel points that do not correspond to the same plane in the shooting scene may be segmented into the same segmented area. The larger the size of the segmented region, the more likely this error will occur. Therefore, in this embodiment, a first threshold can be set based on experience, so that the first type of segmented area whose area is larger than the first threshold is subjected to secondary segmentation, and the second type of segmented area whose area is not larger than the first threshold is considered to be The pixels all correspond to the same plane. Specifically, when Meanshift is used to segment the reference image, the setting of the first threshold is related to the color radius and space radius in the Meanshift segmentation. Take the above example as an example: when the image size is 450×375, the color radius is 30, and the space radius is set to 30, the first threshold can be set to 800 pixels, that is, the number of pixels in a segmented area If there are more than 800, the segmented area is the first type of segmented area.
通常情况下,空间半径不变时,若颜色半径相对较大,则第一阈值相对较小;颜色半径不变时,若空间半径相对较大,则第一阈值相对较大。Generally, when the space radius is constant, if the color radius is relatively large, the first threshold is relatively small; when the color radius is constant, if the space radius is relatively large, the first threshold is relatively large.
本实施例中,也可以采用其他图像分割方法对参考图像进行分割,本发明对此并不限定。In this embodiment, other image segmentation methods may also be used to segment the reference image, which is not limited in the present invention.
S104,针对每个第一类分割区域,执行:对该第一类分割区域进行第二次分割,将该第一类分割区域划分为多个第一类子分割区域;根据每个第一类子分割区域内的支持点和支持点的视差,拟合该第一类子分割区域的第一平面方程;根据所述第一平面方程,确定该第一类子分割区域内非支持点的视差;其中,所述多个第一类子分割区域分别对应于所述拍摄场景中不同的物理平面。S104. For each first-type segmented area, perform: perform a second segment on the first-type segmented area, and divide the first-type segmented area into a plurality of first-type sub-segmented areas; The support points and the parallax of the support points in the sub-segmentation area are fitted to the first plane equation of the first type of sub-segmentation area; according to the first plane equation, the parallax of the non-support points in the first type of sub-segmentation area is determined ; Wherein, the plurality of sub-divided regions of the first type respectively correspond to different physical planes in the shooting scene.
由于设定第一类分割区域存在分割错误,即将对应于多个平面的不同分割区域都分割到了同一个第一类分割区域。因而可以对第一类分割区域进行第二次分割,得到多个第一类子分割区域,使每个第一类子分割区域内的像素点都对应于同一平面。Because there is a segmentation error in setting the first type of segmented area, that is, different segmented areas corresponding to multiple planes are all segmented into the same first type of segmented area. Therefore, a second division can be performed on the first-type segmented area to obtain multiple first-type sub-segmented areas, so that the pixels in each first-type sub-segmented area correspond to the same plane.
在一种实现方式中,步骤S104中的根据每个第一类子分割区域内的支持点和支持点的视差,拟合该第一类子分割区域的第一平面方程,可以包括:In one implementation, fitting the first plane equation of the first type of sub-segmentation area according to the support points and the disparity of the support points in each first type of sub-segmentation area in step S104 may include:
设定第一类子分割区域的第一平面方程为:Set the first plane equation of the first type of sub-division area as:
d(u,v)=au+bv+cd(u,v)=au+bv+c
其中,d(u,v)表示第一类子分割区域内像素点(u,v)的视差,a,b,c为所述第一平面方程的待求解参数,通过以下公式求解所述a,b,c:Wherein, d(u, v) represents the disparity of the pixel point (u, v) in the first type of sub-division area, a, b, c are the parameters to be solved of the first plane equation, and the a is solved by the following formula ,b,c:
其中,ui表示第一类子分割区域内第i个支持点在所述参考图像对应的像素坐标系的u轴的坐标,vi表示第一类子分割区域内第i个支持点在所述参考图像对应的像素坐标系的v轴的坐标,u轴向右,v轴向下,i=1,...,m,m表示第一类子分割区域内的支持点个数,di表示第一类子分割区域内第i个支持点的视差。Among them, u i represents the coordinates of the u-axis of the i-th support point in the pixel coordinate system corresponding to the reference image in the first type of sub-segmentation area, and v i represents the i-th support point in the first type of sub-segmentation area. The coordinates of the v axis of the pixel coordinate system corresponding to the reference image, the u axis is right, the v axis is down, i=1,..., m, m represents the number of support points in the first type of sub-division area, d i represents the disparity of the i-th support point in the sub-segmentation area of the first type.
基于每个第一类子分割区域的第一平面方程,可以确定出该第一类子分割区域内非支持点的视差。这里的非支持点是与支持点相对的概念,具体是指待确定视差的像素点。Based on the first plane equation of each first type of sub-division area, the disparity of non-support points in the first type of sub-division area can be determined. The non-support point here is a concept opposite to the support point, and specifically refers to the pixel point whose parallax is to be determined.
S105,针对每个第二类分割区域,执行:对该第二类分割区域进行三角剖分,将该第二类分割区域划分为多个三角形区域;针对每个三角形区域内的每个非支持点,根据该三角形区域的各顶点和各顶点的视差确定该非支持点对应的第一视差搜索范围;将所述第一视差搜索范围内各视差对应的待匹配点与该非支持点进行逐像素匹配,确定该非支持点的视差;其中,所述各顶点均为支持点。S105, for each second-type segmented area, perform: perform triangulation on the second-type segmented area, and divide the second-type segmented area into a plurality of triangular areas; point, according to each vertex of the triangular area and the parallax of each vertex to determine the first parallax search range corresponding to the non-support point; the points to be matched corresponding to each parallax in the first parallax search range are compared with the non-support point one by one Pixel matching, determining the disparity of the non-support point; wherein, each of the vertices is a support point.
本实施例中,虽然认为面积不大于第一阈值的第二类分割区域内的像素点都对应于同一平面。但由于第二类分割区域的面积较小,其包含的支持点个数较少,甚至于有可能没有足够的支持点进行平面拟合。因而,对于第二类分割区域,本发明采用了三角剖分的方法进行视差计算。In this embodiment, although it is considered that the pixels in the second type of segmented area whose area is not greater than the first threshold all correspond to the same plane. However, due to the small area of the second type of segmentation region, the number of support points contained in it is small, and there may not even be enough support points for plane fitting. Therefore, for the second type of segmented area, the present invention uses a triangulation method to calculate the disparity.
三角剖分,即构建Delaunay三角形,是代数拓扑学里的基本研究方法。对一图像区域进行三角剖分后,任意两个三角形或者不相交,或者恰好相交于一条边。本实施例中,由于三角形的各顶点均为支持点,所以三角形内的像素点的视差与三角形各顶点的视差较为相似。而且三角形内的像素点的视差与周围一定范围的支持点的视差也较为相似。将与一个像素点的视差较为相似的视差所对应的待匹配点与该像素点进行逐像素匹配,可以极大地缩小该像素点的视差搜索范围,在保证匹配准确性的基础上,提高了匹配效率,在具体的计算机实现过程中,实现了更快速地匹配计算。Triangulation, the construction of Delaunay triangles, is a fundamental research method in algebraic topology. After triangulating an image area, any two triangles either do not intersect, or intersect exactly at one edge. In this embodiment, since each vertex of the triangle is a support point, the disparity of the pixel points in the triangle is relatively similar to the disparity of each vertex of the triangle. Moreover, the parallax of the pixel points in the triangle is relatively similar to the parallax of the surrounding support points in a certain range. Matching the point to be matched corresponding to the disparity similar to the disparity of a pixel with the pixel can greatly reduce the disparity search range of the pixel, and improve the matching accuracy on the basis of ensuring the matching accuracy. Efficiency, in the specific computer implementation process, achieves faster matching calculations.
在图1所示实施例的一种实现方式中,如图2所示,步骤S104中的对该第一类分割区域进行第二次分割,将该第一类分割区域划分为多个第一类子分割区域,可以包括:In an implementation of the embodiment shown in FIG. 1 , as shown in FIG. 2 , in step S104, the first type of segmented area is divided for the second time, and the first type of segmented area is divided into a plurality of first Class sub-segmentation areas, which can include:
S201,按照预设的平面拟合规则,拟合该第一类分割区域内的多个支持点子集对应的物理平面的平面方程;其中,所述多个支持点子集分别对应于所述拍摄场景中不同的物理平面。S201. Fit the plane equation of the physical plane corresponding to the plurality of support point subsets in the first type of segmented area according to the preset plane fitting rule; wherein, the plurality of support point subsets respectively correspond to the shooting scene different physical planes.
S202,在拟合得到的各所述物理平面中,若其中多个物理平面满足预设合并条件,则根据所述多个物理平面内的支持点和支持点的视差,拟合得到合并后物理平面的平面方程;根据合并后物理平面的平面方程和未被合并的物理平面的平面方程,计算各合并后物理平面、未被合并的物理平面间的交线,确定出所述多个第一类子分割区域;其中,所述预设合并条件为:所述多个物理平面中,任一物理平面与至少一个其他物理平面的距离小于第三阈值;S202. Among the fitted physical planes, if multiple physical planes satisfy the preset merging condition, according to the support points in the multiple physical planes and the parallax of the support points, fit the merged physical plane The plane equation of the plane; according to the plane equation of the merged physical plane and the plane equation of the unmerged physical plane, calculate the intersection line between each merged physical plane and the unmerged physical plane, and determine the plurality of first Class subdivided regions; wherein, the preset merging condition is: among the plurality of physical planes, the distance between any physical plane and at least one other physical plane is less than a third threshold;
本实施例中,针对步骤S201得到的第一类分割区域的多个平面,若其中的两个平面的距离较小,则可以将这两个平面进行合并,看作是一个平面。可以理解,合并后平面的支持点个数要多于未合并的单个平面的支持点个数,那么通过合并后平面的支持点来拟合平面方程,要比单个平面的平面方程更为准确。上述第三阈值可根据经验设定,如设定为2。In this embodiment, for the multiple planes of the first type of segmented area obtained in step S201, if the distance between two of the planes is relatively small, the two planes may be merged and regarded as one plane. It can be understood that the number of support points of the merged plane is more than that of the unmerged single plane, so fitting the plane equation through the support points of the merged plane is more accurate than the plane equation of a single plane. The above-mentioned third threshold can be set according to experience, for example, set to 2.
具体的,计算两个平面间的距离,可通过以下方式实现:Specifically, calculating the distance between two planes can be achieved in the following ways:
设定平面1的平面方程为:A1*x+B1*y+C1*d+D1=0,其中心点为(x1,y1,d1),平面2的平面方程为:A2*x+B2*y+C2*d+D2=0,其中心点为(x2,y2,d2),则平面1和平面2间的距离D=dis1+dis2,其中,Set the plane equation of plane 1 as: A 1 *x+B 1 *y+C 1 *d+D 1 =0, its center point is (x 1 , y 1 , d 1 ), the plane equation of plane 2 is : A 2 *x+B 2 *y+C 2 *d+D 2 =0, its center point is (x 2 , y 2 , d 2 ), then the distance between plane 1 and plane 2 is D=dis 1 + dis 2 , where,
具体的,步骤S202中的“根据所述多个物理平面内的支持点和支持点的视差,拟合得到合并后物理平面的平面方程”的实现过程可以参考步骤S104中的“根据每个第一类子分割区域内的支持点和支持点的视差,拟合该第一类子分割区域的第一平面方程”这一步骤的实现过程。Specifically, in step S202, the implementation process of "according to the support points in the multiple physical planes and the disparity of the support points, fitting to obtain the plane equation of the combined physical plane" can refer to the "according to each Support points in a class of sub-segmentation regions and the parallax of the support points, fitting the first plane equation of the first type of sub-segmentation regions” is the implementation process of this step.
在各合并后的平面、各未合并的平面中,相邻两个平面间的交线上的像素点满足该相邻两个平面各自的平面方程。在确定出所有相邻平面间的交线后,也就确定出了第一类分割区域的多个第一类子分割区域。In each merged plane and each unmerged plane, the pixel points on the intersection line between two adjacent planes satisfy the respective plane equations of the two adjacent planes. After determining the intersection lines between all adjacent planes, multiple first-type sub-segmentation areas of the first-type divisional area are also determined.
S203,在拟合得到的各所述物理平面中,若其中任意两个物理平面不满足所述预设合并条件,则根据各所述物理平面的平面方程,计算各所述物理平面间的交线,确定出所述多个第一类子分割区域。S203. Among the fitted physical planes, if any two of the physical planes do not meet the preset merging condition, calculate the intersection between the physical planes according to the plane equations of the physical planes. Lines to determine the plurality of first-type sub-divided regions.
经过上述步骤S201-S203实现了对第一类分割区域进行二次分割,所得到的每个第一类子分割区域对应了拍摄场景中不同的物理平面。因而本实施例中,可以基于确定出的第一类子分割区域中的支持点拟合该第一类子分割区域的平面方程。Through the above steps S201-S203, the secondary segmentation of the first type of segmented area is realized, and each obtained first type of sub-segmented area corresponds to a different physical plane in the shooting scene. Therefore, in this embodiment, the plane equation of the first type of sub-segmentation area may be fitted based on the determined support points in the first type of sub-segmentation area.
在图2所示实现方式的一种具体实现方式中,如图3所示,步骤S201中的按照预设的平面拟合规则,拟合该第一类分割区域内的多个支持点子集对应的物理平面的平面方程,可以包括:In a specific implementation of the implementation shown in FIG. 2 , as shown in FIG. 3 , in step S201, according to the preset plane fitting rules, fitting the plurality of support point subsets corresponding to the first type of segmentation area The plane equation for the physical plane of , can include:
S301,基于随机抽样一致性RANSAC算法,从该第一类分割区域内的当前支持点集Y中选取目标支持点子集O;其中,所述O为所述Y中、支持点个数最多的支持点子集;S301, based on the random sampling consistent RANSAC algorithm, select a target support point subset O from the current support point set Y in the first type of segmented area; wherein, the O is the support with the largest number of support points in the Y set of ideas;
RANSAC算法可以比较准确地将图像中对应于同一平面的像素点选取出来。由于本发明具体是通过对应于一个平面的支持点和支持点的视差拟合该平面的方程。所以本实施例中,只需要通过RANSAC算法将第一类分割区域内的对应于各平面的支持点选取出来即可。具体的,可以按照支持点子集中支持点个数由多到少的顺序,逐一拟合每个支持点子集对应的平面的平面方程。The RANSAC algorithm can more accurately select the pixels corresponding to the same plane in the image. Because the present invention specifically fits the equation of a plane through the support points corresponding to the plane and the parallax of the support points. Therefore, in this embodiment, it is only necessary to select the support points corresponding to each plane in the first type of segmented area through the RANSAC algorithm. Specifically, the plane equations of the planes corresponding to each support point subset may be fitted one by one in the descending order of the number of support points in the support point subset.
S302,根据所述O的支持点和支持点的视差,拟合所述O对应的物理平面的平面方程;S302, fitting the plane equation of the physical plane corresponding to the O according to the support points of the O and the parallax of the support points;
具体的,步骤S302的实现过程可以参考步骤S104中的“根据每个第一类子分割区域内的支持点和支持点的视差,拟合该第一类子分割区域的第一平面方程”这一步骤的实现过程。Specifically, the implementation process of step S302 can refer to the "according to the support points in each first type of sub-segmentation area and the parallax of the support points, fitting the first plane equation of the first type of sub-segmentation area" in step S104 One-step implementation process.
S303,判断当前未拟合支持点子集Y-O的支持点个数是否少于预设比例的该第一类分割区域内的支持点个数;S303, judging whether the number of support points of the currently unfit support point subset Y-O is less than the number of support points in the first type of segmented area of the preset ratio;
可以理解,若当前未拟合支持点子集Y-O的支持点个数太少,甚至当前未拟合支持点子集Y-O已没有足够的支持点进行平面拟合,那么在这种情况下,就不能根据当前未拟合支持点子集Y-O的支持点来拟合其平面方程。具体的,上述预设比例可以根据经验设定,如设定为10%。It can be understood that if the number of support points in the current unfit support point subset Y-O is too small, or even the current unfit support point subset Y-O does not have enough support points for plane fitting, then in this case, it cannot be based on The support points of the support point subset Y-O are not currently fitted to fit their plane equations. Specifically, the aforementioned preset ratio can be set according to experience, for example, set to 10%.
S304,若所述Y-O的支持点个数不少于预设比例的该第一类分割区域内的支持点个数,则将所述Y-O作为该第一类分割区域内的当前支持点集,返回执行步骤S301;S304, if the number of support points of the Y-O is not less than the number of support points in the first-type segmented area of a preset ratio, use the Y-O as the current support point set in the first-type segmented area, Return to step S301;
S305,若所述Y-O的支持点个数少于预设比例的该第一类分割区域内的支持点个数,则将当前已拟合的物理平面的平面方程作为最终的拟合结果。S305. If the number of support points of the Y-O is less than the number of support points in the first-type segmented region of the preset ratio, use the plane equation of the currently fitted physical plane as the final fitting result.
对于剩余的未拟合的支持点子集Y-O的支持点,会在图2所示实施方式中的步骤S202或步骤S203中确定平面交线的过程中,被包含在某个第一类子分割区域内。具体的,这些未拟合的支持点可能会被包含在不同的第一类子分割区域,或者可能会被包含在相同的第一类子分割区域。For the support points of the remaining unfit support point subset Y-O, they will be included in a certain first type of sub-division area during the process of determining the plane intersection line in step S202 or step S203 in the embodiment shown in FIG. 2 Inside. Specifically, these unfit support points may be included in different first-type sub-segmentation regions, or may be included in the same first-type sub-segmentation region.
经过上述步骤S301-S305的迭代,可以得到第一类分割区域内多个不同平面的平面方程。而且在具体的计算机实现过程中,可以同时对多个第一类分割区域进行上述步骤S301-S305的迭代处理,因此提高了匹配效率。Through the iteration of the above steps S301-S305, the plane equations of multiple different planes in the first type of segmented area can be obtained. Moreover, in a specific computer implementation process, the iterative processing of the above-mentioned steps S301-S305 can be performed on multiple first-type segmented regions at the same time, thus improving the matching efficiency.
在图1所示实施例的一种实现方式中,步骤S105中的针对每个三角形区域内的每个非支持点,根据该三角形区域的各顶点和各顶点的视差确定该非支持点对应的第一视差搜索范围,可以包括:In an implementation of the embodiment shown in FIG. 1 , for each unsupported point in each triangular area in step S105, the corresponding vertex of the unsupported point is determined according to the vertices of the triangular area and the parallax of each vertex. The first disparity search range can include:
针对每个三角形区域,根据该三角形区域内的各顶点和各顶点的视差,确定该三角形区域所在平面的第二平面方程;For each triangular area, according to each vertex in the triangular area and the parallax of each vertex, determine the second plane equation of the plane where the triangular area is located;
根据所述第二平面方程确定该非支持点的视差估计值;determining an estimated parallax value of the unsupported point according to the second plane equation;
所述第一视差搜索范围包括:所述各顶点的视差、将所述各顶点的视差加和减预设值后的视差、所述视差估计值以及该非支持点所属的预设邻域内的目标支持点的视差;其中,所述目标支持点的视差与根据所述第二平面方程确定的该目标支持点的视差估计值之差的绝对值不超过第四阈值。The first disparity search range includes: the disparity of each vertex, the disparity obtained by adding and subtracting a preset value from the disparity of each vertex, the estimated disparity value, and the disparity in the preset neighborhood to which the non-support point belongs. The parallax of the target support point; wherein, the absolute value of the difference between the parallax of the target support point and the estimated value of the parallax of the target support point determined according to the second plane equation does not exceed a fourth threshold.
在上述实现方式中,“针对每个三角形区域,根据该三角形区域内的各顶点和各顶点的视差,确定该三角形区域所在平面的第二平面方程”的实现过程可以参考步骤S104中的“根据每个第一类子分割区域内的支持点和支持点的视差,拟合该第一类子分割区域的第一平面方程”这一步骤的实现过程。In the above implementation, the implementation process of "for each triangular area, according to the vertices in the triangular area and the parallax of each vertex, determine the second plane equation of the plane where the triangular area is located" can refer to the "According to The implementation process of the step of fitting the support points and the parallax of the support points in each first type of sub-division area to the first plane equation of the first type of sub-division area".
示例性地,假设所确定的第二平面方程为:A*x+B*y+C*d+D=0,则三角形内一非支持点(x0,y0)的视差估计值为 Exemplarily, assuming that the determined second plane equation is: A*x+B*y+C*d+D=0, then the disparity estimation value of a non-support point (x 0 , y 0 ) in the triangle is
上述预设值可以为一个值或多个值,如果为一个值,则可以为1,如果为多个值,则可以为1、2等。例如:三角形一个顶点的视差值为2,预设值为1,则将顶点视差加和减预设值后的视差为:1和3。The aforementioned preset value can be one value or multiple values, if it is one value, it can be 1, if it is multiple values, it can be 1, 2, etc. For example: the parallax value of a vertex of a triangle is 2, and the default value is 1, then the parallax after adding and subtracting the preset value to the vertex parallax is: 1 and 3.
上述该非支持点所属的预设邻域可以是:将参考图像划分为多个预设大小的矩形区域后,根据该非支持点的坐标确定出其所属的矩形区域。更为具体地,可以对每个矩形区域进行位置标记,根据该非支持点的坐标确定其所属的矩形区域的位置标记,也就确定出该非支持点所述的矩形区域是哪个矩形区域。例如:参考图像为40×40的图像,将其划分为4个20×20的小区域,将这4个矩形区域分别标记为(0,0)、(0,1)、(1,0)、(1,1)。一个非支持点的坐标为(3,5),则3/20=0,5/20=0,所以它属于(0,0)这个区域;另一个非支持点的坐标为(35,2),同理35/20=1,2/20=0,则它属于(1,0)这个矩形区域。上述预设大小可根据经验设定,如设定为20×20。同样,上述第四阈值也可以根据经验设定,如设定为2。The aforementioned preset neighborhood to which the non-support point belongs may be: after dividing the reference image into a plurality of rectangular areas of a preset size, the rectangular area to which the non-support point belongs is determined according to the coordinates of the non-support point. More specifically, each rectangular area can be marked with a position, and the position mark of the rectangular area to which it belongs is determined according to the coordinates of the non-support point, and it is determined which rectangular area the rectangular area described by the non-support point is. For example: the reference image is a 40×40 image, which is divided into four small areas of 20×20, and these four rectangular areas are marked as (0,0), (0,1), (1,0) , (1, 1). The coordinates of a non-support point are (3, 5), then 3/20=0, 5/20=0, so it belongs to the area of (0, 0); the coordinates of another non-support point are (35, 2) , similarly 35/20=1, 2/20=0, then it belongs to the rectangular area (1,0). The above preset size can be set according to experience, for example, it is set to 20×20. Similarly, the above fourth threshold can also be set according to experience, for example, set to 2.
确定出三角形内一个非支持点的第一视差搜索范围后,可以将该第一视差搜索范围的各视差对应的各待匹配点与该非支持点进行逐一匹配,以从各待匹配点中确定出该支持点的匹配点。After determining the first parallax search range of a non-support point in the triangle, each point to be matched corresponding to each parallax of the first parallax search range can be matched with the non-support point one by one, so as to determine from each point to be matched Out of the matching point of the support point.
在图1所示实施例的一种实现方式中,步骤S105中的将所述第一视差搜索范围内各视差对应的待匹配点与该非支持点进行逐像素匹配,确定该非支持点的视差,可以包括:In an implementation of the embodiment shown in FIG. 1 , in step S105, the point to be matched corresponding to each disparity in the first disparity search range is matched pixel by pixel with the non-support point, and the non-support point is determined. Parallax, which can include:
通过以下公式,确定该非支持点的视差:The non-support point is determined by the following formula Parallax for:
其中,为该非支持点的视差,dn表示所述该非支持点的视差估计值,表示所述第一视差搜索范围内的各视差,N表示所述第一视差搜索范围内的视差数,S表示所述参考图像的支持点集;表示的后验概率,通过以下公式计算:in, for the non-support point The disparity, d n represents the disparity estimated value of the non-support point, Represents each disparity within the first disparity search range, N represents the number of disparities within the first disparity search range, and S represents the support point set of the reference image; express The posterior probability of , calculated by the following formula:
其中,表示dn对应的待匹配点为所述非支持点的正确匹配点的概率,表示所述第一视差搜索范围内的各视差对应的匹配点为所述非支持点的正确匹配点的概率。in, Indicates that the point to be matched corresponding to d n is the non-support point The probability of the correct matching point of , Indicates that the matching points corresponding to each disparity within the first disparity search range are the non-support points The probability of the correct matching point of .
上述以及是一种概率化的表示。具体的,本实施例中,可以计算非支持点与各待匹配点的相似度,该相似度可以用非支持点的像素值与待匹配点的像素值之差的绝对值表示。如果一个待匹配点的像素值与非支持点的像素值之差的绝对值越小,表示这个待匹配点与非支持点越相似,则这个待匹配点是非支持点的正确匹配点的概率就越大。the above as well as is a probabilistic representation. Specifically, in this embodiment, non-support points can be calculated The similarity with each point to be matched, the similarity can use non-support points The absolute value of the difference between the pixel value of and the pixel value of the point to be matched. If the pixel value of a point to be matched is the same as the non-support point The smaller the absolute value of the difference between the pixel values, it means that the point to be matched and the non-support point The more similar, the point to be matched is a non-support point The probability of the correct matching point is greater.
本发明实施例提供的基于平面约束和三角剖分的双目视觉立体匹配方法,针对面积较大的分割区域的各子分割区域,基于平面约束的思想,通过各子分割区域的平面方程确定各子分割区域内所有非支持点的视差,能够实现对缺失像素信息的遮挡区域以及存在匹配二义性的大面积无纹理区域更为准确地且鲁棒性更好地匹配,从而降低了匹配错误率。并且本发明实施例,针对面积较小的分割区域进行三角剖分,根据三角形的顶点和顶点视差确定三角形内非支持点的视差搜索范围,极大缩小了非支持点的视差搜索范围,提高了匹配效率。The binocular vision stereo matching method based on plane constraints and triangulation provided by the embodiment of the present invention, for each sub-segmented area of a larger-area segmented area, based on the idea of plane constraints, each sub-segmented area is determined by the plane equation of each sub-segmented area. The disparity of all non-support points in the sub-segmentation area can achieve more accurate and robust matching of occluded areas with missing pixel information and large areas of texture-free areas with matching ambiguities, thereby reducing matching errors Rate. And in the embodiment of the present invention, triangulation is carried out for the smaller segmented area, and the parallax search range of the unsupported points in the triangle is determined according to the vertices of the triangle and the parallax of the vertices, which greatly reduces the parallax search range of the unsupported points and improves the matching efficiency.
为了验证本发明实施例提供的基于平面约束和三角剖分的双目视觉立体匹配方法的有益效果,本发明通过仿真实验进行了具体的验证,如图4所示。其中,(a)是Cones测试集中的左图;(b)是Cones测试集中的右图;(c)是Middlebury平台提供的以(a)为参考图像的真实视差图;(d)是对(a)进行Meanshift分割后的结果图;(e)中黑色框表示Meanshift分割结果图中分割错误的第一类分割区域;(f)是从(e)中提取的待进行二次分割的某一第一类分割区域的轮廓;(g)是将(f)中的第一类分割区域进行RANSAC平面拟合后得到的二次分割结果图;(h)是对(a)进行三角剖分得到的三角形;(i)是基于本发明提出的匹配方法得到的视差图;(j)是用基于最小生成树的非局部方法得到的视差图;(k)是基于LIBELAS(Library for Efficient Large-scale Stereo Matching)算法得到的视差图;(1)是基于支持窗口的局部方法得到的视差图。In order to verify the beneficial effects of the binocular vision stereo matching method based on plane constraints and triangulation provided by the embodiment of the present invention, the present invention conducts specific verification through simulation experiments, as shown in FIG. 4 . Among them, (a) is the left image in the Cones test set; (b) is the right image in the Cones test set; (c) is the real disparity map provided by the Middlebury platform with (a) as the reference image; (d) is the pair ( a) The result map after Meanshift segmentation; the black box in (e) indicates the first type of segmentation error in the Meanshift segmentation result map; (f) is a certain segment extracted from (e) to be divided twice The outline of the first type of segmented area; (g) is the second segmentation result obtained by fitting the first type of segmented area in (f) with RANSAC plane; (h) is obtained by triangulating (a) (i) is the disparity map obtained based on the matching method proposed by the present invention; (j) is the disparity map obtained by the non-local method based on the minimum spanning tree; (k) is based on LIBELAS (Library for Efficient Large-scale The disparity map obtained by the Stereo Matching algorithm; (1) is the disparity map obtained by the local method based on the support window.
在仿真实验中,为了提高匹配效率,利用现有的计算资源对参考图像同时进行两路运算,一路对参考图像进行Meanshift分割,另一路直接对整幅参考图像进行三角剖分,如(h)所示。In the simulation experiment, in order to improve the matching efficiency, the existing computing resources are used to perform two operations on the reference image at the same time, one is to perform Meanshift segmentation on the reference image, and the other is to directly triangulate the entire reference image, such as (h) shown.
通过图4的仿真结果可以看出,基于本发明提出的基于平面约束和三角剖分的双目视觉立体匹配方法得到的视差图的效果要明显优于基于其他三种方法得到的视差图。It can be seen from the simulation results in Fig. 4 that the effect of the disparity map obtained based on the binocular vision stereo matching method based on the plane constraint and triangulation proposed by the present invention is significantly better than that obtained based on the other three methods.
为了进一步验证发明实施例提供的基于平面约束和三角剖分的双目视觉立体匹配方法的有益效果,如表1所示,本发明针对来自Middlebury平台提供的四组标准测试图,具体为:Venus、Cones、Tsukuba和Teddy,比较了本申请提供的基于平面约束和三角剖分的双目视觉立体匹配方法与其它三种立体匹配算法在匹配每一组标准测试图时的匹配错误率。具体地,针对每一组标准测试图,比较了三种具体情况下的匹配错误率。其中,其他三种立体匹配算法包括:导向滤波(Guided filter,简称GF)算法;非局部平均(Non-Local,简称NL)算法;LIBELAS算法。三种具体情况包括:Nonocc:不考虑存在遮挡区域的情况;All:包含全图所有区域的情况;Disc:只考虑深度不连续区域的情况。In order to further verify the beneficial effects of the binocular vision stereo matching method based on plane constraints and triangulation provided by the embodiment of the invention, as shown in Table 1, the present invention is aimed at four sets of standard test diagrams provided by the Middlebury platform, specifically: Venus , Cones, Tsukuba and Teddy, compared the matching error rate of the binocular vision stereo matching method based on plane constraints and triangulation provided by this application with other three stereo matching algorithms when matching each set of standard test images. Specifically, for each set of standard test patterns, the matching error rates in three specific cases are compared. Among them, the other three stereo matching algorithms include: Guided filter (GF for short) algorithm; Non-Local average (NL for short) algorithm; LIBELAS algorithm. Three specific cases include: Nonocc: the case where there is no occlusion area; All: the case that includes all areas of the whole image; Disc: only the case where the depth discontinuity area is considered.
表1本发明方法与其他三种立体匹配算法的匹配错误率Table 1 The matching error rate of the inventive method and other three stereo matching algorithms
从表1中可以看出,在大多数情况下,本发明提出的基于平面约束和三角剖分的双目视觉立体匹配方法的匹配错误率要低于其他三种立体匹配算法的匹配错误率。因此,本发明方法的立体匹配效果要优于其他三种立体匹配算法。It can be seen from Table 1 that in most cases, the matching error rate of the binocular vision stereo matching method based on plane constraints and triangulation proposed by the present invention is lower than that of the other three stereo matching algorithms. Therefore, the stereo matching effect of the method of the present invention is better than the other three stereo matching algorithms.
图5为本发明实施例提供的一种基于平面约束和三角剖分的双目视觉立体匹配装置的结构图,该装置包括:FIG. 5 is a structural diagram of a binocular vision stereo matching device based on plane constraints and triangulation provided by an embodiment of the present invention. The device includes:
获取模块501,用于获取两个平行放置的摄像机在同一时间分别采集的同一拍摄场景的左图像和右图像,并将其中任一幅作为参考图像,另一幅作为待匹配图像;The acquisition module 501 is used to acquire the left image and the right image of the same shooting scene collected by two parallel cameras at the same time, and any one of them is used as a reference image, and the other is used as an image to be matched;
确定模块502,用于确定所述参考图像中的支持点,并计算各所述支持点的视差;其中,所述支持点为所述参考图像中的、在所述待匹配图像中有唯一且正确匹配点的像素点;The determination module 502 is configured to determine the support points in the reference image, and calculate the disparity of each of the support points; wherein, the support points are unique and unique in the image to be matched in the reference image. Correctly match the pixels of the point;
分割模块503,用于按照预设的图像分割方式,对所述参考图像进行分割,得到多个分割区域;将各所述分割区域划分为分割面积大于第一阈值的第一类分割区域,和/或分割面积不大于所述第一阈值的第二类分割区域;A segmentation module 503, configured to segment the reference image according to a preset image segmentation method to obtain a plurality of segmented areas; divide each segmented area into a first type of segmented area whose segmented area is greater than a first threshold, and /or a second type of segmented area whose segmented area is not greater than the first threshold;
第一执行模块504,用于针对每个第一类分割区域,执行:对该第一类分割区域进行第二次分割,将该第一类分割区域划分为多个第一类子分割区域;根据每个第一类子分割区域内的支持点和支持点的视差,拟合该第一类子分割区域的第一平面方程;根据所述第一平面方程,确定该第一类子分割区域内非支持点的视差;其中,所述多个第一类子分割区域分别对应于所述拍摄场景中不同的物理平面;The first executing module 504 is configured to execute, for each segmented area of the first type: performing a second segment on the segmented area of the first type, and divide the segmented area of the first type into a plurality of sub-segmented areas of the first type; According to the support points and the disparity of the support points in each first type of sub-segmentation area, fitting the first plane equation of the first type of sub-segmentation area; according to the first type of sub-segmentation area, determining the first type of sub-segmentation area The parallax of the inner non-support point; wherein, the plurality of first-type sub-segmented regions respectively correspond to different physical planes in the shooting scene;
第二执行模块505,用于针对每个第二类分割区域,执行:对该第二类分割区域进行三角剖分,将该第二类分割区域划分为多个三角形区域;针对每个三角形区域内的每个非支持点,根据该三角形区域的各顶点和各顶点的视差确定该非支持点对应的第一视差搜索范围;将所述第一视差搜索范围内各视差对应的待匹配点与该非支持点进行逐像素匹配,确定该非支持点的视差;其中,所述各顶点均为支持点。The second execution module 505 is configured to, for each second-type segmented area, execute: triangulating the second-type segmented area, dividing the second-type segmented area into a plurality of triangular areas; for each triangular area For each unsupported point in the triangular area, determine the first disparity search range corresponding to the unsupported point according to each vertex of the triangular area and the disparity of each apex; The unsupported point is matched pixel by pixel to determine the disparity of the unsupported point; wherein, each of the vertices is a support point.
本发明实施例提供的基于平面约束和三角剖分的双目视觉立体匹配装置的有益效果与方法实施例的有益效果相同。该装置针对面积较大的分割区域的各子分割区域,基于平面约束的思想,通过各子分割区域的平面方程确定各子分割区域内所有非支持点的视差,能够实现对缺失像素信息的遮挡区域以及存在匹配二义性的大面积无纹理区域更为准确地且鲁棒性更好地匹配,从而降低了匹配错误率。并且本发明实例,针对面积较小的分割区域进行三角剖分,根据三角形的顶点和顶点视差确定三角形内非支持点的视差搜索范围,极大缩小了非支持点的视差搜索范围,提高了匹配效率。The beneficial effect of the binocular vision stereo matching device based on plane constraint and triangulation provided by the embodiment of the present invention is the same as that of the method embodiment. For each sub-segmented area of a larger-area segmented area, based on the idea of plane constraints, the device determines the parallax of all non-support points in each sub-segmented area through the plane equation of each sub-segmented area, and can realize the occlusion of missing pixel information Regions and large textureless regions with matching ambiguity are more accurately and robustly matched, thereby reducing the matching error rate. And example of the present invention, triangulation is carried out for the segmented area lesser in area, determines the disparity search range of unsupported points in the triangle according to the apex of triangle and vertex disparity, greatly reduces the disparity search range of unsupported points, improves matching efficiency.
可选地,所述确定模块502包括:网格构建子模块、确定子模块。Optionally, the determination module 502 includes: a grid construction submodule and a determination submodule.
网格构建子模块,用于以所述参考图像的左上角像素点作为起点,沿所述参考图像对应的像素坐标系的u轴和v轴,在所述参考图像中构建步长为预设步长的网格;将所述网格中的、除了位于所述参考图像边缘处的交点作为候选支持点;其中,u轴向右,v轴向下。The grid construction sub-module is used to use the upper left pixel point of the reference image as a starting point, along the u-axis and v-axis of the pixel coordinate system corresponding to the reference image, and construct a step size of preset in the reference image A grid with a step size; the intersection points in the grid, except those located at the edge of the reference image, are used as candidate support points; wherein, the u axis is rightward, and the v axis is downward.
第一确定子模块,用于针对每个候选支持点,计算预先设置的该候选支持点对应的第二视差搜索范围内各视差对应的待匹配点的向量与该候选支持点的向量的距离;若计算得到的所述距离中小于第二阈值的各距离中,最小的距离的个数为1,则将该候选支持点作为支持点;其中,所述第二视差搜索范围内各视差对应的待匹配点的向量,以及所述该候选支持点的向量均根据预设尺寸的sobel算子计算得到。The first determination submodule is used to calculate, for each candidate support point, the distance between the vector of the point to be matched and the vector of the candidate support point corresponding to each parallax in the second parallax search range corresponding to the preset candidate support point; If the number of the smallest distance among the calculated distances smaller than the second threshold is 1, then use the candidate support point as a support point; wherein, each parallax corresponding to the second parallax search range The vectors of the points to be matched and the vectors of the candidate support points are calculated according to a sobel operator with a preset size.
可选地,所述分割模块503,具体用于按照均值偏移Meanshift图像分割方式,对所述参考图像进行分割,得到至少一个分割区域。Optionally, the segmentation module 503 is specifically configured to segment the reference image according to the Meanshift image segmentation method to obtain at least one segmented region.
可选地,所述第一执行模块504包括:第一拟合子模块、第二拟合子模块、第二确定子模块和第三确定子模块。Optionally, the first executing module 504 includes: a first fitting submodule, a second fitting submodule, a second determining submodule, and a third determining submodule.
第一拟合子模块,用于按照预设的平面拟合规则,拟合该第一类分割区域内的多个支持点子集对应的物理平面的平面方程;其中,所述多个支持点子集分别对应于所述拍摄场景中不同的物理平面;在拟合得到的各所述物理平面中,若其中多个物理平面满足预设合并条件,则触发第二拟合子模块;在拟合得到的各所述物理平面中,若其中任意两个物理平面不满足所述预设合并条件,则触发第三确定子模块;其中,所述预设合并条件为:所述多个物理平面中,任一物理平面与至少一个其他物理平面的距离小于第三阈值。The first fitting submodule is used to fit the plane equation of the physical plane corresponding to the plurality of support point subsets in the first type of segmented area according to the preset plane fitting rule; wherein, the plurality of support point subsets Corresponding to different physical planes in the shooting scene respectively; in each of the physical planes obtained by fitting, if a plurality of physical planes satisfy the preset merging condition, the second fitting submodule is triggered; after the fitting is obtained In each of the physical planes, if any two of the physical planes do not meet the preset merging condition, a third determining submodule is triggered; wherein the preset merging condition is: among the multiple physical planes, A distance of any physical plane from at least one other physical plane is less than a third threshold.
第二拟合子模块,用于根据所述多个物理平面内的支持点和支持点的视差,拟合得到合并后物理平面的平面方程,触发第二确定子模块;The second fitting submodule is used to fit the plane equation of the merged physical plane according to the support points in the multiple physical planes and the parallax of the support points, and trigger the second determination submodule;
第二确定子模块,用于根据合并后物理平面的平面方程和未被合并的物理平面的平面方程,计算各合并后物理平面、未被合并的物理平面间的交线,确定出所述多个第一类子分割区域。The second determining submodule is used to calculate the intersection lines between the combined physical planes and the unmerged physical planes according to the plane equation of the combined physical plane and the plane equation of the unmerged physical plane, and determine the multiple A first-class sub-segmentation area.
第三确定子模块,用于根据各所述物理平面的平面方程,计算各所述物理平面间的交线,确定出所述多个第一类子分割区域。The third determination sub-module is configured to calculate the intersection lines between the physical planes according to the plane equations of the physical planes, and determine the plurality of first-type subdivided regions.
可选地,第一拟合子模块包括:选取子单元、拟合子单元和判断子单元。Optionally, the first fitting submodule includes: a selection subunit, a fitting subunit and a judging subunit.
选取子单元,用于基于随机抽样一致性RANSAC算法,从该第一类分割区域内的当前支持点集Y中选取目标支持点子集O;其中,所述O为所述Y中、支持点个数最多的支持点子集。Selecting a subunit, used to select a target support point subset O from the current support point set Y in the first type of segmented area based on the random sampling consistency RANSAC algorithm; wherein, the O is the number of support points in the Y The subset with the largest number of support points.
拟合子单元,用于根据所述O的支持点和支持点的视差,拟合所述O对应的物理平面的平面方程。The fitting subunit is configured to fit the plane equation of the physical plane corresponding to the O according to the support points of the O and the parallax of the support points.
判断子单元,用于判断当前未拟合支持点子集Y-O的支持点个数是否少于预设比例的该第一类分割区域内的支持点个数;若所述Y-O的支持点个数不少于预设比例的该第一类分割区域内的支持点个数,则将所述Y-O作为该第一类分割区域内的当前支持点集,触发选取子单元;若所述Y-O的支持点个数少于预设比例的该第一类分割区域内的支持点个数,则将当前已拟合的物理平面的平面方程作为最终的拟合结果。A judging subunit, used to judge whether the number of support points of the current unfit support point subset Y-O is less than the number of support points in the first type of segmented area of the preset ratio; if the number of support points of the Y-O is not The number of support points in the first type of segmented area that is less than the preset ratio, then use the Y-O as the current support point set in the first type of segmented area to trigger the selection of subunits; if the support points of the Y-O If the number of support points in the first-type segmented region is less than the preset ratio, the plane equation of the currently fitted physical plane is taken as the final fitting result.
可选地,所述第一执行模块504,具体用于设定第一类子分割区域的第一平面方程为:Optionally, the first execution module 504 is specifically used to set the first plane equation of the first type of sub-segmentation area as:
d(u,v)=au+bv+cd(u,v)=au+bv+c
其中,d(u,v)表示第一类子分割区域内像素点(u,v)的视差,a,b,c为所述第一平面方程的待求解参数,通过以下公式求解所述a,b,c:Wherein, d(u, v) represents the disparity of the pixel point (u, v) in the first type of sub-division area, a, b, c are the parameters to be solved of the first plane equation, and the a is solved by the following formula ,b,c:
其中,ui表示第一类子分割区域内第i个支持点在所述参考图像对应的像素坐标系的u轴的坐标,vi表示第一类子分割区域内第i个支持点在所述参考图像对应的像素坐标系的v轴的坐标,u轴向右,v轴向下,i=1,...,m,m表示第一类子分割区域内的支持点个数,di表示第一类子分割区域内第i个支持点的视差。Among them, u i represents the coordinates of the u-axis of the i-th support point in the pixel coordinate system corresponding to the reference image in the first type of sub-segmentation area, and v i represents the i-th support point in the first type of sub-segmentation area. The coordinates of the v axis of the pixel coordinate system corresponding to the reference image, the u axis is right, the v axis is down, i=1,..., m, m represents the number of support points in the first type of sub-division area, d i represents the disparity of the i-th support point in the sub-segmentation area of the first type.
可选地,第二执行模块505,包括:第四确定子模块、第五确定子模块。Optionally, the second executing module 505 includes: a fourth determining submodule and a fifth determining submodule.
第四确定子模块,用于针对每个三角形区域,根据该三角形区域内的各顶点和各顶点的视差,确定该三角形区域所在平面的第二平面方程。The fourth determination sub-module is used for determining, for each triangular area, the second plane equation of the plane where the triangular area is located according to the vertices in the triangular area and the parallax of the vertices.
第五确定子模块,用于根据所述第二平面方程确定该非支持点的视差估计值。The fifth determination submodule is configured to determine the estimated parallax value of the non-support point according to the second plane equation.
所述第一视差搜索范围包括:所述各顶点的视差、将所述各顶点的视差加和减预设值后的视差、第五确定子模块确定的所述视差估计值以及以该非支持点为中心的预设邻域内的目标支持点的视差;其中,所述目标支持点的视差与根据所述第二平面方程确定的该目标支持点的视差估计值之差的绝对值不超过第四阈值。The first parallax search range includes: the parallax of each vertex, the parallax obtained by adding and subtracting a preset value from the parallax of each vertex, the estimated value of parallax determined by the fifth determining submodule, and the non-supported The parallax of the target support point within the preset neighborhood centered on the point; wherein, the absolute value of the difference between the parallax of the target support point and the estimated value of the target support point’s parallax determined according to the second plane equation does not exceed the first Four thresholds.
可选地,第二执行模块505,具体用于通过以下公式,确定该非支持点的视差:Optionally, the second execution module 505 is specifically configured to determine the non-support point through the following formula Parallax for:
其中,为该非支持点的视差,dn表示所述该非支持点的视差估计值,表示所述第一视差搜索范围内的各视差,N表示所述第一视差搜索范围内的视差数,S表示所述参考图像的支持点集;表示的后验概率,通过以下公式计算:in, for the non-support point The disparity, d n represents the disparity estimated value of the non-support point, Represents each disparity within the first disparity search range, N represents the number of disparities within the first disparity search range, and S represents the support point set of the reference image; express The posterior probability of , calculated by the following formula:
其中,表示dn的先验概率,表示所述第一视差搜索范围内的各视差对应的匹配点为所述非支持点的正确匹配点的概率。in, Indicates the prior probability of d n , Indicates that the matching points corresponding to each disparity within the first disparity search range are the non-support points The probability of the correct matching point of .
本发明实施例还提供了一种电子设备,如图6所示,包括处理器601、通信接口602、存储器603和通信总线604,其中,处理器601,通信接口602,存储器603通过通信总线604完成相互间的通信,The embodiment of the present invention also provides an electronic device, as shown in FIG. complete the mutual communication,
存储器603,用于存放计算机程序;Memory 603, used to store computer programs;
处理器601,用于执行存储器603上所存放的程序时,实现如下步骤:When the processor 601 is used to execute the program stored on the memory 603, the following steps are implemented:
获取两个平行放置的摄像机在同一时间分别采集的同一拍摄场景的左图像和右图像,并将其中任一幅作为参考图像,另一幅作为待匹配图像;Obtain the left image and the right image of the same shooting scene collected by two parallel cameras at the same time, and use any one of them as a reference image and the other as an image to be matched;
确定所述参考图像中的支持点,并计算各所述支持点的视差;其中,所述支持点为所述参考图像中的、在所述待匹配图像中有唯一且正确匹配点的像素点;Determining the support points in the reference image, and calculating the parallax of each of the support points; wherein, the support points are pixels in the reference image that have unique and correct matching points in the image to be matched ;
按照预设的图像分割方式,对所述参考图像进行分割,得到多个分割区域;将各所述分割区域划分为分割面积大于第一阈值的第一类分割区域,和/或分割面积不大于所述第一阈值的第二类分割区域;According to the preset image segmentation method, the reference image is segmented to obtain a plurality of segmented areas; each of the segmented areas is divided into the first type of segmented area whose segmented area is larger than the first threshold, and/or the segmented area is not larger than the second type of segmentation region of the first threshold;
针对每个第一类分割区域,执行:对该第一类分割区域进行第二次分割,将该第一类分割区域划分为多个第一类子分割区域;根据每个第一类子分割区域内的支持点和支持点的视差,拟合该第一类子分割区域的第一平面方程;根据所述第一平面方程,确定该第一类子分割区域内非支持点的视差;其中,所述多个第一类子分割区域分别对应于所述拍摄场景中不同的物理平面;For each first-type segmented area, perform: perform a second segment on the first-type segmented area, divide the first-type segmented area into a plurality of first-type sub-segmented areas; The support points in the region and the parallax of the support points are fitted to the first plane equation of the first type of sub-segmentation area; according to the first plane equation, the parallax of the non-support points in the first type of sub-segmentation area is determined; wherein , the plurality of first-type sub-divided regions respectively correspond to different physical planes in the shooting scene;
针对每个第二类分割区域,执行:对该第二类分割区域进行三角剖分,将该第二类分割区域划分为多个三角形区域;针对每个三角形区域内的每个非支持点,根据该三角形区域的各顶点和各顶点的视差确定该非支持点对应的第一视差搜索范围;将所述第一视差搜索范围内各视差对应的待匹配点与该非支持点进行逐像素匹配,确定该非支持点的视差;其中,所述各顶点均为支持点。For each second-type segmented area, execute: triangulate the second-type segmented area, divide the second-type segmented area into a plurality of triangular areas; for each non-support point in each triangular area, Determine the first parallax search range corresponding to the unsupported point according to the vertices of the triangular area and the parallax of each vertex; match the points to be matched corresponding to each parallax in the first parallax search range with the unsupported point pixel by pixel. , to determine the disparity of the non-support point; wherein, each of the vertices is a support point.
本发明实施例提供的电子设备,处理器通过执行存储器上所存放的程序时,针对面积较大的分割区域的各子分割区域,基于平面约束的思想,通过各子分割区域的平面方程确定各子分割区域内所有非支持点的视差,能够实现对缺失像素信息的遮挡区域以及存在匹配二义性的大面积无纹理区域更为准确地且鲁棒性更好地匹配,从而降低了匹配错误率。并且本发明实例,针对面积较小的分割区域进行三角剖分,根据三角形的顶点和顶点视差确定三角形内非支持点的视差搜索范围,极大缩小了非支持点的视差搜索范围,提高了匹配效率。In the electronic device provided by the embodiment of the present invention, when the processor executes the program stored in the memory, for each sub-segmented area of a larger-area segmented area, based on the idea of plane constraints, each sub-segmented area is determined by the plane equation of each sub-segmented area. The disparity of all non-support points in the sub-segmentation area can achieve more accurate and robust matching of occluded areas with missing pixel information and large areas of texture-free areas with matching ambiguities, thereby reducing matching errors Rate. And example of the present invention, triangulation is carried out for the segmented area lesser in area, determines the disparity search range of unsupported points in the triangle according to the apex of triangle and vertex disparity, greatly reduces the disparity search range of unsupported points, improves matching efficiency.
上述电子设备提到的通信总线可以是外设部件互连标准(Peripheral ComponentInterconnect,简称PCI)总线或扩展工业标准结构(Extended Industry StandardArchitecture,简称EISA)总线等。该通信总线可以分为地址总线、数据总线、控制总线等。为便于表示,图中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。The communication bus mentioned in the above-mentioned electronic device may be a Peripheral Component Interconnect (PCI for short) bus or an Extended Industry Standard Architecture (EISA for short) bus or the like. The communication bus can be divided into an address bus, a data bus, a control bus, and the like. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
通信接口用于上述电子设备与其他设备之间的通信。The communication interface is used for communication between the electronic device and other devices.
存储器可以包括随机存取存储器(Random Access Memory,简称RAM),也可以包括非易失性存储器(non-volatile memory),例如至少一个磁盘存储器。可选的,存储器还可以是至少一个位于远离前述处理器的存储装置。The memory may include a random access memory (Random Access Memory, RAM for short), and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory. Optionally, the memory may also be at least one storage device located far away from the aforementioned processor.
上述的处理器可以是通用处理器,包括中央处理器(Central Processing Unit,简称CPU)、网络处理器(Network Processor,简称NP)等;还可以是数字信号处理器(Digital Signal Processing,简称DSP)、专用集成电路(Application SpecificIntegrated Circuit,简称ASIC)、现场可编程门阵列(Field-Programmable Gate Array,简称FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。The above-mentioned processor can be a general-purpose processor, including a central processing unit (Central Processing Unit, referred to as CPU), a network processor (Network Processor, referred to as NP), etc.; it can also be a digital signal processor (Digital Signal Processing, referred to as DSP) , Application Specific Integrated Circuit (ASIC for short), Field Programmable Gate Array (Field-Programmable Gate Array, FPGA for short) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
在本发明提供的又一实施例中,还提供了一种计算机可读存储介质,该计算机可读存储介质中存储有指令,当其在计算机上运行时,使得计算机执行上述实施例中任一的基于平面约束和三角剖分的双目视觉立体匹配方法。In yet another embodiment provided by the present invention, a computer-readable storage medium is also provided. Instructions are stored in the computer-readable storage medium. When the computer-readable storage medium is run on a computer, it causes the computer to execute any one of the above-mentioned embodiments. Stereo matching method for binocular vision based on plane constraints and triangulation.
本发明实施例提供的计算机可读存储介质内存储的指令,当其在计算机上运行时,针对面积较大的分割区域的各子分割区域,基于平面约束的思想,通过各子分割区域的平面方程确定各子分割区域内所有非支持点的视差,能够实现对缺失像素信息的遮挡区域以及存在匹配二义性的大面积无纹理区域更为准确地且鲁棒性更好地匹配,从而降低了匹配错误率。并且本发明实例,针对面积较小的分割区域进行三角剖分,根据三角形的顶点和顶点视差确定三角形内非支持点的视差搜索范围,极大缩小了非支持点的视差搜索范围,提高了匹配效率。The instructions stored in the computer-readable storage medium provided by the embodiments of the present invention, when running on a computer, for each sub-division area of a larger-area division area, based on the idea of plane constraints, pass the plane of each sub-division area The equation determines the disparity of all non-support points in each sub-segmentation area, which can achieve more accurate and robust matching of occluded areas with missing pixel information and large-area texture-free areas with matching ambiguity, thereby reducing match error rate. And example of the present invention, triangulation is carried out for the segmented area lesser in area, determines the disparity search range of unsupported points in the triangle according to the apex of triangle and vertex disparity, greatly reduces the disparity search range of unsupported points, improves matching efficiency.
在本发明提供的又一实施例中,还提供了一种包含指令的计算机程序产品,当其在计算机上运行时,使得计算机执行上述实施例中任一的基于平面约束和三角剖分的双目视觉立体匹配方法。In yet another embodiment provided by the present invention, a computer program product containing instructions is also provided, and when it is run on a computer, it causes the computer to perform any of the above-mentioned double-dimensional analysis based on plane constraints and triangulation. Visual stereo matching method.
本发明实施例提供的包含指令的计算程序产品,当其在计算机上运行时,针对面积较大的分割区域的各子分割区域,基于平面约束的思想,通过各子分割区域的平面方程确定各子分割区域内所有非支持点的视差,能够实现对缺失像素信息的遮挡区域以及存在匹配二义性的大面积无纹理区域更为准确地且鲁棒性更好地匹配,从而降低了匹配错误率。并且本发明实例,针对面积较小的分割区域进行三角剖分,根据三角形的顶点和顶点视差确定三角形内非支持点的视差搜索范围,极大缩小了非支持点的视差搜索范围,提高了匹配效率。The calculation program product containing instructions provided by the embodiment of the present invention, when it is run on a computer, for each sub-division area of a larger-area division area, based on the idea of plane constraints, each sub-division area is determined by the plane equation of each sub-division area. The disparity of all non-support points in the sub-segmentation area can achieve more accurate and robust matching of occluded areas with missing pixel information and large areas of texture-free areas with matching ambiguities, thereby reducing matching errors Rate. And example of the present invention, triangulation is carried out for the segmented area lesser in area, determines the disparity search range of unsupported points in the triangle according to the apex of triangle and vertex disparity, greatly reduces the disparity search range of unsupported points, improves matching efficiency.
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行计算机程序指令时,全部或部分地产生按照本发明实施例的流程或功能。计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线(DSL))或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质(例如固态硬盘Solid State Disk(SSD))等。In the above embodiments, all or part of them may be implemented by software, hardware, firmware or any combination thereof. When implemented using software, it may be implemented in whole or in part in the form of a computer program product. A computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on the computer, the processes or functions according to the embodiments of the present invention are produced in whole or in part. A computer can be a general purpose computer, special purpose computer, computer network, or other programmable device. Computer instructions may be stored in or transmitted from one computer-readable storage medium to another computer-readable storage medium, e.g. Coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.) to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that can be accessed by a computer, or a data storage device such as a server, a data center, etc. integrated with one or more available media. The available media may be magnetic media (eg, floppy disk, hard disk, magnetic tape), optical media (eg, DVD), or semiconductor media (eg, Solid State Disk (SSD)).
需要说明的是,在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个......”限定的要素,并不排除在包括要素的过程、方法、物品或者设备中还存在另外的相同要素。It should be noted that in this article, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that there is a relationship between these entities or operations. There is no such actual relationship or order between them. Furthermore, the term "comprises", "comprises" or any other variation thereof is intended to cover a non-exclusive inclusion such that a process, method, article, or apparatus comprising a set of elements includes not only those elements, but also includes elements not expressly listed. other elements of or also include elements inherent in such a process, method, article, or device. Without further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article or apparatus that includes the element.
本说明书中的各个实施例均采用相关的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于装置/电子设备/存储介质/计算机程序产品实施例而言,由于其基本相似于方法实施例,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。Each embodiment in this specification is described in a related manner, the same and similar parts of each embodiment can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device/electronic equipment/storage medium/computer program product embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and for relevant parts, please refer to part of the description of the method embodiments.
以上仅为本发明的较佳实施例而已,并非用于限定本发明的保护范围。凡在本发明的精神和原则之内所作的任何修改、等同替换、改进等,均包含在本发明的保护范围内。The above are only preferred embodiments of the present invention, and are not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principles of the present invention are included in the protection scope of the present invention.
Claims (10)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201810252302.6A CN108564604B (en) | 2018-03-26 | 2018-03-26 | Binocular vision stereo matching method and device based on plane constraint and triangulation |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201810252302.6A CN108564604B (en) | 2018-03-26 | 2018-03-26 | Binocular vision stereo matching method and device based on plane constraint and triangulation |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN108564604A true CN108564604A (en) | 2018-09-21 |
| CN108564604B CN108564604B (en) | 2020-07-03 |
Family
ID=63533162
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201810252302.6A Expired - Fee Related CN108564604B (en) | 2018-03-26 | 2018-03-26 | Binocular vision stereo matching method and device based on plane constraint and triangulation |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN108564604B (en) |
Cited By (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN112102504A (en) * | 2020-09-16 | 2020-12-18 | 成都威爱新经济技术研究院有限公司 | Three-dimensional scene and two-dimensional image mixing method based on mixed reality |
| CN112308896A (en) * | 2020-11-06 | 2021-02-02 | 上海肇观电子科技有限公司 | Image processing method, chip circuit, device, electronic apparatus, and storage medium |
| CN113141495A (en) * | 2020-01-16 | 2021-07-20 | 纳恩博(北京)科技有限公司 | Image processing method and device, storage medium and electronic device |
| WO2022052582A1 (en) * | 2020-09-08 | 2022-03-17 | 苏州浪潮智能科技有限公司 | Image registration method and device, electronic apparatus, and storage medium |
Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101312539A (en) * | 2008-07-03 | 2008-11-26 | 浙江大学 | Hierarchical Image Depth Extraction Method for 3D Television |
| CN101887589A (en) * | 2010-06-13 | 2010-11-17 | 东南大学 | A Real-Shot Low-Texture Image Reconstruction Method Based on Stereo Vision |
| CN102982560A (en) * | 2011-11-02 | 2013-03-20 | 微软公司 | Surface segmentation according to RGB and depth image |
| US20160239979A1 (en) * | 2011-11-11 | 2016-08-18 | Edge 3 Technologies, Inc. | Method and Apparatus for Enhancing Stereo Vision |
| CN106709948A (en) * | 2016-12-21 | 2017-05-24 | 浙江大学 | Quick binocular stereo matching method based on superpixel segmentation |
| CN107016698A (en) * | 2017-03-20 | 2017-08-04 | 深圳格兰泰克汽车电子有限公司 | Based on tapered plane smooth binocular solid matching process and device |
-
2018
- 2018-03-26 CN CN201810252302.6A patent/CN108564604B/en not_active Expired - Fee Related
Patent Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101312539A (en) * | 2008-07-03 | 2008-11-26 | 浙江大学 | Hierarchical Image Depth Extraction Method for 3D Television |
| CN101887589A (en) * | 2010-06-13 | 2010-11-17 | 东南大学 | A Real-Shot Low-Texture Image Reconstruction Method Based on Stereo Vision |
| CN102982560A (en) * | 2011-11-02 | 2013-03-20 | 微软公司 | Surface segmentation according to RGB and depth image |
| US20160239979A1 (en) * | 2011-11-11 | 2016-08-18 | Edge 3 Technologies, Inc. | Method and Apparatus for Enhancing Stereo Vision |
| CN106709948A (en) * | 2016-12-21 | 2017-05-24 | 浙江大学 | Quick binocular stereo matching method based on superpixel segmentation |
| CN107016698A (en) * | 2017-03-20 | 2017-08-04 | 深圳格兰泰克汽车电子有限公司 | Based on tapered plane smooth binocular solid matching process and device |
Non-Patent Citations (3)
| Title |
|---|
| ANDREAS GEIGER ET AL.: ""Efficient Large-Scale Stereo Matching"", 《HTTPS://WWW.RESEARCHGATE.NET/PUBLICATION/220745081》 * |
| RICHARD LINARES ET AL.: ""Constrained Relative Attitude Determination for Two-Vehicle Formations"", 《HTTPS://ARC.AIAA.ORG/DOI/PDF/10.2514/1.50053》 * |
| SUDIPTA NARAYAN SINHA ET AL.: ""Efficient High-Resolution Stereo Matching Using Local Plane Sweeps"", 《2014 IEEE CONFERENCE ON COMPUTER VISION AND PATTERN RECOGNITION》 * |
Cited By (8)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN113141495A (en) * | 2020-01-16 | 2021-07-20 | 纳恩博(北京)科技有限公司 | Image processing method and device, storage medium and electronic device |
| CN113141495B (en) * | 2020-01-16 | 2023-03-24 | 纳恩博(北京)科技有限公司 | Image processing method and device, storage medium and electronic device |
| WO2022052582A1 (en) * | 2020-09-08 | 2022-03-17 | 苏州浪潮智能科技有限公司 | Image registration method and device, electronic apparatus, and storage medium |
| US12541868B2 (en) | 2020-09-08 | 2026-02-03 | Inspur Suzhou Intelligent Technology Co., Ltd. | Image registration method and apparatus, electronic apparatus, and storage medium |
| CN112102504A (en) * | 2020-09-16 | 2020-12-18 | 成都威爱新经济技术研究院有限公司 | Three-dimensional scene and two-dimensional image mixing method based on mixed reality |
| CN112308896A (en) * | 2020-11-06 | 2021-02-02 | 上海肇观电子科技有限公司 | Image processing method, chip circuit, device, electronic apparatus, and storage medium |
| CN112308896B (en) * | 2020-11-06 | 2025-03-11 | 上海肇观电子科技有限公司 | Image processing method, chip circuit, device, electronic device and storage medium |
| CN112308896B9 (en) * | 2020-11-06 | 2025-04-18 | 上海肇观电子科技有限公司 | Image processing method, chip circuit, device, electronic device and storage medium |
Also Published As
| Publication number | Publication date |
|---|---|
| CN108564604B (en) | 2020-07-03 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US8199977B2 (en) | System and method for extraction of features from a 3-D point cloud | |
| US8447099B2 (en) | Forming 3D models using two images | |
| CN115063550B (en) | Semantic point cloud map construction method and system and intelligent robot | |
| US8452081B2 (en) | Forming 3D models using multiple images | |
| US8711143B2 (en) | System and method for interactive image-based modeling of curved surfaces using single-view and multi-view feature curves | |
| KR102318023B1 (en) | 3-Dimensional Model Generation Using Edges | |
| WO2025156819A1 (en) | Three-dimensional point cloud segmentation method and apparatus based on locally weighted curvature and two-point method | |
| CN103247045B (en) | A kind of method obtaining artificial scene principal direction and image border from multi views | |
| WO2020119684A1 (en) | 3d navigation semantic map update method, apparatus and device | |
| CN106033621B (en) | A kind of method and device of three-dimensional modeling | |
| CN111105366B (en) | Image processing method and device, terminal equipment and storage medium | |
| CN110930503B (en) | Clothing three-dimensional model building method, system, storage medium and electronic equipment | |
| CN111340922A (en) | Method and electronic device for localization and map construction | |
| CN112116639A (en) | Image registration method and device, electronic equipment and storage medium | |
| CN108564604B (en) | Binocular vision stereo matching method and device based on plane constraint and triangulation | |
| CN113744416B (en) | A mask-based global point cloud filtering method, device and storage medium | |
| WO2023165220A1 (en) | Target object detection method and apparatus | |
| CN113052954A (en) | Three-dimensional reconstruction method, device, terminal and storage medium based on line segment matching | |
| CN120912613B (en) | Reinforcing steel bar spacing measuring method and system based on multi-eye vision | |
| CN113052880A (en) | SFM sparse reconstruction method, system and application | |
| Peng et al. | Ocm3d: Object-centric monocular 3d object detection | |
| CN115222616B (en) | Point cloud hole repairing method, device, medium and equipment based on heterogeneous point cloud | |
| US20240355067A1 (en) | Fully automated estimation of scene parameters | |
| CN107464257B (en) | Wide baseline matching method and device | |
| Kyöstilä et al. | Merging overlapping depth maps into a nonredundant point cloud |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant | ||
| CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20200703 |
|
| CF01 | Termination of patent right due to non-payment of annual fee |