OpenCV StereoSGBM in openframeworks


I am trying to get the StereoSGBM working in Linux Ubuntu. Has anyone been successful using openframeworks with the openCV StereoSGBM disparity map?

I am using 2 sony ps3eye cameras.
I calibrated the two cameras. I did the opencv stereoRectify also, as well as the opencv initUndistortRectifyMap.

I have an openCV separated project that works greatly but I am having problems trying to have the same result inside openframeworks, calling the StereoSGBM function.

I aways get a black image from the disparity method. When I normalize the dispMat I get a strange behaviour image with a vertical white bar in the middle.

I am using also ofxCv form kylemcdonald to make the convertions to Mat’s opencv from the OF videograbber.

Do you know what am I missing here?

Thank you a lot fro any help.


    drawMat(cameraLeft,20,20);      //left image from camera converted to Mat
    drawMat(cameraRight,400,20);  //right image from camera converted to Mat

    cv::StereoSGBM sbm;
    sbm.SADWindowSize =  3; 
    sbm.numberOfDisparities = 144;
    sbm.preFilterCap =63;
    sbm.minDisparity = -39;
    sbm.uniquenessRatio = 10;
    sbm.speckleWindowSize = 100;
    sbm.speckleRange = 32;
    sbm.disp12MaxDiff = 1;
    sbm.fullDP = true;
    sbm.P1 = 216;
    sbm.P2 = 864;
    sbm(leftMap, rightMap, dispMat);


normalize(dispMat, dispMatN, 0, 255, CV_MINMAX, CV_8U);