parse scene stored in MVSNet format composed of undistorted images and camera poses for example see GigaVision benchmark (http://gigamvs.net): |--sceneX |--images |--xxx.jpg |--xxx.jpg .... |--cams |--xxx_cam.txt |--xxx_cam.txt .... |--render_cams |--xxx_cam.txt |--xxx_cam.txt .... where the camera parameter of one image stored in a cam.txt file contains the camera extrinsic E = [R|t], intrinsic
| 260 | // |
| 261 | // DEPTH_MIN DEPTH_INTERVAL (DEPTH_NUM DEPTH_MAX) |
| 262 | bool ParseSceneMVSNet(Scene& scene, const String& strPath) |
| 263 | { |
| 264 | #if defined(_SUPPORT_CPP17) && (!defined(__GNUC__) || (__GNUC__ > 7)) |
| 265 | IIndex prevPlatformID = NO_ID; |
| 266 | for (const std::filesystem::directory_entry& entry : std::filesystem::directory_iterator((strPath + MVSNET_IMAGES_FOLDER).c_str())) { |
| 267 | if (entry.path().extension() != MVSNET_IMAGES_EXT) |
| 268 | continue; |
| 269 | // parse camera |
| 270 | const std::string strCamFileName(strPath + MVSNET_CAMERAS_FOLDER PATH_SEPARATOR_STR + entry.path().stem().string().c_str() + MVSNET_CAMERAS_NAME); |
| 271 | std::ifstream fcam(strCamFileName); |
| 272 | if (!fcam) |
| 273 | continue; |
| 274 | String line; |
| 275 | do { |
| 276 | std::getline(fcam, line); |
| 277 | } while (line != "extrinsic" && fcam.good()); |
| 278 | String strP; |
| 279 | for (int i = 0; i < 3; ++i) { |
| 280 | std::getline(fcam, line); |
| 281 | strP += ' ' + line; |
| 282 | } |
| 283 | if (!fcam.good()) |
| 284 | continue; |
| 285 | size_t argc; |
| 286 | CAutoPtrArr<LPSTR> argv; |
| 287 | argv = Util::CommandLineToArgvA(strP, argc); |
| 288 | if (argc != 12) |
| 289 | continue; |
| 290 | Matrix3x4 P; |
| 291 | ImageListParse(argv, P); |
| 292 | do { |
| 293 | std::getline(fcam, line); |
| 294 | } while (line != "intrinsic" && fcam.good()); |
| 295 | strP.clear(); |
| 296 | for (int i = 0; i < 3; ++i) { |
| 297 | std::getline(fcam, line); |
| 298 | strP += ' ' + line; |
| 299 | } |
| 300 | if (!fcam.good()) |
| 301 | continue; |
| 302 | argv = Util::CommandLineToArgvA(strP, argc); |
| 303 | if (argc != 9) |
| 304 | continue; |
| 305 | Matrix3x3 K; |
| 306 | ImageListParse(argv, K); |
| 307 | // setup camera |
| 308 | IIndex platformID; |
| 309 | if (prevPlatformID == NO_ID || !K.IsEqual(scene.platforms[prevPlatformID].cameras[0].K, 1e-3)) { |
| 310 | prevPlatformID = platformID = scene.platforms.size(); |
| 311 | Platform& platform = scene.platforms.emplace_back(); |
| 312 | Platform::Camera& camera = platform.cameras.emplace_back(); |
| 313 | camera.K = K; |
| 314 | camera.R = RMatrix::IDENTITY; |
| 315 | camera.C = CMatrix::ZERO; |
| 316 | } else { |
| 317 | platformID = prevPlatformID; |
| 318 | } |
| 319 | Platform& platform = scene.platforms[platformID]; |
no test coverage detected