Sasha
Sasha

Reputation: 29

How do I use Java to search an image for a specific image/logo/sign, etc?

I'm creating a small game for my uncle (who's running for some political office), a "Find the Sign" game, where users are presented an image, and they search and click on the sign in the picture. Like, the user is shown a picture of a building, like a store or something, and they need to click on the campaign sign that's been posted in the window. There are different kinds of signs, but they all have the same logo in common.

Upvotes: 0

Views: 507

Answers (1)

filip-fku
filip-fku

Reputation: 3265

If you truly want to go down the path of image recognition there are well known algorithms.. try Googling around for some, but a few you could look at are SIFT of SURF for instance. Getting something working might take quite an effort though - maybe you could look for a library implementation.

However in your case it seems like that's a bit overkill. If it's a small game as you say, I'm guessing you will be presenting a not too large number of images. You can just annotate each image with the coordinates of the logo you're looking for, say with a simple rectangle, and check if the user clicked within that pre-determined region. This is a small manual overhead for each image - probably not much larger than what you would already do manually to package each into your application/database.

For example, a simple hard coded map might do. You can probably think of a better approach.

Map<String,Rectangle> mapLogoLocationToImage = new HashMap<String,Rectangle>();
mapLogoLocationToImage.put("post_office.png",new Rectangle(1,1,5,5);
mapLogoLocationToImage.put("office_block.png",new Rectangle(3,7,4,6);
.
.

Upvotes: 2

Related Questions