Skip to content

Commit 7d7312a

Browse files
committed
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
2 parents 3e9ebc4 + 94d1b9b commit 7d7312a

File tree

4 files changed

+33
-17
lines changed

4 files changed

+33
-17
lines changed

modules/rgbd/src/plane.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -555,8 +555,8 @@ class InlierFinder
555555
plane = Ptr<PlaneBase>(new PlaneABC(plane_grid.m_(y, x), n, (int)index_plane,
556556
(float)sensor_error_a_, (float)sensor_error_b_, (float)sensor_error_c_));
557557

558-
Mat_<unsigned char> plane_mask = Mat_<unsigned char>::zeros(points3d.rows / block_size_,
559-
points3d.cols / block_size_);
558+
Mat_<unsigned char> plane_mask = Mat_<unsigned char>::zeros(divUp(points3d.rows, block_size_),
559+
divUp(points3d.cols, block_size_));
560560
std::set<TileQueue::PlaneTile> neighboring_tiles;
561561
neighboring_tiles.insert(front_tile);
562562
plane_queue.remove(front_tile.y_, front_tile.x_);

modules/rgbd/test/test_normal.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,4 +441,15 @@ TEST(Rgbd_Plane, compute)
441441
test.safe_run();
442442
}
443443

444+
TEST(Rgbd_Plane, regression_2309_valgrind_check)
445+
{
446+
Mat points(640, 480, CV_32FC3, Scalar::all(0));
447+
rgbd::RgbdPlane plane_detector;
448+
plane_detector.setBlockSize(9); // Note, 640%9 is 1 and 480%9 is 3
449+
450+
Mat mask;
451+
std::vector<cv::Vec4f> planes;
452+
plane_detector(points, mask, planes); // Will corrupt memory; valgrind gets triggered
453+
}
454+
444455
}} // namespace

modules/text/src/text_detectorCNN.cpp

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,29 @@ class TextDetectorCNNImpl : public TextDetectorCNN
2929
{
3030
for(int k = 0; k < nbrTextBoxes; k++)
3131
{
32-
float x_min = buffer[k*nCol + 3]*inputShape.width;
33-
float y_min = buffer[k*nCol + 4]*inputShape.height;
32+
float confidence_ = buffer[k*nCol + 2];
33+
if (confidence_ <= FLT_EPSILON) continue;
3434

35-
float x_max = buffer[k*nCol + 5]*inputShape.width;
36-
float y_max = buffer[k*nCol + 6]*inputShape.height;
35+
float x_min_f = buffer[k*nCol + 3]*inputShape.width;
36+
float y_min_f = buffer[k*nCol + 4]*inputShape.height;
3737

38-
CV_CheckLT(x_min, x_max, "");
39-
CV_CheckLT(y_min, y_max, "");
38+
float x_max_f = buffer[k*nCol + 5]*inputShape.width;
39+
float y_max_f = buffer[k*nCol + 6]*inputShape.height;
4040

41-
x_min = std::max(0.f, x_min);
42-
y_min = std::max(0.f, y_min);
41+
int x_min = cvRound(std::max(0.f, x_min_f));
42+
int y_min = cvRound(std::max(0.f, y_min_f));
4343

44-
x_max = std::min(inputShape.width - 1.f, x_max);
45-
y_max = std::min(inputShape.height - 1.f, y_max);
44+
int x_max = std::min(inputShape.width - 1, cvRound(x_max_f));
45+
int y_max = std::min(inputShape.height - 1, cvRound(y_max_f));
4646

47-
int wd = cvRound(x_max - x_min);
48-
int ht = cvRound(y_max - y_min);
47+
if (x_min >= x_max) continue;
48+
if (y_min >= y_max) continue;
4949

50-
Bbox.push_back(Rect(cvRound(x_min), cvRound(y_min), wd, ht));
51-
confidence.push_back(buffer[k*nCol + 2]);
50+
int wd = x_max - x_min;
51+
int ht = y_max - y_min;
52+
53+
Bbox.push_back(Rect(x_min, y_min, wd, ht));
54+
confidence.push_back(confidence_);
5255
}
5356
}
5457

modules/xfeatures2d/src/sift.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@
107107
#include <stdarg.h>
108108
#include <opencv2/core/hal/hal.hpp>
109109

110+
#include <opencv2/core/utils/tls.hpp>
111+
110112
namespace cv
111113
{
112114
namespace xfeatures2d
@@ -709,7 +711,7 @@ void SIFT_Impl::findScaleSpaceExtrema( const std::vector<Mat>& gauss_pyr, const
709711
const int threshold = cvFloor(0.5 * contrastThreshold / nOctaveLayers * 255 * SIFT_FIXPT_SCALE);
710712

711713
keypoints.clear();
712-
TLSData<std::vector<KeyPoint> > tls_kpts_struct;
714+
TLSDataAccumulator<std::vector<KeyPoint> > tls_kpts_struct;
713715

714716
for( int o = 0; o < nOctaves; o++ )
715717
for( int i = 1; i <= nOctaveLayers; i++ )

0 commit comments

Comments
 (0)