ar - recognitioncontexts Function
This function gives you contextual information about the image or object that was recognized by the AR app. Use it to define certain actions or properties of the app based on the recognition event.
The function expects major/minor integer pairs to identify the recognition. These pairs are defined in the AR application’s AR assets.
Construct a JSON payload that maps the major/minor pairs as they're defined in the AR assets of the iOS app.
{
"items": [
{
"name": "blue-pump_recognition",
"major": 1,
"minor": [
1
],
"actionAnimations": [
{
"name": "fadeIn",
"duration": 0.25,
"nodes": [
"pump",
"assembly",
"Long_Rod",
"Rod_Nut",
"Washer",
"Fly_Wheel",
"Rod_Enclosure",
"Small_Rod"
]
},
{
"name": "moveZ",
"value": 0.2,
"duration": 0.25,
"nodes": [
"assembly"
]
}
]
},
{
"name": "red-pump_recognition",
"major": 2,
"minor": [
1
],
"actionAnimations": [
{
"name": "fadeIn",
"duration": 0.25,
"nodes": [
"red-pump"
]
},
{
"name": "moveZ",
"value": 0.1,
"duration": 0.5,
"nodes": [
"Front"
]
},
{
"name": "moveX",
"value": -0.25,
"duration": 0.5,
"nodes": [
"Front"
]
},
{
"name": "fadeOut",
"duration": 0.25,
"nodes": [
"Front"
]
},
{
"name": "moveZ",
"value": 0.2,
"duration": 0.5,
"nodes": [
"Cogs",
"Washers"
]
}
]
}
]
}
Once your array is finished, minify and escape the JSON payload
into a string.
"{\"items\":[{\"name\":\"blue-pump_recognition\",\"major\":1,\"minor\":[1],\"actionAnimations\":[{\"name\":\"fadeIn\",\"duration\":0.25,\"nodes\":[\"pump\",\"assembly\",\"Long_Rod\",\"Rod_Nut\",\"Washer\",\"Fly_Wheel\",\"Rod_Enclosure\",\"Small_Rod\"]},{\"name\":\"moveZ\",\"value\":0.2,\"duration\":0.25,\"nodes\":[\"assembly\"]}]},{\"name\":\"red-pump_recognition\",\"major\":2,\"minor\":[1],\"actionAnimations\":[{\"name\":\"fadeIn\",\"duration\":0.25,\"nodes\":[\"red-pump\"]},{\"name\":\"moveZ\",\"value\":0.1,\"duration\":0.5,\"nodes\":[\"Front\"]},{\"name\":\"moveX\",\"value\":-0.25,\"duration\":0.5,\"nodes\":[\"Front\"]},{\"name\":\"fadeOut\",\"duration\":0.25,\"nodes\":[\"Front\"]},{\"name\":\"moveZ\",\"value\":0.2,\"duration\":0.5,\"nodes\":[\"Cogs\",\"Washers\"]}]}]}"
Run the following F(n) command to set the configuration.
fn config f ar-accelerator ar-recognitioncontexts mapping "{\"items\":[{\"name\":\"blue-pump_recognition\",\"major\":1,\"minor\":[1],\"actionAnimations\":[{\"name\":\"fadeIn\",\"duration\":0.25,\"nodes\":[\"pump\",\"assembly\",\"Long_Rod\",\"Rod_Nut\",\"Washer\",\"Fly_Wheel\",\"Rod_Enclosure\",\"Small_Rod\"]},{\"name\":\"moveZ\",\"value\":0.2,\"duration\":0.25,\"nodes\":[\"assembly\"]}]},{\"name\":\"red-pump_recognition\",\"major\":2,\"minor\":[1],\"actionAnimations\":[{\"name\":\"fadeIn\",\"duration\":0.25,\"nodes\":[\"red-pump\"]},{\"name\":\"moveZ\",\"value\":0.1,\"duration\":0.5,\"nodes\":[\"Front\"]},{\"name\":\"moveX\",\"value\":-0.25,\"duration\":0.5,\"nodes\":[\"Front\"]},{\"name\":\"fadeOut\",\"duration\":0.25,\"nodes\":[\"Front\"]},{\"name\":\"moveZ\",\"value\":0.2,\"duration\":0.5,\"nodes\":[\"Cogs\",\"Washers\"]}]}]}"
Test the configuration is correct by running invoke:
echo -n '{"major":1,"minor":1}' | fn invoke ar-accelerator ar-recognitioncontexts
The expected return result is a JSON object with the variables
set above nested in a service object.
{"items":[{"name":"blue-pump_recognition","major":1,"minor":[1],"actionAnimations":[{"name":"fadeIn","duration":0.25,"nodes":["pump","assembly","Long_Rod","Rod_Nut","Washer","Fly_Wheel","Rod_Enclosure","Small_Rod"]},{"name":"moveZ","value":0.2,"duration":0.25,"nodes":["assembly"]}]}]}