1. A computer implemented method for generating an environment map of an input video sequence, the method comprising: identifying a plurality of keyframes of the input video sequence and adding the identified keyframes into an initial environment map, the keyframes being identified based on video features associated with a plurality of video frames of the input video sequence, and the initial environment map being represented by a keyframe pose graph; enforcing local metric properties of a group of identified keyframes of the initial environment map; optimizing the initial environment map based on global metric properties of the identified keyframes, wherein optimizing the initial environment map comprises: clustering the identified keyframes into a plurality of disjoint sets of keyframes based on geodesic distance information of the keyframe pose graph, a disjoint set of keyframes representing a segment of keyframes; for each segment of keyframes, enforcing local metric properties of the keyframes in the segment; applying global segment optimization to the segments of keyframes, comprising: embedding the segments of keyframes and landmarks associated with the keyframes of the segments into a metric space; and updating projected three-dimensional coordinates of the landmarks to the associated keyframes based on the metric constraints of the landmarks and keyframes; and generating an output environment map based on the optimization.