From 334ac49d343f7ce80512e6b01e1e58ca18504d70 Mon Sep 17 00:00:00 2001 From: Vadim Pisarevsky Date: Wed, 24 Nov 2010 22:54:52 +0000 Subject: [PATCH] added user mode selection (thanks to tito for the patch, ticket #563) --- modules/highgui/src/cap_dc1394_v2.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/modules/highgui/src/cap_dc1394_v2.cpp b/modules/highgui/src/cap_dc1394_v2.cpp index 405c01a..12c0da6 100644 --- a/modules/highgui/src/cap_dc1394_v2.cpp +++ b/modules/highgui/src/cap_dc1394_v2.cpp @@ -219,6 +219,7 @@ protected: double fps; int nDMABufs; bool started; + int userMode; enum { VIDERE = 0x5505 }; @@ -257,6 +258,7 @@ CvCaptureCAM_DC1394_v2_CPP::CvCaptureCAM_DC1394_v2_CPP() frameC = 0; nimages = 1; rectify = false; + userMode = -1; } @@ -277,7 +279,7 @@ bool CvCaptureCAM_DC1394_v2_CPP::startCapture() DC1394_ISO_SPEED_3200); } - if (frameWidth > 0 || frameHeight > 0) + if (userMode == -1 && (frameWidth > 0 || frameHeight > 0)) { dc1394video_mode_t bestMode = (dc1394video_mode_t) - 1; dc1394video_modes_t videoModes; @@ -321,6 +323,17 @@ bool CvCaptureCAM_DC1394_v2_CPP::startCapture() if ((int)bestMode >= 0) code = dc1394_video_set_mode(dcCam, bestMode); } + + if (userMode > 0) + { + dc1394video_modes_t videoModes; + dc1394_video_get_supported_modes(dcCam, &videoModes); + if (userMode < videoModes.num) + { + dc1394video_mode_t mode = videoModes.modes[userMode]; + code = dc1394_video_set_mode(dcCam, mode); + } + } if (fps > 0) { @@ -601,6 +614,9 @@ bool CvCaptureCAM_DC1394_v2_CPP::setProperty(int propId, double value) return false; rectify = fabs(value) > FLT_EPSILON; break; + case CV_CAP_PROP_MODE: + userMode = cvRound(value); + break; default: return false; } -- 2.7.4