From 62739acc2835108bcbe9d5def89da7933437f253 Mon Sep 17 00:00:00 2001 From: oneLOH <503417472@qq.com> Date: Fri, 7 Jun 2024 14:50:20 +0800 Subject: [PATCH] fix bug: convert gray images --- src/tag/tag_extract.hpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/tag/tag_extract.hpp b/src/tag/tag_extract.hpp index e706a38..c4bf2d9 100644 --- a/src/tag/tag_extract.hpp +++ b/src/tag/tag_extract.hpp @@ -46,9 +46,14 @@ tag_extract(std::string image_dir) { for (auto &image_name : image_vec) { std::string img_path = image_dir + image_name; - cv::Mat frame, gray; - frame = cv::imread(img_path.c_str(), cv::IMREAD_IGNORE_ORIENTATION); - cv::cvtColor(frame, gray, cv::COLOR_BGR2GRAY); + cv::Mat image, gray; + image = cv::imread(img_path.c_str(), cv::IMREAD_IGNORE_ORIENTATION); + if (image.type() != CV_8UC1) { + cv::cvtColor(image, gray, cv::COLOR_RGB2GRAY); + } else { + gray = image; + } + image_u8_t im = {.width = gray.cols, .height = gray.rows, .stride = gray.cols,