Osmap
1
Osmap documentation
|
This is a class for a singleton attached to ORB-SLAM2's map. More...
#include <Osmap.h>
Public Types | |
enum | Options { FEATURES_FILE_DELIMITED, FEATURES_FILE_NOT_DELIMITED, NO_MAPPOINTS_FILE, NO_KEYFRAMES_FILE, NO_FEATURES_FILE, NO_FEATURES_DESCRIPTORS, ONLY_MAPPOINTS_FEATURES, NO_LOOPS, K_IN_KEYFRAME, NO_DEPURATION, NO_SET_BAD, NO_APPEND_FOUND_MAPPOINTS, OPTIONS_SIZE } |
All the options available. More... | |
Public Member Functions | |
void | clearVectors () |
Clear temporary vectors. More... | |
int | countFeatures () |
Count the number of features in vectorKeyFrames. More... | |
void | depurate () |
Irons keyframes and mappoints sets in map, before save. More... | |
void | deserialize (const SerializedK &, Mat &k) |
Reconstruct the intrinsic camera matrix K from protocol buffer message. More... | |
void | deserialize (const SerializedKArray &serializedKArray, vector< Mat *> &vK) |
Reconstruct an array of camera calibration matrix K. More... | |
void | deserialize (const SerializedDescriptor &, Mat &) |
Reconstruct a descriptor, an 1x32 uchar Mat (256 bits). More... | |
void | deserialize (const SerializedPose &, Mat &) |
Reconstruct a 4x4 float Mat representing a pose in homogeneous coordinates. More... | |
void | deserialize (const SerializedPosition &, Mat &) |
Reconstructs 3D mappoint position in a 3x1 float Mat. More... | |
void | deserialize (const SerializedKeypoint &, KeyPoint &) |
Reconstructs a KeyPoint. More... | |
OsmapMapPoint * | deserialize (const SerializedMappoint &serializedMappoint) |
Creates and fills a MapPoint from optional message fields. More... | |
int | deserialize (const SerializedMappointArray &, vector< OsmapMapPoint *> &) |
Retrieves MapPoints from an array, and append them to the map. More... | |
OsmapKeyFrame * | deserialize (const SerializedKeyframe &) |
Reconstructs a KeyFrame from optional fields. More... | |
int | deserialize (const SerializedKeyframeArray &, vector< OsmapKeyFrame *> &) |
Retrieves MapPoints from an array, and append them to the map. More... | |
OsmapKeyFrame * | deserialize (const SerializedKeyframeFeatures &) |
Retrieves all features belonging to one keyframe. More... | |
int | deserialize (const SerializedKeyframeFeaturesArray &) |
Retrieves all keyframe's features from the specified serialization object to vectorKeyframe. More... | |
int | featuresLoad (string filename) |
Load the content of a "map.features" file and applies it to vectorKeyFrames. More... | |
int | featuresSave (string filename) |
Save KeyFrane's features of vectorKeyFrames to file, usually "map.features". More... | |
OsmapKeyFrame * | getKeyFrame (unsigned int id) |
Looks for a KeyFrame id in the map. More... | |
void | getKeyFramesFromMap () |
Populate vectorKeyFrames with MapPoints from Map.mspKeyFrames. More... | |
MapPoint * | getMapPoint (unsigned int id) |
Looks for a mappoint by its id in the map. More... | |
void | getMapPointsFromMap () |
Populate vectorMapPoints with MapPoints from Map.mspMapPoints. More... | |
void | getVectorKFromKeyframes () |
Traverse map's keyframes looking for different K matrices, and stores them into vectorK. More... | |
int | KeyFramesLoad (string filename) |
Load the content of a "map.keyframes" file to vectorKeyFrames. More... | |
int | KeyFramesSave (string filename) |
Save the content of vectorKeyFrames to file like "map.keyframes". More... | |
void | log () |
template<typename Head , typename... Args> | |
void | log (const Head &head, const Args &... args) |
void | mapLoad (string yamlFilename, bool noSetBad=false, bool pauseThreads=true) |
Loads the map from a set of files in the folder whose name is provided as an argument. More... | |
int | MapPointsLoad (string filename) |
Load the content of a "map.mappoints" file to vectorMapPoints. More... | |
int | MapPointsSave (string filename) |
Save the content of vectorMapPoints to file like "map.mappoints". More... | |
void | mapSave (string basefilename, bool pauseThreads=true) |
Saves the map to a set of files in the actual directory, with the extensionless name provided as the only argument and different extensions for each file. More... | |
Osmap (System &_system) | |
Only constructor, the only way to set the orb-slam2 map. More... | |
void | parsePath (const string &path, string *filename=NULL, string *pathDirectory=NULL) |
Utility for separating path and filename from a full path. More... | |
bool | readDelimitedFrom (google::protobuf::io::ZeroCopyInputStream *rawInput, google::protobuf::MessageLite *message) |
Reads a message to a vector file. More... | |
void | rebuild (bool noSetBad=false) |
Rebuilding takes place right after loading a map from files, before the map is copied to ORB-SLAM2' sets. More... | |
void | serialize (const Mat &k, SerializedK *serializedK) |
Serialize provided intrinsic camera matrix K to the protocol buffer message. More... | |
void | serialize (const vector< Mat *> &vK, SerializedKArray &serializedKArray) |
Serialize an array of camera calibration matrix K. More... | |
void | serialize (const Mat &, SerializedDescriptor *) |
Serializes a descriptor, an 1x32 uchar Mat (256 bits). More... | |
void | serialize (const Mat &, SerializedPose *) |
Serialize a 4x4 float Mat representing a pose in homogeneous coordinates. More... | |
void | serialize (const Mat &, SerializedPosition *) |
Serialize 3D mappoint position, a 3x1 float Mat. More... | |
void | serialize (const KeyPoint &, SerializedKeypoint *) |
Serialize 4 properties of a KeyPoint. More... | |
void | serialize (const OsmapMapPoint &, SerializedMappoint *) |
Serializes a MapPoint, according to options. More... | |
int | serialize (const vector< OsmapMapPoint *> &, SerializedMappointArray &) |
Serialized array of MapPoints. More... | |
void | serialize (const OsmapKeyFrame &, SerializedKeyframe *) |
Serialize a KeyFrame. More... | |
int | serialize (const vector< OsmapKeyFrame *> &, SerializedKeyframeArray &) |
Serialized array of KeyFrames. More... | |
void | serialize (const OsmapKeyFrame &, SerializedKeyframeFeatures *) |
Serialize all features observed by a KeyFrame. More... | |
int | serialize (const vector< OsmapKeyFrame *> &vKF, SerializedKeyframeFeaturesArray &serializedKeyframeFeaturesArray) |
Serialize all keyframe's features from provided keyframes container, to the specified serialization object. More... | |
void | setKeyFramesToMap () |
Populate Map.mspKeyFrames with MapPoints from vectorKeyFrames. More... | |
void | setMapPointsToMap () |
Populate Map.mspMapPoints with MapPoints from vectorMapPoints. More... | |
bool | writeDelimitedTo (const google::protobuf::MessageLite &message, google::protobuf::io::ZeroCopyOutputStream *rawOutput) |
Writes a message to a vector file. More... | |
Public Attributes | |
Frame & | currentFrame |
Any frame, to copy configuration values from. More... | |
KeyFrameDatabase & | keyFrameDatabase |
Database of keyframes to be build after loading. More... | |
vector< unsigned int > | keyframeid2vectorkIdx |
For each index KeyFrame.mnId the value returned is an index to vectorK. More... | |
OsmapMap & | map |
ORB-SLAM2 map to be serialized. More... | |
bitset< 32 > | options = 0 |
Set of chosen options for serializing. More... | |
KeyFrame * | pRefKF = NULL |
This keyframe is a vehicle to MapPoint construction, which need a pRefKF as argument. More... | |
System & | system |
System, needed to populate new keyframes after construction on deserialization, with some configuration values. More... | |
vector< Mat const * > | vectorK |
Usually there is only one common matrix K for all KeyFrames in the entire map, there can be more, but there won't be as many K as KeyFrames. More... | |
vector< OsmapKeyFrame * > | vectorKeyFrames |
Buffer where map's keyframes are stored in ascending id order, to save them to file in this order. More... | |
vector< OsmapMapPoint * > | vectorMapPoints |
Buffer where map's mappoints are stored in ascending id order, to save them to file in this order. More... | |
bool | verbose = false |
Whether or not print on console info for debuging. More... | |
This is a class for a singleton attached to ORB-SLAM2's map.
Its constructor attaches it to the map. Its methods mapLoad and mapSave load and save a map.
A map is saved to a set of files in the actual folder, with a filename provided:
The header is the only text file, in yaml format. Other files are in binary format. keyframes, mappoints and features files consist on a single protocol buffers 3 message. features file can also be an ad hoc delimited array of protocol buffers 3 messages.
Protocol buffers messages format can be found in osmap.proto file. Some of these objects has another object like KeyPoint, nested serialized with the appropiate serialize signature.
Methods:
General rules:
Usage example:
In Orb-Slam2's main.cc, this code will save and load a map:
...
Construct the osmap object, can be right after SLAM construction. You only need one instance to load and save as many maps you want. Osmap osmap = ORB_SLAM2::Osmap(SLAM); ... Whe you already has a map to save osmap.mapSave("myFirstMap"); // "myFirstMap" or "myFirstMap.yaml", same thing ... Now you want to load the map osmap.mapLoad("myFirstMap.yaml");
In Linux, zenity comes handy as dialog to get file name to load and save map. You need zenity installed, this runs the command line:
char cstringfilename[1024];
Load dialog FILE *f = popen("zenity --file-selection", "r"); fgets(cstringfilename, 1024, f);
Save dialog FILE *f = popen("zenity --file-selection --save --confirm-overwrite --filename=mapa", "r"); fgets(cstringfilename, 1024, f);
You probably want to go to localization only mode (tracking only, no mapping) right before saving or loading. To do that:
SLAM->ActivateLocalizationMode();
User also can control this with the button "Localization mode" in viewer.
All the options available.
Options are persetted into options property. Default is zero. Options are activated with 1.
To test an option:
if(options[ORB_SLAM2::Osmap::ONLY_MAPPOINTS_FEATURES])...
To set an option:
options.set(ORB_SLAM2::Osmap::ONLY_MAPPOINTS_FEATURES);
Available options are documented in enum Options. New options can be added in the future, but the order of existing options must be keeped. So, new options must be added to the end of enum.
Time stamp is not optional because it always occupy place in protocol buffers, as all numeric fields. Defaults to 0.
Options are saved in the map file. NO_SET_BAD is the only option one can have insterest to set before loading, while not set in the file.
ORB_SLAM2::Osmap::Osmap | ( | System & | _system | ) |
Only constructor, the only way to set the orb-slam2 map.
void ORB_SLAM2::Osmap::clearVectors | ( | ) |
Clear temporary vectors.
Only clears the vectors, not the objects its pointer elements pointed to (keyframes, mappoints, K matrices), because they belong to the map.
int ORB_SLAM2::Osmap::countFeatures | ( | ) |
Count the number of features in vectorKeyFrames.
Invoked by mapSave to decide to use or not delimited form of feature file.
void ORB_SLAM2::Osmap::depurate | ( | ) |
Irons keyframes and mappoints sets in map, before save.
Tests all keyframes in MapPoints.mObservations and mappoints in KeyFrames.mvpMapPoints, checking they are:
Those who not pass this check are eliminated, avoiding serialization of elements not belonging to the map.
This depuration affects (improves) the actual map in memory.
Invoked by mapSave.
void ORB_SLAM2::Osmap::deserialize | ( | const SerializedK & | , |
Mat & | k | ||
) |
Reconstruct the intrinsic camera matrix K from protocol buffer message.
All 4 fields are required.
serializedK | Protocol buffers source message. |
k | Destination to be reconstruted. K matrix, also known as calibration matrix, instrinsic matrix and camera matrix, 3x3 float Mat, usually from KeyFrame::mK. |
void ORB_SLAM2::Osmap::deserialize | ( | const SerializedKArray & | serializedKArray, |
vector< Mat *> & | vK | ||
) |
Reconstruct an array of camera calibration matrix K.
The array should be retrieved from keyframes analisys. Usually there is only one K common to all keyframes.
serializedKArray | The serialization destination object. |
vK | The vector of K matrices to serialize. Usually Osmap::vectorK member. |
void ORB_SLAM2::Osmap::deserialize | ( | const SerializedDescriptor & | , |
Mat & | |||
) |
Reconstruct a descriptor, an 1x32 uchar Mat (256 bits).
Exactly 8 int required.
void ORB_SLAM2::Osmap::deserialize | ( | const SerializedPose & | , |
Mat & | |||
) |
Reconstruct a 4x4 float Mat representing a pose in homogeneous coordinates.
Exactly 12 float required.
void ORB_SLAM2::Osmap::deserialize | ( | const SerializedPosition & | , |
Mat & | |||
) |
Reconstructs 3D mappoint position in a 3x1 float Mat.
All 3 fields required.
void ORB_SLAM2::Osmap::deserialize | ( | const SerializedKeypoint & | , |
KeyPoint & | |||
) |
Reconstructs a KeyPoint.
All 4 fields required.
OsmapMapPoint* ORB_SLAM2::Osmap::deserialize | ( | const SerializedMappoint & | serializedMappoint | ) |
Creates and fills a MapPoint from optional message fields.
It doesn't perform MapPoint initialization. This should be done after deserialization.
serializedMappoint | Protocol buffers source message. |
int ORB_SLAM2::Osmap::deserialize | ( | const SerializedMappointArray & | , |
vector< OsmapMapPoint *> & | |||
) |
Retrieves MapPoints from an array, and append them to the map.
serializedMapPointArray | message to set up. Data goes to the output iterator. |
output | iterator on the destination container. Usually std::inserter(mspMapPoints, mspMapPoints.end()). For vector it can be a Back inserter iterator where output is placed in arrival order. Usually mspMapPoints.begin(). About set back_inserter: https://stackoverflow.com/questions/908272/stdback-inserter-for-a-stdset |
OsmapKeyFrame* ORB_SLAM2::Osmap::deserialize | ( | const SerializedKeyframe & | ) |
Reconstructs a KeyFrame from optional fields.
It doesn't perform KeyFrame initialization. This should be done after deserialization.
int ORB_SLAM2::Osmap::deserialize | ( | const SerializedKeyframeArray & | , |
vector< OsmapKeyFrame *> & | |||
) |
Retrieves MapPoints from an array, and append them to the map.
serializedMapPointArray | message to set up. Data goes from map. |
OsmapKeyFrame* ORB_SLAM2::Osmap::deserialize | ( | const SerializedKeyframeFeatures & | ) |
Retrieves all features belonging to one keyframe.
First it takes the required keyframe_id field, and look in map for the keyframe with that id. Hence, keyframes must be already deserialized in map.
Puts all KeyPoints, MapPoints* and descriptors in their respective containters of the provided KeyFrame.
SerializedKeyframeFeatures | Object to be deserialized. |
int ORB_SLAM2::Osmap::deserialize | ( | const SerializedKeyframeFeaturesArray & | ) |
Retrieves all keyframe's features from the specified serialization object to vectorKeyframe.
int ORB_SLAM2::Osmap::featuresLoad | ( | string | filename | ) |
Load the content of a "map.features" file and applies it to vectorKeyFrames.
filename | full name of the file to open. |
int ORB_SLAM2::Osmap::featuresSave | ( | string | filename | ) |
Save KeyFrane's features of vectorKeyFrames to file, usually "map.features".
filename | full name of the file to be created and saved. |
OsmapKeyFrame* ORB_SLAM2::Osmap::getKeyFrame | ( | unsigned int | id | ) |
Looks for a KeyFrame id in the map.
Keyframes are usually stored in ascending id order. This function will be more probably called in the same way, so it is optimized for this expected behaviour. It uses itLastKF.
id | Id of the KeyFrame to look for. |
void ORB_SLAM2::Osmap::getKeyFramesFromMap | ( | ) |
Populate vectorKeyFrames with MapPoints from Map.mspKeyFrames.
This is done as the first step to save keyframes.
MapPoint* ORB_SLAM2::Osmap::getMapPoint | ( | unsigned int | id | ) |
Looks for a mappoint by its id in the map.
id | Id of the MapPoint to look for. |
void ORB_SLAM2::Osmap::getMapPointsFromMap | ( | ) |
Populate vectorMapPoints with MapPoints from Map.mspMapPoints.
This is done as the first step to save mappoints.
void ORB_SLAM2::Osmap::getVectorKFromKeyframes | ( | ) |
Traverse map's keyframes looking for different K matrices, and stores them into vectorK.
It also populates keyframeid2vectork.
int ORB_SLAM2::Osmap::KeyFramesLoad | ( | string | filename | ) |
Load the content of a "map.keyframes" file to vectorKeyFrames.
filename | full name of the file to open. |
int ORB_SLAM2::Osmap::KeyFramesSave | ( | string | filename | ) |
Save the content of vectorKeyFrames to file like "map.keyframes".
Need
filename | full name of the file to be created and saved. |
This method ignores option NO_KEYFRAMES_FILE
|
inline |
|
inline |
void ORB_SLAM2::Osmap::mapLoad | ( | string | yamlFilename, |
bool | noSetBad = false , |
||
bool | pauseThreads = true |
||
) |
Loads the map from a set of files in the folder whose name is provided as an argument.
This is the entry point to load a map. This method uses the Osmap object to serialize the map to files.
yamlFilename | file name of .yaml file (including .yaml extension) describing a map. |
noSetBad | true to avoid bad mappoints and keyframes deletion on rebuilding after loading. |
stopTrheads | Serializing needs some orb-slam2 threads to be paused. true (the default value) signals mapLoad to pause the threads before saving, and resume them after saving. false when threads are paused and resumed by other means. |
Only these properties are read from yaml:
Before calling this method, threads must be paused.
int ORB_SLAM2::Osmap::MapPointsLoad | ( | string | filename | ) |
Load the content of a "map.mappoints" file to vectorMapPoints.
filename | full name of the file to open. |
int ORB_SLAM2::Osmap::MapPointsSave | ( | string | filename | ) |
Save the content of vectorMapPoints to file like "map.mappoints".
filename | full name of the file to be created and saved. |
This method ignores option NO_MAPPOINTS_FILE If not K_IN_KEYFRAME option (the default), vectorK must be populated (see getVectorKFromKeyframes) prior invocation of this method.
void ORB_SLAM2::Osmap::mapSave | ( | string | basefilename, |
bool | pauseThreads = true |
||
) |
Saves the map to a set of files in the actual directory, with the extensionless name provided as the only argument and different extensions for each file.
If filename has .yaml extension, mapSave will remove it to get the actual basefilename. Any existing file is rewritten without warning. This is the entry point to save a map. This method uses the Osmap object to serialize the map to files. Before calling this method:
basefilename | File name without extenion or with .yaml extension. Many files will be created with this basefilename and different extensions. |
pauseThreads | Serializing needs some orb-slam2 threads to be paused. true (the default value) signals mapSave to pause the threads before saving, and resume them after saving. false when threads are paused and resumed by other means. |
MapSave copy map's mappoints and keyframes sets to vectorMapPoints and vectorKeyFrames and sort them, to save objects in ascending id order. MapLoad doesn't use those vector.
If features number exceed an arbitrary maximum, in order to avoid size related protocol buffer problems, mapSave limit the size of protocol buffer's messages saving features file in delimited form, using Kendon Varda writeDelimitedTo function.
void ORB_SLAM2::Osmap::parsePath | ( | const string & | path, |
string * | filename = NULL , |
||
string * | pathDirectory = NULL |
||
) |
Utility for separating path and filename from a full path.
filename | Output string, filename found in path, '' if no file in the path. Can be NULL. |
pathDirectory | Output string with the directory's path, '' if none. Can be NULL. |
bool ORB_SLAM2::Osmap::readDelimitedFrom | ( | google::protobuf::io::ZeroCopyInputStream * | rawInput, |
google::protobuf::MessageLite * | message | ||
) |
Reads a message to a vector file.
A vector file is an array of messages.
message | |
rawOutput | input stream, readable source file. |
Kendon Varda code to serialize many messages in one file, from https://stackoverflow.com/questions/2340730/are-there-c-equivalents-for-the-protocol-buffers-delimited-i-o-functions-in-ja
void ORB_SLAM2::Osmap::rebuild | ( | bool | noSetBad = false | ) |
Rebuilding takes place right after loading a map from files, before the map is copied to ORB-SLAM2' sets.
Works on Osmap::vectorMapPoints and Osmap::vectorKeyFrames. After rebuilding, the elements in these vector should be copied to the map sets.
rebuild() needs KeyPoints and MapPoints to be initialized with a lot of properties set, as the default constructors for OsmapKeyFrame and OsmapMapPoint show.
noSetBad | true to avoid bad mappoints and keyframes deletion on rebuilding. |
This method checks Osmap::verbose property to produce console output for debugging purposes.
How rebuild works:
void ORB_SLAM2::Osmap::serialize | ( | const Mat & | k, |
SerializedK * | serializedK | ||
) |
Serialize provided intrinsic camera matrix K to the protocol buffer message.
All 4 fields required.
k | Source to be serialized. K matrix, also known as calibration matrix, instrinsic matrix and camera matrix, 3x3 float Mat, usually from KeyFrame::mK. |
serializedK | Protocol buffers destination message to be serialized. |
void ORB_SLAM2::Osmap::serialize | ( | const vector< Mat *> & | vK, |
SerializedKArray & | serializedKArray | ||
) |
Serialize an array of camera calibration matrix K.
The array should be retrieved from keyframes analisys. Usually there is only one K common to all keyframes.
vK | The vector of K matrices to serialize. |
serializedKArray | The serialization destination object. |
void ORB_SLAM2::Osmap::serialize | ( | const Mat & | , |
SerializedDescriptor * | |||
) |
Serializes a descriptor, an 1x32 uchar Mat (256 bits).
Protocol Buffers doesn't have a Byte type, so it's serialized to 8 int. Exactly 8 int required.
void ORB_SLAM2::Osmap::serialize | ( | const Mat & | , |
SerializedPose * | |||
) |
Serialize a 4x4 float Mat representing a pose in homogeneous coordinates.
Exactly 12 float required.
void ORB_SLAM2::Osmap::serialize | ( | const Mat & | , |
SerializedPosition * | |||
) |
Serialize 3D mappoint position, a 3x1 float Mat.
All 3 fields required.
void ORB_SLAM2::Osmap::serialize | ( | const KeyPoint & | , |
SerializedKeypoint * | |||
) |
Serialize 4 properties of a KeyPoint.
All 4 fields required.
void ORB_SLAM2::Osmap::serialize | ( | const OsmapMapPoint & | , |
SerializedMappoint * | |||
) |
Serializes a MapPoint, according to options.
int ORB_SLAM2::Osmap::serialize | ( | const vector< OsmapMapPoint *> & | , |
SerializedMappointArray & | |||
) |
Serialized array of MapPoints.
The serialized message can be saved to an exclusive file, or be appended to a multiobject file.
start | Inclusive begining of the range of MapPoints to be serialized. Usually map.mspMapPoints.begin(). |
end | Exclusive end of the range of MapPoints to be serialized. Usually map.mspMapPoints.end(). |
serializedMapPointArray | message to set up. Data comes from the range iterated. |
void ORB_SLAM2::Osmap::serialize | ( | const OsmapKeyFrame & | , |
SerializedKeyframe * | |||
) |
Serialize a KeyFrame.
Serialization and deserialization assume KeyFrames are processed in ascending id order.
int ORB_SLAM2::Osmap::serialize | ( | const vector< OsmapKeyFrame *> & | , |
SerializedKeyframeArray & | |||
) |
Serialized array of KeyFrames.
This can make a file, or be appended to a multiobject file. KeyFrames will be serialized in ascending id order.
serializedKeyFrameArray | message to set up. Data comes from map. |
void ORB_SLAM2::Osmap::serialize | ( | const OsmapKeyFrame & | , |
SerializedKeyframeFeatures * | |||
) |
Serialize all features observed by a KeyFrame.
pKF | KeyFrame owner of the feature. The features will be stored in this KeyFrame containers. |
SerializedKeyframeFeatures | Message destination of serialization. |
int ORB_SLAM2::Osmap::serialize | ( | const vector< OsmapKeyFrame *> & | vKF, |
SerializedKeyframeFeaturesArray & | serializedKeyframeFeaturesArray | ||
) |
Serialize all keyframe's features from provided keyframes container, to the specified serialization object.
vKF | vector of KeyFrames to save, usually vectorKeyFrames member order by mnId. |
serializedKeyframeFeaturesArray | output serialization object. |
void ORB_SLAM2::Osmap::setKeyFramesToMap | ( | ) |
Populate Map.mspKeyFrames with MapPoints from vectorKeyFrames.
This is done after loading keyframes.
void ORB_SLAM2::Osmap::setMapPointsToMap | ( | ) |
Populate Map.mspMapPoints with MapPoints from vectorMapPoints.
This is done after loading mappoints.
bool ORB_SLAM2::Osmap::writeDelimitedTo | ( | const google::protobuf::MessageLite & | message, |
google::protobuf::io::ZeroCopyOutputStream * | rawOutput | ||
) |
Writes a message to a vector file.
A vector file is an array of messages. In order to possibilitate deserialization, the message size is prepended to the message.
message | |
rawOutput | output stream, writable destination file. |
Kendon Varda code to serialize many messages in one file, from https://stackoverflow.com/questions/2340730/are-there-c-equivalents-for-the-protocol-buffers-delimited-i-o-functions-in-ja
When writing to a file, *rawOutput object must be deleted before closing the file, to ensure flushing.
Frame& ORB_SLAM2::Osmap::currentFrame |
Any frame, to copy configuration values from.
Constructor takes currentFrame from Tracker.
KeyFrameDatabase& ORB_SLAM2::Osmap::keyFrameDatabase |
Database of keyframes to be build after loading.
vector<unsigned int> ORB_SLAM2::Osmap::keyframeid2vectorkIdx |
For each index KeyFrame.mnId the value returned is an index to vectorK.
The later is the index saved in each keyframe as k. It is populated only by getVectorKFromKeyframes, and consumed only while saving the map, during keyframe serialization.
OsmapMap& ORB_SLAM2::Osmap::map |
ORB-SLAM2 map to be serialized.
bitset<32> ORB_SLAM2::Osmap::options = 0 |
Set of chosen options for serializing.
User must set options prior to saving a map. Loading a map should reflect in this property the saved map options.
KeyFrame* ORB_SLAM2::Osmap::pRefKF = NULL |
This keyframe is a vehicle to MapPoint construction, which need a pRefKF as argument.
MapPoint construction occurs only while loading. pRefKF can be any KeyFrame. mapLoad can be invoked when there is no map in orbslam2, which means there is no keyframe in it. So Osmap constructs one. But constructed a KeyFrame requires a populated Frame (Osmap uses tracker.currentFrame), and it isn't populated with data before first tracking loop. This means pRefKF can't be constructed in Osmap constructor. pRefKF keyframe is constructed on the first map load, more specifically right before mappoints are loaded.
System& ORB_SLAM2::Osmap::system |
System, needed to populate new keyframes after construction on deserialization, with some configuration values.
vector<Mat const *> ORB_SLAM2::Osmap::vectorK |
Usually there is only one common matrix K for all KeyFrames in the entire map, there can be more, but there won't be as many K as KeyFrames.
This vector temporarily store different K for serialization and deserialization. This avoids serializing one K per KeyFrame. This vector is consumed in keyframe deserialization.
vector<OsmapKeyFrame*> ORB_SLAM2::Osmap::vectorKeyFrames |
Buffer where map's keyframes are stored in ascending id order, to save them to file in this order.
This vector is set in mapSave, and it's left ontouched for user interest.
vector<OsmapMapPoint*> ORB_SLAM2::Osmap::vectorMapPoints |
Buffer where map's mappoints are stored in ascending id order, to save them to file in this order.
This vector is set in mapSave, and it's left ontouched for user interest. This vector is consumed in serialize
bool ORB_SLAM2::Osmap::verbose = false |
Whether or not print on console info for debuging.