I try to capture video using Logitech C920 webcam with full hd resolution. It provides 30 fps with this resolution.
It works with windows camera application at 30 fps but whatever I try, I could not get this fps rate with opencv videoCapture.
Note: I use windows 10 and vs15. I tried with different usb ports, opencv versions and codecs. Result is same, ~5 fps.
I measured fps ignoring first 10 frames. Here are my calculations: only read = "5.04fps" , read+imshow = "4.97fps" and read+imshow+write = "4.91fps"
void main()
{
mainStream.open(0);
mainStream.set(CV_CAP_PROP_FRAME_WIDTH, 1920);
mainStream.set(CV_CAP_PROP_FRAME_HEIGHT, 1080);
mainStream.set(CV_CAP_PROP_FPS, 30);
mainStream.set(CV_CAP_PROP_FOURCC, CV_FOURCC('M', 'J', 'P', 'G'));
mainWriter.open("outputnew2.avi", CV_FOURCC('M', 'J', 'P', 'G'), 30, cv::Size(frameW, frameH), true);
namedWindow("frame", 1);
while (true){
Mat frame;
mainStream >> frame;
imshow("frame", frame);
if (waitKey(5) == 27)
break;
mainWriter << frame;
}
mainStream.release();
mainWriter.release();
}
VideoCaptureconstructor? - pptasznioutputnew2.avifor sure has 1920x1080 resolution with 30fps. Also, better don't useoperator>>, usereadinstead, because it returnsbooland you can check if there is a new frame. Alsoimshowis rather slow ... - pptaszni