| 472 | } // unnamed namespace |
| 473 | |
| 474 | int main(int argc, LPCTSTR* argv) |
| 475 | { |
| 476 | #ifdef _DEBUGINFO |
| 477 | // set _crtBreakAlloc index or use _CrtSetBreakAlloc() to stop in <dbgheap.c> at allocation |
| 478 | _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);// | _CRTDBG_CHECK_ALWAYS_DF); |
| 479 | #endif |
| 480 | |
| 481 | Application application; |
| 482 | if (!application.Initialize(argc, argv)) |
| 483 | return EXIT_FAILURE; |
| 484 | |
| 485 | TD_TIMER_START(); |
| 486 | |
| 487 | if (OPT::bOpenMVS2OpenMVG) { |
| 488 | // read OpenMVS input data |
| 489 | MVS::Scene scene(OPT::nMaxThreads); |
| 490 | if (!scene.Load(MAKE_PATH_SAFE(OPT::strInputFileName))) |
| 491 | return EXIT_FAILURE; |
| 492 | |
| 493 | // convert data from OpenMVS to OpenMVG |
| 494 | openMVS::MVS_IO::SfM_Scene sceneBAF; |
| 495 | FOREACH(p, scene.platforms) { |
| 496 | const MVS::Platform& platform = scene.platforms[p]; |
| 497 | if (platform.cameras.GetSize() != 1) { |
| 498 | LOG("error: unsupported scene structure"); |
| 499 | return EXIT_FAILURE; |
| 500 | } |
| 501 | const MVS::Platform::Camera& camera = platform.cameras[0]; |
| 502 | openMVS::MVS_IO::Camera cameraBAF; |
| 503 | cameraBAF.K = camera.K; |
| 504 | sceneBAF.cameras.push_back(cameraBAF); |
| 505 | } |
| 506 | FOREACH(i, scene.images) { |
| 507 | const MVS::Image& image = scene.images[i]; |
| 508 | const MVS::Platform& platform = scene.platforms[image.platformID]; |
| 509 | const MVS::Platform::Pose& pose = platform.poses[image.poseID]; |
| 510 | openMVS::MVS_IO::Image imageBAF; |
| 511 | imageBAF.name = image.name; |
| 512 | imageBAF.name = MAKE_PATH_REL(WORKING_FOLDER_FULL, imageBAF.name); |
| 513 | imageBAF.id_camera = image.platformID; |
| 514 | imageBAF.id_pose = (uint32_t)sceneBAF.poses.size(); |
| 515 | sceneBAF.images.push_back(imageBAF); |
| 516 | openMVS::MVS_IO::Pose poseBAF; |
| 517 | poseBAF.R = pose.R; |
| 518 | poseBAF.C = pose.C; |
| 519 | sceneBAF.poses.push_back(poseBAF); |
| 520 | } |
| 521 | sceneBAF.vertices.reserve(scene.pointcloud.points.GetSize()); |
| 522 | FOREACH(p, scene.pointcloud.points) { |
| 523 | const MVS::PointCloud::Point& point = scene.pointcloud.points[p]; |
| 524 | openMVS::MVS_IO::Vertex vertexBAF; |
| 525 | vertexBAF.X = ((const MVS::PointCloud::Point::EVec)point).cast<REAL>(); |
| 526 | const MVS::PointCloud::ViewArr& views = scene.pointcloud.pointViews[p]; |
| 527 | FOREACH(v, views) { |
| 528 | unsigned viewBAF = views[(uint32_t)v]; |
| 529 | vertexBAF.views.push_back(viewBAF); |
| 530 | } |
| 531 | sceneBAF.vertices.push_back(vertexBAF); |
nothing calls this directly
no test coverage detected