MCPcopy Create free account
hub / github.com/alicevision/AliceVision / getReferenceViewId

Function getReferenceViewId

src/software/utils/main_sfmTransform.cpp:238–282  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

236} // namespace
237
238IndexT 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
284bool getPoseFromJson(const std::string & lineUpFilename, Eigen::Matrix4d & T, IndexT & frameId)
285{

Callers 1

aliceVision_mainFunction · 0.85

Calls 7

getViewIdFromExpressionFunction · 0.85
push_backMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected