How To Call It
Capture is a global table: call its functions with a dot (Capture.<method>(...)), not a colon.
Compares two Base64 crops locally and returns a status, similarity score and match table. Supports RGB, grayscale, edges, single-object appearance, object shape and three color measurements. Object methods require one complete object surrounded by a uniform or transparent border.
Documented for app version 1.0.59Updated:
Capture is a global table: call its functions with a dot (Capture.<method>(...)), not a colon.
In detection flow, refresh the screen with Snap.screenRefresh() first, then narrow the search area and confidence using Region and FindParam.
left/right are Base64 images. method: image_rgb, image_gray, image_edges, image_object, image_object_shape, color_average, color_histogram or color_layout. Optional threshold 0.5–1 (0.9), pixelTolerance 0–64 (16), backgroundTolerance 0–64 (24), timeoutMs 1–60000 (2000). RGB/grayscale/object appearance use pixel tolerance; edges use a minimum edge strength of 8; object methods use background tolerance. Color measurements and object shape do not use pixel tolerance. Returns matched, status, score (0–1), reason. Status: matched, not_found, unreadable, invalid_reference, invalid_target, timeout. Invalid options or images raise errors; stop requests propagate. Each image is limited to 950000 Base64 characters and 4194304 pixels; measurements sample up to 256 pixels per side. Scores are not probabilities. Does not locate objects within a larger region or return coordinates; multi-object, clipped or ambiguous-background object crops are rejected. Average color and color distribution ignore position; color_layout uses a 4×4 grid. Images are not sent to a server.
It is typically combined with Snap, Region, Asset, and FindParam; you can feed the result into quickTap(), click(), or a follow-up OCR step.
The snippet below is a starter pattern that can be applied directly in runtime flow.
local a = Capture.regionToBase64(Region(20, 100, 120, 120), "png", 100)
local b = Capture.regionToBase64(Region(220, 100, 120, 120), "png", 100)
local result = Capture.compareImages(a, b, "image_object", 0.9, 16, 24, 2000)
if result.matched then
print("Similarity: " .. result.score)
else
print(result.status .. ": " .. result.reason)
endFrom foundation to combined usage, each level is provided as a separate code block so you can copy the level you need and adapt it directly.
local a = Capture.regionToBase64(Region(20, 100, 120, 120), "png", 100)
local b = Capture.regionToBase64(Region(220, 100, 120, 120), "png", 100)
local result = Capture.compareImages(a, b, "image_object", 0.9, 16, 24, 2000)
if result.matched then
print("Similarity: " .. result.score)
else
print(result.status .. ": " .. result.reason)
endlocal stepOk = true
local a = Capture.regionToBase64(Region(20, 100, 120, 120), "png", 100)
local b = Capture.regionToBase64(Region(220, 100, 120, 120), "png", 100)
local result = Capture.compareImages(a, b, "image_object", 0.9, 16, 24, 2000)
if result.matched then
print("Similarity: " .. result.score)
else
print(result.status .. ": " .. result.reason)
end
if stepOk then
wait(200)
endlocal ok, err = pcall(function()
local a = Capture.regionToBase64(Region(20, 100, 120, 120), "png", 100)
local b = Capture.regionToBase64(Region(220, 100, 120, 120), "png", 100)
local result = Capture.compareImages(a, b, "image_object", 0.9, 16, 24, 2000)
if result.matched then
print("Similarity: " .. result.score)
else
print(result.status .. ": " .. result.reason)
end
end)
if not ok then
print("API step failed: Capture.compareImages: " .. tostring(err))
requestStop()
end-- In detection flow, refresh the screen with Snap.screenRefresh() first, then narrow the search area and confidence using Region and FindParam.
local function run_compareimages_step()
local a = Capture.regionToBase64(Region(20, 100, 120, 120), "png", 100)
local b = Capture.regionToBase64(Region(220, 100, 120, 120), "png", 100)
local result = Capture.compareImages(a, b, "image_object", 0.9, 16, 24, 2000)
if result.matched then
print("Similarity: " .. result.score)
else
print(result.status .. ": " .. result.reason)
end
end
local ok, err = pcall(run_compareimages_step)
if not ok then
toast("Step failed")
print(err)
endSnap.screenRefresh()
local a = Capture.regionToBase64(Region(20, 100, 120, 120), "png", 100)
local b = Capture.regionToBase64(Region(220, 100, 120, 120), "png", 100)
local result = Capture.compareImages(a, b, "image_object", 0.9, 16, 24, 2000)
if result.matched then
print("Similarity: " .. result.score)
else
print(result.status .. ": " .. result.reason)
end
local target = Region():find(Asset.image("target"), FindParam.timeout(3000))
if target then
quickTap(target)
end
toast("Detection step completed")