Skip to content

Commit 62bb8d6

Browse files
committed
removing redundant directions dome/imageset/image NEEDS TESTING
1 parent 3af2830 commit 62bb8d6

21 files changed

+276
-259
lines changed

relight-cli/main.cpp

+48-39
Original file line numberDiff line numberDiff line change
@@ -23,40 +23,39 @@ void help() {
2323
cout << "Usage: relight-cli [-bpqy3PnmMwkrsSRBcCeEv]<input folder> [output folder]\n\n";
2424
cout << " relight-cli [-q] <input.ptm|.rti> [output folder]\n\n";
2525
cout << " relight-cli [-q] <input.json> [output.ptm]\n\n";
26-
cout << "\tinput folder containing a .lp with number of photos and light directions\n";
26+
cout << "\tinput folder containing a .lp or .dome with number of photos and light directions\n";
2727
cout << "\toptional output folder (default ./)\n\n";
28-
cout << "\t-b <basis>: rbf(default), ptm, lptm, hsh, yrbf, bilinear\n";
29-
cout << "\t-p <int> : number of planes (default: 9)\n";
30-
cout << "\t-q <int> : jpeg quality (default: 95)\n";
31-
cout << "\t-y <int> : number of Y planes in YCC\n\n";
32-
cout << "\t-3 <radius[:offset]>: 3d light positions processing, ratio diameter_dome/image_width\n and optionally vertical offset of the center of the sphere to the surface.\n";
28+
cout << "\t -b <basis>: rbf(default), ptm, lptm, hsh, yrbf, bilinear\n";
29+
cout << "\t -p <int> : number of planes (default: 9)\n";
30+
cout << "\t -q <int> : jpeg quality (default: 95)\n";
31+
cout << "\t -y <int> : number of Y planes in YCC\n\n";
32+
cout << "\t -3 <radius[:offset]>: 3d light positions processing, ratio diameter_dome/image_width\n and optionally vertical offset of the center of the sphere to the surface.\n";
3333

34-
cout << "\t-P <pixel size in MM>: this number is saved in .json output and within image metadata\n";
35-
// cout << "\t-m <int> : number of materials (default 8)\n";
36-
cout << "\t-n : extract normals\n";
37-
cout << "\t-m : extract mean image\n";
38-
cout << "\t-M : extract median image (7/8th quantile) \n";
34+
cout << "\t -P <pixel size in MM>: this number is saved in .json output and within image metadata\n";
35+
cout << "\t -n : extract normals\n";
36+
cout << "\t -m : extract mean image\n";
37+
cout << "\t -M : extract median image (7/8th quantile) \n";
3938

40-
cout << "\t-w : number of workers (default 8)\n";
41-
cout << "\t-k <int>x<int>+<int>+<int>: Cropping extracts only the widthxheight+offx+offy part\n";
39+
cout << "\t -w : number of workers (default 8)\n";
40+
cout << "\t -k <int>x<int>+<int>+<int>: Cropping extracts only the widthxheight+offx+offy part\n";
4241

4342
cout << "\nIgnore exotic parameters below here\n\n";
44-
cout << "\n-H : fix overexposure in ptm and hsh due to bad sampling\n";
45-
cout << "\t-r <int> : side of the basis function (default 8, 0 means rbf interpolation)\n";
46-
cout << "\t-s <int> : sampling RAM for pca in MB (default 500MB)\n";
47-
cout << "\t-S <float>: sigma in rgf gaussian interpolation default 0.125 (~100 img)\n";
48-
cout << "\t-R <float>: regularization coeff for bilinear default 0.1\n";
49-
cout << "\t-B <float>: range compress bits for planes (default 0.0) 1.0 means compress\n";
50-
cout << "\t-c <float>: coeff quantization (to test!) default 1.5\n";
51-
cout << "\t-C : apply chroma subsampling \n";
52-
cout << "\t-e : evaluate reconstruction error (default: false)\n";
53-
cout << "\t-E <int> : evaluate error on a single image (but remove it for fitting)\n";
43+
cout << "\n -H : fix overexposure in ptm and hsh due to bad sampling\n";
44+
cout << "\t -r <int> : side of the basis function (default 8, 0 means rbf interpolation)\n";
45+
cout << "\t -s <int> : sampling RAM for pca in MB (default 500MB)\n";
46+
cout << "\t -S <float>: sigma in rgf gaussian interpolation default 0.125 (~100 img)\n";
47+
cout << "\t -R <float>: regularization coeff for bilinear default 0.1\n";
48+
cout << "\t -B <float>: range compress bits for planes (default 0.0) 1.0 means compress\n";
49+
cout << "\t -c <float>: coeff quantization (to test!) default 1.5\n";
50+
cout << "\t -C : apply chroma subsampling \n";
51+
cout << "\t -e : evaluate reconstruction error (default: false)\n";
52+
cout << "\t -E <int> : evaluate error on a single image (but remove it for fitting)\n";
5453

5554
cout << "\n\nTesting options, will use the input folder as an RTI source: \n";
5655

57-
cout << "\t-D <path> : directory to store rebuilt images\n";
58-
cout << "\t-L <x:y:z> : reconstruct only one image from light parameters, output is the filename\n";
59-
cout << "\t-v : verbose, prints progress info\n";
56+
cout << "\t -D <path> : directory to store rebuilt images\n";
57+
cout << "\t -L <x:y:z> : reconstruct only one image from light parameters, output is the filename\n";
58+
cout << "\t -v : verbose, prints progress info\n";
6059
}
6160

