|
From: Tapio V. <aa...@us...> - 2012-07-18 10:48:21
|
Author: Tapio Vierros <tap...@gm...>
Date: Wed Jul 18 13:47:31 2012 +0300
Webcam: if default resolution is smaller than VGA, try to get VGA.
---
game/webcam.cc | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/game/webcam.cc b/game/webcam.cc
index 85fa849..561dff3 100644
--- a/game/webcam.cc
+++ b/game/webcam.cc
@@ -30,6 +30,17 @@ Webcam::Webcam(int cam_id):
if (!m_capture->isOpened())
throw std::runtime_error("Could not initialize webcam capturing!");
}
+ // Try to get at least VGA resolution
+ if (m_capture->get(CV_CAP_PROP_FRAME_WIDTH) < 640
+ || m_capture->get(CV_CAP_PROP_FRAME_HEIGHT) < 480) {
+ m_capture->set(CV_CAP_PROP_FRAME_WIDTH, 640);
+ m_capture->set(CV_CAP_PROP_FRAME_HEIGHT, 480);
+ }
+ // Print actual values
+ std::cout << "Webcam frame properties: "
+ << m_capture->get(CV_CAP_PROP_FRAME_WIDTH) << "x"
+ << m_capture->get(CV_CAP_PROP_FRAME_HEIGHT) << std::endl;
+
// Initialize the video writer
#ifdef SAVE_WEBCAM_VIDEO
float fps = m_capture->get(CV_CAP_PROP_FPS);
|