CN108564604B - Binocular vision stereo matching method and device based on plane constraint and triangulation - Google Patents

Binocular vision stereo matching method and device based on plane constraint and triangulation Download PDF

Info

Publication number
CN108564604B
CN108564604B CN201810252302.6A CN201810252302A CN108564604B CN 108564604 B CN108564604 B CN 108564604B CN 201810252302 A CN201810252302 A CN 201810252302A CN 108564604 B CN108564604 B CN 108564604B
Authority
CN
China
Prior art keywords
type
point
parallax
area
plane
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.)
Expired - Fee Related
Application number
CN201810252302.6A
Other languages
Chinese (zh)
Other versions
CN108564604A (en
Inventor
张雪松
白肖艳
康学净
明安龙
苏圣
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing University of Posts and Telecommunications
Original Assignee
Beijing University of Posts and Telecommunications
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Beijing University of Posts and Telecommunications filed Critical Beijing University of Posts and Telecommunications
Priority to CN201810252302.6A priority Critical patent/CN108564604B/en
Publication of CN108564604A publication Critical patent/CN108564604A/en
Application granted granted Critical
Publication of CN108564604B publication Critical patent/CN108564604B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/30Determination of transform parameters for the alignment of images, i.e. image registration
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/11Region-based segmentation
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/136Segmentation; Edge detection involving thresholding
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10004Still image; Photographic image
    • G06T2207/10012Stereo 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

The embodiment of the invention provides a binocular vision stereo matching method and device based on plane constraint and triangulation. The method comprises the following steps: acquiring left and right images acquired by two cameras, and taking any one image as a reference image; determining a support point of a reference image and calculating a parallax; segmenting the reference image according to a preset mode; dividing each divided area into a first type and/or a second type divided area; secondarily dividing each first-class divided area; determining the parallax of the non-support point in each sub-segmentation region according to the support point and the parallax of each sub-segmentation region; triangulating each second type of segmented region; determining a parallax searching range of a non-support point in each triangular area according to the vertex and the parallax of the triangular area; and matching the point to be matched and the non-support point corresponding to the range pixel by pixel to determine the parallax of the non-support point. The invention can more accurately match the shielded area and the large-area non-texture area. And the parallax searching range of the small area segmentation area is reduced, and the matching efficiency is improved.

Description

基于平面约束和三角剖分的双目视觉立体匹配方法及装置Stereo matching method and device for binocular vision based on plane constraint and triangulation

技术领域technical field

本发明涉及计算机视觉技术领域,特别是涉及一种基于平面约束和三角剖分的双目视觉立体匹配方法及装置。The invention relates to the technical field of computer vision, in particular to a method and device for stereo matching of binocular vision 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 stereo matching. Among them, the stereo matching of binocular vision includes: first, use a binocular camera or two cameras placed in parallel to shoot the same physical scene at the same time to obtain left and right images; then find the projection point of the same object 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. According to the generated disparity map and the principle of similar triangles, the actual distance between the target and the camera in the captured physical scene can be further calculated, and this process is also called stereoscopic depth calculation. Stereo vision depth calculation is widely used in practical applications such as 3D scene reconstruction, autonomous navigation of mobile robots, and more and more applications in medical imaging, industrial inspection and other fields.

目前常用的双目视觉立体匹配算法有:基于支持窗口的局部算法、基于图像切割或动态规划的全局算法、基于最小生成树的非局部匹配算法等。At present, the commonly used stereo matching algorithms for binocular vision include: local algorithm based on support window, global algorithm based on image cutting or dynamic programming, and non-local matching algorithm based on minimum spanning tree.

由于所述左右图像从是从不同拍摄角度获得的,不可避免会有遮挡区域或大面积无纹理区域的存在。其中,遮挡区域是指只在一幅图像中可见,在另一幅图像中没有对应像素信息的区域,通常是由于拍摄角度不同而造成的。大面积无纹理区域通常是指那些没有明显特征点的区域,例如室内区域中的白色墙壁等。而上述立体匹配算法都是逐像素进行匹配的,因而对于遮挡区域的像素信息的缺失以及大面积无纹理区域在匹配时的二义性,上述立体匹配算法均不能很好地解决遮挡区域或大面积无纹理区域的匹配,会造成匹配错误率较高以及匹配效率较低。Since the left and right images are obtained from different shooting angles, it is inevitable that there will be an occluded area or a large area without texture. Among them, the occlusion area refers to the area that is only visible in one image and has no corresponding pixel information in the other image, which is usually caused by different shooting angles. Large untextured areas usually refer to those areas without obvious feature points, such as white walls in indoor areas, etc. The above stereo matching algorithms are all matched pixel by pixel. Therefore, for the lack of pixel information in occluded areas and the ambiguity in matching of large areas without texture, the above stereo matching algorithms can not solve the problem of occlusion areas or large areas. The matching of the area without texture area will result in a high matching error rate and a low matching efficiency.

发明内容SUMMARY OF THE INVENTION

本发明实施例的目的在于提供一种基于平面约束和三角剖分的双目视觉立体匹配方法及装置,以降低双目视觉立体匹配的匹配错误率,并提高匹配效率。具体技术方案如下:The purpose of the embodiments of the present invention is to provide a method and device for stereo matching of binocular vision based on plane constraints and triangulation, so as to reduce the matching error rate of stereo matching of binocular vision and improve the matching efficiency. The specific technical solutions are as follows:

为达到上述目的,第一方面,本发明实施提供了一种基于平面约束和三角剖分的双目视觉立体匹配方法,该方法包括:In order to achieve the above object, in the first aspect, the present invention provides a stereo matching method for binocular vision based on plane constraints and triangulation, the method comprising:

获取两个平行放置的摄像机在同一时间分别采集的同一拍摄场景的左图像和右图像,并将其中任一幅作为参考图像,另一幅作为待匹配图像;Acquire the left image and the right image of the same shooting scene collected by two cameras placed in parallel at the same time, and use any one of them as a reference image and the other as an image to be matched;

确定所述参考图像中的支持点,并计算各所述支持点的视差;其中,所述支持点为所述参考图像中的、在所述待匹配图像中有唯一且正确匹配点的像素点;Determine the support points in the reference image, and calculate the parallax of each support point; 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 a preset image segmentation method, the reference image is segmented to obtain a plurality of segmented regions; each of the segmented regions is divided into a first-type segmented region with a segmented area greater than a first threshold, and/or a segmented area not greater than the second type of segmentation region of the first threshold;

针对每个第一类分割区域,执行:对该第一类分割区域进行第二次分割,将该第一类分割区域划分为多个第一类子分割区域;根据每个第一类子分割区域内的支持点和支持点的视差,拟合该第一类子分割区域的第一平面方程;根据所述第一平面方程,确定该第一类子分割区域内非支持点的视差;其中,所述多个第一类子分割区域分别对应于所述拍摄场景中不同的物理平面;For each first-type segmentation area, perform: perform a second segmentation on the first-type segmentation area, and divide the first-type segmentation area into a plurality of first-type sub-segmentation areas; according to each first-type sub-segmentation The disparity of the support point and the support point in the area, fit the first plane equation of the first type of sub-segmented area; according to the first plane equation, determine the disparity of the non-supported point in the first type of sub-segmented area; wherein , the plurality of first-type sub-segmentation regions respectively correspond to different physical planes in the shooting scene;

针对每个第二类分割区域,执行:对该第二类分割区域进行三角剖分,将该第二类分割区域划分为多个三角形区域;针对每个三角形区域内的每个非支持点,根据该三角形区域的各顶点和各顶点的视差确定该非支持点对应的第一视差搜索范围;将所述第一视差搜索范围内各视差对应的待匹配点与该非支持点进行逐像素匹配,确定该非支持点的视差;其中,所述各顶点均为支持点。For each segmented region of the second type, perform: triangulate the segmented region of the second type, and divide the segmented region of the second type into a plurality of triangular regions; for each non-support point in each triangular region, Determine the first parallax search range corresponding to the unsupported point according to the parallax of each vertex and each vertex of the triangle area; perform pixel-by-pixel matching between the to-be-matched point corresponding to each parallax within the first parallax search range and the non-supported point , determine the parallax of the non-supporting point; wherein, each vertex is a supporting point.

可选地,所述确定所述参考图像中的支持点,包括:Optionally, the determining of the support points in the reference image includes:

以所述参考图像的左上角像素点作为起点,沿所述参考图像对应的像素坐标系的u轴和v轴,在所述参考图像中构建步长为预设步长的网格;将所述网格中的、除了位于所述参考图像边缘处的交点作为候选支持点;其中,u轴向右,v轴向下;Taking the pixel in the upper left corner of the reference image as the 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 preset step size in the reference image; In the grid, except for the intersection points located at the edge of the reference image as candidate support points; wherein, the u axis is to the right, and the v axis is downward;

针对每个候选支持点,计算预先设置的该候选支持点对应的第二视差搜索范围内各视差对应的待匹配点的向量与该候选支持点的向量的距离;若计算得到的所述距离中小于第二阈值的各距离中,最小的距离的个数为1,则将该候选支持点作为支持点;其中,所述第二视差搜索范围内各视差对应的待匹配点的向量,以及所述该候选支持点的向量均根据预设尺寸的sobel算子计算得到。For each candidate support point, calculate the distance between the vector of the to-be-matched point corresponding to each parallax within the second parallax search range corresponding to the candidate support point and the vector of the candidate support point; if the calculated distance is small Among the distances of the second threshold, if the number of the smallest distance is 1, the candidate support point is regarded as a support point; wherein, the vector of the points to be matched corresponding to each parallax within the second parallax search range, and the The vectors of the candidate support points are all calculated according to the preset size of the sobel operator.

可选地,所述按照预设的图像分割方式,对所述参考图像进行分割,得到多个分割区域,包括:Optionally, according to the preset image segmentation method, the reference image is segmented to obtain a plurality of segmented regions, including:

按照均值偏移Meanshift图像分割方式,对所述参考图像进行分割,得到至少一个分割区域。The reference image is segmented according to the mean shift image segmentation method to obtain at least one segmented region.

可选地,所述对该第一类分割区域进行第二次分割,将该第一类分割区域划分为多个第一类子分割区域,包括:Optionally, performing the second segmentation on the first-type segmentation area, and dividing the first-type segmentation area into a plurality of first-type sub-segmentation areas, including:

按照预设的平面拟合规则,拟合该第一类分割区域内的多个支持点子集对应的物理平面的平面方程;其中,所述多个支持点子集分别对应于所述拍摄场景中不同的物理平面;According to the preset plane fitting rule, fit the plane equation of the physical plane corresponding to the plurality of support point subsets in the first type of segmentation area; wherein, the multiple support point subsets correspond to different the physical plane;

在拟合得到的各所述物理平面中,若其中多个物理平面满足预设合并条件,则根据所述多个物理平面内的支持点和支持点的视差,拟合得到合并后物理平面的平面方程;根据合并后物理平面的平面方程和未被合并的物理平面的平面方程,计算各合并后物理平面、未被合并的物理平面间的交线,确定出所述多个第一类子分割区域;其中,所述预设合并条件为:所述多个物理平面中,任一物理平面与至少一个其他物理平面的距离小于第三阈值;In each of the physical planes obtained by fitting, if multiple physical planes meet the preset merging conditions, then according to the support points in the multiple physical planes and the disparity of the support points, the fitting of the merged physical planes is obtained. Plane equation; according to the plane equation of the merged physical plane and the plane equation of the unmerged physical plane, calculate the line of intersection between the merged physical planes and the unmerged physical planes, and determine the plurality of first-type subtypes dividing a region; 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;

在拟合得到的各所述物理平面中,若其中任意两个物理平面不满足所述预设合并条件,则根据各所述物理平面的平面方程,计算各所述物理平面间的交线,确定出所述多个第一类子分割区域。In each of the physical planes obtained by fitting, if any two of the physical planes do not satisfy the preset merging condition, then according to the plane equation of each of the physical planes, the intersection line between the physical planes is calculated, The plurality of sub-segmented regions of the first type are determined.

可选地,所述按照预设的平面拟合规则,拟合该第一类分割区域内的多个支持点子集对应的物理平面的平面方程,包括:Optionally, according to a preset plane fitting rule, fitting the plane equation of the physical plane corresponding to the multiple support point subsets in the first type of segmented region, including:

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 segmentation area; wherein, the O is the support point in the Y with the largest number of support points point subset;

S2、根据所述O的支持点和支持点的视差,拟合所述O对应的物理平面的平面方程;S2, fit the plane equation of the physical plane corresponding to the O according to the support point of the O and the parallax of the support point;

S3、判断当前未拟合支持点子集Y-O的支持点个数是否少于预设比例的该第一类分割区域内的支持点个数;S3, judging whether the number of support points of the current unfitted support point subset Y-O is less than the number of support points in the first type of segmentation area of a 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 of segmented area at a preset ratio, then the Y-O is used as the current set of support points in the first type of segmented area, and the execution returns 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 region at a 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-segmented region according to the support points and the disparity of the support points in each of the first-type sub-segmented regions, including:

设定第一类子分割区域的第一平面方程为:The first plane equation of the first type of sub-segmented region is set as:

d(u,v)=au+bv+cd(u, v)=au+bv+c

其中,d(u,v)表示第一类子分割区域内像素点(u,v)的视差,a,b,c为所述第一平面方程的待求解参数,通过以下公式求解所述a,b,c:Among them, d(u, v) represents the disparity of the pixel point (u, v) in the first type of sub-segmented region, a, b, c are the parameters to be solved for the first plane equation, and the a is solved by the following formula , b, c:

Figure BDA0001608097790000041
Figure BDA0001608097790000041

其中,ui表示第一类子分割区域内第i个支持点在所述参考图像对应的像素坐标系的u轴的坐标,vi表示第一类子分割区域内第i个支持点在所述参考图像对应的像素坐标系的v轴的坐标,u轴向右,v轴向下,i=1,...,m,m表示第一类子分割区域内的支持点个数,di表示第一类子分割区域内第i个支持点的视差。Among them, ui represents the coordinate of the i-th support point in the first type of sub-segmentation area on the u-axis of the pixel coordinate system corresponding to the reference image, and v i represents the i-th support point in the first type of sub-segmentation area in the The coordinates of the v-axis of the pixel coordinate system corresponding to the reference image, the u-axis is to the right, the v-axis is down, i=1, . i represents the disparity of the i-th support point in the first type of sub-segmented region.

可选地,所述针对每个三角形区域内的每个非支持点,根据该三角形区域的各顶点和各顶点的视差确定该非支持点对应的第一视差搜索范围,包括:Optionally, for each non-supporting point in each triangular area, determine the first parallax search range corresponding to the non-supporting point according to the parallax of each vertex and each vertex of the triangular area, including:

针对每个三角形区域,根据该三角形区域内的各顶点和各顶点的视差,确定该三角形区域所在平面的第二平面方程;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 the disparity estimate of the unsupported 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 the parallax of each vertex by a preset value, the parallax estimated value, and the non-support point within the preset neighborhood The parallax of the target support point; wherein, the absolute value of the difference between the parallax of the target support point and the disparity estimated value of the target support point determined according to the second plane equation does not exceed a fourth threshold.

可选地,所述将所述第一视差搜索范围内各视差对应的待匹配点与该非支持点进行逐像素匹配,确定该非支持点的视差,包括:Optionally, performing pixel-by-pixel matching between the to-be-matched point corresponding to each parallax within the first parallax search range and the non-supported point, and determining the parallax of the non-supported point, comprising:

通过以下公式,确定该非支持点

Figure BDA0001608097790000051
的视差:The non-support point is determined by the following formula
Figure BDA0001608097790000051
Parallax of:

Figure BDA0001608097790000052
Figure BDA0001608097790000052

其中,

Figure BDA0001608097790000053
为该非支持点
Figure BDA0001608097790000054
的视差,dn表示所述该非支持点的视差估计值,
Figure BDA0001608097790000055
表示所述第一视差搜索范围内的各视差,N表示所述第一视差搜索范围内的视差数,S表示所述参考图像的支持点集;
Figure BDA0001608097790000056
表示
Figure BDA0001608097790000057
的后验概率,通过以下公式计算:in,
Figure BDA0001608097790000053
for the non-support point
Figure BDA0001608097790000054
The disparity of , d n represents the disparity estimation value of the non-supported point,
Figure BDA0001608097790000055
represents each parallax within the first parallax search range, N represents the number of parallaxes within the first parallax search range, and S represents the support point set of the reference image;
Figure BDA0001608097790000056
express
Figure BDA0001608097790000057
The posterior probability of , is calculated by the following formula:

Figure BDA0001608097790000058
Figure BDA0001608097790000058

其中,

Figure BDA0001608097790000059
表示dn对应的待匹配点为所述非支持点
Figure BDA00016080977900000510
的正确匹配点的概率,
Figure BDA00016080977900000511
表示所述第一视差搜索范围内的各视差对应的匹配点为所述非支持点
Figure BDA00016080977900000512
的正确匹配点的概率。in,
Figure BDA0001608097790000059
Indicates that the to-be-matched point corresponding to d n is the non-supported point
Figure BDA00016080977900000510
The probability of the correct matching point of ,
Figure BDA00016080977900000511
Indicates that the matching point corresponding to each parallax within the first parallax search range is the unsupported point
Figure BDA00016080977900000512
The probability of the correct matching point.

第二方面,本发明实施例提供了一种基于平面约束和三角剖分的双目视觉立体匹配装置,该装置包括:In a second aspect, an embodiment of the present invention provides a stereo matching device for binocular vision based on plane constraints and triangulation, and the device includes:

获取模块,用于获取两个平行放置的摄像机在同一时间分别采集的同一拍摄场景的左图像和右图像,并将其中任一幅作为参考图像,另一幅作为待匹配图像;an acquisition module, configured to acquire the left image and the right image of the same shooting scene respectively collected by two cameras placed in parallel at the same time, and use any one of them as a reference image and the other as an image to be matched;

确定模块,用于确定所述参考图像中的支持点,并计算各所述支持点的视差;其中,所述支持点为所述参考图像中的、在所述待匹配图像中有唯一且正确匹配点的像素点;A determination module, configured to determine the support points in the reference image, and calculate the disparity of each support point; wherein, the support points are unique and correct in the reference image and in the to-be-matched image Pixel points 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 regions; to divide each of the segmented regions into a first-type segmented region with a segmented area greater than a first threshold, and/ Or the second type of segmentation area whose segmentation area is not greater than the first threshold;

第一执行模块,用于针对每个第一类分割区域,执行:对该第一类分割区域进行第二次分割,将该第一类分割区域划分为多个第一类子分割区域;根据每个第一类子分割区域内的支持点和支持点的视差,拟合该第一类子分割区域的第一平面方程;根据所述第一平面方程,确定该第一类子分割区域内非支持点的视差;其中,所述多个第一类子分割区域分别对应于所述拍摄场景中不同的物理平面;The first execution module is configured to, for each first-type segmented region, execute: perform a second segmentation on the first-type segmented region, and divide the first-type segmented region into a plurality of first-type sub-segmented regions; according to For the support points and the disparity of the support points in each first-type sub-segmentation area, fit the first plane equation of the first-type sub-segmentation area; according to the first plane equation, determine the first-type sub-segmentation area Disparity of non-supported points; wherein, the plurality of first-type sub-segmentation regions respectively correspond to different physical planes in the shooting scene;

第二执行模块,用于针对每个第二类分割区域,执行:对该第二类分割区域进行三角剖分,将该第二类分割区域划分为多个三角形区域;针对每个三角形区域内的每个非支持点,根据该三角形区域的各顶点和各顶点的视差确定该非支持点对应的第一视差搜索范围;将所述第一视差搜索范围内各视差对应的待匹配点与该非支持点进行逐像素匹配,确定该非支持点的视差;其中,所述各顶点均为支持点。The second execution module is configured to perform, for each segmented region of the second type: triangulate the segmented region of the second type, and divide the segmented region of the second type into a plurality of triangular regions; For each non-supporting point, determine the first parallax search range corresponding to the non-supporting point according to the parallax of each vertex and each vertex of the triangle area; compare the point to be matched corresponding to each parallax in the first parallax search range The unsupported point is matched pixel by pixel to determine the parallax of the unsupported 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 communicate with each other through the communication bus;

存储器,用于存放计算机程序;memory for storing computer programs;

处理器,用于执行存储器上所存放的程序时,实现如上第一方面所述的基于平面约束和三角剖分的双目视觉立体匹配的方法步骤。The processor is configured to implement the method steps for stereo matching of binocular vision 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 runs on a computer, the computer causes the computer to execute the plane-based method described in the first aspect above. Constrained and triangulated method steps for binocular stereo matching.

第五方面,本发明实施例提供了一种包含指令的计算机程序产品,当其在计算机上运行时,使得计算机执行如上第一方面所述的基于平面约束和三角剖分的双目视觉立体匹配的方法步骤。In a fifth aspect, an embodiment of the present invention provides a computer program product including instructions, which, when run on a computer, enables the computer to perform the stereo matching of binocular vision 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 constraint and triangulation provided by the embodiment of the present invention, after dividing the reference image, the segmented area with a larger area is segmented a second time, so as to determine the corresponding images corresponding to different physical planes. The sub-segmented area is further fitted according to the support points of the sub-segmented area and the disparity of the support points, and the plane equation of the sub-segmented area is determined, and the disparity of the non-supported points in the sub-segmented area is determined according to the plane equation. At the same time, triangulate the segmented area with a small area and divide it into multiple triangles; further determine the first parallax search range of the non-support points in the triangle according to the parallax of the vertices of the triangles and the vertexes, and assign the corresponding parallaxes within the range to the first parallax search range. The to-be-matched point and the unsupported point are matched pixel by pixel, so as to determine the parallax of the unsupported point.

可见,本发明实施例,针对面积较大的分割区域的各子分割区域,基于平面约束的思想,通过各子分割区域的平面方程确定各子分割区域内所有非支持点的视差,能够实现对缺失像素信息的遮挡区域以及存在匹配二义性的大面积无纹理区域更为准确地且鲁棒性更好地匹配,从而降低了匹配错误率。并且本发明实施例,针对面积较小的分割区域进行三角剖分,根据三角形的顶点和顶点视差确定三角形内非支持点的视差搜索范围,极大缩小了非支持点的视差搜索范围,提高了匹配效率。It can be seen that, in this embodiment of the present invention, for each sub-segmentation area of a larger segmented area, based on the idea of plane constraints, the parallax of all non-supporting points in each sub-segmented area is determined by the plane equation of each sub-segmented area, which can realize the Occlusion areas with missing pixel information and large textureless areas with matching ambiguity are more accurately and robustly matched, thereby reducing the matching error rate. In addition, in this embodiment of the present invention, triangulation is performed for a divided area with a small area, and the parallax search range of the non-supported points in the triangle is determined according to the vertex of the triangle and the parallax of the vertex, which greatly reduces the parallax search range of the non-supported points and improves the matching efficiency.

当然,实施本发明的任一产品或方法必不一定需要同时达到以上所述的所有优点。Of course, it is not necessary for any product or method to implement the present invention to simultaneously achieve all of the advantages described above.

附图说明Description of drawings

为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍。In order to illustrate the embodiments of the present invention or the technical solutions in the prior art more clearly, the following briefly introduces the accompanying drawings that are required in the description of the embodiments or the prior art.

图1为本发明实施例提供的基于平面约束和三角剖分的双目视觉立体匹配方法的流程图;1 is a flowchart of a method for stereo matching of binocular vision based on plane constraints and triangulation provided by an embodiment of the present invention;

图2为图1所示实施例的步骤S104中实现对该第一类分割区域进行第二次分割,将该第一类分割区域划分为多个第一类子分割区域的一种具体流程图;FIG. 2 is a specific flow chart of implementing the second division of the first type of segmentation area and dividing the first type of segmentation area into a plurality of first type of sub-segmented areas in step S104 of the embodiment shown in FIG. 1 ;

图3为图2所示实施例中步骤S201的一种具体流程图;Fig. 3 is a specific flow chart of step S201 in the embodiment shown in Fig. 2;

图4为本发明实施例提供的仿真实验结果图;Fig. 4 is a simulation experiment result diagram provided by an embodiment of the present invention;

图5为本发明实施例提供的基于平面约束和三角剖分的双目视觉立体匹配装置的结构图;5 is a structural diagram of a stereo matching device for binocular vision 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 according to an embodiment of the present invention.

具体实施方式Detailed ways

下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, but not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.

在双目视觉立体匹配时,为了降低遮挡区域和大面积无纹理区域的匹配错误率,并提高匹配效率,如图1所示,本发明提供了一种基于平面约束和三角剖分的双目视觉立体匹配方法,该方法包括:In the stereo matching of binocular vision, in order to reduce the matching error rate of occluded areas and large areas without texture, and improve the matching efficiency, as shown in FIG. 1, the present invention provides a binocular based on plane constraints and triangulation. A visual stereo matching method, the method includes:

S101,获取两个平行放置的摄像机在同一时间分别采集的同一拍摄场景的左图像和右图像,并将其中任一幅作为参考图像,另一幅作为待匹配图像。S101: Acquire a left image and a right image of the same shooting scene respectively collected by two cameras placed in parallel 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 3D stereo vision produced by human eyes when viewing 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 acquired to further find the shooting scene The projected points of the target in the left and right images, also called corresponding points, to generate the disparity map. Then, through the similar triangle principle, the disparity map can be converted into a depth map containing the depth information of the camera and each target in the shooting scene, that is, the actual distance between the camera and each target in the shooting scene, for further 3D reconstruction.

本实施例中,也可以通过一个双目摄像机的两个摄像单元同时采集一拍摄场景的左右图像。In this embodiment, the left and right images of a shooting scene can also be simultaneously collected by two camera units of a binocular camera.

摄像机所采集的左图像或右图像均可以作为参考图像,若将其中一幅作为参考图像,那么另一幅就是待匹配图像。例如,将左图像作为参考图像,则本发明的目的就是确定出左图像中每个像素点的视差,生成左图像的视差图。在本实施例中,示例性地,将左图像作为参考图像,来详细描述各步骤。Either the left image or the right image captured by the camera can be used as the reference image, and if one of them is used as the reference image, the other is the image to be matched. For example, taking the left image as the 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, each step is described in detail by taking the left image as a reference image exemplarily.

S102,确定所述参考图像中的支持点,并计算各所述支持点的视差;其中,所述支持点为所述参考图像中的、在所述待匹配图像中有唯一且正确匹配点的像素点。S102: Determine the support points in the reference image, and calculate the disparity of each support point; wherein, the support points are those in the reference image that have unique and correct matching points in the to-be-matched image pixel.

本发明基于这样的观察:实际场景中的某个点通常不是孤立的,而是与其它一些点共存于同一个物理平面,对应地,参考图像中的某个像素点通常不是孤立的,而是与其它一些像素点共同对应于拍摄场景中的同一个物理平面。那么,基于平面约束的思想,如果能够准确地确定参考图像中每个像素点所对应的物理平面,就可以以平面为最小计算单元进行视差值填充,即可以根据像素点对应的物理平面的平面方程来确定该像素点的视差。因而,对于遮挡区域和大面积无纹理区域内的像素点的视差确定具有鲁棒性。The present invention is based on the observation that a certain point in the actual scene is usually not isolated, but coexists with some other points on the same physical plane. Correspondingly, a certain pixel in the reference image is usually not isolated, but It corresponds to the same physical plane in the shooting scene together with some other pixels. 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 minimum calculation unit, that is, the disparity value can be filled according to the physical plane corresponding to the pixel. The plane equation to determine the disparity of the pixel. Therefore, the disparity determination of pixels in occluded areas and large textureless areas 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 may be pre-determined, and these support points are pixels with unique and correct matching points in the image to be matched. The difference has good robustness and can be used to fit a 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 choose Determining a part of such pixel points 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, taking the upper left pixel point 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, constructing a grid with a step size of a preset step size in the reference image; The intersections in the grid except at the edge of the reference image are taken 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, taking the intersections 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 uniformly determined. distributed in the reference image. When the plane equation is fitted by the parallax of support points and support points, the distribution of support points in each plane is relatively uniform, and the density of support points in 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 corner pixel 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 pixels at the intersection 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), ..., last row of grid: (255, 0), (255, 5), (255, 10), ..., (255, 255). In the above intersections, after removing the intersections at the edge of the reference image, the pixels at the remaining intersections are candidate support points: The second row of the grid: (5, 5), (5, 10), ..., (5, 255) , third row of grid: (10, 5), (10, 10), …, (10, 255), …, last row of 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 to-be-matched point corresponding to each parallax within the second parallax search range corresponding to the candidate support point and the vector of the candidate support point; 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 points to be matched corresponding to each parallax within 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 in the left image is (5, 10), and the projection point x r in the right image is (5, 8), then the disparity d(x l )=2 of x l .

