Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+37 votes

I'm guessing that the slider's max value needs to be set to the total number of frames in the video, and that we need to use the slider's value to find the frame but I have no idea how to do it.

asked in CSC285_Fall2018 by (1 point)
+6

Instead of setting the slider's max value to the total number of frames as you said, you could also consider these 3 values to compute the % of your "point" in the slider that corresponds to % length of the video :

  1. newValue.doubleValue() represents the new value in the slider (where you
    changed it)
  2. sliderSeekBar.getMax() represents the total value of the slider (usually returns 100 by default)
  3. capture.get(Videoio.CV_CAP_PROP_FRAME_COUNT) that tells you the number of actual frames in the video

2 Answers

+16 votes

Good point. You can do this with:

vidCap.get(Videoio.CV_CAP_PROP_FRAME_COUNT);

where vidCap is an opencv VideoCapture object.

answered by (3.9k points)
+15 votes

I also use these to set the value that the slider bar represents:
sliderSeekBar.setMax();
sliderSeekBar.setWidthMax();

those 2 look the same and I don't know for sure if one of them is unnecessary, but when removed the sliderSeekBar.setWidthMax, it didn't work.

answered by (1 point)
+8

is sliderSeekBar the name of your Slider object?

+7

yes it is! sorry for not clarifying that.

+7

What computation did you have using both sliderSeekBar.setMax(); and sliderSeekBar.setWidthMax();?

...