Skip to content

Commit

Permalink
reading xml
Browse files Browse the repository at this point in the history
  • Loading branch information
Erika committed Sep 10, 2024
1 parent c85ac9a commit c6ff8fb
Show file tree
Hide file tree
Showing 5 changed files with 173 additions and 21 deletions.
17 changes: 11 additions & 6 deletions relight-pano/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
#include <QCommandLineParser>
#include <QCommandLineOption>
#include <iostream>
#include <QtXml>
#include "panobuilder.h"
#include "orixml.h"
using namespace std;

void help(){
Expand All @@ -21,6 +23,9 @@ int main(int argc, char *argv[])
QCoreApplication app(argc, argv);
QCoreApplication::setApplicationName("relight-pano");

QString pippo;
OriXml oriXml = pippo;
exit(0);

QCommandLineParser parser;
parser.setApplicationDescription("relight-pano: builds an RTI panorama");
Expand Down Expand Up @@ -71,12 +76,12 @@ int main(int argc, char *argv[])
}
startingStep = (PanoBuilder::Steps) s;
}
builder.setMm3d("/home/ponchio/devel/micmac/bin/mm3d");
//"/Users/erika/Desktop/micmac/bin/mm3d");
builder.setRelightCli("/home/ponchio/devel/relight/relight-cli/relight-cli");
//"/Users/erika/Desktop/projects/relight/build/relight-cli/relight-cli";
builder.setRelightMerge("/home/ponchio/devel/relight/relight-merge/relight-merge");
//"/Users/erika/Desktop/projects/relight/build/relight-cli/relight-merge";
// builder.setMm3d("/home/ponchio/devel/micmac/bin/mm3d");
builder.setMm3d("/Users/erika/Desktop/micmac/bin/mm3d");
//builder.setRelightCli("/home/ponchio/devel/relight/relight-cli/relight-cli");
builder.setRelightCli("/Users/erika/Desktop/projects/relight/build/relight-cli/relight-cli");
//builder.setRelightMerge("/home/ponchio/devel/relight/relight-merge/relight-merge");
builder.setRelightCli("/Users/erika/Desktop/projects/relight/build/relight-cli/relight-merge");

builder.process(startingStep);
}
Expand Down
2 changes: 2 additions & 0 deletions relight-pano/orixml.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class OriXml {
QString filename;

Eigen::Vector3d center;
Eigen::Matrix2d rotation;


//center Vector3double
//rotation Matrix3d
Expand Down
152 changes: 147 additions & 5 deletions relight-pano/panobuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <QProcess>
#include <QFileInfo>
#include <QImage>
#include "qexifimageheader.h"
#include "exiftransplant.h"
using namespace std;

PanoBuilder::PanoBuilder(QString dataset_path)
Expand Down Expand Up @@ -187,11 +187,11 @@ void PanoBuilder::tapioca(){
throw QString("Missing '*.jpg' not found in ") + subDir.path();
QString photo = photos[0];

QExifImageHeader exif;
bool success = exif.loadFromJpeg(dataset.absoluteFilePath(photo));
ExifTransplant exif;
bool success = exif.transplant(dataset.absoluteFilePath(photo).toStdString().c_str(),
(subDir.dirName() + ".jpg").toStdString().c_str());
if(!success)
throw QString("Unable to load exif from: ") + dataset.absoluteFilePath(photo);
//exif.saveToJpeg(subDir.dirName() + ".jpg");
throw QString("Unable to load exif from: ") + QString(exif.error.c_str()) + dataset.absoluteFilePath(photo);
}

QString program = mm3d_path;
Expand All @@ -214,4 +214,146 @@ void PanoBuilder::tapioca(){
cout << qPrintable(process.readAllStandardOutput()) << endl;
}

void PanoBuilder::schnaps(){
//prende l'input dalla sottodir di homol e jpg
cd("photogrammetry");

QDir currentDir = QDir::current();
QDir homolDir(currentDir.filePath("Homol"));
if (!homolDir.exists()) {
throw QString("Homol directory does not exist in current directory: ") + homolDir.absolutePath();

}
cout << qPrintable(homolDir.absolutePath()) << endl;

QStringList jpgFiles = currentDir.entryList(QStringList() << "*.jpg" << "*.JPG", QDir::Files);
if (jpgFiles.isEmpty()) {
throw QString("No JPEG images found in photogrammetry directory");
}

QString program = mm3d_path;
QStringList arguments;
arguments << "Schnaps" << ".*jpg";

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();
}

if (!process.waitForFinished(-1)) {
throw QString("Failed to run ") + process.readAllStandardError();
}
cout << qPrintable(process.readAllStandardOutput()) << endl;
}

