Main Menu

All times are in GMT -8 (DST) :: The time is now 4:14 pm.

Login or Register
Create an account and register your LMI products to gain access to useful resources.

Register Account


Sub Menu

Knowledge Base
Article Data
Article Ref
Date Created
Fri, 29th Sep 2017
Date Modified
Fri, 29th Sep 2017

   Drawing a rectangle marker of the final ROI


 Code snippet to draw a rectangle of the ROI in a Model-Based configuration using the ToolPosition and the Transform of the tool


// Get tool position info
float toolx = HSBlob.ToolPositionX;
float tooly = HSBlob.ToolPositionY;
float toolr = HSBlob.ToolRotation;
float width = HSBlob.ToolWidth;
float height = HSBlob.ToolHeight;

// Get transform info, this is the position of the instance
float transformx = HSBlob.TransformTranslationX;
float transformy = HSBlob.TransformTranslationY;
float transformr = HSBlob.TransformRotation;

// Apply the rotation of the transform to the tool position
float cos = (float)Math.Cos(transformr * Math.PI / 180.0);
float sin = (float)Math.Sin(transformr * Math.PI / 180.0);
float x = toolx * cos - tooly * sin;
float y = toolx * sin + tooly * cos;

// Translate the rotated tool position to the instance position
x += transformx;
y += transformy;

// Compute the final rotation of the tool position
float rotation = transformr + toolr;

// Display the Region of Interest Rectangle
mApplicationDisplay.AddRectangleMarker("Driver Blob", x, y, width, height, true);//user drawable box
mApplicationDisplay.set_RectangleMarkerHeight("Driver Blob", height);
mApplicationDisplay.set_RectangleMarkerWidth("Driver Blob", width);
mApplicationDisplay.set_RectangleMarkerRotation("Driver Blob", rotation);
mApplicationDisplay.set_RectangleMarkerConstraints("Driver Blob", HSDISPLAYLib.hsRectangleMarkerConstraints.hsRectangleNoConstraints);
mApplicationDisplay.set_MarkerColor("Driver Blob", HSDISPLAYLib.hsColor.hsGreen);