[Learn OpenCV Introduction] [005] [Video playback control]

Source: Internet
Author: User

Cvsetcaptureproperty (video, attributes, attribute values)

Set the properties of the video, which can be the location of the macro Cv_cap_prop_pos_frames video frame

Cvgetcaptureproperty (video, properties)

To get the property value of the video, the property can be the macro Cv_cap_prop_frames_count video frame number, cv_cap_prop_frame_width the width of the video, Cv_cap_prop_frame_height

Cvcreatetrackbar (scroll bar name, window name, slider position, total frame count, callback function)

Creates a scrollbar in the window and sets the position and total frame count, triggering the callback function when the scrollbar is dragged

Cvsettrackbarpos (scroll bar name, window name, position)

Set the position of the scroll bar in the window

#include <stdio.h> #include <iostream> #include <fstream> #include "cv.h" #include "highgui.h" using namespace Std;int g_slider_position = 0; cvcapture* g_capture = null;void ontrackbarslide (int pos) {Cvsetcaptureproperty (g_capture,cv_cap_prop_pos_frames,pos );}    int Getaviframes (char * fname) {char tempsize[4];    Trying to open the video file Ifstream videofile (fname, ios::in | ios::binary);  Checking the availablity of the file if (!videofile) {cout << "couldn ' t open the input file" <<      FName << Endl;    Exit (1);    }//Get the number of frames VIDEOFILE.SEEKG (0x30, Ios::beg);    Videofile.read (Tempsize, 4);    int frames = (unsigned char) tempsize[0] + 0x100* (unsigned char) tempsize[1] + 0x10000* (unsigned char) tempsize[2] +    0x1000000* (unsigned char) tempsize[3];    Videofile.close (); return frames;} int main (int argc, char** argv) {Cvnamedwindow ("Hello", cv_window_autosize); g_capture = CvcreatefileCapture (argv[1]); Iplimage *foo = Cvqueryframe (g_capture); int frames = (int) cvgetcaptureproperty (g_capture,cv_cap_ prop_frame_count); int TMPW = (int) cvgetcaptureproperty (g_capture,cv_cap_prop_frame_width); int tmph = (int) Cvgetcaptureproperty (g_capture,cv_cap_prop_frame_height);p rintf ("OpenCV frames%d W%d h%d\n", Frames, TMPW, tmph); Frames = Getaviframes (argv[1]);p rintf ("Hacked frames%d W%d h%d\n", Frames, TMPW, tmph), Cvcreatetrackbar ("position", "he Llo ", &g_slider_position,frames,ontrackbarslide); Iplimage *frame;frames = 0;while (1) {frame = Cvqueryframe (g_ capture); if (!frame) {break;} frames++;p rintf ("\nframe number=%d", frames), Cvsettrackbarpos ("position", "hello", frames); Cvshowimage ("Hello", frame), char C = (char) Cvwaitkey, if (c = =) {break;}} Cvreleasecapture (&g_capture); Cvdestroywindow ("Hello"); return 0;}

[Learn OpenCV Introduction] [005] [Video playback control]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.