Search

Studio

Image Recognition Bot Templates and OCR: Asset Lab

Build image recognition bot assets in Asset Lab: capture an emulator or cloud device screen, pick tap coordinates, test an OCR region live and crop templates.

  • Windows
  • Mac
  • Emulator
  • Cloud device
  • Studio
  • Python SDK
Beginner Updated 7 min read
On this page
  1. Before you start
  2. Open Asset Lab
  3. Connect and capture
  4. The tools
  5. Pick a point
  6. Test an OCR region
  7. Crop a template
  8. Use the image ID in an image recognition bot
  9. Template matching tips for a game bot
  10. Troubleshooting
  11. Asset Helper not found
  12. ADB not found
  13. No cloud devices, or the device cannot be selected
  14. Cloud capture failed
  15. Next

Asset Lab is the helper app in Macro Automation Studio (MAS) where an image recognition bot gets its assets. It captures a device screen, then lets you pick coordinates, test OCR regions and crop template images into your Image Library. Use it before you write find_object or read_text calls, so the numbers in your script come from real pixels.

Before you start

  • MAS is installed and you are signed in. Asset Lab reuses your session.
  • A device to capture: a local emulator with ADB switched on, or a cloud device in the ready state.
  • On a Mac, adb must be found by MAS. See Install MAS if MAS reports “ADB executable not found”.

Open Asset Lab

Asset Lab is a separate window. On Windows it is AssetHelper.exe next to the app; on a Mac it is AssetLab.app inside the bundle. MAS launches it with your sign-in, adb and Tesseract already configured. Three places open it:

  1. In the Code Editor, open the Assets panel and click Open Asset Helper.
  2. In Device Groups, click Open in Asset Helper on a cloud device card that is ready. Asset Lab opens connected to that device with a fresh capture.
  3. In the Code Editor’s cloud device view, click Open in Asset Helper.

Connect and capture

The connection area has two source tabs: Local and Cloud.

  1. Click the scan button, then pick the emulator’s port from the list. Type the port if the scan does not find it.
  2. Click Connect.
  3. Click Capture Screenshot or press F5. Navigate the emulator to the screen you want and capture again whenever you need a fresh frame.
  1. Pick a device from the list. Only devices in the ready state can be selected; others show their state, such as stopped or starting. Start a stopped device from Cloud Devices in MAS.
  2. Click Connect. Asset Lab captures the screen at once.
  3. Click Live to see and control the device. The stream runs over WebRTC at the device’s native resolution. Navigate to the screen you want, then click Freeze & Capture. The capture is a real adb screenshot, not a video frame, so it matches what find_object sees during a run.

Opening Live takes over the stream from anyone else watching the device, including the device view in MAS.

Captures are always native resolution. The footer shows the coordinates under the mouse and how many points, paths and regions you have drawn.

The tools

ToolKeyUse it for
PointsPCoordinates for mas.click and mas.swipe
OCRRA region for mas.read_text, tested live
SwipeSStart and end coordinates of a drag
CropCA template image for mas.find_object

Tab toggles the side panel, Esc deselects the tool, and ? lists the shortcuts.

Pick a point

  1. Press P and click the element. Click its center, not its edge.
  2. The Points panel lists each point. Click Copy to put the coordinates on the clipboard as JSON.

Points suit elements that never move. For anything that moves, crop a template instead.

Test an OCR region

  1. Press R and drag a rectangle around the text.
  2. The OCR panel shows the cropped region and runs Tesseract on this computer. The text appears under OCR Results, with the model that read it.
  3. Adjust the settings until the text reads correctly, then click Copy for the region coordinates or Copy Text for the text.

The settings map to mas.read_text arguments:

Asset Lab settingSDK argument
OCR Model: Default (Balanced), Fast, Bestmodel="eng", "eng_fast", "eng_best"
Page Segmentation Mode (PSM): 0 to 13psm=7 for one line, 8 for one word, 6 for a block, 11 for sparse text
Image Preprocessing: Grayscalecolor_conversion=ColorConversion.BGR_TO_GRAY
Image Preprocessing: Binary (Black/White)color_conversion=ColorConversion.BLACK_WHITE

Crop a template

  1. Press C and drag a rectangle around the element.
  2. In the dialog, choose Save As… to keep a PNG on your computer, or Upload to Server to add it to your Image Library.
  3. For an upload, enter a file name and confirm. The dialog reports the library name and the image ID, for example “Saved to your image library as play_button (id 42)”.

Back in the Code Editor, the Assets panel refreshes when the window regains focus, and Copy ID puts the ID on the clipboard. The library accepts images up to 10 MB in jpg, jpeg, png, gif or webp; crops from Asset Lab are PNG.

Use the image ID in an image recognition bot

Declare IDs once with mas.images and use the names everywhere else. find_object_retry tries three times, two seconds apart, and returns None when nothing matches.

python
import mas

images = mas.images({"play_button": 42, "close_x": 43})

match = mas.find_object_retry(images.play_button, total_tries=3, time_sleep=2.0)
if match:
    mas.click(match.x, match.y)
else:
    mas.log("Play button not on screen", level="warning")

find_object accepts a match at a threshold of 0.8 by default. Pass search_region=Region(x1, y1, x2, y2) to limit the search to the part of the screen where the element lives; it is faster and avoids look-alikes elsewhere. When a control has several looks, list them with find_any_object_retry.

The mas.images call also matters outside the script: MAS reads the IDs from it when it publishes a project to the Marketplace and when it packs a cloud run, so the templates travel with the code. Only images in your own library resolve.

For a region you tested in the OCR panel:

python
import mas
from mas import Region, ColorConversion

gold = mas.read_text(
    region=Region(x1=610, y1=24, x2=760, y2=64),
    model="eng",
    psm=7,
    color_conversion=ColorConversion.BLACK_WHITE,
)
print(gold.text, gold.confidence)

Template matching tips for a game bot

  • Crop tight. Include the element and a few pixels of margin, not the background around it.
  • Avoid text and numbers that change. Crop the icon or the button frame, not the counter next to it.
  • Capture at the resolution the macro runs at. A template from a 1080p emulator misses on a 720p one, and a cloud device profile differs from your emulator. Recapture after you change the emulator’s resolution or DPI.
  • Prefer static, high-contrast elements. Animated areas produce templates that match on some frames only.
  • Make one template per state. A greyed-out button and an active one are two images.
  • Start at the 0.8 threshold. Raise it when the wrong element matches; lower it a little when a correct element is missed.
  • Name images by what they are. mas.images names must be valid Python identifiers such as login_btn.

Troubleshooting

Asset Helper not found

Windows: AssetHelper.exe is missing next to the app. Mac: AssetLab.app is missing from the bundle. Reinstall MAS from the download page.

ADB not found

MAS could not locate adb, so Asset Lab cannot talk to a local emulator. On Windows, reinstall MAS. On a Mac, install adb with Homebrew as described on Install MAS and restart MAS.

No cloud devices, or the device cannot be selected

The Cloud tab lists devices on your account and greys out any that are not ready. Create or start the device from Cloud Devices in MAS; the list refreshes on its own.

Cloud capture failed

The device may have stopped between listing and capture. Refresh the list and retry. If the message says the device’s host needs a refresh, stop and start the device in Cloud Devices, then capture again.

Next

Turn a template into a loop on Image recognition macros, and read the full argument lists on Vision.

Next steps

Related pages

Was this page helpful?

Questions? Ask in Discord