From 0bbbe41c3ed408c6d70dbdba012e5c504ef8805e Mon Sep 17 00:00:00 2001 From: yangjiaxuan <171295266@qq.com> Date: Mon, 13 Nov 2023 17:21:47 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=81=8F=E8=89=B2=E6=A0=A1?= =?UTF-8?q?=E6=AD=A3=EF=BC=8C=E9=A9=B1=E5=8A=A8=E5=B1=82=E4=B8=8E=E7=AE=97?= =?UTF-8?q?=E6=B3=95=E5=B1=82=E6=8E=A5=E5=8F=A3=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ImageApplyColorCastCorrect.cpp | 47 ++++++++++++------- .../ImageProcess/ImageApplyColorCastCorrect.h | 17 ++++++- hgdriver/hgdev/image_process.cpp | 21 ++++++++- 3 files changed, 64 insertions(+), 21 deletions(-) diff --git a/hgdriver/ImageProcess/ImageApplyColorCastCorrect.cpp b/hgdriver/ImageProcess/ImageApplyColorCastCorrect.cpp index 76091e2..00c4189 100644 --- a/hgdriver/ImageProcess/ImageApplyColorCastCorrect.cpp +++ b/hgdriver/ImageProcess/ImageApplyColorCastCorrect.cpp @@ -8,35 +8,43 @@ #define min(a, b) ((a) < (b) ? (a) : (b)) constexpr auto SIZE_OF_TABLE = 256; -CImageApplyColorCastCorrect::CImageApplyColorCastCorrect(int pid) +CImageApplyColorCastCorrect::CImageApplyColorCastCorrect(PreScheme ps) : m_table_h(new uchar[SIZE_OF_TABLE]) , m_table_l(new uchar[SIZE_OF_TABLE]) , m_table_s(new uchar[SIZE_OF_TABLE]) { std::vector points_x, points_y; - - points_x = { 2, 9, 15, 18, 22, 34, 50, 63, 78, 92, 103, 114, 126, 137, 140, 147, 154, 163, 176, 200, 225, 248, 251, 254 }; - points_y = { 11, 17, 24, 28, 32, 41, 56, 81, 106, 115, 119, 124, 131, 138, 141, 145, 153, 166, 186, 201, 217, 251, 259, 264 }; - - if (0x300 == pid) + + switch (ps) { - points_x = { 0, 2, 5, 9, 15, 20, 26, 39, 54, 70, 83, 94, 102, 113, 128, 139, 146, 151, 156, 164, 177, 199, 232, 253 }; + case CImageApplyColorCastCorrect::G200: + points_x = { 2, 9, 15, 18, 22, 34, 50, 63, 78, 92, 103, 114, 126, 137, 140, 147, 154, 163, 176, 200, 225, 248, 251, 254 }; + points_y = { 11, 17, 24, 28, 32, 41, 56, 81, 106, 115, 119, 124, 131, 138, 141, 145, 153, 166, 186, 201, 217, 251, 259, 264 }; + break; + case CImageApplyColorCastCorrect::G300: + points_x = { 1, 7, 12, 18, 33, 52, 68, 81, 91, 100, 111, 125, 138, 142, 147, 153, 161, 172, 198, 230, 248, 250, 252, 253 }; + points_y = { 26, 31, 33, 36, 40, 44, 56, 92, 104, 114, 126, 135, 141, 143, 146, 151, 169, 198, 218, 227, 252, 266, 272, 276 }; + break; + case CImageApplyColorCastCorrect::G300_D8: + points_x = { 0, 2, 5, 9, 15, 20, 26, 39, 54, 70, 83, 94, 102, 113, 128, 139, 146, 151, 156, 164, 177, 199, 232, 253 }; points_y = { 11, 17, 21, 26, 31, 33, 36, 40, 44, 56, 92, 104, 114, 126, 135, 141, 143, 146, 151, 169, 198, 218, 227, 252 }; - } - else if (0x400 == pid) - { + break; + case CImageApplyColorCastCorrect::G400_402: + points_x = { 2, 8, 15, 20, 27, 41, 50, 67, 80, 91, 99, 109, 124, 138, 145, 150, 157, 164, 177, 202, 232, 250, 252, 255 }; + points_y = { 21, 26, 31, 33, 36, 40, 44, 56, 92, 104, 114, 126, 135, 141, 143, 146, 151, 169, 198, 218, 227, 252, 266, 272 }; + break; + case CImageApplyColorCastCorrect::G400_3288: points_x = { 2, 3, 5, 7, 11, 16, 19, 25, 40, 57, 72, 84, 95, 101, 111, 126, 144, 148, 152, 157, 165, 179, 203, 234 }; points_y = { -3, 11, 17, 21, 26, 31, 33, 36, 40, 44, 56, 92, 104, 114, 126, 135, 141, 143, 146, 151, 169, 198, 218, 227 }; - } - else if (0x302 == pid) - { + break; + case CImageApplyColorCastCorrect::Android302: points_x = { 0, 6, 11, 19, 37, 48, 66, 79, 89, 97, 108, 122, 138, 143, 147, 150, 158, 170, 199, 233, 248, 249, 250, 252 }; points_y = { 26, 31, 33, 36, 40, 44, 56, 92, 104, 114, 126, 135, 141, 143, 146, 151, 169, 198, 218, 227, 252, 266, 272, 276 }; - } - else if (0x402 == pid) - { - points_x = { 2, 8, 15, 20, 27, 41, 50, 67, 80, 91, 99, 109, 124, 138, 145, 150, 157, 164, 177, 202, 232, 250, 252, 255 }; - points_y = { 21, 26, 31, 33, 36, 40, 44, 56, 92, 104, 114, 126, 135, 141, 143, 146, 151, 169, 198, 218, 227, 252, 266, 272 }; + break; + default: + points_x = { 0, 255 }; + points_y = { 0, 255 }; + break; } createTable_h(points_x, points_y); @@ -53,6 +61,9 @@ CImageApplyColorCastCorrect::CImageApplyColorCastCorrect(int pid) CImageApplyColorCastCorrect::CImageApplyColorCastCorrect(const std::vector& h_x, const std::vector& h_y, const std::vector& l_x, const std::vector& l_y, const std::vector& s_x, const std::vector& s_y) + : m_table_h(new uchar[SIZE_OF_TABLE]) + , m_table_l(new uchar[SIZE_OF_TABLE]) + , m_table_s(new uchar[SIZE_OF_TABLE]) { if (!h_x.empty() && !h_y.empty()) createTable_h(h_x, h_y); diff --git a/hgdriver/ImageProcess/ImageApplyColorCastCorrect.h b/hgdriver/ImageProcess/ImageApplyColorCastCorrect.h index 63ab12c..8bae92e 100644 --- a/hgdriver/ImageProcess/ImageApplyColorCastCorrect.h +++ b/hgdriver/ImageProcess/ImageApplyColorCastCorrect.h @@ -11,7 +11,9 @@ * v1.3 2023/04/17 增加新查值表导入方式。 * v2.0 2023/05/15 重构查值表算法。 * v2.1 2023/10/07 添加饱和度、亮度调节,当前暂不开放参数设置接口。 - * 版本号:v2.1 + * v2.2 2023/11/13 增加预设方案 + * v2.2.1 2023/11/13 调整枚举类型词条 + * 版本号:v2.2.1 * ==================================================== */ @@ -24,7 +26,18 @@ class GIMGPROC_LIBRARY_API CImageApplyColorCastCorrect : public CImageApply { public: - CImageApplyColorCastCorrect(int pid); + //预设方案 + enum PreScheme + { + G200, + G300, + G300_D8, + G400_402, + G400_3288, + Android302 + }; + + CImageApplyColorCastCorrect(PreScheme ps = G200); CImageApplyColorCastCorrect(const std::vector& h_x, const std::vector& h_y, const std::vector& l_x, const std::vector& l_y, diff --git a/hgdriver/hgdev/image_process.cpp b/hgdriver/hgdev/image_process.cpp index 3b09e63..e17ca48 100644 --- a/hgdriver/hgdev/image_process.cpp +++ b/hgdriver/hgdev/image_process.cpp @@ -1411,7 +1411,26 @@ namespace hg_imgproc int ret = SCANNER_ERR_OK; std::vector mats(mats_); mats_.clear(); - CImageApplyColorCastCorrect ColorCastCorrect(pid_); + + CImageApplyColorCastCorrect::PreScheme deviceType = CImageApplyColorCastCorrect::G200; + if (0x300 == pid_) + { + deviceType = CImageApplyColorCastCorrect::G300_D8; + } + else if (0x400 == pid_) + { + deviceType = CImageApplyColorCastCorrect::G400_3288; + } + else if (0x402 == pid_) + { + deviceType = CImageApplyColorCastCorrect::G400_402; + } + else if (0x302 == pid_) + { + deviceType = CImageApplyColorCastCorrect::Android302; + } + + CImageApplyColorCastCorrect ColorCastCorrect(deviceType); ColorCastCorrect.apply(mats, true); //cv::imwrite(to_string(i) + "cis_test_image.jpg", mats[i]);