dispel.providers.generic.touch module#
The touch module provides general abstraction classes to handle touch events.
Touch events are represented in Touchs and Gestures that
represent one consecutive interaction (touch down to touch up) and overlapping
interactions, respectively.
- class dispel.providers.generic.touch.Gesture[source]#
Bases:
objectA collection of overlapping
Touchinteractions.- TOUCH_CLS#
The class used to create touches in
touch_factory().alias of
Touch
- property dwell_time: timedelta#
Get the dwell time of the gesture.
- Returns:
The time spent between the first touch on the screen and the first movement made after that.
- Return type:
- classmethod from_data_frame(data, **kwargs)[source]#
Create gestures from a data frame.
- Parameters:
data (DataFrame) – A data frame containing touch events.
kwargs – Additional key word arguments passed to
Gesture.gesture_factory().
- Returns:
A sequence of gestures based on the provided
data. The data frame is split according to thetouchPathIdinto separate touch interactions. Consecutively overlapping touches are combined as gestures.- Return type:
List[Gesture]
- classmethod gesture_factory(touches, **kwargs)[source]#
Get a gesture instance for a list of touches.
This method can be overwritten by inheriting classes to customize how gestures are constructed.
- Parameters:
touches (Sequence[Touch]) – The results from the touch factory. See
touch_factory()for details.kwargs – Additional key word arguments for overridden methods to eventually use.
- Returns:
The gesture representing the passed
Touchobjects intouches.- Return type:
- property movement_begin: datetime#
Get the start of the movement for the gesture.
- Returns:
The date time of the first recorded movement of the gesture.
- Return type:
- dispel.providers.generic.touch.TOUCH_ACTIONS = namespace(up='up', down='down', move='move')#
List of possible touch actions.
- dispel.providers.generic.touch.TOUCH_COLUMNS = ['xPosition', 'yPosition', 'touchAction', 'tsTouch', 'touchPathId', 'pressure']#
The valid column names to use the touch module.’
- class dispel.providers.generic.touch.Touch[source]#
Bases:
objectA consecutive interaction with the screen.
The
Touchrepresents the touch events of one consecutive interaction with the screen from the firstdownaction until theupaction.- __init__(data, pointer=UnknownPointer(index=0))#
- Parameters:
data (dataclasses.InitVar[DataFrame]) –
pointer (Pointer) –
- Return type:
None
- property acceleration: Series#
Get the pointer acceleration during the interaction.
- Returns:
The change of velocity over time.
- Return type:
- property begin: datetime#
Get the start of the touch.
- Returns:
The date time of the first touch event
- Return type:
- data: dataclasses.InitVar[DataFrame]#
- property displacements: DataFrame#
Get the displacements per touch event.
- Returns:
Returns the changes in position in x and y direction at each touch event.
- Return type:
- property duration: timedelta#
Get the duration of the touch.
- Returns:
The duration of the touch interaction from its start to its end.
- Return type:
- property end: datetime#
Get the end of the touch.
- Returns:
The date time of the last touch event
- Return type:
- property has_major_radius#
Has major radius measurements.
- property has_pressure: bool#
Has the interaction pressure information.
- Returns:
Trueif pressure information is available. Otherwise,False- Return type:
- property initial_pressure: float#
Get the initially exerted pressure of the pointer.
- Returns:
The pressure exerted on the screen upon initiation of the interaction. If the first reading was
0the subsequent one will be returned.- Return type:
- property is_incomplete: bool#
Is the interaction incomplete.
- Returns:
Returns
Trueif either thedownorupaction is not observed. Otherwise,False.- Return type:
- property jerk: Series#
Get the pointer jerk during the interaction.
- Returns:
The change of acceleration over time.
- Return type:
- property length: float#
Get the length of the interaction.
- Returns:
The length of the interaction based on the sum of euclidean norm vector of displacements.
- Return type:
- property mean_squared_jerk#
Get the average squared jerk.
- Returns:
The average squared jerk.
- Return type:
- property mean_squared_pressure_jerk#
Get the average squared jerk of the applied pressure.
- Returns:
The average squared jerk of the applied pressure.
- Return type:
- property movement_begin: datetime#
Get the start of the movement for the touch.
- Returns:
The date time of the first recorded movement of the touch.
- Return type:
- property positions: DataFrame#
Get the x and y coordinates of the touch interactions.
- Returns:
A data frame with two columns
XPositionandyPositionand the time points as index.- Return type:
- property pressure: Series#
Get the pressure information associated with the touch.
- Returns:
The pressure values excluding
0-values at the very first reading.- Return type:
- property pressure_acceleration: Series#
Get the pressure acceleration.
- Returns:
The second derivative of the pressure information.
- Return type:
- property pressure_change: Series#
Get the pressure change.
- Returns:
The first derivative of the pressure information.
- Return type:
- property pressure_jerk: Series#
Get the pressure jerk.
- Returns:
The change of pressure acceleration over time.
- Return type:
- property speed: Series#
Get the pointer speed of the interaction.
- Returns:
The change in position over time.
- Return type:
- property time_deltas: Series#
Get the time differences between consecutive touch events.
- Returns:
Returns a series of time differences in milliseconds between consecutive touch events with the index based on the touch event time stamp.
- Return type:
- to_segments()[source]#
Get multi-segment representation of the touch interaction.
- Return type:
Multisegment
- class dispel.providers.generic.touch.UnknownPointer[source]#
Bases:
PointerUnknown pointer reference.
This pointer can be used if the pointer is unknown.
- dispel.providers.generic.touch.reassign_touch_path_id(data)[source]#
Reassign touch path ids.
Touch path ids are sometimes mixed when there are no fingers on the screen. This function makes sure consecutive touches are assigned ascending new ids.
- dispel.providers.generic.touch.split_touches(raw_data, begin, end)[source]#
Split touch events.
This function reassign the touch path ids of raw touch events in a data frame by making sure that the path ids are unique and given in ascending order. One can also filter the input sequence by specifying the start and end timestamp.