第二视差搜索范围包括了多个视差值,对于一个候选支持点来说,其对应的第二视差搜索范围内的每个视差值都与待匹配图像中的一个待匹配像素点(简称为待匹配点)对应。例如,对于候选支持点(5,255),其对应的第二视差搜索范围内的一个视差为2,则该视差2对应的待匹配点为(5,253)。The second parallax search range includes multiple parallax values. For a candidate support point, each parallax value in the corresponding second parallax search range is the same as a pixel to be matched in the image to be matched (referred to as corresponds to the point to be matched). For example, for the candidate support point (5, 255), a parallax corresponding to the second parallax search range is 2, and the point to be matched corresponding to the parallax 2 is (5, 253).

本实施例中,第二视差搜索范围的最小值可以为0,最大值可以根据需要设定,如设定为参考图像的宽度的一半。例如,参考图像的宽度为256,则可以设定第二视差搜索范围为0~128。那么对于候选支持点(5,255)来说,其对应的第二视差搜索范围内各视差对应的待匹配点为:待匹配图像中的像素点(5,137),…,(5,255)。当然,可以理解的是,不同的候选支持点对应的第二视差搜索范围的最大值可以不同。In this embodiment, the minimum value of the second parallax search range may be 0, and the maximum value may be set as required, for example, set to be half the width of the reference image. For example, if the width of the reference image is 256, the second parallax search range may be set to 0-128. Then for the candidate support point (5, 255), the corresponding points to be matched for each parallax in the corresponding second parallax search range are: pixel points (5, 137), ..., (5, 255) in the image to be matched ). Of course, it can be understood that the maximum value of the second parallax 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, it is set to 3×3. The second threshold can also be set empirically, for example, set to 2. In step S12, after the vector of candidate support points and the vector of each point to be matched are obtained by calculating the sobel operator, the distance between the vector of candidate support point and the vector of each point to be matched can be calculated to determine the candidate support point and the vector of each point 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 distances among the calculated distances is 1, it means that the candidate support point has a unique correct matching point, and the candidate support point can be used as a support point. Conversely, if the number of the smallest distances 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 point 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, which are R1-R5 respectively, and the second threshold is 2. If the distances between the candidate support point L1 and the points to be matched R1-R5 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 distances from 0 is 1, then the candidate support point L1 has a unique correct matching point R1, and the candidate support point can be used as the support point. If the distances between the candidate support point L1 and the points to be matched R1-R5 are: 1, 1, 2, 2, 2, then among the distances smaller than the second threshold (1, 1 in sequence), the smallest distance is 1 If the number of L1 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 the 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: Divide the reference image according to a preset image segmentation method to obtain a plurality of divided areas; divide each of the divided areas into a first type of divided area with a divided area larger than a first threshold, and/or divided areas A segmented region of the second type that is 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 the mean shift image segmentation method to obtain a plurality of segmented regions. Specifically, in the segmentation process, according to the size of the reference image and/or other attributes of the image, the color radius and the spatial radius in the Meanshift segmentation can be adjusted according to experience, so that the segmentation result is as accurate as possible. Normally, when adjusting the color radius and space radius for the image size property, if the image is relatively large, the color radius is relatively small and the space radius is relatively large. For example, for an image of size 450×375, you can set the color radius to 30 and the space radius to 30; for an image of size 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 pixels that do not correspond to the same plane in the shooting scene may be segmented into the same segmentation area. The larger the size of the segmented area, the more likely this error will occur. Therefore, in this embodiment, a first threshold can be set based on experience, so as to perform secondary segmentation of the first type of segmentation region with an area greater than the first threshold, and consider that the second type of segmentation region whose area is not greater than the first threshold The pixels of all correspond to the same plane. Specifically, when using Meanshift to segment the reference image, the setting of the first threshold is related to the color radius and the 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 divided 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 segmentation on the first-type segmented area, and divide the first-type segmented area into a plurality of first-type sub-segmented areas; according to each first-type segmented area The parallax of the support point and the support point in the sub-segmented area is fitted to the first plane equation of the first type of sub-segmented area; according to the first plane equation, the parallax of the non-supported point in the first type of sub-segmented area is determined ; wherein, the plurality of sub-segmented regions of the first type respectively correspond to different physical planes in the shooting scene.

