A single servlet, VisualSearchServlet, uses three classes to dynamically build new HTML document pages based on search results: TextSearch, VisualSearch, and SearchParameter. Both TextSearch and VisualSearch are derived from an abstract base class, SearchEngine.
creates an instance of MediaCollection
and uses its open()
method to load all images stored in the corresponding image database.
The value supplied to the path argument in the open()
method determines what images are loaded.
uses MediaCollection.getKeys
to retrieve a list of the keys to the MediaObjects in the MediaCollection
category.
uses MediaCollection.getMediaObject to get a list of all the MediaObjects in the opened image database. Each retrieved MediaObject instance can be used as input to MediaCollection.search to find MediaObjects representing visually similar images.
String imagepath = "c:\\com\\evisionglobal\\eve\\sample\\categories\\Clothes";
MediaCollection mediaCollection = (MediaCollection) Eve.newMediaCollection(); mediaCollection.open( imagepath ); long[] keys = mediaCollection.getKeys(); MediaObject[] mObjects = mediaCollection.getMediaObject( keys ); Int colorPercent = 100,shapePercent=0; texturePercent=0;objectPercent=0; for ( int i = 0; i < mObjects.length(); ++i ) { SearchParameters sp = (SearchParameters) Eve.newSearchParameters(); sp.setSearch(Eve.COLOR, true, (float)(colorPercent/100)); sp.setSearch(Eve.SHAPE, true, (float)(shapePercent/100)); sp.setSearch(Eve.TEXTURE, true, (float)(texturePercent/100)); sp.setSearch(Eve.REGION, true, (float)(objectPercent/100)); MediaObject mo = mediaCollection.getMediaObject( mObject[i].getKey() ); SearchResults[] results = mediaCollection.search(mo, sp); } |