Database API

ClickPoints comes with a powerful API which enables access from within python to ClickPoints Projects which are stored in a .cdb ClickPoints SQLite database.

To get started reading and writing to a database use:

1import clickpoints
2db = clickpoints.DataFile("project.cdb")

This will open an existing project file called project.cdb.

Note

The Examples section demonstrates the use of the API with various examples and provides a good starting point to write custom evaluations.

Database Models

The .cdb file consists of multiple SQL tables in which it stores its information. Each table is represented in the API as a peewee model. Users which are not familiar can use the API without any knowledge of peewee, as the API provides all functions necessary to access the data. For each table a get (retrieve entries), set (add and change entries) and delete (remove entries) function is provided. Functions with a plural name always work on multiple entries at once and all arguments can be provided as single values or arrays if multiple entries should be affected.

The tables are: Meta, Path, Layer, Image, Offset, Track, MarkerType, Marker, Line, Rectangle, Ellipse, Polygon, Mask, MaskType, Annotation, Tag, TagAssociation.

class Meta

Stores key value pairs containing meta information for the ClickPoints project.

Attributes:
  • key (str, unique) - the key

  • value (str) - the value for the key

class Path

Stores a path. Referenced by each image entry.

See also: getPath(), getPaths(), setPath(), deletePaths().

Attributes:
  • path (str, unique) - the path

  • images (list of Image ) - the images with this path.

class Image

Stores an image.

See also: getImage(), getImages(), getImageIterator(), setImage(), deleteImages().

Attributes:
  • filename (str, unique) - the name of the file.

  • ext (str) - the extension of the file.

  • frame (int) - the frame of the file (0 for images, >= 0 for images from videos).

  • external_id (int) - the id of the file entry of a corresponding external database. Only used when ClickPoints is started from an external database.

  • timestamp (datetime) - the timestamp associated to the image.

  • sort_index (int, unique) - the index of the image. The number shown in ClickPoints next to the time line.

  • width (int) - None if it has not be set, otherwise the width of the image.

  • height (int) - None if it has not be set, otherwise the height of the image.

  • path ( Path ) - the linked path entry containing the path to the image.

  • layer (int) - the id separating different kinds of images for the same sort_index.

  • offset ( Offset ) - the linked offset entry containing the offsets stored for this image.

  • annotation ( Annotation ) - the linked annotation entry for this image.

  • markers (list of Marker ) - a list of marker entries for this image.

  • lines (list of Line ) - a list of line entries for this image.

  • rectangles (list of Rectangle ) - a list of rectangle entries for this image.

  • mask ( Mask ) - the mask entry associated with the image.

  • data (array) - the image data as a numpy array. Data will be loaded on demand and cached.

  • data8 (array, uint8) - the image data converted to unsigned 8 bit integers.

  • getShape() (list) - a list containing height and width of the image. If they are not stored in the database yet, the image data has to be loaded.

class Offset

Offsets associated with an image.

See also: setOffset(), deleteOffsets().

Attributes:
  • image ( Image ) - the associated image entry.

  • x (int) - the x offset

  • y (int) - the y offset

class Layer

Stores the name of a layer. Referenced by each image entry.

See also: getLayer(), getLayers(), setLayer(), deleteLayers().

Attributes:
  • name (str, unique) - the name of the layer

  • images (list of Image ) - the images with this layer.

class Track

A track containing multiple markers.

See also: getTrack(), getTracks(), setTrack(), deleteTracks(), getTracksNanPadded().

Attributes:
  • style (str) - the style for this track.

  • text (str) - an additional text associated with this track. It is displayed next to the markers of this track in ClickPoints.

  • hidden (bool) - whether the track should be displayed in ClickPoints.

  • points (array) - an Nx2 array containing the x and y coordinates of the associated markers.

  • points_corrected (array) - an Nx2 array containing the x and y coordinates of the associated markers corrected by the offsets of the images.

  • markers (list of Marker ) - a list containing all the associated markers.

  • times (list of datetime) - a list containing the timestamps for the images of the associated markers.

  • frames (list of int) - a list containing all the frame numbers for the images of the associated markers.

  • image_ids (list of int) - a list containing all the ids for the images of the associated markers.

Methods:
split(marker)

Split the track after the given marker and create a new track which contains all the markers after the given marker.

Parameters:
  • marker (int, Marker ) - the marker id or marker entry at which to split.

Returns:
  • new_track ( Track ) - the new track which contains the markers after the given marker.

removeAfter(marker)

Remove all the markers from the track after the given marker.

Parameters:
  • marker (int, Marker ) - the marker id or marker entry after which to remove markers.

Returns:
  • count (int) - the amount of deleted markers.

merge(track)

Merge the track with the given track. All markers from the other track are moved to this track. The other track which is then empty will be removed. Only works if the tracks don’t have markers in the same images, as this would cause ambiguities.

Parameters:
  • track (int, Track ) - the track id or track entry whose markers should be merged to this track.

Returns:
  • count (int) - the amount of new markers for this track.

changeType(new_type)

Change the type of the track and its markers to another type.

Parameters:
  • new_type (str, int MarkerType ) - the id, name or entry for the marker type which should be the new type of this track. It has to be of mode TYPE_Track.

Returns:
  • count (int) - the amount of markers that have been changed.

class MarkerType

A marker type.

See also: getMarkerTypes(), getMarkerType(), setMarkerType(), deleteMarkerTypes().

Attributes:
  • name (str, unique) - the name of the marker type.

  • color (str) - the color of the marker in HTML format, e.g. #FF0000 (red).

  • mode (int) - the mode, hast to be either: TYPE_Normal, TYPE_Rect, TYPE_Line or TYPE_Track

  • style (str) - the style of the marker type.

  • text (str) - an additional text associated with the marker type. It is displayed next to the markers of this type in ClickPoints.

  • hidden (bool) - whether the markers of this type should be displayed in ClickPoints.

  • markers (list of Marker ) - a list containing all markers of this type. Only for TYPE_Normal and TYPE_Track.

  • lines (list of Line ) - a list containing all lines of this type. Only for TYPE_Line.

  • markers (list of Rectangle ) - a list containing all rectangles of this type. Only for TYPE_Rect.

class Marker

A marker.

See also: getMarker(), getMarkers(), setMarker(), setMarkers(), deleteMarkers().

Attributes:
  • image ( Image ) - the image entry associated with this marker.

  • x (float) - the x coordinate of the marker.

  • y (float) - the y coordinate of the marker.

  • type ( MarkerType ) - the marker type.

  • processed (bool) - a flag that is set to 0 if the marker is manually moved in ClickPoints, it can be set from an add-on if the add-on has already processed this marker.

  • style (str) - the style definition of the marker.

  • text (str) - an additional text associated with the marker. It is displayed next to the marker in ClickPoints.

  • track ( Track ) - the track entry the marker belongs to. Only for TYPE_Track.

  • correctedXY() (array) - the marker position corrected by the offset of the image.

  • pos() (array) - an array containing the coordinates of the marker: [x, y].

Methods:
changeType(new_type)

Change the type of the marker.

Parameters:
  • new_type (str, int MarkerType ) - the id, name or entry for the marker type which should be the new type of this marker. It has to be of mode TYPE_Normal.

getPixes(shape, perimeter)

Get a row, column tuple to index an image.

Parameters:
  • shape (tuple, optional) - The extent of the image to crop the indices to.

  • perimeter (bool, optional) - Whether to index the area (default) or the perimeter. (Has no effect for single marker points)

class Line

A line.

See also: getLine(), getLines(), setLine(), setLines(), deleteLines().