由于设定第一类分割区域存在分割错误,即将对应于多个平面的不同分割区域都分割到了同一个第一类分割区域。因而可以对第一类分割区域进行第二次分割,得到多个第一类子分割区域,使每个第一类子分割区域内的像素点都对应于同一平面。Since there is a segmentation error in setting the first-type segmentation region, that is, different segmentation regions corresponding to multiple planes are divided into the same first-type segmentation region. Therefore, the first-type segmented region can be segmented a second time to obtain a plurality of first-type sub-segmented regions, so that the pixels in each of the first-type sub-segmented regions correspond to the same plane.

在一种实现方式中,步骤S104中的根据每个第一类子分割区域内的支持点和支持点的视差,拟合该第一类子分割区域的第一平面方程,可以包括:In an implementation manner, in step S104, fitting the first plane equation of the first type of sub-segmented region according to the support point and the disparity of the support point in each of the first-type sub-segmented regions may include:

设定第一类子分割区域的第一平面方程为:The first plane equation of the first type of sub-segmented region is set as:

d(u,v)=au+bv+cd(u, v)=au+bv+c

其中,d(u,v)表示第一类子分割区域内像素点(u,v)的视差,a,b,c为所述第一平面方程的待求解参数,通过以下公式求解所述a,b,c:Among them, d(u, v) represents the disparity of the pixel point (u, v) in the first type of sub-segmented region, a, b, c are the parameters to be solved for the first plane equation, and the a is solved by the following formula , b, c:

Figure BDA0001608097790000121
Figure BDA0001608097790000121

其中,ui表示第一类子分割区域内第i个支持点在所述参考图像对应的像素坐标系的u轴的坐标,vi表示第一类子分割区域内第i个支持点在所述参考图像对应的像素坐标系的v轴的坐标,u轴向右,v轴向下,i=1,...,m,m表示第一类子分割区域内的支持点个数,di表示第一类子分割区域内第i个支持点的视差。Among them, ui represents the coordinate of the i-th support point in the first type of sub-segmentation area on the u-axis of the pixel coordinate system corresponding to the reference image, and v i represents the i-th support point in the first type of sub-segmentation area in the The coordinates of the v-axis of the pixel coordinate system corresponding to the reference image, the u-axis is to the right, the v-axis is down, i=1, . i represents the disparity of the i-th support point in the first type of sub-segmented region.

基于每个第一类子分割区域的第一平面方程,可以确定出该第一类子分割区域内非支持点的视差。这里的非支持点是与支持点相对的概念,具体是指待确定视差的像素点。Based on the first plane equation of each sub-segmented region of the first type, the disparity of the unsupported points in the sub-segmented region of the first type can be determined. The non-support point here is a concept relative to the support point, and specifically refers to the pixel point whose disparity is to be determined.

S105,针对每个第二类分割区域,执行:对该第二类分割区域进行三角剖分,将该第二类分割区域划分为多个三角形区域;针对每个三角形区域内的每个非支持点,根据该三角形区域的各顶点和各顶点的视差确定该非支持点对应的第一视差搜索范围;将所述第一视差搜索范围内各视差对应的待匹配点与该非支持点进行逐像素匹配,确定该非支持点的视差;其中,所述各顶点均为支持点。S105, for each second-type segmentation area, perform: triangulate the second-type segmentation area, and divide the second-type segmentation area into a plurality of triangular areas; for each non-supporting area in each triangular area point, determine the first parallax search range corresponding to the non-supported point according to the parallax of each vertex and each vertex of the triangle area; carry out a step-by-step process between the to-be-matched point corresponding to each parallax in the first parallax search range and the non-supported point Pixel matching is performed to determine the parallax of the unsupported 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 regions whose area is not larger than the first threshold value all correspond to the same plane. However, due to the small area of the second type of segmentation area, the number of supporting points contained in it is small, and there may even be insufficient supporting points for plane fitting. Therefore, for the second type of segmented region, the present invention adopts the triangulation method to calculate the parallax.

三角剖分,即构建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 on exactly one edge. In this embodiment, since each vertex of the triangle is a support point, the parallax of the pixel point in the triangle is similar to the parallax of each vertex of the triangle. Moreover, the disparity of the pixels in the triangle is similar to the disparity of the surrounding support points in a certain range. Matching the to-be-matched point corresponding to the parallax of a pixel point with the pixel point by pixel can greatly reduce the parallax search range of the pixel point, 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 manner of the embodiment shown in FIG. 1 , as shown in FIG. 2 , in step S104 , the first type of segmentation area is divided a second time, and the first type of segmentation area is divided into a plurality of first type segmentation areas. Class sub-division area, which can include:

S201,按照预设的平面拟合规则,拟合该第一类分割区域内的多个支持点子集对应的物理平面的平面方程;其中,所述多个支持点子集分别对应于所述拍摄场景中不同的物理平面。S201, according to a preset plane fitting rule, fit a plane equation of a physical plane corresponding to a plurality of support point subsets in the first-type segmented region; wherein, the multiple support point subsets respectively correspond to the shooting scene different physical planes.

