Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
vision
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor 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
mobile_robotics
wolf_projects
wolf_lib
plugins
vision
Commits
21a544a8
Commit
21a544a8
authored
3 years ago
by
Joan Solà Ortega
Browse files
Options
Downloads
Patches
Plain Diff
Explore only inner cells of grid (not the ones at the borders)
parent
e35b0e1e
No related branches found
No related tags found
2 merge requests
!36
After cmake and const refactor
,
!28
Resolve "Building a new visual odometry system"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/processor/processor_visual_odometry.cpp
+7
-13
7 additions, 13 deletions
src/processor/processor_visual_odometry.cpp
with
7 additions
and
13 deletions
src/processor/processor_visual_odometry.cpp
+
7
−
13
View file @
21a544a8
...
@@ -97,18 +97,12 @@ void ProcessorVisualOdometry::preProcess()
...
@@ -97,18 +97,12 @@ void ProcessorVisualOdometry::preProcess()
// detector_->detect(img_incoming, kps_current);
// detector_->detect(img_incoming, kps_current);
// We add all the detected KeyPoints to the cell, knowing that they are all empty at this point
// We add all the detected KeyPoints to the cell, knowing that they are all empty at this point
for
(
int
i
=
0
;
i
<
params_visual_odometry_
->
grid_params_
.
nbr_cells_h_
;
i
++
){
for
(
int
i
=
1
;
i
<
params_visual_odometry_
->
grid_params_
.
nbr_cells_h_
-
1
;
i
++
){
for
(
int
j
=
0
;
j
<
params_visual_odometry_
->
grid_params_
.
nbr_cells_v_
;
j
++
){
for
(
int
j
=
1
;
j
<
params_visual_odometry_
->
grid_params_
.
nbr_cells_v_
-
1
;
j
++
){
cv
::
Rect
rect_roi
;
cv
::
Rect
rect_roi
;
WOLF_INFO
(
i
,
j
)
Eigen
::
Vector2i
cell_index
;
cell_index
<<
i
,
j
;
Eigen
::
Vector2i
cell_index
;
cell_index
<<
i
,
j
;
cell_grid_
.
cell2roi
(
cell_index
,
rect_roi
);
cell_grid_
.
cell2roi
(
cell_index
,
rect_roi
);
// some cells are not inside of the image (borders + padding), if not pass
bool
is_inside
=
(
rect_roi
&
cv
::
Rect
(
0
,
0
,
img_incoming
.
cols
,
img_incoming
.
rows
))
==
rect_roi
;
if
(
!
is_inside
){
continue
;
}
cv
::
Mat
img_roi
(
img_incoming
,
rect_roi
);
// no data copy -> no overhead
cv
::
Mat
img_roi
(
img_incoming
,
rect_roi
);
// no data copy -> no overhead
std
::
vector
<
cv
::
KeyPoint
>
kps_roi
;
std
::
vector
<
cv
::
KeyPoint
>
kps_roi
;
detector_
->
detect
(
img_roi
,
kps_roi
);
detector_
->
detect
(
img_roi
,
kps_roi
);
...
@@ -120,14 +114,13 @@ void ProcessorVisualOdometry::preProcess()
...
@@ -120,14 +114,13 @@ void ProcessorVisualOdometry::preProcess()
// -> translate to the full image corner coordinate system
// -> translate to the full image corner coordinate system
kps_roi
.
at
(
0
).
pt
.
x
=
kps_roi
.
at
(
0
).
pt
.
x
+
rect_roi
.
x
;
kps_roi
.
at
(
0
).
pt
.
x
=
kps_roi
.
at
(
0
).
pt
.
x
+
rect_roi
.
x
;
kps_roi
.
at
(
0
).
pt
.
y
=
kps_roi
.
at
(
0
).
pt
.
y
+
rect_roi
.
y
;
kps_roi
.
at
(
0
).
pt
.
y
=
kps_roi
.
at
(
0
).
pt
.
y
+
rect_roi
.
y
;
// WOLF_TRACE("kps_roi first: ", kps_roi.at(0).pt.x, " ", kps_roi.at(0).pt.y)
capture_image_incoming_
->
addKeyPoints
(
kps_roi
);
capture_image_incoming_
->
addKeyPoints
(
kps_roi
);
}
}
}
}
}
}
// Select a limited number of these keypoints
// Select a limited number of these keypoints
//
cv::KeyPointsFilter::
retainBest(kps_current, params_visual_odometry_->max_new_features);
// retainBest(kps_current, params_visual_odometry_->max_new_features);
// capture_image_incoming_->addKeyPoints(kps_current);
// capture_image_incoming_->addKeyPoints(kps_current);
// Initialize the tracks data structure with a "dummy track" where the keypoint is pointing to itself
// Initialize the tracks data structure with a "dummy track" where the keypoint is pointing to itself
...
@@ -230,7 +223,7 @@ void ProcessorVisualOdometry::preProcess()
...
@@ -230,7 +223,7 @@ void ProcessorVisualOdometry::preProcess()
// Detect in the whole image and retain N best: BAD because cannot control the repartition of KeyPoints
// Detect in the whole image and retain N best: BAD because cannot control the repartition of KeyPoints
// detector_->detect(img_last, kps_last_new);
// detector_->detect(img_last, kps_last_new);
//
cv::KeyPointsFilter::
retainBest(kps_last_new, params_visual_odometry_->max_new_features);
// retainBest(kps_last_new, params_visual_odometry_->max_new_features);
// Instead, use the grid to detect new keypoints in empty cells
// Instead, use the grid to detect new keypoints in empty cells
// We try a bunch of time to add keypoints to randomly selected empty regions of interest
// We try a bunch of time to add keypoints to randomly selected empty regions of interest
...
@@ -246,7 +239,7 @@ void ProcessorVisualOdometry::preProcess()
...
@@ -246,7 +239,7 @@ void ProcessorVisualOdometry::preProcess()
detector_
->
detect
(
img_roi
,
kps_roi
);
detector_
->
detect
(
img_roi
,
kps_roi
);
if
(
kps_roi
.
size
()
>
0
){
if
(
kps_roi
.
size
()
>
0
){
// retain only the best image in each region of interest
// retain only the best image in each region of interest
cv
::
KeyPointsFilter
::
retainBest
(
kps_roi
,
1
);
retainBest
(
kps_roi
,
1
);
// Keypoints are detected in the local coordinates of the region of interest
// Keypoints are detected in the local coordinates of the region of interest
// -> translate to the full image corner coordinate system
// -> translate to the full image corner coordinate system
kps_roi
.
at
(
0
).
pt
.
x
=
kps_roi
.
at
(
0
).
pt
.
x
+
rect_roi
.
x
;
kps_roi
.
at
(
0
).
pt
.
x
=
kps_roi
.
at
(
0
).
pt
.
x
+
rect_roi
.
x
;
...
@@ -634,7 +627,7 @@ bool ProcessorVisualOdometry::filterWithEssential(const KeyPointsMap _mwkps_prev
...
@@ -634,7 +627,7 @@ bool ProcessorVisualOdometry::filterWithEssential(const KeyPointsMap _mwkps_prev
return
true
;
return
true
;
}
}
VisualOdometry
::
retainBest
(
std
::
vector
<
cv
::
KeyPoint
>
&
_keypoints
,
int
n
)
void
Processor
VisualOdometry
::
retainBest
(
std
::
vector
<
cv
::
KeyPoint
>
&
_keypoints
,
int
n
)
{
{
if
(
_keypoints
.
size
()
>
n
)
{
if
(
_keypoints
.
size
()
>
n
)
{
if
(
n
==
0
)
{
if
(
n
==
0
)
{
...
@@ -646,6 +639,7 @@ VisualOdometry::retainBest(std::vector<cv::KeyPoint> &_keypoints, int n)
...
@@ -646,6 +639,7 @@ VisualOdometry::retainBest(std::vector<cv::KeyPoint> &_keypoints, int n)
_keypoints
.
resize
(
n
);
_keypoints
.
resize
(
n
);
}
}
}
}
}
//namespace wolf
}
//namespace wolf
// Register in the FactoryProcessor
// Register in the FactoryProcessor
...
...
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