Question
Code snippet to draw a rectangle of the ROI in a Model-Based configuration using the ToolPosition and the Transform of the tool
Answer
{
// 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);
}
Comments
0 comments
Please sign in to leave a comment.