S202,在拟合得到的各所述物理平面中,若其中多个物理平面满足预设合并条件,则根据所述多个物理平面内的支持点和支持点的视差,拟合得到合并后物理平面的平面方程;根据合并后物理平面的平面方程和未被合并的物理平面的平面方程,计算各合并后物理平面、未被合并的物理平面间的交线,确定出所述多个第一类子分割区域;其中,所述预设合并条件为:所述多个物理平面中,任一物理平面与至少一个其他物理平面的距离小于第三阈值;S202, in each of the physical planes obtained by fitting, if a plurality of the physical planes satisfy the preset merging condition, then according to the support points in the plurality of physical planes and the parallax of the support points, a combined physical plane is obtained by fitting 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 between the merged physical planes and the unmerged physical planes, and determine the plurality of first Class sub-division area; wherein, the preset merging condition is: in 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, with respect to the multiple planes of the first-type segmented region obtained in step S201, if the distance between the two planes is small, the two planes may be combined and regarded as one plane. It can be understood that the number of support points of the merged plane is more than the number of support points of a single unmerged plane, so fitting the plane equation by 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 implemented 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 ), and the plane equation of plane 2 is : A 2 *x+B 2 *y+C 2 *d+D 2 =0, and its center point is (x 2 , y 2 , d 2 ), then the distance between plane 1 and plane 2 D=dis 1 + dis 2 , where,

Figure BDA0001608097790000141
Figure BDA0001608097790000141

具体的,步骤S202中的“根据所述多个物理平面内的支持点和支持点的视差,拟合得到合并后物理平面的平面方程”的实现过程可以参考步骤S104中的“根据每个第一类子分割区域内的支持点和支持点的视差,拟合该第一类子分割区域的第一平面方程”这一步骤的实现过程。Specifically, for the implementation process of "according to the support points in the plurality of physical planes and the parallax of the support points, the plane equation of the merged physical plane is obtained by fitting" in step S202, and reference may be made to the implementation process of "according to each th The implementation process of the step of fitting the first plane equation of the first type of sub-segmented area to the support point and the disparity of the support point in the first type of sub-segmented area.

在各合并后的平面、各未合并的平面中,相邻两个平面间的交线上的像素点满足该相邻两个平面各自的平面方程。在确定出所有相邻平面间的交线后,也就确定出了第一类分割区域的多个第一类子分割区域。In each merged plane and each unmerged plane, the pixel points on the intersection between the two adjacent planes satisfy the respective plane equations of the two adjacent planes. After the intersections between all adjacent planes are determined, a plurality of first-type sub-segmentation regions of the first-type segmented region are also determined.

S203,在拟合得到的各所述物理平面中,若其中任意两个物理平面不满足所述预设合并条件,则根据各所述物理平面的平面方程,计算各所述物理平面间的交线,确定出所述多个第一类子分割区域。S203, in each of the physical planes obtained by fitting, 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 equation of the physical planes line to determine the plurality of first-type sub-segmentation regions.

经过上述步骤S201-S203实现了对第一类分割区域进行二次分割,所得到的每个第一类子分割区域对应了拍摄场景中不同的物理平面。因而本实施例中,可以基于确定出的第一类子分割区域中的支持点拟合该第一类子分割区域的平面方程。After the above steps S201-S203, the first type of segmentation area is divided twice, 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-segmented area can be fitted based on the determined support points in the first type of sub-segmented area.

在图2所示实现方式的一种具体实现方式中,如图3所示,步骤S201中的按照预设的平面拟合规则,拟合该第一类分割区域内的多个支持点子集对应的物理平面的平面方程,可以包括:In a specific implementation manner of the implementation manner shown in FIG. 2 , as shown in FIG. 3 , in step S201 , according to a preset plane fitting rule, a plurality of support point subsets corresponding to the first type of segmented regions are fitted. The plane equation of the physical plane can include:

S301,基于随机抽样一致性RANSAC算法,从该第一类分割区域内的当前支持点集Y中选取目标支持点子集O;其中,所述O为所述Y中、支持点个数最多的支持点子集;S301, 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 segmentation area; wherein, the O is the support point in the Y with the largest number of support points point subset;

RANSAC算法可以比较准确地将图像中对应于同一平面的像素点选取出来。由于本发明具体是通过对应于一个平面的支持点和支持点的视差拟合该平面的方程。所以本实施例中,只需要通过RANSAC算法将第一类分割区域内的对应于各平面的支持点选取出来即可。具体的,可以按照支持点子集中支持点个数由多到少的顺序,逐一拟合每个支持点子集对应的平面的平面方程。The RANSAC algorithm can more accurately select the pixels corresponding to the same plane in the image. Since 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 region through the RANSAC algorithm. Specifically, the plane equations of the planes corresponding to each support point subset may be fitted one by one according to the descending order of the number of support points in the support point subset.

S302,根据所述O的支持点和支持点的视差,拟合所述O对应的物理平面的平面方程;S302, fit the plane equation of the physical plane corresponding to the O according to the support point of the O and the parallax of the support point;

具体的,步骤S302的实现过程可以参考步骤S104中的“根据每个第一类子分割区域内的支持点和支持点的视差,拟合该第一类子分割区域的第一平面方程”这一步骤的实现过程。Specifically, for the implementation process of step S302, reference may be made to the step S104, "Fit the first plane equation of the first type of sub-segmented region according to the support point and the disparity of the support point in each of the first-type sub-segmented regions". One-step implementation process.

S303,判断当前未拟合支持点子集Y-O的支持点个数是否少于预设比例的该第一类分割区域内的支持点个数;S303, judging whether the number of support points in the currently unfitted support point subset Y-O is less than the number of support points in the first type of segmentation area of a preset ratio;

可以理解,若当前未拟合支持点子集Y-O的支持点个数太少,甚至当前未拟合支持点子集Y-O已没有足够的支持点进行平面拟合,那么在这种情况下,就不能根据当前未拟合支持点子集Y-O的支持点来拟合其平面方程。具体的,上述预设比例可以根据经验设定,如设定为10%。It can be understood that if the number of support points in the current unfitted support point subset Y-O is too small, or even the current unfitted support point subset Y-O does not have enough support points for plane fitting, then in this case, the The support points of the support point subset Y-O are not currently fitted to fit their plane equations. Specifically, the above-mentioned 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 of segmentation area at a preset ratio, then the Y-O is used as the current set of support points in the first type of segmentation 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 at a preset ratio, use the plane equation of the currently fitted physical plane as the final fitting result.

对于剩余的未拟合的支持点子集Y-O的支持点,会在图2所示实施方式中的步骤S202或步骤S203中确定平面交线的过程中,被包含在某个第一类子分割区域内。具体的,这些未拟合的支持点可能会被包含在不同的第一类子分割区域,或者可能会被包含在相同的第一类子分割区域。The support points of the remaining unfitted support point subset Y-O will be included in a certain first-type sub-division area during the process of determining the plane intersection in step S202 or step S203 in the embodiment shown in FIG. 2 . Inside. Specifically, these unfitted 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的迭代处理,因此提高了匹配效率。After the iteration of the above steps S301-S305, the plane equations of a plurality of different planes in the segmented region of the first type can be obtained. Moreover, in a specific computer implementation process, the iterative processing of the above steps S301-S305 can be performed on a plurality of 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 non-supporting point in each triangular area in step S105, the corresponding non-supporting point is determined according to each vertex of the triangular area and the parallax of each vertex. The first parallax search range may 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 the disparity estimate of the unsupported 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 the parallax of each vertex by a preset value, the parallax estimated value, and the parallax within the preset neighborhood to which the non-supported 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 disparity estimated value of the target support point determined according to the second plane equation does not exceed a fourth threshold.

在上述实现方式中,“针对每个三角形区域,根据该三角形区域内的各顶点和各顶点的视差,确定该三角形区域所在平面的第二平面方程”的实现过程可以参考步骤S104中的“根据每个第一类子分割区域内的支持点和支持点的视差,拟合该第一类子分割区域的第一平面方程”这一步骤的实现过程。In the above-mentioned implementation manner, for the implementation process of "for each triangle area, according to each vertex in the triangle area and the parallax of each vertex, determine the second plane equation of the plane where the triangle area is located", please refer to step S104 "According to The implementation process of the step of fitting the first plane equation of the first type of sub-segmented area to the support point and the disparity of the support point in each first-type sub-segmented area.

示例性地,假设所确定的第二平面方程为:A*x+B*y+C*d+D=0,则三角形内一非支持点(x0,y0)的视差估计值为

Figure BDA0001608097790000161
Exemplarily, assuming that the determined second plane equation is: A*x+B*y+C*d+D=0, then the estimated disparity of an unsupported point (x 0 , y 0 ) in the triangle is
Figure BDA0001608097790000161

上述预设值可以为一个值或多个值,如果为一个值,则可以为1,如果为多个值,则可以为1、2等。例如:三角形一个顶点的视差值为2,预设值为1,则将顶点视差加和减预设值后的视差为:1和3。The above-mentioned preset value may be one value or multiple values, if it is one value, it may be 1, and if it is multiple values, it may be 1, 2, and so on. For example, if the parallax value of one vertex of a triangle is 2, and the default value is 1, the parallax value after adding and subtracting the default 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 preset neighborhood to which the unsupported point belongs may be: after dividing the reference image into a plurality of rectangular areas of preset size, the rectangular area to which the unsupported point belongs is determined according to the coordinates of the unsupported point. More specifically, each rectangular area can be marked with a position mark, and the position mark of the rectangular area to which the non-support point belongs is determined according to the coordinates of the non-support point, that is, the rectangular area described by the non-support point is determined. For example: the reference image is a 40×40 image, which is divided into 4 small areas of 20×20, and the 4 rectangular areas are marked as (0, 0), (0, 1), (1, 0) , (1, 1). The coordinates of an unsupported point are (3, 5), then 3/20=0, 5/20=0, so it belongs to the area of (0, 0); the coordinates of another unsupported point are (35, 2) , similarly 35/20=1, 2/20=0, then it belongs to the rectangular area of (1, 0). The above preset size can be set according to experience, such as 20×20. Similarly, the above-mentioned fourth threshold can also be set according to experience, for example, set to 2.

确定出三角形内一个非支持点的第一视差搜索范围后,可以将该第一视差搜索范围的各视差对应的各待匹配点与该非支持点进行逐一匹配,以从各待匹配点中确定出该支持点的匹配点。After determining the first parallax search range of an unsupported point in the triangle, each to-be-matched point corresponding to each parallax of the first parallax search range can be matched with the non-supported point one by one to determine from the to-be-matched points. Find the matching point of the support point.

在图1所示实施例的一种实现方式中,步骤S105中的将所述第一视差搜索范围内各视差对应的待匹配点与该非支持点进行逐像素匹配,确定该非支持点的视差,可以包括:In an implementation manner of the embodiment shown in FIG. 1 , in step S105, the points to be matched corresponding to each parallax in the first parallax search range are matched with the non-support point pixel by pixel, and the unsupported point is determined by pixel-by-pixel matching Parallax, which can include:

通过以下公式,确定该非支持点

Figure BDA0001608097790000171
的视差:The non-support point is determined by the following formula
Figure BDA0001608097790000171
Parallax of:

Figure BDA0001608097790000172
Figure BDA0001608097790000172

其中,

Figure BDA0001608097790000173
为该非支持点
Figure BDA0001608097790000174
的视差,dn表示所述该非支持点的视差估计值,
Figure BDA0001608097790000175
表示所述第一视差搜索范围内的各视差,N表示所述第一视差搜索范围内的视差数,S表示所述参考图像的支持点集;
Figure BDA0001608097790000176
表示
Figure BDA0001608097790000177
的后验概率,通过以下公式计算:in,
Figure BDA0001608097790000173
for the non-support point
Figure BDA0001608097790000174
The disparity of , d n represents the disparity estimation value of the non-supported point,
Figure BDA0001608097790000175
represents each parallax within the first parallax search range, N represents the number of parallaxes within the first parallax search range, and S represents the support point set of the reference image;
Figure BDA0001608097790000176
express
Figure BDA0001608097790000177
The posterior probability of , is calculated by the following formula:

Figure BDA0001608097790000178
Figure BDA0001608097790000178

其中,

Figure BDA0001608097790000179
表示dn对应的待匹配点为所述非支持点
Figure BDA00016080977900001710
的正确匹配点的概率,
Figure BDA00016080977900001711
表示所述第一视差搜索范围内的各视差对应的匹配点为所述非支持点
Figure BDA00016080977900001712
的正确匹配点的概率。in,
Figure BDA0001608097790000179
Indicates that the to-be-matched point corresponding to d n is the non-supported point
Figure BDA00016080977900001710
The probability of the correct matching point of ,
Figure BDA00016080977900001711
Indicates that the matching point corresponding to each parallax within the first parallax search range is the unsupported point
Figure BDA00016080977900001712
The probability of the correct matching point.

