|
|
|
|
@ -9,7 +9,7 @@ namespace
|
|
|
|
|
{
|
|
|
|
|
constexpr const char *LEFT_DIR_NAME = "left";
|
|
|
|
|
constexpr const char *RIGHT_DIR_NAME = "right";
|
|
|
|
|
constexpr const char *PRODUCT_DIR_PREFIX = "__DB__";
|
|
|
|
|
constexpr const char *PRODUCT_DIR_PREFIX = "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 静态成员定义
|
|
|
|
|
@ -134,6 +134,7 @@ std::string LoadImage::GetInfo(const std::string &str)
|
|
|
|
|
std::string LoadImage::extractProductId(const std::string &dir_name)
|
|
|
|
|
{
|
|
|
|
|
// 检查是否以 "__DB__" 开头
|
|
|
|
|
if(PRODUCT_DIR_PREFIX == "") return dir_name;
|
|
|
|
|
if (dir_name.find(PRODUCT_DIR_PREFIX) == 0)
|
|
|
|
|
{
|
|
|
|
|
// 跳过前缀,返回剩余部分作为产品 ID
|
|
|
|
|
@ -158,18 +159,20 @@ std::string LoadImage::extractChannelName(const std::string &filename)
|
|
|
|
|
name = name.substr(0, ext_pos);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Step 2: 优先尝试用 '^' 分隔符提取(如 "img_01^CH1" -> "CH1")
|
|
|
|
|
size_t sep_pos = name.rfind('^');
|
|
|
|
|
// Step 2: 优先尝试用 '^' 分隔符提取(如 "img_01^CH1^Org" -> "CH1")
|
|
|
|
|
size_t last_sep_pos = name.rfind('^');
|
|
|
|
|
size_t sep_pos = name.rfind('^', last_sep_pos - 1);
|
|
|
|
|
if (sep_pos != std::string::npos && sep_pos < name.length() - 1)
|
|
|
|
|
{
|
|
|
|
|
return name.substr(sep_pos + 1);
|
|
|
|
|
return name.substr(sep_pos + 1, last_sep_pos - sep_pos - 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Step 3: 其次尝试用 '_' 分隔符提取(如 "img_01_CH1" -> "CH1")
|
|
|
|
|
size_t under_pos = name.rfind('_');
|
|
|
|
|
// Step 3: 其次尝试用 '_' 分隔符提取(如 "img_01_CH1_Org" -> "CH1")
|
|
|
|
|
size_t last_under_pos = name.rfind('_');
|
|
|
|
|
size_t under_pos = name.rfind('_', last_under_pos - 1);
|
|
|
|
|
if (under_pos != std::string::npos && under_pos < name.length() - 1)
|
|
|
|
|
{
|
|
|
|
|
return name.substr(under_pos + 1);
|
|
|
|
|
return name.substr(under_pos + 1, last_under_pos - under_pos - 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Step 4: 如果没有分隔符,返回整个文件名(不含扩展名)
|
|
|
|
|
|