Skip to content

Commit cf0d219

Browse files
committed
AME2
1 parent a19f535 commit cf0d219

File tree

18 files changed

+263
-140
lines changed

18 files changed

+263
-140
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: windows-latest
1212
strategy:
1313
matrix:
14-
dotnet-version: ['7.0.x' ]
14+
dotnet-version: ['10.0.x' ]
1515

1616
steps:
1717
- uses: actions/checkout@v3
@@ -20,7 +20,7 @@ jobs:
2020

2121
- uses: actions/setup-dotnet@v3
2222
with:
23-
dotnet-version: '7.0.x'
23+
dotnet-version: '10.0.x'
2424

2525
- name: Add MSYS64 bin to PATH
2626
run: echo "C:\msys64\usr\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
@@ -48,7 +48,7 @@ jobs:
4848
uses: "marvinpinto/action-automatic-releases@latest"
4949
with:
5050
repo_token: "${{ secrets.GITHUB_TOKEN }}"
51-
automatic_release_tag: "latest"
51+
automatic_release_tag: "ame-latest"
5252
prerelease: true
5353
title: "plugin_KinectOne Build Artifact"
5454
files: |

KinectHandler/KinectHandler.h

Lines changed: 49 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,39 @@ using namespace Collections::Generic;
1010
using namespace ComponentModel::Composition;
1111
using namespace Runtime::InteropServices;
1212

13-
using namespace Amethyst::Plugins::Contract;
14-
1513
namespace KinectHandler
1614
{
15+
private enum TrackedJointTypeInternal
16+
{
17+
JointHead,
18+
JointNeck,
19+
JointSpineShoulder,
20+
JointShoulderLeft,
21+
JointElbowLeft,
22+
JointWristLeft,
23+
JointHandLeft,
24+
JointHandTipLeft,
25+
JointThumbLeft,
26+
JointShoulderRight,
27+
JointElbowRight,
28+
JointWristRight,
29+
JointHandRight,
30+
JointHandTipRight,
31+
JointThumbRight,
32+
JointSpineMiddle,
33+
JointSpineWaist,
34+
JointHipLeft,
35+
JointKneeLeft,
36+
JointFootLeft,
37+
JointFootTipLeft,
38+
JointHipRight,
39+
JointKneeRight,
40+
JointFootRight,
41+
JointFootTipRight,
42+
JointManual,
43+
JointCount
44+
};
45+
1746
public ref class KinectJoint sealed
1847
{
1948
public:
@@ -36,12 +65,13 @@ namespace KinectHandler
3665
private:
3766
KinectWrapper* kinect_;
3867
FunctionToCallDelegate^ function_;
68+
array<BYTE>^ managed_buffer_ = nullptr;
3969

4070
public:
4171
KinectHandler() : kinect_(new KinectWrapper())
4272
{
4373
function_ = gcnew FunctionToCallDelegate(this, &KinectHandler::StatusChangedHandler);
44-
pin_ptr<FunctionToCallDelegate^> tmp = &function_; // Pin the function delegate
74+
[[maybe_unused]] pin_ptr<FunctionToCallDelegate^> tmp = &function_; // Pin the function delegate
4575

4676
status_changed_event = static_cast<void(__cdecl*)()>(
4777
Marshal::GetFunctionPointerForDelegate(function_).ToPointer());
@@ -58,9 +88,11 @@ namespace KinectHandler
5888
const auto& [unmanagedBuffer, size] = kinect_->color_buffer();
5989
if (!unmanagedBuffer || size <= 0) return __nullptr;
6090

61-
auto data = gcnew array<byte>(size); // Managed image placeholder
62-
Marshal::Copy(IntPtr(unmanagedBuffer), data, 0, size);
63-
return data; // Return managed array of bytes for our camera image
91+
if (managed_buffer_ == nullptr || managed_buffer_->Length != size)
92+
managed_buffer_ = gcnew array<BYTE>(size); // allocate once
93+
94+
Marshal::Copy(IntPtr(unmanagedBuffer), managed_buffer_, 0, size);
95+
return managed_buffer_;
6496
}
6597

6698
List<KinectJoint^>^ GetTrackedKinectJoints()
@@ -71,26 +103,26 @@ namespace KinectHandler
71103
const auto& orientations = kinect_->bone_orientations();
72104

73105
auto trackedKinectJoints = gcnew List<KinectJoint^>;
74-
for each (auto v in Enum::GetValues<TrackedJointType>())
106+
for (auto v = 0; v < JointCount; v++)
75107
{
76-
if (v == TrackedJointType::JointManual)
108+
if (v == JointManual)
77109
continue; // Skip unsupported joints
78110

79-
auto joint = gcnew KinectJoint(static_cast<int>(v));
111+
auto joint = gcnew KinectJoint(v);
80112

81113
joint->TrackingState =
82-
positions[kinect_->KinectJointType(static_cast<int>(v))].TrackingState;
114+
positions[kinect_->KinectJointType(v)].TrackingState;
83115

84116
joint->Position = Vector3(
85-
positions[kinect_->KinectJointType(static_cast<int>(v))].Position.X,
86-
positions[kinect_->KinectJointType(static_cast<int>(v))].Position.Y,
87-
positions[kinect_->KinectJointType(static_cast<int>(v))].Position.Z);
117+
positions[kinect_->KinectJointType(v)].Position.X,
118+
positions[kinect_->KinectJointType(v)].Position.Y,
119+
positions[kinect_->KinectJointType(v)].Position.Z);
88120

89121
joint->Orientation = Quaternion(
90-
orientations[kinect_->KinectJointType(static_cast<int>(v))].Orientation.x,
91-
orientations[kinect_->KinectJointType(static_cast<int>(v))].Orientation.y,
92-
orientations[kinect_->KinectJointType(static_cast<int>(v))].Orientation.z,
93-
orientations[kinect_->KinectJointType(static_cast<int>(v))].Orientation.w);
122+
orientations[kinect_->KinectJointType(v)].Orientation.x,
123+
orientations[kinect_->KinectJointType(v)].Orientation.y,
124+
orientations[kinect_->KinectJointType(v)].Orientation.z,
125+
orientations[kinect_->KinectJointType(v)].Orientation.w);
94126

95127
trackedKinectJoints->Add(joint);
96128
}
@@ -129,11 +161,6 @@ namespace KinectHandler
129161
void set(const bool value) { kinect_->camera_enabled(value); }
130162
}
131163

132-
property bool IsSettingsDaemonSupported
133-
{
134-
bool get() { return DeviceStatus == 0; }
135-
}
136-
137164
property int CameraImageWidth
138165
{
139166
int get() { return kinect_->CameraImageSize().first; }

KinectHandler/KinectHandler.vcxproj

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@
2424
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
2525
<ConfigurationType>DynamicLibrary</ConfigurationType>
2626
<UseDebugLibraries>true</UseDebugLibraries>
27-
<PlatformToolset>v143</PlatformToolset>
27+
<PlatformToolset>v145</PlatformToolset>
2828
<CLRSupport>NetCore</CLRSupport>
2929
<CharacterSet>Unicode</CharacterSet>
3030
</PropertyGroup>
3131
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
3232
<ConfigurationType>DynamicLibrary</ConfigurationType>
3333
<UseDebugLibraries>false</UseDebugLibraries>
34-
<PlatformToolset>v143</PlatformToolset>
34+
<PlatformToolset>v145</PlatformToolset>
3535
<CLRSupport>NetCore</CLRSupport>
3636
<CharacterSet>Unicode</CharacterSet>
3737
</PropertyGroup>
@@ -94,9 +94,6 @@
9494
<ClCompile Include="AssemblyInfo.cpp" />
9595
</ItemGroup>
9696
<ItemGroup>
97-
<PackageReference Include="Amethyst.Plugins.Contract">
98-
<Version>1.3.0</Version>
99-
</PackageReference>
10097
<PackageReference Include="System.ComponentModel">
10198
<Version>4.3.0</Version>
10299
</PackageReference>

external/manifest.json

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
{
2-
"version": "1.0.0.0",
3-
"display_name": "Xbox One Kinect",
4-
"download_": "plugin_KinectOne.zip",
5-
"changelog": "Allow Microsoft.Kinect trimming as we're replacing it anyway.",
6-
"guid": "K2VRTEAM-AME2-APII-DVCE-DVCEKINECTV2"
7-
}
2+
"name": "Xbox One Kinect",
3+
"description": "Ame2 plugin for the Xbox One Kinect.",
4+
"guid": "K2VRTEAM-AME2-APII-DVCE-DVCEKINECTV2",
5+
"type": "device",
6+
"author": "K2VR Team",
7+
"artifacts": [
8+
{
9+
"version": "2.0.0.0",
10+
"contract": "2.0.0.0",
11+
"platform": "windows",
12+
"name": "Kinect V2",
13+
"download": "plugin_KinectOne.zip",
14+
"changelog": "Initial release of the Kinect V2 plugin."
15+
}
16+
]
17+
}

0 commit comments

Comments
 (0)