switch from tbb_hash to std::hash

This commit is contained in:
Vladyslav Usenko 2020-04-28 19:24:19 +02:00
parent a03be4effa
commit b90f08eaeb
10 changed files with 33 additions and 36 deletions

View File

@ -69,20 +69,23 @@ struct CalibInitPoseData {
EIGEN_MAKE_ALIGNED_OPERATOR_NEW EIGEN_MAKE_ALIGNED_OPERATOR_NEW
}; };
using CalibCornerMap = tbb::concurrent_unordered_map<TimeCamId, CalibCornerData,
std::hash<TimeCamId>>;
using CalibInitPoseMap =
tbb::concurrent_unordered_map<TimeCamId, CalibInitPoseData,
std::hash<TimeCamId>>;
class CalibHelper { class CalibHelper {
public: public:
static void detectCorners( static void detectCorners(const VioDatasetPtr& vio_data,
const VioDatasetPtr& vio_data, CalibCornerMap& calib_corners,
tbb::concurrent_unordered_map<TimeCamId, CalibCornerData>& calib_corners, CalibCornerMap& calib_corners_rejected);
tbb::concurrent_unordered_map<TimeCamId, CalibCornerData>&
calib_corners_rejected);
static void initCamPoses( static void initCamPoses(
const Calibration<double>::Ptr& calib, const Calibration<double>::Ptr& calib,
const Eigen::aligned_vector<Eigen::Vector4d>& aprilgrid_corner_pos_3d, const Eigen::aligned_vector<Eigen::Vector4d>& aprilgrid_corner_pos_3d,
tbb::concurrent_unordered_map<TimeCamId, CalibCornerData>& calib_corners, CalibCornerMap& calib_corners, CalibInitPoseMap& calib_init_poses);
tbb::concurrent_unordered_map<TimeCamId, CalibInitPoseData>&
calib_init_poses);
static bool initializeIntrinsics( static bool initializeIntrinsics(
const Eigen::aligned_vector<Eigen::Vector2d>& corners, const Eigen::aligned_vector<Eigen::Vector2d>& corners,

View File

@ -111,10 +111,9 @@ class CamCalib {
VioDatasetPtr vio_dataset; VioDatasetPtr vio_dataset;
// CalibrationPtr calib; // CalibrationPtr calib;
tbb::concurrent_unordered_map<TimeCamId, CalibCornerData> calib_corners; CalibCornerMap calib_corners;
tbb::concurrent_unordered_map<TimeCamId, CalibCornerData> CalibCornerMap calib_corners_rejected;
calib_corners_rejected; CalibInitPoseMap calib_init_poses;
tbb::concurrent_unordered_map<TimeCamId, CalibInitPoseData> calib_init_poses;
std::shared_ptr<std::thread> processing_thread; std::shared_ptr<std::thread> processing_thread;

View File

@ -110,10 +110,9 @@ class CamImuCalib {
VioDatasetPtr vio_dataset; VioDatasetPtr vio_dataset;
tbb::concurrent_unordered_map<TimeCamId, CalibCornerData> calib_corners; CalibCornerMap calib_corners;
tbb::concurrent_unordered_map<TimeCamId, CalibCornerData> CalibCornerMap calib_corners_rejected;
calib_corners_rejected; CalibInitPoseMap calib_init_poses;
tbb::concurrent_unordered_map<TimeCamId, CalibInitPoseData> calib_init_poses;
std::shared_ptr<std::thread> processing_thread; std::shared_ptr<std::thread> processing_thread;

View File

@ -195,7 +195,9 @@ class FrameToFrameOpticalFlow : public OpticalFlowBase {
init_vec.push_back(kv.second); init_vec.push_back(kv.second);
} }
tbb::concurrent_unordered_map<KeypointId, Eigen::AffineCompact2f> result; tbb::concurrent_unordered_map<KeypointId, Eigen::AffineCompact2f,
std::hash<KeypointId>>
result;
auto compute_func = [&](const tbb::blocked_range<size_t>& range) { auto compute_func = [&](const tbb::blocked_range<size_t>& range) {
for (size_t r = range.begin(); r != range.end(); ++r) { for (size_t r = range.begin(); r != range.end(); ++r) {

View File

@ -183,7 +183,9 @@ class PatchOpticalFlow : public OpticalFlowBase {
init_vec.push_back(kv.second); init_vec.push_back(kv.second);
} }
tbb::concurrent_unordered_map<KeypointId, Eigen::AffineCompact2f> result; tbb::concurrent_unordered_map<KeypointId, Eigen::AffineCompact2f,
std::hash<KeypointId>>
result;
auto compute_func = [&](const tbb::blocked_range<size_t>& range) { auto compute_func = [&](const tbb::blocked_range<size_t>& range) {
for (size_t r = range.begin(); r != range.end(); ++r) { for (size_t r = range.begin(); r != range.end(); ++r) {

View File

@ -109,7 +109,8 @@ struct KeypointsData {
}; };
/// feature corners is a collection of { imageId => KeypointsData } /// feature corners is a collection of { imageId => KeypointsData }
using Corners = tbb::concurrent_unordered_map<TimeCamId, KeypointsData>; using Corners = tbb::concurrent_unordered_map<TimeCamId, KeypointsData,
std::hash<TimeCamId>>;
/// feature matches for an image pair /// feature matches for an image pair
struct MatchData { struct MatchData {
@ -127,7 +128,7 @@ struct MatchData {
/// feature matches is a collection of { (imageId, imageId) => MatchData } /// feature matches is a collection of { (imageId, imageId) => MatchData }
using Matches = tbb::concurrent_unordered_map< using Matches = tbb::concurrent_unordered_map<
std::pair<TimeCamId, TimeCamId>, MatchData, std::pair<TimeCamId, TimeCamId>, MatchData,
tbb::tbb_hash<std::pair<TimeCamId, TimeCamId>>, std::hash<std::pair<TimeCamId, TimeCamId>>,
std::equal_to<std::pair<TimeCamId, TimeCamId>>, std::equal_to<std::pair<TimeCamId, TimeCamId>>,
Eigen::aligned_allocator< Eigen::aligned_allocator<
std::pair<const std::pair<TimeCamId, TimeCamId>, MatchData>>>; std::pair<const std::pair<TimeCamId, TimeCamId>, MatchData>>>;

View File

@ -57,12 +57,6 @@ class HashBow;
class NfrMapper : public BundleAdjustmentBase { class NfrMapper : public BundleAdjustmentBase {
public: public:
using Ptr = std::shared_ptr<NfrMapper>; using Ptr = std::shared_ptr<NfrMapper>;
using Matches = tbb::concurrent_unordered_map<
std::pair<TimeCamId, TimeCamId>, MatchData,
tbb::tbb_hash<std::pair<TimeCamId, TimeCamId>>,
std::equal_to<std::pair<TimeCamId, TimeCamId>>,
Eigen::aligned_allocator<
std::pair<const std::pair<TimeCamId, TimeCamId>, MatchData>>>;
template <class AccumT> template <class AccumT>
struct MapperLinearizeAbsReduce struct MapperLinearizeAbsReduce

View File

@ -97,11 +97,9 @@ bool estimateTransformation(
return ransac.inliers_.size() > 8; return ransac.inliers_.size() > 8;
} }
void CalibHelper::detectCorners( void CalibHelper::detectCorners(const VioDatasetPtr &vio_data,
const VioDatasetPtr &vio_data, CalibCornerMap &calib_corners,
tbb::concurrent_unordered_map<TimeCamId, CalibCornerData> &calib_corners, CalibCornerMap &calib_corners_rejected) {
tbb::concurrent_unordered_map<TimeCamId, CalibCornerData>
&calib_corners_rejected) {
calib_corners.clear(); calib_corners.clear();
calib_corners_rejected.clear(); calib_corners_rejected.clear();
@ -144,9 +142,7 @@ void CalibHelper::detectCorners(
void CalibHelper::initCamPoses( void CalibHelper::initCamPoses(
const Calibration<double>::Ptr &calib, const Calibration<double>::Ptr &calib,
const Eigen::aligned_vector<Eigen::Vector4d> &aprilgrid_corner_pos_3d, const Eigen::aligned_vector<Eigen::Vector4d> &aprilgrid_corner_pos_3d,
tbb::concurrent_unordered_map<TimeCamId, CalibCornerData> &calib_corners, CalibCornerMap &calib_corners, CalibInitPoseMap &calib_init_poses) {
tbb::concurrent_unordered_map<TimeCamId, CalibInitPoseData>
&calib_init_poses) {
calib_init_poses.clear(); calib_init_poses.clear();
std::vector<TimeCamId> corners; std::vector<TimeCamId> corners;

View File

@ -83,7 +83,8 @@ basalt::VioDatasetPtr vio_dataset;
basalt::VioConfig vio_config; basalt::VioConfig vio_config;
basalt::OpticalFlowBase::Ptr opt_flow_ptr; basalt::OpticalFlowBase::Ptr opt_flow_ptr;
tbb::concurrent_unordered_map<int64_t, basalt::OpticalFlowResult::Ptr> tbb::concurrent_unordered_map<int64_t, basalt::OpticalFlowResult::Ptr,
std::hash<int64_t>>
observations; observations;
tbb::concurrent_bounded_queue<basalt::OpticalFlowResult::Ptr> tbb::concurrent_bounded_queue<basalt::OpticalFlowResult::Ptr>
observations_queue; observations_queue;

View File

@ -130,7 +130,7 @@ Eigen::aligned_vector<Eigen::Vector3d> gt_t_w_i;
std::string marg_data_path; std::string marg_data_path;
size_t last_frame_processed = 0; size_t last_frame_processed = 0;
tbb::concurrent_unordered_map<int64_t, int> timestamp_to_id; tbb::concurrent_unordered_map<int64_t, int, std::hash<int64_t>> timestamp_to_id;
std::mutex m; std::mutex m;
std::condition_variable cv; std::condition_variable cv;