| 1443 | } |
| 1444 | |
| 1445 | bool System::LoadAtlas(int type) |
| 1446 | { |
| 1447 | string strFileVoc, strVocChecksum; |
| 1448 | bool isRead = false; |
| 1449 | |
| 1450 | string pathLoadFileName = "./"; |
| 1451 | pathLoadFileName = pathLoadFileName.append(mStrLoadAtlasFromFile); |
| 1452 | pathLoadFileName = pathLoadFileName.append(".osa"); |
| 1453 | |
| 1454 | if(type == TEXT_FILE) // File text |
| 1455 | { |
| 1456 | cout << "Starting to read the save text file " << endl; |
| 1457 | std::ifstream ifs(pathLoadFileName, std::ios::binary); |
| 1458 | if(!ifs.good()) |
| 1459 | { |
| 1460 | cout << "Load file not found" << endl; |
| 1461 | return false; |
| 1462 | } |
| 1463 | boost::archive::text_iarchive ia(ifs); |
| 1464 | ia >> strFileVoc; |
| 1465 | ia >> strVocChecksum; |
| 1466 | ia >> mpAtlas; |
| 1467 | cout << "End to load the save text file " << endl; |
| 1468 | isRead = true; |
| 1469 | } |
| 1470 | else if(type == BINARY_FILE) // File binary |
| 1471 | { |
| 1472 | cout << "Starting to read the save binary file" << endl; |
| 1473 | std::ifstream ifs(pathLoadFileName, std::ios::binary); |
| 1474 | if(!ifs.good()) |
| 1475 | { |
| 1476 | cout << "Load file not found" << endl; |
| 1477 | return false; |
| 1478 | } |
| 1479 | boost::archive::binary_iarchive ia(ifs); |
| 1480 | ia >> strFileVoc; |
| 1481 | ia >> strVocChecksum; |
| 1482 | ia >> mpAtlas; |
| 1483 | cout << "End to load the save binary file" << endl; |
| 1484 | isRead = true; |
| 1485 | } |
| 1486 | |
| 1487 | if(isRead) |
| 1488 | { |
| 1489 | //Check if the vocabulary is the same |
| 1490 | string strInputVocabularyChecksum = CalculateCheckSum(mStrVocabularyFilePath,TEXT_FILE); |
| 1491 | |
| 1492 | if(strInputVocabularyChecksum.compare(strVocChecksum) != 0) |
| 1493 | { |
| 1494 | cout << "The vocabulary load isn't the same which the load session was created " << endl; |
| 1495 | cout << "-Vocabulary name: " << strFileVoc << endl; |
| 1496 | return false; // Both are differents |
| 1497 | } |
| 1498 | |
| 1499 | mpAtlas->SetKeyFrameDababase(mpKeyFrameDatabase); |
| 1500 | mpAtlas->SetORBVocabulary(mpVocabulary); |
| 1501 | mpAtlas->PostLoad(); |
| 1502 |
nothing calls this directly
no test coverage detected