locate_map

Locate a registered map scene with ORB and RANSAC in one observation of this pixel region. Uses the pinned frame when caching is on. Requires ready screen capture. Selects the highest-scoring transform even when other candidates have similar scores. Does not poll, send input or locate the player. The region must fit inside the current screen, with each edge from 48 to 8192 pixels and at most 33554432 pixels in total.

Syntax

region.locate_map(references, tile_size=None, max_frame_age_ms=1000, exclude=None)

Parameters

NameDescription
referenceslist[dict] | tuple[dict]
1 to 64 dictionaries requiring id, world, space, template, origin_x, origin_y and tile_size. Optional exclude accepts up to 32 Regions in source-image pixels. Other keys are rejected. IDs must be unique; id, world and space are nonempty strings. template is a stored, unscaled and uncropped wide Template. origin_x/y are finite source-image pixel coordinates of the shared space origin; tile_size is positive source pixels per map tile. Register separate coordinate spaces for disconnected bays. Each reference image must have edges from 48 to 4096 pixels and at most 4194304 pixels in total.
Required · Positional or named
No default
tile_sizeNumber?
Expected current pixels per map tile, finite and positive. Scale agreement contributes to candidate ranking. None omits this ranking prior; screen dimensions are not used to infer map scale.
Optional · Positional or named
Default: None
max_frame_age_msNumber
Whole milliseconds from 1 to 5000 for unpinned frames, checked before and during localization and before return. A frame pinned by this flow remains valid regardless of processing time while the same pin is held. Releasing or replacing that pin returns STALE with reason pinned_frame_changed; future timestamps are invalid.
Optional · Positional or named
Default: 1000
excludelist[Region] | tuple[Region]?
Up to 32 finite, positive-area Regions excluded from query features. Uses absolute screen pixels, clipped to this region. Reference exclude uses source-image pixels. None or an empty list excludes nothing.
Optional · Positional or named
Default: None

Returns

dict — status is LOCATED, UNKNOWN when no transform can be computed, or STALE. reason, frame_id, captured_at_ms and age_ms identify the observation. LOCATED adds reference_id, world, space, matrix, origin_x, origin_y, tile_size, scale, inliers, residual_px, score, runner_up_score and score_gap; these fields are None otherwise. The score and gap are diagnostic only; the highest-scoring computed transform is returned. matrix is [a, -b, tx, b, a, ty], mapping source pixels to screen pixels. origin_x/y project the registered origin to screen pixels; tile_size is detected pixels per map tile. No player pose is returned.

Example

# Locate a registered map scene
refs = [{"id": "harbor", "world": "ANGLER", "space": "harbor", "template": Template("harbor_wide"), "origin_x": 120, "origin_y": 480, "tile_size": 96}]
scene = Region.full_screen().locate_map(refs, tile_size=64)
if scene["status"] == "LOCATED":
    print(scene["world"], scene["origin_x"], scene["origin_y"])