0

I have some task to do video processing and I want to do it with openCV and java.

The problem is when I didn't do much process there the video runs so fast. On the other hand when there is plenty thing to do with the video, the video runs so slow on my program. I got an idea to do something with the fps and then I only get this and still wonder how to get fps from video in java with or without openCV.

any help will be appreciated, especially if you can solve my root problem :)

Community
  • 1
  • 1
Shofwan
  • 451
  • 2
  • 6
  • 16
  • `double fps = cap.get(CV_CAP_PROP_FPS)` – Miki Sep 18 '15 at 23:17
  • Unfortunately in [here](http://docs.opencv.org/java/org/opencv/highgui/VideoCapture.html) there were only CV_CAP_PROP_FRAME_WIDTH and CV_CAP_PROP_FRAME_HEIGHT option, neither FPS can be found [here](http://docs.opencv.org/java/org/opencv/highgui/Highgui.html). it can only be found [here](http://docs.opencv.org/modules/highgui/doc/reading_and_writing_images_and_video.html#videocapture-get) in C++ OpenCV – Shofwan Sep 18 '15 at 23:45
  • after a short research, it may be a bug. Try `cap.get(5);` – Miki Sep 18 '15 at 23:49
  • https://github.com/Itseez/opencv/issues/4667 – Miki Sep 18 '15 at 23:50
  • yeah it worked. on my video that has 29 fps it says 29.97002997002997 – Shofwan Sep 18 '15 at 23:58
  • do OpenCV in java are that bad? should I move to C++? what about JavaCV? – Shofwan Sep 19 '15 at 00:02
  • I personally use and prefer C++. Java and Python bindings work ok generally, some bug may happen. JavaCV is not recommended since it's not official nor well supported. – Miki Sep 19 '15 at 00:03

1 Answers1

0

For OpenCV 3 the constants for the fps, width, height, etc are in VideoIO. In other words, you have to use:

cap.get(Videoio.CAP_PROP_FPS);
cap.get(Videoio.CAP_PROP_FRAME_WIDTH);
cap.get(Videoio.CAP_PROP_FRAME_HEIGHT);
Roland
  • 18,114
  • 12
  • 62
  • 93
  • Have you tried CAP_PROP_FRAME_WIDTH and HEIGHT? I need it recently and when I use it, both of them turn out to return the width of the video. Maybe it's a bug? – Shofwan Sep 30 '15 at 13:41
  • Uh okay I have tried it with another video and it works fine actually. Only for just this [video](https://www.dropbox.com/sh/dshmg0cnoup8wgq/AACVHl6LnNgSKgTvnYY3B_56a/visiontraffic.avi?dl=0) it's become 640x640. Actually it's 360x640. Can you try it for me? – Shofwan Sep 30 '15 at 13:56
  • I get 640x640 as well for that. – Roland Sep 30 '15 at 14:04