Handwritten Data

Representation of a recording of on-line handwritten data. On-line means that the pen trajectory is given (and not online as in ‘Internet’).

class hwrt.HandwrittenData.HandwrittenData(raw_data_json, formula_id=None, raw_data_id=None, formula_in_latex=None, wild_point_count=0, missing_stroke=0, user_id=0)

Represents a handwritten symbol.

count_single_dots()

Count all strokes of this recording that have only a single dot.

feature_extraction(algorithms)

Get a list of features.

Every algorithm has to return the features as a list.

get_area()

Get the area in square pixels of the recording.

get_bounding_box()

Get the bounding box of a pointlist.

get_center_of_mass()

Get a tuple (x,y) that is the center of mass. The center of mass is not necessarily the same as the center of the bounding box. Imagine a black square and a single dot wide outside of the square.

get_height()

Get the height of the rectangular, axis-parallel bounding box.

get_pointlist()

Get a list of lists of tuples from JSON raw data string. Those lists represent strokes with control points.

Every point is a dictionary: {‘x’: 123, ‘y’: 42, ‘time’: 1337}

get_sorted_pointlist()

Make sure that the points and strokes are in order.

get_time()

Get the time in which the recording was created.

get_width()

Get the width of the rectangular, axis-parallel bounding box.

preprocessing(algorithms)

Apply preprocessing algorithms.

>>> a = HandwrittenData(...)
>>> preprocessing_queue = [(preprocessing.scale_and_shift, []),                                    (preprocessing.connect_strokes, []),                                    (preprocessing.douglas_peucker,                                     {'EPSILON': 0.2}),                                    (preprocessing.space_evenly,                                     {'number': 100,                                      'KIND': 'cubic'})]
>>> a.preprocessing(preprocessing_queue)
set_pointlist(pointlist)

Overwrite pointlist. :param pointlist: The inner lists represent strokes. Every stroke

consists of points. Every point is a dictinary with ‘x’, ‘y’, ‘time’.
show()

Show the data graphically in a new pop-up window.