NativeCalls.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. using System;
  2. using System.Runtime.InteropServices;
  3. namespace TouchlessA3D {
  4. public static class NativeCalls {
  5. public enum ResultType {
  6. RESULT_UNAVAILABLE = 0,
  7. RESULT_OK = 1,
  8. }
  9. [DllImport("touchless_a3d_xr")] // ta3d_engine_t
  10. public static extern IntPtr ta3d_engine_acquire(System.String unique_id, System.String persistent_storage_path,
  11. IntPtr calibration, IntPtr callback, IntPtr callback_context);
  12. [DllImport("touchless_a3d_xr")]
  13. public static extern void ta3d_engine_release(IntPtr ta3d_engine_t);
  14. [DllImport("touchless_a3d_xr")]
  15. public static extern void ta3d_engine_handle_frame(IntPtr ta3d_engine_t, IntPtr ta3d_frame_t);
  16. [DllImport("touchless_a3d_xr")] //ta3d_frame_t
  17. public static extern IntPtr ta3d_frame_create_from_android_420(
  18. IntPtr src_y, int src_stride_y,
  19. IntPtr src_u, int src_stride_u,
  20. IntPtr src_v, int src_stride_v,
  21. int pixel_stride_uv, int width, int height,
  22. long timestamp_ms, FrameRotation rotation);
  23. [DllImport("touchless_a3d_xr")]
  24. public static extern IntPtr ta3d_frame_create_from_rgba(
  25. IntPtr src_rgba, int src_stride,
  26. int width, int height,
  27. long timestamp_ms, FrameRotation rotation,
  28. bool flip_vertically);
  29. [DllImport("touchless_a3d_xr")]
  30. public static extern void ta3d_frame_destroy(IntPtr ta3d_frame_t);
  31. [DllImport("touchless_a3d_xr")]
  32. public static extern GestureType ta3d_event_get_type(IntPtr ta3d_event_t);
  33. [DllImport("touchless_a3d_xr")]
  34. public static extern void ta3d_skeleton_points_3d(IntPtr ta3d_event_t, IntPtr ta3d_skeleton_3d_t);
  35. [DllImport("touchless_a3d_xr")]
  36. public static extern ResultType ta3d_get_calibration(PreconfiguredCalibrations ta3denum, IntPtr ta3d_skeleton_3d_s);
  37. [DllImport("touchless_a3d_xr")]
  38. public static extern HandednessType ta3d_get_handedness(IntPtr ta3d_event_t);
  39. [StructLayout(LayoutKind.Sequential)]
  40. public struct ta3d_point_2_float_t {
  41. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
  42. public float[] coordinates;
  43. }
  44. [StructLayout(LayoutKind.Sequential)]
  45. public struct ta3d_point_3_float_t {
  46. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
  47. public float[] coordinates;
  48. }
  49. [StructLayout(LayoutKind.Sequential)]
  50. public struct ta3d_size_2_float_t {
  51. public float width;
  52. public float height;
  53. }
  54. [StructLayout(LayoutKind.Sequential)]
  55. public struct ta3d_matrix_3_3_float_t {
  56. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 9)]
  57. public float[] elements;
  58. }
  59. [StructLayout(LayoutKind.Sequential)]
  60. public struct ta3d_matrix_1_8_float_t {
  61. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
  62. public float[] elements;
  63. }
  64. [StructLayout(LayoutKind.Sequential)]
  65. public struct ta3d_calibration_s {
  66. public ta3d_size_2_float_t calibration_size;
  67. public ta3d_matrix_3_3_float_t camera_matrix;
  68. public ta3d_matrix_1_8_float_t distortion_coefficients;
  69. }
  70. [StructLayout(LayoutKind.Sequential)]
  71. public struct ta3d_skeleton_3d_s {
  72. public ResultType status;
  73. [MarshalAs(UnmanagedType.ByValArray, SizeConst = SkeletonInfo.POINTS_END)]
  74. public ta3d_point_3_float_t[] points;
  75. [MarshalAs(UnmanagedType.ByValArray, SizeConst = SkeletonInfo.BONES_END)]
  76. public ta3d_matrix_3_3_float_t[] rotations;
  77. [MarshalAs(UnmanagedType.ByValArray, SizeConst = SkeletonInfo.BONES_END)]
  78. public float[] bone_lengths;
  79. }
  80. }
  81. }