The following code sample assumes that you want to find similar images of a car from several media collections. In this example, we:
open two disk-based collections
search each of the collections
combine the results of the two searches
sort the combined results
// create
the two MediaCollection objects and open the two collections
MediaCollection
mc01 = Eve.newMediaCollection();
MediaCollection
mc02 = Eve.newMediaCollection();
mc01.open(
directoryPath1 );
mc02.open( directoryPath2 );
// read
in a media object containing the car picture
MediaObject
source = Eve.newMediaObject();
source.loadFrom ("\\images\\carpicture.jpeg.edf");
// set
up a 50-50 color and region search
SearchParameters
parameters = Eve.newSearchParameters();
parameters.setSearch(Eve.COLOR,true,0.5);
parameters.setSearch(Eve.REGION,true,0.5);
// perform
the two searches using the same source object and parameters
SearchResults
results1[] = mc01.search(source,parameters);
SearchResults results2[] = mc02.search(source,parameters);
// add
the results of the two searches together
SearchResults
worker = Eve.newSearchResults();
SearchResults finalResults[] = worker.append(results1,results2);
// sort
the combined results by similarity
finalResults = worker.similaritySort(finalResults);
// truncate
the results after the first 32 entries
// (results
are sorted in descending order of similarity)
finalResults
= worker.chop(finalResults,32);
At this point you have a single array with (possible) entries
from each collection. To determine which collection generated a particular
result, use the SearchResults.getCollectionName()
method.