API

This page provides the API documentation of EdiHeadyTrack.

video

class EdiHeadyTrack.video.Video(filename=None)[source]

A class representing a Video

cap
filename

path to video file

Type:

str

fps

framerate in frames per second

Type:

int

height

pixel height of video

Type:

int

total_frames

length of video in frames

Type:

int

width

pixel width of video

Type:

int

writer
create_writer()[source]

creates video writer object

get_dim()[source]

gets video dimensions

get_fps()[source]

gets video fps

get_length()[source]

gets length of video in frames

create_writer()[source]

Create writer object for recording videos based on chosen video.

get_dim()[source]

Get video resolution

get_fps()[source]

Get framerate of video in fps

get_length()[source]

Get length of video in frames

calibration

camera

class EdiHeadyTrack.camera.Calibrator(checkerboard, video=<EdiHeadyTrack.video.Video object>, show=True)[source]

A class used to represent a camera Calibrator

checkerboard
Type:

Checkerboard

criteria

tuple of criteria for successful camera calibration

Type:

tuple

distortion

ndarray of distortion parameters

Type:

ndarray

frame

ndarray representing video frame

Type:

ndarray

gray_frame

ndarray representing grayscale video frame

Type:

ndarray

matrix

ndarray representing camera intrinsic matrix

Type:

ndarray

r_vecs

ndarray of rotational vectors

Type:

ndarray

t_vecs

ndarray of translation vectors

Type:

ndarray

calibrate()[source]

Perform camera calibration process

draw_corners(corners)[source]

Draw checkerboard corners on video frame

save_outputs()[source]

Save camera parameters to csv files

calibrate()[source]

Performs the camera calibration procedure outlined here:

https://docs.opencv.org/4.x/dc/dbb/tutorial_py_calibration.html

draw_corners(corners)[source]

Draws corners of checkerboard onto frame to verify calibration is working

Parameters:

corners (ndarray) – ndarray of the corners found for a given frame

Returns:

  • complete (bool) – bool representing whether search for corners is complete

  • frame (ndarray) – new video frame with corners drawn

save_outputs()[source]

Saves matrices to csv

class EdiHeadyTrack.camera.Camera[source]

A class used to represent a Camera.

focal_length

float representing the focal length of the Camera in mm

Type:

float

internal_matrix

array representing the Camera’s intrinsic parameters

Type:

ndarray

distortion_matrix

array representing the Camera’s lens distortion parameters

Type:

ndarray

calibrator

Calibrator object used for camera calibration

Type:

Calibrator

calibrated

bool for quick checking if camera has been calibrated

Type:

bool

video

Video object where the footage has been shot using this Camera

Type:

Video

calibrate(checkerboard=(9,6), video=Video()):

Performs calibration on the camera

calibrate(checkerboard=(9, 6), video=<EdiHeadyTrack.video.Video object>, show=True)[source]

Creates a calibrator object and calibrates the Camera.

If arguments checkerboard and video aren’t passed in, the default checkerboard pattern and an empty video are used.

Parameters:
  • checkerboard (tuple, optional) – Checkerboard pattern used in camera calibration (default is 9x6)

  • video (Video, optional) – Video used to calibrate camera

class EdiHeadyTrack.camera.Checkerboard(dimensions=(9, 6))[source]

A class used to represent a calibration Checkerboard

dimensions

tuple of checkerboard pattern dimensions

Type:

tuple

min_points

integer threshold of minimum detected points for checkerboard to be considered found

Type:

int

objectp3d

array of checkerboard points in three dimensions

Type:

ndarray

threedpoints

list of checkerboard points in three dimensions for each frame where a checkerboard is found

Type:

list

twodpoints

list of detected checkerboard points in two dimensions for each frame

Type:

list

get_corners(gray_frame)[source]

Finds checkerboard corners in a given grayscale frame

get_corners(gray_frame)[source]

Looks for checkerboard corners in a given grayscale video frame.

Parameters:

gray_frame (ndarray) – ndarray representing grayscale frame from video

Returns:

  • ret (bool) – bool representing if corner search was successful

  • corners (ndarray) – ndarray containing coordinates of corners

facedetector

imu

class EdiHeadyTrack.imu.Wax9(filename, time_offset=0, id=False)[source]

