1

When capturing a frame in a camera video capture in opencv, how can i get the frame timestamp in system's timeframe instead of the camera timeframe?

cap = cv2.VideoCapture(1)
while(cap.isOpened()):
    ret, frame = cap.read()
    systime = time.time() # this is not an accurate way to measure timestamp in system time
    camtime = cap.get(cv2.CAP_PROP_POS_MSEC)/1000.# this is the timestamp in camera time

This is needed because certain actions have to be triggered by the computer according to the results of the frame analyses. These actions are triggered using the system's time, so in order to calculate the correct time, the frame timestamp has to be in system's time

AlexK
  • 2,855
  • 9
  • 16
  • 27
omar
  • 513
  • 2
  • 5
  • 13
  • Which system are you referring to? The system on which this Python script will be run? And how would you like the timestamp to look? time.ctime() for example will provide you with current time on your system in terms of year, month, day, etc. – AlexK Mar 08 '19 at 23:36
  • I'm running this code on a ubuntu os. The look of the timestamp is not important, I'm using the time.time() – omar Mar 09 '19 at 05:10
  • I am not asking about OS. I still don't understand the problem. What's wrong with using time.time()? You don't want to use it? What is system's time or system's timeframe in your mind? What is your desired value for systime above? – AlexK Mar 09 '19 at 07:22
  • Maybe my question isnt too clear, I'm sorry if that's the case. Doing time.time() after cap.read() does not give an accurate time of the frame taken by the camera, it's off by about 80 milliseconds. CAP_PROP_POS_MSEC gives an accurate time, but i cannot use it because it's in camera time and not the operating system time. So in summary i just want the time the frame was taken accurately. – omar Mar 09 '19 at 18:54
  • Thanks, I get the question now, but I can only point you to some other SO dicussions: https://stackoverflow.com/q/42230269/9987623, https://stackoverflow.com/q/37751123/9987623 – AlexK Mar 09 '19 at 20:07

0 Answers0