Ask Your Question

Revision history [back]

cv::VideoCapture::set failed on image sequence

I am trying to use a cursor to seek a specific frame in stream.

main.cpp code follows:

#include <iostream>
#include <opencv2/opencv.hpp>

int main()
{
  cv::VideoCapture cap;

  if (!cap.open("8%d.jpg"))
    return 1;

  double index = cap.get(CV_CAP_PROP_POS_FRAMES);

  index += 10.0;    
  std::cout << "Seek to index: " << std::endl;

  if ( !(index < cap.get(CV_CAP_PROP_FRAME_COUNT)) )
    return 1;

  bool retval = cap.set(CV_CAP_PROP_POS_FRAMES, index);
  assert(retval);

  std::cout << cap.get(CV_CAP_PROP_POS_FRAMES) << std::endl;

  cap.release();
  return 0;
}

Command line on Ubuntu 14.4.3 LTS with OpenCV 2.4.11:

g++ main.cpp `pkg-config --cflags --libs opencv`

Command to check returning value:

echo "$#"

Output:

Seek to index: 10
-9.223377e+18

cv::VideoCapture::set function on an image sequence seems to break the stream, can you tell me why ?

Note: It works for a video as input but not an image sequence!

PS: I prefer asking before looking inside OpenCV-FFmpeg source code (it could take a while). Same question as http://stackoverflow.com/questions/32818053/cvvideocaptureset-failed-on-image-sequence