Advertisement
Guest User

Untitled

a guest
Jul 1st, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. #include "opencv2/highgui/highgui.hpp"
  2. #include "opencv2/imgproc/imgproc.hpp"
  3. #include <iostream>
  4. #include <fstream>
  5. int g_slider_position = 0;
  6. CvCapture* g_capture = NULL;
  7. void onTrackbarSlide(int pos)
  8. {
  9. cvSetCaptureProperty(
  10. g_capture,
  11. CV_CAP_PROP_POS_FRAMES,
  12. pos
  13. );
  14. }
  15. int main( int argc, char** argv )
  16. {
  17. cvNamedWindow( "Example3", CV_WINDOW_AUTOSIZE );
  18. g_capture = cvCreateFileCapture( "ab.MP4" );
  19. int frames = (int) cvGetCaptureProperty(
  20. g_capture,
  21. CV_CAP_PROP_FRAME_COUNT
  22. );
  23. if( frames!= 0 )
  24. {
  25. cvCreateTrackbar(
  26. "Position",
  27. "Example3",
  28. &g_slider_position,
  29. frames,
  30. onTrackbarSlide
  31. );
  32. }
  33. IplImage* frame;
  34. // While loop (as in Example 2) capture & show video
  35. while(1)
  36. {
  37. frame = cvQueryFrame( g_capture );
  38. if( !frame ) break;
  39. cvShowImage( "Example2", frame );
  40. char c = cvWaitKey(33);
  41. if( c == 27 ) break;
  42. }
  43. // Release memory and destroy window
  44. cvDestroyWindow( "Example3" );
  45. return(0);
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement