Skip to content

Files

File I/O utilities for reading and writing IOU and tracking data.

This module provides functions to read and write CSV files containing IOU (Intersection over Union) metrics and tracking information.

read_iou

read_iou(iou_file)

Read IOU metrics from a CSV file.

Parameters:

Name Type Description Default
iou_file str

Path to the CSV file containing IOU metrics.

required

Returns:

Type Description
DataFrame

DataFrame containing IOU metrics with columns for video ID, detection ID, and IOU values.

Source code in src/dnt/shared/files.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
def read_iou(iou_file):
    """Read IOU metrics from a CSV file.

    Parameters
    ----------
    iou_file : str
        Path to the CSV file containing IOU metrics.

    Returns
    -------
    pd.DataFrame
        DataFrame containing IOU metrics with columns for video ID, detection ID,
        and IOU values.

    """
    results = pd.read_csv(
        iou_file, header=None, dtype={0: int, 1: int, 2: float, 3: float, 4: float, 5: float, 6: float, 7: int}
    )
    return results

write_iou

write_iou(ious, iou_file)

Write IOU metrics to a CSV file.

Parameters:

Name Type Description Default
ious DataFrame

DataFrame containing IOU metrics to write.

required
iou_file str

Path to the output CSV file.

required
Source code in src/dnt/shared/files.py
31
32
33
34
35
36
37
38
39
40
41
42
def write_iou(ious, iou_file):
    """Write IOU metrics to a CSV file.

    Parameters
    ----------
    ious : pd.DataFrame
        DataFrame containing IOU metrics to write.
    iou_file : str
        Path to the output CSV file.

    """
    ious.to_csv(iou_file, header=False, index=False)

read_track

read_track(track_file)

Read tracking data from a CSV file.

Parameters:

Name Type Description Default
track_file str

Path to the CSV file containing tracking information.

required

Returns:

Type Description
DataFrame

DataFrame containing tracking data with video ID, track ID, coordinates, and additional tracking metrics.

Source code in src/dnt/shared/files.py
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
def read_track(track_file):
    """Read tracking data from a CSV file.

    Parameters
    ----------
    track_file : str
        Path to the CSV file containing tracking information.

    Returns
    -------
    pd.DataFrame
        DataFrame containing tracking data with video ID, track ID, coordinates,
        and additional tracking metrics.

    """
    results = pd.read_csv(
        track_file,
        header=None,
        dtype={0: int, 1: int, 2: float, 3: float, 4: float, 5: float, 6: float, 7: int, 8: int, 9: int},
    )
    return results

write_track

write_track(tracks, track_file)

Write tracking data to a CSV file.

Parameters:

Name Type Description Default
tracks DataFrame

DataFrame containing tracking data to write.

required
track_file str

Path to the output CSV file.

required
Source code in src/dnt/shared/files.py
68
69
70
71
72
73
74
75
76
77
78
79
def write_track(tracks, track_file):
    """Write tracking data to a CSV file.

    Parameters
    ----------
    tracks : pd.DataFrame
        DataFrame containing tracking data to write.
    track_file : str
        Path to the output CSV file.

    """
    tracks.to_csv(track_file, header=False, index=False)

read_spd

read_spd(spd_file)

Read speed data from a CSV file.

Parameters:

Name Type Description Default
spd_file str

Path to the CSV file containing speed information.

required

Returns:

Type Description
DataFrame

DataFrame containing speed data with columns for video ID, reference, and frame.

Source code in src/dnt/shared/files.py
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
def read_spd(spd_file):
    """Read speed data from a CSV file.

    Parameters
    ----------
    spd_file : str
        Path to the CSV file containing speed information.

    Returns
    -------
    pd.DataFrame
        DataFrame containing speed data with columns for video ID, reference, and frame.

    """
    results = pd.read_csv(spd_file, header=None, dtype={0: int, 1: int, 2: int})
    return results