Documentation Portal      

What are you looking for?

Rectangle Fitting

Functional Guide | Reference: SetTransitionType, SetTransitionChoice, SetRectangle, Measure, GetMeasuredRectangle, GetSizeX, GetSizeY, GetAngle

/////////////////////////////////////////////////////////////////////////
// This code snippet shows how to create a rectangle measurement tool, //
// adjust the transition parameters, set the nominal gauge position, //
// perform the measurement and retrieve the result. //
/////////////////////////////////////////////////////////////////////////
// Image constructor
EImageBW8 srcImage;
// ERectangleGauge constructor
ERectangleGauge rectangleGauge;
// Adjust the transition parameters
rectangleGauge.SetTransitionType(ETransitionType_Bw);
rectangleGauge.SetTransitionChoice(ETransitionChoice_LargestAmplitude);
// Set the rectangle fitting gauge position,
// size (50x30 units) and orientation (15°)
EPoint center(256.f, 256.f);
ERectangle rectangle(center, 50.f, 30.f, 15.f);
rectangleGauge.SetRectangle(rectangle);
// Measure
rectangleGauge.Measure(&srcImage);
// Get the size and the rotation angle of the fitted rectangle
float sizeX = rectangleGauge.GetMeasuredRectangle().GetSizeX();
float sizeY = rectangleGauge.GetMeasuredRectangle().GetSizeY();
float angle = rectangleGauge.GetMeasuredRectangle().GetAngle();
// Save the point gauge measurement context
rectangleGauge.Save("myRectangleGauge.gge");
'/////////////////////////////////////////////////////////////////////////
'// This code snippet shows how to create a rectangle measurement tool, //
'// adjust the transition parameters, set the nominal gauge position, //
'// perform the measurement and retrieve the result. //
'/////////////////////////////////////////////////////////////////////////
' Image constructor
Dim srcImage As New EImageBW8
' ERectangleGauge constructor
Dim rectangleGauge As New ERectangleGauge
' Adjust the transition parameters
rectangleGauge.TransitionType = ETransitionType_Bw
rectangleGauge.TransitionChoice = ETransitionChoice_LargestAmplitude
' Set the rectangle fitting gauge position,
' size (50x30 units) and orientation (15°)
rectangleGauge.SetCenterXY 256#, 256#
rectangleGauge.SetSize 50#, 30#
rectangleGauge.angle = 15#
' Measure
rectangleGauge.Measure srcImage
' Get the size and the rotation angle of the fitted rectangle
Dim sizeX As Single
Dim sizeY As Single
Dim angle As Single
sizeX = rectangleGauge.MeasuredRectangle.sizeX
sizeY = rectangleGauge.MeasuredRectangle.sizeY
angle = rectangleGauge.MeasuredRectangle.angle
' Save the point gauge measurement context
rectangleGauge.Save "myRectangleGauge.gge"
/////////////////////////////////////////////////////////////////////////
// This code snippet shows how to create a rectangle measurement tool, //
// adjust the transition parameters, set the nominal gauge position, //
// perform the measurement and retrieve the result. //
/////////////////////////////////////////////////////////////////////////
// Image constructor
EImageBW8 srcImage= new EImageBW8();
// ERectangleGauge constructor
ERectangleGauge rectangleGauge= new ERectangleGauge();
// Adjust the transition parameters
rectangleGauge.TransitionType= ETransitionType.Bw;
rectangleGauge.TransitionChoice= ETransitionChoice.LargestAmplitude;
// Set the rectangle fitting gauge position,
// size (50x30 units) and orientation (15°)
rectangleGauge.SetCenterXY(256.0f, 256.0f);
rectangleGauge.SetSize(50.0f, 30.0f);
rectangleGauge.Angle = 15.0f;
// Measure
rectangleGauge.Measure(srcImage);
// Get the size and the rotation angle of the fitted rectangle
float sizeX = rectangleGauge.MeasuredRectangle.SizeX;
float sizeY = rectangleGauge.MeasuredRectangle.SizeY;
float angle = rectangleGauge.MeasuredRectangle.Angle;
// Save the point gauge measurement context
rectangleGauge.Save("myRectangleGauge.gge");

Which API shall we display?

© 2019 EURESYS s.a.  -  About Documentation  -  Open Source Licenses  -  Open eVision 2.10.0.1121