Depth calculation of stereo images

asked 2015-12-16 21:37:56 -0600

updated 2015-12-17 02:33:32 -0600

LorenaGdL gravatar image

I want to execute program of depth calculation of stereo images.I need to know which version of openCV and Microsoft visual studio supports "Mat" function because all the programs available are mostly written using "Mat",please help soon.

cv::Mat depthImage; 
depthImage = cv::imread("coffee_mug_1_1_1_depthcrop.png", CV_LOAD_IMAGE_ANYDEPTH | CV_LOAD_IMAGE_ANYCOLOR ); // Read the file 
depthImage.convertTo(depthImage, CV_32F); // convert the image data to float type   
namedWindow("window");
float max = 0;
for(int i = 0; i < depthImage.rows; i++){
    for(int j = 0; j < depthImage.cols; j++){
        if(depthImage.at<float>(i,j) > max){
            max = depthImage.at<float>(i,j);
        }
    }   
}
cout << max << endl;


float divisor = max / 255.0;
cout << divisor << endl;
for(int i = 0; i < depthImage.rows; i++){
    for(int j = 0; j < depthImage.cols; j++){
        cout << depthImage.at<float>(i,j) << ", ";
        max = depthImage.at<float>(i,j) /= divisor;
        cout << depthImage.at<float>(i,j) << endl;
    }   
}


imshow("window", depthImage);
waitKey(0);
edit retag flag offensive close merge delete

Comments

Can you explain your problem?

LBerger gravatar imageLBerger ( 2015-12-17 01:20:55 -0600 )edit
2

btw, please never call anything max , since there are already various functions / macros with that name around

berak gravatar imageberak ( 2015-12-17 01:55:29 -0600 )edit

it seems to be impossible to change the title ?

berak gravatar imageberak ( 2015-12-17 01:58:36 -0600 )edit
2

Mat is not a function but a class. In fact, it is the class, the basic structure to deal with images in OpenCV (from version 2 on). So yep, if you find an OpenCV program that doesn't use Mat in it, throw it away and don't even bother to read it.

LorenaGdL gravatar imageLorenaGdL ( 2015-12-17 02:26:35 -0600 )edit
1

@berak changed. Although not sure if that is the real problem...

LorenaGdL gravatar imageLorenaGdL ( 2015-12-17 02:34:26 -0600 )edit