Skip to content

Commit

Permalink
Use flooring instead of rounding when computing a grid index
Browse files Browse the repository at this point in the history
  • Loading branch information
shinsumicco committed Feb 21, 2020
1 parent 51806a3 commit 57ed306
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/openvslam/data/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ auto assign_keypoints_to_grid(camera::base* camera, const std::vector<cv::KeyPoi
* @return
*/
inline bool get_cell_indices(camera::base* camera, const cv::KeyPoint& keypt, int& cell_idx_x, int& cell_idx_y) {
cell_idx_x = cvRound((keypt.pt.x - camera->img_bounds_.min_x_) * camera->inv_cell_width_);
cell_idx_y = cvRound((keypt.pt.y - camera->img_bounds_.min_y_) * camera->inv_cell_height_);
cell_idx_x = cvFloor((keypt.pt.x - camera->img_bounds_.min_x_) * camera->inv_cell_width_);
cell_idx_y = cvFloor((keypt.pt.y - camera->img_bounds_.min_y_) * camera->inv_cell_height_);
return (0 <= cell_idx_x && cell_idx_x < static_cast<int>(camera->num_grid_cols_)
&& 0 <= cell_idx_y && cell_idx_y < static_cast<int>(camera->num_grid_rows_));
}
Expand Down

0 comments on commit 57ed306

Please sign in to comment.