Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
ButtonPusher
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Button Pusher
ButtonPusher
Commits
36e20b59
Commit
36e20b59
authored
Jan 07, 2018
by
16이상민
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change the class extraction method: Extract Module -> Extract Class
Complete tests for class 'SourceBuffer'
parent
c6acafe4
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
230 additions
and
147 deletions
+230
-147
SourceBufferTests.cs
Assets/Editor/SourceBufferTests.cs
+44
-10
KinectUnityAddin.dll.meta
Assets/Plugins/Metro/KinectUnityAddin.dll.meta
+74
-20
x86_64.meta
Assets/Plugins/x86_64.meta
+2
-1
KinectUnityAddin.dll.meta
Assets/Plugins/x86_64/KinectUnityAddin.dll.meta
+75
-84
CoordinateMapperManager.cs
Assets/Script/CoordinateMapperManager.cs
+31
-31
ProjectSettings.asset
ProjectSettings/ProjectSettings.asset
+4
-1
No files found.
Assets/Editor/SourceBufferTests.cs
View file @
36e20b59
using
UnityEngine
;
using
UnityEditor
;
using
UnityEngine.TestTools
;
using
UnityEngine.TestTools
;
using
NUnit.Framework
;
using
System.Collections
;
using
Windows.Kinect
;
...
...
@@ -8,10 +6,7 @@ using System.Runtime.InteropServices;
public
class
SourceBufferTests
{
const
int
DepthWidth
=
512
,
DepthHeight
=
424
,
ColorWidth
=
1920
,
ColorHeight
=
1080
;
SourceBuffer
_SourceBuffer
=
new
SourceBuffer
();
[
Test
]
public
void
SourceBufferTestsSimplePasses
()
...
...
@@ -34,9 +29,10 @@ public class SourceBufferTests
var
sourceFrame
=
sourceFrameReader
.
AcquireLatestFrame
();
SourceBuffer
.
UpdateBuffers
(
sourceFrame
);
_
SourceBuffer
.
UpdateBuffers
(
sourceFrame
);
ColorBufferTest
(
sourceFrame
);
BodyIndexBufferTest
(
sourceFrame
);
}
sensor
.
Close
();
...
...
@@ -44,7 +40,7 @@ public class SourceBufferTests
private
void
ColorBufferTest
(
MultiSourceFrame
sourceFrame
)
{
var
colorBuffer
=
new
byte
[
ColorWidth
*
ColorHeight
*
4
];
var
colorBuffer
=
new
byte
[
SourceBuffer
.
ColorWidth
*
SourceBuffer
.
ColorHeight
*
4
];
using
(
var
colorFrame
=
sourceFrame
.
ColorFrameReference
.
AcquireFrame
())
if
(
colorFrame
!=
null
)
{
...
...
@@ -53,7 +49,45 @@ public class SourceBufferTests
ColorData
.
Free
();
}
Assert
.
AreEqual
(
colorBuffer
,
SourceBuffer
.
ColorBuffer
,
"ColorBufferTest failed."
);
Assert
.
AreEqual
(
colorBuffer
,
_SourceBuffer
.
ColorBuffer
,
"ColorBufferTest failed."
);
}
private
void
BodyIndexBufferTest
(
MultiSourceFrame
sourceFrame
)
{
var
bodyIndexBuffer
=
new
byte
[
SourceBuffer
.
DepthWidth
*
SourceBuffer
.
DepthHeight
];
using
(
var
bodyIndexFrame
=
sourceFrame
.
BodyIndexFrameReference
.
AcquireFrame
())
if
(
bodyIndexFrame
!=
null
)
{
var
BodyIndexData
=
GCHandle
.
Alloc
(
bodyIndexBuffer
,
GCHandleType
.
Pinned
);
bodyIndexFrame
.
CopyFrameDataToIntPtr
(
BodyIndexData
.
AddrOfPinnedObject
(),
(
uint
)
bodyIndexBuffer
.
Length
);
BodyIndexData
.
Free
();
}
Assert
.
AreEqual
(
bodyIndexBuffer
,
_SourceBuffer
.
BodyIndexBuffer
,
"BodyIndexBufferTest failed."
);
}
private
void
UpdateDepthBuffer
(
MultiSourceFrame
sourceFrame
)
{
var
depthBuffer
=
new
ushort
[
SourceBuffer
.
DepthWidth
*
SourceBuffer
.
DepthHeight
];
using
(
var
depthFrame
=
sourceFrame
.
DepthFrameReference
.
AcquireFrame
())
if
(
depthFrame
!=
null
)
{
var
DepthData
=
GCHandle
.
Alloc
(
depthBuffer
,
GCHandleType
.
Pinned
);
depthFrame
.
CopyFrameDataToIntPtr
(
DepthData
.
AddrOfPinnedObject
(),
(
uint
)
depthBuffer
.
Length
*
sizeof
(
ushort
));
DepthData
.
Free
();
}
Assert
.
AreEqual
(
depthBuffer
,
_SourceBuffer
.
DepthBuffer
,
"DepthBufferTest failed."
);
}
private
void
UpdateBodyBuffer
(
MultiSourceFrame
sourceFrame
)
{
var
bodyBuffer
=
new
Body
[
SourceBuffer
.
BodyCount
];
using
(
var
bodyFrame
=
sourceFrame
.
BodyFrameReference
.
AcquireFrame
())
if
(
bodyFrame
!=
null
)
bodyFrame
.
GetAndRefreshBodyData
(
bodyBuffer
);
Assert
.
AreEqual
(
bodyBuffer
,
_SourceBuffer
.
BodyBuffer
,
"BodyBufferTest failed."
);
}
// A UnityTest behaves like a coroutine in PlayMode
...
...
Assets/Plugins/Metro/KinectUnityAddin.dll.meta
View file @
36e20b59
fileFormatVersion: 2
guid: 85bafbe9b14b18b45b445b304b1f3efc
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
isPreloaded: 0
isOverridable: 0
platformData:
data:
first:
Any:
second:
enabled: 0
settings: {}
data:
first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
data:
first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 1
settings:
CPU: x86
- first:
'': Any
second:
enabled: 0
settings:
Exclude Editor: 1
Exclude Linux: 1
Exclude Linux64: 1
Exclude LinuxUniversal: 1
Exclude OSXUniversal: 1
Exclude Win: 1
Exclude Win64: 1
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
- first:
Facebook: Win
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Facebook: Win64
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Standalone: Linux
second:
enabled: 0
settings:
CPU: x86
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: x86_64
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 1
settings:
CPU: x86
userData:
assetBundleName:
assetBundleVariant:
Assets/Plugins/x86_64.meta
View file @
36e20b59
fileFormatVersion: 2
guid: 40e0d3de9df769b42b6ae91ec22df21e
folderAsset: yes
timeCreated: 15
03553766
timeCreated: 15
15256762
licenseType: Free
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
Assets/Plugins/x86_64/KinectUnityAddin.dll.meta
View file @
36e20b59
fileFormatVersion: 2
guid: 82e143d16729051459ae6a54b37e9eab
timeCreated: 1515256762
licenseType: Free
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
isPreloaded: 0
isOverridable: 0
platformData:
data:
first:
Any:
second:
enabled: 1
settings: {}
data:
first:
Editor: Editor
second:
enabled: 0
settings:
CPU: x86_64
DefaultValueInitialized: true
data:
first:
Facebook: Win
second:
enabled: 0
settings:
CPU: None
data:
first:
Facebook: Win64
second:
enabled: 1
settings:
CPU: AnyCPU
data:
first:
Standalone: Linux
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: Linux64
second:
enabled: 1
settings:
CPU: x86_64
data:
first:
Standalone: LinuxUniversal
second:
enabled: 1
settings:
CPU: x86_64
data:
first:
Standalone: OSXIntel
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: OSXIntel64
second:
enabled: 1
settings:
CPU: AnyCPU
data:
first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: x86_64
data:
first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: Win64
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
'': OSXIntel
second:
enabled: 0
settings:
CPU: None
- first:
'': OSXIntel64
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
CPU: x86_64
DefaultValueInitialized: true
- first:
Facebook: Win
second:
enabled: 0
settings:
CPU: None
- first:
Facebook: Win64
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
Standalone: Linux
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Linux64
second:
enabled: 1
settings:
CPU: x86_64
- first:
Standalone: LinuxUniversal
second:
enabled: 1
settings:
CPU: x86_64
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: x86_64
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 1
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
Assets/Script/CoordinateMapperManager.cs
View file @
36e20b59
...
...
@@ -8,9 +8,8 @@ public class CoordinateMapperManager : MonoBehaviour
private
CoordinateMapper
_CoordinateMapper
;
private
MultiSourceFrameReader
_SourceFrameReader
;
private
DepthSpacePoint
[]
_DepthCoordinates
;
const
int
ColorWidth
=
1920
;
const
int
ColorHeight
=
1080
;
private
SourceBuffer
_SourceBuffer
;
long
frameCount
=
0
;
...
...
@@ -24,17 +23,17 @@ public class CoordinateMapperManager : MonoBehaviour
public
Texture2D
ColorTexture
{
get
{
return
_ColorRGBX
;
}
}
public
byte
[]
BodyIndexBuffer
{
get
{
return
SourceBuffer
.
BodyIndexBuffer
;
}
}
{
get
{
return
_
SourceBuffer
.
BodyIndexBuffer
;
}
}
public
DepthSpacePoint
[]
DepthCoordinates
{
get
{
return
_DepthCoordinates
;
}
}
public
Body
[]
BodyBuffer
{
get
{
return
SourceBuffer
.
BodyBuffer
;
}
}
{
get
{
return
_
SourceBuffer
.
BodyBuffer
;
}
}
void
Awake
()
{
_ColorRGBX
=
new
Texture2D
(
ColorWidth
,
ColorHeight
,
TextureFormat
.
RGBA32
,
false
);
_ColorRGBX
=
new
Texture2D
(
SourceBuffer
.
ColorWidth
,
SourceBuffer
.
ColorHeight
,
TextureFormat
.
RGBA32
,
false
);
_DepthCoordinates
=
new
DepthSpacePoint
[
ColorWidth
*
ColorHeight
];
_DepthCoordinates
=
new
DepthSpacePoint
[
SourceBuffer
.
ColorWidth
*
SourceBuffer
.
ColorHeight
];
InitializeDefaultSensor
();
}
...
...
@@ -76,19 +75,19 @@ public class CoordinateMapperManager : MonoBehaviour
void
ProcessFrame
()
{
var
DepthData
=
GCHandle
.
Alloc
(
SourceBuffer
.
DepthBuffer
,
GCHandleType
.
Pinned
);
var
DepthData
=
GCHandle
.
Alloc
(
_
SourceBuffer
.
DepthBuffer
,
GCHandleType
.
Pinned
);
var
pDepthCoordinatesData
=
GCHandle
.
Alloc
(
_DepthCoordinates
,
GCHandleType
.
Pinned
);
_CoordinateMapper
.
MapColorFrameToDepthSpaceUsingIntPtr
(
DepthData
.
AddrOfPinnedObject
(),
(
uint
)
SourceBuffer
.
DepthBuffer
.
Length
*
sizeof
(
ushort
),
(
uint
)
_
SourceBuffer
.
DepthBuffer
.
Length
*
sizeof
(
ushort
),
pDepthCoordinatesData
.
AddrOfPinnedObject
(),
(
uint
)
_DepthCoordinates
.
Length
);
pDepthCoordinatesData
.
Free
();
DepthData
.
Free
();
_ColorRGBX
.
LoadRawTextureData
(
SourceBuffer
.
ColorBuffer
);
_ColorRGBX
.
LoadRawTextureData
(
_
SourceBuffer
.
ColorBuffer
);
_ColorRGBX
.
Apply
();
}
...
...
@@ -115,7 +114,7 @@ public class CoordinateMapperManager : MonoBehaviour
if
((
nullFrame
=
sourceFrame
==
null
))
return
;
SourceBuffer
.
UpdateBuffers
(
sourceFrame
);
_
SourceBuffer
.
UpdateBuffers
(
sourceFrame
);
ProcessFrame
();
}
...
...
@@ -138,28 +137,29 @@ public class CoordinateMapperManager : MonoBehaviour
}
}
public
static
class
SourceBuffer
public
class
SourceBuffer
{
private
const
int
DepthWidth
=
512
;
private
const
int
DepthHeight
=
424
;
public
const
int
ColorWidth
=
1920
;
public
const
int
ColorHeight
=
1080
;
static
private
byte
[]
_ColorBuffer
=
new
byte
[
ColorWidth
*
ColorHeight
*
4
],
_BodyIndexBuffer
=
new
byte
[
DepthWidth
*
DepthHeight
];
static
private
ushort
[]
_DepthBuffer
=
new
ushort
[
DepthWidth
*
DepthHeight
];
private
static
Body
[]
_BodyBuffer
=
new
Body
[
6
];
public
static
byte
[]
ColorBuffer
public
const
int
DepthWidth
=
512
;
public
const
int
DepthHeight
=
424
;
public
const
int
ColorWidth
=
1920
;
public
const
int
ColorHeight
=
1080
;
public
const
int
BodyCount
=
6
;
private
byte
[]
_ColorBuffer
=
new
byte
[
ColorWidth
*
ColorHeight
*
4
],
_BodyIndexBuffer
=
new
byte
[
DepthWidth
*
DepthHeight
];
private
ushort
[]
_DepthBuffer
=
new
ushort
[
DepthWidth
*
DepthHeight
];
private
Body
[]
_BodyBuffer
=
new
Body
[
BodyCount
];
public
byte
[]
ColorBuffer
{
get
{
return
_ColorBuffer
;
}
}
public
static
byte
[]
BodyIndexBuffer
public
byte
[]
BodyIndexBuffer
{
get
{
return
_BodyIndexBuffer
;
}
}
public
static
ushort
[]
DepthBuffer
public
ushort
[]
DepthBuffer
{
get
{
return
_DepthBuffer
;
}
}
public
static
Body
[]
BodyBuffer
public
Body
[]
BodyBuffer
{
get
{
return
_BodyBuffer
;
}
}
public
static
void
UpdateBuffers
(
MultiSourceFrame
sourceFrame
)
public
void
UpdateBuffers
(
MultiSourceFrame
sourceFrame
)
{
UpdateColorBuffer
(
sourceFrame
);
UpdateBodyIndexBuffer
(
sourceFrame
);
...
...
@@ -167,7 +167,7 @@ public static class SourceBuffer
UpdateBodyBuffer
(
sourceFrame
);
}
private
static
void
UpdateColorBuffer
(
MultiSourceFrame
sourceFrame
)
private
void
UpdateColorBuffer
(
MultiSourceFrame
sourceFrame
)
{
using
(
var
colorFrame
=
sourceFrame
.
ColorFrameReference
.
AcquireFrame
())
if
(
colorFrame
!=
null
)
...
...
@@ -178,7 +178,7 @@ public static class SourceBuffer
}
}
private
static
void
UpdateBodyIndexBuffer
(
MultiSourceFrame
sourceFrame
)
private
void
UpdateBodyIndexBuffer
(
MultiSourceFrame
sourceFrame
)
{
using
(
var
bodyIndexFrame
=
sourceFrame
.
BodyIndexFrameReference
.
AcquireFrame
())
if
(
bodyIndexFrame
!=
null
)
...
...
@@ -189,7 +189,7 @@ public static class SourceBuffer
}
}
private
static
void
UpdateDepthBuffer
(
MultiSourceFrame
sourceFrame
)
private
void
UpdateDepthBuffer
(
MultiSourceFrame
sourceFrame
)
{
using
(
var
depthFrame
=
sourceFrame
.
DepthFrameReference
.
AcquireFrame
())
if
(
depthFrame
!=
null
)
...
...
@@ -200,7 +200,7 @@ public static class SourceBuffer
}
}
private
static
void
UpdateBodyBuffer
(
MultiSourceFrame
sourceFrame
)
private
void
UpdateBodyBuffer
(
MultiSourceFrame
sourceFrame
)
{
using
(
var
bodyFrame
=
sourceFrame
.
BodyFrameReference
.
AcquireFrame
())
if
(
bodyFrame
!=
null
)
...
...
ProjectSettings/ProjectSettings.asset
View file @
36e20b59
...
...
@@ -258,7 +258,10 @@ PlayerSettings:
resolutionDialogBanner
:
{
fileID
:
0
}
m_BuildTargetIcons
:
[]
m_BuildTargetBatching
:
[]
m_BuildTargetGraphicsAPIs
:
[]
m_BuildTargetGraphicsAPIs
:
-
m_BuildTarget
:
WindowsStandaloneSupport
m_APIs
:
02000000
m_Automatic
:
1
m_BuildTargetVRSettings
:
[]
m_BuildTargetEnableVuforiaSettings
:
[]
openGLRequireES31
:
0
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment