Getting timestamp on livestream video on OpenCV quick and dirty.

So I have been working on testing some SLAM methods in specific ORB-SLAM2 and in order to make it run on a webcam one needs to pass among the frame in open CV a timestamp for the frame. In theory it should be dead easy, just call on the CV::VideoCapture class the Get method with the “CV_CAP_PROP_POS_MSEC” property according to the OpenCV documentation. But turns out this is half implemented so for live streams it just doesnt work. According to this it turns out there is a way to patch the OpenCV Library and implement this, but I was just needing to get a timestamp really quick in order to feed to my SLAM method. So what I did was this:

I took this piece of code from the same ORB-SLAM2 repo and accommodated to count the time to query a frame from the webcam. Its a quick and dirty trick but does its job 🙂