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
0c4ff5dc
Commit
0c4ff5dc
authored
4 years ago
by
simon.fanetti
Browse files
Options
Downloads
Patches
Plain Diff
add comments
parent
7ba1afb0
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
app/SandboxSetup/croppingmask.cpp
+3
-3
3 additions, 3 deletions
app/SandboxSetup/croppingmask.cpp
src/components/projection.cpp
+29
-5
29 additions, 5 deletions
src/components/projection.cpp
with
32 additions
and
8 deletions
app/SandboxSetup/croppingmask.cpp
+
3
−
3
View file @
0c4ff5dc
...
...
@@ -31,12 +31,12 @@ void CroppingMask::valideRoutine(){
timer
->
stop
();
setup
->
getCamera
()
->
capture
();
std
::
vector
<
cv
::
Point
>
rectPoints
=
getRectPoints
();
cv
::
Point2i
center
=
setup
->
getCenterOfQuadrilateral
(
rectPoints
);
cv
::
Point2i
center
Projection
=
setup
->
getCenterOfQuadrilateral
(
rectPoints
);
cv
::
Mat
depthFrame
=
setup
->
getCamera
()
->
getDepthFrame
();
setup
->
setupAdjustMatrix
(
rectPoints
,
center
);
setup
->
setupAdjustMatrix
(
rectPoints
,
center
Projection
);
setup
->
setupCroppingMask
(
rectPoints
);
setup
->
getProjection
()
->
setDistanceTopSandbox
(
depthFrame
.
at
<
float
>
(
center
));
setup
->
getProjection
()
->
setDistanceTopSandbox
(
depthFrame
.
at
<
float
>
(
center
Projection
));
endSuccess
=
true
;
}
...
...
This diff is collapsed.
Click to expand it.
src/components/projection.cpp
+
29
−
5
View file @
0c4ff5dc
...
...
@@ -27,7 +27,9 @@ cv::Point2i Projection::revertRotatePixel(cv::Point2i pixel){
}
// Adjust the projected frame with the topology from the camera to the beamer POV
/*
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
){
if
(
deprojectMap
.
empty
()
||
deprojectMap
.
size
()
!=
depth
.
size
()){
...
...
@@ -43,10 +45,10 @@ void Projection::adjustFrame(cv::Mat_<float> depth, cv::Mat_<cv::Vec3b> src, cv:
deprojectMap
=
cv
::
Point2i
(
-
1
,
-
1
);
frameMap
=
cv
::
Point2i
(
-
1
,
-
1
);
resized_dst
=
cv
::
Vec3b
(
0
,
0
,
0
);
// resize the frames to be a multiple of the camera size :
// src.size = n * camera.depth.size , where n is uint > 0
cv
::
resize
(
dst
,
resized_dst
,
resized_dst
.
size
());
// resize to match 1:1 ratio with resized_dst, since we'll do later:
// resized_dst[i] = src[i]
cv
::
resize
(
src
,
src
,
resized_dst
.
size
());
deprojectPixelsFromDepth
(
depth
,
camera
->
getCroppingMask
(),
camera
,
beamer_pos
,
deprojectMap
);
...
...
@@ -63,6 +65,11 @@ void Projection::adjustFrame(cv::Mat_<float> depth, cv::Mat_<cv::Vec3b> src, cv:
* PRIVATE
*/
/*
Deproject pixels in 3D, then adapt to Beamer's POV, and go back to 2D
This gives us the location od pixels adapted to the Beamer projection
*/
void
Projection
::
deprojectPixelsFromDepth
(
cv
::
Mat_
<
float
>
&
depth
,
cv
::
Rect
mask
,
Camera
*
camera
,
cv
::
Point3f
beamer_pos
,
cv
::
Mat_
<
cv
::
Point2i
>
&
deprojectMap
){
// Browse the depth frame matching the cropping mask
...
...
@@ -87,7 +94,13 @@ void Projection::deprojectPixelsFromDepth(cv::Mat_<float> &depth, cv::Rect mask,
}
}
/*
Save the highest points in deprojectMap into frameMap,
because some points can be deprojected at the same location
frameMap indicates for each pixel of dst, where it should get the value from in src
deprojectMap indicates for each pixel, where it'll be displayed
*/
void
Projection
::
filterLowestDeprojectedPoints
(
cv
::
Mat_
<
float
>
&
depth
,
cv
::
Mat_
<
cv
::
Point2i
>
&
deprojectMap
,
cv
::
Mat_
<
cv
::
Point2i
>
&
frameMap
){
for
(
int
j
=
0
;
j
<
deprojectMap
.
rows
;
j
++
){
...
...
@@ -115,6 +128,11 @@ void Projection::filterLowestDeprojectedPoints(cv::Mat_<float> &depth, cv::Mat_<
}
/*
Build the frame using frameMap,
where each pixel describes in which pixel of the source it should take the value from
dst[i] = src[frameMap[i]]
*/
void
Projection
::
buildFrame
(
cv
::
Mat_
<
float
>
&
depth
,
cv
::
Mat_
<
cv
::
Point2i
>
&
frameMap
,
cv
::
Mat_
<
cv
::
Vec3b
>
&
src
,
cv
::
Mat_
<
cv
::
Vec3b
>
&
dst
){
for
(
int
j
=
0
;
j
<
frameMap
.
rows
;
j
++
){
...
...
@@ -132,6 +150,10 @@ void Projection::buildFrame(cv::Mat_<float> &depth, cv::Mat_<cv::Point2i> &frame
}
/*
resize the frames to be a multiple of the base size:
src.size = n * base.size, where n is uint > 0
*/
cv
::
Size
Projection
::
getMatchingSize
(
cv
::
Mat
&
src
,
cv
::
Mat
&
base
){
cv
::
Size
bigSize
;
bigSize
.
width
=
(
src
.
size
().
width
%
base
.
size
().
width
==
0
)
?
src
.
size
().
width
:
src
.
size
().
width
-
(
src
.
size
().
width
%
base
.
size
().
width
)
+
base
.
size
().
width
;
...
...
@@ -140,7 +162,9 @@ cv::Size Projection::getMatchingSize(cv::Mat &src, cv::Mat &base){
}
// pixels coordinates are relative to the camera depth frame
/*
pixels coordinates are relative to the camera depth frame
*/
void
Projection
::
copyPixelsInto
(
cv
::
Point2i
pixel_dst
,
cv
::
Mat_
<
cv
::
Vec3b
>
&
dst
,
cv
::
Point2i
pixel_src
,
cv
::
Mat_
<
cv
::
Vec3b
>
&
src
,
cv
::
Mat_
<
float
>
&
depth
){
if
(
src
.
size
().
width
==
dst
.
size
().
width
&&
src
.
size
().
height
==
dst
.
size
().
height
){
...
...
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