Auto Annotation
Automatically annotates scene objects with semantic labels for AI/segmentation.
Automatically annotates scene objects with semantic labels for AI/segmentation.
Overview
util_autoAnnotation walks the scene tree and assigns annotation labels (e.g., BUILDINGS, NATURE, STREET) to objects that lack them. Uses fuzzy matching on shape names and object names to guess appropriate categories. Useful for generating training data for computer vision / semantic segmentation.
Extension path: lua/ge/extensions/util/autoAnnotation.lua
Exports (M)
| Function | Signature | Description |
|---|---|---|
autoAnnotateLevel | () | Annotates both scenetree and forest groups. |
autoAnnotateScenetree | () | Walks MissionGroup and annotates all children. |
autoAnnotateGroups | () | Annotates ForestItemDataSet items. |
onInit | () | No-op initialization hook. |
Internals
Shape Name Matching
Objects are matched by their shapeName field against known patterns:
| Pattern | Annotation |
|---|---|
building | BUILDINGS |
tree | NATURE |
sidewalk | SIDEWALK |
sign | TRAFFIC_SIGNS |
tunnel | STREET |
fence, fencing | BUILDINGS |
road | ASPHALT |
busstop | BUILDINGS |
excavator | CAR |
Unmatched shapes default to OBSTACLES.
Name Matching (GroundCover)
GroundCover objects use their name instead of shape:
| Pattern | Annotation |
|---|---|
grass | NATURE |
shrubs | NATURE |
Unmatched names default to NATURE.
Visitor Pattern
visitNode(parent, node) dispatches to class-specific visitors:
| Class | Handler |
|---|---|
TSStatic | Fuzzy-match shapeName |
ForestItemData | Same as TSStatic |
Forest | Iterate items, visit each ForestItemData |
GroundCover | Fuzzy-match name |
SFXSpace, SFXEmitter, PointLight, SpotLight | No-op (skipped) |
The walker recurses into children via getCount() / getObject().
Annotation Application
setAnnotation(node, annotation) sets:
node.annotation= label stringnode.mode="Override"- Calls
node:postApply()to commit changes
Only objects with empty annotation fields are modified.
How It Works
- Call
autoAnnotateLevel()to process the entire level. - The scenetree is walked starting from
MissionGroup. - Each node is dispatched to its class visitor.
- Visitors check the object's annotation field; if empty, guess from shape/name.
- Forest items are handled separately via
ForestItemDataSet.
Lua Examples
-- Annotate the entire current level
extensions.util_autoAnnotation.autoAnnotateLevel()
-- Annotate only the scenetree (no forests)
extensions.util_autoAnnotation.autoAnnotateScenetree()
-- Annotate only forest items
extensions.util_autoAnnotation.autoAnnotateGroups()Additional Exports
M.autoAnnotateGroups- (undocumented)M.autoAnnotateLevel- (undocumented)M.autoAnnotateScenetree- (undocumented)M.onInit- (undocumented)