上述

Figure BDA00016080977900001713
以及
Figure BDA00016080977900001714
是一种概率化的表示。具体的,本实施例中,可以计算非支持点
Figure BDA00016080977900001715
与各待匹配点的相似度,该相似度可以用非支持点
Figure BDA0001608097790000181
的像素值与待匹配点的像素值之差的绝对值表示。如果一个待匹配点的像素值与非支持点
Figure BDA0001608097790000182
的像素值之差的绝对值越小,表示这个待匹配点与非支持点
Figure BDA0001608097790000183
越相似,则这个待匹配点是非支持点
Figure BDA0001608097790000184
的正确匹配点的概率就越大。the above
Figure BDA00016080977900001713
as well as
Figure BDA00016080977900001714
is a probabilistic representation. Specifically, in this embodiment, the non-support point can be calculated
Figure BDA00016080977900001715
The similarity with each point to be matched, the similarity can use the non-support point
Figure BDA0001608097790000181
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
Figure BDA0001608097790000182
The smaller the absolute value of the difference between the pixel values, the smaller the point to be matched and the non-support point
Figure BDA0001608097790000183
The more similar, the point to be matched is a non-support point
Figure BDA0001608097790000184
The greater the probability of correct matching points.

本发明实施例提供的基于平面约束和三角剖分的双目视觉立体匹配方法,针对面积较大的分割区域的各子分割区域,基于平面约束的思想,通过各子分割区域的平面方程确定各子分割区域内所有非支持点的视差,能够实现对缺失像素信息的遮挡区域以及存在匹配二义性的大面积无纹理区域更为准确地且鲁棒性更好地匹配,从而降低了匹配错误率。并且本发明实施例,针对面积较小的分割区域进行三角剖分,根据三角形的顶点和顶点视差确定三角形内非支持点的视差搜索范围,极大缩小了非支持点的视差搜索范围,提高了匹配效率。The binocular vision stereo matching method based on plane constraint and triangulation provided by the embodiment of the present invention, for each sub-segmentation region of a larger-area segmented region, based on the idea of plane constraint, the plane equation of each sub-segmentation region determines the The disparity of all non-supported points in the sub-segmentation area can achieve more accurate and robust matching of occluded areas with missing pixel information and large-area textureless areas with matching ambiguity, thereby reducing matching errors. Rate. In addition, in this embodiment of the present invention, triangulation is performed for a divided area with a small area, and the parallax search range of the non-supported points in the triangle is determined according to the vertex of the triangle and the parallax of the vertex, which greatly reduces the parallax search range of the non-supported 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 stereo matching method for binocular vision 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 diagram after Meanshift segmentation; (e) the black box represents the first type of segmentation region that is wrongly segmented in the Meanshift segmentation result diagram; (f) is a certain segment extracted from (e) to be subjected to secondary segmentation The outline of the first type of segmentation area; (g) is the second segmentation result obtained by fitting the first type of segmentation area in (f) to the 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-way operations on the reference image at the same time, one way to perform Meanshift segmentation on the reference image, and the other way 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 by the binocular stereo matching method based on plane constraints and triangulation proposed by the present invention is obviously better than that obtained by 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 in the embodiment of the invention, as shown in Table 1, the present invention is directed to four sets of standard test charts provided by the Middlebury platform, specifically: Venus , Cones, Tsukuba, and Teddy, compared the matching error rate of the stereo matching method for binocular vision based on plane constraints and triangulation provided in this application with other three stereo matching algorithms when matching each set of standard test images. Specifically, for each set of standard test maps, the matching error rates in three specific cases are compared. The other three stereo matching algorithms include: a Guided filter (GF for short) algorithm; a Non-Local (NL for short) algorithm; and a LIBELAS algorithm. The three specific cases include: Nonocc: the case where the occluded area is not considered; All: the case where all areas of the whole image are included; Disc: the case where only the depth discontinuity area is considered.

表1本发明方法与其他三种立体匹配算法的匹配错误率Table 1 Matching error rate between the method of the present invention and other three stereo matching algorithms

Figure BDA0001608097790000191
Figure BDA0001608097790000191

从表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 in 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为本发明实施例提供的一种基于平面约束和三角剖分的双目视觉立体匹配装置的结构图,该装置包括: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, and the device includes:

获取模块501,用于获取两个平行放置的摄像机在同一时间分别采集的同一拍摄场景的左图像和右图像,并将其中任一幅作为参考图像,另一幅作为待匹配图像;The acquisition module 501 is used to acquire the left image and the right image of the same shooting scene respectively collected by two cameras placed in parallel at the same time, and use any one of them as a reference image and the other as an image to be matched;

确定模块502,用于确定所述参考图像中的支持点,并计算各所述支持点的视差;其中,所述支持点为所述参考图像中的、在所述待匹配图像中有唯一且正确匹配点的像素点;A determination module 502, configured to determine the support points in the reference image, and calculate the disparity of each support point; wherein, the support points are unique and unique in the image to be matched in the reference image. Correctly match the pixel point 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 regions; to divide each of the segmented regions into a first-type segmented region with a segmented area 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 execution module 504 is configured to perform, for each first-type segmented region, performing a second segmentation on the first-type segmented region, and dividing the first-type segmented region into a plurality of first-type sub-segmented regions; According to the support points in each first-type sub-segmentation region and the disparity of the support points, the first plane equation of the first-type sub-segmentation region is fitted; according to the first plane equation, the first-type sub-segmentation region is determined Parallax of non-supported points within; wherein, the plurality of first-type sub-segmentation regions respectively correspond to different physical planes in the shooting scene;

第二执行模块505,用于针对每个第二类分割区域,执行:对该第二类分割区域进行三角剖分,将该第二类分割区域划分为多个三角形区域;针对每个三角形区域内的每个非支持点,根据该三角形区域的各顶点和各顶点的视差确定该非支持点对应的第一视差搜索范围;将所述第一视差搜索范围内各视差对应的待匹配点与该非支持点进行逐像素匹配,确定该非支持点的视差;其中,所述各顶点均为支持点。The second execution module 505 is configured to perform, for each segmented region of the second type: triangulate the segmented region of the second type, and divide the segmented region of the second type into a plurality of triangular regions; for each triangular region For each non-support point in the triangle area, determine the first parallax search range corresponding to the non-support point according to the parallax of each vertex and each vertex of the triangle area; The unsupported point is matched pixel by pixel to determine the parallax of the unsupported point; wherein, each of the vertices is a support point.

本发明实施例提供的基于平面约束和三角剖分的双目视觉立体匹配装置的有益效果与方法实施例的有益效果相同。该装置针对面积较大的分割区域的各子分割区域,基于平面约束的思想,通过各子分割区域的平面方程确定各子分割区域内所有非支持点的视差,能够实现对缺失像素信息的遮挡区域以及存在匹配二义性的大面积无纹理区域更为准确地且鲁棒性更好地匹配,从而降低了匹配错误率。并且本发明实例,针对面积较小的分割区域进行三角剖分,根据三角形的顶点和顶点视差确定三角形内非支持点的视差搜索范围,极大缩小了非支持点的视差搜索范围,提高了匹配效率。The beneficial effects of the stereo matching device for binocular vision based on plane constraints and triangulation provided by the embodiments of the present invention are the same as those of the method embodiments. Aiming at each sub-segmentation area of a segmented area with a larger area, the device determines the parallax of all non-supported points in each sub-segmented area through the plane equation of each sub-segmented area based on the idea of plane constraint, 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. In addition, in the example of the present invention, triangulation is performed for the divided area with a small area, and the parallax search range of the non-support points in the triangle is determined according to the vertex of the triangle and the vertex parallax, which greatly reduces the parallax search range of the non-support points and improves the matching. efficiency.

可选地,所述确定模块502包括:网格构建子模块、确定子模块。Optionally, the determining module 502 includes: a grid construction sub-module and a determination sub-module.

网格构建子模块,用于以所述参考图像的左上角像素点作为起点,沿所述参考图像对应的像素坐标系的u轴和v轴,在所述参考图像中构建步长为预设步长的网格;将所述网格中的、除了位于所述参考图像边缘处的交点作为候选支持点;其中,u轴向右,v轴向下。The grid construction sub-module is used to take the upper left pixel of the reference image as the starting point, along the u-axis and the v-axis of the pixel coordinate system corresponding to the reference image, the construction step in the reference image is a preset A grid of steps; the intersections in the grid except at the edge of the reference image are used as candidate support points; where the u-axis is to the right, and the v-axis is downward.

第一确定子模块,用于针对每个候选支持点,计算预先设置的该候选支持点对应的第二视差搜索范围内各视差对应的待匹配点的向量与该候选支持点的向量的距离;若计算得到的所述距离中小于第二阈值的各距离中,最小的距离的个数为1,则将该候选支持点作为支持点;其中,所述第二视差搜索范围内各视差对应的待匹配点的向量,以及所述该候选支持点的向量均根据预设尺寸的sobel算子计算得到。The first determination sub-module is used to calculate, for each candidate support point, the distance between the vector of the to-be-matched point corresponding to each parallax within the second parallax search range corresponding to the candidate support point and the vector of the candidate support point; If among the calculated distances smaller than the second threshold, the number of the smallest distances is 1, the candidate support point is used as a support point; wherein, the corresponding parallax in the second parallax search range The vector of the point to be matched and the vector of the candidate support point are calculated according to the sobel operator of the preset size.

可选地,所述分割模块503,具体用于按照均值偏移Meanshift图像分割方式,对所述参考图像进行分割,得到至少一个分割区域。Optionally, the segmentation module 503 is specifically configured to segment the reference image according to the mean shift image segmentation method to obtain at least one segmented region.

可选地,所述第一执行模块504包括:第一拟合子模块、第二拟合子模块、第二确定子模块和第三确定子模块。Optionally, the first execution module 504 includes: a first fitting submodule, a second fitting submodule, a second determination submodule, and a third determination submodule.

第一拟合子模块,用于按照预设的平面拟合规则,拟合该第一类分割区域内的多个支持点子集对应的物理平面的平面方程;其中,所述多个支持点子集分别对应于所述拍摄场景中不同的物理平面;在拟合得到的各所述物理平面中,若其中多个物理平面满足预设合并条件,则触发第二拟合子模块;在拟合得到的各所述物理平面中,若其中任意两个物理平面不满足所述预设合并条件,则触发第三确定子模块;其中,所述预设合并条件为:所述多个物理平面中,任一物理平面与至少一个其他物理平面的距离小于第三阈值。a first fitting sub-module, configured to fit a plane equation of a physical plane corresponding to a plurality of support point subsets in the first type of segmented region according to a preset plane fitting rule; wherein the plurality of support point subsets respectively correspond to different physical planes in the shooting scene; in each of the physical planes obtained by fitting, if a plurality of the physical planes meet the preset merging condition, the second fitting sub-module 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, the third determination sub-module is triggered; 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.

第二拟合子模块,用于根据所述多个物理平面内的支持点和支持点的视差,拟合得到合并后物理平面的平面方程,触发第二确定子模块;a second fitting sub-module, configured to obtain a plane equation of the merged physical plane by fitting according to the support points in the plurality of physical planes and the parallax of the support points, and trigger the second determination sub-module;

第二确定子模块,用于根据合并后物理平面的平面方程和未被合并的物理平面的平面方程,计算各合并后物理平面、未被合并的物理平面间的交线,确定出所述多个第一类子分割区域。The second determination sub-module is configured to calculate the intersection between the merged physical planes and the unmerged physical planes according to the plane equation of the merged physical plane and the plane equation of the unmerged physical plane, and determine the multiple physical planes. A first-class sub-segmentation region.

第三确定子模块,用于根据各所述物理平面的平面方程,计算各所述物理平面间的交线,确定出所述多个第一类子分割区域。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 sub-division regions.

可选地,第一拟合子模块包括:选取子单元、拟合子单元和判断子单元。Optionally, the first fitting submodule includes: a selection subunit, a fitting subunit, and a judgment subunit.

选取子单元,用于基于随机抽样一致性RANSAC算法,从该第一类分割区域内的当前支持点集Y中选取目标支持点子集O;其中,所述O为所述Y中、支持点个数最多的支持点子集。The selection subunit is used to select the target support point subset O from the current support point set Y in the first type of segmentation area based on the random sampling consistency RANSAC algorithm; wherein, the O is the number of support points in the Y The largest subset of support points.

拟合子单元,用于根据所述O的支持点和支持点的视差,拟合所述O对应的物理平面的平面方程。The fitting subunit is used for fitting the plane equation of the physical plane corresponding to the O according to the support point of the O and the parallax of the support point.

