【发布时间】:2020-01-11 09:38:31
【问题描述】:
我使用SGBM和wls得到的视差图如下。但是得到的视差图有一些缺陷,所以我的点云也很差。有人可以告诉我如何优化它吗?
int dis2pcloud(Mat color,Mat depth)
{
if (color.empty() || depth.empty())
{
cout << "The image is empty, please check it!" << endl;
return -1;
}
PointCloud<PointXYZRGB>::Ptr cloud(new PointCloud<PointXYZRGB>);
for (int row = 0; row < depth.rows; row++)
{
for (int col = 0; col < depth.cols; col++)
{
ushort d = depth.ptr<ushort>(row)[col];
if (d==0)
continue;
PointXYZRGB p;
p.z = fx * baseline / (d + doffs); // Zc = baseline * f / (d + doffs)
p.x = (col - u0) * p.z / fx;
p.y = (row - v0) * p.z / fy;
p.y = -p.y;
p.z = -p.z;
p.b = color.ptr<uchar>(row)[col * 3];
p.g = color.ptr<uchar>(row)[col * 3 + 1];
p.r = color.ptr<uchar>(row)[col * 3 + 2];
cloud->points.push_back(p);
}
}
【问题讨论】:
标签: depth stereo-3d 3d-reconstruction