Essential plugin package for labelmore
npm install @infolks/labelmore-essentialsregisterFormat` method of the encoder.
Note: The format registered must be a proper COCO JSON format.
The format must contain the following informations:
- name String : name of the annotation label
- description Object : any extra information related to the annotation
- classTitle String : name of the annotation class. E.g. Car, Pedestrian etc.
- attributes Object : label attributes E.g. Occluded, Truncated etc.
- points Object : spacial information of the annotation (co-ordinate points)
#### JSON Format Example
`json
{
"name": "Car_1562909220502",
"description": {
"type": "types.default.bndbox"
},
"classTitle": "Car",
"attributes": {},
"points": {
"exterior": [
[
220.71155595996362,
242.18926296633305
],
[
326.2729754322112,
312.9262966333031
]
],
"interior": []
}
}
`
#### Registering a JSON Format
A new format is registered to JSON Encoder by using an EncoderFormat object.
An EncoderFormat object is a javascript object with an encode method.
A common method to create a format is to:
1. Create a format class implementing the encode method.
2. Create an instance of the class and register it to JSON encoder.
##### Example: Registering bounding box format
boundbox.json.format.ts
`typescript
export class BoundboxJsonFormat {
constructor(private labeller: LabelManager) {}
/**
* @param label - label to encode
* @param class_ - class of the label
*/
encode(label: Label, class_: LabelClass) {
/*
* return a js object defining the json export format for boundbox label
*/
return {
name: this.labeller.getName(label),
description: {
type: label.type
},
classTitle: class_.name,
attributes: label.attributes || {},
points: {
exterior: [[label.props.xmin, label.props.ymin], [label.props.xmax, label.props.ymax]],
interior: []
}
}
}
}
`
boundbox.label.ts
`typescript
// import BoundboxJsonFormat from boundbox.json.format.ts
export class BoundboxLabel extends SimpleLabelType {
// ....
constructor(projectManager: ProjectManager, /...other dependencies/) {
//...
if (projectManager.hasEncoder('encoders.default.json')) {
const jsonEnc = projectManager.getEncoder('encoders.default.json')
if (!jsonEnc.hasFormat(DEFAULT_LABEL_TYPES.boundbox)) {
jsonEnc.registerFormat(DEFAULT_LABEL_TYPES.boundbox, new BoundboxJsonFormat(labeller))
// DEFAULT_LABEL_TYPES.boundbox is constant giving the registered name of default bounding box label type
// this should be replaced with the registered name of the label type for which the format is registered
}
}
//...
}
}
`
Label Types
The Essentials package contains BoundingBox, Contour and Polyline labels.
$3
The default bounding box label, implements the BoundboxProps.
Represents a rectangular bounding box.
To draw a boundbox label into workspace:
- The type should be set as types.default.bndbox (Note: The type name of default boundbox can be accessed using the constant DEFAULT_LABEL_TYPES.boundbox)
- The props should have:
- xmin Number : X co-ordinate of top left point
- ymin Number : Y co-ordinate of top left point
- xmax Number : X co-ordinate of bottom right point
- ymax Number : Y co-ordinate of bottom right point
#### Example : Adding a bounding box label to workspace
`typescript
// adding boundbox label
// code block from the boundbox tool
this.labeller.add({
type: DEFAULT_LABEL_TYPES.boundbox,
props: {
xmin: this.preview.bounds.left,
ymin: this.preview.bounds.top,
xmax: this.preview.bounds.right,
ymax: this.preview.bounds.bottom
}
})
`
$3
The default contour or polygon label, implements the ContourProps.
Represents a closed polygon shape.
To draw a contour label into workspace:
- The type should be set as types.default.contour (Note: The type name of default contour can be accessed using the constant DEFAULT_LABEL_TYPES.contour)
- The props should have:
- points Array : Array of co-ordinate points
#### Example : Adding a contour label to workspace
`typescript
// adding contour label
// code block from the contour tool
this.labeller.add({
type: DEFAULT_LABEL_TYPES.contour,
props: {
points: this.points.map(p => ({x: p.x, y: p.y}))
}
})
`
$3
The default polyline label, implements the PolylineProps.
Represents an open polyline shape.
To draw a polyline label into workspace:
- The type should be set as types.default.line (Note: The type name of default polyline can be accessed using the constant DEFAULT_LABEL_TYPES.line)
- The props should have:
- points Array : Array of co-ordinate points
#### Example : Adding a polyline label to workspace
`typescript
// adding polyline label
// code block from line tool
this.labeller.add({
type: DEFAULT_LABEL_TYPES.line,
props: {
points: this.points.map(p => ({x: p.x, y: p.y}))
}
})
`
$3
The default keypoint label.
Represents a keypoint skeleton.
To draw a keypoint label into workspace:
- The type should be set as types.default.keypoint
- The props should have:
- boundbox Object : props of a boundbox label
- xmin Number : X co-ordinate of top left point
- ymin Number : Y co-ordinate of top left point
- xmax Number : X co-ordinate of bottom right point
- ymax Number : Y co-ordinate of bottom right point
- keypoints Array : An array of object each of the form:
- name String : name of the keypoint
- point Object: coordinate of the point
- x Number: x co-ordinate of the point
- y Number: y co-ordinate of the point
Panels
The Essentials package contains the necessary panels for selecting label class, keypoint, scene attributes and class attributes
!Panels
Sources
The essentials package contains the disk source which allows projects to use the disk storage for input and output.
!Disk Source
Tools
The essentials package contains tools for basic annotation.
It contains:
| Tool | Default Shortcut |
| --------- | :--------------: |
| Select | A |
| Boundbox | R |
| Contour | C |
| Polyline | W |
| Keypoint | X |
| Pan | D |
Note: Default shortcuts are set in the tool in-built and cannot be changed.
Note: Shortcuts can be changed for each project
$3
Used to select annotation labels.
Actions
| Trigger | Interaction | Action |
| ----------------- | ----------------- | --------------------------------- |
| Left Mouse | Click | Select annotation |
| Delete Key | Press | Delete selected annotation |
| Up Arrow Key | Press | Bring selected annotation forward |
| Down Arrow Key | Press | Take selected annotation backward |
$3
Used for creating box annotations.
Actions
| Trigger | Interaction | Action |
| ----------------- | ----------------- | --------------------------------- |
| Left Mouse | Click & Drag | Create annotation |
$3
Used for creating polygon/contour annotations.
Actions
| Trigger | Interaction | Action |
| ----------------- | ----------------- | --------------------------------------------------------- |
| Left Mouse | Click | Add a point while drawing |
| '' | Alt + Click | Remove point from selected annotation |
| '' | Shift + Click | Add point to selected annotation |
| Backspace | Press | Backtrack last point while drawing |
| Alt | Press & Hold | Enable snapping mode while drawing |
| Tab | Press | Snap points of selected annotation to nearby annotations |
$3
Used for creating polyline annotations.
Actions
| Trigger | Interaction | Action |
| ----------------- | ----------------- | --------------------------------------------------------- |
| Left Mouse | Click | Add a point while drawing |
| '' | Alt + Click | Remove point from selected annotation |
| '' | Shift + Click | Add point to selected annotation |
| Backspace | Press | Backtrack last point while drawing |
$3
Used for creating keypoint annotations
#### Boundbox Mode
Boundbox mode is active during the start of annotation.
This mode is deactivated once boundbox is drawn.
Actions
| Trigger | Interaction | Action |
| ----------------- | ----------------- | --------------------------------- |
| Left Mouse | Click & Drag | Create bounding box |
#### Keypoint Mode
This mode is activated once boundbox is drawn.
You can start adding keypoints in this mode.
| Trigger | Interaction | Action |
| ----------------- | ----------------- | ------------------------------------------------- |
| Left Mouse | Click | Add keypoint (A keypoint need to be selected) |
| '' | Alt + Click | Remove a keypoint from selected annotation |
| '' | Shift + Click | Add an extra keypoint to selected annotation |
| Backspace | Press | Remove last added point (or boundbox) |
| V | Alt + Click | Toggle visibility mode |
Note:
- on pressing backspace, if no keypoint is added, the boundbox is deleted and the tool is set to Boundbox Mode.
- The visibility mode can be accessed from the store dependency as: `store.state.globals['tools.default.keypoint.visibility']``