Attributes:
  • image ( Image ) - the image entry associated with this line.

  • x1 (float) - the first x coordinate of the line.

  • y1 (float) - the first y coordinate of the line.

  • x2 (float) - the second x coordinate of the line.

  • y2 (float) - the second y coordinate of the line.

  • type ( MarkerType ) - the marker type.

  • processed (bool) - a flag that is set to 0 if the line is manually moved in ClickPoints, it can be set from an add-on if the add-on has already processed this line.

  • style (str) - the style definition of the line.

  • text (str) - an additional text associated with the line. It is displayed next to the line in ClickPoints.

  • correctedXY() (array) - the line positions corrected by the offset of the image.

  • pos() (array) - an array containing the coordinates of the line: [x, y].

  • length() (float) - the length of the line in pixel.

  • angle() (float) - the angle of the line to the horizontal in radians.

Methods:
changeType(new_type)

Change the type of the line.

Parameters:
  • new_type (str, int MarkerType ) - the id, name or entry for the marker type which should be the new type of this line. It has to be of mode TYPE_Line.

cropImage(image=None, width=None)

Crop a line of the given image provided by the line. If a width is given, a two dimensional region is cropped from the image, if not a one dimensional array is returned

Parameters:
  • image (ndarray, * :py:class:`Image` *) - the image as a database entry or a numpy array.

  • width (int, optional) - the width of the 2D line to crop from the image.

getPixes(shape, perimeter)

Get a row, column tuple to index an image.

Parameters:
  • shape (tuple, optional) - The extent of the image to crop the indices to.

  • perimeter (bool, optional) - Whether to index the area (default) or the perimeter. (Has no effect for a line)

class Rectangle

A rectangle.

See also: getRectangle(), getRectangles(), setRectangle(), setRectangles(), deleteRectangles().

Attributes:
  • image ( Image ) - the image entry associated with this rectangle.

  • x (float) - the x coordinate of the rectangle.

  • y (float) - the y coordinate of the rectangle.

  • width (float) - the width of the rectangle.

  • height (float) - the height of the rectangle.

  • type ( MarkerType ) - the marker type.

  • processed (bool) - a flag that is set to 0 if the rectangle is manually moved in ClickPoints, it can be set from an add-on if the add-on has already processed this line.

  • style (str) - the style definition of the rectangle.

  • text (str) - an additional text associated with the rectangle. It is displayed next to the rectangle in ClickPoints.

  • correctedXY() (array) - the rectangle positions corrected by the offset of the image.

  • pos() (array) - an array containing the coordinates of the rectangle: [x, y].

  • slice_x(border=0) (slice) - a slice object to use the rectangle to cut out a region of an image

  • slice_y(border=0) (slice) - a slice object to use the rectangle to cut out a region of an image

  • slice(border=0) (tuple) - a tuple of a y-slice and an x-slice, border specifies an additional border to slice around the rectangle

  • area() (float) - the area of the rectangle

Methods:
changeType(new_type)

Change the type of the rectangle.

Parameters:
  • new_type (str, int MarkerType ) - the id, name or entry for the marker type which should be the new type of this rectangle. It has to be of mode TYPE_Rect.

cropImage(image=None, with_offset=True, with_subpixel=True, border=0)

Crop a region of the given image provided by the rectangle.

Parameters:
  • image (ndarray, * :py:class:`Image` *) - the image as a database entry or a numpy array.

  • with_offset (bool) - whether to apply the offset of the image. Default True.

  • with_subpixel (bool) - whether to apply a subpixel shift for the region. Default True.

  • border (number) - a number of border pixels to add to the region. Default 0.

getPixes(shape, perimeter)

Get a row, column tuple to index an image.

Parameters:
  • shape (tuple, optional) - The extent of the image to crop the indices to.

  • perimeter (bool, optional) - Whether to index the area (default) or the perimeter.

class Ellipse

An ellipse.

See also: getEllipse(), getEllipses(), setEllipse(), setEllipses(), deleteEllipses().

Attributes:
  • image ( Image ) - the image entry associated with this ellipse.

  • x (float) - the x coordinate of the center of the ellipse.

  • y (float) - the y coordinate of the center of the ellipse.

  • width (float) - the width of the ellipse.

  • height (float) - the height of the ellipse.

  • angle (float) - the angle of the ellipse.

  • type ( MarkerType ) - the marker type.

  • processed (bool) - a flag that is set to 0 if the ellipse is manually moved in ClickPoints, it can be set from an add-on if the add-on has already processed this ellipse.

  • style (str) - the style definition of the ellipse.

  • text (str) - an additional text associated with the ellipse. It is displayed next to the ellipse in ClickPoints.

  • center (array) - an array containing the coordinates of the center of the ellipse: [x, y].

  • area (float) - the area of the ellipse

Methods:
changeType(new_type)

Change the type of the ellipse.

Parameters:
  • new_type (str, int MarkerType ) - the id, name or entry for the marker type which should be the new type of this ellipse. It has to be of mode TYPE_Ellipse.

getPixes(shape, perimeter)

Get a row, column tuple to index an image.

Parameters:
  • shape (tuple, optional) - The extent of the image to crop the indices to.

  • perimeter (bool, optional) - Whether to index the area (default) or the perimeter.

class Polygon

A polygon.

See also: getPolygon(), getPolygons(), setPolygon(), deletePolygons().

Attributes:
  • image ( Image ) - the image entry associated with this polygon.

  • points (array) - the points of the vertices of the polygon.

  • type ( MarkerType ) - the marker type.

  • processed (bool) - a flag that is set to 0 if the polygon is manually moved in ClickPoints, it can be set from an add-on if the add-on has already processed this polygon.

  • style (str) - the style definition of the polygon.

  • text (str) - an additional text associated with the polygon. It is displayed next to the polygon in ClickPoints.

  • center (array) - an array containing the coordinates of the center of the polygon: [x, y].

  • area (float) - the area of the polygon.

  • perimeter (float) - the perimeter of the polygon.

Methods:
changeType(new_type)

Change the type of the polygon.

Parameters:
  • new_type (str, int MarkerType ) - the id, name or entry for the marker type which should be the new type of this polygon. It has to be of mode TYPE_Polygon.

getPixes(shape, perimeter)

Get a row, column tuple to index an image.

Parameters:
  • shape (tuple, optional) - The extent of the image to crop the indices to.

  • perimeter (bool, optional) - Whether to index the area (default) or the perimeter.

class Mask

A mask entry.

See also: getMask(), getMasks(), setMask(), deleteMasks().

Attributes:
  • image ( Image ) - the image entry associated with this marker.

  • data (array) - the mask image as a numpy array. Mask types are stored by their index value.

class MaskType

A mask type.

See also: getMaskType(), getMaskTypes(), setMaskType(), deleteMaskTypes().

Attributes:
  • name (str) - the name of the mask type.

  • color (str) - the color of the mask type in HTML format, e.g. #FF0000 (red).

  • index (int) - the integer value used to represent this type in the mask.

class Annotation

An annotation.

See also: getAnnotation(), getAnnotations(), setAnnotation(), deleteAnnotations().

Attributes:
  • image ( Image ) - the image entry associated with this annotation.

  • timestamp (datetime) - the timestamp of the image linked to the annotation.

  • comment (str) - the text of the comment.

  • rating (int) - the value added to the annotation as rating.

  • tags (list of Tag ) - the tags associated with this annotation.

class Tag

A tag for an Annotation.

See also: getTag(), getTags(), setTag(), deleteTags().

Attributes:
  • name (str) - the name of the tag.

  • annotations (list of Annotation ) - the annotations associated with this tag.

class TagAssociation

A link between a Tag and an Annotation

Attributes:
  • annotation ( Annotation ) - the linked annotation.

  • tag ( Tag ) - the linked tag.

DataFile

The DataFile is the interface to the ClickPoints database. This can either be used in external evaluation scripts that take data clicked in ClickPoints for further evaluation or in add-on scripts where it is accessible through the self.db class variable.

class clickpoints.DataFile(database_filename=None, mode='r')[source]

The DataFile class provides access to the .cdb file format in which ClickPoints stores the data for a project.

Parameters
  • database_filename (string) – the filename to open

  • mode (string, optional) – can be ‘r’ (default) to open an existing database and append data to it or ‘w’ to create a new database. If the mode is ‘w’ and the database already exists, it will be deleted and a new database will be created.

