HandTrackingT3D.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.Android;
  5. using System.Runtime.InteropServices;
  6. using TouchlessA3D;
  7. using System;
  8. using System.Xml;
  9. using System.Text;
  10. namespace Ximmerse.XR.InputSystems
  11. {
  12. /// <summary>
  13. /// Hand tracking module implementor on touchless 3D SDK.
  14. /// </summary>
  15. internal class HandTrackingT3D : I_HandleTrackingModule
  16. {
  17. private readonly static int width = 1440;
  18. private readonly static int height = 1080; //264
  19. /// <summary>
  20. /// Image data array.
  21. /// </summary>
  22. private Color32[] imgData = new Color32[width * height];
  23. private bool m_IsModuleEnabled;
  24. /// <summary>
  25. /// RGB camera texture to be passed to native plugin.
  26. /// </summary>
  27. private WebCamTexture cameraTexture;
  28. private GCHandle imageHandle;
  29. public bool IsModuleEnabled
  30. {
  31. get => m_IsModuleEnabled;
  32. }
  33. private Engine touchlessEngine;
  34. Transform handTrackingAnchor;
  35. Transform mainCamera;
  36. Matrix4x4 hand_local_2_world;
  37. /// <summary>
  38. /// Raw hand track info by native plugin.
  39. /// </summary>
  40. HandTrackingInfo handTrackInfo;
  41. /// <summary>
  42. /// 上一个合法帧的hand track info.
  43. /// </summary>
  44. HandTrackingInfo previousValidFrameHandTrackInfo;
  45. /// <summary>
  46. /// Gets the hand track info
  47. /// </summary>
  48. public HandTrackingInfo HandleTrackInfo
  49. {
  50. get => handTrackInfo;
  51. }
  52. public bool IsTrackings
  53. {
  54. get => handTrackInfo.IsTracking;
  55. }
  56. private readonly object lockObj = new object();
  57. GestureEvent locked_gestureEvent;
  58. public void DisableModule()
  59. {
  60. #if DEVELOPMENT_BUILD
  61. try
  62. {
  63. #endif
  64. if (!m_IsModuleEnabled)
  65. {
  66. return;
  67. }
  68. m_IsModuleEnabled = false;
  69. handTrackInfo.Dispose();
  70. previousValidFrameHandTrackInfo.Dispose();
  71. //cameraTexture.Stop();
  72. //cameraTexture = null;
  73. XimmerseXR.RequestStopRGBCamera();
  74. touchlessEngine = null;
  75. imageHandle.Free();
  76. #if DEVELOPMENT_BUILD
  77. }
  78. catch (Exception e)
  79. {
  80. Debug.LogException(e);
  81. }
  82. #endif
  83. }
  84. /// <summary>
  85. /// A 3 x 3 float array to calibrate RGB camera.
  86. /// </summary>
  87. static float[,] CalibrationMatrix = null;
  88. /// <summary>
  89. /// A 8 array to identify the distortion coefficients of the RGB camera.
  90. /// </summary>
  91. static float[] DistortionCoefficients = null;
  92. /// <summary>
  93. /// XML file path contains the rgb camera parameter.
  94. /// </summary>
  95. const string kRGBCalibrationXMLPath = "/backup/rgb_vio_camera_params.xml";
  96. static void ParseRGBCameraParams()
  97. {
  98. try
  99. {
  100. XmlDocument xmlDoc = new XmlDocument(); // Create an XML document object
  101. xmlDoc.Load(kRGBCalibrationXMLPath); // Load the XML document from the specified file
  102. XmlNodeList RGBCamMats = xmlDoc.GetElementsByTagName("RGBCamMat");
  103. ParseCalibrationMatrix(RGBCamMats, out CalibrationMatrix);
  104. XmlNodeList RGBDistCoeff = xmlDoc.GetElementsByTagName("RGBDistCoeff");
  105. ParseDistortionCoefficients(RGBDistCoeff, out DistortionCoefficients);
  106. #if DEVELOPMENT_BUILD
  107. StringBuilder buffer = new StringBuilder();
  108. buffer.AppendFormat("CalibrationMatrix : ");
  109. for (int row = 0; row < 3; row++)
  110. for (int col = 0; col < 3; col++)
  111. {
  112. buffer.AppendFormat("{0} ", CalibrationMatrix[col, row]);
  113. }
  114. buffer.AppendFormat("\r\nDistortionCoefficients : ");
  115. foreach (var coefficient in DistortionCoefficients)
  116. {
  117. buffer.AppendFormat("{0} ", coefficient);
  118. }
  119. #endif
  120. }
  121. catch (Exception exc)
  122. {
  123. Debug.LogErrorFormat("ParseRGBCameraParams error : {0}", exc.Message);
  124. Debug.LogException(exc);
  125. }
  126. }
  127. /// <summary>
  128. /// Reads XML element and output a calibrationMatrix (3x3) array
  129. /// </summary>
  130. /// <param name="RGBCamMats"></param>
  131. /// <param name="calibrationMatrix"></param>
  132. private static void ParseCalibrationMatrix(XmlNodeList RGBCamMats, out float[,] calibrationMatrix)
  133. {
  134. calibrationMatrix = new float[3, 3];
  135. int row = 0, col = 0;
  136. try
  137. {
  138. XmlElement dataElement = RGBCamMats.Item(0)["data"];
  139. var textInArray = dataElement.InnerText.Trim().Split(' ');
  140. for (int i = 0; i < textInArray.Length; i++)
  141. {
  142. string t = textInArray[i];
  143. if (float.TryParse(t, out float value))
  144. {
  145. calibrationMatrix[row, col] = value;
  146. col++;
  147. if (col >= 3)
  148. {
  149. col = 0;
  150. row++;
  151. }
  152. }
  153. }
  154. }
  155. catch (Exception exc)
  156. {
  157. Debug.LogException(exc);
  158. }
  159. }
  160. /// <summary>
  161. /// Reads XML element and output a distortion cofficient (8) array
  162. /// </summary>
  163. /// <param name="RGBCamMats"></param>
  164. /// <param name="DistortionCofficients"></param>
  165. private static void ParseDistortionCoefficients(XmlNodeList RGBDistCoeff, out float[] DistortionCofficients)
  166. {
  167. DistortionCofficients = new float[8];
  168. int col = 0;
  169. try
  170. {
  171. XmlElement dataElement = RGBDistCoeff.Item(0)["data"];
  172. var textInArray = dataElement.InnerText.Trim().Split(' ');
  173. for (int i = 0; i < textInArray.Length; i++)
  174. {
  175. string t = textInArray[i];
  176. if (float.TryParse(t, out float value))
  177. {
  178. DistortionCofficients[col] = value;
  179. col++;
  180. if (col >= 8)
  181. {
  182. break;
  183. }
  184. }
  185. }
  186. }
  187. catch (Exception exc)
  188. {
  189. Debug.LogException(exc);
  190. }
  191. }
  192. public bool EnableModule(InitializeHandTrackingModuleParameter initParameter)
  193. {
  194. if (DistortionCoefficients == null || CalibrationMatrix == null)
  195. {
  196. ParseRGBCameraParams();
  197. }
  198. #if DEVELOPMENT_BUILD
  199. try
  200. {
  201. #endif
  202. if (m_IsModuleEnabled)
  203. {
  204. Debug.Log("HandTrackingT3D module already activate.");
  205. return false;
  206. }
  207. handTrackingAnchor = initParameter.TrackingAnchor;
  208. if (!Permission.HasUserAuthorizedPermission(Permission.Camera))
  209. {
  210. Permission.RequestUserPermission(Permission.Camera);
  211. }
  212. //WebCamDevice[] devices = WebCamTexture.devices;
  213. //if (devices.Length == 0)
  214. // return false;
  215. //for (int i = 0; i < devices.Length; i++)
  216. //{
  217. // var curr = devices[i];
  218. // if (curr.isFrontFacing == true)
  219. // {
  220. // //RhinoX using front facing camera
  221. // cameraTexture = new WebCamTexture(curr.name, width, height, 60);
  222. // break;
  223. // }
  224. //}
  225. //cameraTexture.Play();
  226. XimmerseXR.RequestOpenRGBCamera(width, height);
  227. cameraTexture = XimmerseXR.RGBCameraTexture;
  228. imageHandle = GCHandle.Alloc(imgData, GCHandleType.Pinned);
  229. string uniqueID = SystemInfo.deviceUniqueIdentifier;
  230. string storageLocation = Application.persistentDataPath;
  231. //var calibration = new NativeCalibration();
  232. //var calibration = new Calibration(cameraTexture.width, cameraTexture.height,
  233. // CalibrationMatrix, DistortionCoefficients);
  234. var calibration = new Calibration(1440, 1080, CalibrationMatrix, DistortionCoefficients);
  235. //var calibration = new Calibration(width * 4f, height * 4f, CalibrationMatrix, DistortionCoefficients);
  236. touchlessEngine = new Engine(uniqueID, storageLocation, calibration, OnTouchlessEvent);
  237. handTrackInfo = new HandTrackingInfo()
  238. {
  239. ThumbFinger = new RawFingerTrackingInfo(3)
  240. {
  241. bendnessRangeMin = 0.7f,
  242. bendnessRangeMax = 0.9f,
  243. },
  244. IndexFinger = new RawFingerTrackingInfo(4)
  245. {
  246. bendnessRangeMin = 0.1f,
  247. bendnessRangeMax = 0.9f,
  248. },
  249. MiddleFinger = new RawFingerTrackingInfo(4)
  250. {
  251. bendnessRangeMin = 0.1f,
  252. bendnessRangeMax = 0.9f,
  253. },
  254. RingFinger = new RawFingerTrackingInfo(4)
  255. {
  256. bendnessRangeMin = 0.1f,
  257. bendnessRangeMax = 0.9f,
  258. },
  259. LittleFinger = new RawFingerTrackingInfo(4)
  260. {
  261. bendnessRangeMin = 0.1f,
  262. bendnessRangeMax = 0.9f,
  263. },
  264. };
  265. previousValidFrameHandTrackInfo = new HandTrackingInfo()
  266. {
  267. ThumbFinger = new RawFingerTrackingInfo(3)
  268. {
  269. bendnessRangeMin = 0.7f,
  270. bendnessRangeMax = 0.9f,
  271. },
  272. IndexFinger = new RawFingerTrackingInfo(4)
  273. {
  274. bendnessRangeMin = 0.1f,
  275. bendnessRangeMax = 0.9f,
  276. },
  277. MiddleFinger = new RawFingerTrackingInfo(4)
  278. {
  279. bendnessRangeMin = 0.1f,
  280. bendnessRangeMax = 0.9f,
  281. },
  282. RingFinger = new RawFingerTrackingInfo(4)
  283. {
  284. bendnessRangeMin = 0.1f,
  285. bendnessRangeMax = 0.9f,
  286. },
  287. LittleFinger = new RawFingerTrackingInfo(4)
  288. {
  289. bendnessRangeMin = 0.1f,
  290. bendnessRangeMax = 0.9f,
  291. },
  292. };
  293. m_IsModuleEnabled = true;
  294. Debug.Log("T3D hand tracking is now active.");
  295. return true;
  296. #if DEVELOPMENT_BUILD
  297. }
  298. catch (Exception e)
  299. {
  300. Debug.LogException(e);
  301. }
  302. return false;
  303. #endif
  304. }
  305. private bool isvalid;
  306. private bool isTracking;
  307. int frame = 0;
  308. public void Optimize()
  309. {
  310. isvalid = handTrackInfo.IsValid;
  311. if (isvalid)
  312. {
  313. frame = 0;
  314. handTrackInfo.IsTracking = isvalid;
  315. }
  316. else
  317. {
  318. frame++;
  319. if (frame > 5)
  320. {
  321. handTrackInfo.IsTracking = isvalid;
  322. }
  323. }
  324. }
  325. /// <summary>
  326. /// Call per frame , in main thread.
  327. /// </summary>
  328. public void Tick()
  329. {
  330. #if DEVELOPMENT_BUILD
  331. try
  332. {
  333. #endif
  334. //备份当前帧
  335. if (handTrackInfo.IsValid)
  336. {
  337. previousValidFrameHandTrackInfo.CopyFrom(handTrackInfo);
  338. }
  339. //对于50ms之前的合法帧,由于时间过长, 需要抛弃
  340. else if (previousValidFrameHandTrackInfo.IsValid)
  341. {
  342. if (new TimeSpan(handTrackInfo.Timestamp - previousValidFrameHandTrackInfo.Timestamp).TotalMilliseconds > 50d)
  343. {
  344. previousValidFrameHandTrackInfo.IsValid = false;
  345. }
  346. }
  347. handTrackInfo.IsValid = false;//reset hand track info before native plugin feedback
  348. if (!m_IsModuleEnabled || null == cameraTexture || !cameraTexture.didUpdateThisFrame)
  349. {
  350. return;
  351. }
  352. //GestureEvent syncedEvent = null;
  353. lock (lockObj)
  354. {
  355. if (locked_gestureEvent != null)
  356. {
  357. ParseGestureEvent(locked_gestureEvent);
  358. //syncedEvent = new GestureEvent(locked_gestureEvent);
  359. //locked_gestureEvent = null;
  360. }
  361. }
  362. Optimize();
  363. ////Debug.LogFormat("HandTrackingT3D.Tick : {0}, {1}", syncedEvent != null, syncedEvent != null && syncedEvent.skeletonValid);
  364. //if (null != syncedEvent)
  365. //{
  366. // ParseGestureEvent(locked_gestureEvent);
  367. //}
  368. //update the tracking anchor local to world matrix
  369. hand_local_2_world = handTrackingAnchor.localToWorldMatrix;
  370. cameraTexture.GetPixels32(imgData);
  371. using (var frame = new Frame(imageHandle.AddrOfPinnedObject(), cameraTexture.width * 4, cameraTexture.width, cameraTexture.height, System.DateTimeOffset.Now.ToUnixTimeMilliseconds(), FrameRotation.ROTATION_NONE, true))
  372. {
  373. touchlessEngine.handleFrame(frame);
  374. }
  375. #if DEVELOPMENT_BUILD
  376. }
  377. catch (Exception e)
  378. {
  379. Debug.LogException(e);
  380. }
  381. #endif
  382. }
  383. /// <summary>
  384. /// Convert T3D skeleton to hand track info :
  385. /// </summary>
  386. /// <param name="args"></param>
  387. private void ParseGestureEvent(GestureEvent args)
  388. {
  389. Skeleton t3dSkel = args.skeleton;
  390. if (handTrackInfo.IsValid && (!args.skeletonValid || t3dSkel == null))
  391. {
  392. Debug.Log("Hand tracking become invalid !");
  393. }
  394. if (t3dSkel == null)
  395. {
  396. return;
  397. }
  398. handTrackInfo.IsValid = args.skeletonValid;
  399. handTrackInfo.Timestamp = System.DateTime.Now.Ticks;
  400. //update raw hand tracking info data
  401. handTrackInfo.Handness = args.handedness == HandednessType.LEFT_HAND ? HandnessType.Left : HandnessType.Right;
  402. handTrackInfo.ThumbFinger.Positions[0] = hand_local_2_world.MultiplyPoint3x4(t3dSkel.points[SkeletonPointsID.THUMB2]);
  403. handTrackInfo.ThumbFinger.Positions[1] = hand_local_2_world.MultiplyPoint3x4(t3dSkel.points[SkeletonPointsID.THUMB3]);
  404. handTrackInfo.ThumbFinger.Positions[2] = hand_local_2_world.MultiplyPoint3x4(t3dSkel.points[SkeletonPointsID.THUMB4]);
  405. handTrackInfo.IndexFinger.Positions[0] = hand_local_2_world.MultiplyPoint3x4(t3dSkel.points[SkeletonPointsID.INDEX1]);
  406. handTrackInfo.IndexFinger.Positions[1] = hand_local_2_world.MultiplyPoint3x4(t3dSkel.points[SkeletonPointsID.INDEX2]);
  407. handTrackInfo.IndexFinger.Positions[2] = hand_local_2_world.MultiplyPoint3x4(t3dSkel.points[SkeletonPointsID.INDEX3]);
  408. handTrackInfo.IndexFinger.Positions[3] = hand_local_2_world.MultiplyPoint3x4(t3dSkel.points[SkeletonPointsID.INDEX4]);
  409. handTrackInfo.MiddleFinger.Positions[0] = hand_local_2_world.MultiplyPoint3x4(t3dSkel.points[SkeletonPointsID.MIDDLE1]);
  410. handTrackInfo.MiddleFinger.Positions[1] = hand_local_2_world.MultiplyPoint3x4(t3dSkel.points[SkeletonPointsID.MIDDLE2]);
  411. handTrackInfo.MiddleFinger.Positions[2] = hand_local_2_world.MultiplyPoint3x4(t3dSkel.points[SkeletonPointsID.MIDDLE3]);
  412. handTrackInfo.MiddleFinger.Positions[3] = hand_local_2_world.MultiplyPoint3x4(t3dSkel.points[SkeletonPointsID.MIDDLE4]);
  413. handTrackInfo.RingFinger.Positions[0] = hand_local_2_world.MultiplyPoint3x4(t3dSkel.points[SkeletonPointsID.RING1]);
  414. handTrackInfo.RingFinger.Positions[1] = hand_local_2_world.MultiplyPoint3x4(t3dSkel.points[SkeletonPointsID.RING2]);
  415. handTrackInfo.RingFinger.Positions[2] = hand_local_2_world.MultiplyPoint3x4(t3dSkel.points[SkeletonPointsID.RING3]);
  416. handTrackInfo.RingFinger.Positions[3] = hand_local_2_world.MultiplyPoint3x4(t3dSkel.points[SkeletonPointsID.RING4]);
  417. handTrackInfo.LittleFinger.Positions[0] = hand_local_2_world.MultiplyPoint3x4(t3dSkel.points[SkeletonPointsID.PINKY1]);
  418. handTrackInfo.LittleFinger.Positions[1] = hand_local_2_world.MultiplyPoint3x4(t3dSkel.points[SkeletonPointsID.PINKY2]);
  419. handTrackInfo.LittleFinger.Positions[2] = hand_local_2_world.MultiplyPoint3x4(t3dSkel.points[SkeletonPointsID.PINKY3]);
  420. handTrackInfo.LittleFinger.Positions[3] = hand_local_2_world.MultiplyPoint3x4(t3dSkel.points[SkeletonPointsID.PINKY4]);
  421. handTrackInfo.UpdateProperties();
  422. //Debug.LogFormat("bendness thumb = {0}, index = {1}, middle = {2}, ring = {3}, little = {4}", handTrackInfo.ThumbFinger.bendness, handTrackInfo.IndexFinger.bendness,
  423. //handTrackInfo.MiddleFinger.bendness, handTrackInfo.RingFinger.bendness, handTrackInfo.LittleFinger.bendness);
  424. Vector3 wristPos = hand_local_2_world.MultiplyPoint3x4(t3dSkel.points[SkeletonPointsID.WRIST]);
  425. Vector3 wristToRing = handTrackInfo.RingFinger.Positions[0] - wristPos;
  426. Vector3 wristToMiddle = handTrackInfo.MiddleFinger.Positions[0] - wristPos;
  427. Vector3 ringToMiddle = handTrackInfo.MiddleFinger.Positions[0] - handTrackInfo.RingFinger.Positions[0];
  428. handTrackInfo.PalmPosition = wristPos + wristToRing * 0.45f + ringToMiddle * 0.43f;
  429. handTrackInfo.PalmScale = Vector3.one * wristToMiddle.magnitude * 0.86f;
  430. if (previousValidFrameHandTrackInfo.IsValid)
  431. {
  432. handTrackInfo.PalmDeltaPosition = handTrackInfo.PalmPosition - previousValidFrameHandTrackInfo.PalmPosition;
  433. handTrackInfo.PalmVelocity = handTrackInfo.PalmDeltaPosition / (float)new TimeSpan(handTrackInfo.Timestamp - previousValidFrameHandTrackInfo.Timestamp).TotalSeconds;
  434. }
  435. Vector3 crs = Vector3.Cross(wristToRing, wristToMiddle);
  436. //Make palm normal always facing UP upon the palm surface:
  437. if (args.handedness == HandednessType.LEFT_HAND)
  438. {
  439. crs = -crs;
  440. }
  441. handTrackInfo.PalmRotation = Quaternion.LookRotation(wristToRing, crs);
  442. handTrackInfo.PalmNormal = crs.normalized;
  443. //Calculate local position to main camera:
  444. if (!mainCamera)
  445. {
  446. mainCamera = Camera.main.transform;
  447. }
  448. if (mainCamera && mainCamera.parent)
  449. {
  450. if (mainCamera.parent)
  451. {
  452. handTrackInfo.PalmLocalPosition = mainCamera.parent.InverseTransformPoint(handTrackInfo.PalmPosition);
  453. handTrackInfo.PalmLocalRotation = Quaternion.Inverse(mainCamera.parent.rotation) * handTrackInfo.PalmRotation;
  454. handTrackInfo.PalmLocalNormal = mainCamera.parent.InverseTransformVector(handTrackInfo.PalmNormal);
  455. }
  456. else
  457. {
  458. handTrackInfo.PalmLocalPosition = mainCamera.InverseTransformPoint(handTrackInfo.PalmPosition);
  459. handTrackInfo.PalmLocalRotation = Quaternion.Inverse(mainCamera.rotation) * handTrackInfo.PalmRotation;
  460. handTrackInfo.PalmLocalNormal = mainCamera.InverseTransformVector(handTrackInfo.PalmNormal);
  461. }
  462. }
  463. //Debug.LogFormat("Get valid hand track frame at time: {0}, is valid: {3} palm point: {1}, thumb point: {2}",
  464. // handTrackInfo.Timestamp, handTrackInfo.PalmPosition, handTrackInfo.ThumbFinger.Positions[0], handTrackInfo.IsValid);
  465. handTrackInfo.NativeGestureType = (int)args.type;
  466. //Update gesture enum:
  467. if (handTrackInfo.IsValid == false)
  468. {
  469. handTrackInfo.gestureFistOpenHand = GestureType_Fist_OpenHand.None;
  470. handTrackInfo.gestureGrisp = GestureType_Grisp.None;
  471. handTrackInfo.NativeGestureType = -1;
  472. }
  473. else
  474. {
  475. //gesture type of open hand / grisp :
  476. if (handTrackInfo.NativeGestureType == (int)TouchlessA3D.GestureType.HAND || handTrackInfo.NativeGestureType == (int)TouchlessA3D.GestureType.OPEN_HAND)
  477. {
  478. handTrackInfo.gestureFistOpenHand = GestureType_Fist_OpenHand.Opened;
  479. handTrackInfo.gestureGrisp = GestureType_Grisp.GrispOpen;
  480. }
  481. //Fist - close hand and grasp clsoed
  482. if (handTrackInfo.NativeGestureType == (int)TouchlessA3D.GestureType.CLOSED_HAND)
  483. {
  484. handTrackInfo.gestureFistOpenHand = GestureType_Fist_OpenHand.Fist;
  485. handTrackInfo.gestureGrisp = GestureType_Grisp.GraspClosed;
  486. }
  487. //Grisp pinch:
  488. if (handTrackInfo.NativeGestureType == (int)TouchlessA3D.GestureType.CLOSED_PINCH)
  489. {
  490. handTrackInfo.gestureGrisp = GestureType_Grisp.GraspClosed;
  491. }
  492. }
  493. }
  494. /// <summary>
  495. /// Callback on native event.
  496. /// </summary>
  497. /// <param name="sender"></param>
  498. /// <param name="args"></param>
  499. private void OnTouchlessEvent(object sender, GestureEvent args)
  500. {
  501. //Debug.LogFormat("OnTouchlessEvent : {0}", args.skeletonValid);
  502. lock (lockObj)
  503. {
  504. locked_gestureEvent = args;
  505. }
  506. }
  507. }
  508. }