Skip to content

Commit 28d9f75

Browse files
author
Erika
committed
added latest version of depthmap
1 parent 8ccca38 commit 28d9f75

File tree

3 files changed

+32
-16
lines changed

3 files changed

+32
-16
lines changed

depthmap/depthmap.cpp

+19-7
Original file line numberDiff line numberDiff line change
@@ -983,8 +983,21 @@ void OrthoDepthmap::verifyPointCloud(){
983983

984984

985985
}
986-
void OrthoDepthmap::integratedCamera(const CameraDepthmap& camera){
987-
int count =0;
986+
void OrthoDepthmap::integratedCamera(const CameraDepthmap& camera, const char *outputFile){
987+
988+
QFile outFile(outputFile);
989+
if (!outFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
990+
cerr << "Errore nell'aprire il file di output: " << outputFile << endl;
991+
return;
992+
}
993+
//test
994+
float z = point_cloud[0][2];
995+
auto o = camera.camera.projectionToImage(Eigen::Vector3f(0, 0, z));
996+
auto u = camera.camera.projectionToImage(Eigen::Vector3f(1, 0, z));
997+
float pixel_size = 1 / (u[0] - o[0]);
998+
999+
QTextStream out(&outFile);
1000+
9881001
for (size_t i = 0; i < point_cloud.size(); i++) {
9891002

9901003
Eigen::Vector3f& realCoord = point_cloud[i];
@@ -995,15 +1008,14 @@ void OrthoDepthmap::integratedCamera(const CameraDepthmap& camera){
9951008
int pixelY = static_cast<int>(round(imageCoords[1]));
9961009

9971010
if (pixelX >= 0 && pixelX < camera.width && pixelY >= 0 && pixelY < camera.height) {
998-
float depthValue = elevation[pixelX + pixelY * camera.width];
999-
float h = pixelCoord[2];
1000-
count++;
1001-
cout << depthValue << h << endl;
1011+
float depthValue = camera.elevation[pixelX + pixelY * camera.width]* pixel_size;
1012+
float h = realCoord[2];
1013+
1014+
out << depthValue << "\t" << h << "\t" << imageCoords[0]/camera.width << "\t" << imageCoords[1]/camera.height <<"\n"; //red e green
10021015

10031016

10041017
}
10051018
}
1006-
cout << count << endl;
10071019
}
10081020
//fit h = a+b*elev
10091021

depthmap/depthmap.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class OrthoDepthmap:
8989
//itera sui punti, chiama l'inversa, prima converte a intero perche sono float vede se xy stanno in w e h, se non dentro problema
9090
//legge nella depth l h corrispondente
9191
void verifyPointCloud();
92-
void integratedCamera(const CameraDepthmap& camera);
92+
void integratedCamera(const CameraDepthmap& camera, const char *outputFile);
9393
void fitLinearRegressionFromPairs();
9494

9595

depthmap/main.cpp

+12-8
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ int main(int argc, char *argv[]) {
2222
#endif
2323

2424
QString depthmapPath = base + "testcenterRel_copia/photogrammetry/Malt/Z_Num7_DeZoom4_STD-MALT.tif";
25-
QString orientationXmlPath = base + "testcenterRel_copia/photogrammetry/Ori-Relative/Orientation-L05C12.tif.xml";
25+
QString cameraDepthmap = base + "testcenterRel_copia/datasets/L04C12_depth_rti.tiff";
26+
QString orientationXmlPath = base + "testcenterRel_copia/photogrammetry/Ori-Relative/Orientation-L04C12.tif.xml";
2627
QString maskPath = base + "testcenterRel_copia/photogrammetry/Malt/Masq_STD-MALT_DeZoom4.tif";
2728
QString plyFile = base +"testcenterRel_copia/photogrammetry/AperiCloud_Relative__mini.ply";
2829
Depthmap depth;
@@ -31,6 +32,7 @@ int main(int argc, char *argv[]) {
3132
QString outputPath = base + "testcenterRel_copia/photogrammetry/depthmap_projectL05C13.png";
3233
QString output_mask = base + "testcenterRel_copia/photogrammetry/mask_test.tif";
3334
QString output_depth = base + "testcenterRel_copia/photogrammetry/depth_test.tif";
35+
QString output_points = base + "testcenterRel_copia/photogrammetry/points_h.txt";
3436

3537
OrthoDepthmap ortho;
3638

@@ -52,19 +54,21 @@ int main(int argc, char *argv[]) {
5254
ortho.verifyPointCloud();
5355
ortho.fitLinearRegressionFromPairs();
5456

55-
Camera camera;
56-
camera.loadXml(orientationXmlPath);
5757
CameraDepthmap depthCam;
5858
//xml per camera e tiff per la depth map
5959
depthCam.camera.loadXml(orientationXmlPath);
60-
depthCam.loadDepth(qPrintable(depthmapPath));
61-
ortho.integratedCamera(depthCam);
60+
depthCam.loadDepth(qPrintable(cameraDepthmap));
61+
if(depthCam.width != depthCam.camera.width || depthCam.height != depthCam.camera.height){
62+
cerr << "width is not the same" << endl;
63+
return -1;
64+
}
65+
ortho.integratedCamera(depthCam, qPrintable(output_points));
6266

6367

6468
//int pixelX = 165;
6569
//int pixelY = 144;
6670
//float pixelZ = 4.5;
67-
ortho.projectToCameraDepthMap(camera, outputPath);
71+
ortho.projectToCameraDepthMap(depthCam.camera, outputPath);
6872
Eigen::Matrix3f rotationMatrix;
6973
Eigen::Vector3f center;
7074

@@ -144,8 +148,8 @@ lineare per la serie di coppie per trovare a e b). Pesa i punti.
144148
//realCoordinates[2] = -10.4198828;
145149
//Eigen::Vector3f imageCoords = camera.projectionToImage(realCoordinates);
146150

147-
cout << "Rotation matrix:"<< endl << camera.rotation << endl;
148-
cout << "Central vector: (" << camera.center << endl;
151+
//cout << "Rotation matrix:"<< endl << camera.rotation << endl;
152+
//cout << "Central vector: (" << camera.center << endl;
149153
//cout << "Real coordinates: (" << realCoordinates[0] << ", "
150154
// << realCoordinates[1] << ", " << realCoordinates[2] << ")" << endl;
151155

0 commit comments

Comments
 (0)