mirror of
https://github.com/modelec/detection_pot.git
synced 2026-01-19 00:57:28 +01:00
properly quit the program
This commit is contained in:
@@ -50,6 +50,7 @@ ArucoDetector::~ArucoDetector()
|
||||
{
|
||||
cam->stopVideo();
|
||||
cv::destroyAllWindows();
|
||||
delete cam;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -6,21 +6,14 @@
|
||||
#include <atomic>
|
||||
#include <optional>
|
||||
|
||||
std::atomic<bool> 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<std::thread> 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;
|
||||
}
|
||||
Reference in New Issue
Block a user