deleteAnnotations(image=None, frame=None, filename=None, timestamp=None, comment=None, rating=None, id=None)[source]

Delete all Annotation entries with the given criteria.

See also: getAnnotation(), getAnnotations(), setAnnotation().

Parameters
  • image (int, Image, array_like, optional) – the image/images for which the annotations should be retrieved. If omitted, frame numbers or filenames should be specified instead.

  • frame (int, array_like, optional) – frame number/numbers of the images, which annotations should be returned. If omitted, images or filenames should be specified instead.

  • filename (string, array_like, optional) – filename of the image/images, which annotations should be returned. If omitted, images or frame numbers should be specified instead.

  • timestamp (datetime, array_like, optional) – timestamp/s of the annotations.

  • comment (string, array_like, optional) – the comment/s of the annotations.

  • rating (int, array_like, optional) – the rating/s of the annotations.

  • id (int, array_like, optional) – id/ids of the annotations.

Returns

rows – the number of affected rows.

Return type

int

deleteEllipses(image=None, frame=None, filename=None, x=None, y=None, width=None, height=None, angle=None, type=None, processed=None, text=None, id=None, layer=None)[source]

Delete all Ellipse entries with the given criteria.

See also: getEllipse(), getEllipses(), setEllipse(), setEllipses().

Parameters
  • image (int, Image, array_like, optional) – the image/s of the ellipses.

  • frame (int, array_like, optional) – the frame/s of the images of the ellipses.

  • filename (string, array_like, optional) – the filename/s of the images of the ellipses.

  • x (int, array_like, optional) – the x coordinate/s of the center/s of the ellipses.

  • y (int, array_like, optional) – the y coordinate/s of the center/s of the ellipses.

  • width (int, array_like, optional) – the width/s of the ellipses.

  • height (int, array_like, optional) – the height/s of the ellipses.

  • angle (int, array_like, optional) – the angle/s of the ellipses in degrees.

  • type (string, MarkerType, array_like, optional) – the marker type/s (or name/s) of the ellipses.

  • processed (int, array_like, optional) – the processed flag/s of the ellipses.

  • text (string, array_like, optional) – the text/s of the ellipses.

  • id (int, array_like, optional) – the id/s of the ellipses.

Returns

rows – the number of affected rows.

Return type

int

deleteImages(filename=None, path=None, frame=None, external_id=None, timestamp=None, width=None, height=None, id=None, layer=None)[source]

Delete all Image entries with the given criteria.

See also: getImage(), getImages(), getImageIterator(), setImage().

Parameters
  • filename (string, array_like, optional) – the filename/filenames of the image (including the extension)

  • path (string, int, Path, array_like optional) – the path string, id or entry of the image to insert

  • frame (int, array_like, optional) – the number/numbers of frames the images have

  • external_id (int, array_like, optional) – an external id/ids for the images. Only necessary if the annotation server is used

  • timestamp (datetime object, array_like, optional) – the timestamp/timestamps of the images

  • width (int, array_like, optional) – the width/widths of the images

  • height (int, optional) – the height/heights of the images

  • id (int, array_like, optional) – the id/ids of the images

  • layer (int, array_like, optional) – the layer/layers of the images

Returns

rows – the number of affected rows.

Return type

int

deleteLayers(layer_name=None, base_layer=None, id=None)[source]

Delete all Layer entries with the given criteria.

See also: getLayer(), getLayers(), setLayer()

Parameters
  • layer_name (string, optional) – the string/s specifying the name/s of the layer/s.

  • base_layer (int, Layer, optional) – the base layer to which this layer should reference.

  • id (int, optional) – the id/s of the layers.

Returns

rows – the number of affected rows.

Return type

int

deleteLines(image=None, frame=None, filename=None, x1=None, y1=None, x2=None, y2=None, type=None, processed=None, text=None, id=None)[source]

Delete all Line entries with the given criteria.

See also: getLine(), getLines(), setLine(), setLines().

Parameters
  • image (int, Image, array_like, optional) – the image/s of the lines.

  • frame (int, array_like, optional) – the frame/s of the images of the lines.

  • filename (string, array_like, optional) – the filename/s of the images of the lines.

  • x1 (int, array_like, optional) – the x coordinate/s of the start of the lines.

  • y1 (int, array_like, optional) – the y coordinate/s of the start of the lines.

  • x2 (int, array_like, optional) – the x coordinate/s of the end of the lines.

  • y2 (int, array_like, optional) – the y coordinate/s of the end of the lines.

  • type (string, MarkerType, array_like, optional) – the marker type/s (or name/s) of the lines.

  • processed (int, array_like, optional) – the processed flag/s of the lines.

  • text (string, array_like, optional) – the text/s of the lines.

  • id (int, array_like, optional) – the id/s of the lines.

Returns

rows – the number of affected rows.

Return type

int

deleteMarkerTypes(name=None, color=None, mode=None, text=None, hidden=None, id=None)[source]

Delete all MarkerType entries from the database, which match the given criteria.

See also: getMarkerType(), getMarkerTypes(), setMarkerType().

Parameters
  • name (str, array_like, optional) – the name of the type

  • color (str, array_like, optional) – hex code string for rgb color of style “#00ff3f”

  • mode (int, array_like, optional) – mode of the marker type (marker 0, rect 1, line 2, track 4)

  • text (str, array_like, optional) – display text

  • hidden (bool, array_like, optional) – whether the types should be displayed in ClickPoints

  • id (int, array_like, optional) – id of the MarkerType object

Returns

entries – nr of deleted entries

Return type

int

deleteMarkers(image=None, frame=None, filename=None, x=None, y=None, type=None, processed=None, track=None, text=None, id=None, layer=None)[source]

Delete all Marker entries with the given criteria.

See also: getMarker(), getMarkers(), setMarker(), setMarkers().

Parameters
  • image (int, Image, array_like, optional) – the image/s of the markers.

  • frame (int, array_like, optional) – the frame/s of the images of the markers.

  • filename (string, array_like, optional) – the filename/s of the images of the markers.

  • x (int, array_like, optional) – the x coordinate/s of the markers.

  • y (int, array_like, optional) – the y coordinate/s of the markers.

  • type (string, MarkerType, array_like, optional) – the marker type/s (or name/s) of the markers.

  • processed (int, array_like, optional) – the processed flag/s of the markers.

  • track (int, Track, array_like, optional) – the track id/s or instance/s of the markers.

  • text (string, array_like, optional) – the text/s of the markers.

  • id (int, array_like, optional) – the id/s of the markers.

Returns

rows – the number of affected rows.

Return type

int

deleteMaskTypes(name=None, color=None, index=None, id=None)[source]

Delete all MaskType entries from the database, which match the given criteria.

See also: getMaskType(), getMaskTypes(), setMaskType().

Parameters
  • name (string, array_like, optional) – the name/names of the mask types.

  • color (string, array_like, optional) – the color/colors of the mask types.

  • index (int, array_like, optional) – the index/indices of the mask types, which is used for painting this mask types.

  • id (int, array_like, optional) – the id/ids of the mask types.

deleteMasks(image=None, frame=None, filename=None, id=None, layer=None)[source]

Delete all Mask entries with the given criteria.

See also: getMask(), getMasks(), setMask().

Parameters
  • image (int, Image, array_like, optional) – the image/images for which the mask should be deleted. If omitted, frame numbers or filenames should be specified instead.

  • frame (int, array_like, optional) – frame number/numbers of the images, which masks should be deleted. If omitted, images or filenames should be specified instead.

  • filename (string, array_like, optional) – filename of the image/images, which masks should be deleted. If omitted, images or frame numbers should be specified instead.

  • id (int, array_like, optional) – id/ids of the masks.

  • layer (int, array_like, optional) – layer/layers of the images, which masks should be deleted. Always use with frame!

deleteOffsets(image=None)[source]

Delete all Offset entries from the database, which match the given criteria. If no criteria a given, delete all.

