Find a small image in a larger, fixed image


This is Python script that I have used:

    #Match the gray scale images and calculate the Center Coordinates: px,py
    result = cv2.matchTemplate(img_gray,template,cv2.TM_CCOEFF_NORMED)

It gives the Match % of the small image "img_gray" as found in the larger image, "template", and places the center of that match in px,py coordinates.

Thus I can determine the X,Y coordinates of the small image on the large one, in-program.

Is there a function in App Inventor that I can use to find the location of a small "search image" inside a larger image? All static, (not video)
Some might call this a "Find Waldo" challenge, but my images are more simple, but with inconsistent lighting (hence the conversion to gray scale)

Thanks for pointing me in the right direction !

No. The tool you probably would use to do something in App Inventor like that is the Canvas, The Canvas can display an image with 'images'. There are tools to determine coordinates of the smaller 'images' and you might be able to create a similar app.

You might use the Canvas along with ImageSprites. What you do depends on exactly what your app is supposed to do. Could you provide a better example (perhaps with an image showing what you propose to do)?

Thank you; I will learn CANVAS and the Sprite routines in MitAppInv.

The app is an attempt to make a mobile version.
A high resolution (large) professional photo of photo-collage art is on the phone as a database.
Then a field person can have the app Search & Locate their smaller images from the camera or gallery to see if it is in the large image. Manually this takes a person nearly an hour per imaged and is prone to errors and fatigue. Dozens of small images may be searched by one User

You might consider using a commercial App designed for such tasks instead of trying to DIY your own - or find a JavaScript that can do it - App Inventor can run JavaScript in tandem with an HTML file that can be stored on the phone (containing your large image), no Internet required.

1 Like