11// std
2+ #include < chrono>
23#include < csignal>
34#include < iostream>
45#include < unordered_map>
5- #include < chrono>
66
77// Includes common necessary includes for development using depthai library
88#include " depthai/depthai.hpp"
99
1010// #define DEPTHAI_STABILITY_TEST_SCRIPT
1111
1212#ifdef DEPTHAI_STABILITY_TEST_DEBUG
13- #include < opencv2/opencv.hpp>
13+ #include < opencv2/opencv.hpp>
1414#endif
1515
1616static const std::vector<std::string> labelMap = {
@@ -42,7 +42,7 @@ int main(int argc, char** argv) {
4242 // nnPath = std::string(argv[1]);
4343 // }
4444
45- seconds TEST_TIMEOUT{24 * 60 * 60 };
45+ seconds TEST_TIMEOUT{24 * 60 * 60 };
4646 if (argc > 1 ) {
4747 TEST_TIMEOUT = seconds{stoi (argv[1 ])};
4848 }
@@ -62,13 +62,13 @@ int main(int argc, char** argv) {
6262 auto edgeDetectorLeft = pipeline.create <dai::node::EdgeDetector>();
6363 auto edgeDetectorRight = pipeline.create <dai::node::EdgeDetector>();
6464 auto edgeDetectorRgb = pipeline.create <dai::node::EdgeDetector>();
65- #ifdef DEPTHAI_STABILITY_TEST_SCRIPT
65+ #ifdef DEPTHAI_STABILITY_TEST_SCRIPT
6666 auto script1 = pipeline.create <dai::node::Script>();
6767 auto script2 = pipeline.create <dai::node::Script>();
6868 auto script3 = pipeline.create <dai::node::Script>();
6969 auto script4 = pipeline.create <dai::node::Script>();
7070 auto scriptBurn = pipeline.create <dai::node::Script>();
71- #endif
71+ #endif
7272
7373 // TODO(themarpe) - enable specific parts separatelly, to control load
7474 // auto featureTrackerLeft = pipeline.create<dai::node::FeatureTracker>();
@@ -84,10 +84,10 @@ int main(int argc, char** argv) {
8484 auto xoutEdgeLeft = pipeline.create <dai::node::XLinkOut>();
8585 auto xoutEdgeRight = pipeline.create <dai::node::XLinkOut>();
8686 auto xoutEdgeRgb = pipeline.create <dai::node::XLinkOut>();
87- #ifdef DEPTHAI_STABILITY_TEST_SCRIPT
87+ #ifdef DEPTHAI_STABILITY_TEST_SCRIPT
8888 auto scriptOut = pipeline.create <dai::node::XLinkOut>();
8989 auto scriptOut2 = pipeline.create <dai::node::XLinkOut>();
90- #endif
90+ #endif
9191 // auto xoutTrackedFeaturesLeft = pipeline.create<dai::node::XLinkOut>();
9292 // auto xoutTrackedFeaturesRight = pipeline.create<dai::node::XLinkOut>();
9393
@@ -105,14 +105,13 @@ int main(int argc, char** argv) {
105105 xoutEdgeLeft->setStreamName (edgeLeftStr);
106106 xoutEdgeRight->setStreamName (edgeRightStr);
107107 xoutEdgeRgb->setStreamName (edgeRgbStr);
108- #ifdef DEPTHAI_STABILITY_TEST_SCRIPT
108+ #ifdef DEPTHAI_STABILITY_TEST_SCRIPT
109109 scriptOut->setStreamName (" script" );
110110 scriptOut2->setStreamName (" script2" );
111- #endif
111+ #endif
112112 // xoutTrackedFeaturesLeft->setStreamName("trackedFeaturesLeft");
113113 // xoutTrackedFeaturesRight->setStreamName("trackedFeaturesRight");
114114
115-
116115 // Properties
117116 camRgb->setBoardSocket (dai::CameraBoardSocket::RGB);
118117 camRgb->setResolution (dai::ColorCameraProperties::SensorResolution::THE_4_K);
@@ -152,7 +151,7 @@ int main(int argc, char** argv) {
152151
153152 edgeDetectorRgb->setMaxOutputFrameSize (8294400 );
154153
155- #ifdef DEPTHAI_STABILITY_TEST_SCRIPT
154+ #ifdef DEPTHAI_STABILITY_TEST_SCRIPT
156155 std::string source1 = R"(
157156 import time
158157 import json
@@ -219,7 +218,7 @@ int main(int argc, char** argv) {
219218 time.sleep(0.001)
220219 )" );
221220 scriptBurn->setProcessor (dai::ProcessorType::LEON_MSS);
222- #endif
221+ #endif
223222
224223 // // By default the least mount of resources are allocated
225224 // // increasing it improves performance when optical flow is enabled
@@ -254,12 +253,12 @@ int main(int argc, char** argv) {
254253 edgeDetectorLeft->outputImage .link (xoutEdgeLeft->input );
255254 edgeDetectorRight->outputImage .link (xoutEdgeRight->input );
256255
257- #ifdef DEPTHAI_STABILITY_TEST_SCRIPT
256+ #ifdef DEPTHAI_STABILITY_TEST_SCRIPT
258257 script1->outputs [" out" ].link (script2->inputs [" in" ]);
259258 script2->outputs [" out" ].link (scriptOut->input );
260259 script3->outputs [" out" ].link (script4->inputs [" in" ]);
261260 script4->outputs [" out" ].link (scriptOut2->input );
262- #endif
261+ #endif
263262
264263 // monoLeft->out.link(featureTrackerLeft->inputImage);
265264 // featureTrackerLeft->outputFeatures.link(xoutTrackedFeaturesLeft->input);
@@ -284,10 +283,10 @@ int main(int argc, char** argv) {
284283 auto edgeRightQueue = device.getOutputQueue (edgeRightStr, 8 , false );
285284 auto edgeRgbQueue = device.getOutputQueue (edgeRgbStr, 8 , false );
286285
287- #ifdef DEPTHAI_STABILITY_TEST_SCRIPT
286+ #ifdef DEPTHAI_STABILITY_TEST_SCRIPT
288287 auto scriptQueue = device.getOutputQueue (" script" , 8 , false );
289288 auto script2Queue = device.getOutputQueue (" script2" , 8 , false );
290- #endif
289+ #endif
291290
292291 // auto outputFeaturesLeftQueue = device.getOutputQueue("trackedFeaturesLeft", 8, false);
293292 // auto outputFeaturesRightQueue = device.getOutputQueue("trackedFeaturesRight", 8, false);
@@ -299,11 +298,10 @@ int main(int argc, char** argv) {
299298 auto color = cv::Scalar (255 , 255 , 255 );
300299#endif
301300
302-
303301 mutex countersMtx;
304302 unordered_map<std::string, int > counters;
305303
306- thread countingThread ([&countersMtx, &counters, &device, TEST_TIMEOUT](){
304+ thread countingThread ([&countersMtx, &counters, &device, TEST_TIMEOUT]() {
307305 // Initial delay
308306 this_thread::sleep_for (5s);
309307
@@ -314,9 +312,10 @@ int main(int argc, char** argv) {
314312 unique_lock<mutex> l (countersMtx);
315313
316314 bool failed = counters.size () == 0 ;
317- cout << " [" << duration_cast<seconds>(steady_clock::now () - timeoutStopwatch).count () << " s] " << " FPS: " ;
318- for (const auto & kv : counters){
319- if (kv.second == 0 ){
315+ cout << " [" << duration_cast<seconds>(steady_clock::now () - timeoutStopwatch).count () << " s] "
316+ << " FPS: " ;
317+ for (const auto & kv : counters) {
318+ if (kv.second == 0 ) {
320319 failed = true ;
321320 }
322321
@@ -333,7 +332,7 @@ int main(int argc, char** argv) {
333332 fiveFpsCounter = steady_clock::now ();
334333 }
335334
336- if (steady_clock::now () - timeoutStopwatch > TEST_TIMEOUT){
335+ if (steady_clock::now () - timeoutStopwatch > TEST_TIMEOUT) {
337336 alive = false ;
338337 break ;
339338 }
@@ -357,10 +356,10 @@ int main(int argc, char** argv) {
357356 auto edgeLefts = edgeLeftQueue->tryGetAll <dai::ImgFrame>();
358357 auto edgeRights = edgeRightQueue->tryGetAll <dai::ImgFrame>();
359358
360- #ifdef DEPTHAI_STABILITY_TEST_SCRIPT
359+ #ifdef DEPTHAI_STABILITY_TEST_SCRIPT
361360 auto script = scriptQueue->tryGetAll <dai::Buffer>();
362361 auto script2 = script2Queue->tryGetAll <dai::Buffer>();
363- #endif
362+ #endif
364363
365364 // auto edgeRgbs = edgeRgbQueue->getAll<dai::ImgFrame>();
366365
@@ -378,15 +377,15 @@ int main(int argc, char** argv) {
378377 counters[" edgeLefts" ] += edgeLefts.size ();
379378 counters[" edgeRights" ] += edgeRights.size ();
380379
381- #ifdef DEPTHAI_STABILITY_TEST_SCRIPT
380+ #ifdef DEPTHAI_STABILITY_TEST_SCRIPT
382381 counters[" script" ] += script.size ();
383382 counters[" script2" ] += script2.size ();
384- #endif
383+ #endif
385384 // counters["trackedLefts"] += trackedLefts.size();
386385 // counters["trackedRights"] += trackedRigths.size();
387386 }
388387
389- #ifdef DEPTHAI_STABILITY_TEST_DEBUG
388+ #ifdef DEPTHAI_STABILITY_TEST_DEBUG
390389
391390 // / DISPLAY & OPENCV Section
392391 for (const auto & edgeLeft : edgeLefts) {
@@ -402,7 +401,6 @@ int main(int argc, char** argv) {
402401 // cv::imshow(edgeRgbStr, edgeRgbFrame);
403402 // }
404403
405-
406404 cv::Mat frame = imgFrame->getCvFrame ();
407405 cv::Mat depthFrame = depth->getFrame (); // depthFrame values are in millimeters
408406
@@ -475,27 +473,26 @@ int main(int argc, char** argv) {
475473 cv::imshow (" depth" , depthFrameColor);
476474 cv::imshow (" rgb" , frame);
477475
478- #ifdef DEPTHAI_STABILITY_TEST_SCRIPT
476+ #ifdef DEPTHAI_STABILITY_TEST_SCRIPT
479477 for (auto json : script) {
480478 if (json != nullptr ) {
481- std::cout << " Script: " << std::string ((const char *) json->getData ().data (), json->getData ().size ()) << std::endl;
479+ std::cout << " Script: " << std::string ((const char *)json->getData ().data (), json->getData ().size ()) << std::endl;
482480 }
483481 }
484482 for (auto json : script2) {
485483 if (json != nullptr ) {
486- std::cout << " Script2: " << std::string ((const char *) json->getData ().data (), json->getData ().size ()) << std::endl;
484+ std::cout << " Script2: " << std::string ((const char *)json->getData ().data (), json->getData ().size ()) << std::endl;
487485 }
488486 }
489- #endif
487+ #endif
490488
491489 int key = cv::waitKey (1 );
492490 if (key == ' q' || key == ' Q' ) {
493491 alive = false ;
494492 break ;
495493 }
496494
497- #endif
498-
495+ #endif
499496 }
500497
501498 // Clean up the counting thread
0 commit comments