6 #include "unordered_map"
7 #include "unordered_set"
9 static void drawFeatures(cv::Mat& frame, std::vector<dai::TrackedFeature>& features) {
10 static const auto pointColor = cv::Scalar(0, 0, 255);
11 static const int circleRadius = 2;
12 for(
auto& feature : features) {
13 cv::circle(frame, cv::Point(feature.position.x, feature.position.y), circleRadius,
pointColor, -1, cv::LINE_AA, 0);
35 xoutPassthroughFrameLeft->setStreamName(
"passthroughFrameLeft");
36 xoutTrackedFeaturesLeft->
setStreamName(
"trackedFeaturesLeft");
37 xoutPassthroughFrameRight->
setStreamName(
"passthroughFrameRight");
38 xoutTrackedFeaturesRight->
setStreamName(
"trackedFeaturesRight");
39 xinTrackedFeaturesConfig->
setStreamName(
"trackedFeaturesConfig");
43 monoLeft->setCamera(
"left");
48 featureTrackerLeft->initialConfig.setMotionEstimator(
false);
52 monoLeft->out.link(featureTrackerLeft->inputImage);
53 featureTrackerLeft->passthroughInputImage.link(xoutPassthroughFrameLeft->input);
54 featureTrackerLeft->outputFeatures.link(xoutTrackedFeaturesLeft->
input);
55 xinTrackedFeaturesConfig->out.link(featureTrackerLeft->inputConfig);
60 xinTrackedFeaturesConfig->out.link(featureTrackerRight->
inputConfig);
64 printf(
"Press 's' to switch between Harris and Shi-Thomasi corner detector! \n");
70 auto passthroughImageLeftQueue = device.
getOutputQueue(
"passthroughFrameLeft", 8,
false);
71 auto outputFeaturesLeftQueue = device.
getOutputQueue(
"trackedFeaturesLeft", 8,
false);
72 auto passthroughImageRightQueue = device.
getOutputQueue(
"passthroughFrameRight", 8,
false);
73 auto outputFeaturesRightQueue = device.
getOutputQueue(
"trackedFeaturesRight", 8,
false);
75 auto inputFeatureTrackerConfigQueue = device.
getInputQueue(
"trackedFeaturesConfig");
77 const auto leftWindowName =
"left";
78 const auto rightWindowName =
"right";
81 auto inPassthroughFrameLeft = passthroughImageLeftQueue->get<
dai::ImgFrame>();
82 cv::Mat passthroughFrameLeft = inPassthroughFrameLeft->
getFrame();
84 cv::cvtColor(passthroughFrameLeft, leftFrame, cv::COLOR_GRAY2BGR);
86 auto inPassthroughFrameRight = passthroughImageRightQueue->get<
dai::ImgFrame>();
87 cv::Mat passthroughFrameRight = inPassthroughFrameRight->
getFrame();
89 cv::cvtColor(passthroughFrameRight, rightFrame, cv::COLOR_GRAY2BGR);
91 auto trackedFeaturesLeft = outputFeaturesLeftQueue->get<
dai::TrackedFeatures>()->trackedFeatures;
94 auto trackedFeaturesRight = outputFeaturesRightQueue->get<
dai::TrackedFeatures>()->trackedFeatures;
98 cv::imshow(leftWindowName, leftFrame);
99 cv::imshow(rightWindowName, rightFrame);
101 int key = cv::waitKey(1);
104 }
else if(key ==
's') {
107 printf(
"Switching to Shi-Thomasi \n");
110 printf(
"Switching to Harris \n");
113 cfg.set(featureTrackerConfig);
114 inputFeatureTrackerConfigQueue->send(cfg);