Annotation API¶
Manage clip annotations which include Strokes and Texts.
Annotations can only be set on the particular Frame of a Clip.
Annotations can either be read-write or read-only.
A Frame of a clip can have multiple Read-Write Annotations and it can have only 1 Read-Only Annotation.
- class rpa.api.annotation_api.AnnotationApi(*args: Any, **kwargs: Any)[source]
Bases:
QObject
- append_strokes(clip_id: str, frame: int, strokes: List[Stroke]) bool [source]
This method adds new strokes to a specified clip and frame.
- Parameters:
clip_id (str) – Id of a clip.
frame (int) – Frame number.
strokes (list[Stroke]) – List of RPA Stroke objects to add to the frame.
- Returns:
True if success False otherwise
- Return type:
(bool)
- append_texts(clip_id: str, frame: int, texts: List[Text]) bool [source]
This method adds new text annotations to the specified clip and frame.
- Parameters:
clip_id (str) – Id of a clip.
frame (int) – Frame number.
texts (list[Text]) – List of RPA Text objects to add to the frame.
- Returns:
True if success False otherwise
- Return type:
(bool)
- append_transient_point(clip_id: str, frame: int, token: str, stroke_point: StrokePoint, is_line: bool = False) bool [source]
This methods adds a transient point(temporary point for drawing) to a specified frame in a clip. These points are used to build or update a stroke during the drawing process. If the token already exists, the point is appended to the stroke associated with that token.
- Parameters:
clip_id (str) – Id of a clip where the transient point will be added.
frame (int) – frame number where the point should be added.
token (str) – A unique identifier that associates the transient point with a specified drawing stroke.
stroke_point (StrokePoint) – RPA StrokePoint that needs to be appended to the transient stroke that is created by means of appending transient points.
is_line (bool) – If the is_line flag is True, the trasient stroke is a line, only 2 points at most will be kept.
- Returns:
True if success False otherwise
- Return type:
(bool)
- clear_frame(clip_id: str, frame: int) bool [source]
This method clears all annotations in a specified clip and frame. This differs from delete, when you do undo/redo, this still brings back the cleared annotations, but delete will not.
- Parameters:
clip_id (str) – Id of a clip.
frame (int) – Frame number where annotations should be cleared.
- Returns:
True if success False otherwise
- Return type:
(bool)
- property delegate_mngr: DelegateMngr
- delete_ro_annotations(clips: list) bool [source]
This method deletes the read-only annotations from given clips.
- Parameters:
clips (list) – list of clip ids.
- Returns:
True if success False otherwise
- Return type:
(bool)
- delete_rw_annotation(clip_id: str, frame: int) bool [source]
This method deletes the read-write annotation from a specified clip and frame. Unlike clear, delete doesn’t bring back the annotation on undo.
- Parameters:
clip_id (str) – Id of a clip.
frame (int) – Frame number.
- Returns:
True if success False otherwise
- Return type:
(bool)
- delete_transient_points(clip_id: str, frame: int, token: str) bool [source]
Removes all transient points associated with a specific RPA Stroke in a given clip and frame.
- Parameters:
clip_id (str) – Id of a clip where the transient points should be deleted.
frame (int) – Frame number where the points should be deleted.
token (str) – The unique identifier associated with the stroke whose points are to be deleted.
- Returns:
True if success False otherwise
- Return type:
(bool)
- get_ro_annotations(clip_id: str, frame: int) List[Annotation] [source]
Retrieves the list of read-only annotations for the specified clip and frame.
- Parameters:
clip_id (str) – Id of a clip.
frame (int) – Clip frame number
- Returns:
Read-only Annotations(strokes and texts) objects.
- Return type:
(list)
- get_ro_frames(clip_id: str) List[int] [source]
Retrieves the frames that contain read-only annotations within a specified clip. These are frames where annotations cannot be modified or erased and are used for viewing only.
- Parameters:
clip_id (str) – Id of a clip.
- Returns:
A list of frame numbers that contain read-only annotations.
- Return type:
list[int]
- get_rw_annotation(clip_id: str, frame: int) Annotation [source]
Retrieves the read-write annotations for a specified clip and frame.
- Parameters:
clip_id (str) – Id of a clip.
frame (int) – frame number.
- Returns:
RPA Annotation(strokes and texts) object.
- Return type:
Annotation(RPA Annotation)
- get_rw_frames(clip_id: str) List[int] [source]
Retrieves the frames that contain read-write annotations within a specified clip. There are frames where annotations can be modified or erased.
- Parameters:
clip_id (str) – Id of a clip.
- Returns:
A list of frame numbers that contain read-write annotations.
- Return type:
list
- get_transient_stroke(clip_id: str, frame: int, token: str)[source]
Retrieves all transient points associated with a specific stroke in a given clip and frame.
- Parameters:
clip_id (str) – Id of a clip where the transient stroke exists.
frame (int) – Frame number where the stroke is located.
token (str) – A unique identifier associated with the stroke that needs to be retrieved.
- Returns:
The RPA Stroke that is created by means of appending transient stroke-points.
- Return type:
Stroke
- redo(clip_id: str, frame: int) bool [source]
This method reapplies the most recent undone annotation change in the specified clip and frame.
- Parameters:
clip_id (str) – Id of a clip.
frame (int) – Frame number.
- Returns:
True if success False otherwise
- Return type:
(bool)
- set_laser_pointer(id: str, point: Point, color: Color) bool [source]
This method sets a laser pointer on the specified clip and frame.
- Parameters:
id (str) – Id of the laser pointer.
point (Point) – RPA Point object holding the normalized (0.0 to 1.0) position where the laser pointer should be placed.
color (Color) – The RPA Color objectfor the laset pointer.
- Returns:
True if success False otherwise
- Return type:
(bool)
- set_pointer(stroke_point: StrokePoint) bool [source]
This method sets a pen pointer on the specified clip and frame.
- Parameters:
stroke_point (StrokePoint) – The RPA StrokePoint that needs to be used to draw the pointer.
- Returns:
True if success False otherwise
- Return type:
(bool)
- set_ro_annotations(annotations: Dict) bool [source]
Set the list of read-only annotaitons that need to be set for the clips and their respective frames as mentioned in the given dict.
Following is an example of how the annotations dict should look like,
annotations = { "clip_id_1": { frame_1: [Annotation(), Annotation(), Annotation()] frame_2: [Annotation(), Annotation(), Annotation()] frame_3: [Annotation(), Annotation()] }, "clip_id_2": { frame_1: [Annotation(), Annotation(), Annotation()] frame_2: [Annotation(), Annotation(), Annotation()] frame_3: [Annotation(), Annotation()] } }
- Parameters:
annotations (Dict) – Dictionary of annotations
Returns: (bool) : True if success False otherwise.
- set_rw_annotations(annotations: Dict) bool [source]
Sets the read-write annotations for the clips and their respective frames as given in the dictionary.
Here is an example of how the annotations dict should look like,
{ "clip_id_1": { frame_1: Annotation() frame_2: Annotation() frame_3: Annotation() }, "clip_id_2": { frame_1: Annotation() frame_2: Annotation() frame_3: Annotation() } }
- Parameters:
annotatoins (Dict) – Annotaions that need to be set on clips and
frames. (their respective) –
- Returns:
True is success else False
- Return type:
(bool)
- set_text(clip_id: str, frame: int, text: Text) bool [source]
Based on the text properties defined in the text object set the text as an annotation.
If a text-annotation already exists at the same position as the position in given text object, then that existing text annotation’s text and properties will be updated with the text and properties of the the given text-object.
- Parameters:
clip_id (str) – Id of a clip.
frame (int) – Frame number.
text (Text) – RPA Text object
- Returns:
True if success else False
- Return type:
(bool)
- undo(clip_id: str, frame: int) bool [source]
Reverts the most recent annotation change in the specified clip and frame.
- Parameters:
clip_id (str) – Id of a clip.
frame (int) – Frame number.
- Returns:
True if success False otherwise
- Return type:
(bool)