判断子单元,用于判断当前未拟合支持点子集Y-O的支持点个数是否少于预设比例的该第一类分割区域内的支持点个数;若所述Y-O的支持点个数不少于预设比例的该第一类分割区域内的支持点个数,则将所述Y-O作为该第一类分割区域内的当前支持点集,触发选取子单元;若所述Y-O的支持点个数少于预设比例的该第一类分割区域内的支持点个数,则将当前已拟合的物理平面的平面方程作为最终的拟合结果。The judging subunit is used for judging whether the number of support points of the current unfitted support point subset Y-O is less than the number of support points in the first-class segmented area of the preset ratio; if the number of support points of the Y-O is not less than the number of support points in the first type of segmentation area of the preset ratio, then the Y-O is used as the current support point set in the first type of segmentation area, triggering the selection of subunits; if the support points of the Y-O The number of support points in the first-type segmented region is less than the preset ratio, and the plane equation of the currently fitted physical plane is used as the final fitting result.

可选地,所述第一执行模块504,具体用于设定第一类子分割区域的第一平面方程为:Optionally, the first execution module 504 is specifically configured to set the first plane equation of the first type of sub-segmented region as:

d(u,v)=au+bv+cd(u, v)=au+bv+c

其中,d(u,v)表示第一类子分割区域内像素点(u,v)的视差,a,b,c为所述第一平面方程的待求解参数,通过以下公式求解所述a,b,c:Among them, d(u, v) represents the disparity of the pixel point (u, v) in the first type of sub-segmented region, a, b, c are the parameters to be solved for the first plane equation, and the a is solved by the following formula , b, c:

Figure BDA0001608097790000221
Figure BDA0001608097790000221

其中,ui表示第一类子分割区域内第i个支持点在所述参考图像对应的像素坐标系的u轴的坐标,vi表示第一类子分割区域内第i个支持点在所述参考图像对应的像素坐标系的v轴的坐标,u轴向右,v轴向下,i=1,...,m,m表示第一类子分割区域内的支持点个数,di表示第一类子分割区域内第i个支持点的视差。Among them, ui represents the coordinate of the i-th support point in the first type of sub-segmentation area on the u-axis of the pixel coordinate system corresponding to the reference image, and v i represents the i-th support point in the first type of sub-segmentation area in the The coordinates of the v-axis of the pixel coordinate system corresponding to the reference image, the u-axis is to the right, the v-axis is down, i=1, . i represents the disparity of the i-th support point in the first type of sub-segmented region.

可选地,第二执行模块505,包括:第四确定子模块、第五确定子模块。Optionally, the second execution module 505 includes: a fourth determination sub-module and a fifth determination sub-module.

第四确定子模块,用于针对每个三角形区域,根据该三角形区域内的各顶点和各顶点的视差,确定该三角形区域所在平面的第二平面方程。The fourth determination sub-module is configured to, for each triangular area, determine the second plane equation of the plane where the triangular area is located according to each vertex in the triangular area and the parallax of each vertex.

第五确定子模块,用于根据所述第二平面方程确定该非支持点的视差估计值。The fifth determination sub-module is configured to determine the disparity estimation 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 the parallax of each vertex by a preset value, the parallax estimated value determined by the fifth determination sub-module, and the non-supported parallax value. The parallax of the target support point in the preset neighborhood with the point as the center; wherein, the absolute value of the difference between the parallax of the target support point and the disparity estimated value of the target support point determined according to the second plane equation does not exceed the first Four thresholds.

可选地,第二执行模块505,具体用于通过以下公式,确定该非支持点

Figure BDA00016080977900002311
的视差:Optionally, the second execution module 505 is specifically configured to determine the non-support point through the following formula
Figure BDA00016080977900002311
Parallax of:

Figure BDA0001608097790000231
Figure BDA0001608097790000231

其中,

Figure BDA0001608097790000232
为该非支持点
Figure BDA0001608097790000233
的视差,dn表示所述该非支持点的视差估计值,
Figure BDA0001608097790000234
表示所述第一视差搜索范围内的各视差,N表示所述第一视差搜索范围内的视差数,S表示所述参考图像的支持点集;
Figure BDA0001608097790000235
表示
Figure BDA0001608097790000236
的后验概率,通过以下公式计算:in,
Figure BDA0001608097790000232
for the non-support point
Figure BDA0001608097790000233
The disparity of , d n represents the disparity estimation value of the non-supported point,
Figure BDA0001608097790000234
represents each parallax within the first parallax search range, N represents the number of parallaxes within the first parallax search range, and S represents the support point set of the reference image;
Figure BDA0001608097790000235
express
Figure BDA0001608097790000236
The posterior probability of , is calculated by the following formula:

Figure BDA0001608097790000237
Figure BDA0001608097790000237

其中,

Figure BDA0001608097790000238
表示dn的先验概率,
Figure BDA0001608097790000239
表示所述第一视差搜索范围内的各视差对应的匹配点为所述非支持点
Figure BDA00016080977900002310
的正确匹配点的概率。in,
Figure BDA0001608097790000238
represents the prior probability of d n ,
Figure BDA0001608097790000239
Indicates that the matching point corresponding to each parallax within the first parallax search range is the unsupported point
Figure BDA00016080977900002310
The probability of the correct matching point.

本发明实施例还提供了一种电子设备,如图6所示,包括处理器601、通信接口602、存储器603和通信总线604,其中,处理器601,通信接口602,存储器603通过通信总线604完成相互间的通信,An embodiment of the present invention further provides an electronic device, as shown in FIG. 6 , including a processor 601 , a communication interface 602 , a memory 603 and a communication bus 604 , wherein the processor 601 , the communication interface 602 , and the memory 603 pass through the communication bus 604 complete communication with each other,

存储器603,用于存放计算机程序;a memory 603 for storing computer programs;

处理器601,用于执行存储器603上所存放的程序时,实现如下步骤:When the processor 601 is used to execute the program stored in the memory 603, the following steps are implemented:

获取两个平行放置的摄像机在同一时间分别采集的同一拍摄场景的左图像和右图像,并将其中任一幅作为参考图像,另一幅作为待匹配图像;Acquire the left image and the right image of the same shooting scene collected by two cameras placed in parallel at the same time, and use any one of them as a reference image and the other as an image to be matched;

确定所述参考图像中的支持点,并计算各所述支持点的视差;其中,所述支持点为所述参考图像中的、在所述待匹配图像中有唯一且正确匹配点的像素点;Determine the support points in the reference image, and calculate the parallax of each support point; 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 a preset image segmentation method, the reference image is segmented to obtain a plurality of segmented regions; each of the segmented regions is divided into a first-type segmented region with a segmented area greater than a first threshold, and/or a segmented area not greater than the second type of segmentation region of the first threshold;

针对每个第一类分割区域,执行:对该第一类分割区域进行第二次分割,将该第一类分割区域划分为多个第一类子分割区域;根据每个第一类子分割区域内的支持点和支持点的视差,拟合该第一类子分割区域的第一平面方程;根据所述第一平面方程,确定该第一类子分割区域内非支持点的视差;其中,所述多个第一类子分割区域分别对应于所述拍摄场景中不同的物理平面;For each first-type segmentation area, perform: perform a second segmentation on the first-type segmentation area, and divide the first-type segmentation area into a plurality of first-type sub-segmentation areas; according to each first-type sub-segmentation The disparity of the support point and the support point in the area, fit the first plane equation of the first type of sub-segmented area; according to the first plane equation, determine the disparity of the non-supported point in the first type of sub-segmented area; wherein , the plurality of first-type sub-segmentation regions respectively correspond to different physical planes in the shooting scene;

针对每个第二类分割区域,执行:对该第二类分割区域进行三角剖分,将该第二类分割区域划分为多个三角形区域;针对每个三角形区域内的每个非支持点,根据该三角形区域的各顶点和各顶点的视差确定该非支持点对应的第一视差搜索范围;将所述第一视差搜索范围内各视差对应的待匹配点与该非支持点进行逐像素匹配,确定该非支持点的视差;其中,所述各顶点均为支持点。For each segmented region of the second type, perform: triangulate the segmented region of the second type, and divide the segmented region of the second type into a plurality of triangular regions; for each non-support point in each triangular region, Determine the first parallax search range corresponding to the unsupported point according to the parallax of each vertex and each vertex of the triangle area; perform pixel-by-pixel matching between the to-be-matched point corresponding to each parallax within the first parallax search range and the non-supported point , determine the parallax of the non-supporting point; wherein, each vertex is a supporting 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-division area of the divided area with a larger area, based on the idea of plane constraints, the plane equation of each sub-division area determines each sub-division area. The disparity of all non-supported points in the sub-segmentation area can achieve more accurate and robust matching of occluded areas with missing pixel information and large-area textureless areas with matching ambiguity, thereby reducing matching errors. Rate. In addition, in the example of the present invention, triangulation is performed for the divided area with a small area, and the parallax search range of the non-support points in the triangle is determined according to the vertex of the triangle and the vertex parallax, which greatly reduces the parallax search range of the non-support points and improves the matching. efficiency.

上述电子设备提到的通信总线可以是外设部件互连标准(Peripheral ComponentInterconnect,简称PCI)总线或扩展工业标准结构(Extended Industry StandardArchitecture,简称EISA)总线等。该通信总线可以分为地址总线、数据总线、控制总线等。为便于表示,图中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。The communication bus mentioned in the above 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 presentation, 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 above electronic device and other devices.

存储器可以包括随机存取存储器(Random Access Memory,简称RAM),也可以包括非易失性存储器(non-volatile memory),例如至少一个磁盘存储器。可选的,存储器还可以是至少一个位于远离前述处理器的存储装置。The memory may include random access memory (Random Access Memory, RAM for short), and may also include 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 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 may 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.; may also be a digital signal processor (Digital Signal Processing, referred to as DSP) , Application Specific Integrated Circuit (ASIC for short), Field-Programmable Gate Array (FPGA for short) or other programmable logic devices, discrete gate or transistor logic devices, and discrete hardware components.

在本发明提供的又一实施例中,还提供了一种计算机可读存储介质,该计算机可读存储介质中存储有指令,当其在计算机上运行时,使得计算机执行上述实施例中任一的基于平面约束和三角剖分的双目视觉立体匹配方法。In yet another embodiment provided by the present invention, a computer-readable storage medium is also provided, where instructions are stored in the computer-readable storage medium, when the computer-readable storage medium is run on a computer, the computer is made to execute any one of the above-mentioned embodiments. A stereo matching method for binocular vision based on planar constraints and triangulation.

本发明实施例提供的计算机可读存储介质内存储的指令,当其在计算机上运行时,针对面积较大的分割区域的各子分割区域,基于平面约束的思想,通过各子分割区域的平面方程确定各子分割区域内所有非支持点的视差,能够实现对缺失像素信息的遮挡区域以及存在匹配二义性的大面积无纹理区域更为准确地且鲁棒性更好地匹配,从而降低了匹配错误率。并且本发明实例,针对面积较小的分割区域进行三角剖分,根据三角形的顶点和顶点视差确定三角形内非支持点的视差搜索范围,极大缩小了非支持点的视差搜索范围,提高了匹配效率。When the instructions stored in the computer-readable storage medium provided by the embodiments of the present invention are run on a computer, for each sub-segmentation area of the segmented area with a larger area, based on the idea of plane constraint, the plane of each sub-segmented area is The equation determines the disparity of all non-supported points in each sub-segmented area, which can achieve more accurate and robust matching of occluded areas with missing pixel information and large-area textureless areas with matching ambiguity, thereby reducing match error rate. In addition, in the example of the present invention, triangulation is performed for the divided area with a small area, and the parallax search range of the non-support points in the triangle is determined according to the vertex of the triangle and the vertex parallax, which greatly reduces the parallax search range of the non-support points and improves the matching. efficiency.

在本发明提供的又一实施例中,还提供了一种包含指令的计算机程序产品,当其在计算机上运行时,使得计算机执行上述实施例中任一的基于平面约束和三角剖分的双目视觉立体匹配方法。In yet another embodiment provided by the present invention, there is also provided a computer program product comprising instructions, which, when run on a computer, causes the computer to execute any one of the above-mentioned embodiments based on the dual plane constraint and triangulation. A visual stereo matching method.

本发明实施例提供的包含指令的计算程序产品,当其在计算机上运行时,针对面积较大的分割区域的各子分割区域,基于平面约束的思想,通过各子分割区域的平面方程确定各子分割区域内所有非支持点的视差,能够实现对缺失像素信息的遮挡区域以及存在匹配二义性的大面积无纹理区域更为准确地且鲁棒性更好地匹配,从而降低了匹配错误率。并且本发明实例,针对面积较小的分割区域进行三角剖分,根据三角形的顶点和顶点视差确定三角形内非支持点的视差搜索范围,极大缩小了非支持点的视差搜索范围,提高了匹配效率。When the computing program product including the instructions provided by the embodiment of the present invention is run on a computer, for each sub-segmented region of the larger-area segmented region, based on the idea of plane constraints, the plane equations of the sub-segmented regions are used to determine each sub-segmented region. The disparity of all non-supported points in the sub-segmentation area can achieve more accurate and robust matching of occluded areas with missing pixel information and large-area textureless areas with matching ambiguity, thereby reducing matching errors. Rate. In addition, in the example of the present invention, triangulation is performed for the divided area with a small area, and the parallax search range of the non-support points in the triangle is determined according to the vertex of the triangle and the vertex parallax, which greatly reduces the parallax search range of the non-support points and improves the matching. efficiency.

在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行计算机程序指令时,全部或部分地产生按照本发明实施例的流程或功能。计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线(DSL))或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质(例如固态硬盘Solid State Disk(SSD))等。In the above-mentioned embodiments, it may be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented in software, it can 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 a computer, the procedures or functions according to the embodiments of the present invention result in whole or in part. The computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable device. Computer instructions may be stored on or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website site, computer, server, or data center over a wire (e.g. coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (eg, infrared, wireless, microwave, etc.) to another website site, computer, server, or data center. A computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server, a data center, or the like that includes an integration of one or more available media. Useful media may be magnetic media (eg, floppy disk, hard disk, magnetic tape), optical media (eg, DVD), or semiconductor media (eg, Solid State Disk (SSD)), among others.

需要说明的是,在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个......”限定的要素,并不排除在包括要素的过程、方法、物品或者设备中还存在另外的相同要素。It should be noted that, in this document, 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 any relationship between these entities or operations. any such actual relationship or sequence exists. Moreover, the terms "comprising", "comprising" or any other variation thereof are intended to encompass a non-exclusive inclusion such that a process, method, article or device that includes a list of elements includes not only those elements, but also includes not explicitly listed or other elements inherent to such a process, method, article or apparatus. Without further limitation, an element qualified by the phrase "comprising a..." does not preclude the presence of additional identical elements in the process, method, article, or device that includes the element.

本说明书中的各个实施例均采用相关的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于装置/电子设备/存储介质/计算机程序产品实施例而言,由于其基本相似于方法实施例,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。Each embodiment in this specification is described in a related manner, and the same and similar parts between the various embodiments may be referred to each other, and each embodiment focuses on the differences from other embodiments. Especially, for the apparatus/electronic device/storage medium/computer program product embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and for related parts, please refer to the partial description of the method embodiment.

以上仅为本发明的较佳实施例而已,并非用于限定本发明的保护范围。凡在本发明的精神和原则之内所作的任何修改、等同替换、改进等,均包含在本发明的保护范围内。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 principle of the present invention are included in the protection scope of the present invention.

Claims (9)

1.一种基于平面约束和三角剖分的双目视觉立体匹配方法,其特征在于,包括:1. a binocular vision stereo matching method based on plane constraint and triangulation, is characterized in that, comprises: 获取两个平行放置的摄像机在同一时间分别采集的同一拍摄场景的左图像和右图像,并将其中任一幅作为参考图像,另一幅作为待匹配图像;Acquire the left image and the right image of the same shooting scene collected by two cameras placed in parallel at the same time, and use any one of them as a reference image and the other as an image to be matched; 确定所述参考图像中的支持点,并计算各所述支持点的视差;其中,所述支持点为所述参考图像中的、在所述待匹配图像中有唯一且正确匹配点的像素点;Determine the support points in the reference image, and calculate the parallax of each support point; 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 a preset image segmentation method, the reference image is segmented to obtain a plurality of segmented regions; the second type of segmentation region of the first threshold; 针对每个第一类分割区域,执行:对该第一类分割区域进行第二次分割,将该第一类分割区域划分为多个第一类子分割区域;根据每个第一类子分割区域内的支持点和支持点的视差,拟合该第一类子分割区域的第一平面方程;根据所述第一平面方程,确定该第一类子分割区域内非支持点的视差;其中,所述多个第一类子分割区域分别对应于所述拍摄场景中不同的物理平面;For each first-type segmentation area, perform: perform a second segmentation on the first-type segmentation area, and divide the first-type segmentation area into a plurality of first-type sub-segmentation areas; according to each first-type sub-segmentation The disparity of the support point and the support point in the area, fit the first plane equation of the first type of sub-segmented area; according to the first plane equation, determine the disparity of the non-supported point in the first type of sub-segmented area; wherein , the plurality of first-type sub-segmentation regions respectively correspond to different physical planes in the shooting scene; 针对每个第二类分割区域,执行:对该第二类分割区域进行三角剖分,将该第二类分割区域划分为多个三角形区域;针对每个三角形区域内的每个非支持点,根据该三角形区域的各顶点和各顶点的视差确定该非支持点对应的第一视差搜索范围;将所述第一视差搜索范围内各视差对应的待匹配点与该非支持点进行逐像素匹配,确定该非支持点的视差;其中,所述各顶点均为支持点;For each segmented region of the second type, perform: triangulate the segmented region of the second type, and divide the segmented region of the second type into a plurality of triangular regions; for each non-support point in each triangular region, Determine the first parallax search range corresponding to the unsupported point according to the parallax of each vertex and each vertex of the triangle area; perform pixel-by-pixel matching between the to-be-matched point corresponding to each parallax within the first parallax search range and the non-supported point , determine the parallax of the non-supporting point; wherein, each vertex is a supporting point; 其中,所述对该第一类分割区域进行第二次分割,将该第一类分割区域划分为多个第一类子分割区域,包括:Wherein, the second division of the first type of segmentation area is performed, and the first type of segmentation area is divided into a plurality of first type of sub-segmentation areas, including: 按照预设的平面拟合规则,拟合该第一类分割区域内的多个支持点子集对应的物理平面的平面方程;其中,所述多个支持点子集分别对应于所述拍摄场景中不同的物理平面;According to the preset plane fitting rule, fit the plane equation of the physical plane corresponding to the plurality of support point subsets in the first type of segmentation area; wherein, the multiple support point subsets correspond to different the physical plane; 在拟合得到的各所述物理平面中,若其中多个物理平面满足预设合并条件,则根据所述多个物理平面内的支持点和支持点的视差,拟合得到合并后物理平面的平面方程;根据合并后物理平面的平面方程和未被合并的物理平面的平面方程,计算各合并后物理平面、未被合并的物理平面间的交线,确定出所述多个第一类子分割区域;其中,所述预设合并条件为:所述多个物理平面中,任一物理平面与至少一个其他物理平面的距离小于第三阈值;In each of the physical planes obtained by fitting, if multiple physical planes meet the preset merging conditions, then according to the support points in the multiple physical planes and the disparity of the support points, the fitting of the merged physical planes is obtained. Plane equation; according to the plane equation of the merged physical plane and the plane equation of the unmerged physical plane, calculate the line of intersection between the merged physical planes and the unmerged physical planes, and determine the plurality of first-type subtypes dividing a region; 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; 在拟合得到的各所述物理平面中,若其中任意两个物理平面不满足所述预设合并条件,则根据各所述物理平面的平面方程,计算各所述物理平面间的交线,确定出所述多个第一类子分割区域。In each of the physical planes obtained by fitting, if any two of the physical planes do not satisfy the preset merging condition, then according to the plane equation of each of the physical planes, the intersection line between the physical planes is calculated, The plurality of sub-segmented regions of the first type are determined. 2.根据权利要求1所述的方法,其特征在于,所述确定所述参考图像中的支持点,包括:2. The method according to claim 1, wherein the determining a support point in the reference image comprises: 以所述参考图像的左上角像素点作为起点,沿所述参考图像对应的像素坐标系的u轴和v轴,在所述参考图像中构建步长为预设步长的网格;将所述网格中的、除了位于所述参考图像边缘处的交点作为候选支持点;其中,u轴向右,v轴向下;Taking the pixel in the upper left corner of the reference image as the 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 preset step size in the reference image; In the grid, except for the intersection points located at the edge of the reference image as candidate support points; wherein, the u axis is to the right, and the v axis is downward; 针对每个候选支持点,计算预先设置的该候选支持点对应的第二视差搜索范围内各视差对应的待匹配点的向量与该候选支持点的向量的距离;若计算得到的所述距离中小于第二阈值的各距离中,最小的距离的个数为1,则将该候选支持点作为支持点;其中,所述第二视差搜索范围内各视差对应的待匹配点的向量,以及所述该候选支持点的向量均根据预设尺寸的sobel算子计算得到。For each candidate support point, calculate the distance between the vector of the to-be-matched point corresponding to each parallax within the second parallax search range corresponding to the candidate support point and the vector of the candidate support point; if the calculated distance is small Among the distances of the second threshold, if the number of the smallest distance is 1, the candidate support point is regarded as a support point; wherein, the vector of the points to be matched corresponding to each parallax within the second parallax search range, and the The vectors of the candidate support points are all calculated according to the preset size of the sobel operator. 3.根据权利要求1所述的方法,其特征在于,所述按照预设的图像分割方式,对所述参考图像进行分割,得到多个分割区域,包括:3. The method according to claim 1, wherein the reference image is segmented according to a preset image segmentation method to obtain a plurality of segmented regions, comprising: 按照均值偏移Meanshift图像分割方式,对所述参考图像进行分割,得到多个分割区域。The reference image is segmented according to the mean shift image segmentation method to obtain a plurality of segmented regions. 4.根据权利要求1所述的方法,所述按照预设的平面拟合规则,拟合该第一类分割区域内的多个支持点子集对应的物理平面的平面方程,包括:4. The method according to claim 1, wherein according to a preset plane fitting rule, fitting the plane equation of the physical plane corresponding to a plurality of support point subsets in the first-type segmented region, comprising: 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 segmentation area; wherein, the O is the support point in the Y with the largest number of support points point subset; S2、根据所述O的支持点和支持点的视差,拟合所述O对应的物理平面的平面方程;S2, fit the plane equation of the physical plane corresponding to the O according to the support point of the O and the parallax of the support point; S3、判断当前未拟合支持点子集Y-O的支持点个数是否少于预设比例的该第一类分割区域内的支持点个数;S3, judging whether the number of support points of the current unfitted support point subset Y-O is less than the number of support points in the first type of segmentation area of a 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 of segmented area at a preset ratio, then the Y-O is used as the current set of support points in the first type of segmented area, and the execution returns 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 region at a preset ratio, the plane equation of the currently fitted physical plane is used as the final fitting result. 5.根据权利要求1所述的方法,其特征在于,所述根据每个第一类子分割区域内的支持点和支持点的视差,拟合该第一类子分割区域的第一平面方程,包括:5 . The method according to claim 1 , wherein the first plane equation of the first type of sub-segmented region is fitted according to the support point and the disparity of the support point in each of the first-type sub-segmented regions. 6 . ,include: 设定第一类子分割区域的第一平面方程为:The first plane equation of the first type of sub-segmented region is set as: d(u,v)=au+bv+cd(u,v)=au+bv+c 其中,d(u,v)表示第一类子分割区域内像素点(u,v)的视差,a,b,c为所述第一平面方程的待求解参数,通过以下公式求解所述a,b,c:Among them, d(u, v) represents the disparity of the pixel (u, v) in the first type of sub-segmentation area, a, b, c are the parameters to be solved for the first plane equation, and the a is solved by the following formula ,b,c:
Figure FDA0002451191050000031
Figure FDA0002451191050000031
其中,ui表示第一类子分割区域内第i个支持点在所述参考图像对应的像素坐标系的u轴的坐标,vi表示第一类子分割区域内第i个支持点在所述参考图像对应的像素坐标系的v轴的坐标,u轴向右,v轴向下,i=1,...,m,m表示第一类子分割区域内的支持点个数,di表示第一类子分割区域内第i个支持点的视差。Among them, ui represents the coordinate of the i-th support point in the first type of sub-segmentation area on the u-axis of the pixel coordinate system corresponding to the reference image, and v i represents the i-th support point in the first type of sub-segmentation area in the The coordinates of the v-axis of the pixel coordinate system corresponding to the reference image, the u-axis is to the right, the v-axis is down, i=1,...,m, m represents the number of support points in the first type of sub-segmentation area, d i represents the disparity of the i-th support point in the first type of sub-segmented region.
6.根据权利要求1所述的方法,其特征在于,所述针对每个三角形区域内的每个非支持点,根据该三角形区域的各顶点和各顶点的视差确定该非支持点对应的第一视差搜索范围,包括:6 . The method according to claim 1 , wherein, for each non-supporting point in each triangular area, the third corresponding to the non-supporting point is determined according to each vertex of the triangular area and the parallax of each vertex. 7 . A parallax search range, including: 针对每个三角形区域,根据该三角形区域内的各顶点和各顶点的视差,确定该三角形区域所在平面的第二平面方程;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 the disparity estimate of the unsupported 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 the parallax of each vertex by a preset value, the parallax estimated value, and the parallax within the preset neighborhood to which the non-supported 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 disparity estimated value of the target support point determined according to the second plane equation does not exceed a fourth threshold. 7.根据权利要求6所述的方法,其特征在于,所述将所述第一视差搜索范围内各视差对应的待匹配点与该非支持点进行逐像素匹配,确定该非支持点的视差,包括:7 . The method according to claim 6 , wherein the point to be matched corresponding to each parallax in the first parallax search range is matched with the unsupported point pixel by pixel, and the parallax of the unsupported point is determined. 8 . ,include: 通过以下公式,确定该非支持点
Figure FDA0002451191050000041
的视差:
The non-support point is determined by the following formula
Figure FDA0002451191050000041
Parallax of:
Figure FDA0002451191050000042
Figure FDA0002451191050000042
其中,
Figure FDA0002451191050000043
为该非支持点
Figure FDA0002451191050000044
的视差,dn表示所述该非支持点的视差估计值,
Figure FDA0002451191050000045
表示所述第一视差搜索范围内的各视差,N表示所述第一视差搜索范围内的视差数,S表示所述参考图像的支持点集;
Figure FDA0002451191050000046
表示
Figure FDA0002451191050000047
的后验概率,通过以下公式计算:
in,
Figure FDA0002451191050000043
for the non-support point
Figure FDA0002451191050000044
The disparity of , d n represents the disparity estimation value of the non-supported point,
Figure FDA0002451191050000045
represents each parallax within the first parallax search range, N represents the number of parallaxes within the first parallax search range, and S represents the support point set of the reference image;
Figure FDA0002451191050000046
express
Figure FDA0002451191050000047
The posterior probability of , is calculated by the following formula:
Figure FDA0002451191050000048
Figure FDA0002451191050000048
其中,
Figure FDA0002451191050000049
表示dn对应的待匹配点为所述非支持点
Figure FDA00024511910500000410
的正确匹配点的概率,
Figure FDA00024511910500000411
表示所述第一视差搜索范围内的各视差对应的待匹配点为所述非支持点
Figure FDA00024511910500000412
的正确匹配点的概率。
in,
Figure FDA0002451191050000049
Indicates that the to-be-matched point corresponding to d n is the non-supported point
Figure FDA00024511910500000410
The probability of the correct matching point of ,
Figure FDA00024511910500000411
Indicates that the to-be-matched point corresponding to each parallax within the first parallax search range is the non-supported point
Figure FDA00024511910500000412
The probability of the correct matching point.
8.一种基于平面约束和三角剖分的双目视觉立体匹配装置,其特征在于,包括:8. A binocular vision stereo matching device based on plane constraint and triangulation, is characterized in that, comprises: 获取模块,用于获取两个平行放置的摄像机在同一时间分别采集的同一拍摄场景的左图像和右图像,并将其中任一幅作为参考图像,另一幅作为待匹配图像;an acquisition module, configured to acquire the left image and the right image of the same shooting scene respectively collected by two cameras placed in parallel at the same time, and use any one of them as a reference image and the other as an image to be matched; 确定模块,用于确定所述参考图像中的支持点,并计算各所述支持点的视差;其中,所述支持点为所述参考图像中的、在所述待匹配图像中有唯一且正确匹配点的像素点;A determination module, configured to determine the support points in the reference image, and calculate the disparity of each support point; wherein, the support points are unique and correct in the reference image and in the to-be-matched image Pixel points 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 regions; divide each of the segmented regions into a first-type segmented region with a segmented area greater than a first threshold, and segment a second type of segmentation region whose area is not greater than the first threshold; 第一执行模块,用于针对每个第一类分割区域,执行:对该第一类分割区域进行第二次分割,将该第一类分割区域划分为多个第一类子分割区域;根据每个第一类子分割区域内的支持点和支持点的视差,拟合该第一类子分割区域的第一平面方程;根据所述第一平面方程,确定该第一类子分割区域内非支持点的视差;其中,所述多个第一类子分割区域分别对应于所述拍摄场景中不同的物理平面;The first execution module is configured to, for each first-type segmented region, execute: perform a second segmentation on the first-type segmented region, and divide the first-type segmented region into a plurality of first-type sub-segmented regions; according to For the support points and the disparity of the support points in each first-type sub-segmentation area, fit the first plane equation of the first-type sub-segmentation area; according to the first plane equation, determine the first-type sub-segmentation area Disparity of non-supported points; wherein, the plurality of first-type sub-segmentation regions respectively correspond to different physical planes in the shooting scene; 第二执行模块,用于针对每个第二类分割区域,执行:对该第二类分割区域进行三角剖分,将该第二类分割区域划分为多个三角形区域;针对每个三角形区域内的每个非支持点,根据该三角形区域的各顶点和各顶点的视差确定该非支持点对应的第一视差搜索范围;将所述第一视差搜索范围内各视差对应的待匹配点与该非支持点进行逐像素匹配,确定该非支持点的视差;其中,所述各顶点均为支持点;The second execution module is configured to perform, for each segmented region of the second type: triangulate the segmented region of the second type, and divide the segmented region of the second type into a plurality of triangular regions; For each non-supporting point, determine the first parallax search range corresponding to the non-supporting point according to the parallax of each vertex and each vertex of the triangle area; compare the point to be matched corresponding to each parallax in the first parallax search range The unsupported point is matched pixel by pixel, and the parallax of the unsupported point is determined; wherein, each of the vertices is a support point; 其中,所述第一执行模块包括:第一拟合子模块、第二拟合子模块、第二确定子模块和第三确定子模块;Wherein, the first execution module includes: a first fitting sub-module, a second fitting sub-module, a second determination sub-module and a third determination sub-module; 所述第一拟合子模块,用于按照预设的平面拟合规则,拟合该第一类分割区域内的多个支持点子集对应的物理平面的平面方程;其中,所述多个支持点子集分别对应于所述拍摄场景中不同的物理平面;在拟合得到的各所述物理平面中,若其中多个物理平面满足预设合并条件,则触发所述第二拟合子模块;在拟合得到的各所述物理平面中,若其中任意两个物理平面不满足所述预设合并条件,则触发所述第三确定子模块;其中,所述预设合并条件为:所述多个物理平面中,任一物理平面与至少一个其他物理平面的距离小于第三阈值;The first fitting sub-module is configured to fit the plane equation of the physical plane corresponding to the plurality of support point subsets in the first type of segmented region according to the preset plane fitting rule; wherein, the plurality of support points The point subsets respectively correspond to different physical planes in the shooting scene; in each of the physical planes obtained by fitting, if a plurality of the physical planes satisfy a preset merging condition, the second fitting submodule is triggered; In each of the physical planes obtained by fitting, if any two of the physical planes do not meet the preset merging condition, the third determination sub-module is triggered; wherein, the preset merging condition is: the Among the multiple physical planes, the distance between any physical plane and at least one other physical plane is less than a third threshold; 所述第二拟合子模块,用于根据所述多个物理平面内的支持点和支持点的视差,拟合得到合并后物理平面的平面方程,触发所述第二确定子模块;The second fitting sub-module is configured to obtain the plane equation of the merged physical plane by fitting according to the support points in the multiple physical planes and the parallax of the support points, and trigger the second determination sub-module; 所述第二确定子模块,用于根据合并后物理平面的平面方程和未被合并的物理平面的平面方程,计算各合并后物理平面、未被合并的物理平面间的交线,确定出所述多个第一类子分割区域;The second determination submodule is used to calculate the intersection between the merged physical planes and the unmerged physical planes according to the plane equation of the merged physical plane and the plane equation of the unmerged physical plane, and determine the the plurality of first-type sub-segmentation regions; 所述第三确定子模块,用于根据各所述物理平面的平面方程,计算各所述物理平面间的交线,确定出所述多个第一类子分割区域。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 sub-division regions. 9.一种电子设备,其特征在于,包括处理器、通信接口、存储器和通信总线,其中,处理器,通信接口,存储器通过通信总线完成相互间的通信;9. An electronic device, characterized in that it comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface, and the memory complete mutual communication through the communication bus; 存储器,用于存放计算机程序;memory for storing computer programs; 处理器,用于执行存储器上所存放的程序时,实现权利要求1-7任一所述的方法步骤。The processor is configured to implement the method steps of any one of claims 1-7 when executing the program stored in the memory.
CN201810252302.6A 2018-03-26 2018-03-26 Binocular vision stereo matching method and device based on plane constraint and triangulation Expired - Fee Related CN108564604B (en)

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 CN108564604A (en) 2018-09-21
CN108564604B true 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)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113141495B (en) * 2020-01-16 2023-03-24 纳恩博(北京)科技有限公司 Image processing method and device, storage medium and electronic device
CN112116639B (en) * 2020-09-08 2022-06-07 苏州浪潮智能科技有限公司 Image registration method and device, electronic equipment and storage medium
CN112102504A (en) * 2020-09-16 2020-12-18 成都威爱新经济技术研究院有限公司 Three-dimensional scene and two-dimensional image mixing method based on mixed reality
CN112308896B9 (en) * 2020-11-06 2025-04-18 上海肇观电子科技有限公司 Image processing method, chip circuit, device, electronic device and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101312539A (en) * 2008-07-03 2008-11-26 浙江大学 Hierarchical Image Depth Extraction Method for 3D Television
CN102982560A (en) * 2011-11-02 2013-03-20 微软公司 Surface segmentation according to RGB and depth image
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

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101887589B (en) * 2010-06-13 2012-05-02 东南大学 A Real-Shot Low-Texture Image Reconstruction Method Based on Stereo Vision
US9672609B1 (en) * 2011-11-11 2017-06-06 Edge 3 Technologies, Inc. Method and apparatus for improved depth-map estimation

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101312539A (en) * 2008-07-03 2008-11-26 浙江大学 Hierarchical Image Depth Extraction Method for 3D Television
CN102982560A (en) * 2011-11-02 2013-03-20 微软公司 Surface segmentation according to RGB and depth image
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)

