Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
ar_sandbox_app
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AR_Sandbox
ar_sandbox_app
Commits
a12a9bd5
Commit
a12a9bd5
authored
4 years ago
by
simon.fanetti
Browse files
Options
Downloads
Patches
Plain Diff
fixed color
parent
c18de7e4
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/app.cpp
+29
-23
29 additions, 23 deletions
app/app.cpp
with
29 additions
and
23 deletions
app/app.cpp
+
29
−
23
View file @
a12a9bd5
...
...
@@ -30,34 +30,34 @@ int main(int argc, char *argv[])
void
showLevel
(){
float
top
=
sandbox
.
getProjection
()
->
getDistanceTopSandbox
();
float
sandboxHeight
=
0.
1
f
;
float
sandboxHeight
=
0.
2
f
;
char
windowName
[]
=
"Sandbox"
;
cv
::
namedWindow
(
windowName
,
CV_WINDOW_NORMAL
);
cv
::
setWindowProperty
(
windowName
,
CV_WND_PROP_FULLSCREEN
,
CV_WINDOW_FULLSCREEN
);
//
// Debug
//
/*
CALLGRIND_START_INSTRUMENTATION;
CALLGRIND_TOGGLE_COLLECT;
sandbox.captureFrame();
cv::Mat depth = sandbox.getDepthFrame();
cv::Mat colored = colorizeDepth(depth, top, sandboxHeight);
cv::Mat res;
cv::cvtColor(colored, res, CV_BGR2RGB);
CALLGRIND_START_INSTRUMENTATION;
CALLGRIND_TOGGLE_COLLECT;
res = sandbox.adjustProjection(res);
cv::imshow(windowName, res);
cv::destroyAllWindows();
CALLGRIND_TOGGLE_COLLECT;
CALLGRIND_STOP_INSTRUMENTATION;
cv::imshow(windowName, res);
*/
*/
//
...
...
@@ -65,9 +65,18 @@ void showLevel(){
//
const
float
depth_margin
=
0.02
f
;
sandbox
.
captureFrame
();
cv
::
Mat
depth
=
sandbox
.
getDepthFrame
();
do
{
sandbox
.
captureFrame
();
cv
::
Mat
depth
=
sandbox
.
getDepthFrame
();
//cv::Mat new_depth = sandbox.getDepthFrame();
//cv::Mat mask_diff = cv::abs(depth-new_depth) > depth_margin;
//if(cv::countNonZero(mask_diff))
// depth.setTo(new_depth, mask_diff);
cv
::
Mat
colored
=
colorizeDepth
(
depth
,
top
,
sandboxHeight
);
cv
::
Mat
res
;
cv
::
cvtColor
(
colored
,
res
,
CV_BGR2RGB
);
...
...
@@ -77,14 +86,9 @@ void showLevel(){
cv
::
imshow
(
windowName
,
res
);
}
while
(
cv
::
waitKey
(
10
)
!=
ESCAPE_CHAR
);
cv
::
destroyAllWindows
();
//
// End
//
cv
::
destroyAllWindows
();
}
/*
...
...
@@ -93,8 +97,8 @@ void showLevel(){
cv
::
Mat
colorizeDepth
(
cv
::
Mat
depth
,
float
sandboxTop
,
float
sandboxHeight
){
// matrix with depth from 0 to n, where 0 is the lowest point
cv
::
Mat
normalizedDepth
=
(
depth
-
sandboxTop
)
*
-
1.0
f
+
sandboxHeight
;
normalizedDepth
.
setTo
(
0
.0
f
,
normalizedDepth
<
0
.0
f
);
cv
::
Mat
normalizedDepth
=
depth
*
-
1.0
f
+
(
sandboxTop
+
sandboxHeight
)
;
normalizedDepth
.
setTo
(
0
,
normalizedDepth
<
0
);
normalizedDepth
.
setTo
(
sandboxHeight
,
normalizedDepth
>
sandboxHeight
);
cv
::
Mat
res
=
cv
::
Mat
(
depth
.
rows
,
depth
.
cols
,
CV_8UC3
);
...
...
@@ -144,14 +148,16 @@ cv::Scalar floatToColor(float value, float min, float max){
float
relative
=
clamped
-
min
;
float
relativeMax
=
max
-
min
;
uint
colorMax
=
4
*
CHANNEL_MAX
;
uint
color
=
static_cast
<
uint
>
(
relative
*
colorMax
/
relativeMax
);
int
index
=
static_cast
<
uint
>
(
color
/
CHANNEL_MAX
);
const
uint
COLOR_MAX
=
4
*
(
CHANNEL_MAX
+
1
)
-
1
;
uint
color
=
static_cast
<
uint
>
(
relative
*
COLOR_MAX
/
relativeMax
);
uint
index
=
static_cast
<
uint
>
(
color
/
(
CHANNEL_MAX
+
1
));
// red at the highest point, blue at the lowest
uint8_t
r
=
static_cast
<
uint8_t
>
(
initColors
[
index
][
0
]
+
coeffColors
[
index
][
0
]
*
(
color
%
CHANNEL_MAX
)
);
uint8_t
g
=
static_cast
<
uint8_t
>
(
initColors
[
index
][
1
]
+
coeffColors
[
index
][
1
]
*
(
color
%
CHANNEL_MAX
)
);
uint8_t
b
=
static_cast
<
uint8_t
>
(
initColors
[
index
][
2
]
+
coeffColors
[
index
][
2
]
*
(
color
%
CHANNEL_MAX
)
);
uint8_t
r
=
static_cast
<
uint8_t
>
(
initColors
[
index
][
0
]
+
coeffColors
[
index
][
0
]
*
(
color
%
(
CHANNEL_MAX
+
1
)
)
);
uint8_t
g
=
static_cast
<
uint8_t
>
(
initColors
[
index
][
1
]
+
coeffColors
[
index
][
1
]
*
(
color
%
(
CHANNEL_MAX
+
1
)
)
);
uint8_t
b
=
static_cast
<
uint8_t
>
(
initColors
[
index
][
2
]
+
coeffColors
[
index
][
2
]
*
(
color
%
(
CHANNEL_MAX
+
1
)
)
);
return
cv
::
Scalar
(
r
,
g
,
b
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment