c3d.Writer¶
-
class
c3d.
Writer
(point_rate=480.0, analog_rate=0.0, point_scale=-1.0, point_units=u'mm ', gen_scale=1.0)¶ This class writes metadata and frames to a C3D file.
For example, to read an existing C3D file, apply some sort of data processing to the frames, and write out another C3D file:
>>> r = c3d.Reader(open('data.c3d', 'rb')) >>> w = c3d.Writer() >>> w.add_frames(process_frames_somehow(r.read_frames())) >>> with open('smoothed.c3d', 'wb') as handle: >>> w.write(handle)
Parameters: - point_rate : float, optional
The frame rate of the data. Defaults to 480.
- analog_rate : float, optional
The number of analog samples per frame. Defaults to 0.
- point_scale : float, optional
The scale factor for point data. Defaults to -1 (i.e., “check the POINT:SCALE parameter”).
- point_units : str, optional
The units that the point numbers represent. Defaults to
'mm '
.- gen_scale : float, optional
General scaling factor for data. Defaults to 1.
-
__init__
(point_rate=480.0, analog_rate=0.0, point_scale=-1.0, point_units=u'mm ', gen_scale=1.0)¶ Set metadata for this writer.
Methods
__init__
([point_rate, analog_rate, …])Set metadata for this writer. add_frames
(frames)Add frames to this writer instance. add_group
(group_id, name, desc)Add a new parameter group. check_metadata
()Ensure that the metadata in our file is self-consistent. first_frame
()get
(group[, default])Get a group or parameter. get_bytes
(key)Get a parameter value as a byte string. get_float
(key)Get a parameter value as a 32-bit float. get_int16
(key)Get a parameter value as a 16-bit signed integer. get_int32
(key)Get a parameter value as a 32-bit signed integer. get_int8
(key)Get a parameter value as an 8-bit signed integer. get_string
(key)Get a parameter value as a string. get_uint16
(key)Get a parameter value as a 16-bit unsigned integer. get_uint32
(key)Get a parameter value as a 32-bit unsigned integer. get_uint8
(key)Get a parameter value as an 8-bit unsigned integer. last_frame
()parameter_blocks
()Compute the size (in 512B blocks) of the parameter section. write
(handle)Write metadata and point + analog frames to a file handle. Attributes
analog_labels
analog_rate
analog_used
point_labels
point_rate
point_scale
point_used
-
add_frames
(frames)¶ Add frames to this writer instance.
Parameters: - frames : sequence of (point, analog) tuples
A sequence of frame data to add to the writer.
-
write
(handle)¶ Write metadata and point + analog frames to a file handle.
Parameters: - handle : file
Write metadata and C3D motion frames to the given file handle. The writer does not close the handle.