Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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 (though it doesn't seem like python supports this function), or even use a trackbar and update its position to reflect the time. Good luck!

click to hide/show revision 2
Linked to the non-qt version of adding text in frames.

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 (though it doesn't seem like python supports this function), , or even use a trackbar and update its position to reflect the time. Good luck!