OpenCV - getting the slider to update its position during video playback

后端 未结 6 1918
-上瘾入骨i
-上瘾入骨i 2020-12-28 21:12

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

6条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-28 21:47

    You can try the solution below.

    change this

    void onTrackbarSlide(int pos)
    {
        cvSetCaptureProperty(g_capture, CV_CAP_PROP_POS_FRAMES, pos);
    }
    

    to

    void onTrackbarSlide( int pos )
    {
        if( pos > g_slider_position + 1 )
        cvSetCaptureProperty( 
            g_capture, 
            CV_CAP_PROP_POS_FRAMES, 
            pos);
    }
    

    and also change this

    cvSetTrackbarPos(
                "Position", 
                "The Tom 'n Jerry Show",
                ++g_slider_position
                );
    

    to

    cvSetTrackbarPos(
                "Position", 
                "The Tom 'n Jerry Show",
                g_slider_position + 1
                );
    

提交回复
热议问题