mirror of
https://github.com/modelec/detection_pot.git
synced 2026-01-18 16:47:33 +01:00
Press enter to stop the infinite while loop
This commit is contained in:
@@ -1,5 +1,18 @@
|
||||
#include "utils/ArucoDetector.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
#include <atomic>
|
||||
|
||||
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
|
||||
@@ -32,6 +45,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
// End argument parser
|
||||
|
||||
std::thread userInput(userInputThread);
|
||||
|
||||
const auto robotPose = Type::RobotPose{cv::Point3f(0, 0, 0), CV_PI/2};
|
||||
|
||||
ArucoDetector detector(robotPose, calibrationPath, BLUE, cameraId, headless);
|
||||
@@ -60,7 +75,15 @@ int main(int argc, char *argv[])
|
||||
ArucoDetector::solarPanelDetector(p.first, p.second.first, p.second.first, robotPose);
|
||||
}
|
||||
}
|
||||
|
||||
if (stopRequested)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Wait for the user input thread to finish
|
||||
userInput.join();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -3,9 +3,13 @@
|
||||
ArucoDetector::ArucoDetector(const Type::RobotPose& pose, const std::string& calibrationPath, const Team team, const int cameraId, const bool headless) : robotPose(pose), headless(headless), team(team)
|
||||
{
|
||||
// this->detector = cv::aruco::ArucoDetector(getPredefinedDictionary(cv::aruco::DICT_4X4_50), cv::aruco::DetectorParameters());
|
||||
this->dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_4X4_50);
|
||||
// this->dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_4X4_50);
|
||||
// this->parameters = cv::aruco::DetectorParameters();
|
||||
|
||||
// 4.6
|
||||
this->dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_4X4_50);
|
||||
|
||||
|
||||
this->transformationMatrix = (cv::Mat_<double>(4, 4) <<
|
||||
cos(pose.theta), 0, sin(pose.theta), pose.position.x,
|
||||
0, 1, 0, pose.position.y,
|
||||
|
||||
@@ -13,7 +13,11 @@ class ArucoDetector {
|
||||
|
||||
cv::VideoCapture cap;
|
||||
|
||||
// 4.6
|
||||
cv::Ptr<cv::aruco::Dictionary> dictionary;
|
||||
|
||||
// 4.8
|
||||
// cv::aruco::Dictionary dictionary;
|
||||
// cv::aruco::DetectorParameters parameters;
|
||||
// cv::aruco::ArucoDetector detector;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user