How to get roi and line value?
AnsweredHi,
I'm trying to do the roi & line event. I've already add roi & line events in my setting. How to get roi & line points values that I set in the setting page?
Below is the setting sections I use.
"sections":
[
{
"type": "Section",
"caption": "Crossing Line",
"items":
[
{
"type": "GroupBox",
"caption": "Lines",
"items":
[
{
"type": "Repeater",
"count": 5,
"template":
{
"type": "GroupBox",
"caption": "Line #",
"filledCheckItems": ["line#.figure"],
"items":
[
{
"type": "LineFigure",
"name": "line#.figure"
},
{
"type": "CheckBox",
"name": "line#.person",
"caption": "Person",
"defaultValue": false
},
{
"type": "CheckBox",
"name": "line#.vehicle",
"caption": "Vehicle",
"defaultValue": false
},
{
"type": "CheckBox",
"name": "line#.crossing",
"caption": "Crossing",
"defaultValue": false
}
]
}
}
]
}
]
},
{
"type": "Section",
"caption": "In Area",
"items":
[
{
"type": "GroupBox",
"caption": "Polygons",
"items":
[
{
"type": "Repeater",
"count": 5,
"template":
{
"type": "GroupBox",
"caption": "Polygon #",
"filledCheckItems": ["polygon#.figure"],
"items":
[
{
"type": "PolygonFigure",
"name": "polygon#.figure",
"minPoints": 3,
"maxPoints": 20
},
{
"type": "SpinBox",
"name": "polygon#.object.size.threshold",
"caption": "Object Size Threshold",
"defaultValue": 10,
"minValue": 0,
"maxValue": 100
},
{
"type": "SpinBox",
"name": "polygon#.duration.threshold",
"caption": "Duration threshold (ms)",
"defaultValue": 1,
"minValue": 1,
"maxValue": 100000
},
{
"type": "ComboBox",
"name": "polygon#.mode",
"caption": "Intersection Mode",
"defaultValue": "Bottom Point",
"range": ["Bottom Point", "Upper Bounding Box", "Lower Bounding Box", "Full Bounding Box"]
}
]
}
}
]
}
]
}
]
-
You can search for the values in the setting page, by its "name".
And this search and retrieve task is done by the function below:
ConsumingDeviceAgent::settingValue(const std::string& settingName) const
This function is in the consuming_device_agent, and since we each stream(deviceAgent) has inherited by this ConsumingDeviceAgent Class, we can use this function directely within your deviceAgent class without additional declaration or implementation.For example, if you want to save the point coordination of the secondary Polygon, into the DeviceAgent Class member variable, we can add some code like below. Under the settingsReceived() function.
nx::sdk::Result<const nx::sdk::ISettingsResponse*> DeviceAgent::settingsReceived()
{ ...
m_secondPolygonStr = settinvValue("polygon2.figure");
...
}And when you print out what is in the m_secondPolygonStr, you may see some string set that contains value of the user input. I recommend you to print out that.
-
You can search for the values in the setting page, by its "name".
And this search and retrieve task is done by the function below:
ConsumingDeviceAgent::settingValue(const std::string& settingName) const
This function is in the consuming_device_agent, and since we each stream(deviceAgent) has inherited by this ConsumingDeviceAgent Class, we can use this function directely within your deviceAgent class without additional declaration or implementation.For example, if you want to save the point coordination of the secondary Polygon, into the DeviceAgent Class member variable, we can add some code like below. Under the settingsReceived() function.
nx::sdk::Result<const nx::sdk::ISettingsResponse*> DeviceAgent::settingsReceived()
{ ...
m_secondPolygonStr = settinvValue("polygon2.figure");
...
}And when you print out what is in the m_secondPolygonStr, you may see some string set that contains value of the user input. I recommend you to print out that.
-
In the Json String, you may see the "#" place holder when you use the "repeater". This is the placeholder for the count of the repeater. So, you can access to the specific counter by replacing the "#" into the specific number.
ex)// Json string for the GUI
name: "polygon#.figure"
// DeviceAgent.cpp
settingValue("polygon1.figure") // this returns all the information from the 1st repeater.
settingValue("polygon2.figure") // this returns all the information from the 2nd repeater.
....And if you mean the total number of repeater that is enabled by user,
I am not sure if it is possible or not.
But It was okay to use, because if we are trying to access repeat counter which has not enabled by user,
it is returning empty json string as a return value of settingValue() function.
You may make own function that parse the Json String from the settingValue() function, so that distinguish it's value and status (activated or not)
Please sign in to leave a comment.
Comments
4 comments