VisionPro ToolBlock Scripting Guide
VisionPro ToolBlock Scripting Guide
In both VB and C# scripts, after computing the degrees from radians, the scripts use 'SetScriptTerminalData' method to update the 'Degrees' terminal with the newly computed value, ensuring that the conversion is accessible to the VisionPro system .
In the scripting examples, the conversion from radians to degrees is achieved by multiplying the radians value by 180 and then dividing by π (pi), as seen in both the Visual Basic and C# implementations .
The scripts handle rejected images by checking the 'ResultStatus'. If it is not acceptable ('CogToolResultConstants.Accept'), an image is saved to a predefined directory ('c:\SavedImages\') with an incrementing filename. This logic ensures that only images which fail the specified criteria are saved .
The 'DefineScriptTerminal' method establishes the parameters for data exchange between the script and VisionPro. It sets input and output pathways ensuring that data, such as 'Radians' and 'Degrees', is correctly directed and manipulated, which is essential for the script's operation .
Conditional structures in 'GroupRun' check bounds of width measurements against specified distances. They help dictate script flow by determining whether output aligns with 'Accept' or 'Reject' categories. This control mechanism ensures output accuracy and relevance against predefined thresholds .
The syntax difference includes declaration and method structure. VB uses a combination of 'Function' and 'End Function' for method definition while C# uses 'public override bool'. VB uses 'As' for variable types, whereas C# uses explicit type declaration before variable names. These distinctions highlight differences in language architecture and readability .
The custom behavior implementation evaluates if a detected object's width is within specified 'MinDistance' and 'MaxDistance' limits. If outside these bounds, the script returns a 'Reject' result, along with a message detailing the out-of-range status. Conversely, if within limits, it returns an 'Accept' result, affirming inclusion within specified distances .
The 'ModifyCurrentRunRecord' method is overridable and allows modifications to the current run record during script execution. Although it is empty in the provided examples, its function is crucial for applications needing dynamic adjustments or data persistence during runtime .
The 'Initialize' method is crucial for setting up the script environment by defining necessary script terminals for data transmission. It ensures that the script starts with the requisite settings, thus facilitating proper interaction between the script and the VisionPro framework .
The 'GetBoundingBox' method is used in scenarios where it is important to determine the spatial attributes of blobs detected in an image. It calculates and provides the center coordinates (X, Y) of the bounding box of each blob, facilitating precise image analysis or object tracking .