@@ -27,11 +27,6 @@ OCVCamera::OCVCamera(int width, int height, int fps, int index) :
2727 if (fps < 0 )
2828 this ->fps = cam_native_fps;
2929
30-
31- cap.set (cv::CAP_PROP_FRAME_WIDTH, this ->width );
32- cap.set (cv::CAP_PROP_FRAME_HEIGHT, this ->height );
33- cap.set (cv::CAP_PROP_FPS, this ->fps );
34-
3530 exposure, gain = -1 ;
3631}
3732
@@ -55,7 +50,7 @@ bool OCVCamera::is_camera_available()
5550
5651 cam_native_width = (int )cap.get (cv::CAP_PROP_FRAME_WIDTH);
5752 cam_native_height = (int )cap.get (cv::CAP_PROP_FRAME_HEIGHT);
58- cam_native_fps = ( int )cap.get (cv::CAP_PROP_FPS);
53+ cam_native_fps = std::max ( 30 , ( int )cap.get (cv::CAP_PROP_FPS) );
5954 cap.release ();
6055 }
6156 return available;
@@ -68,6 +63,13 @@ void OCVCamera::start_camera()
6863 {
6964 throw std::runtime_error (" No compatible camera found." );
7065 }
66+
67+ // Force its properties each time we start the camera
68+ // because if we force them with the device switched off
69+ // bugs will occur (tiling, for example).
70+ cap.set (cv::CAP_PROP_FRAME_WIDTH, this ->width );
71+ cap.set (cv::CAP_PROP_FRAME_HEIGHT, this ->height );
72+ cap.set (cv::CAP_PROP_FPS, this ->fps );
7173}
7274
7375void OCVCamera::stop_camera ()
@@ -89,7 +91,7 @@ void OCVCamera::set_settings(CameraSettings& settings)
8991{
9092 this ->width = settings.width > 0 ? settings.width : this ->cam_native_width ;
9193 this ->height = settings.height > 0 ? settings.height : this ->cam_native_height ;
92- this ->fps = settings.fps > 0 ? settings.fps : this ->cam_native_fps ;
94+ this ->fps = settings.fps >= 30 ? settings.fps : this ->cam_native_fps ;
9395
9496 // Disabled for the moment because of the different ranges in generic cameras.
9597 // exposure = settings.exposure < 0 ? -1.0F : (float)settings.exposure/255;
0 commit comments