|
|
|
|
@ -8,6 +8,65 @@ std::string toLower(const std::string &str)
|
|
|
|
|
return lower;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 4 相机代码, 顺序与原有实现保持一致
|
|
|
|
|
static const std::string g_strCameraCodes[] = {"BCA", "DCA", "BTA", "DTA"};
|
|
|
|
|
|
|
|
|
|
// 解析文件名中的 相机代码 与 半幅(左右)
|
|
|
|
|
// 支持两种命名:
|
|
|
|
|
// 1) {前缀}_{相机}_{0|1}_{后缀} 如 3ABD670013A8BG1_BCA_0_src (0=左半, 1=右半)
|
|
|
|
|
// 2) {前缀}{相机}{A|B} 如 BCAA / A_BCAB (A=左半, B=右半)
|
|
|
|
|
// 对应关系: BCA_0 <=> BCAA(左半), BCA_1 <=> BCAB(右半)
|
|
|
|
|
std::string Extract_Camera_And_Half(const std::string &strStem, std::string &strHalf)
|
|
|
|
|
{
|
|
|
|
|
strHalf = "";
|
|
|
|
|
|
|
|
|
|
// 方式1: {前缀}_{相机}_{0|1}_{后缀} (merg 目录下的命名)
|
|
|
|
|
// 形如 3ABD670013A8BG1_BCA_0_src.jpg, 其中 0 对应 BCAA, 1 对应 BCAB
|
|
|
|
|
for (const auto &strCam : g_strCameraCodes)
|
|
|
|
|
{
|
|
|
|
|
const std::string strKey = "_" + strCam + "_";
|
|
|
|
|
size_t pos = strStem.find(strKey);
|
|
|
|
|
while (pos != std::string::npos)
|
|
|
|
|
{
|
|
|
|
|
const size_t nHalfPos = pos + strKey.size();
|
|
|
|
|
if (nHalfPos < strStem.size() &&
|
|
|
|
|
(strStem[nHalfPos] == '0' || strStem[nHalfPos] == '1') &&
|
|
|
|
|
(nHalfPos + 1 >= strStem.size() || strStem[nHalfPos + 1] == '_' || strStem[nHalfPos + 1] == '.'))
|
|
|
|
|
{
|
|
|
|
|
strHalf = (strStem[nHalfPos] == '0') ? "A" : "B";
|
|
|
|
|
return strCam;
|
|
|
|
|
}
|
|
|
|
|
pos = strStem.find(strKey, pos + 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 方式2: {前缀}{相机}{A|B} (原有的 4 相机命名)
|
|
|
|
|
for (const auto &strCam : g_strCameraCodes)
|
|
|
|
|
{
|
|
|
|
|
const size_t pos = strStem.find(strCam);
|
|
|
|
|
if (pos != std::string::npos && pos + strCam.size() < strStem.size())
|
|
|
|
|
{
|
|
|
|
|
const char cHalf = strStem[pos + strCam.size()];
|
|
|
|
|
if (cHalf == 'A' || cHalf == 'B')
|
|
|
|
|
{
|
|
|
|
|
strHalf = std::string(1, cHalf);
|
|
|
|
|
return strCam;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 兜底: 文件名中只包含相机代码, 无法判定左右
|
|
|
|
|
for (const auto &strCam : g_strCameraCodes)
|
|
|
|
|
{
|
|
|
|
|
if (strStem.find(strCam) != std::string::npos)
|
|
|
|
|
{
|
|
|
|
|
return strCam;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int Extract_Name_Base::Read_Product_Image(std::string strPath)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
@ -189,12 +248,17 @@ int Extract_ALL::Extract_Info(std::string strPath, std::string strproduct, int u
|
|
|
|
|
fs::path p = fs::path(strPath);
|
|
|
|
|
std::string filenameWithoutExt = p.stem().string();
|
|
|
|
|
|
|
|
|
|
// 记录半幅信息: 左半(A/BCAA/…_0_) / 右半(B/BCAB/…_1_), 用于配对时确定左右图
|
|
|
|
|
std::string strHalf;
|
|
|
|
|
Extract_Camera_And_Half(filenameWithoutExt, strHalf);
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<Image_Info> pImage = std::make_shared<Image_Info>();
|
|
|
|
|
|
|
|
|
|
pImage->strProductID = strProductName;
|
|
|
|
|
pImage->strCamID = strCameraName;
|
|
|
|
|
pImage->strchannelName = strChannelName;
|
|
|
|
|
pImage->strName = filenameWithoutExt;
|
|
|
|
|
pImage->strHalf = strHalf;
|
|
|
|
|
pImage->strPath = strPath;
|
|
|
|
|
pCamera->image_list.push_back(pImage);
|
|
|
|
|
|
|
|
|
|
@ -207,17 +271,10 @@ std::string Extract_ALL::Extract_Camera_Name(std::string strPath, int userflag)
|
|
|
|
|
fs::path p = fs::path(strPath);
|
|
|
|
|
std::string filename = p.stem();
|
|
|
|
|
|
|
|
|
|
// 文件名包含 BCA/BTA/DCA/DTA/CA/TA 即判定对应相机
|
|
|
|
|
if (filename.find("BCA") != std::string::npos)
|
|
|
|
|
return "BCA";
|
|
|
|
|
else if (filename.find("DCA") != std::string::npos)
|
|
|
|
|
return "DCA";
|
|
|
|
|
else if (filename.find("BTA") != std::string::npos)
|
|
|
|
|
return "BTA";
|
|
|
|
|
else if (filename.find("DTA") != std::string::npos)
|
|
|
|
|
return "DTA";
|
|
|
|
|
|
|
|
|
|
return "";
|
|
|
|
|
// 相机名从统一的命名解析中获取:
|
|
|
|
|
// {相机}{A|B} 形式(BCAA/BCAB) 与 {相机}_{0|1} 形式(BCA_0/BCA_1) 均支持
|
|
|
|
|
std::string strHalf;
|
|
|
|
|
return Extract_Camera_And_Half(filename, strHalf);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string Extract_ALL::Extract_Product_Name(std::string strPath, int userflag)
|
|
|
|
|
@ -252,6 +309,7 @@ std::string Extract_ALL::Extract_Channel_Name(std::string strPath, int userflag)
|
|
|
|
|
// 新格式: {Prefix}_{Camera}{AB}, 如 A_BCAA, M_DTAB, A_BCAB
|
|
|
|
|
// 通道名 = 前缀 (A/M), 表示不同打光方式
|
|
|
|
|
// 支持4相机: BCAA, BCAB, BTAA, BTAB, DCAA, DCAB, DTAA, DTAB
|
|
|
|
|
// 兼容 {Camera}_{0|1} 命名(如 BCA_0 / BCA_1), 其 0/1 对应 A/B
|
|
|
|
|
size_t underscorePos = filename.find('_');
|
|
|
|
|
if (underscorePos != std::string::npos)
|
|
|
|
|
{
|
|
|
|
|
@ -259,7 +317,9 @@ std::string Extract_ALL::Extract_Channel_Name(std::string strPath, int userflag)
|
|
|
|
|
std::string rest = filename.substr(underscorePos + 1);
|
|
|
|
|
// 4相机格式
|
|
|
|
|
if (rest == "BCAA" || rest == "BCAB" || rest == "BTAA" || rest == "BTAB" ||
|
|
|
|
|
rest == "DCAA" || rest == "DCAB" || rest == "DTAA" || rest == "DTAB" )
|
|
|
|
|
rest == "DCAA" || rest == "DCAB" || rest == "DTAA" || rest == "DTAB" ||
|
|
|
|
|
rest == "BCA_0" || rest == "BCA_1" || rest == "BTA_0" || rest == "BTA_1" ||
|
|
|
|
|
rest == "DCA_0" || rest == "DCA_1" || rest == "DTA_0" || rest == "DTA_1")
|
|
|
|
|
{
|
|
|
|
|
return prefix; // "A" or "M"
|
|
|
|
|
}
|
|
|
|
|
|