private void convertToOutput ( View origin ) { structure = new SceneStructureMetric ( false ) ; observations = new SceneObservations ( viewsAdded . size ( ) ) ; // TODO can this be simplified? int idx = 0 ; for ( String key : graph . cameras . keySet ( ) ) { cameraToIndex . put ( key , idx ++ ) ; } structure . initialize ( cameraToIndex . size ( ) , viewsAdded . size ( ) , graph . features3D . size ( ) ) ; for ( String key : graph . cameras . keySet ( ) ) { int i = cameraToIndex . get ( key ) ; structure . setCamera ( i , true , graph . cameras . get ( key ) . pinhole ) ; } // look up table from old index to new index int viewOldToView [ ] = new int [ graph . nodes . size ( ) ] ; Arrays . fill ( viewOldToView , - 1 ) ; for ( int i = 0 ; i < viewsAdded . size ( ) ; i ++ ) { viewOldToView [ graph . nodes . indexOf ( viewsAdded . get ( i ) ) ] = i ; } for ( int i = 0 ; i < viewsAdded . size ( ) ; i ++ ) { View v = viewsAdded . get ( i ) ; int cameraIndex = cameraToIndex . get ( v . camera . camera ) ; structure . setView ( i , v == origin , v . viewToWorld . invert ( null ) ) ; structure . connectViewToCamera ( i , cameraIndex ) ; } for ( int indexPoint = 0 ; indexPoint < graph . features3D . size ( ) ; indexPoint ++ ) { Feature3D f = graph . features3D . get ( indexPoint ) ; structure . setPoint ( indexPoint , f . worldPt . x , f . worldPt . y , f . worldPt . z ) ; if ( f . views . size ( ) != f . obsIdx . size ) throw new RuntimeException ( "BUG!" ) ; for ( int j = 0 ; j < f . views . size ( ) ; j ++ ) { View view = f . views . get ( j ) ; int viewIndex = viewOldToView [ view . index ] ; structure . connectPointToView ( indexPoint , viewIndex ) ; Point2D_F64 pixel = viewsAdded . get ( viewIndex ) . observationPixels . get ( f . obsIdx . get ( j ) ) ; observations . getView ( viewIndex ) . add ( indexPoint , ( float ) ( pixel . x ) , ( float ) ( pixel . y ) ) ; } } }
Converts the internal data structures into the output format for bundle adjustment . Camera models are omitted since they are not available