I am using a videocapture object to capture and process frames of a video in opencv/javacv. I dont know how to get the frame rate.I want a timer that runs in the background during the live video capture.It should pause on a face being detected and continue later. Due to the processing of haarcascade file,it is taking much time for each rame to process. how to adjust the frame rate.
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
VideoCapture camera = new VideoCapture(0);
You can extract various parameter from VideoCapture like frame rate, frame height, frame width etc.
cv::VideoCapture input_video;
if(input_video.open(my_device))
{
std::cout<<"Video file open "<<std::endl;
}
else
{
std::cout<<"Not able to Video file open "<<std::endl;
}
int fps = input_video.get(CV_CAP_PROP_FPS);
int frameCount = input_video.get(CV_CAP_PROP_FRAME_COUNT);
double fheight = input_video.get(CV_CAP_PROP_FRAME_HEIGHT);
double fwidth = input_video.get(CV_CAP_PROP_FRAME_WIDTH);
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
VideoCapture VC = new VideoCapture(0);
//First you requried open Camera.
VC.open();
//Now for geting 'Frame per secand"
VC.get(Videoio.CAP_PROP_FPS); // it returns FPS(Frame per secand)
//Now for seting 'Frame per secand"
VC.set(Videoio.CAP_PROP_FPS,10.0);//in this 10.0 is value for FPS,its double value.
VC.relase();
This answer helps me. There is a list of constants and their values. Just put value to VideoCapture's get() method. Ex. videoCapture.get(5), will return FPS of video.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With