mirror of
https://github.com/modelec/detection_pot.git
synced 2026-01-18 16:47:33 +01:00
handle crash
This commit is contained in:
@@ -88,7 +88,16 @@ std::pair<int, std::vector<std::pair<ArucoTag, std::pair<cv::Mat, cv::Mat>>>> 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<int, std::vector<std::pair<ArucoTag, std::pair<cv::Mat, cv::Mat>>>> result;
|
||||
result.first = -2;
|
||||
return result;
|
||||
}
|
||||
|
||||
cv::flip(frameNotRotated, frameDistored, -1);
|
||||
cv::undistort(frameDistored, frame, cameraMatrix, distCoeffs);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user