@@ -70,7 +70,8 @@ void ObservationsEntity::update(const IndexT& viewId, const QVariantMap& viewer2
7070 size_t rcIndexCount = 0 ;
7171
7272 const auto & it = _landmarksPerView.find (viewId);
73- if (it != _landmarksPerView.end ())
73+ const auto & setValidViewIds = _sfmData.getValidViews ();
74+ if (it != _landmarksPerView.end () && setValidViewIds.find (viewId) != setValidViewIds.end ())
7475 {
7576 // 2D view bounds
7677 const float & scale = viewer2DInfo[" scale" ].toFloat ();
@@ -137,7 +138,7 @@ void ObservationsEntity::fillBytesData(QByteArray& positionData)
137138 // -------------- read position data ----------------------
138139
139140 const auto & nLandmarks = _sfmData.getLandmarks ().size ();
140- const auto & nViews = _sfmData.getViews ().size ();
141+ const auto & nViews = _sfmData.getValidViews ().size ();
141142 positionData.resize (static_cast <int >((nLandmarks + nViews) * 3 * sizeof (float )));
142143 size_t nObservations = 0 ;
143144 // copy positions of landmarks
@@ -160,10 +161,10 @@ void ObservationsEntity::fillBytesData(QByteArray& positionData)
160161 uint viewPosIdx = static_cast <uint>(nLandmarks);
161162 // view camera positions are added after landmarks'
162163 positionsIt += 3 * sizeof (float ) * nLandmarks;
163- for (const auto & viewIt : _sfmData.getViews ())
164+ for (const auto & viewId : _sfmData.getValidViews ())
164165 {
165- _viewId2vertexPos[viewIt. first ] = viewPosIdx++;
166- aliceVision::Vec3f center = _sfmData.getPose (*viewIt. second ).getTransform ().center ().cast <float >();
166+ _viewId2vertexPos[viewId ] = viewPosIdx++;
167+ aliceVision::Vec3f center = _sfmData.getPose (_sfmData. getView (viewId) ).getTransform ().center ().cast <float >();
167168 // graphics to open-gl coordinates system
168169 center.z () *= -1 ;
169170 center.y () *= -1 ;
@@ -188,7 +189,15 @@ void ObservationsEntity::fillBytesData(QByteArray& positionData)
188189 for (const auto & obsIt : landIt.second .observations )
189190 {
190191 *indices++ = landIt.first ;
191- *indices++ = _viewId2vertexPos.at (obsIt.first );
192+ const auto & pos = _viewId2vertexPos.find (obsIt.first );
193+ if (pos != _viewId2vertexPos.end ())
194+ {
195+ *indices++ = pos->second ;
196+ }
197+ else
198+ {
199+ *indices++ = landIt.first ;
200+ }
192201 ++obsGlobalIndex;
193202 }
194203 }
0 commit comments