Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to use cv::StereoMatcher in c++

I struggling a bit understanding how i should apply StereoMatcher to create a simple disparity map?..

From the Api it seems simple but, but this simple piece of code doesn't result in bad_memory access error.

What is going wrong?

#include <iostream>
#include <opencv2/calib3d/calib3d.hpp>
#include <opencv2/opencv.hpp>
#include <opencv2/core.hpp>
#include <opencv2/features2d.hpp>
#include <opencv2/core/affine.hpp>

int main(int argc, const    char * argv[]) {
    // insert code here...
    std::cout << "Hello, World!\n";
    std::cout << CV_VERSION << std::endl;


    cv::Mat left = cv::imread("../left.png");
    cv::Mat right = cv::imread("../right.png");
    cv::Mat disparity_out;
    cv::StereoMatcher* map;
    map->compute(left, right, disparity_out);
    imshow("test",disparity_out);

    return 0;
}

How to use cv::StereoMatcher in c++

I struggling a bit understanding how i should apply StereoMatcher to create a simple disparity map?..

From the Api it seems simple but, but this simple piece of code doesn't does result in bad_memory access error.

What is going wrong?

#include <iostream>
#include <opencv2/calib3d/calib3d.hpp>
#include <opencv2/opencv.hpp>
#include <opencv2/core.hpp>
#include <opencv2/features2d.hpp>
#include <opencv2/core/affine.hpp>

int main(int argc, const    char * argv[]) {
    // insert code here...
    std::cout << "Hello, World!\n";
    std::cout << CV_VERSION << std::endl;


    cv::Mat left = cv::imread("../left.png");
    cv::Mat right = cv::imread("../right.png");
    cv::Mat disparity_out;
    cv::StereoMatcher* map;
    map->compute(left, right, disparity_out);
    imshow("test",disparity_out);

    return 0;
}