Ask Your Question
0

timer in video opencv

asked 2013-03-23 05:02:34 -0600

gett gravatar image

how to display time in video using opencv? CV_CAP_PROP_POS_MSEC--will this help me to display the time? please excuse my limited knowledge in opencv as i am new to this.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2013-03-23 05:41:51 -0600

berak gravatar image

updated 2013-03-23 05:43:11 -0600

are you asking how to get the value ? or how to display it ? anyway, let's try both:

Mat frame;
namedWindow("win");
VideoCapture cap("my.mpeg");
while( cap.isOpened() )
{
     cap >> frame;
     double millis = cap.get(CV_CAP_PROP_POS_MSEC);
     // let's draw it,
     // needs a clone, because the frame is in video-memory
     Mat draw = frame.clone(); 
     putText(draw, format("%4.3f",millis),Point(20,20), FONT_HERSHEY_PLAIN, 1.0, CV_RGB(0,255,0), 2.0);
     imshow("win", draw);
     // no imshow without waitkey..
     int k = waitKey(20);
     if ( k==27 ) break;
}
edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-03-23 05:02:34 -0600

Seen: 801 times

Last updated: Mar 23 '13