-
-
Save OndroNR/ed20afdd6b1a62efa1a8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <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; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// STDMETHOD(Get2DShapePoints)(THIS_ FT_VECTOR2D** ppPoints, UINT* pPointCount) PURE; | |
void Get2DShapePoints(out IntPtr pointsPtr, out uint pointCount); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <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