DEPRECATED: This function was used for interpolation-based initialization.
| 1184 | |
| 1185 | // DEPRECATED: This function was used for interpolation-based initialization. |
| 1186 | void Estimator::ProcessIntermediateFrames() { |
| 1187 | if (m_frame_window.size() < 3) { |
| 1188 | return; // No intermediate frames |
| 1189 | } |
| 1190 | |
| 1191 | auto first_kf = m_frame_window.front(); |
| 1192 | auto last_kf = m_frame_window.back(); |
| 1193 | |
| 1194 | Eigen::Matrix4f T_first = first_kf->GetTwb(); |
| 1195 | Eigen::Matrix4f T_last = last_kf->GetTwb(); |
| 1196 | |
| 1197 | // Extract rotation and translation |
| 1198 | Eigen::Matrix3f R_first = T_first.block<3, 3>(0, 0); |
| 1199 | Eigen::Vector3f t_first = T_first.block<3, 1>(0, 3); |
| 1200 | Eigen::Matrix3f R_last = T_last.block<3, 3>(0, 0); |
| 1201 | Eigen::Vector3f t_last = T_last.block<3, 1>(0, 3); |
| 1202 | |
| 1203 | // Compute relative rotation using Rodrigues |
| 1204 | Eigen::Matrix3f R_rel = R_first.transpose() * R_last; |
| 1205 | Eigen::AngleAxisf aa(R_rel); |
| 1206 | Eigen::Vector3f axis = aa.axis(); |
| 1207 | float angle = aa.angle(); |
| 1208 | |
| 1209 | int n_frames = static_cast<int>(m_frame_window.size()); |
| 1210 | |
| 1211 | LOG_DEBUG("Processing {} intermediate frames to create keyframes...", n_frames - 2); |
| 1212 | |
| 1213 | // Build global feature ID to MapPoint map from first_kf and last_kf (the two frames with triangulated MapPoints) |
| 1214 | std::unordered_map<int, std::shared_ptr<MapPoint>> feature_to_mappoint; |
| 1215 | |
| 1216 | // Collect from first keyframe |
| 1217 | const auto& first_features = first_kf->GetFeatures(); |
| 1218 | for (size_t j = 0; j < first_features.size(); ++j) { |
| 1219 | auto mp = first_kf->GetMapPoint(static_cast<int>(j)); |
| 1220 | if (mp && !mp->IsBad()) { |
| 1221 | feature_to_mappoint[first_features[j]->GetFeatureId()] = mp; |
| 1222 | } |
| 1223 | } |
| 1224 | |
| 1225 | // Collect from last keyframe (may add new MapPoints or override) |
| 1226 | const auto& last_features = last_kf->GetFeatures(); |
| 1227 | for (size_t j = 0; j < last_features.size(); ++j) { |
| 1228 | auto mp = last_kf->GetMapPoint(static_cast<int>(j)); |
| 1229 | if (mp && !mp->IsBad()) { |
| 1230 | int feat_id = last_features[j]->GetFeatureId(); |
| 1231 | if (feature_to_mappoint.find(feat_id) == feature_to_mappoint.end()) { |
| 1232 | feature_to_mappoint[feat_id] = mp; |
| 1233 | } |
| 1234 | } |
| 1235 | } |
| 1236 | |
| 1237 | LOG_DEBUG("Found {} unique MapPoints from first/last keyframes for observation propagation", |
| 1238 | feature_to_mappoint.size()); |
| 1239 | |
| 1240 | // Process intermediate frames (skip first and last which already have poses) |
| 1241 | for (int i = 1; i < n_frames - 1; ++i) { |
| 1242 | auto& frame = m_frame_window[i]; |
| 1243 |
nothing calls this directly
no test coverage detected