├── .gitignore
├── HoloLab.AzureKinect
├── HoloLab.AzureKinect.Test
│ ├── HoloLab.AzureKinect.Test.csproj
│ └── KinectSensorTest.cs
├── HoloLab.AzureKinect.TestApp
│ ├── HoloLab.AzureKinect.TestApp.csproj
│ └── Program.cs
├── HoloLab.AzureKinect.sln
└── HoloLab.AzureKinect
│ ├── AzureKinectException.cs
│ ├── Capture.cs
│ ├── HoloLab.AzureKinect.csproj
│ ├── Image.cs
│ ├── KinectSensor.cs
│ ├── NativeMethod
│ ├── K4A.cs
│ ├── Playback.cs
│ ├── Record.cs
│ └── k4atypes.cs
│ └── enum
│ ├── ColorResolution.cs
│ ├── DepthMode.cs
│ ├── DeviceConfiguration.cs
│ ├── Fps.cs
│ ├── ImageFormat.cs
│ └── WiredSyncMode.cs
├── LICENSE
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.suo
8 | *.user
9 | *.userosscache
10 | *.sln.docstates
11 |
12 | # User-specific files (MonoDevelop/Xamarin Studio)
13 | *.userprefs
14 |
15 | # Build results
16 | [Dd]ebug/
17 | [Dd]ebugPublic/
18 | [Rr]elease/
19 | [Rr]eleases/
20 | x64/
21 | x86/
22 | bld/
23 | [Bb]in/
24 | [Oo]bj/
25 | [Ll]og/
26 |
27 | # Visual Studio 2015/2017 cache/options directory
28 | .vs/
29 | # Uncomment if you have tasks that create the project's static files in wwwroot
30 | #wwwroot/
31 |
32 | # Visual Studio 2017 auto generated files
33 | Generated\ Files/
34 |
35 | # MSTest test Results
36 | [Tt]est[Rr]esult*/
37 | [Bb]uild[Ll]og.*
38 |
39 | # NUNIT
40 | *.VisualState.xml
41 | TestResult.xml
42 |
43 | # Build Results of an ATL Project
44 | [Dd]ebugPS/
45 | [Rr]eleasePS/
46 | dlldata.c
47 |
48 | # Benchmark Results
49 | BenchmarkDotNet.Artifacts/
50 |
51 | # .NET Core
52 | project.lock.json
53 | project.fragment.lock.json
54 | artifacts/
55 | **/Properties/launchSettings.json
56 |
57 | # StyleCop
58 | StyleCopReport.xml
59 |
60 | # Files built by Visual Studio
61 | *_i.c
62 | *_p.c
63 | *_i.h
64 | *.ilk
65 | *.meta
66 | *.obj
67 | *.iobj
68 | *.pch
69 | *.pdb
70 | *.ipdb
71 | *.pgc
72 | *.pgd
73 | *.rsp
74 | *.sbr
75 | *.tlb
76 | *.tli
77 | *.tlh
78 | *.tmp
79 | *.tmp_proj
80 | *.log
81 | *.vspscc
82 | *.vssscc
83 | .builds
84 | *.pidb
85 | *.svclog
86 | *.scc
87 |
88 | # Chutzpah Test files
89 | _Chutzpah*
90 |
91 | # Visual C++ cache files
92 | ipch/
93 | *.aps
94 | *.ncb
95 | *.opendb
96 | *.opensdf
97 | *.sdf
98 | *.cachefile
99 | *.VC.db
100 | *.VC.VC.opendb
101 |
102 | # Visual Studio profiler
103 | *.psess
104 | *.vsp
105 | *.vspx
106 | *.sap
107 |
108 | # Visual Studio Trace Files
109 | *.e2e
110 |
111 | # TFS 2012 Local Workspace
112 | $tf/
113 |
114 | # Guidance Automation Toolkit
115 | *.gpState
116 |
117 | # ReSharper is a .NET coding add-in
118 | _ReSharper*/
119 | *.[Rr]e[Ss]harper
120 | *.DotSettings.user
121 |
122 | # JustCode is a .NET coding add-in
123 | .JustCode
124 |
125 | # TeamCity is a build add-in
126 | _TeamCity*
127 |
128 | # DotCover is a Code Coverage Tool
129 | *.dotCover
130 |
131 | # AxoCover is a Code Coverage Tool
132 | .axoCover/*
133 | !.axoCover/settings.json
134 |
135 | # Visual Studio code coverage results
136 | *.coverage
137 | *.coveragexml
138 |
139 | # NCrunch
140 | _NCrunch_*
141 | .*crunch*.local.xml
142 | nCrunchTemp_*
143 |
144 | # MightyMoose
145 | *.mm.*
146 | AutoTest.Net/
147 |
148 | # Web workbench (sass)
149 | .sass-cache/
150 |
151 | # Installshield output folder
152 | [Ee]xpress/
153 |
154 | # DocProject is a documentation generator add-in
155 | DocProject/buildhelp/
156 | DocProject/Help/*.HxT
157 | DocProject/Help/*.HxC
158 | DocProject/Help/*.hhc
159 | DocProject/Help/*.hhk
160 | DocProject/Help/*.hhp
161 | DocProject/Help/Html2
162 | DocProject/Help/html
163 |
164 | # Click-Once directory
165 | publish/
166 |
167 | # Publish Web Output
168 | *.[Pp]ublish.xml
169 | *.azurePubxml
170 | # Note: Comment the next line if you want to checkin your web deploy settings,
171 | # but database connection strings (with potential passwords) will be unencrypted
172 | *.pubxml
173 | *.publishproj
174 |
175 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
176 | # checkin your Azure Web App publish settings, but sensitive information contained
177 | # in these scripts will be unencrypted
178 | PublishScripts/
179 |
180 | # NuGet Packages
181 | *.nupkg
182 | # The packages folder can be ignored because of Package Restore
183 | **/[Pp]ackages/*
184 | # except build/, which is used as an MSBuild target.
185 | !**/[Pp]ackages/build/
186 | # Uncomment if necessary however generally it will be regenerated when needed
187 | #!**/[Pp]ackages/repositories.config
188 | # NuGet v3's project.json files produces more ignorable files
189 | *.nuget.props
190 | *.nuget.targets
191 |
192 | # Microsoft Azure Build Output
193 | csx/
194 | *.build.csdef
195 |
196 | # Microsoft Azure Emulator
197 | ecf/
198 | rcf/
199 |
200 | # Windows Store app package directories and files
201 | AppPackages/
202 | BundleArtifacts/
203 | Package.StoreAssociation.xml
204 | _pkginfo.txt
205 | *.appx
206 |
207 | # Visual Studio cache files
208 | # files ending in .cache can be ignored
209 | *.[Cc]ache
210 | # but keep track of directories ending in .cache
211 | !*.[Cc]ache/
212 |
213 | # Others
214 | ClientBin/
215 | ~$*
216 | *~
217 | *.dbmdl
218 | *.dbproj.schemaview
219 | *.jfm
220 | *.pfx
221 | *.publishsettings
222 | orleans.codegen.cs
223 |
224 | # Including strong name files can present a security risk
225 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
226 | #*.snk
227 |
228 | # Since there are multiple workflows, uncomment next line to ignore bower_components
229 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
230 | #bower_components/
231 |
232 | # RIA/Silverlight projects
233 | Generated_Code/
234 |
235 | # Backup & report files from converting an old project file
236 | # to a newer Visual Studio version. Backup files are not needed,
237 | # because we have git ;-)
238 | _UpgradeReport_Files/
239 | Backup*/
240 | UpgradeLog*.XML
241 | UpgradeLog*.htm
242 | ServiceFabricBackup/
243 | *.rptproj.bak
244 |
245 | # SQL Server files
246 | *.mdf
247 | *.ldf
248 | *.ndf
249 |
250 | # Business Intelligence projects
251 | *.rdl.data
252 | *.bim.layout
253 | *.bim_*.settings
254 | *.rptproj.rsuser
255 |
256 | # Microsoft Fakes
257 | FakesAssemblies/
258 |
259 | # GhostDoc plugin setting file
260 | *.GhostDoc.xml
261 |
262 | # Node.js Tools for Visual Studio
263 | .ntvs_analysis.dat
264 | node_modules/
265 |
266 | # Visual Studio 6 build log
267 | *.plg
268 |
269 | # Visual Studio 6 workspace options file
270 | *.opt
271 |
272 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
273 | *.vbw
274 |
275 | # Visual Studio LightSwitch build output
276 | **/*.HTMLClient/GeneratedArtifacts
277 | **/*.DesktopClient/GeneratedArtifacts
278 | **/*.DesktopClient/ModelManifest.xml
279 | **/*.Server/GeneratedArtifacts
280 | **/*.Server/ModelManifest.xml
281 | _Pvt_Extensions
282 |
283 | # Paket dependency manager
284 | .paket/paket.exe
285 | paket-files/
286 |
287 | # FAKE - F# Make
288 | .fake/
289 |
290 | # JetBrains Rider
291 | .idea/
292 | *.sln.iml
293 |
294 | # CodeRush
295 | .cr/
296 |
297 | # Python Tools for Visual Studio (PTVS)
298 | __pycache__/
299 | *.pyc
300 |
301 | # Cake - Uncomment if you are using it
302 | # tools/**
303 | # !tools/packages.config
304 |
305 | # Tabs Studio
306 | *.tss
307 |
308 | # Telerik's JustMock configuration file
309 | *.jmconfig
310 |
311 | # BizTalk build output
312 | *.btp.cs
313 | *.btm.cs
314 | *.odx.cs
315 | *.xsd.cs
316 |
317 | # OpenCover UI analysis results
318 | OpenCover/
319 |
320 | # Azure Stream Analytics local run output
321 | ASALocalRun/
322 |
323 | # MSBuild Binary and Structured Log
324 | *.binlog
325 |
326 | # NVidia Nsight GPU debugger configuration file
327 | *.nvuser
328 |
329 | # MFractors (Xamarin productivity tool) working folder
330 | .mfractor/
331 |
--------------------------------------------------------------------------------
/HoloLab.AzureKinect/HoloLab.AzureKinect.Test/HoloLab.AzureKinect.Test.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp2.1
5 |
6 | false
7 |
8 | AnyCPU;x64
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/HoloLab.AzureKinect/HoloLab.AzureKinect.Test/KinectSensorTest.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HoloLabInc/AzureKinectSharp/76e35ec8e1bc34d83b72e86c9fd89ca798cda2df/HoloLab.AzureKinect/HoloLab.AzureKinect.Test/KinectSensorTest.cs
--------------------------------------------------------------------------------
/HoloLab.AzureKinect/HoloLab.AzureKinect.TestApp/HoloLab.AzureKinect.TestApp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp2.1
6 | AnyCPU;x64
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/HoloLab.AzureKinect/HoloLab.AzureKinect.TestApp/Program.cs:
--------------------------------------------------------------------------------
1 | // Copyright(c) 2019 HoloLab Inc.
2 | // This software is released under the MIT License.
3 | // http://opensource.org/licenses/mit-license.php
4 |
5 | using HoloLab.AzureKinect.NativeMethod;
6 | using System;
7 |
8 | namespace HoloLab.AzureKinect.TestApp
9 | {
10 | class Program
11 | {
12 | static void Main(string[] args)
13 | {
14 | try
15 | {
16 | Console.WriteLine($"Device Count : {K4A.k4a_device_get_installed_count()}");
17 | Console.WriteLine($"Device Count : {KinectSensor.SensorCount}");
18 | }
19 | catch (Exception ex)
20 | {
21 | Console.WriteLine(ex.Message);
22 | }
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/HoloLab.AzureKinect/HoloLab.AzureKinect.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.29123.88
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HoloLab.AzureKinect", "HoloLab.AzureKinect\HoloLab.AzureKinect.csproj", "{557897CE-24C0-4BCE-9488-990E56415533}"
7 | EndProject
8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HoloLab.AzureKinect.Test", "HoloLab.AzureKinect.Test\HoloLab.AzureKinect.Test.csproj", "{9F8B85BE-0288-4B52-A612-F30E79293318}"
9 | EndProject
10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HoloLab.AzureKinect.TestApp", "HoloLab.AzureKinect.TestApp\HoloLab.AzureKinect.TestApp.csproj", "{E21CA4A6-E6DA-4253-BDB9-748C448968C3}"
11 | EndProject
12 | Global
13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
14 | Debug|Any CPU = Debug|Any CPU
15 | Debug|x64 = Debug|x64
16 | Release|Any CPU = Release|Any CPU
17 | Release|x64 = Release|x64
18 | EndGlobalSection
19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
20 | {557897CE-24C0-4BCE-9488-990E56415533}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {557897CE-24C0-4BCE-9488-990E56415533}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {557897CE-24C0-4BCE-9488-990E56415533}.Debug|x64.ActiveCfg = Debug|x64
23 | {557897CE-24C0-4BCE-9488-990E56415533}.Debug|x64.Build.0 = Debug|x64
24 | {557897CE-24C0-4BCE-9488-990E56415533}.Release|Any CPU.ActiveCfg = Release|Any CPU
25 | {557897CE-24C0-4BCE-9488-990E56415533}.Release|Any CPU.Build.0 = Release|Any CPU
26 | {557897CE-24C0-4BCE-9488-990E56415533}.Release|x64.ActiveCfg = Release|x64
27 | {557897CE-24C0-4BCE-9488-990E56415533}.Release|x64.Build.0 = Release|x64
28 | {9F8B85BE-0288-4B52-A612-F30E79293318}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
29 | {9F8B85BE-0288-4B52-A612-F30E79293318}.Debug|Any CPU.Build.0 = Debug|Any CPU
30 | {9F8B85BE-0288-4B52-A612-F30E79293318}.Debug|x64.ActiveCfg = Debug|x64
31 | {9F8B85BE-0288-4B52-A612-F30E79293318}.Debug|x64.Build.0 = Debug|x64
32 | {9F8B85BE-0288-4B52-A612-F30E79293318}.Release|Any CPU.ActiveCfg = Release|Any CPU
33 | {9F8B85BE-0288-4B52-A612-F30E79293318}.Release|Any CPU.Build.0 = Release|Any CPU
34 | {9F8B85BE-0288-4B52-A612-F30E79293318}.Release|x64.ActiveCfg = Release|x64
35 | {9F8B85BE-0288-4B52-A612-F30E79293318}.Release|x64.Build.0 = Release|x64
36 | {E21CA4A6-E6DA-4253-BDB9-748C448968C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
37 | {E21CA4A6-E6DA-4253-BDB9-748C448968C3}.Debug|Any CPU.Build.0 = Debug|Any CPU
38 | {E21CA4A6-E6DA-4253-BDB9-748C448968C3}.Debug|x64.ActiveCfg = Debug|x64
39 | {E21CA4A6-E6DA-4253-BDB9-748C448968C3}.Debug|x64.Build.0 = Debug|x64
40 | {E21CA4A6-E6DA-4253-BDB9-748C448968C3}.Release|Any CPU.ActiveCfg = Release|Any CPU
41 | {E21CA4A6-E6DA-4253-BDB9-748C448968C3}.Release|Any CPU.Build.0 = Release|Any CPU
42 | {E21CA4A6-E6DA-4253-BDB9-748C448968C3}.Release|x64.ActiveCfg = Release|x64
43 | {E21CA4A6-E6DA-4253-BDB9-748C448968C3}.Release|x64.Build.0 = Release|x64
44 | EndGlobalSection
45 | GlobalSection(SolutionProperties) = preSolution
46 | HideSolutionNode = FALSE
47 | EndGlobalSection
48 | GlobalSection(ExtensibilityGlobals) = postSolution
49 | SolutionGuid = {C613A72F-3A53-4631-828D-A7E882A88B2A}
50 | EndGlobalSection
51 | EndGlobal
52 |
--------------------------------------------------------------------------------
/HoloLab.AzureKinect/HoloLab.AzureKinect/AzureKinectException.cs:
--------------------------------------------------------------------------------
1 | // Copyright(c) 2019 HoloLab Inc.
2 | // This software is released under the MIT License.
3 | // http://opensource.org/licenses/mit-license.php
4 |
5 | using HoloLab.AzureKinect.NativeMethod;
6 | using System;
7 | using System.Collections.Generic;
8 | using System.Text;
9 |
10 | namespace HoloLab.AzureKinect
11 | {
12 | public class AzureKinectException : Exception
13 | {
14 | k4a_result_t result;
15 |
16 | public AzureKinectException(k4a_result_t result)
17 | {
18 | this.result = result;
19 | }
20 |
21 | public AzureKinectException(string message)
22 | :base(message)
23 | {
24 | }
25 |
26 | public override string Message => result.ToString();
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/HoloLab.AzureKinect/HoloLab.AzureKinect/Capture.cs:
--------------------------------------------------------------------------------
1 | using HoloLab.AzureKinect.NativeMethod;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 |
6 | namespace HoloLab.AzureKinect
7 | {
8 | public class Capture : IDisposable
9 | {
10 | IntPtr capture_handle = IntPtr.Zero;
11 |
12 | public Capture(KinectSensor sensor, Int32 timeout)
13 | {
14 | var ret = Open(sensor, timeout);
15 | if (!ret)
16 | {
17 | throw new AzureKinectException(k4a_wait_result_t.K4A_WAIT_RESULT_TIMEOUT.ToString());
18 | }
19 | }
20 |
21 | public bool Open( KinectSensor sensor, Int32 timeout )
22 | {
23 | var ret = K4A.k4a_device_get_capture(sensor.device_handle, out capture_handle, timeout);
24 | if (ret != k4a_wait_result_t.K4A_WAIT_RESULT_FAILED)
25 | {
26 | throw new AzureKinectException(ret.ToString());
27 | }
28 | else if (ret == k4a_wait_result_t.K4A_WAIT_RESULT_TIMEOUT)
29 | {
30 | return false;
31 | }
32 |
33 | return true;
34 | }
35 |
36 | public void Close()
37 | {
38 | if (capture_handle != IntPtr.Zero)
39 | {
40 | K4A.k4a_capture_release(capture_handle);
41 | capture_handle = IntPtr.Zero;
42 | }
43 | }
44 |
45 | public Image GetColorImage()
46 | {
47 | return new Image(K4A.k4a_capture_get_color_image(capture_handle));
48 | }
49 |
50 | #region IDisposable Support
51 | private bool disposedValue = false; // 重複する呼び出しを検出するには
52 |
53 | protected virtual void Dispose(bool disposing)
54 | {
55 | if (!disposedValue)
56 | {
57 | if (disposing)
58 | {
59 | // TODO: マネージ状態を破棄します (マネージ オブジェクト)。
60 | }
61 |
62 | // TODO: アンマネージ リソース (アンマネージ オブジェクト) を解放し、下のファイナライザーをオーバーライドします。
63 | // TODO: 大きなフィールドを null に設定します。
64 | Close();
65 |
66 | disposedValue = true;
67 | }
68 | }
69 |
70 | // TODO: 上の Dispose(bool disposing) にアンマネージ リソースを解放するコードが含まれる場合にのみ、ファイナライザーをオーバーライドします。
71 | // ~Capture()
72 | // {
73 | // // このコードを変更しないでください。クリーンアップ コードを上の Dispose(bool disposing) に記述します。
74 | // Dispose(false);
75 | // }
76 |
77 | // このコードは、破棄可能なパターンを正しく実装できるように追加されました。
78 | public void Dispose()
79 | {
80 | // このコードを変更しないでください。クリーンアップ コードを上の Dispose(bool disposing) に記述します。
81 | Dispose(true);
82 | // TODO: 上のファイナライザーがオーバーライドされる場合は、次の行のコメントを解除してください。
83 | // GC.SuppressFinalize(this);
84 | }
85 | #endregion
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/HoloLab.AzureKinect/HoloLab.AzureKinect/HoloLab.AzureKinect.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp2.1
5 | AnyCPU;x64
6 | HoloLab Inc.
7 | false
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/HoloLab.AzureKinect/HoloLab.AzureKinect/Image.cs:
--------------------------------------------------------------------------------
1 | using HoloLab.AzureKinect.NativeMethod;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 |
6 | namespace HoloLab.AzureKinect
7 | {
8 | public class Image : IDisposable
9 | {
10 | IntPtr image_handle = IntPtr.Zero;
11 |
12 | internal Image(IntPtr image_handle)
13 | {
14 | this.image_handle = image_handle;
15 | }
16 |
17 | void Close()
18 | {
19 | if (image_handle != IntPtr.Zero)
20 | {
21 | K4A.k4a_image_release(image_handle);
22 | image_handle = IntPtr.Zero;
23 | }
24 | }
25 |
26 | IntPtr getBuffer()
27 | {
28 | return K4A.k4a_image_get_buffer(image_handle);
29 | }
30 |
31 | UInt64 getSize()
32 | {
33 | return K4A.k4a_image_get_size(image_handle);
34 | }
35 |
36 | ImageFormat getFormat()
37 | {
38 | return (ImageFormat)K4A.k4a_image_get_format(image_handle);
39 | }
40 |
41 | int getWidth()
42 | {
43 | return K4A.k4a_image_get_width_pixels(image_handle);
44 | }
45 |
46 | int getHeight()
47 | {
48 | return K4A.k4a_image_get_height_pixels(image_handle);
49 | }
50 |
51 | int getStride()
52 | {
53 | return K4A.k4a_image_get_stride_bytes(image_handle);
54 | }
55 |
56 | UInt64 getTimestamp()
57 | {
58 | return K4A.k4a_image_get_timestamp_usec(image_handle);
59 | }
60 |
61 | #region IDisposable Support
62 | private bool disposedValue = false; // 重複する呼び出しを検出するには
63 |
64 | protected virtual void Dispose(bool disposing)
65 | {
66 | if (!disposedValue)
67 | {
68 | if (disposing)
69 | {
70 | // TODO: マネージ状態を破棄します (マネージ オブジェクト)。
71 | }
72 |
73 | // TODO: アンマネージ リソース (アンマネージ オブジェクト) を解放し、下のファイナライザーをオーバーライドします。
74 | // TODO: 大きなフィールドを null に設定します。
75 | Close();
76 |
77 | disposedValue = true;
78 | }
79 | }
80 |
81 | // TODO: 上の Dispose(bool disposing) にアンマネージ リソースを解放するコードが含まれる場合にのみ、ファイナライザーをオーバーライドします。
82 | // ~Image()
83 | // {
84 | // // このコードを変更しないでください。クリーンアップ コードを上の Dispose(bool disposing) に記述します。
85 | // Dispose(false);
86 | // }
87 |
88 | // このコードは、破棄可能なパターンを正しく実装できるように追加されました。
89 | public void Dispose()
90 | {
91 | // このコードを変更しないでください。クリーンアップ コードを上の Dispose(bool disposing) に記述します。
92 | Dispose(true);
93 | // TODO: 上のファイナライザーがオーバーライドされる場合は、次の行のコメントを解除してください。
94 | // GC.SuppressFinalize(this);
95 | }
96 | #endregion
97 |
98 |
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/HoloLab.AzureKinect/HoloLab.AzureKinect/KinectSensor.cs:
--------------------------------------------------------------------------------
1 | // Copyright(c) 2019 HoloLab Inc.
2 | // This software is released under the MIT License.
3 | // http://opensource.org/licenses/mit-license.php
4 |
5 | using HoloLab.AzureKinect.NativeMethod;
6 | using System;
7 | using System.Collections.Generic;
8 | using System.Runtime.InteropServices;
9 | using System.Text;
10 |
11 | namespace HoloLab.AzureKinect
12 | {
13 | public class KinectSensor : IDisposable
14 | {
15 | internal IntPtr device_handle = IntPtr.Zero;
16 | string serialNumber = string.Empty;
17 |
18 | public static uint SensorCount => K4A.k4a_device_get_installed_count();
19 |
20 | public bool IsOpened => device_handle != IntPtr.Zero;
21 |
22 | ///
23 | /// 最初のKinectセンサーを開く
24 | ///
25 | public void Open()
26 | {
27 | Open(0);
28 | }
29 |
30 | ///
31 | /// 指定されたインデックスのKinectセンサーを開く
32 | ///
33 | ///
34 | public void Open(UInt32 index)
35 | {
36 | Close();
37 |
38 | var ret = K4A.k4a_device_open(index, out device_handle);
39 | if (ret != k4a_result_t.K4A_RESULT_SUCCEEDED)
40 | {
41 | throw new AzureKinectException(ret);
42 | }
43 | }
44 |
45 | ///
46 | /// Kinectセンサーを閉じる
47 | ///
48 | public void Close()
49 | {
50 | if (device_handle != IntPtr.Zero)
51 | {
52 | K4A.k4a_device_close(device_handle);
53 | device_handle = IntPtr.Zero;
54 | serialNumber = string.Empty;
55 | }
56 | }
57 |
58 | ///
59 | /// シリアルナンバーを取得する
60 | ///
61 | ///
62 | public string GetSerialNumber()
63 | {
64 | // 取得済みであれば、そのまま返す
65 | if (!string.IsNullOrEmpty(serialNumber))
66 | {
67 | return serialNumber;
68 | }
69 |
70 | // 第二引数のバッファをNULL(0)にすると、シリアルナンバーのバッファサイズが返る
71 | UInt64 size = 0;
72 | var ret = K4A.k4a_device_get_serialnum(device_handle, IntPtr.Zero, ref size);
73 | if (ret != k4a_buffer_result_t.K4A_BUFFER_RESULT_TOO_SMALL)
74 | {
75 | throw new AzureKinectException(ret.ToString());
76 | }
77 |
78 | // 実際にシリアルナンバーを取得する
79 | var buffer = Marshal.AllocHGlobal((int)size);
80 | try
81 | {
82 | ret = K4A.k4a_device_get_serialnum(device_handle, buffer, ref size);
83 | if (ret != k4a_buffer_result_t.K4A_BUFFER_RESULT_SUCCEEDED)
84 | {
85 | throw new AzureKinectException(ret.ToString());
86 | }
87 |
88 | var serial = new byte[size];
89 | Marshal.Copy(buffer, serial, 0, (int)size);
90 |
91 | // '\0'は抜く
92 | serialNumber = Encoding.ASCII.GetString(serial, 0, (int)size - 1);
93 | return serialNumber;
94 | }
95 | finally
96 | {
97 | Marshal.FreeHGlobal(buffer);
98 | }
99 | }
100 |
101 | ///
102 | /// カメラを起動する
103 | ///
104 | public void StartCamera(DeviceConfiguration config)
105 | {
106 | var ret = K4A.k4a_device_start_cameras(device_handle, ref config);
107 | if (ret != k4a_result_t.K4A_RESULT_SUCCEEDED)
108 | {
109 | throw new AzureKinectException(ret.ToString());
110 | }
111 | }
112 |
113 | ///
114 | /// カメラを停止する
115 | ///
116 | public void StopCamera()
117 | {
118 | K4A.k4a_device_stop_cameras(device_handle);
119 | }
120 |
121 | public Capture GetNextCapture(Int32 timeout = -1)
122 | {
123 | return new Capture(this, timeout);
124 | }
125 |
126 | #region IDisposable Support
127 | private bool disposedValue = false; // 重複する呼び出しを検出するには
128 |
129 | protected virtual void Dispose(bool disposing)
130 | {
131 | if (!disposedValue)
132 | {
133 | if (disposing)
134 | {
135 | // TODO: マネージ状態を破棄します (マネージ オブジェクト)。
136 | }
137 |
138 | // TODO: アンマネージ リソース (アンマネージ オブジェクト) を解放し、下のファイナライザーをオーバーライドします。
139 | // TODO: 大きなフィールドを null に設定します。
140 | Close();
141 |
142 | disposedValue = true;
143 | }
144 | }
145 |
146 | // TODO: 上の Dispose(bool disposing) にアンマネージ リソースを解放するコードが含まれる場合にのみ、ファイナライザーをオーバーライドします。
147 | // ~KinectSensor()
148 | // {
149 | // // このコードを変更しないでください。クリーンアップ コードを上の Dispose(bool disposing) に記述します。
150 | // Dispose(false);
151 | // }
152 |
153 | // このコードは、破棄可能なパターンを正しく実装できるように追加されました。
154 | public void Dispose()
155 | {
156 | // このコードを変更しないでください。クリーンアップ コードを上の Dispose(bool disposing) に記述します。
157 | Dispose(true);
158 | // TODO: 上のファイナライザーがオーバーライドされる場合は、次の行のコメントを解除してください。
159 | // GC.SuppressFinalize(this);
160 | }
161 | #endregion
162 | }
163 | }
164 |
--------------------------------------------------------------------------------
/HoloLab.AzureKinect/HoloLab.AzureKinect/NativeMethod/K4A.cs:
--------------------------------------------------------------------------------
1 | // Copyright(c) 2019 HoloLab Inc.
2 | // This software is released under the MIT License.
3 | // http://opensource.org/licenses/mit-license.php
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Runtime.InteropServices;
8 | using System.Text;
9 |
10 | namespace HoloLab.AzureKinect.NativeMethod
11 | {
12 | public class K4A
13 | {
14 | const string k4a = "k4a.dll";
15 |
16 | [DllImport(k4a)]
17 | public extern static UInt32 k4a_device_get_installed_count();
18 |
19 | [DllImport(k4a)]
20 | public extern static k4a_result_t k4a_device_open(UInt32 index, out IntPtr device_handle);
21 |
22 | [DllImport(k4a)]
23 | public extern static void k4a_device_close(IntPtr device_handle);
24 |
25 | [DllImport(k4a)]
26 | public extern static k4a_wait_result_t k4a_device_get_capture(IntPtr device_handle, out IntPtr capture_handle, Int32 timeout_in_ms);
27 |
28 | [DllImport(k4a)]
29 | public extern static k4a_wait_result_t k4a_device_get_imu_sample(IntPtr device_handle, out IntPtr imu_sample, Int32 timeout_in_ms);
30 |
31 | [DllImport(k4a)]
32 | public extern static k4a_result_t k4a_capture_create(out IntPtr capture_handle);
33 |
34 | [DllImport(k4a)]
35 | public extern static void k4a_capture_release(IntPtr capture_handle);
36 |
37 | [DllImport(k4a)]
38 | public extern static void k4a_capture_reference(IntPtr capture_handle);
39 |
40 | [DllImport(k4a)]
41 | public extern static IntPtr k4a_capture_get_color_image(IntPtr capture_handle);
42 |
43 | [DllImport(k4a)]
44 | public extern static IntPtr k4a_capture_get_depth_image(IntPtr capture_handle);
45 |
46 | [DllImport(k4a)]
47 | public extern static IntPtr k4a_capture_get_ir_image(IntPtr capture_handle);
48 |
49 | [DllImport(k4a)]
50 | public extern static void k4a_capture_set_color_image(IntPtr capture_handle, IntPtr image_handle);
51 |
52 | [DllImport(k4a)]
53 | public extern static void k4a_capture_set_depth_image(IntPtr capture_handle, IntPtr image_handle);
54 |
55 | [DllImport(k4a)]
56 | public extern static void k4a_capture_set_ir_image(IntPtr capture_handle, IntPtr image_handle);
57 |
58 | [DllImport(k4a)]
59 | public extern static void k4a_capture_set_temperature_c(IntPtr capture_handle, float temperature_c);
60 |
61 | [DllImport(k4a)]
62 | public extern static float k4a_capture_get_temperature_c(IntPtr capture_handle);
63 |
64 | [DllImport(k4a)]
65 | public extern static k4a_result_t k4a_image_create(k4a_image_format_t format, int width_pixels, int height_pixels, int stride_bytes, out IntPtr image_handle);
66 |
67 | [DllImport(k4a)]
68 | public extern static k4a_result_t k4a_image_create_from_buffer(k4a_image_format_t format, int width_pixels, int height_pixels, int stride_bytes,
69 | out IntPtr buffer, Int64 buffer_size, k4a_memory_destroy_cb_t buffer_release_cb, IntPtr buffer_release_cb_context, out IntPtr image_handle);
70 |
71 | [DllImport(k4a)]
72 | public extern static IntPtr k4a_image_get_buffer(IntPtr image_handle);
73 |
74 | [DllImport(k4a)]
75 | public extern static UInt64 k4a_image_get_size(IntPtr image_handle);
76 |
77 | [DllImport(k4a)]
78 | public extern static k4a_image_format_t k4a_image_get_format(IntPtr image_handle);
79 |
80 | [DllImport(k4a)]
81 | public extern static int k4a_image_get_width_pixels(IntPtr image_handle);
82 |
83 | [DllImport(k4a)]
84 | public extern static int k4a_image_get_height_pixels(IntPtr image_handle);
85 |
86 | [DllImport(k4a)]
87 | public extern static int k4a_image_get_stride_bytes(IntPtr image_handle);
88 |
89 | [DllImport(k4a)]
90 | public extern static UInt64 k4a_image_get_timestamp_usec(IntPtr image_handle);
91 |
92 | [DllImport(k4a)]
93 | public extern static UInt64 k4a_image_get_exposure_usec(IntPtr image_handle);
94 |
95 | [DllImport(k4a)]
96 | public extern static UInt32 k4a_image_get_white_balance(IntPtr image_handle);
97 |
98 | [DllImport(k4a)]
99 | public extern static UInt32 k4a_image_get_iso_speed(IntPtr image_handle);
100 |
101 | [DllImport(k4a)]
102 | public extern static void k4a_image_set_timestamp_usec(IntPtr image_handle, UInt64 timestamp_usec);
103 |
104 | [DllImport(k4a)]
105 | public extern static void k4a_image_set_exposure_time_usec(IntPtr image_handle, UInt64 exposure_usec);
106 |
107 | [DllImport(k4a)]
108 | public extern static void k4a_image_set_white_balance(IntPtr image_handle, UInt32 white_balance);
109 |
110 | [DllImport(k4a)]
111 | public extern static void k4a_image_set_iso_speed(IntPtr image_handle, UInt32 iso_speed);
112 |
113 | [DllImport(k4a)]
114 | public extern static void k4a_image_reference(IntPtr image_handle);
115 |
116 | [DllImport(k4a)]
117 | public extern static void k4a_image_release(IntPtr image_handle);
118 |
119 | [DllImport(k4a)]
120 | public extern static k4a_result_t k4a_device_start_cameras(IntPtr device_handle, ref DeviceConfiguration config);
121 |
122 | [DllImport(k4a)]
123 | public extern static void k4a_device_stop_cameras(IntPtr device_handle);
124 | // K4A_EXPORT k4a_result_t k4a_device_start_imu(k4a_device_t device_handle);
125 | // K4A_EXPORT void k4a_device_stop_imu(k4a_device_t device_handle);
126 |
127 | [DllImport(k4a)]
128 | public extern static k4a_buffer_result_t k4a_device_get_serialnum(IntPtr device_handle, IntPtr serial_number, ref UInt64 serial_number_size);
129 |
130 | // K4A_EXPORT k4a_result_t k4a_device_get_version(k4a_device_t device_handle, k4a_hardware_version_t* version);
131 | // K4A_EXPORT k4a_result_t k4a_device_get_color_control(k4a_device_t device_handle,
132 | // k4a_color_control_command_t command,
133 | // k4a_color_control_mode_t* mode,
134 | // int32_t* value);
135 | // K4A_EXPORT k4a_result_t k4a_device_set_color_control(k4a_device_t device_handle,
136 | // k4a_color_control_command_t command,
137 | // k4a_color_control_mode_t mode,
138 | // int32_t value);
139 | // K4A_EXPORT k4a_buffer_result_t k4a_device_get_raw_calibration(k4a_device_t device_handle,
140 | // uint8_t* data,
141 | // size_t* data_size);
142 | // K4A_EXPORT k4a_result_t k4a_device_get_calibration(k4a_device_t device_handle,
143 | // const k4a_depth_mode_t depth_mode,
144 | // const k4a_color_resolution_t color_resolution,
145 | // k4a_calibration_t *calibration);
146 | // K4A_EXPORT k4a_result_t k4a_device_get_sync_jack(k4a_device_t device_handle,
147 | // bool* sync_in_jack_connected,
148 | // bool* sync_out_jack_connected);
149 |
150 | // K4A_EXPORT k4a_result_t k4a_calibration_get_from_raw(char* raw_calibration,
151 | // size_t raw_calibration_size,
152 | // const k4a_depth_mode_t depth_mode,
153 | // const k4a_color_resolution_t color_resolution,
154 | // k4a_calibration_t *calibration);
155 | // K4A_EXPORT k4a_result_t k4a_calibration_3d_to_3d(const k4a_calibration_t* calibration,
156 | // const k4a_float3_t* source_point3d,
157 | // const k4a_calibration_type_t source_camera,
158 | // const k4a_calibration_type_t target_camera,
159 | // k4a_float3_t *target_point3d);
160 | //K4A_EXPORT k4a_result_t k4a_calibration_2d_to_3d(const k4a_calibration_t* calibration,
161 | // const k4a_float2_t* source_point2d,
162 | // const float source_depth,
163 | // const k4a_calibration_type_t source_camera,
164 | // const k4a_calibration_type_t target_camera,
165 | // k4a_float3_t *target_point3d,
166 | // int* valid);
167 | // K4A_EXPORT k4a_result_t k4a_calibration_3d_to_2d(const k4a_calibration_t* calibration,
168 | // const k4a_float3_t* source_point3d,
169 | // const k4a_calibration_type_t source_camera,
170 | // const k4a_calibration_type_t target_camera,
171 | // k4a_float2_t *target_point2d,
172 | // int* valid);
173 | // K4A_EXPORT k4a_result_t k4a_calibration_2d_to_2d(const k4a_calibration_t* calibration,
174 | // const k4a_float2_t* source_point2d,
175 | // const float source_depth,
176 | // const k4a_calibration_type_t source_camera,
177 | // const k4a_calibration_type_t target_camera,
178 | // k4a_float2_t *target_point2d,
179 | // int* valid);
180 | // K4A_EXPORT k4a_transformation_t k4a_transformation_create(const k4a_calibration_t* calibration);
181 | // K4A_EXPORT void k4a_transformation_destroy(k4a_transformation_t transformation_handle);
182 | // K4A_EXPORT k4a_result_t k4a_transformation_depth_image_to_color_camera(k4a_transformation_t transformation_handle,
183 | // const k4a_image_t depth_image,
184 | // k4a_image_t transformed_depth_image);
185 | //K4A_EXPORT k4a_result_t k4a_transformation_color_image_to_depth_camera(k4a_transformation_t transformation_handle,
186 | // const k4a_image_t depth_image,
187 | // const k4a_image_t color_image,
188 | // k4a_image_t transformed_color_image);
189 | //K4A_EXPORT k4a_result_t k4a_transformation_depth_image_to_point_cloud(k4a_transformation_t transformation_handle,
190 | // const k4a_image_t depth_image,
191 | // const k4a_calibration_type_t camera,
192 | // k4a_image_t xyz_image);
193 | }
194 | }
195 |
--------------------------------------------------------------------------------
/HoloLab.AzureKinect/HoloLab.AzureKinect/NativeMethod/Playback.cs:
--------------------------------------------------------------------------------
1 | // Copyright(c) 2019 HoloLab Inc.
2 | // This software is released under the MIT License.
3 | // http://opensource.org/licenses/mit-license.php
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Text;
8 |
9 | namespace HoloLab.AzureKinect.NativeMethod
10 | {
11 | class Playback
12 | {
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/HoloLab.AzureKinect/HoloLab.AzureKinect/NativeMethod/Record.cs:
--------------------------------------------------------------------------------
1 | // Copyright(c) 2019 HoloLab Inc.
2 | // This software is released under the MIT License.
3 | // http://opensource.org/licenses/mit-license.php
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Text;
8 |
9 | namespace HoloLab.AzureKinect.NativeMethod
10 | {
11 | class Record
12 | {
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/HoloLab.AzureKinect/HoloLab.AzureKinect/NativeMethod/k4atypes.cs:
--------------------------------------------------------------------------------
1 | // Copyright(c) 2019 HoloLab Inc.
2 | // This software is released under the MIT License.
3 | // http://opensource.org/licenses/mit-license.php
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Text;
8 |
9 | namespace HoloLab.AzureKinect.NativeMethod
10 | {
11 |
12 | public delegate void k4a_memory_destroy_cb_t(IntPtr buffer, IntPtr context);
13 |
14 |
15 | public enum k4a_result_t
16 | {
17 | K4A_RESULT_SUCCEEDED = 0, /**< The result was successful */
18 | K4A_RESULT_FAILED, /**< The result was a failure */
19 | }
20 |
21 | public enum k4a_wait_result_t
22 | {
23 | K4A_WAIT_RESULT_SUCCEEDED = 0, /**< The result was successful */
24 | K4A_WAIT_RESULT_FAILED, /**< The result was a failure */
25 | K4A_WAIT_RESULT_TIMEOUT, /**< The operation timed out */
26 | }
27 |
28 | public enum k4a_image_format_t
29 | {
30 | /** Color image type MJPG.
31 | *
32 | * \details
33 | * The buffer for each image is encoded as a JPEG and can be decoded by a JPEG decoder.
34 | *
35 | * \details
36 | * Because the image is compressed, the stride parameter for the \ref k4a_image_t is not applicable.
37 | *
38 | * \details
39 | * Each MJPG encoded image in a stream may be of differing size depending on the compression efficiency.
40 | */
41 | K4A_IMAGE_FORMAT_COLOR_MJPG = 0,
42 |
43 | /** Color image type NV12.
44 | *
45 | * \details
46 | * NV12 images separate the luminance and chroma data such that all the luminance is at the
47 | * beginning of the buffer, and the chroma lines follow immediately after.
48 | *
49 | * \details
50 | * Stride indicates the length of each line in bytes and should be used to determine the start location of each line
51 | * of the image in memory. Chroma has half as many lines of height and half the width in pixels of the luminance.
52 | * Each chroma line has the same width in bytes as a luminance line.
53 | */
54 | K4A_IMAGE_FORMAT_COLOR_NV12,
55 |
56 | /** Color image type YUY2.
57 | *
58 | * \details
59 | * YUY2 stores chroma and luminance data in interleaved pixels.
60 | *
61 | * \details
62 | * Stride indicates the length of each line in bytes and should be used to determine the start location of each
63 | * line of the image in memory.
64 | */
65 | K4A_IMAGE_FORMAT_COLOR_YUY2,
66 |
67 | /** Color image type BGRA32.
68 | *
69 | * \details
70 | * Each pixel of BGRA32 data is four bytes. The first three bytes represent Blue, Green,
71 | * and Red data. The fourth byte is the alpha channel and is unused in the Azure Kinect APIs.
72 | *
73 | * \details
74 | * Stride indicates the length of each line in bytes and should be used to determine the start location of each
75 | * line of the image in memory.
76 | *
77 | * \details
78 | * The Azure Kinect device does not natively capture in this format. Requesting images of this format
79 | * requires additional computation in the API.
80 | *
81 | */
82 | K4A_IMAGE_FORMAT_COLOR_BGRA32,
83 |
84 | /** Depth image type DEPTH16.
85 | *
86 | * \details
87 | * Each pixel of DEPTH16 data is two bytes of little endian unsigned depth data. The unit of the data is in
88 | * millimeters from the origin of the camera.
89 | *
90 | * \details
91 | * Stride indicates the length of each line in bytes and should be used to determine the start location of each
92 | * line of the image in memory.
93 | */
94 | K4A_IMAGE_FORMAT_DEPTH16,
95 |
96 | /** Image type IR16.
97 | *
98 | * \details
99 | * Each pixel of IR16 data is two bytes of little endian unsigned depth data. The value of the data represents
100 | * brightness.
101 | *
102 | * \details
103 | * This format represents infrared light and is captured by the depth camera.
104 | *
105 | * \details
106 | * Stride indicates the length of each line in bytes and should be used to determine the start location of each
107 | * line of the image in memory.
108 | */
109 | K4A_IMAGE_FORMAT_IR16,
110 |
111 | /** Custom image format.
112 | *
113 | * \details
114 | * Used in conjunction with user created images or images packing non-standard data.
115 | *
116 | * \details
117 | * See the originator of the custom formatted image for information on how to interpret the data.
118 | */
119 | K4A_IMAGE_FORMAT_CUSTOM,
120 | }
121 |
122 | public enum k4a_color_resolution_t
123 | {
124 | K4A_COLOR_RESOLUTION_OFF = 0, /**< Color camera will be turned off with this setting */
125 | K4A_COLOR_RESOLUTION_720P, /**< 1280 * 720 16:9 */
126 | K4A_COLOR_RESOLUTION_1080P, /**< 1920 * 1080 16:9 */
127 | K4A_COLOR_RESOLUTION_1440P, /**< 2560 * 1440 16:9 */
128 | K4A_COLOR_RESOLUTION_1536P, /**< 2048 * 1536 4:3 */
129 | K4A_COLOR_RESOLUTION_2160P, /**< 3840 * 2160 16:9 */
130 | K4A_COLOR_RESOLUTION_3072P, /**< 4096 * 3072 4:3 */
131 | }
132 |
133 | enum k4a_depth_mode_t
134 | {
135 | K4A_DEPTH_MODE_OFF = 0, /**< Depth sensor will be turned off with this setting. */
136 | K4A_DEPTH_MODE_NFOV_2X2BINNED, /**< Depth captured at 320x288. Passive IR is also captured at 320x288. */
137 | K4A_DEPTH_MODE_NFOV_UNBINNED, /**< Depth captured at 640x576. Passive IR is also captured at 640x576. */
138 | K4A_DEPTH_MODE_WFOV_2X2BINNED, /**< Depth captured at 512x512. Passive IR is also captured at 512x512. */
139 | K4A_DEPTH_MODE_WFOV_UNBINNED, /**< Depth captured at 1024x1024. Passive IR is also captured at 1024x1024. */
140 | K4A_DEPTH_MODE_PASSIVE_IR, /**< Passive IR only, captured at 1024x1024. */
141 | }
142 |
143 | enum k4a_fps_t
144 | {
145 | K4A_FRAMES_PER_SECOND_5 = 0, /**< 5 FPS */
146 | K4A_FRAMES_PER_SECOND_15, /**< 15 FPS */
147 | K4A_FRAMES_PER_SECOND_30, /**< 30 FPS */
148 | }
149 |
150 | enum k4a_wired_sync_mode_t
151 | {
152 | K4A_WIRED_SYNC_MODE_STANDALONE, /*< Neither 'Sync In' or 'Sync Out' connections are used. */
153 | K4A_WIRED_SYNC_MODE_MASTER, /*< The 'Sync Out' jack is enabled and synchronization data it driven out the
154 | connected wire.*/
155 | K4A_WIRED_SYNC_MODE_SUBORDINATE /*< The 'Sync In' jack is used for synchronization and 'Sync Out' is driven for the
156 | next device in the chain. 'Sync Out' is a mirror of 'Sync In' for this mode. */
157 | }
158 |
159 | public struct k4a_device_configuration_t
160 | {
161 | /** Image format to capture with the color camera.
162 | *
163 | * The color camera does not natively produce BGRA32 images.
164 | * Setting ::K4A_IMAGE_FORMAT_COLOR_BGRA32 for color_format will result in higher CPU utilization. */
165 | k4a_image_format_t color_format;
166 |
167 | /** Image resolution to capture with the color camera. */
168 | k4a_color_resolution_t color_resolution;
169 |
170 | /** Capture mode for the depth camera. */
171 | k4a_depth_mode_t depth_mode;
172 |
173 | /** Desired frame rate for the color and depth camera. */
174 | k4a_fps_t camera_fps;
175 |
176 | /** Only produce k4a_capture_t objects if they contain synchronized color and depth images.
177 | *
178 | * \details
179 | * This setting controls the behavior in which images are dropped when images are produced faster than they can be
180 | * read, or if there are errors in reading images from the device.
181 | *
182 | * \details
183 | * If set to true, \ref k4a_capture_t objects will only be produced with both color and depth images.
184 | * If set to false, \ref k4a_capture_t objects may be produced only a single image when the corresponding image is
185 | * dropped.
186 | *
187 | * \details
188 | * Setting this to false ensures that the caller receives all of the images received from the camera, regardless of
189 | * whether the corresponding images expected in the capture are available.
190 | *
191 | * \details
192 | * If either the color or depth camera are disabled, this setting has no effect.
193 | */
194 | bool synchronized_images_only;
195 |
196 | /**
197 | * Desired delay between the capture of the color image and the capture of the depth image.
198 | *
199 | * \details
200 | * A negative value indicates that the depth image should be captured before the color image.
201 | *
202 | * \details
203 | * Any value between negative and positive one capture period is valid.
204 | */
205 | Int32 depth_delay_off_color_usec;
206 |
207 | /** The external synchronization mode. */
208 | k4a_wired_sync_mode_t wired_sync_mode;
209 |
210 | /**
211 | * The external synchronization timing.
212 | *
213 | * If this camera is a subordinate, this sets the capture delay between the color camera capture and the external
214 | * input pulse. A setting of zero indicates that the master and subordinate color images should be aligned.
215 | *
216 | * This setting does not effect the 'Sync out' connection.
217 | *
218 | * This value must be positive and range from zero to one capture period.
219 | *
220 | * If this is not a subordinate, then this value is ignored. */
221 | UInt32 subordinate_delay_off_master_usec;
222 |
223 | /**
224 | * Streaming indicator automatically turns on when the color or depth camera's are in use.
225 | *
226 | * This setting disables that behavior and keeps the LED in an off state. */
227 | bool disable_streaming_indicator;
228 | }
229 | }
230 |
231 | public enum k4a_buffer_result_t
232 | {
233 | K4A_BUFFER_RESULT_SUCCEEDED = 0, /**< The result was successful */
234 | K4A_BUFFER_RESULT_FAILED, /**< The result was a failure */
235 | K4A_BUFFER_RESULT_TOO_SMALL, /**< The input buffer was too small */
236 | }
237 |
--------------------------------------------------------------------------------
/HoloLab.AzureKinect/HoloLab.AzureKinect/enum/ColorResolution.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace HoloLab.AzureKinect
6 | {
7 | public enum ColorResolution
8 | {
9 | OFF = 0,
10 | _720P,
11 | _1080P,
12 | _1440P,
13 | _1536P,
14 | _2160P,
15 | _3072P,
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/HoloLab.AzureKinect/HoloLab.AzureKinect/enum/DepthMode.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace HoloLab.AzureKinect
6 | {
7 | public enum DepthMode
8 | {
9 | OFF = 0,
10 | NarrowFOV_2x2_Binned, /**< Depth captured at 320x288. Passive IR is also captured at 320x288. */
11 | NarrowFOV_Unbinned, /**< Depth captured at 640x576. Passive IR is also captured at 640x576. */
12 | WideFOV_2x2_Binned, /**< Depth captured at 512x512. Passive IR is also captured at 512x512. */
13 | WideFOV_Unbinned, /**< Depth captured at 1024x1024. Passive IR is also captured at 1024x1024. */
14 | PassiveIr,
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/HoloLab.AzureKinect/HoloLab.AzureKinect/enum/DeviceConfiguration.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Runtime.InteropServices;
4 | using System.Text;
5 |
6 | namespace HoloLab.AzureKinect
7 | {
8 | [StructLayout(LayoutKind.Sequential, Pack = 1)]
9 | public struct DeviceConfiguration
10 | {
11 | [MarshalAs(UnmanagedType.I4)]
12 | public ImageFormat ColorFormat;
13 |
14 | [MarshalAs(UnmanagedType.I4)]
15 | public ColorResolution ColorResolution;
16 |
17 | [MarshalAs(UnmanagedType.I4)]
18 | public DepthMode DepthMode;
19 |
20 | [MarshalAs(UnmanagedType.I4)]
21 | public Fps CameraFps;
22 |
23 | [MarshalAs(UnmanagedType.U1)]
24 | public bool SynchronizedImagesOnly;
25 |
26 | [MarshalAs(UnmanagedType.I4)]
27 | public Int32 DepthDelayOffColorUsec;
28 |
29 | [MarshalAs(UnmanagedType.I4)]
30 | public WiredSyncMode WiredSyncMode;
31 |
32 | [MarshalAs(UnmanagedType.I4)]
33 | public UInt32 SubordinateDelayOffMasterUsec;
34 |
35 | [MarshalAs(UnmanagedType.U1)]
36 | public bool DisableStreamingIndicator;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/HoloLab.AzureKinect/HoloLab.AzureKinect/enum/Fps.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace HoloLab.AzureKinect
6 | {
7 | public enum Fps
8 | {
9 | _5 = 0,
10 | _15,
11 | _30,
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/HoloLab.AzureKinect/HoloLab.AzureKinect/enum/ImageFormat.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace HoloLab.AzureKinect
6 | {
7 | public enum ImageFormat
8 | {
9 | ColorMJPG = 0,
10 | ColorNV12,
11 | ColorYUY2,
12 | ColorBGRA32,
13 | Depth16,
14 | Ir16,
15 | Custom,
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/HoloLab.AzureKinect/HoloLab.AzureKinect/enum/WiredSyncMode.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace HoloLab.AzureKinect
6 | {
7 | public enum WiredSyncMode
8 | {
9 | Standalone,
10 | Master,
11 | Subordinate
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 HoloLab Inc.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # AzureKinectSharp
--------------------------------------------------------------------------------