src.data package

Submodules

src.data.make_dataset module

The main file for the src.data module. Creates an h5 dataset from the raw NTU RGB+D files. Best called using the Makefile provided.

>>> make data \
    RAW_DATA_PATH=X \
    PROCESSED_DATA_PATH=X \
    DATASET_TYPE=X \
    COMPRESSION=X \
    COMPRESSION_OPTS=X
With the parameters taking from the following values :
  • RAW_DATA_PATH:

    Default value is ./data/raw/

  • PROCESSED_DATA_PATH:

    Default value is ./data/processed/

  • DATASET_TYPE:

    [SKELETON | IR_SKELETON | IR | IR_CROPPED | IR_CROPPED_MOVING]

  • COMPRESSION:

    [“”, lzf, gzip]

  • COMPRESSION_OPTS (gzip compression only):

    [1, .., 9]

src.data.make_dataset_utils module

This module creates different h5 files that contain the data provided by NTU RGB+D in numpy ready format.

The following functions are provided.

  • create_h5_2d_ir_skeleton: Creates h5 with 2D IR skeleton data

  • create_h5_skeleton_dataset: Creates h5 with 3D skeleton data

  • create_h5_ir_dataset: Creates h5 with raw IR sequences

  • create_h5_ir_cropped_dataset_from_h5: Creates h5 containing cropped IR sequences around the subjects with a fixed bounding box. Requires create_h5_ir_dataset and create_h5_2d_ir_skeleton to be run first.

  • create_h5_ir_cropped_moving_dataset_from_h5: Creates h5 containing cropped IR sequences around the subjects with a moving bounding box. Requires create_h5_ir_dataset and create_h5_2d_ir_skeleton to be run first.

src.data.make_dataset_utils.create_h5_2d_ir_skeleton(input_path, output_path, compression='', compression_opts=9)

Creates an h5 dataset of the 2D skeleton projected on the IR frames. For each sequence, a new group with the name of the sequence, SsssCcccPpppRrrrAaaa, is created. In each group, a new dataset is created containing the 2D skeleton data. The skeleton data is of shape (2 {x, y}, max_frame, num_joint, 2 {n_subjects})

The h5 may be used as a standalone but is necessary to create the processed IR h5 files (see below).

The method creates the file “ir_skeleton.h5”. Warning: The file should not be renamed!

Inputs:
  • input_path (str): Path containing the raw NTU files (default: ./data/raw/. See Project Organization in README.md)

  • output_path (str): Path containing the processed h5 files (default: ./data/processed/. See Project Organization in README.md)

  • compression (str): Compression type for h5. May take values in [“”, “lzf”, “gzip”]

  • compression_otps (int): Compression opts. For “gzip” compression only. May take values in the [0; 9] range.

src.data.make_dataset_utils.create_h5_ir_cropped_dataset_from_h5(input_path, output_path, compression='', compression_opts=9)

Creates an h5 dataset with processed IR sequences. The frames are cropped with a bounding box provided by the 2D IR skeleton. The bounding box is fixed across all frames. For each sequence, a new group with the name of the sequence, SsssCcccPpppRrrrAaaa, is created. In each group, a new dataset is created containing the unprocessed IR sequence. The IR video data is of shape (n_frames, H, W).

This method depends on the h5 datasets (ir.h5, ir_skeleton.h5) created by the corresponding methods.

The method creates the file “ir_cropped.h5”. Warning: The file should not be renamed!

Inputs:
  • input_path (str): Path containing the processed h5 files (default: ./data/processed/. See Project Organization in README.md)

  • output_path (str): Path containing the processed h5 files (default: ./data/processed/. See Project Organization in README.md)

  • compression (str): Compression type for h5. May take values in [“”, “lzf”, “gzip”]

  • compression_otps (int): Compression opts. For “gzip” compression only. May take values in the [0; 9] range.

src.data.make_dataset_utils.create_h5_ir_cropped_moving_dataset_from_h5(input_path, output_path, compression='', compression_opts=9)

Creates an h5 dataset with processed IR sequences. The frames are cropped with a bounding box provided by the 2D IR skeleton. The bounding box is updated at every frame. For each sequence, a new group with the name of the sequence, SsssCcccPpppRrrrAaaa, is created. In each group, a new dataset is created containing the unprocessed IR sequence. The IR video data is of shape (n_frames, H, W).

This method depends on the h5 datasets (ir.h5, ir_skeleton.h5) created by the corresponding methods.

The method creates the file “ir_cropped_moving.h5”. Warning: The file should not be renamed!

