When the code calls FlannBasedMatcher::train(),the index of FlannBasedMatcher will be built by
flannIndex = new flann::Index( mergedDescriptors.getDescriptors(), *indexParams );
The code
if( flannIndex.empty() || mergedDescriptors.size() < addedDescCount )
is to check whether the index of FlannBasedMatcher has already been built before.If index has been built before,the train() function will skip the process of building index to save time.