From e74cad83f41e759a37a56c623dafe2d05a692129 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 9 Oct 2013 00:33:17 +0200 Subject: blur before segmenting to win big (2x perf) Signed-off-by: Stanislaw Halik --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'ftnoir_tracker_aruco') diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 781bf711..8025e956 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -188,7 +188,7 @@ void Tracker::run() aruco::MarkerDetector detector; detector.setDesiredSpeed(3); detector.setThresholdParams(11, 5); - cv::Mat color, color_, grayscale, rvec, tvec; + cv::Mat color, color_, grayscale, grayscale2, rvec, tvec; if (!camera.isOpened()) { @@ -201,7 +201,12 @@ void Tracker::run() if (!camera.read(color_)) continue; color_.copyTo(color); - cv::cvtColor(color, grayscale, cv::COLOR_BGR2GRAY); + cv::cvtColor(color, grayscale2, cv::COLOR_BGR2GRAY); + const int kernel = grayscale2.cols > 480 ? 7 : 5; + int kernel2 = kernel * grayscale2.rows / grayscale2.cols; + if ((kernel2 % 2) == 0) + kernel2++; + cv::GaussianBlur(grayscale2, grayscale, cv::Size(kernel, kernel2), 0, 0); const float focal_length_w = 0.5 * grayscale.cols / tan(0.5 * fov * HT_PI / 180); const float focal_length_h = 0.5 * grayscale.rows / tan(0.5 * fov * grayscale.rows / grayscale.cols * HT_PI / 180.0); cv::Mat intrinsics = cv::Mat::eye(3, 3, CV_32FC1); -- cgit v1.2.3