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
c1882494
Commit
c1882494
authored
Feb 09, 2018
by
16이상민
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Repair errors
parent
a07b33a7
Changes
14
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
162 additions
and
175 deletions
+162
-175
SourceBufferTests.cs
Assets/Editor/SourceBufferTests.cs
+75
-36
IBodyFrame.cs
Assets/KinectModule/IBodyFrame.cs
+1
-1
IBodyIndexFrame.cs
Assets/KinectModule/IBodyIndexFrame.cs
+1
-1
IColorFrame.cs
Assets/KinectModule/IColorFrame.cs
+1
-1
IDepthFrame.cs
Assets/KinectModule/IDepthFrame.cs
+1
-1
RealBody.cs
Assets/KinectModule/RealBody.cs
+13
-5
RealBodyFrame.cs
Assets/KinectModule/RealBodyFrame.cs
+6
-9
RealBodyIndexFrame.cs
Assets/KinectModule/RealBodyIndexFrame.cs
+5
-10
RealColorFrame.cs
Assets/KinectModule/RealColorFrame.cs
+6
-11
RealDepthFrame.cs
Assets/KinectModule/RealDepthFrame.cs
+5
-10
RealMultiSourceFrame.cs
Assets/KinectModule/RealMultiSourceFrame.cs
+12
-37
SourceBuffer.cs
Assets/KinectModule/SourceBuffer.cs
+21
-38
MotionDiscriminator.cs
Assets/MotionAnalysis/MotionDiscriminator.cs
+8
-6
CoordinateMapperView.cs
Assets/Script/CoordinateMapperView.cs
+7
-9
No files found.
Assets/Editor/SourceBufferTests.cs
View file @
c1882494
...
@@ -62,10 +62,7 @@ public class SourceBufferTests
...
@@ -62,10 +62,7 @@ public class SourceBufferTests
var
obj
=
new
SourceBuffer
();
var
obj
=
new
SourceBuffer
();
obj
.
UpdateBuffers
(
frame
);
obj
.
UpdateBuffers
(
frame
);
var
expected
=
new
byte
[
KinectConstants
.
ColorWidth
*
var
expected
=
frame
.
LastColorFrame
.
GetData
();
KinectConstants
.
ColorHeight
*
KinectConstants
.
ColorCount
];
frame
.
LastColorFrame
.
CopyData
(
expected
);
var
actual
=
obj
.
ColorBuffer
;
var
actual
=
obj
.
ColorBuffer
;
...
@@ -83,9 +80,7 @@ public class SourceBufferTests
...
@@ -83,9 +80,7 @@ public class SourceBufferTests
var
obj
=
new
SourceBuffer
();
var
obj
=
new
SourceBuffer
();
obj
.
UpdateBuffers
(
frame
);
obj
.
UpdateBuffers
(
frame
);
var
expected
=
new
byte
[
KinectConstants
.
DepthWidth
*
var
expected
=
frame
.
LastBodyIndexFrame
.
GetData
();
KinectConstants
.
DepthHeight
];
frame
.
LastBodyIndexFrame
.
CopyData
(
expected
);
var
actual
=
obj
.
BodyIndexBuffer
;
var
actual
=
obj
.
BodyIndexBuffer
;
...
@@ -103,9 +98,7 @@ public class SourceBufferTests
...
@@ -103,9 +98,7 @@ public class SourceBufferTests
var
obj
=
new
SourceBuffer
();
var
obj
=
new
SourceBuffer
();
obj
.
UpdateBuffers
(
frame
);
obj
.
UpdateBuffers
(
frame
);
var
expected
=
new
ushort
[
KinectConstants
.
DepthWidth
*
var
expected
=
frame
.
LastDepthFrame
.
GetData
();
KinectConstants
.
DepthHeight
];
frame
.
LastDepthFrame
.
CopyData
(
expected
);
var
actual
=
obj
.
DepthBuffer
;
var
actual
=
obj
.
DepthBuffer
;
...
@@ -123,8 +116,7 @@ public class SourceBufferTests
...
@@ -123,8 +116,7 @@ public class SourceBufferTests
var
obj
=
new
SourceBuffer
();
var
obj
=
new
SourceBuffer
();
obj
.
UpdateBuffers
(
frame
);
obj
.
UpdateBuffers
(
frame
);
var
expected
=
new
IBody
[
KinectConstants
.
BodyCount
];
var
expected
=
frame
.
LastBodyFrame
.
GetData
();
frame
.
LastBodyFrame
.
CopyData
(
expected
);
var
actual
=
obj
.
BodyBuffer
;
var
actual
=
obj
.
BodyBuffer
;
...
@@ -157,74 +149,121 @@ public class MultiSourceFrameStub : IMultiSourceFrame
...
@@ -157,74 +149,121 @@ public class MultiSourceFrameStub : IMultiSourceFrame
public
class
GreenColorFrameStub
:
IColorFrame
public
class
GreenColorFrameStub
:
IColorFrame
{
{
private
static
uint
[]
data
=
private
static
byte
[]
data
=
Enumerable
.
Range
(
0
,
Enumerable
.
Repeat
<
uint
>(
0x00FF00FF
,
KinectConstants
.
ColorWidth
*
KinectConstants
.
ColorWidth
*
KinectConstants
.
ColorHeight
).
ToArray
();
KinectConstants
.
ColorHeight
)
.
Select
(
x
=>
(
byte
)((
x
&
1
)
==
1
?
0xFF
:
0
))
.
ToArray
();
public
void
CopyData
(
byte
[]
buffer
)
public
byte
[]
GetData
(
)
{
{
Buffer
.
BlockCopy
(
buffer
,
0
,
data
,
0
,
buffer
.
Length
)
;
return
data
;
}
}
}
}
public
class
Fill1BodyIndexFrameStub
:
IBodyIndexFrame
public
class
Fill1BodyIndexFrameStub
:
IBodyIndexFrame
{
{
public
void
CopyData
(
byte
[]
buffer
)
private
static
byte
[]
data
=
Enumerable
.
Repeat
(
0
,
KinectConstants
.
DepthWidth
*
KinectConstants
.
DepthHeight
)
.
Select
(
x
=>
(
byte
)
x
)
.
ToArray
();
public
byte
[]
GetData
()
{
{
for
(
int
i
=
0
;
i
<
buffer
.
Length
;
++
i
)
return
data
;
buffer
[
i
]
=
1
;
}
}
}
}
public
class
Fill8000DepthFrameStub
:
IDepthFrame
public
class
Fill8000DepthFrameStub
:
IDepthFrame
{
{
public
void
CopyData
(
ushort
[]
buffer
)
private
static
ushort
[]
data
=
Enumerable
.
Repeat
(
8000
,
KinectConstants
.
DepthWidth
*
KinectConstants
.
DepthHeight
)
.
Select
(
x
=>
(
ushort
)
x
)
.
ToArray
();
public
ushort
[]
GetData
()
{
{
for
(
int
i
=
0
;
i
<
buffer
.
Length
;
++
i
)
return
data
;
buffer
[
i
]
=
8000
;
}
}
}
}
public
class
CleanBodyFrameStub
:
IBodyFrame
public
class
CleanBodyFrameStub
:
IBodyFrame
{
{
public
void
CopyData
(
IBody
[]
buffer
)
private
static
BodyFake
[]
data
=
Enumerable
.
Range
(
0
,
KinectConstants
.
BodyCount
)
{
.
Select
(
x
=>
for
(
int
i
=
0
;
i
<
buffer
.
Length
;
++
i
)
{
{
var
tmp
=
new
BodyFake
();
var
tmp
=
new
BodyFake
();
var
joints
=
tmp
.
Joints
;
var
joints
=
tmp
.
Joints
;
for
(
int
j
=
0
;
j
<
KinectConstants
.
JointCount
;
++
j
)
for
(
int
j
=
0
;
j
<
KinectConstants
.
JointCount
;
++
j
)
joints
[
joints
.
ElementAt
(
j
).
Key
]
=
new
JointStub
();
joints
[
joints
.
ElementAt
(
j
).
Key
]
=
new
JointStub
();
tmp
.
IsTracked
=
false
;
tmp
.
IsTracked
=
false
;
buffer
[
i
]
=
tmp
;
return
tmp
;
}
})
.
ToArray
();
public
IBody
[]
GetData
()
{
return
data
;
}
}
}
}
public
class
ColorFrameDummy
:
IColorFrame
public
class
ColorFrameDummy
:
IColorFrame
{
{
private
static
byte
[]
data
=
new
byte
[
KinectConstants
.
ColorWidth
*
KinectConstants
.
ColorHeight
*
KinectConstants
.
ColorCount
];
public
void
CopyData
(
byte
[]
buffer
)
public
void
CopyData
(
byte
[]
buffer
)
{
}
{
}
public
byte
[]
GetData
()
{
return
data
;
}
}
}
public
class
BodyIndexFrameDummy
:
IBodyIndexFrame
public
class
BodyIndexFrameDummy
:
IBodyIndexFrame
{
{
private
static
byte
[]
data
=
new
byte
[
KinectConstants
.
DepthWidth
*
KinectConstants
.
DepthHeight
];
public
void
CopyData
(
byte
[]
buffer
)
public
void
CopyData
(
byte
[]
buffer
)
{
}
{
}
public
byte
[]
GetData
()
{
return
data
;
}
}
}
public
class
DepthFrameDummy
:
IDepthFrame
public
class
DepthFrameDummy
:
IDepthFrame
{
{
private
static
ushort
[]
data
=
new
ushort
[
KinectConstants
.
DepthWidth
*
KinectConstants
.
DepthHeight
];
public
void
CopyData
(
ushort
[]
buffer
)
public
void
CopyData
(
ushort
[]
buffer
)
{
}
{
}
public
ushort
[]
GetData
()
{
return
data
;
}
}
}
public
class
BodyFrameDummy
:
IBodyFrame
public
class
BodyFrameDummy
:
IBodyFrame
{
{
private
static
IBody
[]
data
=
new
IBody
[
KinectConstants
.
BodyCount
];
public
void
CopyData
(
IBody
[]
buffer
)
public
void
CopyData
(
IBody
[]
buffer
)
{
}
{
}
public
IBody
[]
GetData
()
{
return
data
;
}
}
}
public
class
BodyFake
:
IBody
public
class
BodyFake
:
IBody
...
...
Assets/KinectModule/IBodyFrame.cs
View file @
c1882494
...
@@ -2,6 +2,6 @@
...
@@ -2,6 +2,6 @@
{
{
public
interface
IBodyFrame
public
interface
IBodyFrame
{
{
void
CopyData
(
IBody
[]
buffer
);
IBody
[]
GetData
(
);
}
}
}
}
\ No newline at end of file
Assets/KinectModule/IBodyIndexFrame.cs
View file @
c1882494
...
@@ -2,6 +2,6 @@
...
@@ -2,6 +2,6 @@
{
{
public
interface
IBodyIndexFrame
public
interface
IBodyIndexFrame
{
{
void
CopyData
(
byte
[]
buffer
);
byte
[]
GetData
(
);
}
}
}
}
\ No newline at end of file
Assets/KinectModule/IColorFrame.cs
View file @
c1882494
...
@@ -2,6 +2,6 @@
...
@@ -2,6 +2,6 @@
{
{
public
interface
IColorFrame
public
interface
IColorFrame
{
{
void
CopyData
(
byte
[]
buffer
);
byte
[]
GetData
(
);
}
}
}
}
\ No newline at end of file
Assets/KinectModule/IDepthFrame.cs
View file @
c1882494
...
@@ -2,6 +2,6 @@
...
@@ -2,6 +2,6 @@
{
{
public
interface
IDepthFrame
public
interface
IDepthFrame
{
{
void
CopyData
(
ushort
[]
buffer
);
ushort
[]
GetData
(
);
}
}
}
}
\ No newline at end of file
Assets/KinectModule/RealBody.cs
View file @
c1882494
...
@@ -7,6 +7,7 @@ namespace KinectModule
...
@@ -7,6 +7,7 @@ namespace KinectModule
public
class
RealBody
:
IBody
public
class
RealBody
:
IBody
{
{
private
Body
_Body
;
private
Body
_Body
;
private
Dictionary
<
JointType
,
IJoint
>
_Joints
;
public
bool
IsTracked
public
bool
IsTracked
{
{
...
@@ -19,9 +20,7 @@ namespace KinectModule
...
@@ -19,9 +20,7 @@ namespace KinectModule
{
{
get
get
{
{
return
_Body
.
Joints
.
Select
(
x
=>
new
KeyValuePair
<
JointType
,
IJoint
>
return
_Joints
;
(
x
.
Key
,
new
RealJoint
(
x
.
Value
)))
.
ToDictionary
(
x
=>
x
.
Key
,
x
=>
x
.
Value
);
}
}
}
}
public
Body
Value
public
Body
Value
...
@@ -33,17 +32,26 @@ namespace KinectModule
...
@@ -33,17 +32,26 @@ namespace KinectModule
}
}
public
RealBody
(
Body
body
)
public
RealBody
(
Body
body
)
{
if
(
body
!=
null
)
{
{
_Body
=
body
;
_Body
=
body
;
_Joints
=
_Body
.
Joints
.
Select
(
x
=>
new
KeyValuePair
<
JointType
,
IJoint
>
(
x
.
Key
,
new
RealJoint
(
x
.
Value
)))
.
ToDictionary
(
x
=>
x
.
Key
,
x
=>
x
.
Value
);
}
}
}
public
override
bool
Equals
(
object
obj
)
public
override
bool
Equals
(
object
obj
)
{
{
return
this
.
Equals
(
obj
as
IBody
);
return
Equals
(
obj
as
IBody
);
}
}
public
bool
Equals
(
IBody
obj
)
public
bool
Equals
(
IBody
obj
)
{
{
if
(
_Body
==
null
)
return
obj
==
null
;
var
keys
=
Joints
.
Select
(
x
=>
x
.
Key
);
var
keys
=
Joints
.
Select
(
x
=>
x
.
Key
);
foreach
(
var
key
in
keys
)
foreach
(
var
key
in
keys
)
{
{
...
...
Assets/KinectModule/RealBodyFrame.cs
View file @
c1882494
...
@@ -5,25 +5,22 @@ namespace KinectModule
...
@@ -5,25 +5,22 @@ namespace KinectModule
{
{
public
class
RealBodyFrame
:
IBodyFrame
public
class
RealBodyFrame
:
IBodyFrame
{
{
private
Body
[]
_Buffer
=
new
Body
[
KinectConstants
.
BodyCount
];
private
static
Body
[]
_Buffer
=
new
Body
[
KinectConstants
.
BodyCount
];
private
bool
IsValid
=
false
;
public
RealBodyFrame
(
BodyFrame
frame
)
public
RealBodyFrame
(
BodyFrame
frame
)
{
{
if
(
frame
!=
null
)
if
(
frame
!=
null
)
{
{
frame
.
GetAndRefreshBodyData
(
_Buffer
);
frame
.
GetAndRefreshBodyData
(
_Buffer
);
IsValid
=
true
;
}
}
}
}
public
void
CopyData
(
IBody
[]
buffer
)
public
IBody
[]
GetData
(
)
{
{
if
(
IsValid
)
return
Enumerable
.
Range
(
0
,
KinectConstants
.
BodyCount
)
Enumerable
.
Range
(
0
,
KinectConstants
.
BodyCount
)
.
ToList
()
.
ToList
()
.
ForEach
(
x
=>
buffer
[
x
]
=
new
RealBody
(
_Buffer
[
x
]));
.
Select
(
x
=>
new
RealBody
(
_Buffer
[
x
]))
.
ToArray
();
}
}
}
}
}
}
\ No newline at end of file
Assets/KinectModule/RealBodyIndexFrame.cs
View file @
c1882494
using
System
;
using
System.Runtime.InteropServices
;
using
System.Runtime.InteropServices
;
using
Windows.Kinect
;
using
Windows.Kinect
;
namespace
KinectModule
namespace
KinectModule
{
{
public
class
RealBodyIndexFrame
:
IBodyIndexFrame
public
class
RealBodyIndexFrame
:
IBodyIndexFrame
{
{
private
byte
[]
_Buffer
=
new
byte
[
KinectConstants
.
DepthWidth
*
private
static
byte
[]
_Buffer
=
new
byte
[
KinectConstants
.
DepthWidth
*
KinectConstants
.
DepthHeight
];
KinectConstants
.
DepthHeight
];
private
bool
IsValid
=
false
;
public
RealBodyIndexFrame
(
BodyIndexFrame
frame
)
public
RealBodyIndexFrame
(
BodyIndexFrame
frame
)
{
{
...
@@ -17,15 +15,12 @@ namespace KinectModule
...
@@ -17,15 +15,12 @@ namespace KinectModule
var
BodyIndexData
=
GCHandle
.
Alloc
(
_Buffer
,
GCHandleType
.
Pinned
);
var
BodyIndexData
=
GCHandle
.
Alloc
(
_Buffer
,
GCHandleType
.
Pinned
);
frame
.
CopyFrameDataToIntPtr
(
BodyIndexData
.
AddrOfPinnedObject
(),
(
uint
)
_Buffer
.
Length
);
frame
.
CopyFrameDataToIntPtr
(
BodyIndexData
.
AddrOfPinnedObject
(),
(
uint
)
_Buffer
.
Length
);
BodyIndexData
.
Free
();
BodyIndexData
.
Free
();
IsValid
=
true
;
}
}
}
}
public
void
CopyData
(
byte
[]
buffer
)
public
byte
[]
GetData
(
)
{
{
if
(
IsValid
)
return
_Buffer
;
Array
.
Copy
(
_Buffer
,
buffer
,
_Buffer
.
Length
);
}
}
}
}
}
}
\ No newline at end of file
Assets/KinectModule/RealColorFrame.cs
View file @
c1882494
using
System
;
using
System.Runtime.InteropServices
;
using
System.Runtime.InteropServices
;
using
Windows.Kinect
;
using
Windows.Kinect
;
namespace
KinectModule
namespace
KinectModule
{
{
public
class
RealColorFrame
:
IColorFrame
public
class
RealColorFrame
:
IColorFrame
{
{
private
byte
[]
_Buffer
=
new
byte
[
KinectConstants
.
ColorWidth
*
private
static
byte
[]
_Buffer
=
new
byte
[
KinectConstants
.
ColorWidth
*
KinectConstants
.
ColorHeight
*
KinectConstants
.
ColorHeight
*
KinectConstants
.
ColorCount
];
KinectConstants
.
ColorCount
];
private
bool
IsValid
=
false
;
public
RealColorFrame
(
ColorFrame
frame
)
public
RealColorFrame
(
ColorFrame
frame
)
{
{
...
@@ -18,15 +16,12 @@ namespace KinectModule
...
@@ -18,15 +16,12 @@ namespace KinectModule
var
ColorData
=
GCHandle
.
Alloc
(
_Buffer
,
GCHandleType
.
Pinned
);
var
ColorData
=
GCHandle
.
Alloc
(
_Buffer
,
GCHandleType
.
Pinned
);
frame
.
CopyConvertedFrameDataToIntPtr
(
ColorData
.
AddrOfPinnedObject
(),
(
uint
)
_Buffer
.
Length
,
ColorImageFormat
.
Rgba
);
frame
.
CopyConvertedFrameDataToIntPtr
(
ColorData
.
AddrOfPinnedObject
(),
(
uint
)
_Buffer
.
Length
,
ColorImageFormat
.
Rgba
);
ColorData
.
Free
();
ColorData
.
Free
();
IsValid
=
true
;
}
}
}
}
public
void
CopyData
(
byte
[]
buffer
)
public
byte
[]
GetData
(
)
{
{
if
(
IsValid
)
return
_Buffer
;
Array
.
Copy
(
_Buffer
,
buffer
,
_Buffer
.
Length
);
}
}
}
}
}
}
\ No newline at end of file
Assets/KinectModule/RealDepthFrame.cs
View file @
c1882494
using
System
;
using
System.Runtime.InteropServices
;
using
System.Runtime.InteropServices
;
using
Windows.Kinect
;
using
Windows.Kinect
;
namespace
KinectModule
namespace
KinectModule
{
{
public
class
RealDepthFrame
:
IDepthFrame
public
class
RealDepthFrame
:
IDepthFrame
{
{
private
ushort
[]
_Buffer
=
new
ushort
[
KinectConstants
.
DepthWidth
*
private
static
ushort
[]
_Buffer
=
new
ushort
[
KinectConstants
.
DepthWidth
*
KinectConstants
.
DepthHeight
];
KinectConstants
.
DepthHeight
];
private
bool
IsValid
=
false
;
public
RealDepthFrame
(
DepthFrame
frame
)
public
RealDepthFrame
(
DepthFrame
frame
)
{
{
...
@@ -17,15 +15,12 @@ namespace KinectModule
...
@@ -17,15 +15,12 @@ namespace KinectModule
var
DepthData
=
GCHandle
.
Alloc
(
_Buffer
,
GCHandleType
.
Pinned
);
var
DepthData
=
GCHandle
.
Alloc
(
_Buffer
,
GCHandleType
.
Pinned
);
frame
.
CopyFrameDataToIntPtr
(
DepthData
.
AddrOfPinnedObject
(),
(
uint
)
_Buffer
.
Length
*
sizeof
(
ushort
));
frame
.
CopyFrameDataToIntPtr
(
DepthData
.
AddrOfPinnedObject
(),
(
uint
)
_Buffer
.
Length
*
sizeof
(
ushort
));
DepthData
.
Free
();
DepthData
.
Free
();
IsValid
=
true
;
}
}
}
}
public
void
CopyData
(
ushort
[]
buffer
)
public
ushort
[]
GetData
(
)
{
{
if
(
IsValid
)
return
_Buffer
;
Array
.
Copy
(
_Buffer
,
buffer
,
_Buffer
.
Length
);
}
}
}
}
}
}
\ No newline at end of file
Assets/KinectModule/RealMultiSourceFrame.cs
View file @
c1882494
...
@@ -4,60 +4,35 @@ namespace KinectModule
...
@@ -4,60 +4,35 @@ namespace KinectModule
{
{
public
class
RealMultiSourceFrame
:
IMultiSourceFrame
public
class
RealMultiSourceFrame
:
IMultiSourceFrame
{
{
RealColorFrame
_ColorFrame
;
RealBodyIndexFrame
_BodyIndexFrame
;
RealDepthFrame
_DepthFrame
;
RealBodyFrame
_BodyFrame
;
public
IColorFrame
LastColorFrame
public
IColorFrame
LastColorFrame
{
{
get
;
private
set
;
}
get
{
return
_ColorFrame
;
}
}
public
IBodyIndexFrame
LastBodyIndexFrame
public
IBodyIndexFrame
LastBodyIndexFrame
{
{
get
;
private
set
;
}
get
{
return
_BodyIndexFrame
;
}
}
public
IDepthFrame
LastDepthFrame
public
IDepthFrame
LastDepthFrame
{
{
get
;
private
set
;
}
get
{
return
_DepthFrame
;
}
}
public
IBodyFrame
LastBodyFrame
public
IBodyFrame
LastBodyFrame
{
{
get
;
private
set
;
}
get
{
return
_BodyFrame
;
}
}
public
RealMultiSourceFrame
(
MultiSourceFrame
sourceFrame
)
public
RealMultiSourceFrame
(
MultiSourceFrame
sourceFrame
)
{
{
if
(
sourceFrame
==
null
)
if
(
sourceFrame
==
null
)
{
{
_
ColorFrame
=
new
RealColorFrame
(
null
);
Last
ColorFrame
=
new
RealColorFrame
(
null
);
_
BodyIndexFrame
=
new
RealBodyIndexFrame
(
null
);
Last
BodyIndexFrame
=
new
RealBodyIndexFrame
(
null
);
_
DepthFrame
=
new
RealDepthFrame
(
null
);
Last
DepthFrame
=
new
RealDepthFrame
(
null
);
_
BodyFrame
=
new
RealBodyFrame
(
null
);
Last
BodyFrame
=
new
RealBodyFrame
(
null
);
return
;
return
;
}
}
using
(
var
colorFrame
=
sourceFrame
.
ColorFrameReference
.
AcquireFrame
())
using
(
var
colorFrame
=
sourceFrame
.
ColorFrameReference
.
AcquireFrame
())
_ColorFrame
=
new
RealColorFrame
(
colorFrame
);
LastColorFrame
=
new
RealColorFrame
(
colorFrame
);
using
(
var
bodyIndexFrame
=
sourceFrame
.
BodyIndexFrameReference
.
AcquireFrame
())
using
(
var
bodyIndexFrame
=
sourceFrame
.
BodyIndexFrameReference
.
AcquireFrame
())
_BodyIndexFrame
=
new
RealBodyIndexFrame
(
bodyIndexFrame
);
LastBodyIndexFrame
=
new
RealBodyIndexFrame
(
bodyIndexFrame
);
using
(
var
depthFrame
=
sourceFrame
.
DepthFrameReference
.
AcquireFrame
())
using
(
var
depthFrame
=
sourceFrame
.
DepthFrameReference
.
AcquireFrame
())
_DepthFrame
=
new
RealDepthFrame
(
depthFrame
);
LastDepthFrame
=
new
RealDepthFrame
(
depthFrame
);
using
(
var
bodyFrame
=
sourceFrame
.
BodyFrameReference
.
AcquireFrame
())
using
(
var
bodyFrame
=
sourceFrame
.
BodyFrameReference
.
AcquireFrame
())
_BodyFrame
=
new
RealBodyFrame
(
bodyFrame
);
LastBodyFrame
=
new
RealBodyFrame
(
bodyFrame
);
}
}
}
}
}
}
\ No newline at end of file
Assets/KinectModule/SourceBuffer.cs
View file @
c1882494
...
@@ -2,50 +2,33 @@
...
@@ -2,50 +2,33 @@
{
{
public
class
SourceBuffer
public
class
SourceBuffer
{
{
private
byte
[]
_ColorBuffer
=
new
byte
[
KinectConstants
.
ColorWidth
*
KinectConstants
.
ColorHeight
*
KinectConstants
.
ColorCount
],
_BodyIndexBuffer
=
new
byte
[
KinectConstants
.
DepthWidth
*
KinectConstants
.
DepthHeight
];
private
ushort
[]
_DepthBuffer
=
new
ushort
[
KinectConstants
.
DepthWidth
*
KinectConstants
.
DepthHeight
];
private
IBody
[]
_BodyBuffer
=
new
IBody
[
KinectConstants
.
BodyCount
];
public
byte
[]
ColorBuffer
public
byte
[]
ColorBuffer
{
{
get
;
private
set
;
}
get
{
return
_ColorBuffer
;
}
}
public
byte
[]
BodyIndexBuffer
public
byte
[]
BodyIndexBuffer
{
{
get
;
private
set
;
}
get
{
return
_BodyIndexBuffer
;
}
}
public
ushort
[]
DepthBuffer
public
ushort
[]
DepthBuffer
{
{
get
;
private
set
;
}
get
{
return
_DepthBuffer
;
}
}
public
IBody
[]
BodyBuffer
public
IBody
[]
BodyBuffer
{
get
;
private
set
;
}
public
SourceBuffer
()
{
{
get
ColorBuffer
=
new
byte
[
KinectConstants
.
ColorWidth
*
{
KinectConstants
.
ColorHeight
*
return
_BodyBuffer
;
KinectConstants
.
ColorCount
];
}
BodyIndexBuffer
=
new
byte
[
KinectConstants
.
DepthWidth
*
KinectConstants
.
DepthHeight
];
DepthBuffer
=
new
ushort
[
KinectConstants
.
DepthWidth
*
KinectConstants
.
DepthHeight
];
BodyBuffer
=
new
IBody
[
KinectConstants
.
BodyCount
];
}
}
public
void
UpdateBuffers
(
IMultiSourceFrame
sourceFrame
)
public
void
UpdateBuffers
(
IMultiSourceFrame
sourceFrame
)
{
{
sourceFrame
.
LastColorFrame
.
CopyData
(
_ColorBuffer
);
ColorBuffer
=
sourceFrame
.
LastColorFrame
.
GetData
(
);
sourceFrame
.
LastBodyIndexFrame
.
CopyData
(
_BodyIndexBuffer
);
BodyIndexBuffer
=
sourceFrame
.
LastBodyIndexFrame
.
GetData
(
);
sourceFrame
.
LastDepthFrame
.
CopyData
(
_DepthBuffer
);
DepthBuffer
=
sourceFrame
.
LastDepthFrame
.
GetData
(
);
sourceFrame
.
LastBodyFrame
.
CopyData
(
_BodyBuffer
);
BodyBuffer
=
sourceFrame
.
LastBodyFrame
.
GetData
(
);
}
}
}
}
}
}
\ No newline at end of file
Assets/MotionAnalysis/MotionDiscriminator.cs
View file @
c1882494
using
System.Linq
;
using
KinectModule
;
using
System.Linq
;
using
Windows.Kinect
;
using
Windows.Kinect
;
namespace
MotionAnalysis
namespace
MotionAnalysis
...
@@ -12,7 +13,7 @@ namespace MotionAnalysis
...
@@ -12,7 +13,7 @@ namespace MotionAnalysis
public
bool
IsPreseted
public
bool
IsPreseted
{
get
;
private
set
;
}
{
get
;
private
set
;
}
public
void
Preset
(
KinectModule
.
IBody
body
)
public
void
Preset
(
IBody
body
)
{
{
IsPreseted
=
false
;
IsPreseted
=
false
;
...
@@ -26,14 +27,15 @@ namespace MotionAnalysis
...
@@ -26,14 +27,15 @@ namespace MotionAnalysis
}
}
}
}
private
bool
HaveKneeJoint
(
KinectModule
.
IBody
body
)
private
bool
HaveKneeJoint
(
IBody
body
)
{
{
return
body
!=
null
&&
return
body
!=
null
&&
body
.
Joints
!=
null
&&
body
.
Joints
.
ContainsKey
(
JointType
.
KneeLeft
)
&&
body
.
Joints
.
ContainsKey
(
JointType
.
KneeLeft
)
&&
body
.
Joints
.
ContainsKey
(
JointType
.
KneeRight
);
body
.
Joints
.
ContainsKey
(
JointType
.
KneeRight
);
}
}
private
float
ComputeKneeMean
(
KinectModule
.
IBody
body
)
private
float
ComputeKneeMean
(
IBody
body
)
{
{
return
body
.
Joints
.
Where
(
x
=>
x
.
Key
==
JointType
.
KneeLeft
||
return
body
.
Joints
.
Where
(
x
=>
x
.
Key
==
JointType
.
KneeLeft
||
x
.
Key
==
JointType
.
KneeRight
)
x
.
Key
==
JointType
.
KneeRight
)
...
@@ -46,7 +48,7 @@ namespace MotionAnalysis
...
@@ -46,7 +48,7 @@ namespace MotionAnalysis
Motion
=
MotionState
.
UNKNOWN
;
Motion
=
MotionState
.
UNKNOWN
;
}
}
public
void
Update
(
KinectModule
.
IBody
body
)
public
void
Update
(
IBody
body
)
{
{
Extractor
.
Extract
(
body
);
Extractor
.
Extract
(
body
);
...
...
Assets/Script/CoordinateMapperView.cs
View file @
c1882494
...
@@ -4,7 +4,7 @@ using Windows.Kinect;
...
@@ -4,7 +4,7 @@ using Windows.Kinect;
public
class
CoordinateMapperView
:
MonoBehaviour
public
class
CoordinateMapperView
:
MonoBehaviour
{
{
private
GameObject
manager
;
private
CoordinateMapperManager
manager
;
private
ComputeBuffer
DepthBuffer
,
private
ComputeBuffer
DepthBuffer
,
BodyIndexBuffer
;
BodyIndexBuffer
;
...
@@ -14,16 +14,16 @@ public class CoordinateMapperView : MonoBehaviour
...
@@ -14,16 +14,16 @@ public class CoordinateMapperView : MonoBehaviour
void
Start
()
void
Start
()
{
{
var
CoordinateMapperM
anager
=
GameObject
.
Find
(
"InGameManagers"
).
GetComponent
<
CoordinateMapperManager
>();
m
anager
=
GameObject
.
Find
(
"InGameManagers"
).
GetComponent
<
CoordinateMapperManager
>();
var
material
=
GetComponent
<
Renderer
>().
material
;
var
material
=
GetComponent
<
Renderer
>().
material
;
material
.
SetTexture
(
"_MainTex"
,
CoordinateMapperM
anager
.
ColorTexture
);
material
.
SetTexture
(
"_MainTex"
,
m
anager
.
ColorTexture
);
DepthBuffer
=
GenerateBuffer
(
"depthCoordinates"
,
sizeof
(
float
)
*
2
,
DepthBuffer
=
GenerateBuffer
(
"depthCoordinates"
,
sizeof
(
float
)
*
2
,
(
DepthPoints
=
CoordinateMapperManager
.
DepthCoordinates
)
,
material
);
manager
.
DepthCoordinates
,
material
);
BodyIndexBuffer
=
GenerateBuffer
(
"BodyIndexBuffer"
,
sizeof
(
float
),
BodyIndexBuffer
=
GenerateBuffer
(
"BodyIndexBuffer"
,
sizeof
(
float
),
(
BodyIndexPoints
=
CoordinateMapperManager
.
BodyIndexBuffer
)
,
material
);
manager
.
BodyIndexBuffer
,
material
);
}
}
ComputeBuffer
GenerateBuffer
(
string
name
,
int
stride
,
Array
points
,
Material
material
)
ComputeBuffer
GenerateBuffer
(
string
name
,
int
stride
,
Array
points
,
Material
material
)
...
@@ -35,12 +35,10 @@ public class CoordinateMapperView : MonoBehaviour
...
@@ -35,12 +35,10 @@ public class CoordinateMapperView : MonoBehaviour
void
Update
()
void
Update
()
{
{
//TODO: fix perf on this call.
//TODO: fix perf on this call.
DepthBuffer
.
SetData
(
DepthPoint
s
);
DepthBuffer
.
SetData
(
manager
.
DepthCoordinate
s
);
BodyIndexBuffer
.
SetData
(
Array
.
ConvertAll
(
BodyIndexPoints
,
Convert
.
ToSingle
));
BodyIndexBuffer
.
SetData
(
Array
.
ConvertAll
(
manager
.
BodyIndexBuffer
,
Convert
.
ToSingle
));
}
}
void
OnDisable
()
void
OnDisable
()
...
...
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