9 static const std::vector<std::string>
labelMap = {
"background",
"aeroplane",
"bicycle",
"bird",
"boat",
"bottle",
"bus",
10 "car",
"cat",
"chair",
"cow",
"diningtable",
"dog",
"horse",
11 "motorbike",
"person",
"pottedplant",
"sheep",
"sofa",
"train",
"tvmonitor"};
13 int main(
int argc,
char** argv) {
17 std::string nnPath(BLOB_PATH);
21 nnPath = std::string(argv[1]);
25 printf(
"Using blob at path: %s\n", nnPath.c_str());
37 manipOut->setStreamName(
"right");
41 monoRight->setCamera(
"right");
45 manip->initialConfig.setResize(300, 300);
49 nn->setConfidenceThreshold(0.5);
50 nn->setBlobPath(nnPath);
51 nn->setNumInferenceThreads(2);
52 nn->input.setBlocking(
false);
55 monoRight->
out.
link(manip->inputImage);
57 manip->
out.
link(manipOut->input);
68 std::vector<dai::ImgDetection> detections;
71 auto displayFrame = [](std::string name, cv::Mat frame, std::vector<dai::ImgDetection>& detections) {
72 auto color = cv::Scalar(255, 0, 0);
74 for(
auto& detection : detections) {
75 int x1 = detection.xmin * frame.cols;
76 int y1 = detection.ymin * frame.rows;
77 int x2 = detection.xmax * frame.cols;
78 int y2 = detection.ymax * frame.rows;
80 uint32_t labelIndex = detection.label;
81 std::string labelStr =
to_string(labelIndex);
85 cv::putText(frame, labelStr, cv::Point(x1 + 10, y1 + 20), cv::FONT_HERSHEY_TRIPLEX, 0.5, color);
86 std::stringstream confStr;
87 confStr << std::fixed << std::setprecision(2) << detection.confidence * 100;
88 cv::putText(frame, confStr.str(), cv::Point(x1 + 10, y1 + 40), cv::FONT_HERSHEY_TRIPLEX, 0.5, color);
89 cv::rectangle(frame, cv::Rect(cv::Point(x1, y1), cv::Point(x2, y2)), color, cv::FONT_HERSHEY_SIMPLEX);
92 cv::imshow(name, frame);
101 frame = inRight->getCvFrame();
105 detections = inDet->detections;
109 displayFrame(
"right", frame, detections);
112 int key = cv::waitKey(1);
113 if(key ==
'q' || key ==
'Q')
return 0;