Add-on API

ClickPoints allows to easily write add-on scripts. The are called form ClickPoints with command line arguments specifiying which database to use, at which frame to start and how to communicate with ClikcPoints.

The add-on script should start as follows:

1
2
3
4
import clickpoints
start_frame, database, port = clickpoints.GetCommandLineArgs()
db = clickpoints.DataFile(database)
com = clickpoints.Commands(port, catch_terminate_signal=True)

This will retrieve start_frame, database and port from the command line arguments the script was started with. When executing the script through the add-on interface, ClickPoints will provide these values. These can then be used to open the ClickPoints project file and establish a connection to the ClickPoints instance.

Note

The Addons section demonstrates how the add-ons can be used and may serve as a good starting point to write custom add-ons.

Attention

To be able to use the API, the clickpoints package has to be installed! If a ImportError: No module named clickpoints error is raised, you have to install the package first. Go to clickpointspackage in your clickpoints directory and execute python setup.py develop there.

GetCommandLineArgs

clickpoints.GetCommandLineArgs()[source]

Parse the command line arguments for the information provided by ClickPoints, if the script is invoked from within ClickPoints. The arguments are –start_frame –database and –port.

Returns:
  • start_frame (int) – the frame ClickPoints was in when invoking the script. Probably the evaluation should start here
  • database (string) – the filename of the database where the current ClickPoints project is stored. Should be used with clickpoints.DataFile
  • port (int) – the port of the socket connection to communicate with the ClickPoints instance. Should be used with clickpoints.Commands

Commands

class clickpoints.Commands(port=None, catch_terminate_signal=False)[source]

The Commands class provides an interface for external scripts to communicate with a currently open ClickPoints instance. Communication is done using socket connection. ClickPoints provides the port number for this connection when calling an external script. Use clickpoints.GetCommandLineArgs to obtain the port number.

Parameters:
  • port (int, optional) – the port for the socket connection to communicate with ClickPoints. If it is not provided, a dummy connection is used with doesn’t pass any commands. This behaviour is provided to enable external scripts to run with and without a ClickPoints instance.
  • catch_terminate_signal (bool, optional) – whether a terminate signal from ClickPoints should directly terminate the script (default) or if only the terminate_signal flag should be set. This flag can later on be queried with HasTerminateSignal()
CatchTerminateSignal()[source]

Catch the terminate signal when ClickPoints wants to close the script execution. When called at the beginning of the script, the signal is cached and its status can be queried with HasTerminateSignal. This can be used for a gentle program termination, where the current progress loop can be finished before stopping the program execution.

GetImage(value)[source]

Get the currently in ClickPoints displayed image.

Returns:
  • image (ndarray) – the image data.
  • image_id (int) – the image id in the database.
  • image_frame (int) – which frame is used if the image is from a video file. 0 if the source is an image file.
HasTerminateSignal()[source]

Whether or not the program has received a terminate signal form ClickPoints. Can only be used if CatchTerminateSignal was called before.

Returns:terminate_signal – True if ClickPoints has sent a terminate signal.
Return type:bool
JumpFrames(value)[source]

Let ClickPoints jump the given amount of frames.

Parameters:value (int) – the amount of frame which ClickPoints should jump.
JumpFramesWait(value)[source]

Let ClickPoints jump the given amount of frames and wait for it to complete.

Parameters:value (int) – the amount of frame which ClickPoints should jump.
JumpToFrame(value)[source]

Let ClickPoints jump to the given frame.

Parameters:value (int) – the frame to which ClickPoints should jump.
JumpToFrameWait(value)[source]

Let ClickPoints jump to the given frame and wait for it to complete.

Parameters:value (int) – the frame to which ClickPoints should jump.
ReloadMarker(frame=None)[source]

Reloads the marker from the given frame in ClickPoints.

Parameters:frame (int) – the frame which ClickPoints should reload.
ReloadMask()[source]

Reloads the current mask file in ClickPoints.

ReloadTypes()[source]

Reloads the marker types.

log(*args)[source]

Print to the ClickPoints console.

Parameters:*args (string) – multiple strings to print
updateHUD(value)[source]