6261
//convert PTM into relight format
@@ -99,13 +98,13 @@ int main(int argc, char *argv[]) {
9998
}
10099

101100
RtiBuilder builder;
101+
Dome dome;
102102
int quality = 95;
103103
bool evaluate_error = false;
104104
QString redrawdir;
105105
bool relighted = false;
106106
Eigen::Vector3f light;
107107
bool verbose = true;
108-
bool histogram_fix = false;
109108

110109
opterr = 0;
111110
char c;
@@ -137,8 +136,8 @@ int main(int argc, char *argv[]) {
137136
break;
138137
}
139138
case 'P':
140-
builder.pixelSize = atof(optarg);
141-
if(builder.pixelSize <= 0) {
139+
builder.imageset.pixel_size = atof(optarg);
140+
if(builder.imageset.pixel_size <= 0) {
142141
cerr << "Invalid parameter pixelSize (-P): " << optarg << endl;
143142
return 1;
144143
}
@@ -208,11 +207,11 @@ int main(int argc, char *argv[]) {
208207
encoder.distortion = atof(optarg);
209208
break; */
210209
case '3': { //assume lights positionals. (0, 0) is in the center of the image, (might add these values), and unit is image width
211-
builder.imageset.light3d = true;
212-
builder.imageset.dome_radius = float(atof(optarg));
210+
dome.lightConfiguration = Dome::SPHERICAL;
211+
dome.domeDiameter = 2*float(atof(optarg));
213212
QString params(optarg);
214213
if(params.contains(':')) {
215-
builder.imageset.vertical_offset = params.split(':')[1].toDouble();
214+
dome.verticalOffset = params.split(':')[1].toDouble();
216215
}
217216
}
218217
break;
@@ -329,7 +328,7 @@ int main(int argc, char *argv[]) {
329328
return 1;
330329
}
331330

332-
if(builder.imageset.light3d == true && builder.type == RtiBuilder::RBF) {
331+
if(dome.lightConfiguration != Dome::DIRECTIONAL && builder.type == RtiBuilder::RBF) {
333332
cerr << "RBF basis do not support positional lights (for the moment)\n";
334333
return 1;
335334
}
@@ -348,7 +347,7 @@ int main(int argc, char *argv[]) {
348347
}
349348
break;
350349
case Rti::HSH:
351-
if(builder.colorspace == Rti::RGB && (builder.nplanes != 27 || builder.nplanes != 12)) {
350+
if(builder.colorspace == Rti::RGB && (builder.nplanes != 27 && builder.nplanes != 12)) {
352351
cerr << "hsh basis requires 12 or 27 coefficient planes (option -p 12 or -p 27)\n";
353352
return -1;
354353
}
@@ -399,14 +398,16 @@ int main(int argc, char *argv[]) {
399398
QElapsedTimer timer;
400399
timer.start();
401400

401+
402+
402403
QFileInfo info(input.c_str());
403404
if(!info.exists()) {
404405
cerr << "Input \"" << input << "\" doesn't seems to exist." << endl;
405406
return 1;
406407
}
407408
if(info.isFile()) {
408409
if(info.suffix() == "relight") {
409-
if(!builder.initFromProject(input, callback)) {
410+
if(!builder.setupFromProject(input)) {
410411
cerr << builder.error << "\n" << endl;
411412
return 1;
412413
}
@@ -428,7 +429,7 @@ int main(int argc, char *argv[]) {
428429
}
429430
} else if(info.isDir()) {
430431

431-
if(!builder.initFromFolder(input, callback)) {
432+
if(!builder.setupFromFolder(input)) {
432433
cerr << builder.error << " !\n" << endl;
433434
return 1;
434435
}
@@ -437,6 +438,13 @@ int main(int argc, char *argv[]) {
437438
return 1;
438439
}
439440

441+
//if spherical dome has been specified, i
442+
if(dome.lightConfiguration == Dome::SPHERICAL) {
443+
dome.directions = builder.imageset.lights1;
444+
dome.updateSphereDirections();
445+
}
446+
447+
builder.init(callback);
440448
int size = builder.save(output, quality);
441449
if(size == 0) {
442450
cerr << "Failed saving: " << builder.error << " !\n" << endl;
@@ -513,8 +521,9 @@ int main(int argc, char *argv[]) {
513521
}
514522

515523
QDir out(output.c_str());
516-
ImageSet imgset;
517-
imgset.initFromFolder(input.c_str(), true);
524+
builder.setupFromFolder(input.c_str());
525+
ImageSet &imgset = builder.imageset;
526+
518527
double mse = 0;
519528
mse = Rti::evaluateError(imgset, rti, out.filePath("error.png"), builder.skip_image);
520529

@@ -526,7 +535,7 @@ int main(int argc, char *argv[]) {
526535
}
527536
//type, colorspace, nplanes, nmaterials, ny
528537

529-
Eigen::Vector3f light = imgset.lights[builder.skip_image];
538+
Eigen::Vector3f light = dome.directions[builder.skip_image];
530539
float r = sqrt(light[0]*light[0] + light[1]*light[1]);
531540
float azimut = asin(r);
532541
cout << output << "," << types[builder.type] << "," << colorspaces[builder.colorspace] << ","

relight-cli/relight-cli.pro

+6
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,32 @@ mac:LIBS += -L /usr/local/lib /usr/local/lib/libomp.dylib
3232
DESTDIR = "../bin"
3333

3434
SOURCES += main.cpp \
35+
../src/dome.cpp \
3536
../src/getopt.cpp \
3637
../src/imageset.cpp \
3738
../src/jpeg_decoder.cpp \
3839
../src/jpeg_encoder.cpp \
40+
../src/lens.cpp \
3941
../src/rti.cpp \
4042
../src/legacy_rti.cpp \
43+
../src/sphere.cpp \
4144
rtibuilder.cpp \
4245
convert_rti.cpp \
4346
../src/lp.cpp
4447

4548
HEADERS += \
49+
../src/dome.h \
4650
../src/getopt.h \
4751
../src/imageset.h \
4852
../src/jpeg_decoder.h \
4953
../src/jpeg_encoder.h \
54+
../src/lens.h \
5055
../src/material.h \
5156
../src/vector.h \
5257
../src/rti.h \
5358
../src/legacy_rti.h \
5459
../src/eigenpca.h \
60+
../src/sphere.h \
5561
rtibuilder.h \
5662
../src/lp.h
5763

0 commit comments

Comments
 (0)