public boolean pruneViews ( int count ) { List < SceneStructureProjective . View > remainingS = new ArrayList <> ( ) ; List < SceneObservations . View > remainingO = new ArrayList <> ( ) ; // count number of observations in each view int counts [ ] = new int [ structure . views . length ] ; for ( int pointIdx = 0 ; pointIdx < structure . points . length ; pointIdx ++ ) { GrowQueue_I32 viewsIn = structure . points [ pointIdx ] . views ; for ( int i = 0 ; i < viewsIn . size ; i ++ ) { counts [ viewsIn . get ( i ) ] ++ ; } } // TODO Add a list of points to each view reducing number of iterations through all the points // mark views with too few points for removal for ( int viewIdx = 0 ; viewIdx < structure . views . length ; viewIdx ++ ) { if ( counts [ viewIdx ] > count ) { remainingS . add ( structure . views [ viewIdx ] ) ; remainingO . add ( observations . views [ viewIdx ] ) ; } else { structure . views [ viewIdx ] . width = - 2 ; } } // remove the view from points for ( int pointIdx = 0 ; pointIdx < structure . points . length ; pointIdx ++ ) { GrowQueue_I32 viewsIn = structure . points [ pointIdx ] . views ; for ( int i = viewsIn . size - 1 ; i >= 0 ; i -- ) { SceneStructureProjective . View v = structure . views [ viewsIn . get ( i ) ] ; if ( v . width == - 2 ) { viewsIn . remove ( i ) ; } } } if ( structure . views . length == remainingS . size ( ) ) { return false ; } // Create new arrays with the views that were not pruned structure . views = new SceneStructureProjective . View [ remainingS . size ( ) ] ; observations . views = new SceneObservations . View [ remainingO . size ( ) ] ; for ( int i = 0 ; i < structure . views . length ; i ++ ) { structure . views [ i ] = remainingS . get ( i ) ; observations . views [ i ] = remainingO . get ( i ) ; } return true ; }
Removes views with less than count features visible . Observations of features in removed views are also removed . Features are not automatically removed even if there are zero observations of them .