From e45f46c102b5b7c3ee1434bd546e6aaeca812928 Mon Sep 17 00:00:00 2001 From: Tim Zeuner Date: Wed, 30 Nov 2022 18:55:20 +0100 Subject: [PATCH] Proper error message, Check if grab() was successfull --- AutonomousMode/Input/input.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/AutonomousMode/Input/input.cpp b/AutonomousMode/Input/input.cpp index ca704d2..e2c5173 100644 --- a/AutonomousMode/Input/input.cpp +++ b/AutonomousMode/Input/input.cpp @@ -39,17 +39,19 @@ Mat Input::readWebcam() Mat image; if(!cap.isOpened()) { - cout << "Fehler"; + cout << "Video capture not opened" << std::endl; return Mat(); } - cap.grab(); + if(!cap.grab()) { + cout << "Could not grab frame from camera" << std::endl; + return Mat(); + } cap.retrieve(image); - return image; } void Input::freeWebcam() { this->cap.release(); -} \ No newline at end of file +}