XDKDefines.cs 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. using System;
  2. using System.Text;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.Events;
  6. namespace Seengene.XDKUnityPluginCloud {
  7. #region enum
  8. public enum MapQueryStatus {
  9. MAP_SUCCESS = 0,
  10. MAP_FAIL = 1
  11. }
  12. public enum SmoothMoveType {
  13. Linear = 0,
  14. EaseInOut = 1
  15. }
  16. public enum RelocalizeQueryStatus {
  17. // BA success, the result is filtered, implies FRAME_SUCCESS
  18. // In this status, m_inliers_3d_vector contains the set of all 3D points in the BA window
  19. SUCCESS = 0,
  20. // relocalization for current frame is successful, but BA failed
  21. FRAME_SUCCESS_BA_FAIL = 1,
  22. // the requested map is not ready yet on this server
  23. // user should request map first
  24. MAP_FAIL = 2,
  25. // relocalization for current frame is unsuccessful
  26. RELOCALIZE_FAIL = 3,
  27. // BA session is not found for this query, client should request map again
  28. BA_SESSION_EXPIRED = 4
  29. }
  30. public enum DebugInfoType {
  31. Normal = 0,
  32. UpdateFrameNative = 1,
  33. GetSpatialMappingNative = 2
  34. }
  35. #endregion of enum
  36. #region Custom Data Structure
  37. /// <summary>
  38. /// 请求地图,获得session id
  39. /// </summary>
  40. public class RequestMapKeys {
  41. // Request
  42. public const byte RequestType_MapId = 0; // 地图ID
  43. // Response
  44. public const byte ResponseType_SessionId = 0; // session id
  45. public const byte ResponseType_Status = 1; // 请求地图结果状态码
  46. public const byte ResponseType_Scale = 2; // 地图缩放值,暂时没有使用
  47. }
  48. /// <summary>
  49. /// 请求定位,获得定位结果
  50. /// </summary>
  51. public class RelocalizeKeys {
  52. // Request
  53. public const byte RequestType_SessionId = 0; // session id
  54. public const byte RequestType_Seq = 1; // 一个session内的顺序码
  55. public const byte RequestType_Pose = 2; // 当前追踪的位姿
  56. public const byte RequestType_Intrinsics = 3; // 当前图像的内参
  57. public const byte RequestType_Image = 4; // 图像数据
  58. public const byte RequestType_MapID = 5; // 地图id(optional for wechat applet)
  59. public const byte RequestType_CameraModel = 6; // 相机模型(optional for glass, 0:pinhole 1:fisheye 2:others)
  60. public const byte RequestType_DitortionPara = 7; // 相机畸变参数(optional for glass)
  61. // Response
  62. public const byte ResponseType_Status = 0; // 定位结果状态码
  63. public const byte ResponseType_Seq = 1; // 针对session内这个seq请求的定位结果
  64. public const byte ResponseType_Point2dVec = 2; // 2D点向量
  65. public const byte ResponseType_Point3dVec = 3; // 3D点向量
  66. public const byte ResponseType_TransformLtg = 4; // local to global transform
  67. public const byte ResponseType_ExtraMsg = 5; // 其他信息,说明用字符串
  68. }
  69. public class AuthorizationResponse {
  70. public string sessionID;
  71. public Int32 status;
  72. public double scale;
  73. public AuthorizationResponse() { }
  74. public AuthorizationResponse(Int32 status, double scale, string sessionID) {
  75. this.status = status;
  76. this.scale = scale;
  77. this.sessionID = sessionID;
  78. }
  79. public override string ToString() {
  80. return string.Format("AuthorizationResponse status:{0}, scale:{1}, sessionID:{2}", status, scale, sessionID);
  81. }
  82. }
  83. public class RelocationResponse {
  84. public Int32 status;
  85. public Int32 seq;
  86. public List<Vector2> point2d_vec = new List<Vector2>();
  87. public List<Vector3> point3d_vec = new List<Vector3>();
  88. public List<double> transform_ltg = new List<double>();
  89. public string extra_msg;
  90. public Matrix4x4 cameraPos;
  91. public CameraCalibration cameraCalibration;
  92. public string sessionID;
  93. public RelocationResponse() { }
  94. public RelocationResponse(Int32 status, Int32 seq, List<Vector2> point2d_vec, List<Vector3> point3d_vec, List<double> transform_ltg, string extra_msg, Matrix4x4 cameraPos, CameraCalibration cameraCalibration, string sessionID) {
  95. this.status = status;
  96. this.seq = seq;
  97. this.point2d_vec = point2d_vec;
  98. this.point3d_vec = point3d_vec;
  99. this.transform_ltg = transform_ltg;
  100. this.extra_msg = extra_msg;
  101. this.cameraPos = cameraPos;
  102. this.cameraCalibration = cameraCalibration;
  103. this.sessionID = sessionID;
  104. }
  105. public override string ToString() {
  106. return string.Format("RelocationResponse status:{0}, seq:{1}, point2d_vec:{2}, point3d_vec:{3}, transform_ltg:{4}, extra_msg:{5}",
  107. status, seq, XDKTools.ListVectro2ToString(point2d_vec), XDKTools.ListVector3ToString(point3d_vec), XDKTools.ListDoubleToString(transform_ltg), extra_msg);
  108. }
  109. }
  110. [System.Serializable]
  111. public class RelocUploadImageItem {
  112. public string sessionID;
  113. public Int32 seq;
  114. public Matrix4x4 cameraPose;
  115. public CameraCalibration cameraCalibration;
  116. public byte[] imageBytes;
  117. public RelocUploadImageItem() { }
  118. public RelocUploadImageItem(string sessionID, Int32 seq, Matrix4x4 cameraPose, CameraCalibration cameraCalibration, byte[] imageBytes) {
  119. this.sessionID = sessionID;
  120. this.seq = seq;
  121. this.cameraPose = cameraPose;
  122. this.cameraCalibration = cameraCalibration;
  123. this.imageBytes = imageBytes;
  124. }
  125. public override string ToString() {
  126. StringBuilder sb = new StringBuilder();
  127. sb.Append("RelocUploadImageItem: ");
  128. sb.Append("sessionID: " + sessionID + "; ");
  129. sb.Append("seq: " + seq + "; ");
  130. sb.Append("cameraPose: " + cameraPose.ToString() + "; ");
  131. sb.Append("cameraCalibration: " + cameraCalibration.ToString() + "; ");
  132. sb.Append("imageBytes(0-100): " + XDKTools.GetBytesString(imageBytes, 0, 100, ", ") + "; ");
  133. return sb.ToString();
  134. }
  135. }
  136. #endregion of Custom Data Structure
  137. #region Cumsom UnityEvent
  138. [System.Serializable]
  139. public class UnityEventBool : UnityEvent<bool> { }
  140. #endregion of Cumsom UnityEvent
  141. }