Inputs:
  • input_path (str): Path containing the processed h5 files (default: ./data/processed/. See Project Organization in README.md)

  • output_path (str): Path containing the processed h5 files (default: ./data/processed/. See Project Organization in README.md)

  • compression (str): Compression type for h5. May take values in [“”, “lzf”, “gzip”]

  • compression_otps (int): Compression opts. For “gzip” compression only. May take values in the [0; 9] range.

src.data.make_dataset_utils.create_h5_ir_dataset(input_path, output_path, compression='', compression_opts=9)

Creates an h5 dataset of the unprocessed IR sequences. For each sequence, a new group with the name of the sequence, SsssCcccPpppRrrrAaaa, is created. In each group, a new dataset is created containing the unprocessed IR sequence. The IR video data is of shape (n_frames, H, W).

The h5 may be used as a standalone but is necessary to create the processed IR h5 files (see below).

The method creates the file “ir.h5”. Warning: The file should not be renamed!

Inputs:
  • input_path (str): Path containing the raw NTU files (default: ./data/raw/. See Project Organization in README.md)

  • output_path (str): Path containing the processed h5 files (default: ./data/processed/. See Project Organization in README.md)

  • compression (str): Compression type for h5. May take values in [“”, “lzf”, “gzip”]

  • compression_otps (int): Compression opts. For “gzip” compression only. May take values in the [0; 9] range.

src.data.make_dataset_utils.create_h5_skeleton_dataset(input_path, output_path, compression='', compression_opts=9)

Creates an h5 dataset of the 3D skeleton data. For each sequence, a new group with the name of the sequence, SsssCcccPpppRrrrAaaa, is created. In each group, a new dataset is created containing the 3D skeleton data. The skeleton data is of shape (3 {x, y, z}, max_frame, num_joint, 2 {n_subjects})

The method creates the file “skeleton.h5”. Warning: The file should not be renamed!

Inputs:
  • input_path (str): Path containing the raw NTU files (default: ./data/raw/. See Project Organization in README.md)

  • output_path (str): Path containing the processed h5 files (default: ./data/processed/. See Project Organization in README.md)

  • compression (str): Compression type for h5. May take values in [“”, “lzf”, “gzip”]

  • compression_otps (int): Compression opts. For “gzip” compression only. May take values in the [0; 9] range.

src.data.read_NTU_RGB_D_skeleton module

Contains helper functions to extract skeleton data from the NTU RGB+D dataset.

Three functions are provided.

  • read_skeleton: Parses entire skeleton file and outputs skeleton data in a dictionary

  • read_xyz: Only keeps 3D coordinates from dictionary and returns numpy version.

  • read_xy_ir: Only keeps 2D IR coordinates from dictionary and returns numpy version.

src.data.read_NTU_RGB_D_skeleton.read_skeleton(file)

Reads a skeleton file provided by the NTU RGB+D dataset and outputs a dictionary with the data. This code is not original and is courtesy of the awesome ST-GCN repository by yysijie (https://github.com/yysijie/st-gcn/)

Inputs:

file (str): Complete path to the skeleton file.

Outputs:

skeleton_sequence (dict): The treated skeleton file mapped in a dictionary.

src.data.read_NTU_RGB_D_skeleton.read_xy_ir(file, max_body=2, num_joint=25)

Creates a numpy array containing the 2D skeleton data projected on the IR frames for a given skeleton file of the NTU RGB+D dataset. This code is slightly modified and is courtesy of the awesome ST-GCN repository by yysijie (https://github.com/yysijie/st-gcn/)

Inputs:
  • file (str): Complete path to the skeleton file.

  • max_body (int): Maximum number of subjects (2 for NTU RGB+D)

  • numb_joints (int): Maximum number of joints (25 for Kinect v2)

Outputs:

data (np array): Numpy array containing skeleton of shape (2 {x, y}, max_frame, num_joint, 2 {n_subjects})

src.data.read_NTU_RGB_D_skeleton.read_xyz(file, max_body=2, num_joint=25)

Creates a numpy array containing the 3D skeleton data for a given skeleton file of the NTU RGB+D dataset. This code is slightly modified and is courtesy of the awesome ST-GCN repository by yysijie (https://github.com/yysijie/st-gcn/)

Inputs:
  • file (str): Complete path to the skeleton file.

  • max_body (int): Maximum number of subjects (2 for NTU RGB+D)

  • numb_joints (int): Maximum number of joints (25 for Kinect v2)

Outputs:

data (np array): Numpy array containing skeleton of shape (3 {x, y, z}, max_frame, num_joint, 2 {n_subjects})

Module contents