load a text list of views and their neighbors and assign them to the scene images; each line store the view ID followed by the 3+ closest view IDs, ordered in decreasing overlap: <...> for example: 0 1 2 3 4 1 0 2 3 4 2 1 3 0 4 ...
| 468 | // 2 1 3 0 4 |
| 469 | // ... |
| 470 | bool Scene::LoadViewNeighbors(const String& fileName) |
| 471 | { |
| 472 | TD_TIMER_STARTD(); |
| 473 | |
| 474 | // parse image list |
| 475 | SML smlImages(_T("ImageNeighbors")); |
| 476 | smlImages.Load(fileName); |
| 477 | ASSERT(smlImages.GetArrChildren().size() <= 1); |
| 478 | |
| 479 | // fetch image IDs list |
| 480 | size_t argc; |
| 481 | for (SML::const_iterator it=smlImages.begin(); it!=smlImages.end(); ++it) { |
| 482 | // parse image element |
| 483 | CAutoPtrArr<LPSTR> argv(Util::CommandLineToArgvA(it->second.val, argc)); |
| 484 | if (argc > 0 && argv[0][0] == _T('#')) |
| 485 | continue; |
| 486 | if (argc < 2) { |
| 487 | VERBOSE("Invalid image IDs list: %s", it->second.val.c_str()); |
| 488 | continue; |
| 489 | } |
| 490 | // add neighbors to this image |
| 491 | const IIndex ID(String::FromString<IIndex>(argv[0], NO_ID)); |
| 492 | ASSERT(ID != NO_ID); |
| 493 | Image& imageData = images[ID]; |
| 494 | imageData.neighbors.resize(static_cast<IIndex>(argc-1)); |
| 495 | FOREACH(i, imageData.neighbors) { |
| 496 | const IIndex nID(String::FromString<IIndex>(argv[i+1], NO_ID)); |
| 497 | ASSERT(nID != NO_ID); |
| 498 | imageData.neighbors[i] = ViewScore{nID, 0, 1.f, FD2R(15.f), 0.5f, 2.f+(argc-i)*0.5f}; |
| 499 | } |
| 500 | } |
| 501 | |
| 502 | DEBUG_EXTRA("View neighbors list loaded (%s)", TD_TIMER_GET_FMT().c_str()); |
| 503 | return true; |
| 504 | } // LoadViewNeighbors |
| 505 | bool Scene::SaveViewNeighbors(const String& fileName) const |
| 506 | { |
| 507 | ASSERT(ImagesHaveNeighbors()); |