Skip to content

Commit bef3029

Browse files
author
Erika
committed
depthmap Normal resize
1 parent 0c23cbe commit bef3029

File tree

5 files changed

+30
-20
lines changed

5 files changed

+30
-20
lines changed

depthmap/depthmap.cpp

+11-8
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,12 @@ void Depthmap::depthIntegrateNormals(){
220220
for(size_t i = 0; i < normals.size(); i++)
221221
for(int k = 0; k < 3; k++)
222222
normals_float[i*3+k] = normals[i][k];
223+
elevation.clear();
224+
elevation.resize(normals.size(), 0);
223225
bni_integrate(callback, width, height, normals_float, elevation);
224-
226+
for(float &h: elevation){
227+
h = -h;
228+
}
225229
}
226230
void Depthmap::resizeNormals (int factorPowerOfTwo, int step = 1) {
227231
int factor = 1 << factorPowerOfTwo;
@@ -276,13 +280,14 @@ void Depthmap::resizeNormals (int factorPowerOfTwo, int step = 1) {
276280
normals = resizedNormals;
277281
width = targetWidth;
278282
height = targetHeight;
283+
resolution *= factor;
279284

280-
QString filename = "/Users/erika/Desktop/testcenterRel_copia/photogrammetry/surface.jpg";
281-
saveNormals(filename.toStdString().c_str());
285+
//QString filename = "/Users/erika/Desktop/testcenterRel_copia/photogrammetry/surface.jpg";
286+
//saveNormals(filename.toStdString().c_str());
282287
//chiama l'integrale integra le normali e salva il ply
283-
depthIntegrateNormals();
284-
QString plyFilename = "/Users/erika/Desktop/testcenterRel_copia/photogrammetry/resize_normals.obj";
285-
saveObj(plyFilename.toStdString().c_str());
288+
//depthIntegrateNormals();
289+
//QString plyFilename = "/Users/erika/Desktop/testcenterRel_copia/photogrammetry/resize_normals.obj";
290+
//saveObj(plyFilename.toStdString().c_str());
286291

287292
}
288293

@@ -333,8 +338,6 @@ Eigen::Vector3f Depthmap::pixelToRealCoordinates(int pixelX, int pixelY, float p
333338
return Eigen::Vector3f(realX, realY, realZ);
334339
}
335340

336-
337-
338341
bool Camera::loadXml(const QString &pathXml){
339342
//orientation xml
340343
QFile file(pathXml);

depthmap/depthmap.pro

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,17 @@ CONFIG -= app_bundle
1010

1111
LIBS += -L /opt/homebrew/lib -ltiff
1212
SOURCES += \
13+
../src/bni_normal_integration.cpp \
1314
depthmap.cpp \
1415
main.cpp
15-
INCLUDEPATH += -I /opt/homebrew/include
16+
INCLUDEPATH += /opt/homebrew/include \
17+
/opt/homebrew/Cellar/eigen/3.4.0_1/include/eigen3
1618

1719
# Default rules for deployment.
1820
qnx: target.path = /tmp/$${TARGET}/bin
1921
else: unix:!android: target.path = /opt/$${TARGET}/bin
2022
!isEmpty(target.path): INSTALLS += target
2123

2224
HEADERS += \
25+
../src/bni_normal_integration.h \
2326
depthmap.h

depthmap/main.cpp

+11-7
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,31 @@
66
#include <eigen3/Eigen/Dense>
77

88
using namespace std;
9-
9+
// carica il tif, calcola e integra normali per vedere se la superficie è la stessa.
10+
//
1011
int main(int argc, char *argv[]) {
1112
/*if(argc != 3) {
1213
cerr << "Usage: " << argv[0] << "<input.tiff> <output.png>" << endl;
1314
return 1;
1415
}*/
16+
1517
QString depthmapPath = "/Users/erika/Desktop/testcenterRel_copia/photogrammetry/Malt/Z_Num7_DeZoom4_STD-MALT.tif";
1618
QString orientationXmlPath = "/Users/erika/Desktop/testcenterRel_copia/photogrammetry/Ori-Relative/Orientation-L05C12.tif.xml";
1719
QString output = "out.png";
1820
Depthmap depth;
1921
depth.load(qPrintable(depthmapPath));
2022
depth.computeNormals();
21-
depth.saveNormals(qPrintable(output));
22-
depth.saveObj("/Users/erika/Desktop/testcenterRel_copia/photogrammetry/output.obj");
23+
depth.saveNormals("/Users/erika/Desktop/testcenterRel_copia/photogrammetry/original.obj");
24+
depth.saveObj("/Users/erika/Desktop/testcenterRel_copia/photogrammetry/original.obj");
25+
2326
depth.depthIntegrateNormals();
24-
depth.saveNormals("/Users/erika/Desktop/testcenterRel_copia/photogrammetry/surface.jpg");
27+
depth.saveObj("/Users/erika/Desktop/testcenterRel_copia/photogrammetry/integrated.obj");
28+
2529
int factorPowerOfTwo = 1;
2630
depth.resizeNormals(factorPowerOfTwo, 2);
27-
depth.saveObj("/Users/erika/Desktop/testcenterRel_copia/photogrammetry/resize_normals.obj");
31+
depth.depthIntegrateNormals();
32+
depth.saveNormals("/Users/erika/Desktop/testcenterRel_copia/photogrammetry/resized_integrated.jpg");
33+
depth.saveObj("/Users/erika/Desktop/testcenterRel_copia/photogrammetry/resized_integrated.obj");
2834

2935

3036
Camera camera;
@@ -34,8 +40,6 @@ int main(int argc, char *argv[]) {
3440
float pixelZ = 4.5;
3541

3642

37-
38-
3943
Eigen::Matrix3f rotationMatrix;
4044
Eigen::Vector3f center;
4145

relight-cli/relight-cli.pro

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ mac:LIBS += -L /usr/local/lib /usr/local/lib/libomp.dylib
3131

3232
DESTDIR = "../bin"
3333

34-
SOURCES += main.cpp \
34+
©main.cpp \
3535
../src/getopt.cpp \
3636
../src/imageset.cpp \
3737
../src/jpeg_decoder.cpp \

src/bni_normal_integration.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ void bni_integrate(std::function<bool(std::string s, int n)> progressed,
1414
double k = 2.0,
1515
double tolerance = 1e-5,
1616
double solver_tolerance = 1e-5,
17-
int max_iterations = 150,
18-
int max_solver_iterations = 5000);
17+
int max_iterations = 5,
18+
int max_solver_iterations = 100);
1919

2020
std::vector<float> bni_pyramid(std::function<bool(std::string s, int n)> progressed,
2121
int &w, int &h, std::vector<float> &normalmap,
2222
double k = 2.0,
2323
double tolerance = 1e-5,
2424
double solver_tolerance = 1e-5,
2525
int max_iterations = 150,
26-
int max_solver_iterations = 5000,
26+
int max_solver_iterations = 500,
2727
int scale = 0);
2828

2929
bool savePly(const QString &filename, int w, int h, std::vector<float> &z);

0 commit comments

Comments
 (0)