void PanoBuilder::tapas(){
//prende l'input dalla sottodirectory Homol
//TODO mostrare i residui
cd("photogrammetry");

QDir currentDir = QDir::current();
QDir homolDir(currentDir.filePath("Homol"));
if (!homolDir.exists()) {
throw QString("Homol directory does not exist in current directory: ") + homolDir.absolutePath();

}
cout << qPrintable(homolDir.absolutePath()) << endl;

QStringList jpgFiles = currentDir.entryList(QStringList() << "*.jpg" << "*.JPG", QDir::Files);
if (jpgFiles.isEmpty()) {
throw QString("No JPEG images found in photogrammetry directory");
}

QString program = mm3d_path;
QStringList arguments;
arguments << "Tapas" << "RadialBasic" << ".*jpg" <<"Out=Relative" << "SH= _mini";

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();
}

if (!process.waitForFinished(-1)) {
throw QString("Failed to run ") + process.readAllStandardError();
}
cout << qPrintable(process.readAllStandardOutput()) << endl;
}

void PanoBuilder::apericloud(){
//prende l'input dalla sottodirectory Homol
cd("photogrammetry");

QDir currentDir = QDir::current();
QDir homolDir(currentDir.filePath("Homol"));
if (!homolDir.exists()) {
throw QString("Homol directory does not exist in current directory: ") + homolDir.absolutePath();

}
cout << qPrintable(homolDir.absolutePath()) << endl;

QStringList jpgFiles = currentDir.entryList(QStringList() << "*.jpg" << "*.JPG", QDir::Files);
if (jpgFiles.isEmpty()) {
throw QString("No JPEG images found in photogrammetry directory");
}

QString program = mm3d_path;
QStringList arguments;
arguments << "AperiCloud" << "Relative" << ".*jpg";

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();
}

if (!process.waitForFinished(-1)) {
throw QString("Failed to run ") + process.readAllStandardError();
}
cout << qPrintable(process.readAllStandardOutput()) << endl;
}

void PanoBuilder::orthoplane(){
//prende l'input dalla sottodirectory Ori-rel
cd("photogrammetry");

QDir currentDir = QDir::current();
QDir oriRelDir(currentDir.filePath("Ori-Rel"));
if (!oriRelDir.exists()) {
throw QString("Ori-Rel directory does not exist in current directory: ") + oriRelDir.absolutePath();
}


QString program = mm3d_path;
QStringList arguments;
arguments << "" << ""
"" << ".*jpg";

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();
}

if (!process.waitForFinished(-1)) {
throw QString("Failed to run ") + process.readAllStandardError();
}
cout << qPrintable(process.readAllStandardOutput()) << endl;
}
10 changes: 5 additions & 5 deletions relight-pano/panobuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class PanoBuilder : public QObject
JPG //convert to jpg
};

QStringList steps = {"rti", "tapioca"};
QStringList steps = {"rti", "tapioca", "schnaps", "tapas", "apericloud", "orthoplane"};
QDir base_dir;
QDir datasets_dir;
QString mm3d_path;
Expand All @@ -43,10 +43,10 @@ class PanoBuilder : public QObject
//create the directory rti process the datasets and relight-merge the rti planes
void rti();
void tapioca();
void schnaps(){};
void tapas(){};
void apericloud(){};
void orthoplane(){};
void schnaps();
void tapas();
void apericloud();
void orthoplane();
void tarama(){};
void malt_mec(){};
void c3dc(){};
Expand Down
13 changes: 8 additions & 5 deletions relight-pano/relight-pano.pro
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
QT += core gui

QT += xml
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++17
Expand All @@ -12,14 +12,17 @@ SOURCES += \
exiftransplant.cpp \
main.cpp \
mainwindow.cpp \
panobuilder.cpp \
qexifimageheader.cpp
orixml.cpp \
panobuilder.cpp

HEADERS += \
exiftransplant.h \
mainwindow.h \
panobuilder.h \
qexifimageheader.h
orixml.h \
panobuilder.h

mac:INCLUDEPATH += /opt/homebrew/include/eigen3


# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
Expand Down

0 comments on commit c6ff8fb

Please sign in to comment.