7 static const std::vector<std::string>
labelMap = {
"background",
"aeroplane",
"bicycle",
"bird",
"boat",
"bottle",
"bus",
8 "car",
"cat",
"chair",
"cow",
"diningtable",
"dog",
"horse",
9 "motorbike",
"person",
"pottedplant",
"sheep",
"sofa",
"train",
"tvmonitor"};
11 int main(
int argc,
char** argv) {
15 std::string nnPath(BLOB_PATH);
19 nnPath = std::string(argv[1]);
23 printf(
"Using blob at path: %s\n", nnPath.c_str());
40 videoOut->setStreamName(
"h265");
52 nn->setConfidenceThreshold(0.5);
53 nn->setBlobPath(nnPath);
54 nn->setNumInferenceThreads(2);
59 manip->initialConfig.setResize(300, 300);
62 camRgb->video.link(videoEncoder->input);
63 videoEncoder->bitstream.link(videoOut->input);
64 monoRight->out.link(manip->inputImage);
65 manip->out.link(nn->
input);
66 monoRight->out.link(xoutRight->
input);
67 manip->out.link(manipOut->
input);
82 std::vector<dai::ImgDetection> detections;
84 auto color = cv::Scalar(255, 0, 0);
86 auto videoFile = std::ofstream(
"video.h265", std::ios::binary);
87 cv::namedWindow(
"right", cv::WINDOW_NORMAL);
88 cv::namedWindow(
"manip", cv::WINDOW_NORMAL);
96 videoFile.write((
char*)out1->
getData().data(), out1->
getData().size());
107 detections = inDet->detections;
111 for(
auto& detection : detections) {
117 uint32_t labelIndex = detection.label;
118 std::string labelStr =
to_string(labelIndex);
122 cv::putText(frame, labelStr, cv::Point(x1 + 10, y1 + 20), cv::FONT_HERSHEY_TRIPLEX, 0.5, color);
123 std::stringstream confStr;
124 confStr << std::fixed << std::setprecision(2) << detection.confidence * 100;
125 cv::putText(frame, confStr.str(), cv::Point(x1 + 10, y1 + 40), cv::FONT_HERSHEY_TRIPLEX, 0.5, color);
126 cv::rectangle(frame, cv::Rect(cv::Point(x1, y1), cv::Point(x2, y2)), color, cv::FONT_HERSHEY_SIMPLEX);
129 cv::imshow(
"right", frame);
132 if(!frameManip.empty()) {
133 for(
auto& detection : detections) {
134 int x1 = detection.xmin * frameManip.cols;
135 int y1 = detection.ymin * frameManip.rows;
136 int x2 = detection.xmax * frameManip.cols;
137 int y2 = detection.ymax * frameManip.rows;
139 uint32_t labelIndex = detection.label;
140 std::string labelStr =
to_string(labelIndex);
144 cv::putText(frameManip, labelStr, cv::Point(x1 + 10, y1 + 20), cv::FONT_HERSHEY_TRIPLEX, 0.5, color);
145 std::stringstream confStr;
146 confStr << std::fixed << std::setprecision(2) << detection.confidence * 100;
147 cv::putText(frameManip, confStr.str(), cv::Point(x1 + 10, y1 + 40), cv::FONT_HERSHEY_TRIPLEX, 0.5, color);
148 cv::rectangle(frameManip, cv::Rect(cv::Point(x1, y1), cv::Point(x2, y2)), color, cv::FONT_HERSHEY_SIMPLEX);
151 cv::imshow(
"manip", frameManip);
154 int key = cv::waitKey(1);
155 if(key ==
'q' || key ==
'Q') {
159 cout <<
"To view the encoded data, convert the stream file (.h265) into a video file (.mp4), using a command below:" << endl;
160 cout <<
"ffmpeg -framerate 30 -i video.h265 -c copy video.mp4" << endl;