Skip to content

Commit 08e3c00

Browse files
author
Erika
committed
Depthmap classes almost complete
1 parent f6e2025 commit 08e3c00

File tree

3 files changed

+39
-25
lines changed

3 files changed

+39
-25
lines changed

depthmap/depthmap.cpp

+3-5
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ void Depthmap::saveTiff(const char *mask_path,const vector<float> &values, uint3
491491
if (scanLineSize == 0) {
492492
cerr << "Error computing scanline size." << endl;
493493
TIFFClose(maskTiff);
494-
return;
494+
throw QString("Width is zero");
495495
}
496496

497497

@@ -667,7 +667,7 @@ void Depthmap::resizeNormals (int factorPowerOfTwo, int step) {
667667

668668
if (srcX < width && srcY < height) {
669669

670-
// 1. create the array dx and dy, after convert to normals
670+
// 1. create the array dx and dxy, after convert to normals
671671
Eigen::Vector3f normal = normals[srcX + srcY * width];
672672
float dzdx = -normal.x() / normal.z();
673673
float dzdy = -normal.y() / normal.z();
@@ -939,10 +939,7 @@ void OrthoDepthmap::loadPointCloud(const char *textPath){
939939
throw QString("Invalide ply");
940940

941941
point_cloud.push_back(v);
942-
943942
}
944-
945-
946943
}
947944

948945
Eigen::Vector3f OrthoDepthmap::realToPixelCoord(float realX, float realY, float realZ){
@@ -1042,6 +1039,7 @@ void OrthoDepthmap::endIntegration(){
10421039
#endif
10431040
if(weights[i] != 0.0f) {
10441041
elevation[i] /= weights[i];
1042+
mask[i] = 1;
10451043
}
10461044
#ifdef PRESERVE_INTERIOR
10471045
}

depthmap/main.cpp

+30-20
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@ int main(int argc, char *argv[]) {
1717
return 1;
1818
}*/
1919
//input
20-
//#define MACOS 1
20+
#define MACOS 1
2121
#ifdef MACOS
22-
QString base = "/Users/erika/Desktop/testcenterRel_copia/";
22+
QString base = "/Users/erika/Desktop/testRelightMicMac/";
2323
#else
2424
QString base = "";
2525
#endif
2626

2727

2828

29-
QString depthmapPath = base + base + "Z_Num7_DeZoom4_STD-MALT.tif";
29+
QString depthmapPath = base + "photogrammetry/Malt/Z_Num7_DeZoom4_STD-MALT.tif";
3030
//QString cameraDepthmap = base + "datasets/L04C12.tif";
3131
//QString orientationXmlPath = base + "photogrammetry/Ori-Relative/Orientation-L04C12.tif.xml";
32-
QString maskPath = base + "Masq_STD-MALT_DeZoom4.tif";
33-
QString plyFile = base +"AperiCloud_Relative__mini.ply";
32+
QString maskPath = base + "photogrammetry/Malt/Masq_STD-MALT_DeZoom4.tif";
33+
QString plyFile = base + "photogrammetry/AperiCloud_Relative__mini.ply";
3434
//QString point_txt = base + "photogrammetry/points_h.txt";
3535
Depthmap depth;
3636

@@ -47,7 +47,7 @@ int main(int argc, char *argv[]) {
4747

4848
QFile::remove(depthmapPath);
4949
if (!QFile::copy(depthmapPath + "_backup.tif", depthmapPath)) {
50-
cout << "Errror copying depthmap" << endl;
50+
cout << "Error copying depthmap" << depthmapPath.toStdString() << endl;
5151
exit(0);
5252
}
5353
QFile::remove(maskPath);
@@ -61,32 +61,34 @@ int main(int argc, char *argv[]) {
6161
return -1;
6262
}
6363

64-
QDir datasetsDir(base + "../datasets");
65-
QDir xmlDir(base + "Ori-Relative");
66-
QStringList tiffFilters = {"*.tif"};
67-
QStringList xmlFilters = {"Orientation-*.tif.xml"};
64+
QDir datasetsDir(base + "datasets");
65+
QDir xmlDir(base + "photogrammetry/Ori-Relative");
66+
67+
QStringList extensions = {".tiff", ".tif", ".jpg", ".jpeg"};
68+
QStringList tiffFilters = {"*.tiff"};
69+
6870

6971
QFileInfoList tiffFiles = datasetsDir.entryInfoList(tiffFilters, QDir::Files);
7072
if (tiffFiles.isEmpty()) {
7173
cerr << "No .tiff files found in " << datasetsDir.absolutePath().toStdString() << endl;
7274
return -1;
7375
}
7476

75-
QFileInfoList xmlFiles = xmlDir.entryInfoList(xmlFilters, QDir::Files);
77+
QFileInfoList xmlFiles = xmlDir.entryInfoList({"*.xml"}, QDir::Files);
7678
if (xmlFiles.isEmpty()) {
7779
cerr << "No .xml files found in " << xmlDir.absolutePath().toStdString() << endl;
7880
return -1;
7981
}
8082

81-
//doortho = 1 domec =0;
8283

84+
//doortho = 1 domec =0;
8385

8486
//ortho.computeNormals();
8587
//ortho.saveNormals(qPrintable(base + "testcenterRel_copia/photogrammetry/original.png"));
8688
//ortho.saveObj(qPrintable(base + "testcenterRel_copia/photogrammetry/original.obj"));
8789
try{
88-
ortho.saveDepth(qPrintable(output_depth));
89-
ortho.saveMask(qPrintable(output_mask));
90+
ortho.loadDepth(qPrintable(depthmapPath));
91+
ortho.loadMask(qPrintable(maskPath));
9092
ortho.loadPointCloud(qPrintable(plyFile));
9193
} catch(QString e){
9294
cout << qPrintable(e) << endl;
@@ -95,15 +97,23 @@ int main(int argc, char *argv[]) {
9597

9698
ortho.verifyPointCloud();
9799
ortho.beginIntegration();
98-
100+
QString orientationXmlPath;
99101

100102
for (const QFileInfo &tiffFile : tiffFiles) {
101103

102104
CameraDepthmap depthCam;
103105
QString cameraName = tiffFile.completeBaseName();
104-
QString orientationXmlPath = xmlDir.absoluteFilePath("Orientation-" + cameraName + ".tif.xml");
106+
QString orientationXmlPath;
107+
for (const QString &ext : extensions) {
108+
QString potentialPath = xmlDir.absoluteFilePath("Orientation-" + cameraName + ext + ".xml");
109+
if (QFile::exists(potentialPath)) {
110+
orientationXmlPath = potentialPath;
111+
break;
112+
}
113+
}
114+
/*QString orientationXmlPath = xmlDir.absoluteFilePath("Orientation-" + cameraName + ext + ".xml");
105115
106-
cout << "Looking for XML: " << orientationXmlPath.toStdString() << endl;
116+
cout << "Looking for XML: " << orientationXmlPath.toStdString() << endl;*/
107117

108118
if (!depthCam.camera.loadXml(orientationXmlPath)) {
109119
cerr << "Failed to load XML: " << orientationXmlPath.toStdString() << endl;
@@ -112,7 +122,7 @@ int main(int argc, char *argv[]) {
112122

113123
if (!depthCam.loadDepth(qPrintable(tiffFile.absoluteFilePath()))) {
114124
cerr << "Failed to load depth map: " << tiffFile.fileName().toStdString() << endl;
115-
continue;
125+
exit(0);
116126
}
117127
if(depthCam.width != depthCam.camera.width || depthCam.height != depthCam.camera.height){
118128
cerr << "width is not the same" << endl;
@@ -130,7 +140,7 @@ int main(int argc, char *argv[]) {
130140
ortho.endIntegration();
131141
ortho.saveDepth(qPrintable(depthmapPath));
132142
ortho.saveMask(qPrintable(maskPath));
133-
ortho.saveObj("weightsElev2.obj");
143+
ortho.saveObj("weightsElev3.obj");
134144

135145

136146

@@ -154,7 +164,7 @@ int main(int argc, char *argv[]) {
154164
// depth.saveDepth(qPrintable(depthmapPath));
155165
// depth.saveMask(qPrintable(maskPath));
156166
//QString maskObjPath = base + "testcenterRel_copia/photogrammetry/mask.obj";
157-
ortho.saveObj(qPrintable(base + "depthmap_projectL05C13.obj"));
167+
//ortho.saveObj(qPrintable(base + "depthmap_projectL05C13.obj"));
158168

159169

160170
//depth.depthIntegrateNormals();

relight-pano/panobuilder.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,12 @@ void PanoBuilder::malt_ortho(){
563563

564564
executeProcess(program, arguments);
565565

566+
QString depthmapPath = "../photogrammetry/Malt/Z_Num7_DeZoom4_STD-MALT.tif";
567+
if (!QFile::copy(depthmapPath + "_backup.tif", depthmapPath)) {
568+
cout << "Error copying depthmap" << depthmapPath.toStdString() << endl;
569+
exit(0);
570+
}
571+
566572
QStringList ortImages = QDir(orthoPlaneDirName).entryList(QStringList() << "Ort_*.tif", QDir::Files);
567573
if (ortImages.isEmpty()) {
568574
throw QString("Error: No output images found in ").arg(orthoPlaneDirName);

0 commit comments

Comments
 (0)