mirror of
https://github.com/opencv/opencv_contrib.git
synced 2025-10-21 23:01:45 +08:00

Implementation of Quasi Dense Stereo algorithm. (#1941) * initial commit. * Remove license header. * Fix python wrap flags * Change std::string to cv::String, in function declarations, to resolve compilation issues. * Add python wrapper extending header * Fix python wrapper conflicts * Fix implicit type conversions * Change C API types and enums to C++. * Remove redundant included headers and move wanted headers to src/precomp.hpp * Remove saturate header * Remove unnecessary python wrapping flags * Removed defaults parameter header * Split declaration and implementation of the class using Pimpl. * Fix to comply with new public API. * Remove unnecessary modules * Fix maybe-uninitialized warnings on linux * Migration to stereo module * Remove CV_PROP_RW flag. * Remove CV_EXPORTS flags from class members. * Fix: Removed misplaced flag * Remove empty lines. * Move queue to private headers. * Fix default arguments of public methods. * Add authors information and switch to the compact version of license header. * Reorganize and fix markdown files. Create a table of content and move tutorials in new directories. Modify samples and tutorials to use snippet and include Doxygen commands. * Change argument name dMatch->denseMatch, to avoid confusion with cv::DMatch build-in type. * Remove duplicate snippet. * Fix: change vector resize to reserve. * Fix: replace extensive license header with the compact version.
65 lines
1.2 KiB
C++
65 lines
1.2 KiB
C++
#include <opencv2/core.hpp>
|
|
#include <opencv2/highgui.hpp>
|
|
#include <fstream>
|
|
#include <opencv2/stereo.hpp>
|
|
|
|
|
|
|
|
|
|
using namespace cv;
|
|
using namespace std;
|
|
|
|
|
|
int main()
|
|
{
|
|
//! [load]
|
|
cv::Mat rightImg, leftImg;
|
|
leftImg = imread("./imgLeft.png", IMREAD_COLOR);
|
|
rightImg = imread("./imgRight.png", IMREAD_COLOR);
|
|
//! [load]
|
|
|
|
|
|
//! [create]
|
|
cv::Size frameSize = leftImg.size();
|
|
Ptr<stereo::QuasiDenseStereo> stereo = stereo::QuasiDenseStereo::create(frameSize);
|
|
//! [create]
|
|
|
|
|
|
//! [process]
|
|
stereo->process(leftImg, rightImg);
|
|
//! [process]
|
|
|
|
|
|
//! [disp]
|
|
uint8_t displvl = 80;
|
|
cv::Mat disp;
|
|
disp = stereo->getDisparity(displvl);
|
|
cv::namedWindow("disparity map");
|
|
cv::imshow("disparity map", disp);
|
|
//! [disp]
|
|
|
|
|
|
cv::namedWindow("right channel");
|
|
cv::namedWindow("left channel");
|
|
cv::imshow("left channel", leftImg);
|
|
cv::imshow("right channel", rightImg);
|
|
|
|
|
|
//! [export]
|
|
vector<stereo::Match> matches;
|
|
stereo->getDenseMatches(matches);
|
|
std::ofstream dense("./dense.txt", std::ios::out);
|
|
for (uint i=0; i< matches.size(); i++)
|
|
{
|
|
dense << matches[i].p0 << matches[i].p1 << endl;
|
|
}
|
|
dense.close();
|
|
//! [export]
|
|
|
|
|
|
|
|
cv::waitKey(0);
|
|
|
|
return 0;
|
|
}
|