nx_metadata_sdk  1.0
Metadata SDK
settings_model.h
1 // Copyright 2018-present Network Optix, Inc. Licensed under MPL 2.0: www.mozilla.org/MPL/2.0/
2 
3 #pragma once
4 
5 #include <string>
6 
7 namespace nx {
8 namespace vms_server_plugins {
9 namespace analytics {
10 namespace stub {
11 
12 const std::string kEnginePluginSideSetting{"testPluginSideSpinBox"};
13 
14 const std::string kGenerateEventsSetting{"generateEvents"};
15 const std::string kMotionVisualizationObjectType{"nx.stub.motionVisualization"};
16 
17 const std::string kGenerateCarsSetting{"generateCars"};
18 const std::string kGenerateTrucksSetting{"generateTrucks"};
19 const std::string kGeneratePedestriansSetting{"generatePedestrians"};
20 const std::string kGenerateHumanFacesSetting{"generateHumanFaces"};
21 const std::string kGenerateBicyclesSetting{"generateBicycles"};
22 const std::string kGenerateStonesSetting{"generateStones"};
23 const std::string kGenerateFixedObjectSetting{"generateFixedObject"};
24 const std::string kGenerateCounterSetting{"generateCounter"};
25 const std::string kCounterBoundingBoxSideSizeSetting{"counterBoundingBoxSideSize"};
26 const std::string kCounterXOffsetSetting{"counterXOffset"};
27 const std::string kCounterYOffsetSetting{"counterYOffset"};
28 const std::string kFixedObjectColorSetting{"fixedObjectColor"};
29 const std::string kNoSpecialColorSettingValue{"No special color"};
30 
31 const std::string kDeclareAdditionalEventTypesSetting{"declareAdditionalEventTypesSetting"};
32 
33 const std::string kBlinkingObjectPeriodMsSetting{"blinkingObjectPeriodMs"};
34 const std::string kBlinkingObjectInDedicatedPacketSetting{"blinkingObjectInDedicatedPacket"};
35 
36 const std::string kGenerateObjectsEveryNFramesSetting{"generateObjectsEveryNFrames"};
37 const std::string kNumberOfObjectsToGenerateSetting{"numberOfObjectsToGenerate"};
38 const std::string kGeneratePreviewPacketSetting{"generatePreviewPacket"};
39 const std::string kPreviewImageFileSetting{"previewImageFile"};
40 const std::string kGeneratePreviewAfterNFramesSetting("generatePreviewAfterNFrames");
41 const std::string kThrowPluginDiagnosticEventsFromDeviceAgentSetting{
42  "throwPluginDiagnosticEventsFromDeviceAgent"};
43 
44 const std::string kThrowPluginDiagnosticEventsFromEngineSetting{
45  "throwPluginDiagnosticEventsFromEngine"};
46 const std::string kDisableStreamSelectionSetting{"disableStreamSelection"};
47 const std::string kLeakFramesSetting{"leakFrames"};
48 const std::string kAdditionalFrameProcessingDelayMsSetting{"additionalFrameProcessingDelayMs"};
49 const std::string kOverallMetadataDelayMsSetting{"overallMetadataDelayMs"};
50 
51 static const std::string kRegularSettingsModelOption = "regular";
52 static const std::string kAlternativeSettingsModelOption = "alternative";
53 
54 static const std::string kSettingsModelSettings = "settingsModelComboBox";
55 
56 static const std::string kCitySelector = "languageSelectorSettings";
57 static const std::string kEnglishOption = "English";
58 static const std::string kGermanOption = "German";
59 
60 static const std::string kAlternativeSettingsModel =
61  /*suppress newline*/ 1 + (const char*) R"json("
62 {
63  "type": "Settings",
64  "items": [
65  {
66  "type": "ComboBox",
67  "name": ")json" + kSettingsModelSettings + R"json(",
68  "caption": "Settings model",
69  "defaultValue": ")json" + kRegularSettingsModelOption + R"json(",
70  "range": [
71  ")json" + kRegularSettingsModelOption + R"json(",
72  ")json" + kAlternativeSettingsModelOption + R"json("
73  ]
74  },
75  {
76  "type": "GroupBox",
77  "caption": "Alternative GroupBox",
78  "items": [
79  {
80  "type": "CheckBox",
81  "name": "alternativeCheckBox",
82  "caption": "Alternative CheckBox",
83  "defaultValue": true
84  },
85  {
86  "type": "TextField",
87  "name": "alternativeTextField",
88  "caption": "Alternative TextField",
89  "defaultValue": "alternative text"
90  }
91  ]
92  }
93  ]
94 })json";
95 
96 static const std::string kRegularSettingsModelPart1 = /*suppress newline*/ 1 + R"json(
97 {
98  "type": "Settings",
99  "items": [
100  {
101  "type": "ComboBox",
102  "name": ")json" + kSettingsModelSettings + R"json(",
103  "caption": "Settings model",
104  "defaultValue": ")json" + kRegularSettingsModelOption + R"json(",
105  "range": [
106  ")json" + kRegularSettingsModelOption + R"json(",
107  ")json" + kAlternativeSettingsModelOption + R"json("
108  ]
109  },
110  {
111  "type": "GroupBox",
112  "caption": "Real Stub DeviceAgent settings",
113  "items": [
114  {
115  "type": "GroupBox",
116  "caption": "Object generation settings",
117  "items": [)json";
118 
119 static const std::string kStubObjectTypesSettings = R"json(
120  {
121  "type": "CheckBox",
122  "name": ")json" + kGenerateCarsSetting + R"json(",
123  "caption": "Generate cars",
124  "defaultValue": true
125  },
126  {
127  "type": "CheckBox",
128  "name": ")json" + kGenerateTrucksSetting + R"json(",
129  "caption": "Generate trucks",
130  "defaultValue": true
131  },
132  {
133  "type": "CheckBox",
134  "name": ")json" + kGeneratePedestriansSetting + R"json(",
135  "caption": "Generate pedestrians",
136  "defaultValue": true
137  },
138  {
139  "type": "CheckBox",
140  "name": ")json" + kGenerateHumanFacesSetting + R"json(",
141  "caption": "Generate human faces",
142  "defaultValue": true
143  },
144  {
145  "type": "CheckBox",
146  "name": ")json" + kGenerateBicyclesSetting + R"json(",
147  "caption": "Generate bicycles",
148  "defaultValue": true
149  },
150  {
151  "type": "CheckBox",
152  "name": ")json" + kGenerateStonesSetting + R"json(",
153  "caption": "Generate stones",
154  "defaultValue": false
155  },
156  {
157  "type": "CheckBox",
158  "name": ")json" + kGenerateFixedObjectSetting + R"json(",
159  "caption": "Generate fixed object",
160  "description": "Generates a fixed object with coordinates (0.25, 0.25, 0.25, 0.25)",
161  "defaultValue": false
162  },
163  {
164  "type": "ComboBox",
165  "name": ")json" + kFixedObjectColorSetting + R"json(",
166  "caption": "Fixed object color",
167  "range": [
168  ")json" + kNoSpecialColorSettingValue + R"json(",
169  "Magenta", "Blue", "Green", "Yellow", "Cyan", "Purple", "Orange",
170  "Red", "White", "#FFFFC0", "!invalid!", "#NONHEX"
171  ],
172  "defaultValue": ")json" + kNoSpecialColorSettingValue + R"json("
173  },
174  {
175  "type": "CheckBox",
176  "name": ")json" + kGenerateCounterSetting + R"json(",
177  "caption": "Generate counter",
178  "description": "Generates a counter",
179  "defaultValue": false
180  },
181  {
182  "type": "DoubleSpinBox",
183  "caption": "Size of the side of the counter bounding box",
184  "name": ")json" + kCounterBoundingBoxSideSizeSetting + R"json(",
185  "defaultValue": 0.0,
186  "minValue": 0.0,
187  "maxValue": 1.0
188  },
189  {
190  "type": "DoubleSpinBox",
191  "caption": "Counter bounding box X-Offset",
192  "name": ")json" + kCounterXOffsetSetting + R"json(",
193  "defaultValue": 0.0,
194  "minValue": 0.0,
195  "maxValue": 1.0
196  },
197  {
198  "type": "DoubleSpinBox",
199  "caption": "Counter bounding box Y-Offset",
200  "name": ")json" + kCounterYOffsetSetting + R"json(",
201  "defaultValue": 0.0,
202  "minValue": 0.0,
203  "maxValue": 1.0
204  },
205  {
206  "type": "SpinBox",
207  "name": ")json" + kBlinkingObjectPeriodMsSetting + R"json(",
208  "caption": "Generate 1-frame BlinkingObject every N ms (if not 0)",
209  "defaultValue": 0,
210  "minValue": 0,
211  "maxValue": 100000
212  },
213  {
214  "type": "CheckBox",
215  "name": ")json" + kBlinkingObjectInDedicatedPacketSetting + R"json(",
216  "caption": "Put BlinkingObject into a dedicated MetadataPacket",
217  "defaultValue": false
218  },)json";
219 
220 static const std::string kRegularSettingsModelPart1Continuation = R"json(
221  {
222  "type": "CheckBox",
223  "caption": "Declare additional event types",
224  "name": ")json" + kDeclareAdditionalEventTypesSetting + R"json(",
225  "defaultValue": false
226  },
227  {
228  "type": "SpinBox",
229  "name": ")json" + kNumberOfObjectsToGenerateSetting + R"json(",
230  "caption": "Number of objects to generate",
231  "defaultValue": 1,
232  "minValue": 1,
233  "maxValue": 100000
234  },
235  {
236  "type": "SpinBox",
237  "name": ")json" + kGenerateObjectsEveryNFramesSetting + R"json(",
238  "caption": "Generate objects every N frames",
239  "defaultValue": 1,
240  "minValue": 1,
241  "maxValue": 100000
242  },
243  {
244  "type": "CheckBox",
245  "name": ")json" + kGeneratePreviewPacketSetting + R"json(",
246  "caption": "Generate preview packet",
247  "defaultValue": true
248  },
249  {
250  "type": "TextArea",
251  "name": ")json" + kPreviewImageFileSetting + R"json(",
252  "caption": "Preview image file",
253  "description": "Path to an image which should be used as a preview for tracks"
254  },
255  {
256  "type": "SpinBox",
257  "name": ")json" + kGeneratePreviewAfterNFramesSetting + R"json(",
258  "caption": "Generate preview after N frames",
259  "defaultValue": 30,
260  "minValue": 1,
261  "maxValue": 100000
262  },
263  {
264  "type": "SpinBox",
265  "name": ")json" + kOverallMetadataDelayMsSetting + R"json(",
266  "caption": "Overall metadata delay, ms",
267  "defaultValue": 0,
268  "minValue": 0,
269  "maxValue": 1000000000
270  }
271  ]
272  },
273  {
274  "type": "CheckBox",
275  "name": ")json" + kGenerateEventsSetting + R"json(",
276  "caption": "Generate events",
277  "defaultValue": true
278  },
279  {
280  "type": "CheckBox",
281  "name": ")json" + kThrowPluginDiagnosticEventsFromDeviceAgentSetting + R"json(",
282  "caption": "Produce Plugin Diagnostic Events from the DeviceAgent",
283  "defaultValue": false
284  },
285  {
286  "type": "CheckBox",
287  "name": ")json" + kLeakFramesSetting + R"json(",
288  "caption": "Force a memory leak when processing a video frame",
289  "defaultValue": false
290  },
291  {
292  "type": "SpinBox",
293  "name": ")json" + kAdditionalFrameProcessingDelayMsSetting + R"json(",
294  "caption": "Additional frame processing delay, ms",
295  "defaultValue": 0,
296  "minValue": 0,
297  "maxValue": 1000000000
298  }
299  ]
300  },
301  {
302  "type": "GroupBox",
303  "caption": "Example Stub DeviceAgent settings",
304  "items": [
305  {
306  "type": "TextField",
307  "name": "testTextField",
308  "caption": "Device Agent Text Field",
309  "description": "A text field",
310  "defaultValue": "a text"
311  },
312  {
313  "type": "ComboBox",
314  "name": ")json" + kCitySelector + R"json(",
315  "caption": "Cities",
316  "defaultValue": "English",
317  "range": [
318  ")json" + kEnglishOption + R"json(",
319  ")json" + kGermanOption + R"json("
320  ]
321  },)json";
322 
323 static const std::string kEnglishCitiesPart = /*suppress newline*/ 1 + R"json(
324  {
325  "type": "RadioButtonGroup",
326  "name": "testEnglishRadioButtonGroup",
327  "caption": "Choose one",
328  "description": "Choose one option",
329  "defaultValue": "London",
330  "range": [
331  "London",
332  "Liverpool"
333  ]
334  },)json";
335 
336 static const std::string kGermanCitiesPart = /*suppress newline*/ 1 + R"json(
337  {
338  "type": "RadioButtonGroup",
339  "name": "testGermanRadioButtonGroup",
340  "caption": "Choose one",
341  "description": "Choose one option",
342  "defaultValue": "Berlin",
343  "range": [
344  "Berlin",
345  "Nuremberg",
346  "Leipzig"
347  ]
348  },)json";
349 
350 static const std::string kRegularSettingsModelPart2 = /*suppress newline*/ 1 + R"json("
351  {
352  "type": "RadioButtonGroup",
353  "name": "testRadioButtonGroup",
354  "caption": "RadioButton Group",
355  "description": "Choose one option",
356  "defaultValue": "Cs_enodatum",
357  "range": [
358  "K_gowerianus",
359  "K_galilaeii",
360  "S_calloviense",
361  "S_micans",
362  "Cs_enodatum",
363  "K_medea",
364  "K_jason",
365  "K_obductum",
366  "K_posterior"
367  ],
368  "itemCaptions": {
369  "K_gowerianus": "Kepplerites gowerianus",
370  "K_galilaeii": "Kepplerites galilaeii",
371  "S_calloviense": "Sigaloceras calloviense",
372  "S_micans": "Sigaloceras micans",
373  "Cs_enodatum": "Catasigaloceras enodatum",
374  "K_medea": "Kosmoceras medea",
375  "K_jason": "Kosmoceras jason",
376  "K_obductum": "Kosmoceras obductum",
377  "K_posterior": "Kosmoceras posterior"
378  }
379  },
380  {
381  "type": "CheckBoxGroup",
382  "name": "testCheckBoxGroup",
383  "caption": "CheckBox Group",
384  "description": "Choose one or several options",
385  "defaultValue": ["Coleoidea", "Nautiloidea"],
386  "range": [
387  "Coleoidea",
388  "Ammonoidea",
389  "Nautiloidea",
390  "Orthoceratoidea"
391  ],
392  "itemCaptions": {
393  "Coleoidea": "Coleoidea (Bather, 1888)",
394  "Ammonoidea": "Ammonoidea (Zittel, 1884)",
395  "Nautiloidea": "Nautiloidea (Agassiz, 1847)",
396  "Orthoceratoidea": "Orthoceratoidea (M'Coy 1844)"
397  }
398  },
399  {
400  "type": "SpinBox",
401  "caption": "Device Agent SpinBox (plugin side)",
402  "name": "pluginSideTestSpinBox",
403  "defaultValue": 42,
404  "minValue": 0,
405  "maxValue": 100
406  },
407  {
408  "type": "DoubleSpinBox",
409  "caption": "Device Agent DoubleSpinBox",
410  "name": "testDoubleSpinBox",
411  "defaultValue": 3.1415,
412  "minValue": 0.0,
413  "maxValue": 100.0
414  },
415  {
416  "type": "ComboBox",
417  "name": "testComboBox",
418  "caption": "Device Agent ComboBox",
419  "defaultValue": "value2",
420  "range": ["value1", "value2", "value3"],
421  "itemCaptions": {
422  "value1": "Device Agent Value #1",
423  "value2": "Device Agent Value #2",
424  "value3": "Device Agent Value #3"
425  }
426  },
427  {
428  "type": "Separator"
429  },
430  {
431  "type": "CheckBox",
432  "caption": "Device Agent CheckBox",
433  "name": "testCheckBox",
434  "defaultValue": true
435  },
436  {
437  "type": "CheckBox",
438  "caption": "Disabled Device Agent CheckBox",
439  "name": "disabledTestCheckBox",
440  "defaultValue": false,
441  "enabled": false
442  },
443  {
444  "type": "CheckBox",
445  "caption": "Hidden Device Agent CheckBox",
446  "name": "hiddenTestCheckBox",
447  "defaultValue": false,
448  "visible": false
449  }
450  ]
451  }
452  ],)json" R"json(
453  "sections": [)json";
454 
455 static const std::string kRegularSettingsModelPart3 =
456  R"json(
457  {
458  "type": "Section",
459  "caption": "Example",
460  "items": [
461  {
462  "type": "GroupBox",
463  "caption": "Example Stub DeviceAgent settings",
464  "items": [
465  {
466  "type": "TextField",
467  "name": "testTextFieldWithValidation",
468  "caption": "Hexadecimal number text field",
469  "defaultValue": "12ab34cd",
470  "validationRegex": "^[a-f0-9]+$",
471  "validationRegexFlags": "i",
472  "validationErrorMessage": "Text must contain only digits and characters a-f, e.g. 12ab34cd."
473  },
474  {
475  "type": "SpinBox",
476  "caption": "Device Agent SpinBox (plugin side)",
477  "name": "pluginSideTestSpinBox2",
478  "defaultValue": 42,
479  "minValue": 0,
480  "maxValue": 100
481  },
482  {
483  "type": "DoubleSpinBox",
484  "caption": "Device Agent DoubleSpinBox",
485  "name": "testDoubleSpinBox2",
486  "defaultValue": 3.1415,
487  "minValue": 0.0,
488  "maxValue": 100.0
489  },
490  {
491  "type": "ComboBox",
492  "name": "testComboBox2",
493  "caption": "Device Agent ComboBox",
494  "defaultValue": "value2",
495  "range": ["value1", "value2", "value3"]
496  },
497  {
498  "type": "CheckBox",
499  "caption": "Device Agent CheckBox",
500  "name": "testCheckBox2",
501  "defaultValue": true
502  }
503  ]
504  }
505  ],
506  "sections": [
507  {
508  "type": "Section",
509  "caption": "Nested section",
510  "items": [
511  {
512  "type": "GroupBox",
513  "caption": "Nested Section Example",
514  "items": [
515  {
516  "type": "SwitchButton",
517  "caption": "Switch Button",
518  "name": "testSwitch",
519  "description": "Tooltip for the switch button",
520  "defaultValue": false
521  },
522  {
523  "type": "SpinBox",
524  "caption": "SpinBox Parameter",
525  "name": "testSpinBox3",
526  "defaultValue": 42,
527  "minValue": 0,
528  "maxValue": 100
529  },
530  {
531  "type": "DoubleSpinBox",
532  "caption": "DoubleSpinBox Parameter",
533  "name": "testDoubleSpinBox3",
534  "defaultValue": 3.1415,
535  "minValue": 0.0,
536  "maxValue": 100.0
537  },
538  {
539  "type": "ComboBox",
540  "name": "testComboBox3",
541  "caption": "ComboBox Parameter",
542  "defaultValue": "value2",
543  "range": ["value1", "value2", "value3"]
544  },
545  {
546  "type": "CheckBox",
547  "caption": "CheckBox Parameter",
548  "name": "testCheckBox3",
549  "defaultValue": true
550  }
551  ]
552  }
553  ]
554  }
555  ]
556  },
557  {
558  "type": "Section",
559  "caption": "ROI",
560  "items": [
561  {
562  "type": "GroupBox",
563  "caption": "Polygons",
564  "items": [
565  {
566  "type": "PolygonFigure",
567  "name": "excludedArea.figure",
568  "caption": "Excluded area",
569  "useLabelField": false,
570  "maxPoints": 8
571  },
572  {
573  "type": "Repeater",
574  "count": 5,
575  "template": {
576  "type": "GroupBox",
577  "caption": "Polygon #",
578  "filledCheckItems": ["polygon#.figure"],
579  "items": [
580  {
581  "type": "PolygonFigure",
582  "name": "polygon#.figure",
583  "minPoints": 4,
584  "maxPoints": 8
585  },
586  {
587  "type": "SpinBox",
588  "name": "polygon#.threshold",
589  "caption": "Level of detection",
590  "defaultValue": 50,
591  "minValue": 1,
592  "maxValue": 100
593  },
594  {
595  "type": "SpinBox",
596  "name": "polygon#.sensitivity",
597  "caption": "Sensitivity",
598  "defaultValue": 80,
599  "minValue": 1,
600  "maxValue": 100
601  },
602  {
603  "type": "SpinBox",
604  "name": "polygon#.minimumDuration",
605  "caption": "Minimum duration (s)",
606  "defaultValue": 0,
607  "minValue": 0,
608  "maxValue": 5
609  }
610  ]
611  }
612  }
613  ]
614  },
615  {
616  "type": "GroupBox",
617  "caption": "Boxes",
618  "items": [
619  {
620  "type": "Repeater",
621  "count": 5,
622  "template": {
623  "type": "GroupBox",
624  "caption": "Box #",
625  "filledCheckItems": ["box#.figure"],
626  "items": [
627  {
628  "type": "BoxFigure",
629  "name": "box#.figure"
630  },
631  {
632  "type": "SpinBox",
633  "name": "box#.threshold",
634  "caption": "Level of detection",
635  "defaultValue": 50,
636  "minValue": 1,
637  "maxValue": 100
638  },
639  {
640  "type": "SpinBox",
641  "name": "box#.sensitivity",
642  "caption": "Sensitivity",
643  "defaultValue": 80,
644  "minValue": 1,
645  "maxValue": 100
646  },
647  {
648  "type": "SpinBox",
649  "name": "box#.minimumDuration",
650  "caption": "Minimum duration (s)",
651  "defaultValue": 0,
652  "minValue": 0,
653  "maxValue": 5
654  }
655  ]
656  }
657  }
658  ]
659  },
660  {
661  "type": "GroupBox",
662  "caption": "Lines",
663  "items": [
664  {
665  "type": "Repeater",
666  "count": 5,
667  "template": {
668  "type": "GroupBox",
669  "caption": "Line #",
670  "filledCheckItems": ["line#.figure"],
671  "items": [
672  {
673  "type": "LineFigure",
674  "name": "line#.figure"
675  },
676  {
677  "type": "CheckBox",
678  "name": "line#.person",
679  "caption": "Person",
680  "defaultValue": false
681  },
682  {
683  "type": "CheckBox",
684  "name": "line#.vehicle",
685  "caption": "Vehicle",
686  "defaultValue": false
687  },
688  {
689  "type": "CheckBox",
690  "name": "line#.crossing",
691  "caption": "Crossing",
692  "defaultValue": false
693  }
694  ]
695  }
696  }
697  ]
698  },
699  {
700  "type": "GroupBox",
701  "caption": "Polyline",
702  "items": [
703  {
704  "type": "LineFigure",
705  "name": "testPolyLine",
706  "caption": "Polyline",
707  "maxPoints": 8
708  }
709  ]
710  },
711  {
712  "type": "GroupBox",
713  "caption": "Polygon",
714  "items": [
715  {
716  "type": "PolygonFigure",
717  "name": "testPolygon",
718  "caption": "Polygon outside of a repeater",
719  "description": "The points of this polygon are considered as a plugin-side setting",
720  "minPoints": 3,
721  "maxPoints": 8
722  }
723  ]
724  },
725  {
726  "type": "GroupBox",
727  "caption": "Size Constraints",
728  "items": [
729  {
730  "type": "ObjectSizeConstraints",
731  "name": "testSizeConstraints",
732  "caption": "Object size constraints",
733  "description": "Size range an object should fit into to be detected",
734  "defaultValue": {"minimum": [0.1, 0.4], "maximum": [0.2, 0.8]}
735  }
736  ]
737  }
738  ]
739  }
740  ]
741 })json";
742 
743 } // namespace stub
744 } // namespace analytics
745 } // namespace vms_server_plugins
746 } // namespace nx
Definition: apple_utils.h:6