pyapi

script

Script

inout

ScriptOutput

Output

Input

pipeline

PipeInfo

pipe_elements

Datasource

RawFile

AnnoTask

MIATask

SIATask

DataExport

VisualOutput

Loop

model

ImageAnno

TwoDAnno

LabelLeaf

Label

logic.label

LabelTree

dtype

TwoDAnno

class lost.db.dtype.TwoDAnno[source]

Type of a TwoDAnno

BBOX

A BBox.

Type:1
POLYGON

A Polygon.

Type:2
POINT

A Point.

Type:3
LINE

A Line.

Type:4
CIRCLE

A Circle.

Type:5

util methods

anno_helper

blacklist

A helper module to deal with blacklists.

class lost.pyapi.utils.blacklist.ImgBlacklist(my_script, name='img-blacklist.json', context='pipe')[source]

A class to deal with image blacklists.

Such blacklists are often used for annotation loops, in order to prevent annotating the same image multiple times.

my_script

The script instance that creates this blacklist.

Type:lost.pyapi.script.Script
name

The name of the blacklist file.

Type:str
context

Options: instance, pipe, static

Type:str

Example

Add images to blacklist.

>>> blacklist = ImgBlacklist(self, name='blacklist.json')
>>> blacklist.add(['path/to/img0.jpg'])
>>> balcklist.save()

Load a blacklist and check if a certain image is already in list.

>>> blacklist = ImgBlacklist(self, name='blacklist.json')
>>> blacklist.contains('path/to/img0.jpg')
True
>>> blacklist.contains('path/to/img1.jpg')
False

Get list of images that are not part of the blacklist

>>> blacklist.get_whitelist(['path/to/img0.jpg', 'path/to/img1.jpg', 'path/to/img2.jpg'])
['path/to/img1.jpg', 'path/to/img2.jpg']

Add images to the blacklist

>>> blacklist.add(['path/to/img1.jpg', 'path/to/img2.jpg'])
add(imgs)[source]

Add a list of images to blacklist.

Parameters:imgs (list) – A list of image identifiers that should be added to the blacklist.
contains(img)[source]

Check if blacklist contains a spcific image

Parameters:img (str) – The image identifier
Returns:True if img in blacklist, False if not.
Return type:bool
delete_blacklist()[source]

Remove blacklist from filesystem

get_whitelist(img_list, n='all')[source]

Get a list of images that are not part of the blacklist.

Parameters:
  • img_list (list of str) – A list of images where should be checked if they are in the blacklist
  • n ('all' or 'int') – The maximum number of images that should be returned.
Returns:

A list of images that are not in the blacklist.

Return type:

list of str

remove_item(item)[source]

Remove item from blacklist

Parameters:item (str) – The item/ image to remove from blacklist.
save()[source]

Write blacklist to filesystem

vis

lost.pyapi.utils.vis.boxes(script, img_anno, figsize=(15, 15), fontsize=15, label_offset=(0, 15))[source]

Draw bboxes on into an matplotlib figures

Parameters:
  • script (lost.pyapi.script.Script) – The script object that uses this method.
  • img_anno (lost.pyapi.annos.ImageAnno) – The image anno where bboxes should be visualized for.
  • figsize (tuple) – Size of the matplotlib figure
  • fontsize (ing) – Fontsize in pixels for label display
  • label_offset (tuple) – Position of the label in pixels in relation to the upper left corner of the box.
Returns:

Matplotlib figure

lost.pyapi.utils.vis.vis_tracks(img, tracks, frame_n, dots=15, figsize=(10, 10), dot_radius=5, linewidth=2)[source]

Visualize a track on image

Parameters:
  • img (array or str) – An RGB image or path to the image file.
  • tracks (array) – [[frame_n, track_id, xc, yc, w, h]…[…]] Box is defined relative to the image.
  • frame_n (int) – The frame number belonning to the image
  • dots (int) – Number of dots that will be displayed. Past locations that will be visualized.
  • figsize (tuple) – (int,int) Size of the figure to display.
  • dot_radius (int) – Radius of the first dot.
  • linewidth (int) – Linewidth of the box to draw.
Returns:

Matplotlib figure