@@ -43,6 +43,11 @@ namespace OPENCV {
4343 if (!cvFrame.data )
4444 return FrameworkReturnCode::_ERROR_LOAD_IMAGE;
4545
46+ unsigned int w=cvFrame.cols ;
47+ unsigned int h=cvFrame.rows ;
48+ if (w!=m_parameters.resolution .width || h!=m_parameters.resolution .height )
49+ cv::resize (cvFrame, cvFrame, cv::Size ((int )m_parameters.resolution .width ,(int )m_parameters.resolution .height ), 0 , 0 );
50+
4651 return SolAROpenCVHelper::convertToSolar (cvFrame,img);
4752 }
4853
@@ -58,8 +63,28 @@ namespace OPENCV {
5863 {
5964 if (m_is_resolution_set)
6065 {
61- m_capture.set (cv::CAP_PROP_FRAME_WIDTH, m_parameters.resolution .width );
62- m_capture.set (cv::CAP_PROP_FRAME_HEIGHT, m_parameters.resolution .height );
66+ LOG_INFO (" Camera using {} * {} resolution" , m_parameters.resolution .width ,m_parameters.resolution .height )
67+
68+ auto setResolution = [&]
69+ (cv::VideoCaptureProperties dimensionProp,
70+ uint32_t value,
71+ const std::string& dimensionName)
72+ {
73+ bool setResDimOk = m_capture.set (dimensionProp, value);
74+
75+ if (!setResDimOk || m_capture.get (dimensionProp) != value)
76+ {
77+ LOG_WARNING (" Cannot set camera {} to {}. Will fallback to cv::resize() each frame" , dimensionName, value);
78+ if (!setResDimOk)
79+ {
80+ LOG_WARNING ( " Note: cv::VideoCapture::set() returned 'true'" );
81+ }
82+ }
83+ };
84+
85+ setResolution (cv::CAP_PROP_FRAME_WIDTH, m_parameters.resolution .width , " width" );
86+ setResolution (cv::CAP_PROP_FRAME_HEIGHT, m_parameters.resolution .height , " height" );
87+
6388 }
6489 return FrameworkReturnCode::_SUCCESS;
6590 }
0 commit comments