black borders to the left of objects in opencv SGBM depth map

821 views Asked by At

Calibrated 2 same cameras with Opencv StereoCalib. I've got 0.32109 RMS error and 0.386568 average reprogection error results of calibrating

I think this is not big calibration error. But am getting this depth map with opencv SGBM algorithm with black left borders

 int sgbmWinSize = 9;
    int cn = img1.channels();
    sgbm->setPreFilterCap(63);
    sgbm->setBlockSize(sgbmWinSize);
    sgbm->setP1(8 * cn*sgbmWinSize*sgbmWinSize);
    sgbm->setP2(32 * cn*sgbmWinSize*sgbmWinSize);
    sgbm->setMinDisparity(0);
    sgbm->setNumDisparities(numberOfDisparities);
    sgbm->setUniquenessRatio(10);
    sgbm->setSpeckleWindowSize(100);
    sgbm->setSpeckleRange(32);
    sgbm->setDisp12MaxDiff(1);
    sgbm->setMode(alg > 1 ? StereoSGBM::MODE_HH : StereoSGBM::MODE_SGBM);

what's the problem?

1

There are 1 answers

0
Аскер Чик On

Non-occluded area mask In addition to disparity maps, for stereo match- ing method evaluation it is interesting to have a non- occluded area mask. This mask represents in white color the pixels on the scene that are visible from both cameras and in black color the pixels that are visible from only one camera

problem "solved" with

for(int y=0;y<height;y++){
   for(int x=0;x<width;x++){
       if(imageData[y*width+x]==0){
          imageData[y*width+x]=x>width/2?imageData[y*width+x+1]:imageData[y*width+x-1];}}}