diff --git a/modules/imgproc/src/lsd.cpp b/modules/imgproc/src/lsd.cpp index 969d617caf..a467833405 100644 --- a/modules/imgproc/src/lsd.cpp +++ b/modules/imgproc/src/lsd.cpp @@ -267,6 +267,8 @@ private: struct coorlist* next; }; + std::vector list; + struct rect { double x1, y1, x2, y2; // first and second point of the line segment @@ -306,7 +308,7 @@ private: * @param list Return: Vector of coordinate points that are pseudo ordered by magnitude. * Pixels would be ordered by norm value, up to a precision given by max_grad/n_bins. */ - void ll_angle(const double& threshold, const unsigned int& n_bins, std::vector& list); + void ll_angle(const double& threshold, const unsigned int& n_bins); /** * Grow a region starting from point s with a defined precision, @@ -438,7 +440,6 @@ void LineSegmentDetectorImpl::flsd(std::vector& lines, const double p = ANG_TH / 180; const double rho = QUANT / sin(prec); // gradient magnitude threshold - std::vector list; if(SCALE != 1) { Mat gaussian_img; @@ -449,12 +450,12 @@ void LineSegmentDetectorImpl::flsd(std::vector& lines, GaussianBlur(image, gaussian_img, ksize, sigma); // Scale image to needed size resize(gaussian_img, scaled_image, Size(), SCALE, SCALE); - ll_angle(rho, N_BINS, list); + ll_angle(rho, N_BINS); } else { scaled_image = image; - ll_angle(rho, N_BINS, list); + ll_angle(rho, N_BINS); } LOG_NT = 5 * (log10(double(img_width)) + log10(double(img_height))) / 2 + log10(11.0); @@ -518,8 +519,7 @@ void LineSegmentDetectorImpl::flsd(std::vector& lines, } void LineSegmentDetectorImpl::ll_angle(const double& threshold, - const unsigned int& n_bins, - std::vector& list) + const unsigned int& n_bins) { //Initialize data angles = Mat_(scaled_image.size()); @@ -564,7 +564,7 @@ void LineSegmentDetectorImpl::ll_angle(const double& threshold, } // Compute histogram of gradient values - list = std::vector(img_width * img_height); + list.resize(img_width * img_height); std::vector range_s(n_bins); std::vector range_e(n_bins); unsigned int count = 0;