handwriting_sample.transformer package
Submodules
handwriting_sample.transformer.exceptions module
- exception handwriting_sample.transformer.exceptions.TransformerAngleTypeException(angle_type)[source]
Bases:
TransformerExceptionException raised for errors in the input angle type.
- Attributes:
angle_type – input angle_type which caused the error message – explanation of the error
- exception handwriting_sample.transformer.exceptions.TransformerException(message)[source]
Bases:
Exception,HandwritingDataBaseBase class for TransformerException
handwriting_sample.transformer.interface module
- class handwriting_sample.transformer.interface.HandwritingSampleTransformer[source]
Bases:
HandwritingDataBaseClass implementing handwriting data transformer
- CM_TO_MM = 10
- INCH_TO_MM = 25.4
- LPI = 'lpi'
- LPI_VALUE = 5080
- LPMM = 'lpmm'
- LPMM_VALUE = 200
- MAX_AZIMUTH_DEGREE = 360
- MAX_AZIMUTH_VALUE = 3600
- MAX_OLD_RANGE_PRESSURE = 1024
- MAX_PRESSURE_VALUE = 32767
- MAX_TILT_DEGREE = 90
- MAX_TILT_VALUE = 900
- MM = 'mm'
- MM_VALUE = 0.01
- PRESSURE_LEVELS = 8192
- control_for_pressure(input_array, pressure_levels=8192, max_raw_press_value=32767, max_range_press=1024)[source]
Controls for pressure range values.
This function is a fix pressure function in case the old driver has been used Old pressure range is from 0-1024 New and correct pressure range is 0-32767
- Parameters
input_array (np.array) – input pressure data
pressure_levels (int) – OPTIONAL - level of pressures of the device. DEFAULT = 8192
max_raw_press_value (int) – OPTIONAL - maximum theoretical value of pressure. DEFAULT = 32767
max_range_press (int) – OPTIONAL - maximum allowed pressure range of raw data. DEFAULT = 1024
- Returns
converted pressure to new scale
- Return type
np.array
- static correct_pen_status(sample)[source]
Corrects pen status values to binary form
- Parameters
sample (handwriting_sample.HandwritingSample) – updated object of HandwritingSample class
- Returns
instance of HandwritingSample
- Return type
- static normalize_pressure(input_array, max_value=32767, pressure_levels=8192)[source]
Normalizes pressure to pressure level of the device.
- Parameters
input_array (np.array) – Input array with pressure values
max_value (int) – OPTIONAL, DEFAULT = 32767 max theoretical raw pressure value
pressure_levels (int) – OPTIONAL, DEFAULT = 8192 level of pressure of the device
- Returns
array with normalized pressure
- Return type
np.array
- static normalize_time_series(input_array, max_value)[source]
Normalizes input time-series.
- Parameters
input_array (nd.array) – Array of input data
max_value (int) – max heoretical value
- Returns
Normalized data
- Return type
list
- static rescale_axis(sample, rescale_coef=0.5)[source]
Rescale axis values
- Parameters
sample (handwriting_sample.HandwritingSample) – updated object of HandwritingSample class
rescale_coef (float) – OPTIONAL - Coefficient of rescaling, DEFAULT = 0.5
- Returns
handwriting sample with rescaled axis
- Return type
handwriting_sample.HandwritingSample
- static revert_axis(input_array, axis_max_value)[source]
Revert axis
- Parameters
input_array (np.array) – Input array with raw angle values
- Returns
reverted axis
- Return type
nd.array
- transform_all_units(sample, conversion_type='lpi', lpi_value=5080, lpmm_value=200, max_raw_azimuth=3600, max_raw_tilt=900, max_degree_azimuth=360, max_degree_tilt=90, max_pressure=32767, pressure_levels=8192, angles_to_degrees=True, shift_to_zero=True)[source]
- Transforms all unites of sample object:
transforms X,Y to millimeters.
transform time to seconds
normalize or transform to degrees angles
normalize pressure
- Parameters
sample (handwriting_sample.HandwritingSample) – updated object of HandwritingSample class
conversion_type (str) – OPTIONAL [“lpi”|”lpmm”|”mm”], DEFAULT=”lpi”. Set the capturing method used for mapping; “lpi” for inch; “lpmm” for millimeters; “mm” for direct to millimeters
lpi_value (int) – OPTIONAL , DEFAULT = 5080 Set lpi value of digitizing tablet.
lpmm_value (int) – OPTIONAL, DEFAULT = 200 Set lpmm value of digitizing tablet.
max_raw_azimuth (int) – OPTIONAL, DEFAULT = 3600 Maximum theoretical value of azimuth.
max_raw_tilt (int) – OPTIONAL, DEFAULT = 900 Maximum theoretical value of tilt.
max_degree_azimuth (int) – OPTIONAL, DEFAULT = 360 Maximum degree value of azimuth.
max_degree_tilt (int) – OPTIONAL, DEFAULT = 90 Maximum degree value of tilt.
max_pressure (int) – OPTIONAL, DEFAULT = 32767 Maximum theoretical value of pressure.
pressure_levels (int) – OPTIONAL, DEFAULT = 8192 Level of pressures of the device.
angles_to_degrees (bool) – OPTIONAL, DEFAULT = True Transform angles to degrees
shift_to_zero (bool) – OPTIONAL, DEFAULT = True Shift axis values to start from 0,0 coordinates
- Returns
updated object of HandwritingSample class
- Return type
handwriting_sample.HandwritingSample
- static transform_angle(input_array, max_raw_value, max_degree_value)[source]
Transforms raw angle to degrees.
- Parameters
input_array (np.array) – Input array with raw angle values
max_raw_value (int) – Maximal theoretical value of raw angle
max_degree_value (int) – Maximal value of angle in degrees
- Returns
angle in degrees
- Return type
nd.array
- transform_axis(sample, conversion_type='lpi', lpi_value=5080, lpmm_value=200, shift_to_zero=True)[source]
Transforms X,Y axis to millimeters.
- Parameters
sample (handwriting_sample.HandwritingSample) – object of HandwritingSample class
conversion_type (str) – OPTIONAL [“lpi”|”lpmm”|”mm”], DEFAULT=”lpi”. Set the capturing method used for mapping; “lpi” for inch; “lpmm” for millimeters; “mm” for direct to millimeters
lpi_value (int) – OPTIONAL, DEFAULT = 5080 Set lpi value of digitizing tablet
lpmm_value (int) – OPTIONAL, DEFAULT = 200 Set lpmm value of digitizing tablet
shift_to_zero (bool) – OPTIONAL, DEFAULT = True Shift axis values to start from 0,0 coordinates
- Returns
updated object of HandwritingSample class
- Return type
handwriting_sample.HandwritingSample