diff options
| -rw-r--r-- | main.cpp | 74 |
1 files changed, 70 insertions, 4 deletions
@@ -30,6 +30,8 @@ #include <QTimer> #include <QtConcurrent/QtConcurrentRun> +// #define FIRST_COLUMN_ONLY + #define try_apply_config() \ if (!applyConfig(config)) \ { \ @@ -147,6 +149,8 @@ int main(int argc, char* argv[]) PrinterClient printerClient; + // if (false) + qDebug() << "size of raw profile" << sizeof(Pixels); if (true) { // auto rawProfiles = openDump("/home/user/dumps/2024.11.24_19.17.32"); @@ -181,6 +185,7 @@ int main(int argc, char* argv[]) .save("/home/user/dumps/z/imageZ_interpolated.png"); } + if (true) { auto rawProfiles = openDump("/home/user/dumps/2024.12.07_14.51.07"); qDebug() << "raw x-profiles count is" << rawProfiles.size(); @@ -1145,6 +1150,7 @@ static QList<Pixels> openDump(const QString& dumpPath) QDir dumpDir{dirToRead}; + const QStringList nameFilters{"*.bin"}; const auto filter = QDir::Files; const auto sort = QDir::Name; @@ -1163,6 +1169,7 @@ static QList<Pixels> openDump(const QString& dumpPath) QElapsedTimer t; t.start(); qDebug() << "open real files"; + std::cout << "here" << std::endl; std::transform( std::execution::par_unseq, @@ -1171,7 +1178,17 @@ static QList<Pixels> openDump(const QString& dumpPath) resultOptionals->begin(), [dirToRead](const auto& filename) { // std::cout << '.'; - return openRawProfile(dirToRead + "/" + filename); + auto rawProfile = openRawProfile(dirToRead + "/" + filename); + if (rawProfile.has_value()) + { + QFile f(dirToRead + "/" + filename + ".bin"); + qDebug() << "save" << dirToRead + "/" + filename << "too" + << f.fileName(); + f.open(QFile::WriteOnly); + f.write((const char*)&rawProfile.value(), sizeof(Pixels)); + } + return rawProfile; + // return openRawProfile(dirToRead + "/" + filename); } ); @@ -1228,6 +1245,9 @@ static std::optional<Pixels> openRawProfile(const QString& filePath) const auto jsonPixels = json["pixels"].toArray(); // TODO: check json pixels count +#ifdef FIRST_COLUMN_ONLY + result.pixels[0] = jsonPixels.at(0).toDouble(); +#else std::transform( // std::execution::par_unseq, jsonPixels.constBegin(), @@ -1241,6 +1261,7 @@ static std::optional<Pixels> openRawProfile(const QString& filePath) // { // result.pixels[i] = jsonPixels[i].toDouble(); // } +#endif return result; } @@ -1602,26 +1623,46 @@ static QImage calibrationTableToImage( static void interpolate(QSharedPointer<CalibrationTable>& table) { +#ifdef FIRST_COLUMN_ONLY + interpolate(table->at(0)); +#else std::for_each( std::execution::par, table->begin(), table->end(), [](auto& column) { interpolate(column); } ); +#endif } static void interpolate(CalibrationColumn& column) { + size_t counter = 0; + // qDebug() << "AZAZA" << 0; + +#ifdef FIRST_COLUMN_ONLY + { + QFile f("/tmp/column0.csv"); + f.open(QFile::WriteOnly); + + for (const auto& p : column) + { + f.write(QString::number(p).toUtf8()); + f.write(";\n"); + } + } +#endif + // qDebug() << "AZAZA" << 1; auto firstNonZero = std::find_if(column.begin(), column.end(), [](const auto& pixel) { return !qFuzzyIsNull(pixel); }); - + // qDebug() << "AZAZA" << 2; if (firstNonZero == column.end()) { return; } - + // qDebug() << "AZAZA" << 3; for (auto it = firstNonZero; it != column.cend(); ++it) { auto firstZero = @@ -1631,6 +1672,7 @@ static void interpolate(CalibrationColumn& column) if (firstZero == column.end()) { + // qDebug() << "AZAZA" << 4; return; } @@ -1641,6 +1683,7 @@ static void interpolate(CalibrationColumn& column) if (nextNonZero == column.end()) { + // qDebug() << "AZAZA" << 5 << it - firstNonZero; return; } @@ -1658,6 +1701,29 @@ static void interpolate(CalibrationColumn& column) // qDebug() << "set zero to" << *zero; } - it = nextNonZero - 1; + it = nextNonZero; + } + // qDebug() << "AZAZA" << 6; +#ifdef FIRST_COLUMN_ONLY + { + QFile f("/tmp/column0_filled.csv"); + if (!f.open(QFile::WriteOnly)) + { + qDebug() << "AZAZA: cannot open file" << f.fileName(); + qDebug() << "AZAZA" << 7; + exit(0); + } + else + { + qDebug() << "AZAZA: ok"; + } + + for (const auto& p : column) + { + f.write(QString::number(p).toUtf8()); + f.write(";\n"); + } } +#endif + // qDebug() << "AZAZA" << 8; } |
