Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
/// <summary>
/// Get the 2D shape points
/// </summary>
/// <returns>
/// The 2D shape points
/// </returns>
public PointF[] Get2DShapePoints()
{
IntPtr shapePointsPtr;
uint shapePointsCount;
this.CheckPtrAndThrow();
this.faceTrackingResultPtr.Get2DShapePoints(out shapePointsPtr, out shapePointsCount); // volanie unmanaged kodu
PointF[] shapePoints = null;
if (shapePointsCount > 0)
{
shapePoints = new PointF[shapePointsCount];
for (int i = 0; i < shapePointsCount; i++)
{
shapePoints[i] = new PointF();
IntPtr shapePointsIthPtr;
if (IntPtr.Size == 8)
{
// 64bit
shapePointsIthPtr = new IntPtr(shapePointsPtr.ToInt64() + (i * Marshal.SizeOf(typeof(PointF))));
}
else
{
// 32bit
shapePointsIthPtr = new IntPtr(shapePointsPtr.ToInt32() + (i * Marshal.SizeOf(typeof(PointF))));
}
shapePoints[i] = (PointF)Marshal.PtrToStructure(shapePointsIthPtr, typeof(PointF));
}
}
return shapePoints;
}
/// <summary>
/// Represents a 2D vector with x,y elements
/// </summary>
struct FT_VECTOR2D
{
#ifdef __cplusplus
FT_VECTOR2D(FLOAT xParam = 0, FLOAT yParam = 0) : x(xParam), y(yParam) {}
#endif
FLOAT x;
FLOAT y;
};
// STDMETHOD(Get2DShapePoints)(THIS_ FT_VECTOR2D** ppPoints, UINT* pPointCount) PURE;
void Get2DShapePoints(out IntPtr pointsPtr, out uint pointCount);
/// <summary>
/// Represents a point in 2D space with floating point x & y co-ordinates
/// </summary>
[DebuggerDisplay("({x},{y})")]
[StructLayout(LayoutKind.Sequential)]
public struct PointF
{
private readonly float x;
private readonly float y;
public PointF(float x, float y)
{
this.x = x;
this.y = y;
}
/// <summary>
/// Gets an point with 0,0 co-ordinates
/// </summary>
public static PointF Empty
{
get { return new PointF(0, 0); }
}
/// <summary>
/// Returns X co-ordinate
/// </summary>
public float X
{
get { return x; }
}
/// <summary>
/// Returns Y co-ordinate
/// </summary>
public float Y
{
get { return y; }
}
public static bool operator ==(PointF point1, PointF point2)
{
return point1.Equals(point2);
}
public static bool operator !=(PointF point1, PointF point2)
{
return !point1.Equals(point2);
}
public override int GetHashCode()
{
return x.GetHashCode() ^ y.GetHashCode();
}
public override bool Equals(object obj)
{
if (!(obj is PointF))
{
return false;
}
return Equals((PointF)obj);
}
public bool Equals(PointF other)
{
if (x != other.x)
{
return false;
}
return y == other.y;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.