| 236 | } // namespace |
| 237 | |
| 238 | IndexT getReferenceViewId(const sfmData::SfMData& sfmData, const std::string& transform) |
| 239 | { |
| 240 | IndexT refViewId; |
| 241 | try |
| 242 | { |
| 243 | refViewId = sfm::getViewIdFromExpression(sfmData, transform); |
| 244 | if (!sfmData.isPoseAndIntrinsicDefined(refViewId)) |
| 245 | { |
| 246 | return UndefinedIndexT; |
| 247 | } |
| 248 | } |
| 249 | catch (...) |
| 250 | { |
| 251 | refViewId = UndefinedIndexT; |
| 252 | } |
| 253 | |
| 254 | // Default to select the view given timestamp |
| 255 | if (refViewId == UndefinedIndexT) |
| 256 | { |
| 257 | // Sort views with poses per timestamps |
| 258 | std::vector<std::pair<int64_t, IndexT>> sorted_views; |
| 259 | for (auto v : sfmData.getViews()) |
| 260 | { |
| 261 | if (!sfmData.isPoseAndIntrinsicDefined(v.first)) |
| 262 | { |
| 263 | continue; |
| 264 | } |
| 265 | |
| 266 | int64_t t = v.second->getImage().getMetadataDateTimestamp(); |
| 267 | sorted_views.push_back(std::make_pair(t, v.first)); |
| 268 | } |
| 269 | std::sort(sorted_views.begin(), sorted_views.end()); |
| 270 | |
| 271 | if (sorted_views.size() == 0) |
| 272 | { |
| 273 | return UndefinedIndexT; |
| 274 | } |
| 275 | |
| 276 | // Get the view which was taken at the middle of the sequence |
| 277 | int median = sorted_views.size() / 2; |
| 278 | refViewId = sorted_views[sorted_views.size() - 1].second; |
| 279 | } |
| 280 | |
| 281 | return refViewId; |
| 282 | } |
| 283 | |
| 284 | bool getPoseFromJson(const std::string & lineUpFilename, Eigen::Matrix4d & T, IndexT & frameId) |
| 285 | { |
no test coverage detected