Skip to content

Commit

Permalink
added latest version of depthmap
Browse files Browse the repository at this point in the history
  • Loading branch information
Erika committed Jan 15, 2025
1 parent 8ccca38 commit 28d9f75
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 16 deletions.
26 changes: 19 additions & 7 deletions depthmap/depthmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -983,8 +983,21 @@ void OrthoDepthmap::verifyPointCloud(){


}
void OrthoDepthmap::integratedCamera(const CameraDepthmap& camera){
int count =0;
void OrthoDepthmap::integratedCamera(const CameraDepthmap& camera, const char *outputFile){

QFile outFile(outputFile);
if (!outFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
cerr << "Errore nell'aprire il file di output: " << outputFile << endl;
return;
}
//test
float z = point_cloud[0][2];
auto o = camera.camera.projectionToImage(Eigen::Vector3f(0, 0, z));
auto u = camera.camera.projectionToImage(Eigen::Vector3f(1, 0, z));
float pixel_size = 1 / (u[0] - o[0]);

QTextStream out(&outFile);

for (size_t i = 0; i < point_cloud.size(); i++) {

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

if (pixelX >= 0 && pixelX < camera.width && pixelY >= 0 && pixelY < camera.height) {
float depthValue = elevation[pixelX + pixelY * camera.width];
float h = pixelCoord[2];
count++;
cout << depthValue << h << endl;
float depthValue = camera.elevation[pixelX + pixelY * camera.width]* pixel_size;
float h = realCoord[2];

out << depthValue << "\t" << h << "\t" << imageCoords[0]/camera.width << "\t" << imageCoords[1]/camera.height <<"\n"; //red e green


}
}
cout << count << endl;
}
//fit h = a+b*elev

Expand Down
2 changes: 1 addition & 1 deletion depthmap/depthmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class OrthoDepthmap:
//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
//legge nella depth l h corrispondente
void verifyPointCloud();
void integratedCamera(const CameraDepthmap& camera);
void integratedCamera(const CameraDepthmap& camera, const char *outputFile);
void fitLinearRegressionFromPairs();


Expand Down
20 changes: 12 additions & 8 deletions depthmap/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ int main(int argc, char *argv[]) {
#endif

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

OrthoDepthmap ortho;

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

Camera camera;
camera.loadXml(orientationXmlPath);
CameraDepthmap depthCam;
//xml per camera e tiff per la depth map
depthCam.camera.loadXml(orientationXmlPath);
depthCam.loadDepth(qPrintable(depthmapPath));
ortho.integratedCamera(depthCam);
depthCam.loadDepth(qPrintable(cameraDepthmap));
if(depthCam.width != depthCam.camera.width || depthCam.height != depthCam.camera.height){
cerr << "width is not the same" << endl;
return -1;
}
ortho.integratedCamera(depthCam, qPrintable(output_points));


//int pixelX = 165;
//int pixelY = 144;
//float pixelZ = 4.5;
ortho.projectToCameraDepthMap(camera, outputPath);
ortho.projectToCameraDepthMap(depthCam.camera, outputPath);
Eigen::Matrix3f rotationMatrix;
Eigen::Vector3f center;

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

cout << "Rotation matrix:"<< endl << camera.rotation << endl;
cout << "Central vector: (" << camera.center << endl;
//cout << "Rotation matrix:"<< endl << camera.rotation << endl;
//cout << "Central vector: (" << camera.center << endl;
//cout << "Real coordinates: (" << realCoordinates[0] << ", "
// << realCoordinates[1] << ", " << realCoordinates[2] << ")" << endl;

Expand Down

0 comments on commit 28d9f75

Please sign in to comment.