Skip to content

Commit

Permalink
improve interface - camera normalization update (openMVG#1812)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdcseacave authored Oct 23, 2020
1 parent 1389cbd commit d3f93bd
Showing 1 changed file with 2 additions and 32 deletions.
34 changes: 2 additions & 32 deletions src/software/SfM/export/main_openMVG2openMVS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ bool exportToOpenMVS(
MVS::Interface::Platform platform;
// add the camera
MVS::Interface::Platform::Camera camera;
camera.width = cam->w();
camera.height = cam->h();
camera.K = cam->K();
// sub-pose
camera.R = Mat3::Identity();
Expand Down Expand Up @@ -228,38 +230,6 @@ bool exportToOpenMVS(
scene.vertices.push_back(vert);
}

// normalize camera intrinsics
for (size_t p=0; p<scene.platforms.size(); ++p)
{
MVS::Interface::Platform& platform = scene.platforms[p];
for (size_t c=0; c<platform.cameras.size(); ++c) {
MVS::Interface::Platform::Camera& camera = platform.cameras[c];
// find one image using this camera
MVS::Interface::Image* pImage(nullptr);
for (MVS::Interface::Image& image: scene.images)
{
if (image.platformID == p && image.cameraID == c && image.poseID != NO_ID)
{
pImage = &image;
break;
}
}
if (!pImage)
{
std::cerr << "error: no image using camera " << c << " of platform " << p << std::endl;
continue;
}
// read image meta-data
ImageHeader imageHeader;
ReadImageHeader(pImage->name.c_str(), &imageHeader);
const double fScale(1.0/std::max(imageHeader.width, imageHeader.height));
camera.K(0, 0) *= fScale;
camera.K(1, 1) *= fScale;
camera.K(0, 2) *= fScale;
camera.K(1, 2) *= fScale;
}
}

// write OpenMVS data
if (!MVS::ARCHIVE::SerializeSave(scene, sOutFile))
return false;
Expand Down

0 comments on commit d3f93bd

Please sign in to comment.