Up | Example 01 - Calculate Area | Example 02 - Calculate mean value | Example 03 - Manipulate the results from two LineFinders | Example 04 - Dynamic threshold | Example 05 - Auto Exposure | Example 06 - DrawLine | Example 07 - Overlays | Example 08 - Python Objects | Example 09 - Timing | Example 10 - Image Averaging | Example 11 - Image Resampling | Example 12 - Constant Contrast | Example 13 - Serial Communication | Example 14 - Python results | Example 15 - Making a result string | Example 16 - Running tools from a script | Example 17 - Image Manipulation using Python Scripting | Example 18 - Calculating the median angle | Example 19 - Iterating objects located by a blob | Example 20 - Resampling using non-linear calibration | Example 21 - Custom Scorpion Python extension | Example 22 - Accessing Image Pixels | Example 23 - Implementing a tcp/ip Socket Server | Example 24 - Setting ExternalReference from calculated four points | Example 25 - Rotating a reference around in a circle | Example 26 - Grabbing an image from an MOXA Video IP Server | Example 27 - Toolbox Switch | Example 28 - Color Matcher Iteration | Example 29 - Audio Notification | Example 30 - Windows MessageBox | Example 31 -  Client to tcp Socket Server | Example 32 -  Read / Write External Data from / to file | Example 33 - Changing a tool's ROI | Example 34 - Histogram Equalization | Example 35 - Robust Adam 6060 scripts | Example 36 - Bubblesort | Example 37 - Element Statistics | Example 38 - Saving 3D Image | Example 39 - Disabling Zoom in Image Windows | Example 40 - Filtering timeseries | Example 41 - Scorpion Watchdog keep system running | Example 42 - Binary Search | Example 43 - Creating an ordered pointcloud | Example 44 - UDP Socket Communication

 

  

 
Example 33 - Changing a tool's ROI
This example demonstrates how to move or change a tools' ROI position/size from a script

Most tools are positioned in the image (the ROI) either as a rectangle with center/size/angle (e.g. LineFinder) or as a set of polygons (e.g. Blob3). The ROI can be changed as shown below. One or more points are given; one point means move ROI center, several points means reshape ROI.

Example 1 - Move rectangle

LF=GetTool('LF') # rectangle tool, e.g. LineFinder
LF.executeCmd('set;object=roi;value=((200;200))') # moves the ROI center

Example 2 - Set rectangle

LF=GetTool('LF') # rectangle tool, e.g. LineFinder
LF.executeCmd('set;object=roi;value=((100;100)(200;100)(200;150)(100;150))') #specify four corners of the ROI. The angle is calculated from the first two points

Example 3 - Move first polygon

B3=GetTool('B3') # polygon tool, e.g. Blob3
B3.executeCmd('set;object=roi;value=((200;200))') # moves blob3 first polygon to new center (defined as center of gravity for polygon)

Example 4 - Set first polygon

B3=GetTool('B3') # polygon tool, e.g. Blob3
B3.executeCmd('set;object=roi;value=((100;100)(200;100)(100;200))') # polygon defines ROI directly

Example 5 - Move another polygon

B3=GetTool('B3') # polygon tool, e.g. Blob3
B3.executeCmd('set;object=roi;number=2;value=((200;200))') # moves blob3 second polygon to new center (defined as center of gravity for polygon)

 

 
 

Scorpion Vision Version XII : Build 646 - Date: 20170225
Scorpion Vision Software® is a registered trademark of Tordivel AS.
Copyright © 2000 - 2017 Tordivel AS.