From be9690a01ccf5e66f10ae337e2f6e6e61518002c Mon Sep 17 00:00:00 2001
From: asantamaria <asantamaria@iri.upc.edu>
Date: Thu, 10 Jan 2019 15:40:53 +0100
Subject: [PATCH] FIX: cell size as float

---
 src/vision_utils.h | 26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)

diff --git a/src/vision_utils.h b/src/vision_utils.h
index d567ea4..23c13e2 100644
--- a/src/vision_utils.h
+++ b/src/vision_utils.h
@@ -222,13 +222,15 @@ public:
 	FeatureIdxGrid(const size_t& _img_height, const size_t& _img_width, const size_t& _n_cell_rows, const size_t& _n_cell_cols) :
 		n_cell_rows_(_n_cell_rows),
 		n_cell_cols_(_n_cell_cols),
-		cell_width_(_img_width / _n_cell_cols),
-		cell_height_(_img_height / _n_cell_rows),
+		cell_width_((float) _img_width / _n_cell_cols),
+		cell_height_((float)_img_height / _n_cell_rows),
 		grid_(_n_cell_rows, std::vector<FeatureIdxMap>(_n_cell_cols,FeatureIdxMap())),
 		tracking_grid_(Eigen::MatrixXi::Zero(_n_cell_rows,_n_cell_cols)),
 		empty_cells_tile_tmp_(Eigen::MatrixXi::Zero(2,n_cell_rows_ * n_cell_cols_))
 	{
-		//
+        //VU_DEBUG("CELL SIZE: " << cell_width_ << " x " << cell_height_ );
+        //VU_DEBUG("GRID SIZE: " << rows() << " x " << cols() );
+        //VU_DEBUG("IMAGE SIZE: " << _img_width << " x " << _img_height);
 	}
 
 	size_t numFeatures(const size_t& _row, const size_t& _col)
@@ -260,6 +262,16 @@ public:
 		empty_cells_tile_tmp_.setZero();
 	}
 
+	inline int rows()
+	{
+	        return n_cell_rows_;
+	}
+
+	inline int cols()
+	{
+	        return n_cell_cols_;
+	}
+
 	inline Eigen::Vector2i getCell(const cv::KeyPoint& _kp)
 	{
 		Eigen::Vector2i cell; // [Row Col]
@@ -270,8 +282,10 @@ public:
 
 	void insert(const cv::KeyPoint& _kp, const size_t& _idx)
 	{
-		Eigen::Vector2i cell = getCell(_kp);
-		grid_.at(cell(0)).at(cell(1)).emplace(_kp.response, _idx);
+	    Eigen::Vector2i cell = getCell(_kp);
+	    grid_.at(cell(0)).at(cell(1)).emplace(_kp.response, _idx);
+	    //VU_DEBUG("KP at " << _kp.pt.x << "," << _kp.pt.y);
+	    //VU_DEBUG("Inserted in CELL: " << cell(0) << "," << cell(1));
 	}
 
 	void insert(const KeyPointVector& _kps)
@@ -391,7 +405,7 @@ public:
 
 private:
 	 size_t n_cell_rows_, n_cell_cols_;
-	 size_t cell_width_, cell_height_;
+	 float cell_width_, cell_height_;
 	 Grid grid_;
 	 Eigen::MatrixXi tracking_grid_;
 	 Eigen::MatrixXi empty_cells_tile_tmp_;
-- 
GitLab