Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
vision_utils
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
Service Desk
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
labrobotica
algorithms
vision_utils
Commits
49ed543b
Commit
49ed543b
authored
7 years ago
by
Angel Santamaria-Navarro
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' into devel
parents
e91d0f30
504622df
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
src/vision_utils.cpp
+16
-18
16 additions, 18 deletions
src/vision_utils.cpp
src/vision_utils.h
+24
-15
24 additions, 15 deletions
src/vision_utils.h
with
40 additions
and
33 deletions
src/vision_utils.cpp
+
16
−
18
View file @
49ed543b
...
...
@@ -3,18 +3,18 @@
namespace
vision_utils
{
void
whoHasMoved
(
const
KeyPointVector
&
_kp
ts
1
,
const
KeyPointVector
&
_kp
ts
2
,
KeyPointVector
&
_common_kp
ts
,
KeyPointVector
&
_
new
_in_kp
ts
2
)
void
whoHasMoved
(
const
KeyPointVector
&
_kp
_vec_
1
,
const
KeyPointVector
&
_kp
_vec_
2
,
KeyPointVector
&
_common_kp
_vec
,
KeyPointVector
&
_
exclusive
_in_kp
_vec_
2
)
{
_
new
_in_kp
ts
2
.
clear
();
_common_kp
ts
.
clear
();
_
exclusive
_in_kp
_vec_
2
.
clear
();
_common_kp
_vec
.
clear
();
for
(
int
ii
=
0
;
ii
<
_kpts2
.
size
();
++
ii
)
for
(
auto
kp2
:
_kp_vec_2
)
{
bool
existing
=
false
;
for
(
int
jj
=
0
;
jj
<
_kpts1
.
size
();
++
jj
)
for
(
auto
kp1
:
_kp_vec_1
)
{
cv
::
Point2f
p1
=
_
kp
ts2
[
ii
]
.
pt
;
cv
::
Point2f
p2
=
_
kp
ts1
[
ii
]
.
pt
;
cv
::
Point2f
p1
=
kp
2
.
pt
;
cv
::
Point2f
p2
=
kp
1
.
pt
;
if
(
p1
.
x
-
p2
.
x
<
1.0
||
p1
.
y
-
p2
.
y
<
1.0
)
{
existing
=
true
;
...
...
@@ -22,24 +22,22 @@ void whoHasMoved(const KeyPointVector& _kpts1, const KeyPointVector& _kpts2, Key
}
}
if
(
!
existing
)
// New feature
_
new
_in_kp
ts
2
.
push_back
(
_
kp
ts2
[
ii
]
);
_
exclusive
_in_kp
_vec_
2
.
push_back
(
kp
2
);
else
_common_kp
ts
.
push_back
(
_
kp
ts2
[
ii
]
);
_common_kp
_vec
.
push_back
(
kp
2
);
}
}
void
whoHasMoved
(
const
PointVector
&
_pt
s
1
,
const
PointVector
&
_pt
s
2
,
PointVector
&
_common_pt
s
,
PointVector
&
_
new
_in_pt
s
2
)
void
whoHasMoved
(
const
PointVector
&
_pt
_vec_
1
,
const
PointVector
&
_pt
_vec_
2
,
PointVector
&
_common_pt
_vec
,
PointVector
&
_
exclusive
_in_pt
_vec_
2
)
{
_
new
_in_pt
s
2
.
clear
();
_common_pt
s
.
clear
();
_
exclusive
_in_pt
_vec_
2
.
clear
();
_common_pt
_vec
.
clear
();
for
(
int
ii
=
0
;
ii
<
_pts2
.
size
();
++
ii
)
for
(
auto
p2
:
_pt_vec_2
)
{
bool
existing
=
false
;
for
(
int
jj
=
0
;
jj
<
_pts1
.
size
();
++
jj
)
for
(
auto
p1
:
_pt_vec_1
)
{
cv
::
Point2f
p1
=
_pts2
[
ii
];
cv
::
Point2f
p2
=
_pts1
[
ii
];
if
(
p1
.
x
-
p2
.
x
<
1.0
||
p1
.
y
-
p2
.
y
<
1.0
)
{
existing
=
true
;
...
...
@@ -47,9 +45,9 @@ void whoHasMoved(const PointVector& _pts1, const PointVector& _pts2, PointVector
}
}
if
(
!
existing
)
// New feature
_
new
_in_pt
s
2
.
push_back
(
_pts2
[
ii
]
);
_
exclusive
_in_pt
_vec_
2
.
push_back
(
p2
);
else
_common_pt
s
.
push_back
(
_pts2
[
ii
]
);
_common_pt
_vec
.
push_back
(
p2
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/vision_utils.h
+
24
−
15
View file @
49ed543b
...
...
@@ -32,6 +32,7 @@ using namespace boost::assign; // bring 'operator+=()' into scope
typedef
std
::
vector
<
cv
::
Point2f
>
PointVector
;
typedef
std
::
vector
<
cv
::
KeyPoint
>
KeyPointVector
;
typedef
std
::
vector
<
cv
::
line_descriptor
::
KeyLine
>
KeyLineVector
;
typedef
std
::
vector
<
cv
::
Rect
>
RectVector
;
namespace
vision_utils
{
...
...
@@ -156,31 +157,39 @@ inline std::vector<cv::Point2f> vecUnion(std::vector<cv::Point2f> v1, std::vecto
return
v3
;
};
inline
void
drawKeyPoints
(
cv
::
Mat
&
_image
,
const
KeyPointVector
&
_kp_vec
,
const
int
&
_radius
=
5
,
const
cv
::
Scalar
&
_color
=
cv
::
Scalar
(
0
,
0
,
255
),
const
int
&
_thickness
=-
1
)
inline
void
drawKeyPoints
(
cv
::
Mat
&
_image
,
const
KeyPointVector
&
_kp_vec
,
const
int
&
_radius
=
5
,
const
cv
::
Scalar
&
_color
=
cv
::
Scalar
(
0
,
0
,
255
),
const
int
&
_thickness
=-
1
)
{
for
(
unsigned
int
ii
=
0
;
ii
<
_kp_vec
.
size
();
++
ii
)
cv
::
circle
(
_image
,
_
kp
_vec
[
ii
]
.
pt
,
_radius
,
_color
,
_thickness
);
for
(
auto
kp
:
_kp_vec
)
cv
::
circle
(
_image
,
kp
.
pt
,
_radius
,
_color
,
_thickness
);
};
inline
void
drawKeyLines
(
cv
::
Mat
&
_image
,
const
KeyLineVector
&
_kl_vec
)
inline
void
drawKeyLines
(
cv
::
Mat
&
_image
,
const
KeyLineVector
&
_kl_vec
,
const
cv
::
Scalar
&
_color
=
cv
::
Scalar
(
128
,
128
,
255
)
)
{
for
(
unsigned
int
ii
=
0
;
ii
<
_kl_vec
.
size
();
++
ii
)
cv
::
line
(
_image
,
_
kl
_vec
[
ii
]
.
getStartPoint
(),
_
kl
_vec
[
ii
]
.
getEndPoint
(),
cv
::
Scalar
(
128
,
128
,
255
)
,
3
);
for
(
auto
kl
:
_kl_vec
)
cv
::
line
(
_image
,
kl
.
getStartPoint
(),
kl
.
getEndPoint
(),
_color
,
3
);
};
inline
void
copyKPVector
(
const
KeyPointVector
&
kpv_from
,
KeyPointVector
&
kpv_to
)
inline
void
drawRoi
(
cv
::
Mat
_image
,
const
RectVector
&
_roi_vec
,
const
cv
::
Scalar
&
_color
=
cv
::
Scalar
(
128
,
128
,
255
)
)
{
kpv_to
.
clear
();
for
(
int
ii
=
0
;
ii
<
kpv_from
.
size
();
ii
++
)
kpv_to
.
push_back
(
kpv_from
[
ii
]);
for
(
auto
roi
:
_roi_vec
)
cv
::
rectangle
(
_image
,
roi
,
_color
,
1
,
8
,
0
);
cv
::
imshow
(
"Feature tracker"
,
_image
);
}
inline
void
copyKPVector
(
const
KeyPointVector
&
_kpv_from
,
KeyPointVector
&
_kpv_to
)
{
_kpv_to
.
clear
();
for
(
auto
kp
:
_kpv_from
)
_kpv_to
.
push_back
(
kp
);
};
inline
PointVector
KPToP
(
const
KeyPointVector
&
kp
ts
)
inline
PointVector
KPToP
(
const
KeyPointVector
&
_
kp
_vec
)
{
PointVector
pt
s
;
for
(
unsigned
int
ii
=
0
;
ii
<
kpts
.
size
();
ii
++
)
pts
.
push_back
(
kp
ts
[
ii
]
.
pt
);
return
pt
s
;
PointVector
pt
_vec
;
for
(
auto
kp
:
_kp_vec
)
pt_vec
.
push_back
(
kp
.
pt
);
return
pt
_vec
;
};
void
whoHasMoved
(
const
KeyPointVector
&
_kpts1
,
const
KeyPointVector
&
_kpts2
,
KeyPointVector
&
_common_kpts
,
KeyPointVector
&
_new_in_kpts2
);
...
...
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