CameraIntrinsics.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using RootSystem = System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. namespace Windows.Kinect
  5. {
  6. //
  7. // Windows.Kinect.CameraIntrinsics
  8. //
  9. [RootSystem.Runtime.InteropServices.StructLayout(RootSystem.Runtime.InteropServices.LayoutKind.Sequential)]
  10. public struct CameraIntrinsics
  11. {
  12. public float FocalLengthX { get; set; }
  13. public float FocalLengthY { get; set; }
  14. public float PrincipalPointX { get; set; }
  15. public float PrincipalPointY { get; set; }
  16. public float RadialDistortionSecondOrder { get; set; }
  17. public float RadialDistortionFourthOrder { get; set; }
  18. public float RadialDistortionSixthOrder { get; set; }
  19. public override int GetHashCode()
  20. {
  21. return FocalLengthX.GetHashCode() ^ FocalLengthY.GetHashCode() ^
  22. PrincipalPointX.GetHashCode() ^ PrincipalPointY.GetHashCode() ^
  23. RadialDistortionSecondOrder.GetHashCode() ^ RadialDistortionFourthOrder.GetHashCode() ^
  24. RadialDistortionSixthOrder.GetHashCode();
  25. }
  26. public override bool Equals(object obj)
  27. {
  28. if (!(obj is CameraIntrinsics))
  29. {
  30. return false;
  31. }
  32. return this.Equals((CameraIntrinsics)obj);
  33. }
  34. public bool Equals(CameraIntrinsics obj)
  35. {
  36. return FocalLengthX.Equals(obj.FocalLengthX) && FocalLengthY.Equals(obj.FocalLengthY) &&
  37. PrincipalPointX.Equals(obj.PrincipalPointX) && PrincipalPointY.Equals(obj.PrincipalPointY) &&
  38. RadialDistortionSecondOrder.Equals(obj.RadialDistortionSecondOrder) &&
  39. RadialDistortionFourthOrder.Equals(obj.RadialDistortionFourthOrder) &&
  40. RadialDistortionSixthOrder.Equals(obj.RadialDistortionSixthOrder);
  41. }
  42. public static bool operator ==(CameraIntrinsics a, CameraIntrinsics b)
  43. {
  44. return a.Equals(b);
  45. }
  46. public static bool operator !=(CameraIntrinsics a, CameraIntrinsics b)
  47. {
  48. return !(a.Equals(b));
  49. }
  50. }
  51. }