Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
ar_sandbox_lib
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_lib
Commits
3df03d1a
Commit
3df03d1a
authored
4 years ago
by
simon.fanetti
Browse files
Options
Downloads
Patches
Plain Diff
fixe adjustFrame
parent
f4e8f3f1
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Makefile
+2
-0
2 additions, 0 deletions
Makefile
inc/projection.h
+1
-1
1 addition, 1 deletion
inc/projection.h
src/components/projection.cpp
+31
-24
31 additions, 24 deletions
src/components/projection.cpp
with
34 additions
and
25 deletions
Makefile
+
2
−
0
View file @
3df03d1a
all
:
$(
MAKE
)
-C
src
$(
MAKE
)
-C
build
app
:
$(
MAKE
)
-C
app
clean
:
...
...
This diff is collapsed.
Click to expand it.
inc/projection.h
+
1
−
1
View file @
3df03d1a
...
...
@@ -11,7 +11,7 @@ class Projection{
float
distanceTopSandbox
;
void
deprojectPixelsFromDepth
(
cv
::
Mat
&
depth
,
cv
::
Rect
mask
,
Camera
*
camera
,
cv
::
Point3f
beamer_pos
,
cv
::
Mat
&
pixelsDeprojectMap
);
void
filter
High
estDeprojectedPoints
(
cv
::
Mat
&
depth
,
cv
::
Mat
&
pixelsD
eprojectMap
,
cv
::
Mat
&
pixelsDeprojectHighestMap
);
void
filter
Low
estDeprojectedPoints
(
cv
::
Mat
&
depth
,
cv
::
Mat
&
d
eprojectMap
,
cv
::
Mat
&
frameMapMask
);
void
buildFrame
(
cv
::
Mat
&
depth
,
cv
::
Mat
&
pixelsDeprojectHighestMap
,
cv
::
Mat
&
src
,
cv
::
Mat
&
dst
);
cv
::
Point2i
findMatchingPixel
(
int
i
,
int
j
,
float
z
,
Camera
*
camera
,
cv
::
Point3f
beamer_pos
);
void
copyPixelsInto
(
cv
::
Point2i
pixel_dst
,
cv
::
Mat
&
dst
,
cv
::
Point2i
pixel_src
,
cv
::
Mat
&
src
,
cv
::
Mat
&
depth
);
...
...
This diff is collapsed.
Click to expand it.
src/components/projection.cpp
+
31
−
24
View file @
3df03d1a
...
...
@@ -39,16 +39,16 @@ void Projection::adjustFrame(cv::Mat depth, cv::Mat src, cv::Mat &dst, Camera *c
cv
::
resize
(
dst
,
dst
,
getMatchingSize
(
dst
,
mask
));
cv
::
resize
(
src
,
src
,
dst
.
size
());
cv
::
Mat
pixelsD
eprojectMap
=
cv
::
Mat_
<
cv
::
Point2i
>
(
mask
.
height
,
mask
.
width
,
cv
::
Point2i
(
-
1
,
-
1
));
cv
::
Mat
pixelsDeprojectHighestMap
=
cv
::
Mat_
<
cv
::
Point2i
>
(
mask
.
height
,
mask
.
width
,
cv
::
Point2i
(
-
1
,
-
1
));
cv
::
Mat
d
eprojectMap
=
cv
::
Mat_
<
cv
::
Point2i
>
(
mask
.
height
,
mask
.
width
,
cv
::
Point2i
(
-
1
,
-
1
));
cv
::
Mat
frameMapMask
=
cv
::
Mat_
<
cv
::
Point2i
>
(
mask
.
height
,
mask
.
width
,
cv
::
Point2i
(
-
1
,
-
1
));
deprojectPixelsFromDepth
(
depth
,
mask
,
camera
,
beamer_pos
,
pixelsD
eprojectMap
);
deprojectPixelsFromDepth
(
depth
,
mask
,
camera
,
beamer_pos
,
d
eprojectMap
);
filter
High
estDeprojectedPoints
(
depth
,
pixelsD
eprojectMap
,
pixelsDeprojectHighestMap
);
filter
Low
estDeprojectedPoints
(
depth
,
d
eprojectMap
,
frameMapMask
);
// TODO : Holefilling method
buildFrame
(
depth
,
frameMapMask
,
src
,
dst
);
buildFrame
(
depth
,
pixelsDeprojectHighestMap
,
src
,
dst
);
// TODO : Holefilling method
cv
::
resize
(
dst
,
dst
,
dst_size
);
cv
::
warpAffine
(
dst
,
dst
,
adjustingMatrix
,
dst
.
size
());
...
...
@@ -60,7 +60,7 @@ void Projection::adjustFrame(cv::Mat depth, cv::Mat src, cv::Mat &dst, Camera *c
* PRIVATE
*/
void
Projection
::
deprojectPixelsFromDepth
(
cv
::
Mat
&
depth
,
cv
::
Rect
mask
,
Camera
*
camera
,
cv
::
Point3f
beamer_pos
,
cv
::
Mat
&
pixelsD
eprojectMap
){
void
Projection
::
deprojectPixelsFromDepth
(
cv
::
Mat
&
depth
,
cv
::
Rect
mask
,
Camera
*
camera
,
cv
::
Point3f
beamer_pos
,
cv
::
Mat
&
d
eprojectMap
){
// Browse the depth frame matching the cropping mask
// while adapting pixels's position to the beamer's position
...
...
@@ -79,43 +79,50 @@ void Projection::deprojectPixelsFromDepth(cv::Mat &depth, cv::Rect mask, Camera
pixel
.
x
-=
mask
.
x
;
pixel
.
y
-=
mask
.
y
;
pixelsD
eprojectMap
.
at
<
cv
::
Point2i
>
(
j
,
i
)
=
pixel
;
d
eprojectMap
.
at
<
cv
::
Point2i
>
(
j
,
i
)
=
pixel
;
}
}
}
void
Projection
::
filter
High
estDeprojectedPoints
(
cv
::
Mat
&
depth
,
cv
::
Mat
&
pixelsD
eprojectMap
,
cv
::
Mat
&
pixelsDeprojectHighestMap
){
void
Projection
::
filter
Low
estDeprojectedPoints
(
cv
::
Mat
&
depth
,
cv
::
Mat
&
d
eprojectMap
,
cv
::
Mat
&
frameMapMask
){
for
(
int
j
=
0
;
j
<
pixelsD
eprojectMap
.
rows
;
j
++
){
for
(
int
i
=
0
;
i
<
pixelsD
eprojectMap
.
cols
;
i
++
){
for
(
int
j
=
0
;
j
<
d
eprojectMap
.
rows
;
j
++
){
for
(
int
i
=
0
;
i
<
d
eprojectMap
.
cols
;
i
++
){
cv
::
Point2i
pixel
=
pixelsDeprojectMap
.
at
<
cv
::
Point2i
>
(
j
,
i
);
// coords of the new pixel
cv
::
Point2i
deprojectedPixel
=
deprojectMap
.
at
<
cv
::
Point2i
>
(
j
,
i
);
cv
::
Point2i
highestDepthPixel
=
cv
::
Point2i
(
i
,
j
);
if
(
pixel
.
x
!=
-
1
&&
pixel
.
y
!=
-
1
){
if
(
(
0
<=
deprojectedPixel
.
x
&&
deprojectedPixel
.
x
<
depth
.
cols
)
&&
(
0
<=
deprojectedPixel
.
y
&&
deprojectedPixel
.
y
<
depth
.
rows
)
){
// check and keep the highest point at the location pointed by pixel
cv
::
Point2i
defaultPoint
=
pixelsDeprojectHighestMap
.
at
<
cv
::
Point2i
>
(
j
,
i
);
if
(
defaultPoint
.
x
!=
-
1
&&
defaultPoint
.
y
!=
-
1
){
if
(
depth
.
at
<
float
>
(
defaultPoint
)
<=
depth
.
at
<
float
>
(
pixel
))
pixel
=
defaultPoint
;
cv
::
Point2i
currentDepthPixel
=
frameMapMask
.
at
<
cv
::
Point2i
>
(
deprojectedPixel
);
if
(
(
0
<=
currentDepthPixel
.
x
&&
currentDepthPixel
.
x
<
depth
.
cols
)
&&
(
0
<=
currentDepthPixel
.
y
&&
currentDepthPixel
.
y
<
depth
.
rows
)
){
if
(
depth
.
at
<
float
>
(
currentDepthPixel
)
<=
depth
.
at
<
float
>
(
j
,
i
)){
highestDepthPixel
=
currentDepthPixel
;
}
}
pixelsDeprojectHighestMap
.
at
<
cv
::
Point2i
>
(
j
,
i
)
=
p
ixel
;
frameMapMask
.
at
<
cv
::
Point2i
>
(
deprojectedPixel
)
=
highestDepthP
ixel
;
}
}
}
}
void
Projection
::
buildFrame
(
cv
::
Mat
&
depth
,
cv
::
Mat
&
pixelsDeprojectHighestMap
,
cv
::
Mat
&
src
,
cv
::
Mat
&
dst
){
void
Projection
::
buildFrame
(
cv
::
Mat
&
depth
,
cv
::
Mat
&
frameMapMask
,
cv
::
Mat
&
src
,
cv
::
Mat
&
dst
){
for
(
int
j
=
0
;
j
<
pixelsDeprojectHighestMap
.
rows
;
j
++
){
for
(
int
i
=
0
;
i
<
pixelsDeprojectHighestMap
.
cols
;
i
++
){
for
(
int
j
=
0
;
j
<
frameMapMask
.
rows
;
j
++
){
for
(
int
i
=
0
;
i
<
frameMapMask
.
cols
;
i
++
){
cv
::
Point2i
pixel
=
pixelsDeprojectHighestMap
.
at
<
cv
::
Point2i
>
(
j
,
i
);
cv
::
Point2i
pixel_src
=
frameMapMask
.
at
<
cv
::
Point2i
>
(
j
,
i
);
cv
::
Point2i
pixel_dst
=
cv
::
Point2i
(
i
,
j
);
if
(
(
0
<=
pixel
.
x
&&
pixel
.
x
<
depth
.
cols
)
&&
(
0
<=
pixel
.
y
&&
pixel
.
y
<
depth
.
rows
)
){
if
(
(
0
<=
pixel
_src
.
x
&&
pixel
_src
.
x
<
depth
.
cols
)
&&
(
0
<=
pixel
_src
.
y
&&
pixel
_src
.
y
<
depth
.
rows
)
){
// src and dst must be of same size
copyPixelsInto
(
pixel
,
dst
,
cv
::
Point2i
(
i
,
j
)
,
src
,
depth
);
copyPixelsInto
(
pixel
_dst
,
dst
,
pixel_src
,
src
,
depth
);
}
}
}
...
...
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