See also: setOffset().

Parameters

image (int, Image, array_like, optional) – the image/s for which the offset should be deleted.

Returns

rows – number of rows deleted

Return type

int

deletePaths(path_string=None, base_path=None, id=None)[source]

Delete all Path entries with the given criteria.

See also: getPath(), getPaths(), setPath()

Parameters
  • path_string (string, optional) – the string/s specifying the paths.

  • base_path (string, optional) – return only paths starting with the base_path string.

  • id (int, optional) – the id/s of the paths.

Returns

rows – the number of affected rows.

Return type

int

deletePolygons(image=None, frame=None, filename=None, type=None, processed=None, text=None, id=None, layer=None)[source]

Delete all Polygon entries with the given criteria.

See also: getPolygon(), getPolygons(), setPolygon(), setPolygons().

Parameters
  • image (int, Image, array_like, optional) – the image/s of the polygons.

  • frame (int, array_like, optional) – the frame/s of the images of the polygons.

  • filename (string, array_like, optional) – the filename/s of the images of the polygons.

  • type (string, MarkerType, array_like, optional) – the marker type/s (or name/s) of the polygons.

  • processed (int, array_like, optional) – the processed flag/s of the polygons.

  • text (string, array_like, optional) – the text/s of the polygons.

  • id (int, array_like, optional) – the id/s of the polygons.

Returns

rows – the number of affected rows.

Return type

int

deleteRectangles(image=None, frame=None, filename=None, x=None, y=None, width=None, height=None, type=None, processed=None, text=None, id=None, layer=None)[source]

Delete all Rectangle entries with the given criteria.

See also: getRectangle(), getRectangles(), setRectangle(), setRectangles().

Parameters
  • image (int, Image, array_like, optional) – the image/s of the rectangles.

  • frame (int, array_like, optional) – the frame/s of the images of the rectangles.

  • filename (string, array_like, optional) – the filename/s of the images of the rectangles.

  • x (int, array_like, optional) – the x coordinate/s of the upper left corner/s of the rectangles.

  • y (int, array_like, optional) – the y coordinate/s of the upper left corner/s of the rectangles.

  • width (int, array_like, optional) – the width/s of the rectangles.

  • height (int, array_like, optional) – the height/s of the rectangles.

  • type (string, MarkerType, array_like, optional) – the marker type/s (or name/s) of the rectangles.

  • processed (int, array_like, optional) – the processed flag/s of the rectangles.

  • text (string, array_like, optional) – the text/s of the rectangles.

  • id (int, array_like, optional) – the id/s of the rectangles.

Returns

rows – the number of affected rows.

Return type

int

deleteTags(name=None, id=None)[source]

Delete all Tag entries from the database, which match the given criteria. If no criteria a given, delete all.

See also: getTag(), getTags(), setTag().

Parameters
  • name (string, array_like, optional) – the name/names of the Tag.

  • id (int, array_like, optional) – the id/ids of the Tag.

Returns

rows – number of rows deleted

Return type

int

deleteTracks(type=None, text=None, hidden=None, id=None)[source]

Delete a single Track object specified by id or all Track object of an type

See also: getTrack(), getTracks(), setTrack(), getTracksNanPadded().

Parameters
  • type (MarkerType, str, array_like, optional) – the marker type or name of the marker type

  • text (str, array_like, optional) – the Track specific text entry

  • hidden (bool, array_like, optional) – whether the tracks should be displayed in ClickPoints

  • id (int, array_like, array_like, optional) – the Track ID

Returns

rows – the number of affected rows.

Return type

int

getAnnotation(image=None, frame=None, filename=None, id=None, create=False)[source]

Get the Annotation entry for the given image frame number or filename.

See also: getAnnotations(), setAnnotation(), deleteAnnotations().

Parameters
  • image (int, Image, optional) – the image for which the annotation should be retrieved. If omitted, frame number or filename should be specified instead.

  • frame (int, optional) – frame number of the image, which annotation should be returned. If omitted, image or filename should be specified instead.

  • filename (string, optional) – filename of the image, which annotation should be returned. If omitted, image or frame number should be specified instead.

  • id (int, optional) – id of the annotation entry.

  • create (bool, optional) – whether the annotation should be created if it does not exist. (default: False)

Returns

annotation – the desired Annotation entry.

Return type

Annotation

getAnnotations(image=None, frame=None, filename=None, timestamp=None, tag=None, comment=None, rating=None, id=None)[source]

Get all Annotation entries from the database, which match the given criteria. If no criteria a given, return all masks.

See also: getAnnotation(), setAnnotation(), deleteAnnotations().

Parameters
  • image (int, Image, array_like, optional) – the image/images for which the annotations should be retrieved. If omitted, frame numbers or filenames should be specified instead.

  • frame (int, array_like, optional) – frame number/numbers of the images, which annotations should be returned. If omitted, images or filenames should be specified instead.

  • filename (string, array_like, optional) – filename of the image/images, which annotations should be returned. If omitted, images or frame numbers should be specified instead.

  • timestamp (datetime, array_like, optional) – timestamp/s of the annotations.

  • tag (string, array_like, optional) – the tag/s of the annotations to load.

  • comment (string, array_like, optional) – the comment/s of the annotations.

  • rating (int, array_like, optional) – the rating/s of the annotations.

  • id (int, array_like, optional) – id/ids of the annotations.

Returns

entries – a query object containing all the matching Annotation entries in the database file.

Return type

Annotation

getDbVersion()[source]

Returns the version of the currently opened database file.

Returns

version – the version of the database

Return type

string

getEllipse(id)[source]

Retrieve an Ellipse object from the database.

See also: getEllipses(), setEllipse(), setEllipses(), deleteEllipses().

Parameters

id (int) – the id of the ellipse.

Returns

ellipse – the Ellipse with the desired id or None.

Return type

Ellipse

getEllipses(image=None, frame=None, filename=None, x=None, y=None, width=None, height=None, angle=None, type=None, processed=None, text=None, id=None, layer=None)[source]

Get all Ellipse entries with the given criteria.

See also: getEllipse(), setEllipse(), setEllipses(), deleteEllipses().

Parameters
  • image (int, Image, array_like, optional) – the image/s of the ellipses.

  • frame (int, array_like, optional) – the frame/s of the images of the ellipses.

  • filename (string, array_like, optional) – the filename/s of the images of the ellipses.

  • x (int, array_like, optional) – the x coordinate/s of the center/s of the ellipses.

  • y (int, array_like, optional) – the y coordinate/s of the center/s of the ellipses.

  • width (int, array_like, optional) – the width/s of the ellipses.

  • height (int, array_like, optional) – the height/s of the ellipses.

  • angle (float, array_like, optional) – the angle/s of the rectangles in ellipses.

  • type (string, MarkerType, array_like, optional) – the marker type/s (or name/s) of the ellipses.

  • processed (int, array_like, optional) – the processed flag/s of the ellipses.

  • text (string, array_like, optional) – the text/s of the ellipses.

  • id (int, array_like, optional) – the id/s of the ellipses.

  • layer (int, optional) – the id of the image of the ellipses.

Returns

entries – a query object which contains all Ellipse entries.

Return type

array_like

getImage(frame=None, filename=None, id=None, layer=None)[source]

Returns the Image entry with the given frame number and layer.

See also: getImages(), getImageIterator(), setImage(), deleteImages().

Parameters
  • frame (int, optional) – the frame number of the desired image, as displayed in ClickPoints.

  • filename (string, optional) – the filename of the desired image.

  • id (int, optional) – the id of the image.

  • layer (int, string, optional) – the layer_id or name of the layer of the image.

Returns

image – the image entry.

Return type

Image

getImageCount()[source]

Returns the number of images in the database.

Returns

count – the number of images.

Return type

int

getImageIterator(start_frame=0, end_frame=None, skip=1, layer=1)[source]

Get an iterator to iterate over all Image entries starting from start_frame.

