diff --git a/aruco/ArucoDetector.cpp b/aruco/ArucoDetector.cpp index afea84b..32f15b7 100644 --- a/aruco/ArucoDetector.cpp +++ b/aruco/ArucoDetector.cpp @@ -50,6 +50,7 @@ ArucoDetector::~ArucoDetector() { cam->stopVideo(); cv::destroyAllWindows(); + delete cam; } diff --git a/arucoDetector.cpp b/arucoDetector.cpp index 61b97c5..8a89c85 100644 --- a/arucoDetector.cpp +++ b/arucoDetector.cpp @@ -6,21 +6,14 @@ #include #include -std::atomic stopRequested(false); - -void userInputThread() { - // Wait for the user to press Enter - std::cout << "Press Enter to stop the program..." << std::endl; - std::cin.ignore(); - stopRequested = true; -} - int main(int argc, char *argv[]) { // Settup argument parser bool headless = false; + bool stopRequested = false; + for (int i = 0; i < argc; i++) { if (std::string(argv[i]) == "--help") @@ -46,14 +39,6 @@ int main(int argc, char *argv[]) const std::string calibrationPath = argv[1]; - // End argument parser - std::optional userInput; - - if (headless) - { - userInput = std::thread(userInputThread); - } - ArucoDetector detector(calibrationPath, BLUE, headless); auto whiteFlower = ArucoTag(36, "White_flower", 19.6, FLOWER); @@ -109,17 +94,11 @@ int main(int argc, char *argv[]) } } - if (stopRequested) + if (client.shouldStop() || stopRequested) { break; } } - // Wait for the user input thread to finish - if (userInput.has_value()) - { - userInput.value().join(); - } - return 0; } \ No newline at end of file