title: OpenCV - getting the slider to update its position during video playback
body: <p>I've picked up 'Learning OpenCV' and have been trying some of the code examples/exercises. In this code snippet, I want to get the slider to update its position with each video frame change, but for some reason it won't work (the picture freezes with the following code):</p>
  
  <pre><code>#include "cv.h"
  #include "highgui.h"
  
  int g_slider_position = 0;
  CvCapture* g_capture = NULL;
  
  void onTrackbarSlide(int pos)
  {
      cvSetCaptureProperty(g_capture, CV_CAP_PROP_POS_FRAMES, pos);
  }
  
  int main(int argc, char** argv)
  {
      cvNamedWindow("The Tom 'n Jerry Show", CV_WINDOW_AUTOSIZE);
      g_capture = cvCreateFileCapture(argv[1]);
      int frames = (int) cvGetCaptureProperty(
          g_capture, 
          CV_CAP_PROP_FRAME_COUNT
          );
  
      if (frames != 0)
      {
          cvCreateTrackbar(
              "Position",
              "The Tom 'n Jerry Show",
              &amp;g_slider_position,
              frames,
              onTrackbarSlide
              );
      }
  
      IplImage* frame;
  
      while (1)
      {
          frame = cvQueryFrame(g_capture);
          if (!frame) 
              break;
  
          cvSetTrackbarPos(
              "Position", 
              "The Tom 'n Jerry Show",
              ++g_slider_position
              );
  
          cvShowImage("The Tom 'n Jerry Show", frame);
          char c = cvWaitKey(33);
          if (c == 27)
              break;
      }
  
      cvReleaseCapture(&amp;g_capture);
      cvDestroyWindow("The Tom 'n Jerry Show");
  
      return 0;
  }
  </code></pre>
  
  <p>Any idea how to get the slider and video to work as intended?</p>