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
dd34cf23
Commit
dd34cf23
authored
Aug 03, 2017
by
wester
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
camera 2 and normals
parent
5668225e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
4 deletions
+48
-4
example.pnts
3_PointCloud/example.pnts
+0
-0
main.cpp
3_PointCloud/main.cpp
+48
-4
No files found.
3_PointCloud/example.pnts
View file @
dd34cf23
No preview for this file type
3_PointCloud/main.cpp
View file @
dd34cf23
...
@@ -28,6 +28,7 @@ CameraSpacePoint depth2xyz[width*height]; // Maps depth pixels to 3d coordina
...
@@ -28,6 +28,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
];
unsigned
char
frameColors
[
width
*
height
*
3
];
unsigned
char
frameColors
[
width
*
height
*
3
];
bool
frameValidPoints
[
width
*
height
];
bool
frameValidPoints
[
width
*
height
];
...
@@ -63,7 +64,7 @@ std::vector<glm::vec3> controllerPositions;
...
@@ -63,7 +64,7 @@ std::vector<glm::vec3> controllerPositions;
bool
toggleCam
=
false
;
Camera
mainCam
;
Camera
mainCam
;
static
bool
trackControllerPos
=
true
;
static
bool
trackControllerPos
=
true
;
...
@@ -165,12 +166,34 @@ void getDepthData(IMultiSourceFrame* frame) {
...
@@ -165,12 +166,34 @@ void getDepthData(IMultiSourceFrame* frame) {
unsigned
int
sz
;
unsigned
int
sz
;
unsigned
short
*
buf
;
unsigned
short
*
buf
;
depthframe
->
AccessUnderlyingBuffer
(
&
sz
,
&
buf
);
depthframe
->
AccessUnderlyingBuffer
(
&
sz
,
&
buf
);
const
unsigned
short
*
curr
=
(
const
unsigned
short
*
)
buf
;
// Write vertex coordinates
// Write vertex coordinates
mapper
->
MapDepthFrameToCameraSpace
(
width
*
height
,
buf
,
width
*
height
,
depth2xyz
);
mapper
->
MapDepthFrameToCameraSpace
(
width
*
height
,
buf
,
width
*
height
,
depth2xyz
);
for
(
unsigned
int
y
=
0
;
y
<
height
;
y
++
)
{
for
(
unsigned
int
x
=
0
;
x
<
width
;
x
++
)
{
unsigned
int
i
=
x
+
y
*
width
;
framePositions
[
i
]
=
glm
::
vec3
(
depth2xyz
[
i
].
X
,
depth2xyz
[
i
].
Y
,
depth2xyz
[
i
].
Z
);
if
(
x
>
0
&&
y
>
0
&&
x
<
width
-
1
&&
y
<
height
-
1
)
{
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
;
glm
::
vec3
d
(
-
dzdx
,
-
dzdy
,
1.0
f
);
frameNormals
[
i
]
=
normalize
(
d
);
}
else
{
frameNormals
[
i
]
=
glm
::
vec3
(
0.0
,
0.0
,
1.0
);
}
}
}
for
(
unsigned
int
i
=
0
;
i
<
sz
;
i
++
)
{
for
(
unsigned
int
i
=
0
;
i
<
sz
;
i
++
)
{
framePositions
[
i
]
=
glm
::
vec3
(
depth2xyz
[
i
].
X
,
depth2xyz
[
i
].
Y
,
depth2xyz
[
i
].
Z
);
}
}
// Fill in depth2rgb map
// Fill in depth2rgb map
...
@@ -206,19 +229,29 @@ void getRgbData(IMultiSourceFrame* frame) {
...
@@ -206,19 +229,29 @@ void getRgbData(IMultiSourceFrame* frame) {
for
(
int
i
=
0
;
i
<
width
*
height
;
i
++
)
{
for
(
int
i
=
0
;
i
<
width
*
height
;
i
++
)
{
ColorSpacePoint
p
=
depth2rgb
[
i
];
ColorSpacePoint
p
=
depth2rgb
[
i
];
// Check if color pixel coordinates are in bounds
// Check if color pixel coordinates are in bounds
if
(
p
.
X
<
0
||
p
.
Y
<
0
||
p
.
X
>
colorwidth
||
p
.
Y
>
colorheight
)
{
if
(
p
.
X
<
1
||
p
.
Y
<
1
||
p
.
X
>
colorwidth
-
1
||
p
.
Y
>
colorheight
-
1
)
{
*
fdest
++
=
255
;
*
fdest
++
=
255
;
*
fdest
++
=
0
;
*
fdest
++
=
0
;
*
fdest
++
=
0
;
*
fdest
++
=
0
;
*
fvalid
++
=
false
;
*
fvalid
++
=
false
;
}
}
else
{
else
{
if
(
depth2xyz
[
i
].
Z
>
maxTrackingKinect
||
depth2xyz
[
i
].
Z
<
minTrackingKinect
)
{
if
(
depth2xyz
[
i
].
Z
>
maxTrackingKinect
||
depth2xyz
[
i
].
Z
<
minTrackingKinect
)
{
*
fdest
++
=
0
;
*
fdest
++
=
0
;
*
fdest
++
=
255
;
*
fdest
++
=
255
;
*
fdest
++
=
0
;
*
fdest
++
=
0
;
*
fvalid
++
=
false
;
*
fvalid
++
=
false
;
continue
;
}
float
angle
=
dot
(
frameNormals
[
i
],
glm
::
vec3
(
0.0
,
0.0
,
1.0
));
if
(
angle
<
0.1
)
{
*
fdest
++
=
0
;
*
fdest
++
=
0
;
*
fdest
++
=
255
;
*
fvalid
++
=
false
;
}
}
else
{
else
{
int
idx
=
(
int
)
p
.
X
+
colorwidth
*
(
int
)
p
.
Y
;
int
idx
=
(
int
)
p
.
X
+
colorwidth
*
(
int
)
p
.
Y
;
...
@@ -406,7 +439,15 @@ void mainRenderLoop() {
...
@@ -406,7 +439,15 @@ void mainRenderLoop() {
glMatrixMode
(
GL_MODELVIEW
);
glMatrixMode
(
GL_MODELVIEW
);
glLoadIdentity
();
glLoadIdentity
();
//rotateCamera(); //todo
//rotateCamera(); //todo
mainCam
.
applyMatrix
();
if
(
toggleCam
&&
trackControllerPos
)
{
glMultMatrixf
(
glm
::
value_ptr
(
*
currentControlerPos
));
glMultMatrixf
(
glm
::
value_ptr
(
controlerToKinect
));
glRotatef
(
180.0
,
0.0
,
0.0
,
1.0
);
}
else
{
mainCam
.
applyMatrix
();
}
//glTranslatef(0.0, 5, 0.0);
//glTranslatef(0.0, 5, 0.0);
glClear
(
GL_COLOR_BUFFER_BIT
|
GL_DEPTH_BUFFER_BIT
);
glClear
(
GL_COLOR_BUFFER_BIT
|
GL_DEPTH_BUFFER_BIT
);
...
@@ -493,6 +534,9 @@ void keyPressed(unsigned char key, int x, int y)
...
@@ -493,6 +534,9 @@ void keyPressed(unsigned char key, int x, int y)
colors
.
clear
();
colors
.
clear
();
exportData
.
size
=
0
;
exportData
.
size
=
0
;
break
;
break
;
case
'q'
:
toggleCam
=
!
toggleCam
;
break
;
case
27
:
// Escape key
case
27
:
// Escape key
exit
(
0
);
exit
(
0
);
break
;
break
;
...
...
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