Commit 229cd729 authored by Deni's avatar Deni Committed by Alexander Alekhin

Merge pull request #2309 from deni64k:master

Fix memory corruption in RgbdPlane

* Fix memory corruption

* Use divUp instead of explicit rounding up integer division

* rgbd: add test
parent 8fde8d74
......@@ -584,8 +584,8 @@ private:
plane = Ptr<PlaneBase>(new PlaneABC(plane_grid.m_(y, x), n, (int)index_plane,
(float)sensor_error_a_, (float)sensor_error_b_, (float)sensor_error_c_));
Mat_<unsigned char> plane_mask = Mat_<unsigned char>::zeros(points3d.rows / block_size_,
points3d.cols / block_size_);
Mat_<unsigned char> plane_mask = Mat_<unsigned char>::zeros(divUp(points3d.rows, block_size_),
divUp(points3d.cols, block_size_));
std::set<TileQueue::PlaneTile> neighboring_tiles;
neighboring_tiles.insert(front_tile);
plane_queue.remove(front_tile.y_, front_tile.x_);
......
......@@ -470,4 +470,15 @@ TEST(Rgbd_Plane, compute)
test.safe_run();
}
TEST(Rgbd_Plane, regression_2309_valgrind_check)
{
Mat points(640, 480, CV_32FC3, Scalar::all(0));
rgbd::RgbdPlane plane_detector;
plane_detector.setBlockSize(9); // Note, 640%9 is 1 and 480%9 is 3
Mat mask;
std::vector<cv::Vec4f> planes;
plane_detector(points, mask, planes); // Will corrupt memory; valgrind gets triggered
}
}} // namespace
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment