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
2d2de864
Commit
2d2de864
authored
Aug 09, 2017
by
wester
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added depth scanning
parent
dd34cf23
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
18 deletions
+53
-18
KinectTutorial3.sln
3_PointCloud/KinectTutorial3.sln
+4
-2
example.pnts
3_PointCloud/example.pnts
+0
-0
main.cpp
3_PointCloud/main.cpp
+49
-16
No files found.
3_PointCloud/KinectTutorial3.sln
View file @
2d2de864
Microsoft Visual Studio Solution File, Format Version 11.00
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2010
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "KinectTutorial3", "KinectTutorial3.vcxproj", "{AFFAABC2-707F-4CE0-87D1-CCA550249103}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "KinectTutorial3", "KinectTutorial3.vcxproj", "{AFFAABC2-707F-4CE0-87D1-CCA550249103}"
EndProject
EndProject
Global
Global
...
...
3_PointCloud/example.pnts
View file @
2d2de864
No preview for this file type
3_PointCloud/main.cpp
View file @
2d2de864
...
@@ -29,6 +29,7 @@ CameraSpacePoint depth2xyz[width*height]; // Maps depth pixels to 3d coordina
...
@@ -29,6 +29,7 @@ CameraSpacePoint depth2xyz[width*height]; // Maps depth pixels to 3d coordina
//buffers of the current frame
//buffers of the current frame
glm
::
vec3
framePositions
[
width
*
height
];
glm
::
vec3
framePositions
[
width
*
height
];
glm
::
vec3
frameNormals
[
width
*
height
];
glm
::
vec3
frameNormals
[
width
*
height
];
float
frameDepthDifference
[
width
*
height
];
unsigned
char
frameColors
[
width
*
height
*
3
];
unsigned
char
frameColors
[
width
*
height
*
3
];
bool
frameValidPoints
[
width
*
height
];
bool
frameValidPoints
[
width
*
height
];
...
@@ -64,7 +65,7 @@ std::vector<glm::vec3> controllerPositions;
...
@@ -64,7 +65,7 @@ std::vector<glm::vec3> controllerPositions;
bool
toggleCam
=
fals
e
;
bool
toggleCam
=
tru
e
;
Camera
mainCam
;
Camera
mainCam
;
static
bool
trackControllerPos
=
true
;
static
bool
trackControllerPos
=
true
;
...
@@ -178,17 +179,32 @@ void getDepthData(IMultiSourceFrame* frame) {
...
@@ -178,17 +179,32 @@ void getDepthData(IMultiSourceFrame* frame) {
unsigned
int
i
=
x
+
y
*
width
;
unsigned
int
i
=
x
+
y
*
width
;
framePositions
[
i
]
=
glm
::
vec3
(
depth2xyz
[
i
].
X
,
depth2xyz
[
i
].
Y
,
depth2xyz
[
i
].
Z
);
framePositions
[
i
]
=
glm
::
vec3
(
depth2xyz
[
i
].
X
,
depth2xyz
[
i
].
Y
,
depth2xyz
[
i
].
Z
);
if
(
x
>
0
&&
y
>
0
&&
x
<
width
-
1
&&
y
<
height
-
1
)
{
if
(
x
>
0
&&
y
>
0
&&
x
<
width
-
1
&&
y
<
height
-
1
)
{
//normalen
float
dzdx
=
(
curr
[
x
+
1
+
width
*
y
]
-
curr
[
x
-
1
+
width
*
y
])
/
2.0
;
float
dzdx
=
(
curr
[
x
+
1
+
width
*
y
]
-
curr
[
x
-
1
+
width
*
y
])
/
2.0
;
float
dzdy
=
(
curr
[
x
+
width
*
(
y
+
1
)]
-
curr
[
x
+
width
*
(
y
-
1
)])
/
2.0
;
float
dzdy
=
(
curr
[
x
+
width
*
(
y
+
1
)]
-
curr
[
x
+
width
*
(
y
-
1
)])
/
2.0
;
glm
::
vec3
d
(
-
dzdx
,
-
dzdy
,
1.0
f
);
glm
::
vec3
d
(
-
dzdx
,
-
dzdy
,
1.0
f
);
frameNormals
[
i
]
=
normalize
(
d
);
frameNormals
[
i
]
=
normalize
(
d
);
// dz tiefenwert
float
z
=
depth2xyz
[
i
].
Z
;
if
(
true
)
{
frameDepthDifference
[
i
]
=
(
depth2xyz
[
x
+
1
+
width
*
(
y
)].
Z
-
z
)
*
(
depth2xyz
[
x
+
1
+
width
*
(
y
)].
Z
-
z
)
+
(
depth2xyz
[
x
-
1
+
width
*
(
y
)].
Z
-
z
)
*
(
depth2xyz
[
x
-
1
+
width
*
(
y
)].
Z
-
z
)
+
(
depth2xyz
[
x
+
width
*
(
y
+
1
)].
Z
-
z
)
*
(
depth2xyz
[
x
+
width
*
(
y
+
1
)].
Z
-
z
)
+
(
depth2xyz
[
x
+
width
*
(
y
-
1
)].
Z
-
z
)
*
(
depth2xyz
[
x
+
width
*
(
y
-
1
)].
Z
-
z
);
}
else
{
frameDepthDifference
[
i
];
}
//if (x == width / 2 && y == height / 2) std::cout << "Frame Difference " << frameDepthDifference[i]<< std::endl;
}
}
else
{
else
{
frameNormals
[
i
]
=
glm
::
vec3
(
0.0
,
0.0
,
1.0
);
frameNormals
[
i
]
=
glm
::
vec3
(
0.0
,
0.0
,
1.0
);
frameDepthDifference
[
i
]
=
0.0
f
;
}
}
}
}
}
}
...
@@ -245,13 +261,24 @@ void getRgbData(IMultiSourceFrame* frame) {
...
@@ -245,13 +261,24 @@ void getRgbData(IMultiSourceFrame* frame) {
*
fvalid
++
=
false
;
*
fvalid
++
=
false
;
continue
;
continue
;
}
}
if
(
frameDepthDifference
[
i
]
>
100.0
)
{
*
fdest
++
=
255
;
*
fdest
++
=
140
;
*
fdest
++
=
0
;
*
fvalid
++
=
false
;
continue
;
}
float
angle
=
dot
(
frameNormals
[
i
],
glm
::
vec3
(
0.0
,
0.0
,
1.0
));
float
angle
=
dot
(
frameNormals
[
i
],
glm
::
vec3
(
0.0
,
0.0
,
1.0
));
if
(
angle
<
0.
1
)
{
if
(
angle
<
0.
05
)
{
*
fdest
++
=
0
;
*
fdest
++
=
0
;
*
fdest
++
=
0
;
*
fdest
++
=
0
;
*
fdest
++
=
255
;
*
fdest
++
=
255
;
*
fvalid
++
=
false
;
*
fvalid
++
=
false
;
continue
;
}
}
else
{
else
{
int
idx
=
(
int
)
p
.
X
+
colorwidth
*
(
int
)
p
.
Y
;
int
idx
=
(
int
)
p
.
X
+
colorwidth
*
(
int
)
p
.
Y
;
...
@@ -440,9 +467,13 @@ void mainRenderLoop() {
...
@@ -440,9 +467,13 @@ void mainRenderLoop() {
glLoadIdentity
();
glLoadIdentity
();
//rotateCamera(); //todo
//rotateCamera(); //todo
if
(
toggleCam
&&
trackControllerPos
)
{
if
(
toggleCam
&&
trackControllerPos
)
{
glMultMatrixf
(
glm
::
value_ptr
(
*
currentControlerPos
));
glMultMatrixf
(
glm
::
value_ptr
(
controlerToKinect
));
glTranslatef
(
0.0
,
-
0.3
,
-
1.0
);
glRotatef
(
180.0
,
0.0
,
0.0
,
1.0
);
glRotatef
(
10.0
,
1.0
,
0.0
,
0.0
);
glRotatef
(
180.0
,
0.0
,
1.0
,
0.0
);
glMultMatrixf
(
glm
::
value_ptr
(
glm
::
inverse
(
controlerToKinect
)));
glMultMatrixf
(
glm
::
value_ptr
(
glm
::
inverse
(
*
currentControlerPos
)));
//
}
}
else
{
else
{
mainCam
.
applyMatrix
();
mainCam
.
applyMatrix
();
...
@@ -636,9 +667,9 @@ int main(int argc, char* argv[]) {
...
@@ -636,9 +667,9 @@ int main(int argc, char* argv[]) {
controlerToKinect
=
glm
::
rotate
(
controlerToKinect
,
degreeToRadioan
(
180.0
f
),
glm
::
vec3
(
0.0
f
,
1.0
f
,
0.0
f
));
controlerToKinect
=
glm
::
rotate
(
controlerToKinect
,
degreeToRadioan
(
180.0
f
),
glm
::
vec3
(
0.0
f
,
1.0
f
,
0.0
f
));
//controlerToKinect = glm::rotate(controlerToKinect, degreeToRadioan(180.0f), glm::vec3(0.0f, 0.0f, 1.0f));
//controlerToKinect = glm::rotate(controlerToKinect, degreeToRadioan(180.0f), glm::vec3(0.0f, 0.0f, 1.0f));
float
dx
=
0.0
;
// KinectOriginOffsetX - KinectSizeX / 2;
float
dx
=
0.0
0
;
// KinectOriginOffsetX - KinectSizeX / 2;
float
dy
=
KinectSizeY
/
2.0
f
+
0.004
/*HAlterung Platte*/
+
0.011
/* Conroller*/
;
float
dy
=
KinectSizeY
/
2.0
f
+
0.004
/*HAlterung Platte*/
+
0.011
/* Conroller*/
;
// -0.01;
float
dz
=
0.0
;
//-0.023 + 0.02; // 0.045f /*= versatz auf der Halterung; Distanz zur Halterung:*/ + (KinectSizeZ - (0.066 /*halterung z*/ - 0.012 /*halterung berstand*/));
float
dz
=
0.0
0
;
//-0.023 + 0.02; // 0.045f /*= versatz auf der Halterung; Distanz zur Halterung:*/ + (KinectSizeZ - (0.066 /*halterung z*/ - 0.012 /*halterung berstand*/));
controlerToKinect
=
glm
::
translate
(
controlerToKinect
,
(
glm
::
vec3
(
dx
,
-
dy
,
dz
)));
controlerToKinect
=
glm
::
translate
(
controlerToKinect
,
(
glm
::
vec3
(
dx
,
-
dy
,
dz
)));
...
@@ -745,18 +776,19 @@ void setupGrid()
...
@@ -745,18 +776,19 @@ void setupGrid()
{
//init Grid
{
//init Grid
std
::
vector
<
glm
::
vec3
>
grid
;
std
::
vector
<
glm
::
vec3
>
grid
;
std
::
vector
<
unsigned
char
>
gridcolors
;
std
::
vector
<
unsigned
char
>
gridcolors
;
for
(
int
i
=
-
20
;
i
<
21
;
i
++
)
for
(
int
i
=
-
20
;
i
<
21
;
i
++
)
{
{
grid
.
push_back
(
glm
::
vec3
(
20
,
0
,
i
));
grid
.
push_back
(
glm
::
vec3
(
20
,
0
,
i
));
grid
.
push_back
(
glm
::
vec3
(
-
20
,
0
,
i
));
grid
.
push_back
(
glm
::
vec3
(
-
20
,
0
,
i
));
gridcolors
.
push_back
(
255
);
gridcolors
.
push_back
(
i
==
0
?
0
:
255
);
gridcolors
.
push_back
(
i
==
0
?
0
:
255
);
gridcolors
.
push_back
(
i
==
0
?
0
:
255
);
gridcolors
.
push_back
(
i
==
0
?
0
:
255
);
gridcolors
.
push_back
(
255
);
gridcolors
.
push_back
(
255
);
gridcolors
.
push_back
(
i
==
0
?
0
:
255
);
gridcolors
.
push_back
(
i
==
0
?
0
:
255
);
gridcolors
.
push_back
(
i
==
0
?
0
:
255
);
gridcolors
.
push_back
(
i
==
0
?
0
:
255
);
gridcolors
.
push_back
(
255
);
}
}
for
(
int
i
=
-
20
;
i
<
21
;
i
++
)
for
(
int
i
=
-
20
;
i
<
21
;
i
++
)
...
@@ -773,12 +805,13 @@ void setupGrid()
...
@@ -773,12 +805,13 @@ void setupGrid()
}
}
grid
.
push_back
(
glm
::
vec3
(
0
,
-
20
,
0
));
grid
.
push_back
(
glm
::
vec3
(
0
,
-
20
,
0
));
grid
.
push_back
(
glm
::
vec3
(
0
,
20
,
0
));
grid
.
push_back
(
glm
::
vec3
(
0
,
20
,
0
));
gridcolors
.
push_back
(
255
);
gridcolors
.
push_back
(
0
);
gridcolors
.
push_back
(
0
);
gridcolors
.
push_back
(
255
);
gridcolors
.
push_back
(
0
);
gridcolors
.
push_back
(
0
);
gridcolors
.
push_back
(
255
);
gridcolors
.
push_back
(
0
);
gridcolors
.
push_back
(
0
);
gridcolors
.
push_back
(
255
);
gridcolors
.
push_back
(
0
);
gridcolors
.
push_back
(
0
);
glGenBuffers
(
1
,
&
gridData
.
vboID
);
glGenBuffers
(
1
,
&
gridData
.
vboID
);
...
...
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