public static void main ( String args [ ] ) throws Exception { String imageFolder = "C:/images/" ; String imagFilename = "test.jpg" ; String [ ] codebookFiles = { "C:/codebook1.csv" , "C:/codebook2.csv" , "C:/codebook3.csv" , "C:/codebook4.csv" } ; int [ ] numCentroids = { 64 , 64 , 64 , 64 } ; String pcaFilename = "C:/pca.txt" ; int initialLength = numCentroids . length * numCentroids [ 0 ] * AbstractFeatureExtractor . SURFLength ; int targetLength = 128 ; ImageVectorization imvec = new ImageVectorization ( imageFolder , imagFilename , targetLength , 512 * 384 ) ; ImageVectorization . setFeatureExtractor ( new SURFExtractor ( ) ) ; double [ ] [ ] [ ] codebooks = AbstractFeatureAggregator . readQuantizers ( codebookFiles , numCentroids , AbstractFeatureExtractor . SURFLength ) ; ImageVectorization . setVladAggregator ( new VladAggregatorMultipleVocabularies ( codebooks ) ) ; if ( targetLength < initialLength ) { PCA pca = new PCA ( targetLength , 1 , initialLength , true ) ; pca . loadPCAFromFile ( pcaFilename ) ; ImageVectorization . setPcaProjector ( pca ) ; } imvec . setDebug ( true ) ; ImageVectorizationResult imvr = imvec . call ( ) ; System . out . println ( imvr . getImageName ( ) + ": " + Arrays . toString ( imvr . getImageVector ( ) ) ) ; }
Example of SURF extraction multiVLAD aggregation and PCA - projection of a single image using this class .