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
};
using CalibCornerMap = tbb::concurrent_unordered_map<TimeCamId, CalibCornerData,
std::hash<TimeCamId>>;
using CalibInitPoseMap =
tbb::concurrent_unordered_map<TimeCamId, CalibInitPoseData,
std::hash<TimeCamId>>;
class CalibHelper {
public:
static void detectCorners(
const VioDatasetPtr& vio_data,
tbb::concurrent_unordered_map<TimeCamId, CalibCornerData>& calib_corners,
tbb::concurrent_unordered_map<TimeCamId, CalibCornerData>&
calib_corners_rejected);
static void detectCorners(const VioDatasetPtr& vio_data,
CalibCornerMap& calib_corners,
CalibCornerMap& calib_corners_rejected);
static void initCamPoses(
const Calibration<double>::Ptr& calib,
const Eigen::aligned_vector<Eigen::Vector4d>& aprilgrid_corner_pos_3d,
tbb::concurrent_unordered_map<TimeCamId, CalibCornerData>& calib_corners,
tbb::concurrent_unordered_map<TimeCamId, CalibInitPoseData>&
calib_init_poses);
CalibCornerMap& calib_corners, CalibInitPoseMap& calib_init_poses);
static bool initializeIntrinsics(
const Eigen::aligned_vector<Eigen::Vector2d>& corners,

View File

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

View File

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

View File

@ -195,7 +195,9 @@ class FrameToFrameOpticalFlow : public OpticalFlowBase {
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) {
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);
}
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) {
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 }
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
struct MatchData {
@ -127,7 +128,7 @@ struct MatchData {
/// feature matches is a collection of { (imageId, imageId) => MatchData }
using Matches = tbb::concurrent_unordered_map<
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>>,
Eigen::aligned_allocator<
std::pair<const std::pair<TimeCamId, TimeCamId>, MatchData>>>;

View File

@ -57,12 +57,6 @@ class HashBow;
class NfrMapper : public BundleAdjustmentBase {
public:
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>
struct MapperLinearizeAbsReduce

View File

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

View File

@ -83,7 +83,8 @@ basalt::VioDatasetPtr vio_dataset;
basalt::VioConfig vio_config;
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;
tbb::concurrent_bounded_queue<basalt::OpticalFlowResult::Ptr>
observations_queue;

View File

@ -130,7 +130,7 @@ Eigen::aligned_vector<Eigen::Vector3d> gt_t_w_i;
std::string marg_data_path;
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::condition_variable cv;