polaroid-pp

Schlieren and contour plot tool
git clone https://git.0xfab.ch/polaroid-pp.git
Log | Files | Refs | Submodules | README | LICENSE

commit 2f4d85e09f48a18b90cbf25a901e324d2cfe7b20
parent 61b161517b29343fc44385013f509859355371df
Author: Fabian Wermelinger <fabianw@mavt.ethz.ch>
Date:   Thu, 28 Apr 2016 18:29:16 +0200

ongoing refactoring

Diffstat:
Mapps/polaroidCamera/polaroidCameraMPI.cpp | 87++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------
1 file changed, 57 insertions(+), 30 deletions(-)

diff --git a/apps/polaroidCamera/polaroidCameraMPI.cpp b/apps/polaroidCamera/polaroidCameraMPI.cpp @@ -5,14 +5,12 @@ // Copyright 2016 ETH Zurich. All Rights Reserved. #include <iostream> #include <cstdio> -#include <string> #include <vector> -#include "OrganizerMPI.h" #include "ArgumentParser.h" -#include "Polaroid.h" -#include "Cartridges.h" -#include "PhotoFormats.h" +#include "OrganizerMPI.h" +#include "SceneProcessor.h" + using namespace std; @@ -33,13 +31,28 @@ int main(int argc, char* argv[]) } worker.wait(); + vector<char*> myscenes = worker.split_work(); + if (myscenes.size() > 0) + printf("[Worker %d/%d: Load = %d scene(s), start @ %s]\n", worker.rank(), worker.size(), myscenes.size(), myscenes.front()); + else + printf("[Worker %d/%d: Load = %d scene(s), start @ %s]\n", worker.rank(), worker.size(), myscenes.size(), "none"); - myparser.set_strict_mode(); - const string input_type = myparser("-input").asString(); - const string output_format = myparser("-format").asString(); - myparser.unset_strict_mode(); + SceneProcessor myprocessor(myparser); - Cartridge* mycartridge; + if (myparser("-process").asInt(1212) == 1212) + myprocessor.process1212(myscenes, worker.isroot()); + else if (myparser("-process").asInt(1212) == 1122) + myprocessor.process1122(myscenes, worker.isroot()); + else + { + if (worker.isroot()) + cerr << "ERROR: Undefined processing \"" << myparser("-process").asInt(1212) << "\"" << endl; + abort(); + } + + + + Cartridge * const mycartridge; PhotoPaper* myphoto; if (myparser("-format").asString("png") == "png") { @@ -55,42 +68,56 @@ int main(int argc, char* argv[]) myphoto = new PhotoHDF5; } - const double fraction = myparser("-fraction").asDouble(0.5); - const int direction = myparser("-direction").asInt(0); - const int channel = myparser("-channel").asInt(0); - const bool byte_swap = myparser("-swap").asBool(false); - const int wavelet_type = myparser("-wtype").asInt(1); - Polaroid mycam; - vector<char*> myscenes = worker.split_work(); - if (myscenes.size() > 0) - printf("[Worker %d/%d: Load = %d scene(s), start @ %s]\n", worker.rank(), worker.size(), myscenes.size(), myscenes.front()); - else - printf("[Worker %d/%d: Load = %d scene(s), start @ %s]\n", worker.rank(), worker.size(), myscenes.size(), "none"); - size_t k = 0; - for (auto scene: myscenes) + + vector<Polaroid> mycams(myscenes.size()); + for (size_t i=0; i<myscenes.size(); ++i) { - string basename(scene); + Polaroid& thiscam = mycams[i]; + + string basename(myscenes[i]); if (basename.find_last_of(".") != string::npos) basename = basename.substr(0, basename.find_last_of(".")); if (input_type == "hdf5") - mycam.load_hdf5(scene, fraction, direction, channel); + thiscam.load_hdf5(myscenes[i], fraction, direction, channel); else if (input_type == "wavelet") - mycam.load_wavelet(scene, fraction, direction, channel, byte_swap, wavelet_type); + thiscam.load_wavelet(myscenes[i], fraction, direction, channel, byte_swap, wavelet_type); - myphoto->make_new(basename+"-polaroid", mycam.width(), mycam.height()); - mycam.capture(*mycartridge, *myphoto); + if (worker.isroot()) + printf("[Loading Progress %3.1f %%]\n", static_cast<double>(i)/myscenes.size()*100.0); + } + + for (size_t i=0; i<mycams.size(); ++i) + { + Polaroid& thiscam = mycams[i]; + + string basename(myscenes[i]); + if (basename.find_last_of(".") != string::npos) + basename = basename.substr(0, basename.find_last_of(".")); + + // string basename(scene); + // if (basename.find_last_of(".") != string::npos) + // basename = basename.substr(0, basename.find_last_of(".")); + + // if (input_type == "hdf5") + // mycam.load_hdf5(scene, fraction, direction, channel); + // else if (input_type == "wavelet") + // mycam.load_wavelet(scene, fraction, direction, channel, byte_swap, wavelet_type); + + myphoto->make_new(basename+"-polaroid", thiscam.width(), thiscam.height()); + thiscam.capture(*mycartridge, *myphoto); - ++k; if (worker.isroot()) - printf("[Progress %3.1f %%]\n", static_cast<double>(k)/myscenes.size()*100.0); + printf("[Photo Progress %3.1f %%]\n", static_cast<double>(i)/myscenes.size()*100.0); } delete mycartridge; delete myphoto; + + worker.wait(); MPI_Finalize();