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
1b351233
Commit
1b351233
authored
4 years ago
by
simon.fanetti
Browse files
Options
Downloads
Patches
Plain Diff
cleaning
parent
ca4d1533
No related branches found
No related tags found
1 merge request
!3
Custom realsense
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
inc/sandboxSetup.h
+0
-3
0 additions, 3 deletions
inc/sandboxSetup.h
src/lib/sandboxSetup.cpp
+1
-73
1 addition, 73 deletions
src/lib/sandboxSetup.cpp
with
1 addition
and
76 deletions
inc/sandboxSetup.h
+
0
−
3
View file @
1b351233
...
...
@@ -14,8 +14,6 @@ class SandboxSetup{
Camera
*
camera
;
Beamer
*
beamer
;
std
::
vector
<
std
::
vector
<
cv
::
Point2i
>>
getTriangles
(
std
::
vector
<
cv
::
Point2i
>
rectPoints
);
std
::
vector
<
cv
::
Point2i
>
getCentroids
(
std
::
vector
<
std
::
vector
<
cv
::
Point2i
>>
triangles
);
double
toDegrees
(
double
radians
);
public:
...
...
@@ -37,7 +35,6 @@ class SandboxSetup{
int
loadCroppingMask
();
// edit variables of config => not persistant
cv
::
Point2i
getCenterOfQuadrilateral
(
std
::
vector
<
cv
::
Point
>
rectPoints
);
void
setupAdjustMatrix
(
std
::
vector
<
cv
::
Point
>
rectPoints
,
cv
::
Point
center
);
void
setupCroppingMask
(
std
::
vector
<
cv
::
Point
>
rectPoints
);
};
...
...
This diff is collapsed.
Click to expand it.
src/lib/sandboxSetup.cpp
+
1
−
73
View file @
1b351233
...
...
@@ -62,37 +62,6 @@ int SandboxSetup::loadFrameProcessProfil(){
return
loadFrameProcessProfilFrom
(
defaultConfigFilePath
);
}
/*
Get the centroid of a quadrilateral
source : http://jwilson.coe.uga.edu/EMT668/EMT668.Folders.F97/Patterson/EMT%20669/centroid%20of%20quad/Centroid.html
*/
cv
::
Point2i
SandboxSetup
::
getCenterOfQuadrilateral
(
std
::
vector
<
cv
::
Point
>
rectPoints
){
std
::
vector
<
std
::
vector
<
cv
::
Point2i
>>
triangles
=
getTriangles
(
rectPoints
);
std
::
vector
<
cv
::
Point2i
>
centroids
=
getCentroids
(
triangles
);
/*
Pa = P1 + mua (P2 - P1)
Pb = P3 + mub (P4 - P3)
*/
cv
::
Point3d
pa
;
cv
::
Point3d
pb
;
double
mua
;
double
mub
;
beamer
->
LineLineIntersect
(
cv
::
Point3d
(
centroids
.
at
(
0
).
x
,
centroids
.
at
(
0
).
y
,
0
),
cv
::
Point3d
(
centroids
.
at
(
2
).
x
,
centroids
.
at
(
2
).
y
,
0
),
cv
::
Point3d
(
centroids
.
at
(
1
).
x
,
centroids
.
at
(
1
).
y
,
0
),
cv
::
Point3d
(
centroids
.
at
(
3
).
x
,
centroids
.
at
(
3
).
y
,
0
),
&
pa
,
&
pb
,
&
mua
,
&
mub
);
// pa and pb should be the same
cv
::
Point2i
center
;
center
.
x
=
(
pa
.
x
+
pb
.
x
)
/
2
;
center
.
y
=
(
pa
.
y
+
pb
.
y
)
/
2
;
return
center
;
}
/* Assuming points positions are :
* pts[0] : top left
...
...
@@ -107,7 +76,7 @@ void SandboxSetup::setupAdjustMatrix(std::vector<cv::Point> rectPoints, cv::Poin
// Set adjusting matrix for the projection
int
widthTop
=
rectPoints
[
3
].
x
-
rectPoints
[
0
].
x
;
double
angle
=
atan
((
double
)(
rectPoints
[
3
].
y
-
rectPoints
[
0
].
y
)
/
widthTop
);
cv
::
Mat_
<
float
>
matRotation
=
cv
::
getRotationMatrix2D
(
center
,
toDegrees
(
angle
),
1
);
// adjustingMatrix
cv
::
Mat_
<
float
>
matRotation
=
cv
::
getRotationMatrix2D
(
center
,
toDegrees
(
angle
),
1
);
projection
->
setAdjustingMatrix
(
matRotation
);
}
...
...
@@ -138,47 +107,6 @@ void SandboxSetup::setupCroppingMask(std::vector<cv::Point2i> rectPoints){
//
/*
Get the 4 triangles in the quadrilateral
*/
std
::
vector
<
std
::
vector
<
cv
::
Point2i
>>
SandboxSetup
::
getTriangles
(
std
::
vector
<
cv
::
Point2i
>
rectPoints
){
std
::
vector
<
std
::
vector
<
cv
::
Point2i
>>
triangles
;
std
::
vector
<
cv
::
Point2i
>
A
,
B
,
C
,
D
;
std
::
vector
<
cv
::
Point2i
>
lst
[
4
]
=
{
A
,
B
,
C
,
D
};
// 4 triangles in the quadrilateral
for
(
int
i
=
0
;
i
<
4
;
i
++
){
// corners in the triangle
for
(
int
j
=
0
;
j
<
3
;
j
++
){
lst
[
i
].
push_back
(
rectPoints
.
at
(
(
i
+
j
)
%
rectPoints
.
size
()
));
}
triangles
.
push_back
(
lst
[
i
]);
}
return
triangles
;
}
/*
Get the centroid of each of the 4 triangles
source : https://www.khanacademy.org/math/geometry-home/triangle-properties/medians-centroids/v/triangle-medians-and-centroids
*/
std
::
vector
<
cv
::
Point2i
>
SandboxSetup
::
getCentroids
(
std
::
vector
<
std
::
vector
<
cv
::
Point2i
>>
triangles
){
std
::
vector
<
cv
::
Point2i
>
centroids
;
// the centroid is the average of the 3 coordinates
for
(
int
i
=
0
;
i
<
(
int
)
triangles
.
size
();
i
++
){
std
::
vector
<
cv
::
Point2i
>
tr
=
triangles
.
at
(
i
);
cv
::
Point2i
center
;
center
.
x
=
(
tr
.
at
(
0
).
x
+
tr
.
at
(
1
).
x
+
tr
.
at
(
2
).
x
)
/
3
;
center
.
y
=
(
tr
.
at
(
0
).
y
+
tr
.
at
(
1
).
y
+
tr
.
at
(
2
).
y
)
/
3
;
centroids
.
push_back
(
center
);
}
return
centroids
;
}
double
SandboxSetup
::
toDegrees
(
double
radians
){
return
radians
*
(
180.0
/
M_PI
);
}
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