See also: getImage(), getImages(), setImage(), deleteImages().

Parameters
  • start_frame (int, optional) – start at the image with the number start_frame. Default is 0

  • end_frame (int, optional) – the last frame of the iteration (excluded). Default is None, the iteration stops when no more images are present.

  • skip (int, optional) – how many frames to jump. Default is 1

  • layer (int, string, optional) – layer of frames, over which should be iterated.

Returns

image_iterator – an iterator object to iterate over Image entries.

Return type

iterator

Examples

1import clickpoints
2
3# open the database "data.cdb"
4db = clickpoints.DataFile("data.cdb")
5
6# iterate over all images and print the filename
7for image in db.GetImageIterator():
8    print(image.filename)
getImages(frame=None, filename=None, ext=None, external_id=None, timestamp=None, width=None, height=None, path=None, layer=None, order_by='sort_index')[source]

Get all Image entries sorted by sort index. For large databases getImageIterator(), should be used as it doesn’t load all frames at once.

See also: getImage(), getImageIterator(), setImage(), deleteImages().

Parameters
  • frame (int, array_like, optional) – the frame number/s of the image/s as displayed in ClickPoints (sort_index in the database).

  • filename (string, array_like, optional) – the filename/s of the image/s.

  • ext (string, array_like, optional) – the extension/s of the image/s.

  • external_id (int, array_like, optional) – the external id/s of the image/s.

  • timestamp (datetime, array_like, optional) – the timestamp/s of the image/s.

  • width (int, array_like, optional) – the width/s of the image/s.

  • height (int, array_like, optional) – the height/s of the image/s

  • path (int, Path, array_like, optional) – the path/s (or path id/s) of the image/s

  • layer (int, string, array_like, optional) – the layer/s of the image/s

  • order_by (string, optional) – sort by either ‘sort_index’ (default) or ‘timestamp’.

Returns

entries – a query object containing all the Image entries in the database file.

Return type

array_like

getLayer(layer_name=None, base_layer=None, id=None, create=False)[source]

Get a Layer entry from the database.

See also: getLayers(), setLayer(), deleteLayers()

Parameters
  • layer_name (string, optional) – the string specifying the layers name.

  • base_layer (int, Layer, optional) – the base layer to which this layer should reference.

  • id (int, optional) – the id of the layer.

  • create (bool, optional) – whether the layer should be created if it does not exist. (default: False)

Returns

path – the created/requested Layer entry.

Return type

Layer

getLayers(layer_name=None, base_layer=None, id=None)[source]

Get all Layer entries from the database, which match the given criteria. If no critera a given, return all layers.

See also: getLayer(), setLayer(), deleteLayers()

Parameters
  • layer_name (string, optional) – the string/s specifying the layer name/s.

  • base_layer (int, Layer, optional) – the base layer to which this layer should reference.

  • id (int, array_like, optional) – the id/s of the layer/s.

Returns

entries – a query object containing all the matching Layer entries in the database file.

Return type

array_like

getLine(id)[source]

Retrieve an Line object from the database.

See also: getLines(), setLine(), setLines(), deleteLines().

Parameters

id (int) – the id of the line

Returns

line – the Line with the desired id or None.

Return type

Line

getLines(image=None, frame=None, filename=None, x1=None, y1=None, x2=None, y2=None, type=None, processed=None, text=None, id=None)[source]

Get all Line entries with the given criteria.

See also: getLine(), setLine(), setLines(), deleteLines().

Parameters
  • image (int, Image, array_like, optional) – the image/s of the lines.

  • frame (int, array_like, optional) – the frame/s of the images of the lines.

  • filename (string, array_like, optional) – the filename/s of the images of the lines.

  • x1 (int, array_like, optional) – the x coordinate/s of the lines start.

  • y1 (int, array_like, optional) – the y coordinate/s of the lines start.

  • x2 (int, array_like, optional) – the x coordinate/s of the lines end.

  • y2 (int, array_like, optional) – the y coordinate/s of the lines end.

  • type (string, MarkerType, array_like, optional) – the marker type/s (or name/s) of the lines.

  • processed (int, array_like, optional) – the processed flag/s of the lines.

  • text (string, array_like, optional) – the text/s of the lines.

  • id (int, array_like, optional) – the id/s of the lines.

Returns

entries – a query object which contains all Line entries.

Return type

array_like

getMarker(id)[source]

Retrieve an Marker object from the database.

See also: getMarkers(), setMarker(), setMarkers(), deleteMarkers().

Parameters

id (int) – the id of the marker

Returns

marker – the Marker with the desired id or None.

Return type

Marker

getMarkerType(name=None, id=None)[source]

Retrieve an MarkerType object from the database.

See also: getMarkerTypes(), setMarkerType(), deleteMarkerTypes().

Parameters
  • name (str, optional) – the name of the desired type

  • id (int, optional) – id of the MarkerType object

Returns

entries – the MarkerType with the desired name or None.

Return type

array_like

getMarkerTypes(name=None, color=None, mode=None, text=None, hidden=None, id=None)[source]

Retreive all MarkerType objects in the database.

See also: getMarkerType(), setMarkerType(), deleteMarkerTypes().

Parameters
  • name (str, array_like, optional) – the name of the type

  • color (str, array_like, optional) – hex code string for rgb color of style “#00ff3f”

  • mode (int, array_like, optional) – mode of the marker type (marker 0, rect 1, line 2, track 4)

  • text (str, array_like, optional) – display text

  • hidden (bool, array_like, optional) – whether the types should be displayed in ClickPoints

  • id (int, array_like, optional) – id of the MarkerType object

Returns

entries – a query object which contains all MarkerType entries.

Return type

array_like

getMarkers(image=None, frame=None, filename=None, x=None, y=None, type=None, processed=None, track=None, text=None, id=None, layer=None)[source]

Get all Marker entries with the given criteria.

See also: getMarker(), getMarkers(), setMarker(), setMarkers(), deleteMarkers().

Parameters
  • image (int, Image, array_like, optional) – the image/s of the markers.

  • frame (int, array_like, optional) – the frame/s of the images of the markers.

  • filename (string, array_like, optional) – the filename/s of the images of the markers.

  • x (int, array_like, optional) – the x coordinate/s of the markers.

  • y (int, array_like, optional) – the y coordinate/s of the markers.

  • type (string, MarkerType, array_like, optional) – the marker type/s (or name/s) of the markers.

  • processed (int, array_like, optional) – the processed flag/s of the markers.

  • track (int, Track, array_like, optional) – the track id/s or instance/s of the markers.

  • text (string, array_like, optional) – the text/s of the markers.

  • id (int, array_like, optional) – the id/s of the markers.

  • layer (int, optional) – the layer of the markers

Returns

entries – a query object which contains all Marker entries.

Return type

array_like

getMask(image=None, frame=None, filename=None, id=None, layer=None, create=False)[source]

Get the Mask entry for the given image frame number or filename.

See also: getMasks(), setMask(), deleteMasks().

Parameters
  • image (int, Image, optional) – the image for which the mask should be retrieved. If omitted, frame number or filename should be specified instead.

  • frame (int, optional) – frame number of the image, which mask should be returned. If omitted, image or filename should be specified instead.

  • filename (string, optional) – filename of the image, which mask should be returned. If omitted, image or frame number should be specified instead.

  • id (int, optional) – id of the mask entry.

  • create (bool, optional) – whether the mask should be created if it does not exist. (default: False)

  • layer (int, optional) – layer of the image, which mask should be returned. Always use with frame.

Returns

mask – the desired Mask entry.

Return type

Mask

getMaskType(name=None, color=None, index=None, id=None)[source]

Get a MaskType from the database.

See also: getMaskTypes(), setMaskType(), deleteMaskTypes().

Parameters
  • name (string, optional) – the name of the mask type.

  • color (string, optional) – the color of the mask type.

  • index (int, optional) – the index of the mask type, which is used for painting this mask type.

  • id (int, optional) – the id of the mask type.

Returns

