diff --git a/aruco/ArucoDetector.cpp b/aruco/ArucoDetector.cpp index e02d5e0..eaf0fdc 100644 --- a/aruco/ArucoDetector.cpp +++ b/aruco/ArucoDetector.cpp @@ -88,7 +88,16 @@ std::pair>>> Ar cv::Mat frame; cv::Mat frameNotRotated; cv::Mat frameDistored; - cam->getVideoFrame(frameNotRotated, 1000); + + try { + cam->getVideoFrame(frameNotRotated, 1000); + } catch (cv::Exception& e) { + std::cerr << "Error: " << e.what() << std::endl; + std::pair>>> result; + result.first = -2; + return result; + } + cv::flip(frameNotRotated, frameDistored, -1); cv::undistort(frameDistored, frame, cameraMatrix, distCoeffs); diff --git a/arucoDetector.cpp b/arucoDetector.cpp index a25535f..d302324 100644 --- a/arucoDetector.cpp +++ b/arucoDetector.cpp @@ -61,7 +61,13 @@ int main(int argc, char *argv[]) usleep(500'000); while (true) { - auto r = detector.detectArucoTags({whiteFlower, purpleFlower, solarPanel}); + + try { + auto r = detector.detectArucoTags({whiteFlower, purpleFlower, solarPanel}); + } catch (const std::exception& ex) { + std::cerr << "Error: " << ex.what() << std::endl; + return -1; + } code = r.first;