-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paths4.cpp
More file actions
64 lines (51 loc) · 1.73 KB
/
s4.cpp
File metadata and controls
64 lines (51 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <iostream>
#include <fstream>
#include <cstdlib>
#include "Validation.h"
#include "pgm/Image.h"
#include "SurfaceNormalMap.h"
using namespace std;
int OBJ_ARGS[] = {2,3,4};
int main(int argc, const char * argv[]) {
if (argc != 7) {
cerr << "ERROR: Invalid number of arguments." << endl;
exit(-1);
}
const char* input_dirs_fname = argv[1];
const char* output_img_fname = argv[6];
vector<const char*> obj_fnames;
for (int i=0; i < sizeof(OBJ_ARGS) / sizeof(int); i++){
obj_fnames.push_back(argv[OBJ_ARGS[i]]);
}
// Create new sphere images from files, add to vector
vector<Image*> obj_images;
for(int i=0; i < obj_fnames.size(); i++){
Image* img = new Image;
if (readImage(img, obj_fnames[i]) < 0) {
cerr << "ERROR: Something went wrong reading the input image" << endl;
exit(-1);
}
obj_images.push_back(img);
}
// Check if step & threshold are valid ints and set to variables
if (!isValidType<int, const char*>(argv[5])){
cerr << "ERROR: Invalid threshold number." << endl;
exit(-1);
}
int threshold = atoi(argv[5]);
// Read input directions file and store in surface normal map
SurfaceNormalMap snm(input_dirs_fname, obj_images, threshold);
// Create copy of first image and shade with albedo
Image* output_img = new Image(*obj_images[0]);
snm.shadeWithAlbedo(output_img);
// Write output image to file
if (writeImage(output_img, output_img_fname) < 0){
cerr << "ERROR: Something went wrong writing the output image" << endl;
exit(-1);
}
// Clean up and return
for (int i=0; i < obj_images.size(); i++){
delete obj_images[i];
}
return 0;
}