* Cited by examiner, † Cited by third party
Title
"Constrained Relative Attitude Determination for Two-Vehicle Formations";Richard Linares et al.;《https://arc.aiaa.org/doi/pdf/10.2514/1.50053》;20120523;全文 *
"Efficient High-Resolution Stereo Matching Using Local Plane Sweeps";Sudipta Narayan Sinha et al.;《2014 IEEE Conference on Computer Vision and Pattern Recognition》;20140628;全文 *
"Efficient Large-Scale Stereo Matching";Andreas Geiger et al.;《https://www.researchgate.net/publication/220745081》;20101231;第3节 *

Also Published As

Publication number Publication date
CN108564604A (en) 2018-09-21

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
US8452081B2 (en) Forming 3D models using multiple images
CN110276829B (en) Three-dimensional representation by multi-scale voxel hash processing
KR102318023B1 (en) 3-Dimensional Model Generation Using Edges
WO2020119684A1 (en) 3d navigation semantic map update method, apparatus and device
CN106033621B (en) A kind of method and device of three-dimensional modeling
US20130127847A1 (en) System and Method for Interactive Image-based Modeling of Curved Surfaces Using Single-view and Multi-view Feature Curves
WO2015135323A1 (en) Camera tracking method and device
CN108564604B (en) Binocular vision stereo matching method and device based on plane constraint and triangulation
WO2022052582A1 (en) Image registration method and device, electronic apparatus, and storage medium
CN115063550B (en) Semantic point cloud map construction method and system and intelligent robot
WO2025156819A1 (en) Three-dimensional point cloud segmentation method and apparatus based on locally weighted curvature and two-point method
WO2013176894A2 (en) Combining narrow-baseline and wide-baseline stereo for three-dimensional modeling
Zhou et al. Three-dimensional (3D) reconstruction of structures and landscapes: a new point-and-line fusion method
CN113052954A (en) Three-dimensional reconstruction method, device, terminal and storage medium based on line segment matching
EP4246452A1 (en) Three-dimensional point cloud densification device, three-dimensional point cloud densification method, and program
CN109658497B (en) A three-dimensional model reconstruction method and device
CN113379826A (en) Method and device for measuring volume of logistics piece
CN103503033B (en) Merging three-dimensional models based on confidence scores
CN113052880A (en) SFM sparse reconstruction method, system and application
CN113920275A (en) Triangular mesh construction method and device, electronic equipment and readable storage medium
WO2023165220A1 (en) Target object detection method and apparatus
US11087536B2 (en) Methods, devices and computer program products for generation of mesh in constructed 3D images
US20240355067A1 (en) Fully automated estimation of scene parameters

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
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20200703