Preset Example¶
The following example shows a user defined preset for the PatchMatch matching algorithm. It extends an already existing preset StereoMatchingBase and basically just changes the matching method to PatchMatch via the Data
object. It will, however, contain all parameter presets defined in StereoMatchingBase. Furthermore, as the Name
and Description
values already imply, this preset requires a C-series camera (with the JSON schema defined in the Condition
object).
Filtering with the GetPresets command based on this condition only works, however, if the command’s Data parameter is provided. Only if that provided data contains a key ModelName with a value starting with “C57” and if it contains a subnode Parameters, which implies that the camera is currently opened, the preset is returned.
{
"Name": "PatchMatch-C-Series",
"Description": "An example parameter preset that extends the base stereo matching preset and only works with C-series cameras",
"Tags": [
"PatchMatch",
"C",
"Example"
],
"Extends": "StereoMatchingBase",
"Condition": {
"properties": {
"ModelName": {
"type": "string",
"pattern": "^C57.*$"
}
},
"required": [
"ModelName",
"Parameters"
]
},
"Data": {
"Parameters": {
"DisparityMap": {
"StereoMatching": {
"Method": "PatchMatch"
}
}
}
}
}
Structuring a complex condition¶
When writing complex conditions you can split the condition in smaller parts and reference them via the $ref
keyword. A JSON file that is referenced by a preset is called a reference file. A reference file must specify a dialect via the $schema
field, otherwise it is not recognized as such. We currently only support the dialect http://json-schema.org/draft-07/schema. Reference files are distinguished by their filenames, so make sure that each reference file has a unique filename and also consider the already installed reference files, which could lead to filename conflicts.
Alternatively, you can create a preset file that only contains a condition (leave the Data
field empty) and include this pure condition preset in another preset via the Extends
keyword.
In the following the preset example has been restructured using a reference file. For more examples see the installed presets and reference files.
// Simplified condition referencing another file containing parts of the condition
"Condition": {
"$ref": "./isCSeriesCamera.json"
"required": [
"ModelName",
"Parameters"
]
}
// isCSeriesCamera.json
"$schema": "http://json-schema.org/draft-07/schema",
"properties": {
"ModelName": {
"type": "string",
"pattern": "^C57.*$"
}
}