#include #include "depthai/depthai.hpp" int main() { dai::Pipeline pipeline; auto monoLeft = pipeline.create()->build(dai::CameraBoardSocket::CAM_B); auto monoRight = pipeline.create()->build(dai::CameraBoardSocket::CAM_C); auto stereo = pipeline.create(); auto monoLeftOut = monoLeft->requestFullResolutionOutput(); auto monoRightOut = monoRight->requestFullResolutionOutput(); monoLeftOut->link(stereo->left); monoRightOut->link(stereo->right); stereo->setRectification(true); stereo->setExtendedDisparity(true); stereo->setLeftRightCheck(true); auto disparityQueue = stereo->disparity.createOutputQueue(); double maxDisparity = 1.0; pipeline.start(); while(true) { auto disparity = disparityQueue->get(); cv::Mat npDisparity = disparity->getFrame(); double minVal, curMax; cv::minMaxLoc(npDisparity, &minVal, &curMax); maxDisparity = std::max(maxDisparity, curMax); // Normalize the disparity image to an 8-bit scale. cv::Mat normalized; npDisparity.convertTo(normalized, CV_8UC1, 255.0 / maxDisparity); cv::Mat colorizedDisparity; cv::applyColorMap(normalized, colorizedDisparity, cv::COLORMAP_JET); // Set pixels with zero disparity to black. colorizedDisparity.setTo(cv::Scalar(0, 0, 0), normalized == 0); cv::imshow("disparity", colorizedDisparity); int key = cv::waitKey(1); if(key == 'q') { break; } } pipeline.stop(); return 0; }