从Disparity获取3D点时出错

时间:2011-03-13 18:38:52

标签: graphics opencv computer-vision stereo-3d

所以我计算了2个立体图像(左右)之间的差异。看起来是正确的 (因为它在形状上与原始图像有些相似)。之后我使用了这一行: -

cvReprojectImageTo3D(&disparity, threeDimage, &Q);

并在threeDimage中得到答案。它是一个矩阵,我将其作为: -

访问
for(int ii=0;ii<threeDimage->rows;ii++)
    {       
    float *data = (float *)(threeDimage->data.ptr + ii * threeDimage->step);

    for(int jj=0;jj<threeDimage->cols*3;jj=jj+3) 
   {


      float a=data[jj];
      float b=data[jj+1];
      float c=data[jj+2];
      fprintf(fpp,"%f %f %f \n", a,b,c);

       }

}

但问题是它似乎没有给我一个正确的答案。我的文件中有很多重复的值。任何可能出错的提示?矩阵的遍历是否正确?

1 个答案:

答案 0 :(得分:0)

您只能从视差图中存在边缘的点获得不同的3D距离。如果您有大面积相同的差异(输入图像中为灰色),那么它们将具有相同的Z.