entries – the created/requested MaskType entry.

Return type

MaskType

getMaskTypes(name=None, color=None, index=None, id=None)[source]

Get all MaskType entries from the database, which match the given criteria. If no criteria a given, return all mask types.

See also: getMaskType(), setMaskType(), deleteMaskTypes().

Parameters
  • name (string, array_like, optional) – the name/names of the mask types.

  • color (string, array_like, optional) – the color/colors of the mask types.

  • index (int, array_like, optional) – the index/indices of the mask types, which is used for painting this mask types.

  • id (int, array_like, optional) – the id/ids of the mask types.

Returns

entries – a query object containing all the matching MaskType entries in the database file.

Return type

array_like

getMasks(image=None, frame=None, filename=None, id=None, layer=None, order_by='sort_index')[source]

Get all Mask entries from the database, which match the given criteria. If no criteria a given, return all masks.

See also: getMask(), setMask(), deleteMasks().

Parameters
  • image (int, Image, array_like, optional) – the image/images for which the mask should be retrieved. If omitted, frame numbers or filenames should be specified instead.

  • frame (int, array_like, optional) – frame number/numbers of the images, which masks should be returned. If omitted, images or filenames should be specified instead.

  • filename (string, array_like, optional) – filename of the image/images, which masks should be returned. If omitted, images or frame numbers should be specified instead.

  • id (int, array_like, optional) – id/ids of the masks.

  • layer (int, optional) – layer of the images, which masks should be returned. Always use with frame.

  • order_by (string, optional) – sorts the result according to sort paramter (‘sort_index’ or ‘timestamp’)

Returns

entries – a query object containing all the matching Mask entries in the database file.

Return type

Mask

getPath(path_string=None, id=None, create=False, absolute=False)[source]

Get a Path entry from the database.

See also: getPaths(), setPath(), deletePaths()

Parameters
  • path_string (string, optional) – the string specifying the path.

  • id (int, optional) – the id of the path.

  • create (bool, optional) – whether the path should be created if it does not exist. (default: False)

  • absolute (bool, optional) – whether the created path should be absolute or relative to the database file. (default: False)

Returns

path – the created/requested Path entry.

Return type

Path

getPaths(path_string=None, base_path=None, id=None)[source]

Get all Path entries from the database, which match the given criteria. If no critera a given, return all paths.

See also: getPath(), setPath(), deletePaths()

Parameters
  • path_string (string, path_string, optional) – the string/s specifying the path/s.

  • base_path (string, optional) – return only paths starting with the base_path string.

  • id (int, array_like, optional) – the id/s of the path/s.

Returns

entries – a query object containing all the matching Path entries in the database file.

Return type

array_like

getPolygon(id)[source]

Retrieve an Polygon object from the database.

See also: getPolygons(), setPolygon(), setPolygons(), deletePolygons().

Parameters

id (int) – the id of the polygon.

Returns

polygon – the Polygon with the desired id or None.

Return type

Polygon

getPolygons(image=None, frame=None, filename=None, type=None, processed=None, text=None, id=None, layer=None)[source]

Get all Polygon entries with the given criteria.

See also: getPolygon(), setPolygon(), setPolygons(), deletePolygons().

Parameters
  • image (int, Image, array_like, optional) – the image/s of the polygons.

  • frame (int, array_like, optional) – the frame/s of the images of the polygons.

  • filename (string, array_like, optional) – the filename/s of the images of the polygons.

  • type (string, MarkerType, array_like, optional) – the marker type/s (or name/s) of the polygons.

  • processed (int, array_like, optional) – the processed flag/s of the polygons.

  • text (string, array_like, optional) – the text/s of the polygons.

  • id (int, array_like, optional) – the id/s of the polygons.

  • layer (int, optional) – the id of the image of the polygons.

Returns

entries – a query object which contains all Polygon entries.

Return type

array_like

getRectangle(id)[source]

Retrieve an Rectangle object from the database.

See also: getRectangles(), setRectangle(), setRectangles(), deleteRectangles().

Parameters

id (int) – the id of the rectangle.

Returns

rectangle – the Rectangle with the desired id or None.

Return type

Rectangle

getRectangles(image=None, frame=None, filename=None, x=None, y=None, width=None, height=None, type=None, processed=None, text=None, id=None, layer=None)[source]

Get all Rectangle entries with the given criteria.

See also: getRectangle(), setRectangle(), setRectangles(), deleteRectangles().

Parameters
  • image (int, Image, array_like, optional) – the image/s of the rectangles.

  • frame (int, array_like, optional) – the frame/s of the images of the rectangles.

  • filename (string, array_like, optional) – the filename/s of the images of the rectangles.

  • x (int, array_like, optional) – the x coordinate/s of the upper left corner/s of the rectangles.

  • y (int, array_like, optional) – the y coordinate/s of the upper left corner/s of the rectangles.

  • width (int, array_like, optional) – the width/s of the rectangles.

  • height (int, array_like, optional) – the height/s of the rectangles.

  • type (string, MarkerType, array_like, optional) – the marker type/s (or name/s) of the rectangles.

  • processed (int, array_like, optional) – the processed flag/s of the rectangles.

  • text (string, array_like, optional) – the text/s of the rectangles.

  • id (int, array_like, optional) – the id/s of the rectangles.

  • layer (int, optional) – the id of the image of the rectangle

Returns

entries – a query object which contains all Rectangle entries.

Return type

array_like

getTag(name=None, id=None)[source]

Get a specific Tag entry by its name or database ID

See also: getTags(), setTag(), deleteTags().

Parameters
  • name (str) – name of the tag

  • id (int) – id of Tag entry

Returns

entries – requested object of class Tag or None

Return type

Tag

getTags(name=None, id=None)[source]

Get all Tag entries from the database, which match the given criteria. If no criteria a given, return all.

See also: getTag(), setTag(), deleteTags().

Parameters
  • name (string, array_like, optional) – the name/names of the Tag.

  • id (int, array_like, optional) – the id/ids of the Tag.

Returns

entries – a query object containing all the matching Tag entries in the database file.

Return type

array_like

getTrack(id)[source]

Get a specific Track entry by its database ID.

See also: getTracks(), deleteTracks(), getTracksNanPadded().

Parameters

id (int) – id of the track

Returns

entries – requested object of class Track or None

Return type

Track

getTracks(type=None, text=None, hidden=None, id=None)[source]

Get all Track entries, optional filter by type

See also: getTrack(), setTrack(), deleteTracks(), getTracksNanPadded().

Parameters
  • type (MarkerType, str, array_like, optional) – the marker type/types or name of the marker type for the track.

  • text (str, array_like, optional) – the Track specific text entry

  • hidden (bool, array_like, optional) – whether the tracks should be displayed in ClickPoints

  • id (int, array_like, optional) – the Track ID

Returns

entries – a query object which contains the requested Track.

Return type

array_like

getTracksNanPadded(type=None, id=None, start_frame=None, end_frame=None, skip=None, layer=None, apply_offset=False)[source]

Return an array of all track points with the given filters. The array has the shape of [n_tracks, n_images, pos], where pos is the 2D position of the markers.

See also: getTrack(), setTrack(), deleteTracks(), getTracks().

Parameters
  • type (MarkerType, str, array_like, optional) – the marker type/types or name of the marker type for the track.

  • id (int, array_like, optional) – the Track ID

  • start_frame (int, optional) – the frame where to begin the array. Default: first frame.

  • end_frame (int, optional) – the frame where to end the array. Default: last frame.

  • skip (int, optional) – skip every nth frame. Default: don’t skip frames.

  • layer (int, optional) – which layer to use for the images.

  • apply_offset (bool, optional) – whether to apply the image offsets to the marker positions. Default: False.

Returns

nan_padded_array – the array which contains all the track marker positions.

Return type

ndarray

max_sql_variables()[source]

Get the maximum number of arguments allowed in a query by the current sqlite3 implementation.

Returns

inferred SQLITE_MAX_VARIABLE_NUMBER

