调整偏色校正,驱动层与算法层接口一致
This commit is contained in:
parent
b4b363720f
commit
0bbbe41c3e
|
@ -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<double> 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<double>& h_x, const std::vector<double>& h_y,
|
||||
const std::vector<double>& l_x, const std::vector<double>& l_y,
|
||||
const std::vector<double>& s_x, const std::vector<double>& 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);
|
||||
|
|
|
@ -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<double>& h_x, const std::vector<double>& h_y,
|
||||
const std::vector<double>& l_x, const std::vector<double>& l_y,
|
||||
|
|
|
@ -1411,7 +1411,26 @@ namespace hg_imgproc
|
|||
int ret = SCANNER_ERR_OK;
|
||||
std::vector<cv::Mat> 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]);
|
||||
|
|
Loading…
Reference in New Issue