diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2013-10-09 00:33:17 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2013-10-09 00:33:17 +0200 |
commit | e74cad83f41e759a37a56c623dafe2d05a692129 (patch) | |
tree | e1dfbd45fa450b5387a389679fe8ac87cd2a0f6d | |
parent | cdd9a365e08e6fdd0d44199c39d990a46df563e0 (diff) |
blur before segmenting to win big (2x perf)
Signed-off-by: Stanislaw Halik <sthalik@misaki.pl>
-rw-r--r-- | ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
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); |