A class representing a Wax9 IMU: https://axivity.com/downloads/wax9

columns

list of sensor data column headings

Type:

list

extract_from_file()[source]

Extracts kinematic data from file provided

extract_from_file()[source]

Extracts kinematic data from file provided

filter

class EdiHeadyTrack.filter.Filter[source]

A class used to represent a Filter for data

a

denominator polynomial of the IIR filter

Type:

ndarray

b

numerator polynomial of the IIR filter

Type:

ndarray

More information on IIR filters here
https
Type:

//en.wikipedia.org/wiki/Infinite_impulse_response

low_pass_butterworth(fs=4000, lowcut=160, order=4)[source]

creates a low pass butterworth filter

apply(signal)[source]

applies filter to a given signal

apply(signal)[source]

Applies filter to a signal

Parameters:

signal (list) – signal for filter to be applied to

Returns:

filtered_signal – new filtered signal

Return type:

list

low_pass_butterworth(fs=4000, lowcut=160, order=4)[source]

Creates a low pass butterworth filter

Parameters:
  • fs (float, optional) – sampling frequency (default 4000Hz)

  • lowcut (float, optional) – lowcut frequency (default 160Hz)

  • order (int, optional) – order of the filter (default 4)

Return type:

self

sensordata

class EdiHeadyTrack.sensordata.Head(posedetector=<EdiHeadyTrack.posedetector.PoseDetector object>, id=0)[source]

A class used to represent a Head obtained using head pose estimation techniques

posedetector

the PoseDetector object used to find the Head

Type:

PoseDetector

filter

Filter object used for data filtering

Type:

Filter

id

unique identifier given to Head

Type:

str, int, float

pose

dict containing Head pose time history

Type:

dict

apply_filter(filter)[source]

applies filter to head pose data

calculate_kinematics()[source]

calculates kinematic data from pose time history

calculate_pose()

computes HeadPose from detected facial landmarks

apply_filter(filter=<EdiHeadyTrack.filter.Filter object>)[source]

Applies filter to head pose data and updates pose

Parameters:

filter (Filter, optional) – Filter object used to filter data (default Filter())

Return type:

self

calculate_kinematics()[source]

Calculates kinematic data from pose time history

to_csv()[source]

Saves current time-series of pose, velocity and acceleration data to cs

class EdiHeadyTrack.sensordata.IMU(filename=None, time_offset=0, id=0)[source]

A class used to represent an IMU

filename

file containing IMU sensor data

Type:

str

id

unique identifier given to IMU

Type:

int, float, str

time_offset

time offset applied to IMU data to sync with head pose data

Type:

float

apply_filter(filter=<EdiHeadyTrack.filter.Filter object>)[source]

Applies filter to sensor data and updates

Parameters:

filter (Filter, optional) – Filter object used to filter data (default Filter())

Return type:

self

class EdiHeadyTrack.sensordata.SensorData[source]

A class representing SensorData

velocity

time history of rotational velocities

Type:

dict

acceleration

time history of rotational accelerations

Type:

dict

plot

class EdiHeadyTrack.plot.Plot(*sensors)[source]

A class representing a Plot

colors

list of colors used in plots

Type:

list

sensors

list of SensorData objects to be plotted

Type:

list, SensorData

lines

list of dicts containing data of each line being plotted

Type:

list, dict

plot_property(self, property='velocity', xlim=None, ylim=None, key_times=[], show=True):

plots a time comparison between sensor data

plot_property(xproperty='frame', yproperty='velocity', xlim=None, ylim=None, key_times=[], key_frames=[], show=True)[source]

Plots comparison between sensor data

Parameters:
  • xproperty (str) – specifies which property to be plotted on x axis from (‘frame’, ‘time’)

  • yproperty (str) – specifies which property to be plotted on y axis from (‘pose’, ‘velocity’, ‘acceleration’)

  • xlim (tuple, float) – range of times to be plotted over (lower limit, upper limit)

  • ylim (tuple, float) – range of y values to be plotted over (lower limit, upper limit)

  • key_times (list, float, optional) – key time points to display frame images for

  • key_frames (list, float, optional) – key frame numbers to display frame images for

  • *sensors (SensorData) – sensor data objects to be added to plot

summarise()[source]

Produces a summary of the maximum values of each line in a Plot object.