From 478baf937fd221dc15a4d16608b48880d1555f60 Mon Sep 17 00:00:00 2001 From: goldstar616 Date: Wed, 8 Feb 2017 23:29:20 +0900 Subject: [PATCH] Merge pull request #981 from goldstar616:master issue #980 resolves - Some module has a round error similar to #975. (#981) * round function changes to cvRound Minor changes to fix lower visual studio version build errors. * round function changes to cvRound Minor changes to fix lower visual studio version build errors. * round function changes to cvRound Minor changes to fix lower visual studio version build errors. --- modules/text/src/ocr_beamsearch_decoder.cpp | 2 +- modules/text/src/ocr_hmm_decoder.cpp | 2 +- modules/ximgproc/src/fast_line_detector.cpp | 16 ++++++++-------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/text/src/ocr_beamsearch_decoder.cpp b/modules/text/src/ocr_beamsearch_decoder.cpp index 4e7942eec..b067e0ebc 100644 --- a/modules/text/src/ocr_beamsearch_decoder.cpp +++ b/modules/text/src/ocr_beamsearch_decoder.cpp @@ -566,7 +566,7 @@ OCRBeamSearchClassifierCNN::OCRBeamSearchClassifierCNN (const string& filename) nr_feature = weights.rows; nr_class = weights.cols; - patch_size = (int)round(sqrt((float)kernels.cols)); + patch_size = cvRound(sqrt((float)kernels.cols)); window_size = 4*patch_size; step_size = 4; quad_size = 12; diff --git a/modules/text/src/ocr_hmm_decoder.cpp b/modules/text/src/ocr_hmm_decoder.cpp index a5fba688f..ea4c62d00 100644 --- a/modules/text/src/ocr_hmm_decoder.cpp +++ b/modules/text/src/ocr_hmm_decoder.cpp @@ -982,7 +982,7 @@ OCRHMMClassifierCNN::OCRHMMClassifierCNN (const string& filename) nr_feature = weights.rows; nr_class = weights.cols; - patch_size = (int)round(sqrt((float)kernels.cols)); + patch_size = cvRound(sqrt((float)kernels.cols)); // algorithm internal parameters window_size = 32; num_quads = 25; diff --git a/modules/ximgproc/src/fast_line_detector.cpp b/modules/ximgproc/src/fast_line_detector.cpp index 625e14e59..ffd7a5891 100644 --- a/modules/ximgproc/src/fast_line_detector.cpp +++ b/modules/ximgproc/src/fast_line_detector.cpp @@ -182,10 +182,10 @@ void FastLineDetectorImpl::drawSegments(InputOutputArray _image, InputArray line getAngle(seg); double ang = (double)seg.angle; Point2i p1; - p1.x = (int)round(seg.x2 - gap*cos(arrow_angle * CV_PI / 180.0 + ang)); - p1.y = (int)round(seg.y2 - gap*sin(arrow_angle * CV_PI / 180.0 + ang)); + p1.x = cvRound(seg.x2 - gap*cos(arrow_angle * CV_PI / 180.0 + ang)); + p1.y = cvRound(seg.y2 - gap*sin(arrow_angle * CV_PI / 180.0 + ang)); pointInboardTest(_image.getMatRef(), p1); - line(_image.getMatRef(), Point((int)round(seg.x2), (int)round(seg.y2)), p1, Scalar(0,0,255), 1); + line(_image.getMatRef(), Point(cvRound(seg.x2), cvRound(seg.y2)), p1, Scalar(0,0,255), 1); } } } @@ -717,14 +717,14 @@ void FastLineDetectorImpl::drawSegment(Mat& mat, const SEGMENT& seg, Scalar bgr, double arrow_angle = 30.0; Point2i p1; - p1.x = (int)round(seg.x2 - gap*cos(arrow_angle * CV_PI / 180.0 + ang)); - p1.y = (int)round(seg.y2 - gap*sin(arrow_angle * CV_PI / 180.0 + ang)); + p1.x = cvRound(seg.x2 - gap*cos(arrow_angle * CV_PI / 180.0 + ang)); + p1.y = cvRound(seg.y2 - gap*sin(arrow_angle * CV_PI / 180.0 + ang)); pointInboardTest(mat, p1); - line(mat, Point((int)round(seg.x1), (int)round(seg.y1)), - Point((int)round(seg.x2), (int)round(seg.y2)), bgr, thickness, 1); + line(mat, Point(cvRound(seg.x1), cvRound(seg.y1)), + Point(cvRound(seg.x2), cvRound(seg.y2)), bgr, thickness, 1); if(directed) - line(mat, Point((int)round(seg.x2), (int)round(seg.y2)), p1, bgr, thickness, 1); + line(mat, Point(cvRound(seg.x2), cvRound(seg.y2)), p1, bgr, thickness, 1); } } // namespace cv } // namespace ximgproc