NxrSensor.cs 61 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215
  1. using Assets.NXR.Scripts.Slam;
  2. using UnityEngine;
  3. public class NxrSensor
  4. {
  5. private static object syncRoot = new object();
  6. private static NxrSensor _instance = null;
  7. public static NxrSensor Instance
  8. {
  9. get
  10. {
  11. if (_instance == null)
  12. {
  13. lock (syncRoot)
  14. {
  15. if (_instance == null)
  16. {
  17. _instance = new NxrSensor();
  18. }
  19. }
  20. }
  21. return _instance;
  22. }
  23. }
  24. private AndroidJavaClass nxrSensorClass;
  25. private AndroidJavaObject nxrSensorInstance;
  26. private AndroidJavaClass nxrSensorProClass;
  27. private AndroidJavaObject nxrSensorProInstance;
  28. private AndroidJavaClass xvGestureTypeClass;
  29. private AndroidJavaClass rawDataTypeClass;
  30. private AndroidJavaClass rgbResolutionClass;
  31. private AndroidJavaClass tofFPSClass;
  32. private AndroidJavaClass tofStreamModeClass;
  33. private AndroidJavaClass distanceModeClass;
  34. private AndroidJavaClass thermalModeClass;
  35. private AndroidJavaClass planeTypeClass;
  36. private AndroidJavaClass xvLogLevelClass;
  37. public NxrSensor()
  38. {
  39. #if UNITY_ANDROID
  40. if (nxrSensorClass == null)
  41. {
  42. nxrSensorClass = new AndroidJavaClass("ruiyue.nxrsensor.library.NxrXvLibrary");
  43. }
  44. if (nxrSensorClass != null && nxrSensorInstance == null)
  45. {
  46. nxrSensorInstance = nxrSensorClass.CallStatic<AndroidJavaObject>("getInstance");
  47. }
  48. if (nxrSensorProClass == null)
  49. {
  50. nxrSensorProClass = new AndroidJavaClass("com.nibiru.nxrsensor.NxrSensor");
  51. }
  52. if (nxrSensorProClass != null && nxrSensorProInstance == null)
  53. {
  54. nxrSensorProInstance = nxrSensorProClass.CallStatic<AndroidJavaObject>("getInstance");
  55. }
  56. #endif
  57. }
  58. public AndroidJavaObject NxrSensorInstance
  59. {
  60. get { return nxrSensorInstance; }
  61. }
  62. public bool InitLibrary()
  63. {
  64. if (nxrSensorInstance != null)
  65. {
  66. return nxrSensorInstance.Call<bool>("initLibrary");
  67. }
  68. return false;
  69. }
  70. public void UninitLibrary()
  71. {
  72. if (nxrSensorInstance != null)
  73. {
  74. nxrSensorInstance.Call("uninitLibrary");
  75. }
  76. }
  77. #region Slam
  78. public enum PlaneType
  79. {
  80. NONE,
  81. TOF,
  82. STEREO
  83. }
  84. public enum SlamMode
  85. {
  86. Edge,
  87. Mixed,
  88. EdgeFusionOnHost,
  89. NONE
  90. }
  91. public NxrTrackingData GetTrackingDataAt(long paramLong)
  92. {
  93. if (nxrSensorInstance != null)
  94. {
  95. var javaObject = nxrSensorInstance.Call<AndroidJavaObject>("getTrackingDataAt", paramLong);
  96. if (javaObject != null)
  97. {
  98. return new NxrTrackingData(javaObject);
  99. }
  100. }
  101. return null;
  102. }
  103. public class NxrTrackingData
  104. {
  105. public float[] rotation;
  106. public float[] translation;
  107. public float[] prediction_coff_s;
  108. public float[] prediction_coff_b;
  109. public float[] prediction_coff_bdt;
  110. public float[] prediction_coff_bdt2;
  111. public long fetchTimestamp;
  112. public long timestamp;
  113. public int source;
  114. public int black;
  115. public int rotateY;
  116. private AndroidJavaObject androidJavaObject;
  117. public NxrTrackingData()
  118. {
  119. }
  120. public NxrTrackingData(AndroidJavaObject javaObject)
  121. {
  122. androidJavaObject = javaObject;
  123. rotation = javaObject.Get<float[]>("rotation");
  124. rotation[2] *= -1;
  125. translation = javaObject.Get<float[]>("translation");
  126. translation[2] *= -1;
  127. prediction_coff_s = javaObject.Get<float[]>("prediction_coff_s");
  128. prediction_coff_b = javaObject.Get<float[]>("prediction_coff_b");
  129. prediction_coff_bdt = javaObject.Get<float[]>("prediction_coff_bdt");
  130. prediction_coff_bdt2 = javaObject.Get<float[]>("prediction_coff_bdt2");
  131. fetchTimestamp = javaObject.Get<long>("fetchTimestamp");
  132. timestamp = javaObject.Get<long>("timestamp");
  133. source = javaObject.Get<int>("source");
  134. black = javaObject.Get<int>("black");
  135. rotateY = javaObject.Get<int>("rotateY");
  136. }
  137. public string toString()
  138. {
  139. if (androidJavaObject != null)
  140. {
  141. return androidJavaObject.Call<string>("toString");
  142. }
  143. return "";
  144. }
  145. }
  146. public void RegisterPoseCallback()
  147. {
  148. if (nxrSensorInstance != null)
  149. {
  150. nxrSensorInstance.Call("registerPoseCallback", new OnPoseListener());
  151. }
  152. }
  153. public delegate void PoseCallback(NxrTrackingData nxrTrackingData);
  154. public PoseCallback PoseEvent;
  155. public class OnPoseListener : AndroidJavaProxy
  156. {
  157. public OnPoseListener() : base("ruiyue.nxrsensor.library.listener.OnPoseListener")
  158. {
  159. }
  160. public void onPose(AndroidJavaObject paramNxrTrackingData)
  161. {
  162. if (paramNxrTrackingData != null)
  163. {
  164. var nxrTrackingData = new NxrTrackingData(paramNxrTrackingData);
  165. if (Instance.PoseEvent != null)
  166. {
  167. Instance.PoseEvent(nxrTrackingData);
  168. }
  169. }
  170. else
  171. {
  172. Debug.LogError("AndroidJavaObject paramNxrTrackingData is null !!!");
  173. }
  174. }
  175. }
  176. public bool StartPlaneDetection(PlaneType type)
  177. {
  178. if (nxrSensorInstance != null)
  179. {
  180. Debug.Log("StartPlaneDetection:[type=" + type + "]");
  181. if (planeTypeClass != null)
  182. {
  183. planeTypeClass = new AndroidJavaClass("ruiyue.nxrsensor.library.type.PlaneType");
  184. }
  185. var typeObj = planeTypeClass.CallStatic<AndroidJavaObject>("valueOf", type.ToString());
  186. return nxrSensorInstance.Call<bool>("startPlaneDetection", typeObj, new OnPlaneDetectionListener());
  187. }
  188. return false;
  189. }
  190. public bool StopPlaneDetection(int type)
  191. {
  192. if (nxrSensorInstance != null)
  193. {
  194. return nxrSensorInstance.Call<bool>("stopPlaneDetection", type);
  195. }
  196. return false;
  197. }
  198. public class NxrPlaneData
  199. {
  200. public long hostTimestamp = 0L;
  201. public long deviceTimestamp = 0L;
  202. public NxrPointD[] points;
  203. public NxrPointD normal = new NxrPointD();
  204. public int size;
  205. public int id = -1;
  206. public NxrPlaneData(AndroidJavaObject javaObject)
  207. {
  208. hostTimestamp = javaObject.Get<long>("hostTimestamp");
  209. deviceTimestamp = javaObject.Get<long>("deviceTimestamp");
  210. var pointsObj = javaObject.Get<AndroidJavaObject>("points");
  211. if (pointsObj != null)
  212. {
  213. if (pointsObj.GetRawObject().ToInt32() != 0)
  214. {
  215. var pointsObjArray =
  216. AndroidJNIHelper.ConvertFromJNIArray<AndroidJavaObject[]>(pointsObj.GetRawObject());
  217. points = new NxrPointD[pointsObjArray.Length];
  218. for (var i = 0; i < points.Length; i++)
  219. {
  220. var point = new NxrPointD();
  221. point.x = pointsObjArray[i].Get<double>("x");
  222. point.y = pointsObjArray[i].Get<double>("y");
  223. point.z = pointsObjArray[i].Get<double>("z");
  224. points[i] = point;
  225. pointsObjArray[i].Dispose();
  226. }
  227. }
  228. pointsObj.Dispose();
  229. }
  230. var normalObj = javaObject.Get<AndroidJavaObject>("normal");
  231. if (normalObj != null)
  232. {
  233. normal.x = normalObj.Get<double>("x");
  234. normal.y = normalObj.Get<double>("y");
  235. normal.z = normalObj.Get<double>("z");
  236. normalObj.Dispose();
  237. }
  238. size = javaObject.Get<int>("size");
  239. id = javaObject.Get<int>("id");
  240. }
  241. }
  242. public class NxrPointD
  243. {
  244. public double x;
  245. public double y;
  246. public double z;
  247. }
  248. public delegate void PlaneDetectedCallback(NxrPlaneData nxrPlaneData);
  249. public PlaneDetectedCallback PlaneDetectedEvent;
  250. public class OnPlaneDetectionListener : AndroidJavaProxy
  251. {
  252. public OnPlaneDetectionListener() : base("ruiyue.nxrsensor.library.listener.OnPlaneDetectionListener")
  253. {
  254. }
  255. public void onPlaneDetected(AndroidJavaObject paramNxrPlaneData)
  256. {
  257. if (paramNxrPlaneData != null)
  258. {
  259. var nxrPlaneData = new NxrPlaneData(paramNxrPlaneData);
  260. if (Instance.PlaneDetectedEvent != null)
  261. {
  262. Instance.PlaneDetectedEvent(nxrPlaneData);
  263. }
  264. }
  265. else
  266. {
  267. Debug.LogError("AndroidJavaObject paramNxrPlaneData is null !!!");
  268. }
  269. }
  270. }
  271. public int RegisterMapCallback()
  272. {
  273. if (nxrSensorInstance != null)
  274. {
  275. return nxrSensorInstance.Call<int>("registerMapCallback", new OnMapV2Listener());
  276. }
  277. return -1;
  278. }
  279. public bool UnregisterMapCallback(int callbackId)
  280. {
  281. if (nxrSensorInstance != null)
  282. {
  283. return nxrSensorInstance.Call<bool>("unregisterMapCallback", callbackId);
  284. }
  285. return false;
  286. }
  287. public delegate void MapV2Callback(NxrPointD[] nxrPointDs);
  288. public MapV2Callback MapV2Event;
  289. public class OnMapV2Listener : AndroidJavaProxy
  290. {
  291. public OnMapV2Listener() : base("ruiyue.nxrsensor.library.listener.OnMapV2Listener")
  292. {
  293. }
  294. public void onMapV2(AndroidJavaObject paramArrayOfNxrPointD)
  295. {
  296. if (paramArrayOfNxrPointD != null)
  297. {
  298. if (paramArrayOfNxrPointD.GetRawObject().ToInt32() != 0)
  299. {
  300. var nxrPointDArray =
  301. AndroidJNIHelper.ConvertFromJNIArray<AndroidJavaObject[]>(paramArrayOfNxrPointD.GetRawObject());
  302. var points = new NxrPointD[nxrPointDArray.Length];
  303. for (var i = 0; i < points.Length; i++)
  304. {
  305. var point = new NxrPointD();
  306. point.x = nxrPointDArray[i].Get<double>("x");
  307. point.y = nxrPointDArray[i].Get<double>("y");
  308. point.z = nxrPointDArray[i].Get<double>("z");
  309. points[i] = point;
  310. nxrPointDArray[i].Dispose();
  311. }
  312. if (Instance.MapV2Event != null)
  313. {
  314. Instance.MapV2Event(points);
  315. }
  316. }
  317. }
  318. else
  319. {
  320. Debug.LogError("AndroidJavaObject paramArrayOfNxrPointD is null !!!");
  321. }
  322. }
  323. }
  324. public bool LoadMapAndSwitchToCslam(string path)
  325. {
  326. if (nxrSensorInstance != null)
  327. {
  328. return nxrSensorInstance.Call<bool>("loadMapAndSwitchToCslam", path, new OnMapListener());
  329. }
  330. return false;
  331. }
  332. public bool SaveMapAndSwitchToCslam(string path)
  333. {
  334. if (nxrSensorInstance != null)
  335. {
  336. return nxrSensorInstance.Call<bool>("saveMapAndSwitchToCslam", path, new OnMapListener());
  337. }
  338. return false;
  339. }
  340. public delegate void MapPercentCallback(float paramFloat);
  341. public delegate void MapStatusAndQualityCallback(int paramInt1, int paramInt2);
  342. public MapPercentCallback MapPercentEvent;
  343. public MapStatusAndQualityCallback MapStatusAndQualityEvent;
  344. public class OnMapListener : AndroidJavaProxy
  345. {
  346. public OnMapListener() : base("ruiyue.nxrsensor.library.listener.OnMapListener")
  347. {
  348. }
  349. public void onMapPercent(float paramFloat)
  350. {
  351. if (Instance.MapPercentEvent != null)
  352. {
  353. Instance.MapPercentEvent(paramFloat);
  354. }
  355. }
  356. public void onMapStatusAndQuality(int paramInt1, int paramInt2)
  357. {
  358. if (Instance.MapStatusAndQualityEvent != null)
  359. {
  360. Instance.MapStatusAndQualityEvent(paramInt1, paramInt2);
  361. }
  362. }
  363. }
  364. public SlamMode GetSlamMode()
  365. {
  366. if (nxrSensorInstance != null)
  367. {
  368. var slamModeObj = nxrSensorInstance.Call<AndroidJavaObject>("getSlamMode");
  369. if (slamModeObj != null)
  370. {
  371. return (SlamMode) slamModeObj.Call<int>("ordinal");
  372. }
  373. }
  374. return SlamMode.NONE;
  375. }
  376. #endregion
  377. #region Gesture
  378. public enum XvGestureType
  379. {
  380. NONE,
  381. NORMAL,
  382. DYNAMIC_OR_SLAM
  383. }
  384. public bool StartGesture(XvGestureType type)
  385. {
  386. if (nxrSensorInstance != null)
  387. {
  388. if (xvGestureTypeClass == null)
  389. {
  390. xvGestureTypeClass = new AndroidJavaClass("ruiyue.nxrsensor.library.type.XvGestureType");
  391. }
  392. var typeObj = xvGestureTypeClass.CallStatic<AndroidJavaObject>("valueOf", type.ToString());
  393. return nxrSensorInstance.Call<bool>("startGesture", typeObj, new OnGestureListener());
  394. }
  395. return false;
  396. }
  397. public bool StopGesture(int type)
  398. {
  399. if (nxrSensorInstance != null)
  400. {
  401. return nxrSensorInstance.Call<bool>("stopGesture", type);
  402. }
  403. return false;
  404. }
  405. public class NxrGesture
  406. {
  407. public int size;
  408. public int[] gesture;
  409. public float distance;
  410. public float confidence;
  411. public NxrPointF[] position;
  412. public NxrPointF[] slamPosition;
  413. public long dataFetchTimeMs;
  414. public long dataTimeStampMs;
  415. public NxrGesture(AndroidJavaObject javaObject)
  416. {
  417. size = javaObject.Get<int>("size");
  418. gesture = javaObject.Get<int[]>("gesture");
  419. distance = javaObject.Get<float>("distance");
  420. confidence = javaObject.Get<float>("confidence");
  421. var positionObj = javaObject.Get<AndroidJavaObject>("position");
  422. if (positionObj != null)
  423. {
  424. if (positionObj.GetRawObject().ToInt32() != 0)
  425. {
  426. var positionObjArray =
  427. AndroidJNIHelper.ConvertFromJNIArray<AndroidJavaObject[]>(positionObj.GetRawObject());
  428. position = new NxrPointF[positionObjArray.Length];
  429. for (var i = 0; i < position.Length; i++)
  430. {
  431. var tempPosition = new NxrPointF();
  432. tempPosition.x = positionObjArray[i].Get<float>("x");
  433. tempPosition.y = positionObjArray[i].Get<float>("y");
  434. tempPosition.z = positionObjArray[i].Get<float>("z");
  435. position[i] = tempPosition;
  436. positionObjArray[i].Dispose();
  437. }
  438. }
  439. positionObj.Dispose();
  440. }
  441. var slamPositionObj = javaObject.Get<AndroidJavaObject>("slamPosition");
  442. if (slamPositionObj != null)
  443. {
  444. if (slamPositionObj.GetRawObject().ToInt32() != 0)
  445. {
  446. var slamPositionObjArray =
  447. AndroidJNIHelper.ConvertFromJNIArray<AndroidJavaObject[]>(slamPositionObj.GetRawObject());
  448. slamPosition = new NxrPointF[slamPositionObjArray.Length];
  449. for (var i = 0; i < slamPosition.Length; i++)
  450. {
  451. var tempSlamPosition = new NxrPointF();
  452. tempSlamPosition.x = slamPositionObjArray[i].Get<float>("x");
  453. tempSlamPosition.y = slamPositionObjArray[i].Get<float>("y");
  454. tempSlamPosition.z = slamPositionObjArray[i].Get<float>("z");
  455. slamPosition[i] = tempSlamPosition;
  456. slamPositionObjArray[i].Dispose();
  457. }
  458. }
  459. slamPositionObj.Dispose();
  460. }
  461. dataFetchTimeMs = javaObject.Get<long>("dataFetchTimeMs");
  462. dataTimeStampMs = javaObject.Get<long>("dataTimeStampMs");
  463. }
  464. }
  465. public class NxrPointF
  466. {
  467. public float x;
  468. public float y;
  469. public float z;
  470. }
  471. public delegate void GestureCallback(NxrGesture nxrGesture);
  472. public GestureCallback GestureEvent;
  473. public class OnGestureListener : AndroidJavaProxy
  474. {
  475. public OnGestureListener() : base("ruiyue.nxrsensor.library.listener.OnGestureListener")
  476. {
  477. }
  478. public void onGesture(AndroidJavaObject paramNxrGesture)
  479. {
  480. if (paramNxrGesture != null)
  481. {
  482. var nxrGesture = new NxrGesture(paramNxrGesture);
  483. if (Instance.GestureEvent != null)
  484. {
  485. Instance.GestureEvent(nxrGesture);
  486. }
  487. }
  488. else
  489. {
  490. Debug.LogError("AndroidJavaObject paramNxrGesture is null !!!");
  491. }
  492. }
  493. }
  494. public bool StartSkeleton(XvGestureType type)
  495. {
  496. if (nxrSensorInstance != null)
  497. {
  498. var isStartSlam = nxrSensorInstance.Call<bool>("startSlam");
  499. if (isStartSlam)
  500. {
  501. if (xvGestureTypeClass == null)
  502. {
  503. xvGestureTypeClass = new AndroidJavaClass("ruiyue.nxrsensor.library.type.XvGestureType");
  504. }
  505. var typeObj = xvGestureTypeClass.CallStatic<AndroidJavaObject>("valueOf", type.ToString());
  506. return nxrSensorInstance.Call<bool>("startSkeleton", typeObj, new OnSkeletonListener());
  507. }
  508. }
  509. return false;
  510. }
  511. public bool StopSkeleton(int type)
  512. {
  513. if (nxrSensorInstance != null)
  514. {
  515. return nxrSensorInstance.Call<bool>("stopSkeleton", type);
  516. }
  517. return false;
  518. }
  519. public class NxrSkeleton
  520. {
  521. public int size;
  522. public NxrPointF[][] joints;
  523. public long dataFetchTimeMS;
  524. public long dataTimeStampMs;
  525. public NxrPointF[] joints0;
  526. public NxrPointF[] joints1;
  527. public NxrSkeleton(AndroidJavaObject javaObject)
  528. {
  529. size = javaObject.Get<int>("size");
  530. dataFetchTimeMS = javaObject.Get<long>("dataFetchTimeMS");
  531. dataTimeStampMs = javaObject.Get<long>("dataTimeStampMs");
  532. var joints0Array = javaObject.Get<AndroidJavaObject[]>("joints0");
  533. var joints1Array = javaObject.Get<AndroidJavaObject[]>("joints1");
  534. joints0 = new NxrPointF[joints0Array.Length];
  535. joints1 = new NxrPointF[joints1Array.Length];
  536. for (var i = 0; i < joints0.Length; i++)
  537. {
  538. var joint0 = new NxrPointF();
  539. joint0.x = joints0Array[i].Get<float>("x");
  540. joint0.y = joints0Array[i].Get<float>("y");
  541. joint0.z = joints0Array[i].Get<float>("z");
  542. var joint1 = new NxrPointF();
  543. joint1.x = joints1Array[i].Get<float>("x");
  544. joint1.y = joints1Array[i].Get<float>("y");
  545. joint1.z = joints1Array[i].Get<float>("z");
  546. joints0[i] = joint0;
  547. joints1[i] = joint1;
  548. joints0Array[i].Dispose();
  549. joints1Array[i].Dispose();
  550. }
  551. joints = new NxrPointF[2][];
  552. joints[0] = joints0;
  553. joints[1] = joints1;
  554. }
  555. }
  556. public delegate void SkeletonCallback(NxrSkeleton nxrSkeleton);
  557. public SkeletonCallback SkeletonEvent;
  558. public class OnSkeletonListener : AndroidJavaProxy
  559. {
  560. public OnSkeletonListener() : base("ruiyue.nxrsensor.library.listener.OnSkeletonListener")
  561. {
  562. }
  563. public void onSkeleton(AndroidJavaObject paramNxrSkeleton)
  564. {
  565. if (paramNxrSkeleton != null)
  566. {
  567. var nxrSkeleton = new NxrSkeleton(paramNxrSkeleton);
  568. if (Instance.SkeletonEvent != null)
  569. {
  570. Instance.SkeletonEvent(nxrSkeleton);
  571. }
  572. }
  573. else
  574. {
  575. Debug.LogError("AndroidJavaObject paramNxrSkeleton is null !!!");
  576. }
  577. }
  578. }
  579. public void SetConfigPath(string path)
  580. {
  581. if (nxrSensorInstance != null)
  582. {
  583. nxrSensorInstance.Call("setConfigPath", path);
  584. }
  585. }
  586. #endregion
  587. #region Apriltag
  588. public string StartTagDetector(string tagFamliy, double size, double refreshRate)
  589. {
  590. if (nxrSensorInstance != null)
  591. {
  592. return nxrSensorInstance.Call<string>("startTagDetector", tagFamliy, size, refreshRate);
  593. }
  594. return null;
  595. }
  596. public bool StopTagDetector(string detectorId)
  597. {
  598. if (nxrSensorInstance != null)
  599. {
  600. return nxrSensorInstance.Call<bool>("stopTagDetector", detectorId);
  601. }
  602. return false;
  603. }
  604. public TagDetection[] GetTagDetections(string detectorId)
  605. {
  606. if (nxrSensorInstance != null)
  607. {
  608. var tagDetectionsObj = nxrSensorInstance.Call<AndroidJavaObject>("getTagDetections", detectorId);
  609. if (tagDetectionsObj != null)
  610. {
  611. var tagDetectionsArray =
  612. AndroidJNIHelper.ConvertFromJNIArray<AndroidJavaObject[]>(tagDetectionsObj.GetRawObject());
  613. var tagDetections = new TagDetection[tagDetectionsArray.Length];
  614. for (var i = 0; i < tagDetections.Length; i++)
  615. {
  616. tagDetections[i] = new TagDetection(tagDetectionsArray[i]);
  617. tagDetectionsArray[i].Dispose();
  618. }
  619. tagDetectionsObj.Dispose();
  620. return tagDetections;
  621. }
  622. }
  623. return null;
  624. }
  625. public TagDetection[] DetectTags(string tagFamliy, double size)
  626. {
  627. if (nxrSensorInstance != null)
  628. {
  629. var tagDetectionsObj = nxrSensorInstance.Call<AndroidJavaObject>("detectTags", tagFamliy, size);
  630. if (tagDetectionsObj != null)
  631. {
  632. var tagDetectionsArray =
  633. AndroidJNIHelper.ConvertFromJNIArray<AndroidJavaObject[]>(tagDetectionsObj.GetRawObject());
  634. var tagDetections = new TagDetection[tagDetectionsArray.Length];
  635. for (var i = 0; i < tagDetections.Length; i++)
  636. {
  637. tagDetections[i] = new TagDetection(tagDetectionsArray[i]);
  638. tagDetectionsArray[i].Dispose();
  639. }
  640. tagDetectionsObj.Dispose();
  641. return tagDetections;
  642. }
  643. }
  644. return null;
  645. }
  646. public class TagDetection
  647. {
  648. public int id;
  649. public float[] quaternion;
  650. public float[] translation;
  651. public float[] rotation;
  652. public TagDetection(AndroidJavaObject javaObject)
  653. {
  654. id = javaObject.Get<int>("id");
  655. quaternion = javaObject.Get<float[]>("quaternion");
  656. quaternion[2] *= -1;
  657. translation = javaObject.Get<float[]>("translation");
  658. translation[2] *= -1;
  659. rotation = javaObject.Get<float[]>("rotation");
  660. }
  661. }
  662. public void SetTagsMap(string tagFamliy, double tagSize, int[] tagIds, NxrTrackingData[] transforms)
  663. {
  664. if (nxrSensorProInstance != null && transforms != null)
  665. {
  666. var nxrTrackingDataSize = transforms.Length;
  667. var rotation_size = new int[nxrTrackingDataSize];
  668. var translation_size = new int[nxrTrackingDataSize];
  669. var prediction_coff_s_size = new int[nxrTrackingDataSize];
  670. var prediction_coff_b_size = new int[nxrTrackingDataSize];
  671. var prediction_coff_bdt_size = new int[nxrTrackingDataSize];
  672. var prediction_coff_bdt2_size = new int[nxrTrackingDataSize];
  673. var rotation_count = 0;
  674. var translation_count = 0;
  675. var prediction_coff_s_count = 0;
  676. var prediction_coff_b_count = 0;
  677. var prediction_coff_bdt_count = 0;
  678. var prediction_coff_bdt2_count = 0;
  679. var fetchTimestamp = new long[nxrTrackingDataSize];
  680. var timestamp = new long[nxrTrackingDataSize];
  681. var source = new int[nxrTrackingDataSize];
  682. var black = new int[nxrTrackingDataSize];
  683. var rotateY = new int[nxrTrackingDataSize];
  684. for (var i = 0; i < nxrTrackingDataSize; i++)
  685. {
  686. rotation_size[i] = transforms[i].rotation.Length;
  687. translation_size[i] = transforms[i].translation.Length;
  688. prediction_coff_s_size[i] = transforms[i].prediction_coff_s.Length;
  689. prediction_coff_b_size[i] = transforms[i].prediction_coff_b.Length;
  690. prediction_coff_bdt_size[i] = transforms[i].prediction_coff_bdt.Length;
  691. prediction_coff_bdt2_size[i] = transforms[i].prediction_coff_bdt2.Length;
  692. rotation_count += rotation_size[i];
  693. translation_count += translation_size[i];
  694. prediction_coff_s_count += prediction_coff_s_size[i];
  695. prediction_coff_b_count += prediction_coff_b_size[i];
  696. prediction_coff_bdt_count += prediction_coff_bdt_size[i];
  697. prediction_coff_bdt2_count += prediction_coff_bdt2_size[i];
  698. fetchTimestamp[i] = transforms[i].fetchTimestamp;
  699. timestamp[i] = transforms[i].timestamp;
  700. source[i] = transforms[i].source;
  701. black[i] = transforms[i].black;
  702. rotateY[i] = transforms[i].rotateY;
  703. }
  704. var rotation = new float[rotation_count];
  705. var translation = new float[translation_count];
  706. var prediction_coff_s = new float[prediction_coff_s_count];
  707. var prediction_coff_b = new float[prediction_coff_b_count];
  708. var prediction_coff_bdt = new float[prediction_coff_bdt_count];
  709. var prediction_coff_bdt2 = new float[prediction_coff_bdt2_count];
  710. var count = 0;
  711. for (var i = 0; i < nxrTrackingDataSize; i++)
  712. {
  713. for (int j = 0; j < rotation_size[i]; j++)
  714. {
  715. rotation[count] = transforms[i].rotation[j];
  716. count++;
  717. }
  718. }
  719. count = 0;
  720. for (var i = 0; i < nxrTrackingDataSize; i++)
  721. {
  722. for (int j = 0; j < translation_size[i]; j++)
  723. {
  724. translation[count] = transforms[i].translation[j];
  725. count++;
  726. }
  727. }
  728. count = 0;
  729. for (var i = 0; i < nxrTrackingDataSize; i++)
  730. {
  731. for (int j = 0; j < prediction_coff_s_size[i]; j++)
  732. {
  733. prediction_coff_s[count] = transforms[i].prediction_coff_s[j];
  734. count++;
  735. }
  736. }
  737. count = 0;
  738. for (var i = 0; i < nxrTrackingDataSize; i++)
  739. {
  740. for (int j = 0; j < prediction_coff_b_size[i]; j++)
  741. {
  742. prediction_coff_b[count] = transforms[i].prediction_coff_b[j];
  743. count++;
  744. }
  745. }
  746. count = 0;
  747. for (var i = 0; i < nxrTrackingDataSize; i++)
  748. {
  749. for (int j = 0; j < prediction_coff_bdt_size[i]; j++)
  750. {
  751. prediction_coff_bdt[count] = transforms[i].prediction_coff_bdt[j];
  752. count++;
  753. }
  754. }
  755. count = 0;
  756. for (var i = 0; i < nxrTrackingDataSize; i++)
  757. {
  758. for (int j = 0; j < prediction_coff_bdt2_size[i]; j++)
  759. {
  760. prediction_coff_bdt2[count] = transforms[i].prediction_coff_bdt2[j];
  761. count++;
  762. }
  763. }
  764. nxrSensorProInstance.Call("setTagsMap", tagFamliy, tagSize, tagIds, nxrTrackingDataSize,
  765. rotation_size, translation_size, prediction_coff_s_size, prediction_coff_b_size,
  766. prediction_coff_bdt_size, prediction_coff_bdt2_size,
  767. rotation, translation, prediction_coff_s, prediction_coff_b, prediction_coff_bdt, prediction_coff_bdt2,
  768. fetchTimestamp, timestamp, source, black, rotateY);
  769. }
  770. }
  771. public NxrTrackingData GetTrackingDataInTagsMap(double prediction)
  772. {
  773. if (nxrSensorInstance != null)
  774. {
  775. var nxrTrackingDataObj = nxrSensorInstance.Call<AndroidJavaObject>("getTrackingDataInTagsMap", prediction);
  776. if (nxrTrackingDataObj != null)
  777. {
  778. return new NxrTrackingData(nxrTrackingDataObj);
  779. }
  780. }
  781. return null;
  782. }
  783. #endregion
  784. #region Display
  785. public DisplayCalibration ReadDisplayCalibrations()
  786. {
  787. if (nxrSensorInstance != null)
  788. {
  789. var javaObject = nxrSensorInstance.Call<AndroidJavaObject>("readDisplayCalibrations");
  790. if (javaObject != null)
  791. {
  792. return new DisplayCalibration(javaObject);
  793. }
  794. }
  795. return null;
  796. }
  797. public class DisplayCalibration
  798. {
  799. public float[][] K;
  800. public float[][] rotation;
  801. public float[][] translation;
  802. public float[] K0;
  803. public float[] K1;
  804. public float[] rotation0;
  805. public float[] rotation1;
  806. public float[] translation0;
  807. public float[] translation1;
  808. public DisplayCalibration(AndroidJavaObject javaObject)
  809. {
  810. K0 = javaObject.Get<float[]>("K0");
  811. K1 = javaObject.Get<float[]>("K1");
  812. rotation0 = javaObject.Get<float[]>("rotation0");
  813. rotation1 = javaObject.Get<float[]>("rotation1");
  814. translation0 = javaObject.Get<float[]>("translation0");
  815. translation1 = javaObject.Get<float[]>("translation1");
  816. K = new float[2][];
  817. K[0] = K0;
  818. K[1] = K1;
  819. rotation = new float[2][];
  820. rotation[0] = rotation0;
  821. rotation[1] = rotation1;
  822. translation = new float[2][];
  823. translation[0] = translation0;
  824. translation[1] = translation1;
  825. }
  826. }
  827. public void SetDisplayBrightnessLevel(int level)
  828. {
  829. if (nxrSensorInstance != null)
  830. {
  831. nxrSensorInstance.Call("setDisplayBrightnessLevel", level);
  832. }
  833. }
  834. public bool DisplayOpen()
  835. {
  836. if (nxrSensorInstance != null)
  837. {
  838. return nxrSensorInstance.Call<bool>("displayOpen");
  839. }
  840. return false;
  841. }
  842. public bool DisplayClose()
  843. {
  844. if (nxrSensorInstance != null)
  845. {
  846. return nxrSensorInstance.Call<bool>("displayClose");
  847. }
  848. return false;
  849. }
  850. #endregion
  851. #region Rgb
  852. public bool StartStreaming(NxrSlam.RawDataType type)
  853. {
  854. if (nxrSensorInstance != null)
  855. {
  856. if (rawDataTypeClass == null)
  857. {
  858. rawDataTypeClass = new AndroidJavaClass("ruiyue.nxrsensor.library.type.RawDataType");
  859. }
  860. var typeObj = rawDataTypeClass.CallStatic<AndroidJavaObject>("valueOf", type.ToString());
  861. return nxrSensorInstance.Call<bool>("startStreaming", typeObj, new OnStreamDataListener());
  862. }
  863. return false;
  864. }
  865. public bool StopStreaming(NxrSlam.RawDataType type)
  866. {
  867. if (nxrSensorInstance != null)
  868. {
  869. if (rawDataTypeClass == null)
  870. {
  871. rawDataTypeClass = new AndroidJavaClass("ruiyue.nxrsensor.library.type.RawDataType");
  872. }
  873. var typeObj = rawDataTypeClass.CallStatic<AndroidJavaObject>("valueOf", type.ToString());
  874. return nxrSensorInstance.Call<bool>("stopStreaming", typeObj);
  875. }
  876. return false;
  877. }
  878. public class NxrStreamData
  879. {
  880. public byte[] data;
  881. public byte[] left;
  882. public byte[] right;
  883. public int type;
  884. public int format;
  885. public int width;
  886. public int height;
  887. public int size;
  888. public int leftSize;
  889. public int rightSize;
  890. public long timestamp;
  891. public NxrStreamData()
  892. {
  893. }
  894. public NxrStreamData(AndroidJavaObject javaObject)
  895. {
  896. data = javaObject.Get<byte[]>("data");
  897. left = javaObject.Get<byte[]>("left");
  898. right = javaObject.Get<byte[]>("right");
  899. type = javaObject.Get<int>("type");
  900. format = javaObject.Get<int>("format");
  901. width = javaObject.Get<int>("width");
  902. height = javaObject.Get<int>("height");
  903. size = javaObject.Get<int>("size");
  904. leftSize = javaObject.Get<int>("leftSize");
  905. rightSize = javaObject.Get<int>("rightSize");
  906. timestamp = javaObject.Get<long>("timestamp");
  907. }
  908. }
  909. public delegate void StreamDataCallback(NxrSlam.RawDataType paramRawDataType, NxrStreamData paramNxrStreamData);
  910. public StreamDataCallback StreamDataEvent;
  911. public class OnStreamDataListener : AndroidJavaProxy
  912. {
  913. public OnStreamDataListener() : base("ruiyue.nxrsensor.library.listener.OnStreamDataListener")
  914. {
  915. }
  916. public void onStreamData(AndroidJavaObject paramRawDataType, AndroidJavaObject paramNxrStreamData)
  917. {
  918. if (paramNxrStreamData != null)
  919. {
  920. var rawDataType = (NxrSlam.RawDataType) paramRawDataType.Call<int>("ordinal");
  921. var nxrStreamData = new NxrStreamData(paramNxrStreamData);
  922. if (Instance.StreamDataEvent != null)
  923. {
  924. Instance.StreamDataEvent(rawDataType, nxrStreamData);
  925. }
  926. }
  927. }
  928. }
  929. public RgbCalibration ReadRgbCalibrations()
  930. {
  931. if (nxrSensorInstance != null)
  932. {
  933. var javaObject = nxrSensorInstance.Call<AndroidJavaObject>("readRgbCalibrations");
  934. if (javaObject != null)
  935. {
  936. return new RgbCalibration(javaObject);
  937. }
  938. }
  939. return null;
  940. }
  941. public class RgbCalibration
  942. {
  943. public float[][] K;
  944. public float[] rotation;
  945. public float[] translation;
  946. public float[] K0;
  947. public float[] K1;
  948. public float[] K2;
  949. public RgbCalibration(AndroidJavaObject javaObject)
  950. {
  951. rotation = javaObject.Get<float[]>("rotation");
  952. translation = javaObject.Get<float[]>("translation");
  953. K0 = javaObject.Get<float[]>("K0");
  954. K1 = javaObject.Get<float[]>("K1");
  955. K2 = javaObject.Get<float[]>("K2");
  956. K = new float[3][];
  957. K[0] = K0;
  958. K[1] = K1;
  959. K[2] = K2;
  960. }
  961. }
  962. public void SetRgbResolution(NxrSlam.RgbResolution r)
  963. {
  964. if (nxrSensorInstance != null)
  965. {
  966. if (rgbResolutionClass == null)
  967. {
  968. rgbResolutionClass = new AndroidJavaClass("ruiyue.nxrsensor.library.type.RgbResolution");
  969. }
  970. var rObj = rgbResolutionClass.CallStatic<AndroidJavaObject>("valueOf", r.ToString());
  971. nxrSensorInstance.Call("setRgbResolution", rObj);
  972. }
  973. }
  974. public void SetRgbExposure(int aecMode, int exposureGain, int exposureTimeMs)
  975. {
  976. if (nxrSensorInstance != null)
  977. {
  978. nxrSensorInstance.Call("setRgbExposure", aecMode, exposureGain, exposureTimeMs);
  979. }
  980. }
  981. public void SetRgbBrightnessLevel(int level)
  982. {
  983. if (nxrSensorInstance != null)
  984. {
  985. nxrSensorInstance.Call("setRgbBrightnessLevel", level);
  986. }
  987. }
  988. #endregion
  989. #region Tof
  990. public enum TofFPS
  991. {
  992. TOF_FPS_5,
  993. TOF_FPS_10,
  994. TOF_FPS_15,
  995. TOF_FPS_20,
  996. TOF_FPS_25,
  997. TOF_FPS_30
  998. }
  999. public enum TofStreamMode
  1000. {
  1001. ONLY_DEPTH,
  1002. ONLY_CLOUD,
  1003. DEPTH_CLOUD,
  1004. NONE,
  1005. CLOUD_ON_LEFTHAND_SLAM
  1006. }
  1007. public enum DistanceMode
  1008. {
  1009. SHORT,
  1010. MIDDLE,
  1011. LONG
  1012. }
  1013. public int RegisterColorDepthImageCallback()
  1014. {
  1015. if (nxrSensorInstance != null)
  1016. {
  1017. return nxrSensorInstance.Call<int>("registerColorDepthImageCallback", new OnStreamDataV3Listener());
  1018. }
  1019. return -1;
  1020. }
  1021. public bool UnregisterColorDepthImageCallback(int callbackId)
  1022. {
  1023. if (nxrSensorInstance != null)
  1024. {
  1025. return nxrSensorInstance.Call<bool>("unregisterColorDepthImageCallback", callbackId);
  1026. }
  1027. return false;
  1028. }
  1029. public delegate void StreamDataV3ListenerCallback(NxrStreamData paramNxrStreamData);
  1030. public StreamDataV3ListenerCallback StreamDataV3ListenerEvent;
  1031. public class OnStreamDataV3Listener : AndroidJavaProxy
  1032. {
  1033. public OnStreamDataV3Listener() : base("ruiyue.nxrsensor.library.listener.OnStreamDataV3Listener")
  1034. {
  1035. }
  1036. public void onStreamDataV3(AndroidJavaObject paramNxrStreamData)
  1037. {
  1038. if (paramNxrStreamData != null)
  1039. {
  1040. var nxrStreamData = new NxrStreamData(paramNxrStreamData);
  1041. if (Instance.StreamDataV3ListenerEvent != null)
  1042. {
  1043. Instance.StreamDataV3ListenerEvent(nxrStreamData);
  1044. }
  1045. }
  1046. }
  1047. }
  1048. public TofCalibration ReadTofCalibration()
  1049. {
  1050. if (nxrSensorInstance != null)
  1051. {
  1052. var javaObject = nxrSensorInstance.Call<AndroidJavaObject>("readTofCalibration");
  1053. if (javaObject != null)
  1054. {
  1055. return new TofCalibration(javaObject);
  1056. }
  1057. }
  1058. return null;
  1059. }
  1060. public class TofCalibration
  1061. {
  1062. public float[] K;
  1063. public float[] rotation;
  1064. public float[] translation;
  1065. public TofCalibration(AndroidJavaObject javaObject)
  1066. {
  1067. K = javaObject.Get<float[]>("K");
  1068. rotation = javaObject.Get<float[]>("rotation");
  1069. translation = javaObject.Get<float[]>("translation");
  1070. }
  1071. }
  1072. public void SetTofExposure(int aecMode, int exposureGain, int exposureTimeMs)
  1073. {
  1074. if (nxrSensorInstance != null)
  1075. {
  1076. nxrSensorInstance.Call("setTofExposure", aecMode, exposureGain, exposureTimeMs);
  1077. }
  1078. }
  1079. public void SetTofBrightnessLevel(int level)
  1080. {
  1081. if (nxrSensorInstance != null)
  1082. {
  1083. nxrSensorInstance.Call("setTofBrightnessLevel", level);
  1084. }
  1085. }
  1086. public void SetTofFrameRate(TofFPS fps)
  1087. {
  1088. if (nxrSensorInstance != null)
  1089. {
  1090. if (tofFPSClass == null)
  1091. {
  1092. tofFPSClass = new AndroidJavaClass("ruiyue.nxrsensor.library.type.TofFPS");
  1093. }
  1094. var fpsObj = tofFPSClass.CallStatic<AndroidJavaObject>("valueOf", fps.ToString());
  1095. nxrSensorInstance.Call("setTofFrameRate", fpsObj);
  1096. }
  1097. }
  1098. public void SetTofResolution(int resolution)
  1099. {
  1100. if (nxrSensorInstance != null)
  1101. {
  1102. nxrSensorInstance.Call("setTofResolution", resolution);
  1103. }
  1104. }
  1105. public NxrPointCloud DepthImageToPointCloud(NxrStreamData stream)
  1106. {
  1107. if (nxrSensorProInstance != null && stream != null)
  1108. {
  1109. var data = stream.data;
  1110. var left = stream.left;
  1111. var right = stream.right;
  1112. var type = stream.type;
  1113. var format = stream.format;
  1114. var width = stream.width;
  1115. var height = stream.height;
  1116. var size = stream.size;
  1117. var leftSize = stream.leftSize;
  1118. var rightSize = stream.rightSize;
  1119. var timestamp = stream.timestamp;
  1120. var javaObject = nxrSensorProInstance.Call<AndroidJavaObject>("depthImageToPointCloud", data, left, right,
  1121. type, format, width, height, size, leftSize, rightSize, timestamp);
  1122. if (javaObject != null)
  1123. {
  1124. return new NxrPointCloud(javaObject);
  1125. }
  1126. }
  1127. return null;
  1128. }
  1129. public class NxrPointCloud
  1130. {
  1131. public long dataFetchTimeMs;
  1132. public long dataTimeStampMs;
  1133. public NxrPointF[] points;
  1134. public NxrPointCloud(AndroidJavaObject javaObject)
  1135. {
  1136. dataFetchTimeMs = javaObject.Get<long>("dataFetchTimeMs");
  1137. dataTimeStampMs = javaObject.Get<long>("dataTimeStampMs");
  1138. var pointsArray = javaObject.Get<AndroidJavaObject[]>("points");
  1139. points = new NxrPointF[pointsArray.Length];
  1140. for (var i = 0; i < points.Length; i++)
  1141. {
  1142. var nxrPointF = new NxrPointF();
  1143. nxrPointF.x = pointsArray[i].Get<float>("x");
  1144. nxrPointF.y = pointsArray[i].Get<float>("y");
  1145. nxrPointF.z = pointsArray[i].Get<float>("z");
  1146. points[i] = nxrPointF;
  1147. pointsArray[i].Dispose();
  1148. }
  1149. }
  1150. }
  1151. public void SetTofStreamMode(TofStreamMode mode)
  1152. {
  1153. if (nxrSensorInstance != null)
  1154. {
  1155. if (tofStreamModeClass == null)
  1156. {
  1157. tofStreamModeClass = new AndroidJavaClass("ruiyue.nxrsensor.library.type.TofStreamMode");
  1158. }
  1159. var modeObj = tofStreamModeClass.CallStatic<AndroidJavaObject>("valueOf", mode.ToString());
  1160. nxrSensorInstance.Call("setTofStreamMode", modeObj);
  1161. }
  1162. }
  1163. public void SetTofDistanceMode(DistanceMode mode)
  1164. {
  1165. if (nxrSensorInstance != null)
  1166. {
  1167. if (distanceModeClass == null)
  1168. {
  1169. distanceModeClass = new AndroidJavaClass("ruiyue.nxrsensor.library.type.DistanceMode");
  1170. }
  1171. var modeObj = distanceModeClass.CallStatic<AndroidJavaObject>("valueOf", mode.ToString());
  1172. nxrSensorInstance.Call("setTofDistanceMode", modeObj);
  1173. }
  1174. }
  1175. public void SetTofMode(int mode)
  1176. {
  1177. if (nxrSensorInstance != null)
  1178. {
  1179. nxrSensorInstance.Call("setTofMode", mode);
  1180. }
  1181. }
  1182. #endregion
  1183. #region FishEye
  1184. public FishEyeCalibration ReadStereoFisheyesCalibrations(int type)
  1185. {
  1186. if (nxrSensorInstance != null)
  1187. {
  1188. var javaObject = nxrSensorInstance.Call<AndroidJavaObject>("readStereoFisheyesCalibrations", type);
  1189. return new FishEyeCalibration(javaObject);
  1190. }
  1191. return null;
  1192. }
  1193. public FishEyeCalibration ReadStereoFisheyesPDMCalibrations(int type)
  1194. {
  1195. if (nxrSensorInstance != null)
  1196. {
  1197. var javaObject = nxrSensorInstance.Call<AndroidJavaObject>("readStereoFisheyesPDMCalibrations", type);
  1198. return new FishEyeCalibration(javaObject);
  1199. }
  1200. return null;
  1201. }
  1202. public class FishEyeCalibration
  1203. {
  1204. public float[][] K;
  1205. public float[][] rotation;
  1206. public float[][] translation;
  1207. public int imu_fisheye_shift_us;
  1208. public float delta;
  1209. public float[] K0;
  1210. public float[] K1;
  1211. public float[] rotation0;
  1212. public float[] rotation1;
  1213. public float[] translation0;
  1214. public float[] translation1;
  1215. public FishEyeCalibration(AndroidJavaObject javaObject)
  1216. {
  1217. imu_fisheye_shift_us = javaObject.Get<int>("imu_fisheye_shift_us");
  1218. delta = javaObject.Get<float>("delta");
  1219. K0 = javaObject.Get<float[]>("K0");
  1220. K1 = javaObject.Get<float[]>("K1");
  1221. rotation0 = javaObject.Get<float[]>("rotation0");
  1222. rotation1 = javaObject.Get<float[]>("rotation1");
  1223. translation0 = javaObject.Get<float[]>("translation0");
  1224. translation1 = javaObject.Get<float[]>("translation1");
  1225. K = new float[2][];
  1226. K[0] = K0;
  1227. K[1] = K1;
  1228. rotation = new float[2][];
  1229. rotation[0] = rotation0;
  1230. rotation[1] = rotation1;
  1231. translation = new float[2][];
  1232. translation[0] = translation0;
  1233. translation[1] = translation1;
  1234. }
  1235. }
  1236. public void SetFishEyeExposure(int aecMode, int exposureGain, int exposureTimeMs)
  1237. {
  1238. if (nxrSensorInstance != null)
  1239. {
  1240. nxrSensorInstance.Call("setFishEyeExposure", aecMode, exposureGain, exposureTimeMs);
  1241. }
  1242. }
  1243. public void SetFishEyeBrightnessLevel(int level)
  1244. {
  1245. if (nxrSensorInstance != null)
  1246. {
  1247. nxrSensorInstance.Call("setFishEyeBrightnessLevel", level);
  1248. }
  1249. }
  1250. #endregion
  1251. #region Eyetracking
  1252. public void SetEyeTrackingExposure(int leftGain, int leftTimeMs, int rightGain, int rightTimeMs)
  1253. {
  1254. if (nxrSensorInstance != null)
  1255. {
  1256. nxrSensorInstance.Call("setEyeTrackingExposure", leftGain, leftTimeMs, rightGain, rightTimeMs);
  1257. }
  1258. }
  1259. public void SetEyeTrackingLedBrightness(int eye, int led, int brightness)
  1260. {
  1261. if (nxrSensorInstance != null)
  1262. {
  1263. nxrSensorInstance.Call("setEyeTrackingLedBrightness", eye, led, brightness);
  1264. }
  1265. }
  1266. #endregion
  1267. #region 3dof
  1268. public NxrTrackingData Get3dof(double prediction)
  1269. {
  1270. if (nxrSensorInstance != null)
  1271. {
  1272. var javaObject = nxrSensorInstance.Call<AndroidJavaObject>("get3dof", prediction);
  1273. return new NxrTrackingData(javaObject);
  1274. }
  1275. return null;
  1276. }
  1277. public NxrTrackingData Get3dofAt(double timestamp)
  1278. {
  1279. if (nxrSensorInstance != null)
  1280. {
  1281. var javaObject = nxrSensorInstance.Call<AndroidJavaObject>("get3dofAt", timestamp);
  1282. return new NxrTrackingData(javaObject);
  1283. }
  1284. return null;
  1285. }
  1286. public void RegisterOrientationCallback()
  1287. {
  1288. if (nxrSensorInstance != null)
  1289. {
  1290. nxrSensorInstance.Call("registerOrientationCallback", new OnOrientationListener());
  1291. }
  1292. }
  1293. public delegate void OrientationCallback(NxrTrackingData paramNxrTrackingData);
  1294. public OrientationCallback OrientationEvent;
  1295. public class OnOrientationListener : AndroidJavaProxy
  1296. {
  1297. public OnOrientationListener() : base("ruiyue.nxrsensor.library.listener.OnOrientationListener")
  1298. {
  1299. }
  1300. public void onOrientation(AndroidJavaObject paramNxrTrackingData)
  1301. {
  1302. if (paramNxrTrackingData != null)
  1303. {
  1304. var nxrTrackingData = new NxrTrackingData(paramNxrTrackingData);
  1305. if (Instance.OrientationEvent != null)
  1306. {
  1307. Instance.OrientationEvent(nxrTrackingData);
  1308. }
  1309. }
  1310. }
  1311. }
  1312. #endregion
  1313. #region EventStream
  1314. public void RegisterEventCallback()
  1315. {
  1316. if (nxrSensorInstance != null)
  1317. {
  1318. nxrSensorInstance.Call("registerEventCallback", new OnEventListener());
  1319. }
  1320. }
  1321. public delegate void EventCallback(int paramInt1, int paramInt2);
  1322. public EventCallback eventCallback;
  1323. public class OnEventListener : AndroidJavaProxy
  1324. {
  1325. public OnEventListener() : base("ruiyue.nxrsensor.library.listener.OnEventListener")
  1326. {
  1327. }
  1328. public void onEvent(int paramInt1, int paramInt2)
  1329. {
  1330. if (Instance.eventCallback != null)
  1331. {
  1332. Instance.eventCallback(paramInt1, paramInt2);
  1333. }
  1334. }
  1335. }
  1336. #endregion
  1337. #region Imu
  1338. public enum XvLogLevel
  1339. {
  1340. NONE,
  1341. DEBUG,
  1342. INFO,
  1343. WARN,
  1344. ERROR,
  1345. CRITICAL,
  1346. OFF
  1347. }
  1348. public void RegisterImuCallback()
  1349. {
  1350. if (nxrSensorInstance != null)
  1351. {
  1352. nxrSensorInstance.Call("registerImuCallback", new OnRawDataListener());
  1353. }
  1354. }
  1355. public delegate void ImuCallback(NxrRawData paramNxrRawData);
  1356. public ImuCallback ImuEvent;
  1357. public class OnRawDataListener : AndroidJavaProxy
  1358. {
  1359. public OnRawDataListener() : base("ruiyue.nxrsensor.library.listener.OnRawDataListener")
  1360. {
  1361. }
  1362. public void onImu(AndroidJavaObject paramNxrRawData)
  1363. {
  1364. if (paramNxrRawData != null)
  1365. {
  1366. var nxrRawData = new NxrRawData(paramNxrRawData);
  1367. if (Instance.ImuEvent != null)
  1368. {
  1369. Instance.ImuEvent(nxrRawData);
  1370. }
  1371. }
  1372. }
  1373. }
  1374. public class NxrRawData
  1375. {
  1376. public float[] acc;
  1377. public float[] gyro;
  1378. public float[] mag;
  1379. public long timestamp;
  1380. public int quality;
  1381. public NxrRawData(AndroidJavaObject javaObject)
  1382. {
  1383. acc = javaObject.Get<float[]>("acc");
  1384. gyro = javaObject.Get<float[]>("gyro");
  1385. mag = javaObject.Get<float[]>("mag");
  1386. timestamp = javaObject.Get<long>("timestamp");
  1387. quality = javaObject.Get<int>("quality");
  1388. }
  1389. }
  1390. public bool HidWriteAndRead(byte[] values, int vlength, byte[] result, int rlength)
  1391. {
  1392. if (nxrSensorInstance != null)
  1393. {
  1394. return nxrSensorInstance.Call<bool>("hidWriteAndRead", values, vlength, result, rlength);
  1395. }
  1396. return false;
  1397. }
  1398. public NxrVersion Version()
  1399. {
  1400. if (nxrSensorInstance != null)
  1401. {
  1402. var javaObject = nxrSensorInstance.Call<AndroidJavaObject>("version");
  1403. return new NxrVersion(javaObject);
  1404. }
  1405. return null;
  1406. }
  1407. public class NxrVersion
  1408. {
  1409. public int major = 0;
  1410. public int minor = 0;
  1411. public int patch = 0;
  1412. public NxrVersion(AndroidJavaObject javaObject)
  1413. {
  1414. major = javaObject.Get<int>("major");
  1415. minor = javaObject.Get<int>("minor");
  1416. patch = javaObject.Get<int>("patch");
  1417. }
  1418. }
  1419. public void SetLogLevel(XvLogLevel level)
  1420. {
  1421. if (nxrSensorInstance != null)
  1422. {
  1423. if (xvLogLevelClass == null)
  1424. {
  1425. xvLogLevelClass = new AndroidJavaClass("ruiyue.nxrsensor.library.type.XvLogLevel");
  1426. }
  1427. var levelObj = xvLogLevelClass.CallStatic<AndroidJavaObject>("valueOf", level.ToString());
  1428. nxrSensorInstance.Call("setLogLevel", levelObj);
  1429. }
  1430. }
  1431. #endregion
  1432. #region Cnn
  1433. public bool SetDescriptor(string path)
  1434. {
  1435. if (nxrSensorInstance != null)
  1436. {
  1437. return nxrSensorInstance.Call<bool>("setDescriptor", path);
  1438. }
  1439. return false;
  1440. }
  1441. public bool SetModel(string path)
  1442. {
  1443. if (nxrSensorInstance != null)
  1444. {
  1445. return nxrSensorInstance.Call<bool>("setModel", path);
  1446. }
  1447. return false;
  1448. }
  1449. public bool SetSource(int source)
  1450. {
  1451. if (nxrSensorInstance != null)
  1452. {
  1453. return nxrSensorInstance.Call<bool>("setSource", source);
  1454. }
  1455. return false;
  1456. }
  1457. public int GetSource()
  1458. {
  1459. if (nxrSensorInstance != null)
  1460. {
  1461. return nxrSensorInstance.Call<int>("getSource");
  1462. }
  1463. return -1;
  1464. }
  1465. public Descriptor GetDescriptor()
  1466. {
  1467. if (nxrSensorInstance != null)
  1468. {
  1469. var javaObject = nxrSensorInstance.Call<AndroidJavaObject>("getDescriptor");
  1470. return new Descriptor(javaObject);
  1471. }
  1472. return null;
  1473. }
  1474. public class Descriptor
  1475. {
  1476. public string type;
  1477. public string[] classes;
  1478. public double threshold;
  1479. public bool flipStereo;
  1480. public bool flipRgb;
  1481. public bool flipTof;
  1482. public Descriptor(AndroidJavaObject javaObject)
  1483. {
  1484. type = javaObject.Get<string>("type");
  1485. classes = javaObject.Get<string[]>("classes");
  1486. threshold = javaObject.Get<double>("hreshold");
  1487. flipStereo = javaObject.Get<bool>("flipStereo");
  1488. flipRgb = javaObject.Get<bool>("flipRgb");
  1489. flipTof = javaObject.Get<bool>("flipTof");
  1490. }
  1491. }
  1492. public int RegisterCnnRawCallback()
  1493. {
  1494. if (nxrSensorInstance != null)
  1495. {
  1496. return nxrSensorInstance.Call<int>("registerCnnRawCallback", new OnCnnRawDataListener());
  1497. }
  1498. return -1;
  1499. }
  1500. public bool UnregisterCnnRawCallback(int callbackId)
  1501. {
  1502. if (nxrSensorInstance != null)
  1503. {
  1504. return nxrSensorInstance.Call<bool>("unregisterCnnRawCallback", callbackId);
  1505. }
  1506. return false;
  1507. }
  1508. public delegate void CnnCallback(NxrCnnRawData paramNxrCnnRawData);
  1509. public CnnCallback CnnEvent;
  1510. public class OnCnnRawDataListener : AndroidJavaProxy
  1511. {
  1512. public OnCnnRawDataListener() : base("ruiyue.nxrsensor.library.listener.OnCnnRawDataListener")
  1513. {
  1514. }
  1515. public void onCnn(AndroidJavaObject paramNxrCnnRawData)
  1516. {
  1517. if (paramNxrCnnRawData != null)
  1518. {
  1519. var nxrCnnRawData = new NxrCnnRawData(paramNxrCnnRawData);
  1520. if (Instance.CnnEvent != null)
  1521. {
  1522. Instance.CnnEvent(nxrCnnRawData);
  1523. }
  1524. }
  1525. }
  1526. }
  1527. public class NxrCnnRawData
  1528. {
  1529. public float[] data;
  1530. public int size;
  1531. public NxrCnnRawData(AndroidJavaObject javaObject)
  1532. {
  1533. data = javaObject.Get<float[]>("data");
  1534. size = javaObject.Get<int>("size");
  1535. }
  1536. }
  1537. #endregion
  1538. #region Mic
  1539. public bool MicStart()
  1540. {
  1541. if (nxrSensorInstance != null)
  1542. {
  1543. return nxrSensorInstance.Call<bool>("micStart");
  1544. }
  1545. return false;
  1546. }
  1547. public bool MicStop()
  1548. {
  1549. if (nxrSensorInstance != null)
  1550. {
  1551. return nxrSensorInstance.Call<bool>("micStop");
  1552. }
  1553. return false;
  1554. }
  1555. public int RegisterMicCallback()
  1556. {
  1557. if (nxrSensorInstance != null)
  1558. {
  1559. return nxrSensorInstance.Call<int>("registerMicCallback", new OnMicDataListener());
  1560. }
  1561. return -1;
  1562. }
  1563. public bool UnregisterMicCallback(int callbackId)
  1564. {
  1565. if (nxrSensorInstance != null)
  1566. {
  1567. return nxrSensorInstance.Call<bool>("unregisterMicCallback", callbackId);
  1568. }
  1569. return false;
  1570. }
  1571. public delegate void MicCallback(NxrMicData paramNxrMicData);
  1572. public MicCallback MicEvent;
  1573. public class OnMicDataListener : AndroidJavaProxy
  1574. {
  1575. public OnMicDataListener() : base("ruiyue.nxrsensor.library.listener.OnMicDataListener")
  1576. {
  1577. }
  1578. public void onMic(AndroidJavaObject paramNxrMicData)
  1579. {
  1580. if (paramNxrMicData != null)
  1581. {
  1582. var nxrMicData = new NxrMicData(paramNxrMicData);
  1583. if (Instance.MicEvent != null)
  1584. {
  1585. Instance.MicEvent(nxrMicData);
  1586. }
  1587. }
  1588. }
  1589. }
  1590. public class NxrMicData
  1591. {
  1592. public long dataFetchTimeMs;
  1593. public long dataTimeStampMs;
  1594. public byte[] data;
  1595. public int size;
  1596. public NxrMicData(AndroidJavaObject javaObject)
  1597. {
  1598. dataFetchTimeMs = javaObject.Get<long>("dataFetchTimeMs");
  1599. dataTimeStampMs = javaObject.Get<long>("dataTimeStampMs");
  1600. data = javaObject.Get<byte[]>("data");
  1601. size = javaObject.Get<int>("size");
  1602. }
  1603. }
  1604. #endregion
  1605. #region Speak
  1606. public bool SpeakerEnable()
  1607. {
  1608. if (nxrSensorInstance != null)
  1609. {
  1610. return nxrSensorInstance.Call<bool>("speakerEnable");
  1611. }
  1612. return false;
  1613. }
  1614. public bool SpeakerDisable()
  1615. {
  1616. if (nxrSensorInstance != null)
  1617. {
  1618. return nxrSensorInstance.Call<bool>("speakerDisable");
  1619. }
  1620. return false;
  1621. }
  1622. public int SpeakerSend(byte[] data, int size)
  1623. {
  1624. if (nxrSensorInstance != null)
  1625. {
  1626. return nxrSensorInstance.Call<int>("speakerSend", data, size);
  1627. }
  1628. return -1;
  1629. }
  1630. public bool SpeakerPlay(string path)
  1631. {
  1632. if (nxrSensorInstance != null)
  1633. {
  1634. return nxrSensorInstance.Call<bool>("speakerPlay", path);
  1635. }
  1636. return false;
  1637. }
  1638. public bool SpeakerIsPlaying()
  1639. {
  1640. if (nxrSensorInstance != null)
  1641. {
  1642. return nxrSensorInstance.Call<bool>("speakerIsPlaying");
  1643. }
  1644. return false;
  1645. }
  1646. public int RegisterSpeakerCallback()
  1647. {
  1648. if (nxrSensorInstance != null)
  1649. {
  1650. return nxrSensorInstance.Call<int>("registerSpeakerCallback", new OnSpeakerListener());
  1651. }
  1652. return -1;
  1653. }
  1654. public bool UnregisterSpeakerCallback(int callbackId)
  1655. {
  1656. if (nxrSensorInstance != null)
  1657. {
  1658. return nxrSensorInstance.Call<bool>("unregisterSpeakerCallback", callbackId);
  1659. }
  1660. return false;
  1661. }
  1662. public delegate void SpeakerCallback();
  1663. public SpeakerCallback SpeakerEvent;
  1664. public class OnSpeakerListener : AndroidJavaProxy
  1665. {
  1666. public OnSpeakerListener() : base("ruiyue.nxrsensor.library.listener.OnSpeakerListener")
  1667. {
  1668. }
  1669. public void onSpeaker()
  1670. {
  1671. if (Instance.SpeakerEvent != null)
  1672. {
  1673. Instance.SpeakerEvent();
  1674. }
  1675. }
  1676. }
  1677. #endregion
  1678. #region Sgbm
  1679. public bool SgbmStart(string path)
  1680. {
  1681. if (nxrSensorInstance != null)
  1682. {
  1683. return nxrSensorInstance.Call<bool>("sgbmStart", path);
  1684. }
  1685. return false;
  1686. }
  1687. public bool SgbmStop()
  1688. {
  1689. if (nxrSensorInstance != null)
  1690. {
  1691. return nxrSensorInstance.Call<bool>("sgbmStop");
  1692. }
  1693. return false;
  1694. }
  1695. public int RegisterSgbmCallback()
  1696. {
  1697. if (nxrSensorInstance != null)
  1698. {
  1699. return nxrSensorInstance.Call<int>("registerSgbmCallback", new OnStreamDataV3Listener());
  1700. }
  1701. return -1;
  1702. }
  1703. public bool UnregisterSgbmCallback(int callbackId)
  1704. {
  1705. if (nxrSensorInstance != null)
  1706. {
  1707. return nxrSensorInstance.Call<bool>("unregisterSgbmCallback", callbackId);
  1708. }
  1709. return false;
  1710. }
  1711. public bool SgbmSetConfig(string path)
  1712. {
  1713. if (nxrSensorInstance != null)
  1714. {
  1715. return nxrSensorInstance.Call<bool>("sgbmSetConfig", path);
  1716. }
  1717. return false;
  1718. }
  1719. #endregion
  1720. #region Thermal
  1721. public enum ThermalMode
  1722. {
  1723. TEMPERATURE = 0,
  1724. TEMPERTURE = 0,
  1725. GREY = 1
  1726. }
  1727. public void SetThermalMode(ThermalMode mode)
  1728. {
  1729. if (nxrSensorInstance != null)
  1730. {
  1731. if (thermalModeClass == null)
  1732. {
  1733. thermalModeClass = new AndroidJavaClass("ruiyue.nxrsensor.library.type.ThermalMode");
  1734. }
  1735. var modeObj = thermalModeClass.CallStatic<AndroidJavaObject>("valueOf", mode.ToString());
  1736. nxrSensorInstance.Call("setThermalMode", modeObj);
  1737. }
  1738. }
  1739. public bool Control(NxrDeviceSetting setting)
  1740. {
  1741. if (nxrSensorProInstance != null && setting != null)
  1742. {
  1743. var iso_value = setting.iso_value;
  1744. var exp_abs = setting.exp_abs;
  1745. var exp_mode = setting.exp_mode;
  1746. var exp_level = setting.exp_level;
  1747. var exp_anti = setting.exp_anti;
  1748. var iso_mode = setting.iso_mode;
  1749. var awb_mode = setting.awb_mode;
  1750. var awb_lock = setting.awb_lock;
  1751. var af_mode = setting.af_mode;
  1752. var af_dist = setting.af_dist;
  1753. var cmd = setting.cmd;
  1754. var val = setting.val;
  1755. var val16 = setting.val16;
  1756. var val32 = setting.val32;
  1757. return nxrSensorProInstance.Call<bool>("control", iso_value, exp_abs, exp_mode, exp_level, exp_anti,
  1758. iso_mode, awb_mode, awb_lock, af_mode, af_dist, cmd, val, val16, val32);
  1759. }
  1760. return false;
  1761. }
  1762. public class NxrDeviceSetting
  1763. {
  1764. public int iso_value;
  1765. public int exp_abs;
  1766. public int exp_mode;
  1767. public int exp_level;
  1768. public int exp_anti;
  1769. public int iso_mode;
  1770. public int awb_mode;
  1771. public int awb_lock;
  1772. public int af_mode;
  1773. public int af_dist;
  1774. public int cmd;
  1775. public int[] val;
  1776. public int val16;
  1777. public int val32;
  1778. }
  1779. public bool UvcWriteAndRead(byte[] write, int wLen, byte[] read, int rLen)
  1780. {
  1781. if (nxrSensorInstance != null)
  1782. {
  1783. return nxrSensorInstance.Call<bool>("uvcWriteAndRead", write, wLen, read, rLen);
  1784. }
  1785. return false;
  1786. }
  1787. public bool VscWriteAndRead(byte[] write, int wLen, byte[] read, int rLen)
  1788. {
  1789. if (nxrSensorInstance != null)
  1790. {
  1791. return nxrSensorInstance.Call<bool>("vscWriteAndRead", write, wLen, read, rLen);
  1792. }
  1793. return false;
  1794. }
  1795. #endregion
  1796. }