Ask Your Question
0

i want to display time in my video using opencv.

asked 2013-03-23 20:29:53 -0600

gett gravatar image

i want to dispaly time in my video using opencv...just like in video players...i use python for coding... please help....i am beginner in using opencv...

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2013-03-23 20:54:16 -0600

HD_Mouse gravatar image

updated 2013-03-23 20:58:24 -0600

First off, keep in mind that OpenCV is a computer vision library, and what you're asking for is a feature that would be implemented more easily in a GUI framework.

That said, you CAN do this with OpenCV. Using the get function in cv2, you can obtain properties of the video. Properties you'd be interested in are: CV_CAP_PROP_POS_MSEC, and CV_CAP_PROP_POS_AVI_RATIO. You can get the timestamp of the frame in milliseconds from the former, and then the relative position of that frame from the latter. You can also get the length of the entire video in seconds from CV_CAP_PROP_FPS and CV_CAP_PROP_FRAME_COUNT.

For actually displaying the time, you could print it directly onto the frame as text, or even use a trackbar and update its position to reflect the time. Good luck!

edit flag offensive delete link more

Comments

thank you for your answer...but still i have problem when i compile...following is the error i am getting when i compile..

[mov,mp4,m4a,3gp,3g2,mj2 @ 0x183c620] multiple edit list entries, a/v desync might occur, patch welcome

Traceback (most recent call last):

File "vid2.py", line 36, in <module>

main()

File "vid2.py", line 22, in main

millis = cv2.VideoCapture.get(CV_CAP_PROP_POS_MSEC)

AttributeError: 'builtin_function_or_method' object has no attribute 'get'

am i missing any library ?? to my knowledge i have installed libraries of opencv...

gett gravatar imagegett ( 2013-03-24 06:12:46 -0600 )edit

Hm, this might be a bug. The error is reporting that 'get' hasn't actually be defined yet. cv2 is known to have not implemented everything yet, so you can try switching to the cv interface for now, which has VideoWriter working there.

HD_Mouse gravatar imageHD_Mouse ( 2013-03-25 11:46:26 -0600 )edit

Question Tools

Stats

Asked: 2013-03-23 20:29:53 -0600

Seen: 10,269 times

Last updated: Mar 23 '13

Related questions