28 xoutDepth->setStreamName(
"depth");
34 monoLeft->setCamera(
"left");
42 stereo->setLeftRightCheck(
lrcheck);
60 monoLeft->out.link(stereo->left);
61 monoRight->
out.
link(stereo->right);
63 spatialDataCalculator->passthroughDepth.link(xoutDepth->input);
64 stereo->depth.link(spatialDataCalculator->inputDepth);
66 spatialDataCalculator->out.link(xoutSpatialData->
input);
67 xinSpatialCalcConfig->out.link(spatialDataCalculator->
inputConfig);
74 auto spatialCalcQueue = device.
getOutputQueue(
"spatialData", 8,
false);
75 auto spatialCalcConfigInQueue = device.
getInputQueue(
"spatialCalcConfig");
77 auto color = cv::Scalar(255, 255, 255);
79 std::cout <<
"Use WASD keys to move ROI!" << std::endl;
84 cv::Mat depthFrame = inDepth->
getFrame();
85 cv::Mat depthFrameColor;
87 cv::normalize(depthFrame, depthFrameColor, 255, 0, cv::NORM_INF, CV_8UC1);
88 cv::equalizeHist(depthFrameColor, depthFrameColor);
89 cv::applyColorMap(depthFrameColor, depthFrameColor, cv::COLORMAP_HOT);
92 for(
auto depthData : spatialData) {
93 auto roi = depthData.config.roi;
94 roi = roi.denormalize(depthFrameColor.cols, depthFrameColor.rows);
95 auto xmin = (int)roi.topLeft().x;
96 auto ymin = (int)roi.topLeft().y;
97 auto xmax = (int)roi.bottomRight().x;
98 auto ymax = (int)roi.bottomRight().y;
100 auto depthMin = depthData.depthMin;
101 auto depthMax = depthData.depthMax;
103 cv::rectangle(depthFrameColor, cv::Rect(cv::Point(xmin, ymin), cv::Point(xmax, ymax)), color, cv::FONT_HERSHEY_SIMPLEX);
104 std::stringstream depthX;
105 depthX <<
"X: " << (int)depthData.spatialCoordinates.x <<
" mm";
106 cv::putText(depthFrameColor, depthX.str(), cv::Point(xmin + 10, ymin + 20), cv::FONT_HERSHEY_TRIPLEX, 0.5, color);
107 std::stringstream depthY;
108 depthY <<
"Y: " << (int)depthData.spatialCoordinates.y <<
" mm";
109 cv::putText(depthFrameColor, depthY.str(), cv::Point(xmin + 10, ymin + 35), cv::FONT_HERSHEY_TRIPLEX, 0.5, color);
110 std::stringstream depthZ;
111 depthZ <<
"Z: " << (int)depthData.spatialCoordinates.z <<
" mm";
112 cv::putText(depthFrameColor, depthZ.str(), cv::Point(xmin + 10, ymin + 50), cv::FONT_HERSHEY_TRIPLEX, 0.5, color);
115 cv::imshow(
"depth", depthFrameColor);
117 int key = cv::waitKey(1);
152 std::cout <<
"Switching calculation algorithm to MEAN!" << std::endl;
157 std::cout <<
"Switching calculation algorithm to MIN!" << std::endl;
162 std::cout <<
"Switching calculation algorithm to MAX!" << std::endl;
167 std::cout <<
"Switching calculation algorithm to MODE!" << std::endl;
172 std::cout <<
"Switching calculation algorithm to MEDIAN!" << std::endl;
183 spatialCalcConfigInQueue->send(cfg);