Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
masterarbeit-kai
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
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
Philipp Adolf
masterarbeit-kai
Commits
9887b6bc
Commit
9887b6bc
authored
Jul 14, 2017
by
Adrian Hoppe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
offset
parent
2004eaf1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
119 additions
and
152 deletions
+119
-152
Camera.cpp
3_PointCloud/Camera.cpp
+1
-1
Camera.h
3_PointCloud/Camera.h
+1
-1
main.cpp
3_PointCloud/main.cpp
+114
-150
Kinect for Windows V2 屋外で使うためのカバー製作.url
Kinect for Windows V2 屋外で使うためのカバー製作.url
+3
-0
No files found.
3_PointCloud/Camera.cpp
View file @
9887b6bc
...
...
@@ -6,7 +6,7 @@
Camera
::
Camera
()
:
Camera
(
vec3
(
10.0
f
,
5
.0
f
,
0.0
f
))
Camera
::
Camera
()
:
Camera
(
vec3
(
2.0
f
,
0
.0
f
,
0.0
f
))
{
}
...
...
3_PointCloud/Camera.h
View file @
9887b6bc
...
...
@@ -16,7 +16,7 @@ private:
glm
::
vec3
position
;
glm
::
vec3
up
;
float
speed
=
0
.
3
f
;
float
speed
=
0
.
1
f
;
float
mouseSpeed
=
0
.
005
f
;
float
horizontalAngle
=
(
float
)
-
M_PI
/
2
;
...
...
3_PointCloud/main.cpp
View file @
9887b6bc
...
...
@@ -15,6 +15,7 @@
#include <glm/vec3.hpp>
#include <glm/gtc/type_ptr.hpp>
#include "glm/gtc/matrix_transform.hpp"
#include <Kinect.h>
#include "Camera.h"
...
...
@@ -57,8 +58,15 @@ std::vector<unsigned char> colors;
IKinectSensor
*
sensor
;
// Kinect sensor
IMultiSourceFrameReader
*
reader
;
// Kinect data source
ICoordinateMapper
*
mapper
;
// Converts between depth, color, and 3d coordinates
float
KinectOriginOffsetX
=
((
92
+
73
)
/
2.0
f
)
/
1000.0
f
;
float
KinectOriginOffsetY
=
21
/
1000.0
f
;
float
KinectSizeX
=
0.249
;
float
KinectSizeY
=
0.066
;
float
KinectSizeZ
=
0.067
;
SteamTracking
*
steamTracking
=
nullptr
;
int
controllerID
=
3
;
glm
::
mat4x4
*
currentControlerPos
=
nullptr
;
glm
::
mat4x4
controlerToKinect
;
Camera
mainCam
;
...
...
@@ -69,33 +77,64 @@ static bool captureFrame = false;
int
lastX
,
lastY
;
void
drawArrow
()
{
void
DrawCoordinateSystem
()
{
//TETAEDRON BY HAND
glBegin
(
GL_
TRIANGL
ES
);
glBegin
(
GL_
LIN
ES
);
//front triangle
glColor4f
(
1.0
f
,
0.0
f
,
0.0
f
,
1.0
f
);
glVertex3f
(
0.0
f
,
0.0
f
,
0.0
f
);
glVertex3f
(
1.0
f
,
0.0
f
,
0.0
f
);
glColor4f
(
0.0
f
,
1.0
f
,
0.0
f
,
1.0
f
);
glVertex3f
(
0.0
f
,
0.0
f
,
0.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
);
glVertex3f
(
0.0
f
,
0.0
f
,
0.0
f
);
glVertex3f
(
0.0
f
,
0.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
);
glEnd
();
}
void
DrawKinect
()
{
glBegin
(
GL_QUADS
);
//links 82, 5 mm ist origin(siehe bild kinect mesures), kinect v2 : 24, 9 cm x 6, 6 cm x 6, 7cm
glColor4f
(
0.5
f
,
0.5
f
,
0.5
f
,
1.0
f
);
//front
glVertex3f
(
0.0
f
-
KinectOriginOffsetX
,
0.0
f
-
KinectOriginOffsetY
,
0.0
f
);
glVertex3f
(
KinectSizeX
-
KinectOriginOffsetX
,
0.0
f
-
KinectOriginOffsetY
,
0.0
f
);
glVertex3f
(
KinectSizeX
-
KinectOriginOffsetX
,
KinectSizeY
-
KinectOriginOffsetY
,
0.0
f
);
glVertex3f
(
0.0
f
-
KinectOriginOffsetX
,
KinectSizeY
-
KinectOriginOffsetY
,
0.0
f
);
//back
glVertex3f
(
0.0
f
-
KinectOriginOffsetX
,
0.0
f
-
KinectOriginOffsetY
,
-
KinectSizeZ
);
glVertex3f
(
KinectSizeX
-
KinectOriginOffsetX
,
0.0
f
-
KinectOriginOffsetY
,
-
KinectSizeZ
);
glVertex3f
(
KinectSizeX
-
KinectOriginOffsetX
,
KinectSizeY
-
KinectOriginOffsetY
,
-
KinectSizeZ
);
glVertex3f
(
0.0
f
-
KinectOriginOffsetX
,
KinectSizeY
-
KinectOriginOffsetY
,
-
KinectSizeZ
);
//sides
glVertex3f
(
0.0
f
-
KinectOriginOffsetX
,
0.0
f
-
KinectOriginOffsetY
,
0.0
f
);
glVertex3f
(
0.0
f
-
KinectOriginOffsetX
,
0.0
f
-
KinectOriginOffsetY
,
-
KinectSizeZ
);
glVertex3f
(
0.0
f
-
KinectOriginOffsetX
,
KinectSizeY
-
KinectOriginOffsetY
,
-
KinectSizeZ
);
glVertex3f
(
0.0
f
-
KinectOriginOffsetX
,
KinectSizeY
-
KinectOriginOffsetY
,
0.0
f
);
glVertex3f
(
KinectSizeX
-
KinectOriginOffsetX
,
0.0
f
-
KinectOriginOffsetY
,
0.0
f
);
glVertex3f
(
KinectSizeX
-
KinectOriginOffsetX
,
0.0
f
-
KinectOriginOffsetY
,
-
KinectSizeZ
);
glVertex3f
(
KinectSizeX
-
KinectOriginOffsetX
,
KinectSizeY
-
KinectOriginOffsetY
,
-
KinectSizeZ
);
glVertex3f
(
KinectSizeX
-
KinectOriginOffsetX
,
KinectSizeY
-
KinectOriginOffsetY
,
0.0
f
);
//top/bottom
glVertex3f
(
0.0
f
-
KinectOriginOffsetX
,
KinectSizeY
-
KinectOriginOffsetY
,
0.0
f
);
glVertex3f
(
0.0
f
-
KinectOriginOffsetX
,
KinectSizeY
-
KinectOriginOffsetY
,
-
KinectSizeZ
);
glVertex3f
(
KinectSizeX
-
KinectOriginOffsetX
,
KinectSizeY
-
KinectOriginOffsetY
,
-
KinectSizeZ
);
glVertex3f
(
KinectSizeX
-
KinectOriginOffsetX
,
KinectSizeY
-
KinectOriginOffsetY
,
0.0
f
);
glVertex3f
(
0.0
f
-
KinectOriginOffsetX
,
0.0
f
-
KinectOriginOffsetY
,
0.0
f
);
glVertex3f
(
0.0
f
-
KinectOriginOffsetX
,
0.0
f
-
KinectOriginOffsetY
,
-
KinectSizeZ
);
glVertex3f
(
KinectSizeX
-
KinectOriginOffsetX
,
0.0
f
-
KinectOriginOffsetY
,
-
KinectSizeZ
);
glVertex3f
(
KinectSizeX
-
KinectOriginOffsetX
,
0.0
f
-
KinectOriginOffsetY
,
0.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
();
}
...
...
@@ -288,8 +327,8 @@ void mainRenderLoop() {
//get controler pos
delete
currentControlerPos
;
currentControlerPos
=
steamTracking
->
getTransformationForDevice
(
1
);
currentControlerPos
=
steamTracking
->
getTransformationForDevice
(
controllerID
);
getKinectData
();
//add points to point cloud
...
...
@@ -313,51 +352,50 @@ void mainRenderLoop() {
glEnableClientState
(
GL_VERTEX_ARRAY
);
glEnableClientState
(
GL_COLOR_ARRAY
);
//draw Grid
glLineWidth
(
1.
f
);
drawElementArray
(
gridData
,
GL_LINES
);
//draw stored Point cloud
drawElementArray
(
exportData
,
GL_POINTS
);
{
// Controller Space
glPushMatrix
();
if
(
currentControlerPos
)
{
//applay controler Transformation
glMultMatrixf
(
glm
::
value_ptr
(
*
currentControlerPos
));
}
glDisableClientState
(
GL_COLOR_ARRAY
);
DrawCoordinateSystem
();
glPushMatrix
();
//draw current Frame
if
(
currentControlerPos
)
{
//applay controler Transformation
glMultMatrixf
(
glm
::
value_ptr
(
controlerToKinect
));
glMultMatrixf
(
glm
::
value_ptr
(
*
currentControlerPos
));
}
{
// draw controller
glColor4f
(
0.5
f
,
0.5
f
,
0.5
f
,
1.0
f
);
glPointSize
(
1.
f
);
drawElementArray
(
framePoints
,
GL_POINTS
);
glBindBuffer
(
GL_ARRAY_BUFFER
,
controllerData
.
vboID
);
glVertexPointer
(
3
,
GL_FLOAT
,
0
,
NULL
);
glBindBuffer
(
GL_ARRAY_BUFFER
,
controllerData
.
normals
);
glNormalPointer
(
GL_FLOAT
,
0
,
NULL
);
// draw hud arrow
//glTranslatef(0.0f, 1.5f, 0.0f);
float
scale
=
0.1
f
;
scale
=
1.0
f
;
glScalef
(
scale
,
scale
,
scale
);
// glRotatef(-90, 0.0, 1.0, 0.0);
glDrawElements
(
GL_TRIANGLES
,
controllerData
.
size
,
GL_UNSIGNED_SHORT
,
0
);
}
glDisableClientState
(
GL_COLOR_ARRAY
);
glColor4f
(
0.5
f
,
0.5
f
,
0.5
f
,
1.0
f
);
{
//Kinect Space
glPushMatrix
();
glMultMatrixf
(
glm
::
value_ptr
(
controlerToKinect
));
DrawCoordinateSystem
();
glBindBuffer
(
GL_ARRAY_BUFFER
,
controllerData
.
vboID
);
glVertexPointer
(
3
,
GL_FLOAT
,
0
,
NULL
);
glBindBuffer
(
GL_ARRAY_BUFFER
,
controllerData
.
vboID
);
glNormalPointer
(
GL_FLOAT
,
0
,
NULL
);
DrawKinect
();
glDrawElements
(
GL_TRIANGLES
,
controllerData
.
size
,
GL_UNSIGNED_SHORT
,
0
);
//glDrawArrays(GL_TRIANGLES, 0, controllerData.size);
glEnableClientState
(
GL_COLOR_ARRAY
);
//draw Frame Point cloud
glPointSize
(
1.
f
);
drawElementArray
(
framePoints
,
GL_POINTS
);
//drawArrow();
glColor4f
(
0.0
f
,
1.0
f
,
0.0
f
,
1.0
f
);
//glutSolidTeapot(1);
glPopMatrix
();
glPopMatrix
();
}
glPopMatrix
();
}
glDisableClientState
(
GL_VERTEX_ARRAY
);
glDisableClientState
(
GL_COLOR_ARRAY
);
...
...
@@ -407,6 +445,9 @@ void captureNextFrame(vr::VREvent_t event)
}
}
float
degreeToRadioan
(
float
degree
)
{
return
degree
*
M_PI
/
180.0
;
}
int
main
(
int
argc
,
char
*
argv
[])
{
std
::
cout
<<
"Starting Kinect VR Point Cloud creator
\n
"
;
...
...
@@ -451,7 +492,26 @@ int main(int argc, char* argv[]) {
//C:\Program Files (x86)\Steam\steamapps\common\SteamVR\resources\rendermodels\vr_controller_vive_1_5
//HKEY_CURRENT_USER/Software/Valve/SteamPath.
controlerToKinect
=
glm
::
translate
(
glm
::
mat4x4
(),
(
glm
::
vec3
(
-
4.0
f
,
4.0
f
,
12.0
f
)
*
0.01
f
));
controlerToKinect
=
glm
::
translate
(
glm
::
mat4x4
(),
(
glm
::
vec3
(
-
4.0
f
,
-
7.5
f
,
13.0
f
)
*
0.01
f
));
float
dx
=
KinectOriginOffsetX
-
KinectSizeX
/
2
;
float
dy
=
KinectSizeY
/
2
+
0.008
;
// dicke Halterung;
float
dz
=
0.0450
f
;
//TODO - offset nach hinten;
controlerToKinect
=
glm
::
translate
(
glm
::
mat4x4
(),
(
glm
::
vec3
(
0.0
f
,
0.0
f
,
0.24
f
)));
controlerToKinect
=
glm
::
rotate
(
controlerToKinect
,
degreeToRadioan
(
135.0
f
),
glm
::
vec3
(
1.0
f
,
0.0
f
,
0.0
f
));
controlerToKinect
=
glm
::
rotate
(
controlerToKinect
,
degreeToRadioan
(
180.0
f
),
glm
::
vec3
(
0.0
f
,
0.0
f
,
1.0
f
));
controlerToKinect
=
glm
::
translate
(
controlerToKinect
,
(
glm
::
vec3
(
dx
,
-
dy
,
dz
)));
std
::
cout
<<
"Kinect to center: "
<<
dx
<<
" "
<<
dy
<<
" "
<<
dz
;
// x kinect mitte =
//
...
...
@@ -463,6 +523,7 @@ int main(int argc, char* argv[]) {
loadAssImp
(
"C:
\\
Program Files (x86)
\\
Steam
\\
steamapps
\\
common
\\
SteamVR
\\
resources
\\
rendermodels
\\
vr_controller_vive_1_5
\\
vr_controller_vive_1_5.obj"
,
indices
,
out_vertices
,
out_uvs
,
out_normals
);
glGenBuffers
(
1
,
&
controllerData
.
vboID
);
glBindBuffer
(
GL_ARRAY_BUFFER
,
controllerData
.
vboID
);
glBufferData
(
GL_ARRAY_BUFFER
,
out_vertices
.
size
()
*
sizeof
(
glm
::
vec3
),
&
out_vertices
[
0
],
GL_STATIC_DRAW
);
...
...
@@ -567,103 +628,6 @@ void setupGrid()
}
}
void
setupArrow
()
{
static
GLfloat
g_vertex_buffer_data
[]
=
{
-
1.0
f
,
-
1.0
f
,
-
1.0
f
,
// triangle 1 : begin
-
1.0
f
,
-
1.0
f
,
1.0
f
,
-
1.0
f
,
1.0
f
,
1.0
f
,
// triangle 1 : end
1.0
f
,
1.0
f
,
-
1.0
f
,
// triangle 2 : begin
-
1.0
f
,
-
1.0
f
,
-
1.0
f
,
-
1.0
f
,
1.0
f
,
-
1.0
f
,
// triangle 2 : end
1.0
f
,
-
1.0
f
,
1.0
f
,
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
f
,
0.596
f
,
0.789
f
,
0.559
f
,
0.861
f
,
0.639
f
,
0.195
f
,
0.548
f
,
0.859
f
,
0.014
f
,
0.184
f
,
0.576
f
,
0.771
f
,
0.328
f
,
0.970
f
,
0.406
f
,
0.615
f
,
0.116
f
,
0.676
f
,
0.977
f
,
0.133
f
,
0.971
f
,
0.572
f
,
0.833
f
,
0.140
f
,
0.616
f
,
0.489
f
,
0.997
f
,
0.513
f
,
0.064
f
,
0.945
f
,
0.719
f
,
0.592
f
,
0.543
f
,
0.021
f
,
0.978
f
,
0.279
f
,
0.317
f
,
0.505
f
,
0.167
f
,
0.620
f
,
0.077
f
,
0.347
f
,
0.857
f
,
0.137
f
,
0.055
f
,
0.953
f
,
0.042
f
,
0.714
f
,
0.505
f
,
0.345
f
,
0.783
f
,
0.290
f
,
0.734
f
,
0.722
f
,
0.645
f
,
0.174
f
,
0.302
f
,
0.455
f
,
0.848
f
,
0.225
f
,
0.587
f
,
0.040
f
,
0.517
f
,
0.713
f
,
0.338
f
,
0.053
f
,
0.959
f
,
0.120
f
,
0.393
f
,
0.621
f
,
0.362
f
,
0.673
f
,
0.211
f
,
0.457
f
,
0.820
f
,
0.883
f
,
0.371
f
,
0.982
f
,
0.099
f
,
0.879
f
};
std
::
vector
<
unsigned
char
>
gridcolors
;
for
(
int
i
=
0
;
i
<
108
;
i
++
)
{
gridcolors
.
push_back
((
unsigned
char
)(
g_color_buffer_data
[
i
]
*
255
));
}
glGenBuffers
(
1
,
&
arrowData
.
vboID
);
glBindBuffer
(
GL_ARRAY_BUFFER
,
gridData
.
vboID
);
glBufferData
(
GL_ARRAY_BUFFER
,
108
*
sizeof
(
float
),
g_vertex_buffer_data
,
GL_STATIC_DRAW
);
glGenBuffers
(
1
,
&
gridData
.
cboID
);
glBindBuffer
(
GL_ARRAY_BUFFER
,
gridData
.
cboID
);
glBufferData
(
GL_ARRAY_BUFFER
,
gridcolors
.
size
()
*
sizeof
(
unsigned
char
),
&
gridcolors
[
0
],
GL_STATIC_DRAW
);
arrowData
.
size
=
108
;
}
void
close
()
{
delete
steamTracking
;
}
...
...
Kinect for Windows V2 屋外で使うためのカバー製作.url
0 → 100644
View file @
9887b6bc
[InternetShortcut]
[InternetShortcut]
URL=https://social.msdn.microsoft.com/Forums/sqlserver/ja-JP/05a6d2b3-9096-4236-b77a-691c5f047066/kinect-for-windows-v2-?forum=windowsgeneraldevelopmentissuesja
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