Return type

int

setAnnotation(image=None, frame=None, filename=None, timestamp=None, comment=None, rating=None, id=None, layer=None)[source]

Insert or update an Annotation object in the database.

See also: getAnnotation(), getAnnotations(), deleteAnnotations().

Parameters
  • image (int, Image, optional) – the image of the annotation.

  • frame (int, optional) – the frame of the images of the annotation.

  • filename (string, optional) – the filename of the image of the annotation.

  • timestamp (datetime, optional) – the timestamp of the annotation.

  • comment (string, optional) – the text of the annotation.

  • rating (int, optional) – the rating of the annotation.

  • id (int, optional) – the id of the annotation.

Returns

annotation – the created or changed Annotation item.

Return type

Annotation

setEllipse(image=None, frame=None, filename=None, x=None, y=None, width=None, height=None, angle=None, type=None, processed=None, style=None, text=None, id=None, layer=None)[source]

Insert or update an Ellipse object in the database.

See also: getEllipse(), getEllipses(), setEllipses(), deleteEllipses().

Parameters
  • image (int, Image, optional) – the image of the ellipse.

  • frame (int, optional) – the frame of the images of the ellipse.

  • filename (string, optional) – the filename of the image of the ellipse.

  • x (int, optional) – the x coordinate of the center of the ellipse.

  • y (int, optional) – the y coordinate of the center of the ellipse.

  • width (int, optional) – the width of the ellipse.

  • height (int, optional) – the height of the ellipse.

  • angle (float, optional) – the angle of the ellipse in degrees.

  • type (string, MarkerType, optional) – the marker type (or name) of the ellipse.

  • processed (int, optional) – the processed flag of the ellipse.

  • text (string, optional) – the text of the ellipse.

  • id (int, optional) – the id of the ellipse.

  • layer (int, optional) – the id of the image of the ellipse.

Returns

ellipse – the created or changed Ellipse item.

Return type

Ellipse

setEllipses(image=None, frame=None, filename=None, x=None, y=None, width=None, height=None, angle=None, type=None, processed=None, style=None, text=None, id=None, layer=None)[source]

Insert or update multiple Ellipse objects in the database.

See also: getEllipse(), getEllipses(), setEllipse(), deleteEllipses().

Parameters
  • image (int, Image, array_like, optional) – the image/s of the ellipses.

  • frame (int, array_like, optional) – the frame/s of the images of the ellipses.

  • filename (string, array_like, optional) – the filename/s of the images of the ellipses.

  • x (int, array_like, optional) – the x coordinate/s of the center/s of the ellipses.

  • y (int, array_like, optional) – the y coordinate/s of the center/s of the ellipses.

  • width (int, array_like, optional) – the width/s of the ellipses.

  • height (int, array_like, optional) – the height/s of the ellipses.

  • angle (int, array_like, optional) – the angle/s of the ellipses.

  • type (string, MarkerType, array_like, optional) – the marker type/s (or name/s) of the ellipses.

  • processed (int, array_like, optional) – the processed flag/s of the ellipses.

  • text (string, array_like, optional) – the text/s of the ellipses.

  • id (int, array_like, optional) – the id/s of the ellipses.

  • layer (int, optional) – the layer of the images of the ellipses.

Returns

success – it the inserting was successful.

Return type

bool

setImage(filename=None, path=None, frame=None, external_id=None, timestamp=None, width=None, height=None, id=None, layer='default', sort_index=None)[source]

Update or create new Image entry with the given parameters.

See also: getImage(), getImages(), getImageIterator(), deleteImages().

Parameters
  • filename (string, optional) – the filename of the image (including the extension)

  • path (string, int, Path, optional) – the path string, id or entry of the image to insert

  • frame (int, optional) – the frame number if the image is part of a video

  • external_id (int, optional) – an external id for the image. Only necessary if the annotation server is used

  • timestamp (datetime object, optional) – the timestamp of the image

  • width (int, optional) – the width of the image

  • height (int, optional) – the height of the image

  • id (int, optional) – the id of the image

  • layer (int, string, optional) – the layer_id of the image, always use with sort_index

  • sort_index (int, only use with layer) – the sort index (position in the time line) if not in layer 0

Returns

image – the changed or created Image entry

Return type

Image

setLayer(layer_name=None, base_layer=None, id=None)[source]

Update or create a new Layer entry with the given parameters.

See also: getLayer(), getLayers(), deleteLayers()

Parameters
  • layer_name (string, optional) – the string specifying the name of the layer.

  • base_layer (int, Layer, optional) – the base layer to which this layer should reference.

  • id (int, optional) – the id of the layers.

Returns

entries – the changed or created Layer entry.

Return type

Layer

setLine(image=None, frame=None, filename=None, x1=None, y1=None, x2=None, y2=None, type=None, processed=None, style=None, text=None, id=None, layer=None)[source]

Insert or update an Line object in the database.

See also: getLine(), getLines(), setLines(), deleteLines().

Parameters
  • image (int, Image, optional) – the image of the line.

  • frame (int, optional) – the frame of the images of the line.

  • filename (string, optional) – the filename of the image of the line.

  • x1 (int, optional) – the x coordinate of the start of the line.

  • y1 (int, optional) – the y coordinate of the start of the line.

  • x2 (int, optional) – the x coordinate of the end of the line.

  • y2 (int, optional) – the y coordinate of the end of the line.

  • type (string, MarkerType, optional) – the marker type (or name) of the line.

  • processed (int, optional) – the processed flag of the line.

  • text (string, optional) – the text of the line.

  • id (int, optional) – the id of the line.

  • layer (int, optional) – the layer of the image of the line

Returns

line – the created or changed Line item.

Return type

Line

setLines(image=None, frame=None, filename=None, x1=None, y1=None, x2=None, y2=None, type=None, processed=None, style=None, text=None, id=None, layer=None)[source]

Insert or update multiple Line objects in the database.

See also: getLine(), getLines(), setLine(), deleteLines().

Parameters
  • image (int, Image, array_like, optional) – the image/s of the lines.

  • frame (int, array_like, optional) – the frame/s of the images of the lines.

  • filename (string, array_like, optional) – the filename/s of the images of the lines.

  • x1 (int, array_like, optional) – the x coordinate/s of the start of the lines.

  • y1 (int, array_like, optional) – the y coordinate/s of the start of the lines.

  • x2 (int, array_like, optional) – the x coordinate/s of the end of the lines.

  • y2 (int, array_like, optional) – the y coordinate/s of the end of the lines.

  • type (string, MarkerType, array_like, optional) – the marker type/s (or name/s) of the lines.

  • processed (int, array_like, optional) – the processed flag/s of the lines.

  • track (int, Track, array_like, optional) – the track id/s or instance/s of the lines.

  • text (string, array_like, optional) – the text/s of the lines.

  • id (int, array_like, optional) – the id/s of the lines.

  • layer (int, optional) – the layer of the images of the lines

Returns

success – it the inserting was successful.

Return type

bool

setMarker(image=None, frame=None, filename=None, x=None, y=None, type=None, processed=None, track=None, style=None, text=None, id=None, layer=None)[source]

Insert or update an Marker object in the database.

See also: getMarker(), getMarkers(), setMarkers(), deleteMarkers().

Parameters
  • image (int, Image, optional) – the image of the marker.

  • frame (int, optional) – the frame of the images of the marker.

  • filename (string, optional) – the filename of the image of the marker.

  • x (int, optional) – the x coordinate of the marker.

  • y (int, optional) – the y coordinate of the marker.

  • type (string, MarkerType, optional) – the marker type (or name) of the marker.

  • processed (int, optional) – the processed flag of the marker.

  • track (int, Track, optional) – the track id or instance of the marker.

  • text (string, optional) – the text of the marker.

  • id (int, optional) – the id of the marker.

  • layer (int, optional) – the layer of the image of the marker

Returns

marker – the created or changed Marker item.

Return type

Marker

