7

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);
slaveCoder
  • 519
  • 2
  • 17
  • 46
  • I don't know how to do that in java but in C/C++ I'll use , VideoCapture::get(CV_CAP_PROP_FPS) take a look here : http://docs.opencv.org/modules/highgui/doc/reading_and_writing_images_and_video.html#videocapture-get – Engine Feb 18 '14 at 13:09
  • Thanks i've seen this but not possible in java thats the problem. – slaveCoder Feb 18 '14 at 17:20

3 Answers3

4

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);
praks411
  • 1,972
  • 16
  • 23
2
 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();
RAGHHURAAMM
  • 1,099
  • 7
  • 15
Pranav
  • 21
  • 1
1

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.

RAGHHURAAMM
  • 1,099
  • 7
  • 15
dzenisiy
  • 855
  • 10
  • 32