update 读图强制读取灰度图

dev_heyuan
liusiyang 3 months ago
parent a2adff60e8
commit 7c0dea2fac

@ -129,11 +129,11 @@ int AI_Edge_QX_Det::Detect(const cv::Mat &img, cv::Mat &detmask, DetConfig *pDet
m_pdetlog = pdetlog; m_pdetlog = pdetlog;
if (pDetConfig->ninstruct == 767) if (pDetConfig->ninstruct == 767)
{ {
// nRuntype = 1; nRuntype = 1;
} }
else if (pDetConfig->ninstruct == 768) else if (pDetConfig->ninstruct == 768)
{ {
// nRuntype = 2; nRuntype = 2;
} }
bool bdege = false; bool bdege = false;

@ -225,7 +225,7 @@ bool LoadImage::matchesExtension(
cv::Mat LoadImage::loadImageFile(const fs::path &path) const cv::Mat LoadImage::loadImageFile(const fs::path &path) const
{ {
// 使用 IMREAD_UNCHANGED 保留原图通道和位深信息 // 使用 IMREAD_UNCHANGED 保留原图通道和位深信息
return cv::imread(path.string(), cv::IMREAD_UNCHANGED); return cv::imread(path.string(), cv::IMREAD_GRAYSCALE);
} }
/// @brief 加载指定目录下的所有图片(产品 - 图片对两层结构) /// @brief 加载指定目录下的所有图片(产品 - 图片对两层结构)

@ -100,7 +100,7 @@ bool customSort(const AI_Det_Channel_ &a, const AI_Det_Channel_ &b)
// 定义图片读取函数 // 定义图片读取函数
void readImage(const std::string &filename) void readImage(const std::string &filename)
{ {
cv::Mat image = cv::imread(filename); cv::Mat image = cv::imread(filename, cv::IMREAD_GRAYSCALE);
if (image.empty()) if (image.empty())
{ {
std::cerr << "Error: Unable to read image " << filename << std::endl; std::cerr << "Error: Unable to read image " << filename << std::endl;
@ -1912,7 +1912,7 @@ void deal::ProductReadImgThreadFunc(int threadId)
// 读取左图 // 读取左图
long startTime = getcurTime(); long startTime = getcurTime();
cv::Mat left_img; cv::Mat left_img;
cv::Mat img16 = cv::imread(task->left_path, cv::IMREAD_UNCHANGED); cv::Mat img16 = cv::imread(task->left_path, cv::IMREAD_GRAYSCALE);
if (!img16.empty()) if (!img16.empty())
{ {
@ -1936,7 +1936,7 @@ void deal::ProductReadImgThreadFunc(int threadId)
// 读取右图 // 读取右图
cv::Mat right_img; cv::Mat right_img;
img16 = cv::imread(task->right_path, cv::IMREAD_UNCHANGED); img16 = cv::imread(task->right_path, cv::IMREAD_GRAYSCALE);
if (!img16.empty()) if (!img16.empty())
{ {
@ -2095,7 +2095,7 @@ int deal::ReJson_product(std::vector<Json_Det_Path> &jsonList, std::string strPr
std::string json_str = buffer.str(); // 获取 JSON 文件的内容作为字符串 std::string json_str = buffer.str(); // 获取 JSON 文件的内容作为字符串
// 显示读取到的 JSON 字符串 // 显示读取到的 JSON 字符串
// std::cout << "JSON content: " << json_str << std::endl; // std::cout << "JSON content: " << json_str << std::endl;
cv::Mat cutimg = cv::imread(strimg, 0); cv::Mat cutimg = cv::imread(strimg, cv::IMREAD_GRAYSCALE);
int f0 = strJson.rfind('_'); int f0 = strJson.rfind('_');
int f1 = strJson.rfind('.'); int f1 = strJson.rfind('.');
int f2 = strJson.rfind('/'); int f2 = strJson.rfind('/');
@ -2420,7 +2420,7 @@ void deal::Thread_ReadImg(int id)
printf("pImageInfo == nullptr=================id %d=============\n", id); printf("pImageInfo == nullptr=================id %d=============\n", id);
return; return;
} }
pImageInfo->img = cv::imread(pImageInfo->strPath, 0); pImageInfo->img = cv::imread(pImageInfo->strPath, cv::IMREAD_GRAYSCALE);
m_ReadImgThread_Result[id] = pImageInfo; m_ReadImgThread_Result[id] = pImageInfo;
// 线程完成读图,设置现场状态为 完成 // 线程完成读图,设置现场状态为 完成

Loading…
Cancel
Save