Open h-mayorquin opened 1 year ago
The problem is that opencv get() returns 0 if the device doesn't support the property (POS_MSECS). See here.
So fictrac's _timestamp would just be zero for ever in that case. Hence if the get() function returns 0 I use backup time instead.
Agree that it's a bit annoying to have very large timestamp jumps at the beginning of output though. Perhaps I could change the code to only default to backup when retrieved timestamp is zero for two or more frames in a row - assuming video files will only ever have first frame zero.
Thanks for your quick response and thanks for all your work in this project.
What a terrible decision by open CV to use a valid value to mark a null:
My two cents is that it would be easier to just have two columns in the output data that then users can use as they wish:
source_timestamps
: return the timestamps from OpenCV, Basler or PGR as they come.system_timestamps
: returns the system timestamps when the frames are grabed by the program. Just your ts_ms()
function.I think that it is easier if the fallback is transparent like that and way less maintenance burden for you. Trying to hammer these two concepts into the single timestamps
concept seems difficult and specially so if you decide to add more sources in the future.
I think you are proviidng similar value with the ms since midnight
but for some reason it is not available in some of the files that I have received.
Btw, why is ms_since_midnight
defined for PGR_USB3
but not for PGR_USB2
?
Thanks for your quick response and thanks for all your work in My two cents is that it would be easier to just have two columns in the output data that then users can use as they wish:
I also use a timestamp in the program and have to decide which source to use anyway. I will have a closer look at your suggestion though. At least printing some indication of source for tinestamp would be sensible.
Btw, why is
ms_since_midnight
defined forPGR_USB3
but not for
PGR_USB2
?
This looks suspiciously like a bug. Will take a look!
Thanks again.
Btw, I edited my comment above to:
What a terrible decision by open CV to use a valid value to mark a null:
Just in case you read it differently. That was my original intention. I think that your decision of not trying to second guess Open CV is very sensible.
The condition to fallback to system time in the
CVSource
class is the following:https://github.com/rjdmoore/fictrac/blob/9ac055e52d89f49f492a8eb4e1f7c5b8cd6df40a/src/CVSource.cpp#L162-L165
But I think the condition should be strict, that is, I think the condition should be
_timestamp < 0
. Otherwise, timestamps which are 0 are ignored and the fallback of the system time is used instead which creates a time discontinuity. As an example, this is the data that I got by running the algorithm in thesample.mp4
:See the large discontinuity caused by the first timestamp being 0.
To confirm that the first timestamp is indeed 0 we can run ffprobe: