The ScriptLab application is a small GUI that provides a ready to use interface to Python scripting. It mainly offers a display alongside some convenience functions to quickly test, prototype and visualize Python script results. Be aware that the python code may also be loaded through the API and used in custom applications. To use ScriptLab the same prerequisites apply as for Python Scripting.
Start by creating a script in a folder that will become your working directory or workspace. This will create some files, the main Python interface file and some qml files for GUI adjustment in the chosen folder. In addition the ScriptLab will load the default version listed below.
During startup the CvbVisionScript
class will be created, then open_device
is called and is supposed to return a cvb.GenICamDevice
. By default it will discover the CVMockTL and return the first device found on it. Then open_stream
is called and the previously returned device is provided as argument. It is supposed to return a cvb.ImageStream
. Use this method to configure your acquisition. The default implementation just returns the first stream after increasing the flow set pool to 6.
Once a script is loaded you can either acquire a single image or start a continuous stream. Either way process
is called with the acquired cvb.Image
. Here you can implement any image processing based on any library you can access from Python. The default implementation just returns the input image to be displayed. In addition you may return a tuple list. Each tuple contains a cvb.Point2D
, a label string and an optional bounding cvb.RectLT
. The returned tuples will be shown as overlays in the display.
Once you have modified the script you can trigger an application reload, to see the results. All errors including Python script errors are displayed in the console window opened alongside ScriptLab on Windows. Please run from the terminal on Linux, to see the output!
By default ScriptLab starts without any script or workspace loaded. However, if a script is provided as command line argument it will be loaded on startup and the script folder will be used as workspace.
In addition to change the functionality with a Python script also the appearance of the result overlays can be modified using the exported QML files.
ScriptLab will always use the loaded workspace as working directory and therefore the CVMockTL.json will be used when loading a simulated camera.
Debugging a script in ScriptLab works the same way as with Python Scripting. Be aware that continuous acquisition runs in a dedicated thread and therefore requires a manual debugger attachment.