diff --git a/common/BUILD b/common/BUILD index ed0bddf6..db426109 100644 --- a/common/BUILD +++ b/common/BUILD @@ -106,3 +106,14 @@ cc_test( "@com_google_googletest//:gtest_main", ], ) + +cc_library( + name = "video", + hdrs = ["video.hh"], + srcs = ["video.cc"], + deps = [ + "@eigen", + "@opencv", + ], + visibility = ["//visibility:public"] +) \ No newline at end of file diff --git a/common/video.cc b/common/video.cc new file mode 100644 index 00000000..19cd6709 --- /dev/null +++ b/common/video.cc @@ -0,0 +1,15 @@ +#include "opencv2/opencv.hpp" + +namespace robot::common { + +bool images_equal(const cv::Mat& img1, const cv::Mat& img2) { + if (img1.size() != img2.size() || img1.type() != img2.type()) { + return false; + } + cv::Mat diff; + cv::absdiff(img1, img2, diff); + diff = diff.reshape(1); + return cv::countNonZero(diff) == 0; +} + +} diff --git a/common/video.hh b/common/video.hh new file mode 100644 index 00000000..369f1a42 --- /dev/null +++ b/common/video.hh @@ -0,0 +1,9 @@ +#pragma once + +#include "opencv2/opencv.hpp" + +namespace robot::common { + +bool images_equal(const cv::Mat& img1, const cv::Mat& img2); + +} \ No newline at end of file