Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
MasterArbeit
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
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
Kai Westerkamp
MasterArbeit
Commits
872479cc
Commit
872479cc
authored
Jul 03, 2017
by
Kai Westerkamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
asdf
parent
31eb724a
Pipeline
#245
passed with stage
in 19 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
17 deletions
+76
-17
SteamTracking.cpp
3_PointCloud/SteamTracking.cpp
+6
-6
SteamTracking.h
3_PointCloud/SteamTracking.h
+2
-2
main.cpp
3_PointCloud/main.cpp
+68
-9
No files found.
3_PointCloud/SteamTracking.cpp
View file @
872479cc
...
...
@@ -17,9 +17,9 @@ std::string SteamTracking::getDeviceTypeAsString(vr::ETrackedDeviceClass device_
return
type
;
}
glm
::
mat3x4
SteamTracking
::
convertMatrix
(
vr
::
HmdMatrix34_t
in
)
glm
::
mat3x4
*
SteamTracking
::
convertMatrix
(
vr
::
HmdMatrix34_t
in
)
{
return
glm
::
mat3x4
(
in
.
m
[
0
][
0
],
in
.
m
[
0
][
1
],
in
.
m
[
0
][
2
],
in
.
m
[
0
][
3
],
return
new
glm
::
mat3x4
(
in
.
m
[
0
][
0
],
in
.
m
[
0
][
1
],
in
.
m
[
0
][
2
],
in
.
m
[
0
][
3
],
in
.
m
[
1
][
0
],
in
.
m
[
1
][
1
],
in
.
m
[
1
][
2
],
in
.
m
[
1
][
3
],
in
.
m
[
2
][
0
],
in
.
m
[
2
][
1
],
in
.
m
[
2
][
2
],
in
.
m
[
2
][
3
]
);
}
...
...
@@ -93,10 +93,10 @@ void SteamTracking::printMatrix(const vr::HmdMatrix34_t &htm)
}
}
glm
::
mat3x4
SteamTracking
::
getTransformationForDevice
(
int
nDevice
)
glm
::
mat3x4
*
SteamTracking
::
getTransformationForDevice
(
int
nDevice
)
{
if
(
!
vr_system_
)
{
return
glm
::
mat3x4
();
return
new
glm
::
mat3x4
();
}
vr_system_
->
GetDeviceToAbsoluteTrackingPose
(
vr
::
TrackingUniverseRawAndUncalibrated
,
0
,
tracked_device_poses_
,
vr
::
k_unMaxTrackedDeviceCount
);
...
...
@@ -104,7 +104,7 @@ glm::mat3x4 SteamTracking::getTransformationForDevice(int nDevice)
if
(
!
tracked_device_poses_
[
nDevice
].
bPoseIsValid
)
{
if
(
debug
)
std
::
cout
<<
" Device "
<<
nDevice
<<
"Pois is Invalid"
;
return
glm
::
mat3x4
();
return
new
glm
::
mat3x4
();
}
vr
::
ETrackedDeviceClass
device_class
=
vr_system_
->
GetTrackedDeviceClass
(
nDevice
);
...
...
@@ -112,7 +112,7 @@ glm::mat3x4 SteamTracking::getTransformationForDevice(int nDevice)
if
(
device_class
==
vr
::
TrackedDeviceClass_Invalid
)
{
if
(
debug
)
std
::
cout
<<
" Device "
<<
nDevice
<<
"ist Invalid"
;
return
glm
::
mat3x4
();
return
new
glm
::
mat3x4
();
}
vr
::
HmdMatrix34_t
htm
=
tracked_device_poses_
[
nDevice
].
mDeviceToAbsoluteTracking
;
...
...
3_PointCloud/SteamTracking.h
View file @
872479cc
...
...
@@ -15,7 +15,7 @@ private:
std
::
string
getDeviceTypeAsString
(
vr
::
ETrackedDeviceClass
device_class
);
glm
::
mat3x4
convertMatrix
(
vr
::
HmdMatrix34_t
in
);
glm
::
mat3x4
*
convertMatrix
(
vr
::
HmdMatrix34_t
in
);
void
printMatrix
(
const
vr
::
HmdMatrix34_t
&
htm
);
...
...
@@ -26,7 +26,7 @@ public:
void
printVRDevices
();
glm
::
mat3x4
getTransformationForDevice
(
int
nDevice
);
glm
::
mat3x4
*
getTransformationForDevice
(
int
nDevice
);
};
3_PointCloud/main.cpp
View file @
872479cc
...
...
@@ -22,6 +22,12 @@
GLuint
vboId
;
GLuint
cboId
;
GLuint
vboIdArrow
;
GLuint
cboIdArrow
;
float
arrowPoints
[]
=
{
1
,
0
,
0
,
0
,
1
,
0
,
0
,
0
,
1
};
// Intermediate Buffers
unsigned
char
rgbimage
[
colorwidth
*
colorheight
*
4
];
// Stores RGB color image
ColorSpacePoint
depth2rgb
[
width
*
height
];
// Maps depth pixels to rgb pixels
...
...
@@ -41,8 +47,42 @@ IMultiSourceFrameReader* reader; // Kinect data source
ICoordinateMapper
*
mapper
;
// Converts between depth, color, and 3d coordinates
SteamTracking
*
steamTracking
=
nullptr
;
glm
::
mat3x4
*
currentControlerPos
=
nullptr
;
static
bool
writeFile
=
false
;
static
bool
captureFrame
=
false
;
void
drawArrow
()
{
//TETAEDRON BY HAND
glBegin
(
GL_TRIANGLES
);
//front triangle
glColor4f
(
1.0
f
,
0.0
f
,
0.0
f
,
1.0
f
);
glVertex3f
(
0.0
f
,
1.0
f
,
0.0
f
);
glVertex3f
(
-
1.0
f
,
-
1.0
f
,
0.0
f
);
glVertex3f
(
1.0
f
,
-
1.0
f
,
0.0
f
);
//right side triangle
glColor4f
(
0.0
f
,
0.0
f
,
1.0
f
,
1.0
f
);
glVertex3f
(
1.0
f
,
-
1.0
f
,
0.0
f
);
glVertex3f
(
0.0
f
,
1.0
f
,
0.0
f
);
glVertex3f
(
0.0
f
,
-
1.0
f
,
-
1.0
f
);
//left side triangle
glColor4f
(
1.0
f
,
1.0
f
,
1.0
f
,
1.0
f
);
glVertex3f
(
-
1.0
f
,
-
1.0
f
,
0.0
f
);
glVertex3f
(
0.0
f
,
1.0
f
,
0.0
f
);
glVertex3f
(
0.0
f
,
-
1.0
f
,
-
1.0
f
);
//bottom triangle
glColor4f
(
0.0
f
,
1.0
f
,
0.0
f
,
1.0
f
);
glVertex3f
(
-
1.0
f
,
-
1.0
f
,
0.0
f
);
glVertex3f
(
1.0
f
,
-
1.0
f
,
0.0
f
);
glVertex3f
(
0.0
f
,
-
1.0
f
,
-
1.0
f
);
glEnd
();
}
bool
initKinect
()
{
if
(
FAILED
(
GetDefaultKinectSensor
(
&
sensor
)))
{
...
...
@@ -132,6 +172,8 @@ void getRgbData(IMultiSourceFrame* frame, bool writFrameToFile) {
void
getKinectData
(
bool
writeFrameInVector
)
{
IMultiSourceFrame
*
frame
=
NULL
;
if
(
SUCCEEDED
(
reader
->
AcquireLatestFrame
(
&
frame
)))
{
delete
currentControlerPos
;
currentControlerPos
=
steamTracking
->
getTransformationForDevice
(
0
);
if
(
writeFrameInVector
)
{
snapshotPoints
.
clear
();
...
...
@@ -151,10 +193,9 @@ void getKinectData(bool writeFrameInVector) {
colors
.
reserve
(
colors
.
capacity
()
+
width
*
height
);
for
(
int
i
=
0
;
i
<
width
*
height
;
i
++
)
{
glm
::
mat3x4
transform
=
steamTracking
->
getTransformationForDevice
(
0
);
points
.
push_back
(
transform
*
framePositions
[
i
]);
colors
.
push_back
(
frame
Colors
[
i
]);
points
.
push_back
(
*
currentControlerPos
*
framePositions
[
i
]);
colors
.
push_back
(
snapshot
Colors
[
i
]);
}
...
...
@@ -203,23 +244,27 @@ void writePointCloud() {
void
rotateCamera
()
{
static
double
angle
=
0.
;
static
double
radius
=
3
.
;
static
double
radius
=
4
.
;
double
x
=
radius
*
sin
(
angle
);
double
z
=
radius
*
(
1
-
cos
(
angle
))
-
radius
/
2
;
glMatrixMode
(
GL_MODELVIEW
);
glLoadIdentity
();
gluLookAt
(
x
,
0
,
z
,
0
,
0
,
radius
/
2
,
0
,
1
,
0
);
//angle += 0.002;
//gluLookAt(x,0,z,0,0,radius/2,0,1,0);
angle
+=
0.002
;
}
void
drawKinectData
()
{
getKinectData
(
writeFile
);
getKinectData
(
captureFrame
);
captureFrame
=
false
;
if
(
writeFile
)
{
writePointCloud
();
writeFile
=
false
;
}
glMatrixMode
(
GL_MODELVIEW
);
glLoadIdentity
();
rotateCamera
();
glClear
(
GL_COLOR_BUFFER_BIT
|
GL_DEPTH_BUFFER_BIT
);
...
...
@@ -235,6 +280,15 @@ void drawKinectData() {
glPointSize
(
1.
f
);
glDrawArrays
(
GL_POINTS
,
0
,
width
*
height
);
glPushMatrix
();
float
scale
=
1.0
/
10
;
glScalef
(
scale
,
scale
,
scale
);
//drawArrow();
glColor4f
(
1.0
f
,
0.0
f
,
0.0
f
,
1.0
f
);
glutSolidTeapot
(
1
);
glPopMatrix
();
glDisableClientState
(
GL_VERTEX_ARRAY
);
glDisableClientState
(
GL_COLOR_ARRAY
);
...
...
@@ -244,6 +298,9 @@ void keyPressed(unsigned char key, int x, int y)
{
switch
(
key
)
{
case
'a'
:
captureFrame
=
true
;
break
;
case
's'
:
writeFile
=
true
;
break
;
default:
...
...
@@ -254,6 +311,7 @@ void keyPressed(unsigned char key, int x, int y)
instantly */
}
int
main
(
int
argc
,
char
*
argv
[])
{
std
::
cout
<<
"Starting Kinect VR Point Cloud creator"
;
if
(
!
init
(
argc
,
argv
))
return
1
;
...
...
@@ -282,6 +340,7 @@ int main(int argc, char* argv[]) {
glBindBuffer
(
GL_ARRAY_BUFFER
,
cboId
);
glBufferData
(
GL_ARRAY_BUFFER
,
dataSize
,
0
,
GL_DYNAMIC_DRAW
);
// Camera setup
glViewport
(
0
,
0
,
width
,
height
);
glMatrixMode
(
GL_PROJECTION
);
...
...
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