Skip to content

Commit aa12d07

Browse files
committed
Add project files.
1 parent bb51be8 commit aa12d07

File tree

5 files changed

+188
-1
lines changed

5 files changed

+188
-1
lines changed

LICENSE.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) [year] [fullname]
3+
Copyright (c) 2023 Hashory
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Kinect Simple Body Tracking CSV Recorder
2+
3+
This is a tool that uses Azure kinect to record body tracking data to a CSV file.
4+
5+
## Usage
6+
7+
1. Install [Azure kinect Sensor SDK](https://learn.microsoft.com/en-us/azure/kinect-dk/sensor-sdk-download) and [Body Tracking SDK](https://learn.microsoft.com/en-us/azure/Kinect-dk/body-sdk-download).
8+
1. Download this tool. (→ [Release page](https://github.com/Hashory/kinectSimpleBodyTrackingCSVRecorder/releases))
9+
1. Run `kinectSimpleBodyTrackingCSVRecorder.exe`.
10+
11+
## CSV file format
12+
13+
The CSV file contains the following information.
14+
There are 32 joints in total, each with three coordinates (x, y, z). Therefore, there are 96 rows in total.
15+
See [here](https://learn.microsoft.com/en-us/azure/kinect-dk/body-joints#joint-hierarchy) for joint order and more information.
16+
17+
**CSV format:**
18+
```csv
19+
PELVIS.x, PELVIS.y, PELVIS.z, SPINE_NAVAL.x, ・・・ EAR_RIGHT.y, EAR_RIGHT.z
20+
```
21+
22+
Also, be careful with the coordinate system. Azure kinect uses [this](https://learn.microsoft.com/en-us/azure/kinect-dk/coordinate-systems#3d-coordinate-systems).
23+
24+
## License
25+
26+
[MIT License](LICENSE.txt)
27+
28+
## Acknowledgements
29+
30+
This project uses some open source code from the following sources:
31+
32+
- [Azure Kinect Sensor SDK](https://github.com/microsoft/Azure-Kinect-Samples/)
33+
([MIT License](https://github.com/microsoft/Azure-Kinect-Samples/blob/d87e80a2775413ee65f40943bbb65057e4c41976/LICENSE). Copyright: Microsoft Corporation)
34+
- [AKRecorder](https://github.com/shoda888/AKRecorder)
35+
([MIT License](https://github.com/shoda888/AKRecorder/blob/d5cbe673474b2559640fe4f9cfec40a2eac9693e/LICENSE.txt). Copyright: KoheiShoda)
+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.7.34009.444
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "kinectSimpleBodyTrackingCSVRecorder", "kinectSimpleBodyTrackingCSVRecorder\kinectSimpleBodyTrackingCSVRecorder.csproj", "{8260C8A0-90F2-4C3B-9059-22BC06534CCF}"
7+
EndProject
8+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ソリューション項目", "ソリューション項目", "{F6CC715A-BC89-42AC-AC14-21838850A032}"
9+
ProjectSection(SolutionItems) = preProject
10+
LICENSE.txt = LICENSE.txt
11+
README.md = README.md
12+
EndProjectSection
13+
EndProject
14+
Global
15+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
16+
Debug|Any CPU = Debug|Any CPU
17+
Debug|x64 = Debug|x64
18+
Release|Any CPU = Release|Any CPU
19+
Release|x64 = Release|x64
20+
EndGlobalSection
21+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
22+
{8260C8A0-90F2-4C3B-9059-22BC06534CCF}.Debug|Any CPU.ActiveCfg = Debug|x64
23+
{8260C8A0-90F2-4C3B-9059-22BC06534CCF}.Debug|x64.ActiveCfg = Release|x64
24+
{8260C8A0-90F2-4C3B-9059-22BC06534CCF}.Debug|x64.Build.0 = Release|x64
25+
{8260C8A0-90F2-4C3B-9059-22BC06534CCF}.Release|Any CPU.ActiveCfg = Release|x64
26+
{8260C8A0-90F2-4C3B-9059-22BC06534CCF}.Release|x64.ActiveCfg = Release|x64
27+
{8260C8A0-90F2-4C3B-9059-22BC06534CCF}.Release|x64.Build.0 = Release|x64
28+
EndGlobalSection
29+
GlobalSection(SolutionProperties) = preSolution
30+
HideSolutionNode = FALSE
31+
EndGlobalSection
32+
GlobalSection(ExtensibilityGlobals) = postSolution
33+
SolutionGuid = {D65781F9-DE21-4263-8AD6-2A1F0227D695}
34+
EndGlobalSection
35+
EndGlobal
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
using Microsoft.Azure.Kinect.BodyTracking;
2+
using Microsoft.Azure.Kinect.Sensor;
3+
4+
//get current directry
5+
string currentDirectory = Directory.GetCurrentDirectory();
6+
// create a pos data file in the current directry.
7+
string fileName = $@"{currentDirectory}\{DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss")}_posdata.csv";
8+
9+
// capture and write pos data
10+
using (StreamWriter sw = new StreamWriter(fileName, true))
11+
{
12+
// Open device.
13+
using (Device device = Device.Open())
14+
{
15+
device.StartCameras(new DeviceConfiguration()
16+
{
17+
ColorFormat = ImageFormat.ColorBGRA32,
18+
ColorResolution = ColorResolution.R720p,
19+
DepthMode = DepthMode.NFOV_Unbinned,
20+
SynchronizedImagesOnly = true,
21+
WiredSyncMode = WiredSyncMode.Standalone,
22+
CameraFPS = FPS.FPS30
23+
});
24+
25+
26+
27+
// Camera calibration.
28+
var deviceCalibration = device.GetCalibration();
29+
var transformation = deviceCalibration.CreateTransformation();
30+
31+
using (Tracker tracker = Tracker.Create(deviceCalibration, new TrackerConfiguration() { ProcessingMode = TrackerProcessingMode.Gpu, SensorOrientation = SensorOrientation.Default }))
32+
{
33+
var isActive = true;
34+
Console.CancelKeyPress += (s, e) =>
35+
{
36+
e.Cancel = true;
37+
isActive = false;
38+
};
39+
Console.WriteLine("Start Recording. Press Ctrl+C to stop.");
40+
41+
while (isActive)
42+
{
43+
using (Capture sensorCapture = device.GetCapture())
44+
{
45+
// Queue latest frame from the sensor.
46+
tracker.EnqueueCapture(sensorCapture);
47+
}
48+
49+
// Try getting latest tracker frame.
50+
using (Frame frame = tracker.PopResult(TimeSpan.Zero, throwOnTimeout: false))
51+
{
52+
if (frame != null)
53+
{
54+
// is Human?
55+
if (frame.NumberOfBodies > 0)
56+
{
57+
Console.Write("\r" + new string(' ', Console.WindowWidth));
58+
Console.Write("\rIs there person: ");
59+
Console.ForegroundColor = ConsoleColor.Green;
60+
Console.Write("Yes");
61+
62+
// get body
63+
var skeleton = frame.GetBodySkeleton(0);
64+
65+
float[] posData = new float[(int)JointId.Count * 3];
66+
for (int i = 0; i < (int)JointId.Count; i++)
67+
{
68+
var joint = skeleton.GetJoint((JointId)i);
69+
posData[i * 3] = joint.Position.X;
70+
posData[i * 3 + 1] = joint.Position.Y;
71+
posData[i * 3 + 2] = joint.Position.Z;
72+
}
73+
74+
// write pos data to file
75+
sw.WriteLine(string.Join(",", posData));
76+
} else
77+
{
78+
Console.Write("\r" + new string(' ', Console.WindowWidth));
79+
Console.Write("\rIs there person: ");
80+
Console.ForegroundColor = ConsoleColor.Red;
81+
Console.Write("No Person");
82+
}
83+
84+
Console.ResetColor();
85+
}
86+
}
87+
}
88+
}
89+
Console.Write("\r" + new string(' ', Console.WindowWidth));
90+
Console.WriteLine("\rStop Recording.");
91+
}
92+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project Sdk="Microsoft.NET.Sdk">
3+
4+
<PropertyGroup>
5+
<OutputType>Exe</OutputType>
6+
<TargetFramework>net6.0-windows</TargetFramework>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>disable</Nullable>
9+
<Platforms>x64</Platforms>
10+
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
11+
</PropertyGroup>
12+
13+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
14+
<DebugType>none</DebugType>
15+
</PropertyGroup>
16+
17+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
18+
<DebugType>none</DebugType>
19+
</PropertyGroup>
20+
21+
<ItemGroup>
22+
<PackageReference Include="Microsoft.Azure.Kinect.BodyTracking" Version="1.1.2" />
23+
</ItemGroup>
24+
25+
</Project>

0 commit comments

Comments
 (0)