-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
96f7f79
commit 858f569
Showing
38 changed files
with
362 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
#include "descriptor_tracker.h" | ||
#include "util/tf_util.h" | ||
|
||
namespace omni_slam | ||
{ | ||
namespace feature | ||
{ | ||
|
||
DescriptorTracker::DescriptorTracker(std::string detector_type, std::string descriptor_type, std::map<std::string, double> det_args, std::map<std::string, double> desc_args, const float match_thresh, const int keyframe_interval) | ||
: Tracker(keyframe_interval), | ||
Matcher(descriptor_type, match_thresh), | ||
Detector(detector_type, descriptor_type, det_args, desc_args) | ||
{ | ||
} | ||
|
||
int DescriptorTracker::DoTrack(std::vector<data::Landmark> &landmarks, data::Frame &cur_frame, std::vector<double> &errors, bool stereo) | ||
{ | ||
std::vector<data::Landmark> curLandmarks; | ||
std::vector<data::Landmark> prevLandmarks; | ||
int imsize = std::max(cur_frame.GetImage().rows, cur_frame.GetImage().cols); | ||
#pragma omp parallel for collapse(2) | ||
for (int i = 0; i < Region::rs.size() - 1; i++) | ||
{ | ||
for (int j = 0; j < Region::ts.size() - 1; j++) | ||
{ | ||
feature::Detector detector(*static_cast<Detector*>(this)); | ||
detector.DetectInRadialRegion(cur_frame, curLandmarks, feature::Region::rs[i] * imsize, feature::Region::rs[i+1] * imsize, feature::Region::ts[j], feature::Region::ts[j+1]); | ||
detector.DetectInRadialRegion(cur_frame, curLandmarks, feature::Region::rs[i] * imsize, feature::Region::rs[i+1] * imsize, feature::Region::ts[j], feature::Region::ts[j+1], true); | ||
} | ||
} | ||
std::vector<int> origInx; | ||
int i = 0; | ||
for (const data::Landmark &landmark : landmarks) | ||
{ | ||
if (landmark.IsObservedInFrame(keyframeId_)) | ||
{ | ||
data::Landmark l; | ||
l.AddObservation(*landmark.GetObservationByFrameID(keyframeId_), false); | ||
if (stereo) | ||
{ | ||
const data::Feature* stereoFeat = landmark.GetStereoObservationByFrameID(keyframeId_); | ||
if (stereoFeat != nullptr) | ||
{ | ||
l.AddStereoObservation(*stereoFeat); | ||
} | ||
} | ||
prevLandmarks.push_back(l); | ||
origInx.push_back(i); | ||
} | ||
i++; | ||
} | ||
std::vector<data::Landmark> matches; | ||
std::vector<data::Landmark> stereoMatches; | ||
std::vector<int> indices; | ||
std::vector<std::vector<double>> distances; | ||
std::vector<std::vector<double>> stereoDistances; | ||
std::vector<int> stereoIndices; | ||
Match(curLandmarks, prevLandmarks, matches, distances, indices, false); | ||
if (stereo) | ||
{ | ||
Match(curLandmarks, prevLandmarks, stereoMatches, stereoDistances, stereoIndices, true); | ||
} | ||
errors.clear(); | ||
int numGood = 0; | ||
for (int i = 0; i < matches.size(); i++) | ||
{ | ||
data::Landmark &landmark = landmarks[origInx[indices[i]]]; | ||
data::Feature feat(cur_frame, matches[i].GetObservationByFrameID(cur_frame.GetID())->GetKeypoint(), matches[i].GetObservationByFrameID(cur_frame.GetID())->GetDescriptor()); | ||
landmark.AddObservation(feat); | ||
errors.push_back(distances[i][0]); | ||
numGood++; | ||
} | ||
for (int i = 0; i < stereoMatches.size(); i++) | ||
{ | ||
data::Landmark &landmark = landmarks[origInx[stereoIndices[i]]]; | ||
if (!landmark.IsObservedInFrame(cur_frame.GetID())) | ||
{ | ||
continue; | ||
} | ||
data::Feature feat(cur_frame, stereoMatches[i].GetObservationByFrameID(cur_frame.GetID())->GetKeypoint(), stereoMatches[i].GetObservationByFrameID(cur_frame.GetID())->GetDescriptor(), true); | ||
landmark.AddStereoObservation(feat); | ||
} | ||
|
||
return numGood; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#ifndef _DESCRIPTOR_TRACKER_H_ | ||
#define _DESCRIPTOR_TRACKER_H_ | ||
|
||
#include "tracker.h" | ||
#include "matcher.h" | ||
#include "detector.h" | ||
#include "region.h" | ||
#include <opencv2/opencv.hpp> | ||
#include "data/frame.h" | ||
#include "data/landmark.h" | ||
#include "odometry/five_point.h" | ||
#include <vector> | ||
|
||
namespace omni_slam | ||
{ | ||
namespace feature | ||
{ | ||
|
||
class DescriptorTracker : public Tracker, public Matcher, public Detector | ||
{ | ||
public: | ||
DescriptorTracker(std::string detector_type, std::string descriptor_type, std::map<std::string, double> det_args, std::map<std::string, double> desc_args, const float match_thresh = 0., const int keyframe_interval = 1); | ||
|
||
private: | ||
int DoTrack(std::vector<data::Landmark> &landmarks, data::Frame &cur_frame, std::vector<double> &errors, bool stereo); | ||
}; | ||
|
||
} | ||
} | ||
#endif /* _DESCRIPTOR_TRACKER_H_ */ |
Oops, something went wrong.