Switch to a preconfigured Clang for k8 and armv7
This one reuses more of Bazel's builtin features to remain up to date
more easily, and it's easier to expand support for more platforms. This
also takes care of upgrading to a newer Clang.
This will require updating to raspios bullseye on the Raspberry Pis.
This also renames armhf-debian to armv7 to match the broader Bazel
ecosystem's name for this architecture.
Change-Id: I3e2a4f4efea43e76314ca34a9293c7b4b45edd2c
Signed-off-by: Brian Silverman <bsilver16834@gmail.com>
diff --git a/y2020/vision/camera_reader.cc b/y2020/vision/camera_reader.cc
index 64e7948..1e28e82 100644
--- a/y2020/vision/camera_reader.cc
+++ b/y2020/vision/camera_reader.cc
@@ -241,7 +241,7 @@
cv::Mat mask;
cv::Mat homography =
cv::findHomography(per_image.training_points, per_image.query_points,
- CV_RANSAC, 3.0, mask);
+ cv::FM_RANSAC, 3.0, mask);
const int homography_feature_count = cv::countNonZero(mask);
// If mask doesn't have enough leftover matches, skip these matches
@@ -341,7 +341,7 @@
cv::solvePnP(per_image_good_match.training_points_3d,
per_image_good_match.query_points, CameraIntrinsics(),
CameraDistCoeffs(), R_camera_field_vec, T_camera_field,
- FLAGS_use_prev_pose, CV_ITERATIVE);
+ FLAGS_use_prev_pose, cv::SOLVEPNP_ITERATIVE);
}
// We are occasionally seeing NaN in the prior estimate, so checking for
diff --git a/y2020/vision/charuco_lib.cc b/y2020/vision/charuco_lib.cc
index 856c560..21bdcc3 100644
--- a/y2020/vision/charuco_lib.cc
+++ b/y2020/vision/charuco_lib.cc
@@ -146,7 +146,7 @@
(void *)image.data()->data());
const cv::Size image_size(image.cols(), image.rows());
cv::Mat rgb_image(image_size, CV_8UC3);
- cv::cvtColor(image_color_mat, rgb_image, CV_YUV2BGR_YUYV);
+ cv::cvtColor(image_color_mat, rgb_image, cv::COLOR_YUV2BGR_YUYV);
handle_image_(rgb_image, eof);
});
}
diff --git a/y2020/vision/sift/fast_gaussian.bzl b/y2020/vision/sift/fast_gaussian.bzl
index b699282..fdf5afe 100644
--- a/y2020/vision/sift/fast_gaussian.bzl
+++ b/y2020/vision/sift/fast_gaussian.bzl
@@ -37,12 +37,12 @@
]) + " " + cpu_select({
"amd64": "k8",
"roborio": "roborio",
- "armhf": "armhf-debian",
+ "armhf": "armv7",
"cortex-m": "cortex-m",
"cortex-m0plus": "cortex-m0plus",
}),
outs = headers + objects + htmls,
- # The tool doesn't support anything other than k8 and armhf-debian
+ # The tool doesn't support anything other than k8 and armv7.
# right now.
target_compatible_with = platforms.any_of([
"@platforms//cpu:x86_64",
diff --git a/y2020/vision/sift/fast_gaussian_halide_generator.sh b/y2020/vision/sift/fast_gaussian_halide_generator.sh
index d808296..a90f218 100755
--- a/y2020/vision/sift/fast_gaussian_halide_generator.sh
+++ b/y2020/vision/sift/fast_gaussian_halide_generator.sh
@@ -29,7 +29,7 @@
ZLIB1G_DEV="$(mktemp -d)"
-LLVM_TOOLCHAIN="$(dirname "$(dirname "$(rlocation llvm_toolchain_llvm/bin/clang)")")"
+LLVM_TOOLCHAIN="$(dirname "$(dirname "$(rlocation llvm_k8/bin/clang)")")"
dpkg-deb -x "${ZLIB1G_DEV_AMD64_DEB}" "${ZLIB1G_DEV}"
TARGET=x86_64-unknown-linux-gnu
MULTIARCH=x86_64-linux-gnu
@@ -40,8 +40,8 @@
-fcolor-diagnostics \
-I"${HALIDE}/include" \
-nostdinc \
- -isystem"${SYSROOT}/usr/include/c++/7" \
- -isystem"${SYSROOT}/usr/include/${MULTIARCH}/c++/7" \
+ -isystem"${SYSROOT}/usr/include/c++/10" \
+ -isystem"${SYSROOT}/usr/include/${MULTIARCH}/c++/10" \
-isystem"${SYSROOT}/usr/include/c++/7/backward" \
-isystem"${LLVM_TOOLCHAIN}/lib/clang/13.0.0/include" \
-isystem"${SYSROOT}/usr/include/${MULTIARCH}" \
diff --git a/y2020/vision/sift/fast_gaussian_runner.py b/y2020/vision/sift/fast_gaussian_runner.py
index 6faa9fc..cc45208 100755
--- a/y2020/vision/sift/fast_gaussian_runner.py
+++ b/y2020/vision/sift/fast_gaussian_runner.py
@@ -16,7 +16,7 @@
target_cpu = sys.argv[3]
target = {
- 'armhf-debian': 'arm-32-linux-no_asserts',
+ 'armv7': 'arm-32-linux-no_asserts',
'k8': 'x86-64-linux-no_asserts',
}[target_cpu]
diff --git a/y2020/vision/sift/fast_gaussian_test.cc b/y2020/vision/sift/fast_gaussian_test.cc
index a34c6c7..73fd8a7 100644
--- a/y2020/vision/sift/fast_gaussian_test.cc
+++ b/y2020/vision/sift/fast_gaussian_test.cc
@@ -1,8 +1,8 @@
#include "y2020/vision/sift/fast_gaussian.h"
#include <opencv2/imgproc.hpp>
-#include "gtest/gtest.h"
+#include "gtest/gtest.h"
#include "y2020/vision/sift/fast_gaussian_all.h"
namespace frc971 {
@@ -36,13 +36,14 @@
ExpectEqual(default_blurred, explicitly_blurred);
}
-// Verifies that with 8U just a 9x9 blur is as much as you get.
-TEST_F(FastGaussianTest, GaussianSizeS8) {
+// Verifies that with 8U just a 9x9 blur is as much as you get, except for a bit
+// of rounding.
+TEST_F(FastGaussianTest, GaussianSize8U) {
const auto image = RandomImage(500, 500, CV_8UC3);
cv::Mat big_blurred, little_blurred;
cv::GaussianBlur(image, big_blurred, cv::Size(15, 15), 1.6, 1.6);
cv::GaussianBlur(image, little_blurred, cv::Size(9, 9), 1.6, 1.6);
- ExpectEqual(big_blurred, little_blurred);
+ ExpectEqual(big_blurred, little_blurred, 3);
}
// Verifies that FastGaussian and cv::GaussianBlur give the same result.
@@ -62,7 +63,6 @@
DoGeneratedFastGaussian(MatToHalide<const int16_t>(image),
MatToHalide<int16_t>(fast_direct), kSigma));
-
// 1500/65536 = 0.0228, which is under 3%, which is pretty close.
ExpectEqual(slow, fast, 1500);
// The wrapper should be calling the exact same code, so it should end up with
diff --git a/y2020/vision/viewer.cc b/y2020/vision/viewer.cc
index c141e3c..2aff3fb 100644
--- a/y2020/vision/viewer.cc
+++ b/y2020/vision/viewer.cc
@@ -69,7 +69,7 @@
cv::Mat image_color_mat(cv::Size(image->cols(), image->rows()), CV_8UC2,
(void *)image->data()->data());
cv::Mat rgb_image(cv::Size(image->cols(), image->rows()), CV_8UC3);
- cv::cvtColor(image_color_mat, rgb_image, CV_YUV2BGR_YUYV);
+ cv::cvtColor(image_color_mat, rgb_image, cv::COLOR_YUV2BGR_YUYV);
if (!FLAGS_capture.empty()) {
cv::imwrite(FLAGS_capture, rgb_image);
@@ -119,7 +119,7 @@
int keystroke = cv::waitKey(1);
if ((keystroke & 0xFF) == static_cast<int>('c')) {
// Convert again, to get clean image
- cv::cvtColor(image_color_mat, rgb_image, CV_YUV2BGR_YUYV);
+ cv::cvtColor(image_color_mat, rgb_image, cv::COLOR_YUV2BGR_YUYV);
std::stringstream name;
name << "capture-" << aos::realtime_clock::now() << ".png";
cv::imwrite(name.str(), rgb_image);