3 #include <opencv2/opencv.hpp>
13 auto config = std::make_shared<dai::ToFConfig>();
14 config->set(std::move(configRaw));
19 cv::Mat invalidMask = (frameDepth == 0);
20 cv::Mat depthFrameColor;
22 double minDepth = 0.0;
23 double maxDepth = 0.0;
24 cv::minMaxIdx(frameDepth, &minDepth, &maxDepth,
nullptr,
nullptr, ~invalidMask);
25 if(minDepth == maxDepth) {
26 depthFrameColor = cv::Mat::zeros(frameDepth.size(), CV_8UC3);
27 return depthFrameColor;
30 frameDepth.convertTo(logDepth, CV_32F);
32 logDepth.setTo(
log(minDepth), invalidMask);
33 cv::normalize(logDepth, logDepth, 0, 255, cv::NORM_MINMAX, CV_8UC1);
34 cv::applyColorMap(logDepth, depthFrameColor, cv::COLORMAP_JET);
35 depthFrameColor.setTo(cv::Scalar(0, 0, 0), invalidMask);
36 }
catch(
const std::exception& e) {
37 depthFrameColor = cv::Mat::zeros(frameDepth.size(), CV_8UC3);
39 return depthFrameColor;
51 tofConfig.enableOpticalCorrection =
true;
52 tofConfig.enablePhaseShuffleTemporalFilter =
true;
53 tofConfig.phaseUnwrappingLevel = 4;
54 tofConfig.phaseUnwrapErrorThreshold = 300;
56 tofConfig.enableTemperatureCorrection =
false;
60 xinTofConfig->out.link(tof->inputConfig);
62 tof->initialConfig.set(tofConfig);
67 camTof->raw.link(tof->input);
71 tof->depth.link(xout->input);
84 auto start = std::chrono::high_resolution_clock::now();
85 int key = cv::waitKey(1);
87 tofConfig.enableFPPNCorrection = !tofConfig.enableFPPNCorrection;
89 }
else if (key ==
'o') {
90 tofConfig.enableOpticalCorrection = !tofConfig.enableOpticalCorrection;
92 }
else if (key ==
'w') {
93 tofConfig.enableWiggleCorrection = !tofConfig.enableWiggleCorrection;
95 }
else if (key ==
't') {
96 tofConfig.enableTemperatureCorrection = !tofConfig.enableTemperatureCorrection;
98 }
else if (key ==
'q') {
100 }
else if (key ==
'0') {
101 tofConfig.enablePhaseUnwrapping =
false;
102 tofConfig.phaseUnwrappingLevel = 0;
104 }
else if (key ==
'1') {
105 tofConfig.enablePhaseUnwrapping =
true;
106 tofConfig.phaseUnwrappingLevel = 1;
108 }
else if (key ==
'2') {
109 tofConfig.enablePhaseUnwrapping =
true;
110 tofConfig.phaseUnwrappingLevel = 2;
112 }
else if (key ==
'3') {
113 tofConfig.enablePhaseUnwrapping =
true;
114 tofConfig.phaseUnwrappingLevel = 3;
116 }
else if (key ==
'4') {
117 tofConfig.enablePhaseUnwrapping =
true;
118 tofConfig.phaseUnwrappingLevel = 4;
120 }
else if (key ==
'5') {
121 tofConfig.enablePhaseUnwrapping =
true;
122 tofConfig.phaseUnwrappingLevel = 5;
124 }
else if (key ==
'm') {
126 auto currentMedian = tofConfig.median;
127 auto nextMedian = medianSettings[(std::find(medianSettings.begin(), medianSettings.end(), currentMedian) - medianSettings.begin() + 1) % medianSettings.size()];
128 tofConfig.median = nextMedian;
135 cv::imshow(
"Colorized depth", depthColorized);