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
b40b1836
Commit
b40b1836
authored
4 years ago
by
simon.fanetti
Browse files
Options
Downloads
Patches
Plain Diff
fixe projection + code clarity
parent
f2124872
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
inc/projection.h
+1
-1
1 addition, 1 deletion
inc/projection.h
src/components/projection.cpp
+13
-16
13 additions, 16 deletions
src/components/projection.cpp
with
14 additions
and
17 deletions
inc/projection.h
+
1
−
1
View file @
b40b1836
...
...
@@ -15,7 +15,7 @@ class Projection{
void
buildFrame
(
cv
::
Mat_
<
float
>
&
depth
,
cv
::
Mat_
<
cv
::
Point2i
>
&
frameMapMask
,
cv
::
Mat_
<
cv
::
Vec3b
>
&
src
,
cv
::
Mat_
<
cv
::
Vec3b
>
&
dst
);
cv
::
Point2i
findMatchingPixel
(
int
i
,
int
j
,
float
z
,
Camera
*
camera
,
cv
::
Point3f
beamer_pos
);
void
copyPixelsInto
(
cv
::
Point2i
pixel_dst
,
cv
::
Mat_
<
cv
::
Vec3b
>
&
dst
,
cv
::
Point2i
pixel_src
,
cv
::
Mat_
<
cv
::
Vec3b
>
&
src
,
cv
::
Mat_
<
float
>
&
depth
);
cv
::
Size
getMatchingSize
(
cv
::
Mat
_
<
cv
::
Vec3b
>
&
src
,
cv
::
Rec
t
base
);
cv
::
Size
getMatchingSize
(
cv
::
Mat
&
src
,
cv
::
Ma
t
&
base
);
public:
Projection
();
...
...
This diff is collapsed.
Click to expand it.
src/components/projection.cpp
+
13
−
16
View file @
b40b1836
...
...
@@ -31,28 +31,24 @@ cv::Point2i Projection::revertRotatePixel(cv::Point2i pixel){
// Adjust the projected frame with the topology from the camera to the beamer POV
void
Projection
::
adjustFrame
(
cv
::
Mat_
<
float
>
depth
,
cv
::
Mat_
<
cv
::
Vec3b
>
src
,
cv
::
Mat_
<
cv
::
Vec3b
>
&
dst
,
Camera
*
camera
,
cv
::
Point3f
beamer_pos
){
cv
::
Rect
mask
=
camera
->
getCroppingMask
();
// resize the frames to be a multiple of the camera size :
// src.size = n * camera.depth.size , where n is uint > 0
static
cv
::
Mat_
<
cv
::
Vec3b
>
resized_dst
=
cv
::
Mat_
<
cv
::
Vec3b
>
(
getMatchingSize
(
dst
,
mask
));
static
cv
::
Mat_
<
cv
::
Vec3b
>
resized_dst
=
cv
::
Mat_
<
cv
::
Vec3b
>
(
getMatchingSize
(
dst
,
depth
));
cv
::
resize
(
dst
,
resized_dst
,
resized_dst
.
size
());
cv
::
resize
(
src
,
src
,
resized_dst
.
size
());
static
cv
::
Mat_
<
cv
::
Point2i
>
deprojectMap
=
cv
::
Mat_
<
cv
::
Point2i
>
(
mask
.
height
,
mask
.
width
);
static
cv
::
Mat_
<
cv
::
Point2i
>
deprojectMap
=
cv
::
Mat_
<
cv
::
Point2i
>
(
depth
.
size
()
);
deprojectMap
=
cv
::
Point2i
(
-
1
,
-
1
);
static
cv
::
Mat_
<
cv
::
Point2i
>
frameMapMask
=
cv
::
Mat_
<
cv
::
Point2i
>
(
mask
.
height
,
mask
.
width
,
cv
::
Point2i
(
-
1
,
-
1
));
static
cv
::
Mat_
<
cv
::
Point2i
>
frameMapMask
=
cv
::
Mat_
<
cv
::
Point2i
>
(
depth
.
size
()
,
cv
::
Point2i
(
-
1
,
-
1
));
frameMapMask
=
cv
::
Point2i
(
-
1
,
-
1
);
deprojectPixelsFromDepth
(
depth
,
m
ask
,
camera
,
beamer_pos
,
deprojectMap
);
deprojectPixelsFromDepth
(
depth
,
camera
->
getCroppingM
ask
()
,
camera
,
beamer_pos
,
deprojectMap
);
filterLowestDeprojectedPoints
(
depth
,
deprojectMap
,
frameMapMask
);
buildFrame
(
depth
,
frameMapMask
,
src
,
resized_dst
);
// TODO : Holefilling method
cv
::
resize
(
resized_dst
,
dst
,
dst
.
size
());
cv
::
warpAffine
(
dst
,
dst
,
adjustingMatrix
,
dst
.
size
());
}
...
...
@@ -132,10 +128,10 @@ void Projection::buildFrame(cv::Mat_<float> &depth, cv::Mat_<cv::Point2i> &frame
}
cv
::
Size
Projection
::
getMatchingSize
(
cv
::
Mat
_
<
cv
::
Vec3b
>
&
src
,
cv
::
Rec
t
base
){
cv
::
Size
Projection
::
getMatchingSize
(
cv
::
Mat
&
src
,
cv
::
Ma
t
&
base
){
cv
::
Size
bigSize
;
bigSize
.
width
=
(
src
.
size
().
width
%
base
.
width
==
0
)
?
src
.
size
().
width
:
src
.
size
().
width
-
(
src
.
size
().
width
%
base
.
width
)
+
base
.
width
;
bigSize
.
height
=
(
src
.
size
().
height
%
base
.
height
==
0
)
?
src
.
size
().
height
:
src
.
size
().
height
-
(
src
.
size
().
height
%
base
.
height
)
+
base
.
height
;
bigSize
.
width
=
(
src
.
size
().
width
%
base
.
size
().
width
==
0
)
?
src
.
size
().
width
:
src
.
size
().
width
-
(
src
.
size
().
width
%
base
.
size
().
width
)
+
base
.
size
().
width
;
bigSize
.
height
=
(
src
.
size
().
height
%
base
.
size
().
height
==
0
)
?
src
.
size
().
height
:
src
.
size
().
height
-
(
src
.
size
().
height
%
base
.
size
().
height
)
+
base
.
size
().
height
;
return
bigSize
;
}
...
...
@@ -177,13 +173,14 @@ void Projection::copyPixelsInto(cv::Point2i pixel_dst, cv::Mat_<cv::Vec3b> &dst,
cv
::
Point2i
Projection
::
findMatchingPixel
(
int
i
,
int
j
,
float
z
,
Camera
*
camera
,
cv
::
Point3f
CB
){
float
pixel
[
2
]
=
{
static_cast
<
float
>
(
i
),
static_cast
<
float
>
(
j
)};
const
float
BEz
=
distanceTopSandbox
-
CB
.
z
;
cv
::
Point3f
CP
=
camera
->
deprojectPixelToPoint
(
pixel
,
z
);
cv
::
Point3f
BP
=
CB
-
CP
;
float
BAz
=
CB
.
z
+
BP
.
z
;
float
BEz
=
distanceTopSandbox
-
CB
.
z
;
cv
::
Point3f
BP
=
CP
-
CB
;
float
BAz
=
BP
.
z
;
float
alpha
=
BEz
/
BAz
;
cv
::
Point3f
V
=
(
alpha
*
BP
);
cv
::
Point3f
CV
=
V
+
C
B
;
cv
::
Point3f
B
V
=
(
alpha
*
BP
);
cv
::
Point3f
CV
=
CB
+
B
V
;
return
camera
->
projectPointToPixel
(
CV
);
}
...
...
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