How to set or get VideoCapture properties?
I'm trying to modify the properties of a 720p HD Logitech usb webcam, in order to change their fps or image format, size.
But opencv generates the following error:
HIGHGUI ERROR: V4L2: Unable to get property <Unknown string> property (5) - Invalid argument.
The code:
# include <iostream>
# include <opencv2/core/core.hpp>
# include <opencv2/highgui/highgui.hpp>
# include <opencv2/imgproc/imgproc.hpp>
using namespace std;
int main () {
cv :: VideoCapture cap (0); // open the default camera
if (! cap.isOpened ()) // check if we succeeded
return -1;
cv :: Mat edges;
cv :: namedWindow ("edges", 1);
for (;;)
{
cv :: Mat frame;
cap >> frame; // get a new frame from camera
// This function generate error
cap.get double val = (CV_CAP_PROP_FPS);
cout << val << endl;
cv :: cvtColor (frame, edges, CV_BGR2GRAY);
cv :: GaussianBlur (edges, edges, cv :: Size (7,7), 1.5, 1.5);
cv :: Canny (edges, edges, 0, 30, 3);
cv :: imshow ("edges", edges);
if (cv :: waitKey (30)> = 0) break;
}
return 0;
}
I would appreciate some help.