#include #include #include static std::string getCurrentTime() { // 获取当前时间点 auto now = std::chrono::system_clock::now(); // 转换为字符串 auto currentTime = std::chrono::system_clock::to_time_t(now); auto ms = std::chrono::duration_cast(now.time_since_epoch()) % 100; std::tm* localTime = std::localtime(¤tTime); std::stringstream ss; ss << std::put_time(localTime, "%H-%M-%S") << "-" << std::setfill('0') << std::setw(2) << ms.count(); return ss.str(); } static QString getCurrentDate() { QDateTime currentDateTime = QDateTime::currentDateTime(); return currentDateTime.toString("yyyy-MM-dd"); } static QString getCurrentHour() { QDateTime currentDateTime = QDateTime::currentDateTime(); return QString::number(currentDateTime.time().hour()) + "H"; } static void createDirectoryIfNotExists(const QString& path) { QDir dir; dir.mkpath(path); } QString getResSaveFormat(QString baseDir,QString SN, QString okNgText = "", int count = 0,QString cameraKey_index = "") { QString path = baseDir + getCurrentDate() + "//结果图//" + getCurrentHour() + "//" + okNgText + "//" + SN + "//"; createDirectoryIfNotExists(path); return path + "RES" + QString::number(count) + "_" + SN + "_" + cameraKey_index + "_" + QString::fromStdString(getCurrentTime()) + "_" + okNgText + ".jpg"; } QString getOriSaveFormat(QString baseDir, QString SN, QString okNgText = "", int count = 0, QString cameraKey_index = "") { QString path = baseDir + getCurrentDate() + "//原图//" + getCurrentHour() + "//" + okNgText + "//" + SN + "//"; createDirectoryIfNotExists(path); return path + "ORI" + QString::number(count) + "_" + SN + "_" + cameraKey_index + "_" + QString::fromStdString(getCurrentTime()) + ".bmp"; } QString getSegSaveFormat(QString baseDir, QString SN, QString okNgText = "", int count = 0, QString cameraKey_index = "") { QString path = baseDir + getCurrentDate() + "//原图//" + getCurrentHour() + "//" + okNgText + "//" + SN + "//"; createDirectoryIfNotExists(path); return path + "SEG" + QString::number(count) + "_" + SN + "_" + cameraKey_index + "_" + QString::fromStdString(getCurrentTime()) + ".bmp"; } QString getClsSaveFormat(QString baseDir, QString SN, QString okNgText = "", int count = 0, QString cameraKey_index = "") { QString path = baseDir + getCurrentDate() + "//原图//" + getCurrentHour() + "//" + okNgText + "//" + SN + "//"; createDirectoryIfNotExists(path); return path + "Cls" + QString::number(count) + "_" + SN + "_" + cameraKey_index + "_" + QString::fromStdString(getCurrentTime()) + ".bmp"; } QString getTiffSaveFormat(QString baseDir, QString SN, QString okNgText = "", int count = 0, QString cameraKey_index = "") { QString path = baseDir + getCurrentDate() + "//原图//" + getCurrentHour() + "//" + okNgText + "//" + SN + "//"; createDirectoryIfNotExists(path); return path + "Tiff" + QString::number(count) + "_" + SN + "_" + cameraKey_index + "_" + QString::fromStdString(getCurrentTime()) + ".tiff"; } QString getResSaveFormatOneImg(QString baseDir, QString SN, QString okNgText = "", int count = 0, QString cameraKey_index = "") { QString path = baseDir + getCurrentDate() + "//结果图//" + getCurrentHour() + "//" + okNgText + "//"; createDirectoryIfNotExists(path); return path + SN + "_" + "RES" + QString::number(count) + "_" + cameraKey_index + "_" + QString::fromStdString(getCurrentTime()) + ".bmp"; } QString getOriSaveFormatOneImg(QString baseDir, QString SN, QString okNgText = "", int count = 0, QString cameraKey_index = "") { QString path = baseDir + getCurrentDate() + "//原图//" + getCurrentHour() + "//" + okNgText + "//"; createDirectoryIfNotExists(path); return path + SN + "_" + "ORI" + QString::number(count) + "_" + cameraKey_index + "_" + QString::fromStdString(getCurrentTime()) + ".bmp"; } QString getSegSaveFormatOneImg(QString baseDir, QString SN, QString okNgText = "", int count = 0, QString cameraKey_index = "") { QString path = baseDir + getCurrentDate() + "//原图//" + getCurrentHour() + "//" + okNgText + "//"; createDirectoryIfNotExists(path); return path + SN + "_" + "SEG" + QString::number(count) + "_" + cameraKey_index + "_" + QString::fromStdString(getCurrentTime()) + ".bmp"; } QString getClsSaveFormatOneImg(QString baseDir, QString SN, QString okNgText = "", int count = 0, QString cameraKey_index = "") { QString path = baseDir + getCurrentDate() + "//原图//" + getCurrentHour() + "//" + okNgText + "//"; createDirectoryIfNotExists(path); return path + SN + "_" + "Cls" + QString::number(count) + "_" + cameraKey_index + "_" + QString::fromStdString(getCurrentTime()) + ".bmp"; }