setMarkerType(name=None, color=None, mode=None, style=None, text=None, hidden=None, id=None)[source]

Insert or update an MarkerType object in the database.

See also: getMarkerType(), getMarkerTypes(), deleteMarkerTypes().

Parameters
  • name (str, optional) – the name of the type

  • color (str, optional) – hex code string for rgb color of style “#00ff3f”

  • mode (int, optional) – mode of the marker type (marker 0, rect 1, line 2, track 4)

  • style (str, optional) – style string

  • text (str, optional) – display text

  • hidden (bool, optional) – whether the type should be displayed in ClickPoints

  • id (int, optional) – id of the MarkerType object

Returns

entries – the created MarkerType with the desired name or None.

Return type

object

setMarkers(image=None, frame=None, filename=None, x=None, y=None, type=None, processed=None, track=None, style=None, text=None, id=None, layer=None)[source]

Insert or update multiple Marker objects in the database.

See also: getMarker(), getMarkers(), setMarker(), deleteMarkers().

Parameters
  • image (int, Image, array_like, optional) – the image/s of the markers.

  • frame (int, array_like, optional) – the frame/s of the images of the markers.

  • filename (string, array_like, optional) – the filename/s of the images of the markers.

  • x (int, array_like, optional) – the x coordinate/s of the markers.

  • y (int, array_like, optional) – the y coordinate/s of the markers.

  • type (string, MarkerType, array_like, optional) – the marker type/s (or name/s) of the markers.

  • processed (int, array_like, optional) – the processed flag/s of the markers.

  • track (int, Track, array_like, optional) – the track id/s or instance/s of the markers.

  • text (string, array_like, optional) – the text/s of the markers.

  • id (int, array_like, optional) – the id/s of the markers.

  • layer (int, optional) – the layer of the images

Returns

success – it the inserting was successful.

Return type

bool

setMask(image=None, frame=None, filename=None, data=None, id=None, layer=None, checkShape=False)[source]

Update or create new Mask entry with the given parameters.

See also: getMask(), getMasks(), deleteMasks().

Parameters
  • image (int, Image, optional) – the image for which the mask should be set. If omitted, frame number or filename should be specified instead.

  • frame (int, optional) – frame number of the images, which masks should be set. If omitted, image or filename should be specified instead.

  • filename (string, optional) – filename of the image, which masks should be set. If omitted, image or frame number should be specified instead.

  • data (ndarray, optional) – the mask data of the mask to set. Must have the same dimensions as the corresponding image, but only one channel, and it should be using the data type uint8.

  • id (int, optional) – id of the mask entry.

  • layer (int, optional) – the layer of the image, which masks should be set. always use with frame.

  • checkShape (bool, optional) – check if the maks and image have the same shape

Returns

mask – the changed or created Mask entry.

Return type

Mask

setMaskType(name=None, color=None, index=None, id=None)[source]

Update or create a new a MaskType entry with the given parameters.

See also: getMaskType(), getMaskTypes(), setMaskType(), deleteMaskTypes().

Parameters
  • name (string, optional) – the name of the mask type.

  • color (string, optional) – the color of the mask type.

  • index (int, optional) – the index of the mask type, which is used for painting this mask type.

  • id (int, optional) – the id of the mask type.

Returns

entries – the changed or created MaskType entry.

Return type

MaskType

setOffset(image, x, y)[source]

Set an Offset entry for a given image.

See also: deleteOffsets().

Parameters
  • image (int, Image) – the image for which the offset should be given.

  • x (int) – the x coordinate of the offset.

  • y (int) – the y coordinate of the offset.

Returns

entries – object of class Offset

Return type

Offset

setPath(path_string=None, id=None)[source]

Update or create a new Path entry with the given parameters.

See also: getPath(), getPaths(), deletePaths()

Parameters
  • path_string (string, optional) – the string specifying the path.

  • id (int, optional) – the id of the paths.

Returns

entries – the changed or created Path entry.

Return type

Path

setPolygon(image=None, frame=None, filename=None, points=None, type=None, closed=None, processed=None, style=None, text=None, id=None, layer=None)[source]

Insert or update an Polygon object in the database.

See also: getPolygon(), getPolygons(), setPolygons(), deletePolygons().

Parameters
  • image (int, Image, optional) – the image of the polygon.

  • frame (int, optional) – the frame of the images of the polygon.

  • filename (string, optional) – the filename of the image of the polygon.

  • points (array, optional) – the points of the vertices of the polygon.

  • type (string, MarkerType, optional) – the marker type (or name) of the polygon.

  • closed (int, optional) – makes the polygon a closed shape.

  • processed (int, optional) – the processed flag of the polygon.

  • text (string, optional) – the text of the polygon.

  • id (int, optional) – the id of the polygon.

  • layer (int, optional) – the id of the image of the polygon.

Returns

polygon – the created or changed Polygon item.

Return type

Polygon

setRectangle(image=None, frame=None, filename=None, x=None, y=None, width=None, height=None, type=None, processed=None, style=None, text=None, id=None, layer=None)[source]

Insert or update an Rectangle object in the database.

See also: getRectangle(), getRectangles(), setRectangles(), deleteRectangles().

Parameters
  • image (int, Image, optional) – the image of the rectangle.

  • frame (int, optional) – the frame of the images of the rectangle.

  • filename (string, optional) – the filename of the image of the rectangle.

  • x (int, optional) – the x coordinate of the upper left corner of the rectangle.

  • y (int, optional) – the y coordinate of the upper left corner of the rectangle.

  • width (int, optional) – the width of the rectangle.

  • height (int, optional) – the height of the rectangle.

  • type (string, MarkerType, optional) – the marker type (or name) of the rectangle.

  • processed (int, optional) – the processed flag of the rectangle.

  • text (string, optional) – the text of the rectangle.

  • id (int, optional) – the id of the rectangle.

  • layer (int, optional) – the id of the image of the rectangle

Returns

rectangle – the created or changed Rectangle item.

Return type

Rectangle

setRectangles(image=None, frame=None, filename=None, x=None, y=None, width=None, height=None, type=None, processed=None, style=None, text=None, id=None, layer=None)[source]

Insert or update multiple Rectangle objects in the database.

See also: getRectangle(), getRectangles(), setRectangle(), deleteRectangles().

Parameters
  • image (int, Image, array_like, optional) – the image/s of the rectangles.

  • frame (int, array_like, optional) – the frame/s of the images of the rectangles.

  • filename (string, array_like, optional) – the filename/s of the images of the rectangles.

  • x (int, array_like, optional) – the x coordinate/s of the upper left corner/s of the rectangles.

  • y (int, array_like, optional) – the y coordinate/s of the upper left corner/s of the rectangles.

  • width (int, array_like, optional) – the width/s of the rectangles.

  • height (int, array_like, optional) – the height/s of the rectangles.

  • type (string, MarkerType, array_like, optional) – the marker type/s (or name/s) of the rectangles.

  • processed (int, array_like, optional) – the processed flag/s of the rectangles.

  • text (string, array_like, optional) – the text/s of the rectangles.

  • id (int, array_like, optional) – the id/s of the rectangles.

  • layer (int, optional) – the layer of the images of the rectangles

Returns

success – it the inserting was successful.

Return type

bool

setTag(name=None, id=None)[source]

Set a specific Tag entry by its name or database ID

See also: getTag(), getTags(), deleteTags().

Parameters
  • name (str) – name of the tag

  • id (int) – id of Tag entry

Returns

entries – object of class Tag

Return type

Tag

setTrack(type, style=None, text=None, hidden=None, id=None, uid=None)[source]

Insert or update a Track object.

See also: getTrack(), getTracks(), deleteTracks(), getTracksNanPadded().

Parameters
  • type (MarkerType, str) – the marker type or name of the marker type for the track.

  • style – the Track specific style entry

  • text – the Track specific text entry

  • hidden – wether the track should be displayed in ClickPoints

  • id (int, array_like) – the Track ID

Returns

track – a new Track object

Return type

track object