diff --git a/relight-pano/panobuilder.cpp b/relight-pano/panobuilder.cpp index d641863..22be58a 100644 --- a/relight-pano/panobuilder.cpp +++ b/relight-pano/panobuilder.cpp @@ -98,6 +98,38 @@ void PanoBuilder::exportMeans(QDir rtiDir){ } } +void PanoBuilder::executeProcess(QString& program, QStringList& arguments) { + + QString command = program + " " + arguments.join(" "); + cout << "Print command: " << qPrintable(command) << endl; + + QProcess process; + process.start(program, arguments); + + if (!process.waitForStarted()) { + throw QString("Failed to start ") + process.program(); + } + + while(true) { + bool done = process.waitForFinished(1000); + QByteArray standardOutput = process.readAllStandardOutput(); + if (!standardOutput.isEmpty()) { + cout << qPrintable(QString(standardOutput)); + } + QByteArray standardError = process.readAllStandardError(); + + if (!standardError.isEmpty()) { + cout << "Error: " << qPrintable(QString(standardError)) << endl; + } + if(done) + break; + } + + if (process.exitStatus() != QProcess::NormalExit) { + throw QString("Process exited abnormally with exit code: ") + QString::number(process.exitCode()); + } +} + /* directory structures: * datasets @@ -148,18 +180,12 @@ void PanoBuilder::rti(){ } } - QDir mergeDir(base_dir.filePath("merge")); - if (!mergeDir.exists()) { - if (!base_dir.mkdir("merge")) { - throw QString("Could not create 'merge' directory"); - } - } //search the subdirectory, the QDir::Dirs | filter QDir::NoDotAndDotDot to get all subdirectories inside the root directory QStringList subDirs = datasets_dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); for (const QString &subDirName : subDirs) { QDir subDir(datasets_dir.filePath(subDirName)); - + break; //search file .relight QStringList relightFiles = subDir.entryList(QStringList() << "*.relight", QDir::Files); if(relightFiles.size()==0) @@ -168,49 +194,36 @@ void PanoBuilder::rti(){ QStringList arguments; - arguments << subDir.absoluteFilePath(relightFile) << rtiDir.filePath(subDir.dirName()) <<"-b" << "ptm" << "-p" << "18" << "-m"; + //arguments << subDir.absoluteFilePath(relightFile) << rtiDir.filePath(subDir.dirName()) <<"-b" << "ptm" << "-p" << "18" << "-m" + //<<"-3" << "2.5:0.21"; + arguments << datasets_dir.filePath(subDirName) << rtiDir.filePath(subDir.dirName()) <<"-b" << "ptm" << "-p" << "18" << "-m" + <<"-3" << "2.5:0.21"; - QString command = relight_cli_path + " " + arguments.join(" "); - cout << "print command: " << qPrintable(command) <