Skip to content

Confusion: timestamps in timestamps.json seems all within 1 second after 1970-01-01 00:00:00 #91

@OuYaozhong

Description

@OuYaozhong

Hi ,there, @MarioBijelic

In Brief

The way to process the timestamps in tools/DatasetViewer/timestamps.json make me confuse.

All the time stamps are within 1 sec after the start point 1970-01-01 00:00:00, since they are all less than 10 digits (i.e., <= 9 digits)

The analysis is based on the interpretation method cited by convert_timestamp (tools/DatasetViewer/utils_DataViewer.py#L138),

where tells that the last 9-bit digits of the timestamps represents $10^{-9}$ second and the rest most-significant digits represents the second.

All-less-than-10-bit-digit timestamps in timestamps.json make the time shown are all same at the 1970-01-01 00:00:00 (refer to the picture at the last).

🌟Question: What happened ? Any mistake here or I missing something ?


Detail Description

I found that there is an tools/DatasetViewer/timestamps.json file, reflecting the real captured time of the data.

I also found some code in tools/DatasetViewer/DataViewer_V2.py, telling that how the author processing this timestamps file.

In tools/DatasetViewer/DataViewer_V2.py line 279, it has following codes:

self.stereo_timestamp = self.get_timestamp_from_data_name(topic='rgb')
if self.stereo_timestamp is not None:
    date = convert_timestamp(self.stereo_timestamp)
    self.timeRGBEdit.setText('{}'.format(date))
else:
    self.timeRGBEdit.setText('No timestamp found!')

And the self.get_timestamp_from_data_name is defined as below in tools/DatasetViewer/DataViewer_V2.py line 666:

def get_timestamp_from_data_name(self, topic):
    recording = self.recordings[self.current_index]

    # get matching file name from AdverseWeather data
    matching_label_topic = self.timedelays.get(topic)
    old_data_name = matching_label_topic.get(recording.split('.png')[0], 'NoFrame')
    if old_data_name != 'NoFrame':
        old_data_name = os.path.splitext(old_data_name)[0]
        old_data_name = old_data_name.split('_')[1]
        stereo_timestamp = int(old_data_name)
        return stereo_timestamp

    else:
        return None

From above codes, we can see that the timestamps is indexed by the filename of the data, the corresponding timestamp value is saved in the json file timestamps.json in a dictionary style.

In the timestamps.json, the content is organized as following structure:

{
    "modal": {
        "filename": "{old_timestamp}_{new_timestamp}"
    }
}

What above codes do is using file name of the data to index the "{old_timestamp}_{new_timestamp}" string pair.
Then, the {new_timestamp} is the corresponding true time stamp at the time when data is captured.
And the {old_timestamp} is the same as the one at the end of the file name string.

Here are some examples.

"2018-02-03_21-36-01_00100": "00100_-9235816",
"2018-02-03_21-36-01_00200": "00200_-40654056",
"2018-02-03_21-36-01_00300": "00300_-21753718",

Then, author try to convert the time stamp into the real date format, by the code:

date = convert_timestamp(self.stereo_timestamp)

Above self.stereo_timestamp is the same as {new_timestamp}.

The code about the convert_timestamp is here:

def convert_timestamp(timestamp):
    dt = datetime.fromtimestamp(timestamp // 1000000000)
    s = dt.strftime('%Y-%m-%d %H:%M:%S')
    s += '.' + str(int(timestamp % 1000000000)).zfill(9)
    return s

From the code above, it seems that the timestamp should be format as
| n-bit seconds | + | 9-bit $10^{-9}$ second |
The seconds are count from 1970-01-01 00:00:00

So, the unit of the {new_timestamp} is $10^{-9}$ second, then, timestamp = 1,000,000,000 means 1 sec after 1970-01-01 00:00:00, (i.e., 1970-01-01 00:00:01).

However, most of {new_timestamp} in timestamps.json are less than 1000, and even lots of are negative, meaning that the data is captured before year of 1970.

Meanwhile, there are some data are large enough.

There are only 19 {new_timestamp} have 9 digits, meaning that they represent least 0.1 sec, and no {new_timestamp} has >=10 digits, meaning that all {new_timestamp} are < 1 sec after 1970-01-01 00:00:00.

The usage of datetime shown below:

Python 3.12.9 | packaged by Anaconda, Inc. | (main, Feb  6 2025, 18:56:27) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from datetime import datetime
>>> import time
>>> datetime.fromtimestamp(time.time())
datetime.datetime(2025, 5, 22, 15, 28, 48, 284906)
>>> datetime.fromtimestamp(0)
datetime.datetime(1970, 1, 1, 1, 0)
>>> datetime.fromtimestamp(1)
datetime.datetime(1970, 1, 1, 1, 0, 1)

The result is that, in the UI of tools/DatasetViewer/DataViewer_V2.py, it always shows that the data is captured in 1970-01-01 00:00:00 (various based on the timezone you set)

Image

It seems strange and impossible

🌟Could you explain what happened ?

Thanks in advance.

Best Regards

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions