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.handwritten_data.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, user_name='', segmentation=None)

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.

fix_times()

Some recordings have wrong times. Fix them so that nothing after loading a handwritten recording breaks.

get_area()

Get the area in square pixels of the recording.

get_bitmap(time=None, size=32, store_path=None)

Get a bitmap of the object at a given instance of time. If time is None,`then the bitmap is generated for the last point in time.

Parameters:

time : int or None

size : int

Size in pixels. The resulting bitmap will be (size x size).

store_path : None or str

If this is set, then the image will be saved there.

Returns:

numpy array :

Greyscale png image

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.

Returns:

list :

A list of strokes. Each stroke 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.

Parameters:

algorithms : a list objects

Preprocessing allgorithms which get applied in order.

Examples

>>> import preprocessing
>>> 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.

Parameters:

pointlist : a list of strokes; each stroke is a list of points

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.

to_single_symbol_list()

Convert this HandwrittenData object into a list of HandwrittenData objects. Each element of the list is a single symbol.

Returns:list of HandwrittenData objects

Previous topic

Configuration

Next topic

Preprocessing

This Page