Skip to content

Commit 4e5f0f4

Browse files
committed
Initial commit
0 parents  commit 4e5f0f4

21 files changed

+1057
-0
lines changed

SRanipalExtTrackingModule.sln

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.5.33424.131
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SRanipalExtTrackingModule", "SRanipalExtTrackingModule\SRanipalExtTrackingModule.csproj", "{FDB449B6-FE47-4B3F-8660-CCB286C28491}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Debug|x64 = Debug|x64
12+
Release|Any CPU = Release|Any CPU
13+
Release|x64 = Release|x64
14+
EndGlobalSection
15+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+
{FDB449B6-FE47-4B3F-8660-CCB286C28491}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17+
{FDB449B6-FE47-4B3F-8660-CCB286C28491}.Debug|Any CPU.Build.0 = Debug|Any CPU
18+
{FDB449B6-FE47-4B3F-8660-CCB286C28491}.Debug|x64.ActiveCfg = Debug|Any CPU
19+
{FDB449B6-FE47-4B3F-8660-CCB286C28491}.Debug|x64.Build.0 = Debug|Any CPU
20+
{FDB449B6-FE47-4B3F-8660-CCB286C28491}.Release|Any CPU.ActiveCfg = Release|Any CPU
21+
{FDB449B6-FE47-4B3F-8660-CCB286C28491}.Release|Any CPU.Build.0 = Release|Any CPU
22+
{FDB449B6-FE47-4B3F-8660-CCB286C28491}.Release|x64.ActiveCfg = Release|x64
23+
{FDB449B6-FE47-4B3F-8660-CCB286C28491}.Release|x64.Build.0 = Release|x64
24+
EndGlobalSection
25+
GlobalSection(SolutionProperties) = preSolution
26+
HideSolutionNode = FALSE
27+
EndGlobalSection
28+
GlobalSection(ExtensibilityGlobals) = postSolution
29+
SolutionGuid = {39244852-855D-48D9-8FCA-2616D3E513DE}
30+
EndGlobalSection
31+
EndGlobal
32.6 KB
Loading
199 KB
Loading
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
//========= Copyright 2018, HTC Corporation. All rights reserved. ===========
2+
using System.Runtime.InteropServices;
3+
using VRCFaceTracking.Core.Types;
4+
5+
namespace ViveSR
6+
{
7+
namespace anipal
8+
{
9+
namespace Eye
10+
{
11+
#region VerboseData
12+
public enum EyeIndex { LEFT, RIGHT, }
13+
public enum GazeIndex { LEFT, RIGHT, COMBINE }
14+
15+
/** @enum SingleEyeDataValidity
16+
An enum type for getting validity from the structure: eye data's bitmask
17+
*/
18+
public enum SingleEyeDataValidity : int
19+
{
20+
/** The validity of the origin of gaze of the eye data */
21+
SINGLE_EYE_DATA_GAZE_ORIGIN_VALIDITY,
22+
/** The validity of the direction of gaze of the eye data */
23+
SINGLE_EYE_DATA_GAZE_DIRECTION_VALIDITY,
24+
/** The validity of the diameter of gaze of the eye data */
25+
SINGLE_EYE_DATA_PUPIL_DIAMETER_VALIDITY,
26+
/** The validity of the openness of the eye data */
27+
SINGLE_EYE_DATA_EYE_OPENNESS_VALIDITY,
28+
/** The validity of normalized position of pupil */
29+
SINGLE_EYE_DATA_PUPIL_POSITION_IN_SENSOR_AREA_VALIDITY
30+
};
31+
32+
public enum TrackingImprovement : int
33+
{
34+
TRACKING_IMPROVEMENT_USER_POSITION_HMD,
35+
TRACKING_IMPROVEMENT_CALIBRATION_CONTAINS_POOR_DATA,
36+
TRACKING_IMPROVEMENT_CALIBRATION_DIFFERENT_BRIGHTNESS,
37+
TRACKING_IMPROVEMENT_IMAGE_QUALITY,
38+
TRACKING_IMPROVEMENT_INCREASE_EYE_RELIEF,
39+
};
40+
41+
[StructLayout(LayoutKind.Sequential)]
42+
public struct TrackingImprovements
43+
{
44+
public int count;
45+
public unsafe fixed int items[10];
46+
};
47+
48+
/** @struct SingleEyeData
49+
* A struct containing status related an eye.
50+
* @image html EyeData.png width=1040px height=880px
51+
*/
52+
[StructLayout(LayoutKind.Sequential)]
53+
public struct SingleEyeData
54+
{
55+
/** The bits containing all validity for this frame.*/
56+
public System.UInt64 eye_data_validata_bit_mask;
57+
/** The point in the eye from which the gaze ray originates in millimeter.(right-handed coordinate system)*/
58+
public Vector3 gaze_origin_mm;
59+
/** The normalized gaze direction of the eye in [0,1].(right-handed coordinate system)*/
60+
public Vector3 gaze_direction_normalized;
61+
/** The diameter of the pupil in millimeter*/
62+
public float pupil_diameter_mm;
63+
/** A value representing how open the eye is.*/
64+
public float eye_openness;
65+
/** The normalized position of a pupil in [0,1]*/
66+
public Vector2 pupil_position_in_sensor_area;
67+
68+
public bool GetValidity(SingleEyeDataValidity validity) => (eye_data_validata_bit_mask & (ulong)(1 << (int)validity)) > 0;
69+
}
70+
71+
[StructLayout(LayoutKind.Sequential)]
72+
public struct CombinedEyeData
73+
{
74+
public SingleEyeData eye_data;
75+
public byte convergence_distance_validity;
76+
public float convergence_distance_mm;
77+
}
78+
79+
[StructLayout(LayoutKind.Sequential)]
80+
/** @struct VerboseData
81+
* A struct containing all data listed below.
82+
*/
83+
public struct VerboseData
84+
{
85+
/** A instance of the struct as @ref EyeData related to the left eye*/
86+
public SingleEyeData left;
87+
/** A instance of the struct as @ref EyeData related to the right eye*/
88+
public SingleEyeData right;
89+
/** A instance of the struct as @ref EyeData related to the combined eye*/
90+
public CombinedEyeData combined;
91+
public TrackingImprovements tracking_improvements;
92+
}
93+
#endregion
94+
95+
#region EyeParameter
96+
[StructLayout(LayoutKind.Sequential)]
97+
/** @struct GazeRayParameter
98+
* A struct containing all data listed below.
99+
*/
100+
public struct GazeRayParameter
101+
{
102+
/** The sensitive factor of gaze ray in [0,1]. The bigger factor is, the more sensitive the gaze ray is.*/
103+
public double sensitive_factor;
104+
};
105+
106+
[StructLayout(LayoutKind.Sequential)]
107+
/** @struct EyeParameter
108+
* A struct containing all data listed below.
109+
*/
110+
public struct EyeParameter
111+
{
112+
public GazeRayParameter gaze_ray_parameter;
113+
};
114+
#endregion
115+
116+
#region CalibrationResult
117+
public enum CalibrationResult
118+
{
119+
SUCCESS,
120+
FAIL,
121+
BUSY,
122+
}
123+
#endregion
124+
}
125+
}
126+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
//========= Copyright 2018, HTC Corporation. All rights reserved. ===========
2+
using System;
3+
using System.Runtime.InteropServices;
4+
5+
namespace ViveSR
6+
{
7+
namespace anipal
8+
{
9+
namespace Eye
10+
{
11+
#region EyeShape_v2
12+
public enum EyeShape_v2
13+
{
14+
None = -1,
15+
Eye_Left_Blink = 0,
16+
Eye_Left_Wide,
17+
Eye_Left_Right,
18+
Eye_Left_Left,
19+
Eye_Left_Up,
20+
Eye_Left_Down,
21+
Eye_Right_Blink = 6,
22+
Eye_Right_Wide,
23+
Eye_Right_Right,
24+
Eye_Right_Left,
25+
Eye_Right_Up,
26+
Eye_Right_Down,
27+
Eye_Frown = 12,
28+
Eye_Left_Squeeze,
29+
Eye_Right_Squeeze,
30+
Max = 15,
31+
}
32+
33+
#endregion
34+
35+
[StructLayout(LayoutKind.Sequential)]
36+
public struct SingleEyeExpression
37+
{
38+
public float eye_wide; /*!<A value representing how open eye widely.*/
39+
public float eye_squeeze; /*!<A value representing how the eye is closed tightly.*/
40+
public float eye_frown; /*!<A value representing user's frown.*/
41+
};
42+
43+
[StructLayout(LayoutKind.Sequential)]
44+
public struct EyeExpression
45+
{
46+
public SingleEyeExpression left;
47+
public SingleEyeExpression right;
48+
};
49+
50+
[StructLayout(LayoutKind.Sequential)]
51+
/** @struct EyeData
52+
* A struct containing all data listed below.
53+
*/
54+
public struct EyeData_v2
55+
{
56+
/** Indicate if there is a user in front of HMD. */
57+
public byte no_user;
58+
/** The frame sequence.*/
59+
public int frame_sequence;
60+
/** The time when the frame was capturing. in millisecond.*/
61+
public int timestamp;
62+
public VerboseData verbose_data;
63+
public EyeExpression expression_data;
64+
}
65+
}
66+
}
67+
}
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
//========= Copyright 2019, HTC Corporation. All rights reserved. ===========
2+
using System;
3+
using System.Runtime.InteropServices;
4+
5+
namespace ViveSR
6+
{
7+
namespace anipal
8+
{
9+
namespace Eye
10+
{
11+
public static class SRanipal_Eye_API
12+
{
13+
/// <summary>
14+
/// Check HMD device is ViveProEye or not.
15+
/// </summary>
16+
/// <returns>true : ViveProEye, false : other HMD.</returns>
17+
[DllImport("SRanipal")]
18+
public static extern bool IsViveProEye();
19+
20+
/// <summary>
21+
/// Gets data from anipal's Eye module.
22+
/// </summary>
23+
/// <param name="data">ViveSR.anipal.Eye.EyeData</param>
24+
/// <returns>Indicates the resulting ViveSR.Error status of this method.</returns>
25+
[DllImport("SRanipal")]
26+
public static extern Error GetEyeData_v2(ref EyeData_v2 data);
27+
28+
/// <summary>
29+
/// Sets the parameter of anipal's Eye module.
30+
/// </summary>
31+
/// <param name="parameter">ViveSR.anipal.Eye.EyeParameter</param>
32+
/// <returns>Indicates the resulting ViveSR.Error status of this method.</returns>
33+
[DllImport("SRanipal")]
34+
public static extern Error SetEyeParameter(EyeParameter parameter);
35+
36+
/// <summary>
37+
/// Gets the parameter of anipal's Eye module.
38+
/// </summary>
39+
/// <param name="parameter">ViveSR.anipal.Eye.EyeParameter</param>
40+
/// <returns>Indicates the resulting ViveSR.Error status of this method.</returns>
41+
[DllImport("SRanipal")]
42+
public static extern Error GetEyeParameter(ref EyeParameter parameter);
43+
44+
/// <summary>
45+
/// Indicate if user need to do eye calibration now.
46+
/// </summary>
47+
/// <param name="need">If need calibration, it will be true, otherwise it will be false.</param>
48+
/// <returns>Indicates the resulting ViveSR.Error status of this method.</returns>
49+
[DllImport("SRanipal")]
50+
public static extern int IsUserNeedCalibration(ref bool need);
51+
52+
/// <summary>
53+
/// Launches anipal's Eye Calibration tool (an overlay program).
54+
/// </summary>
55+
/// <param name="callback">(Upcoming feature) A callback method invoked at the end of the calibration process.</param>
56+
/// <returns>Indicates the resulting ViveSR.Error status of this method.</returns>
57+
[DllImport("SRanipal")]
58+
public static extern int LaunchEyeCalibration(IntPtr callback);
59+
60+
/* Register a callback function to receive eye camera related data when the module has new outputs.
61+
[in] function pointer of callback
62+
[out] error code. please refer Error in ViveSR_Enums.h
63+
*/
64+
[DllImport("SRanipal")]
65+
public static extern int RegisterEyeDataCallback(IntPtr callback);
66+
67+
/* Unegister a callback function to stop receiving eye camera related data.
68+
* [in] function pointer of callback
69+
* [out] error code. please refer Error in ViveSR_Enums.h
70+
*/
71+
[DllImport("SRanipal")]
72+
public static extern int UnregisterEyeDataCallback(IntPtr callback);
73+
74+
/* Register a callback function to receive eye camera related data when the module has new outputs.
75+
* [in] function pointer of callback
76+
* [out] error code. please refer Error in ViveSR_Enums.h
77+
*/
78+
[DllImport("SRanipal")]
79+
public static extern int RegisterEyeDataCallback_v2(IntPtr callback);
80+
81+
/* Unegister a callback function to stop receiving eye camera related data.
82+
* [in] function pointer of callback
83+
* [out] error code. please refer Error in ViveSR_Enums.h
84+
*/
85+
[DllImport("SRanipal")]
86+
public static extern int UnregisterEyeDataCallback_v2(IntPtr callback);
87+
88+
/* Synchronization the clock on the device and the clock on the system.
89+
* @param[in] Trigger for Synchronization function.
90+
* @return error code. please refer Error in ViveSR_Enums.h
91+
*/
92+
[DllImport("SRanipal")]
93+
public static extern Error SRanipal_UpdateTimeSync();
94+
95+
/* Get the system timestamp.
96+
* @param[out] the value of system timestamp.
97+
* @return error code. please refer Error in ViveSR_Enums.h
98+
*/
99+
[DllImport("SRanipal")]
100+
public static extern Error SRanipal_GetSystemTime(ref Int64 time);
101+
}
102+
}
103+
}
104+
}
105+
106+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//========= Copyright 2019, HTC Corporation. All rights reserved. ===========
2+
using System;
3+
using System.Collections.Generic;
4+
5+
namespace ViveSR
6+
{
7+
namespace anipal
8+
{
9+
namespace Eye
10+
{
11+
public static class SRanipal_Eye_v2
12+
{
13+
public const int ANIPAL_TYPE_EYE_V2 = 2;
14+
15+
public const int WeightingCount = (int)EyeShape_v2.Max;
16+
private static Dictionary<EyeShape_v2, float> Weightings;
17+
18+
static SRanipal_Eye_v2()
19+
{
20+
Weightings = new Dictionary<EyeShape_v2, float>();
21+
for (int i = 0; i < WeightingCount; ++i) Weightings.Add((EyeShape_v2)i, 0.0f);
22+
}
23+
24+
/// <summary>
25+
/// Launches anipal's Eye Calibration feature (an overlay program).
26+
/// </summary>
27+
/// <returns>Indicates the resulting ViveSR.Error status of this method.</returns>
28+
public static bool LaunchEyeCalibration()
29+
{
30+
int result = SRanipal_Eye_API.LaunchEyeCalibration(IntPtr.Zero);
31+
return result == (int)Error.WORK;
32+
}
33+
}
34+
}
35+
}
36+
}

0 commit comments

Comments
 (0)