123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763 |
- #ifndef __MAS_ALGO_DEF_H
- #define __MAS_ALGO_DEF_H
- #include "MAS_Definition.h"
- #include "TZJson.h"
- NAMESPACE_MAS_BEGIN
- typedef enum __DET_INIT_TYPE_CODE {
- DIT_INT = 0x00,
- DIT_DOUBLE = 0x01,
- DIT_STRING = 0x02,
- DIT_BOOL = 0x03,
- DIT_FORM = 0x04
- } EN_INIT_CODE;
- typedef enum __DET_DET_AREA_CODE {
- DDA_ROI = 0x00,
- DDA_IGNORE = 0x01,
- DDA_LINE = 0x02
- } EN_DET_AREA_CODE;
- typedef enum __STRA_RESTLT_TYPE {
- SRT_NONE,
- SRT_EVENT,
- SRT_ALARM,
- SRT_NOT_SHOW = 0x1000,
- } EN_STRA_RESULT;
- struct TextInfo {
- std::string Text;
- TZ_FLOAT TextLTX;
- TZ_FLOAT TextLTY;
- std::string TextColor;
- TZ_INT TextSize;
- TZ_INT TextThickness;
- std::string BackgroundColor;
- TextInfo() : Text(""), TextLTX(-1),
- TextLTY(-1), TextColor("#000000"),
- TextSize(2), TextThickness(1),
- BackgroundColor("") {}
-
- TextInfo(std::string text, TZ_FLOAT x, TZ_FLOAT y,
- const std::string & color = "#000000",
- TZ_INT size = 2, TZ_INT thickness = 1,
- std::string backgroundColor = "") :
- Text(text), TextLTX(x), TextLTY(y), TextColor(color),
- TextSize(size), TextThickness(thickness),
- BackgroundColor(backgroundColor) {}
- TextInfo(const TextInfo & origin) :
- Text(origin.Text), TextLTX(origin.TextLTX),
- TextLTY(origin.TextLTY), TextColor(origin.TextColor),
- TextSize(origin.TextSize), TextThickness(origin.TextThickness),
- BackgroundColor(origin.BackgroundColor) {}
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "Text", Text);
- tzc::json::setFiled(document, "TextLTX", TextLTX);
- tzc::json::setFiled(document, "TextLTY", TextLTY);
- tzc::json::setFiled(document, "TextColor", TextColor);
- tzc::json::setFiled(document, "TextSize", TextSize);
- tzc::json::setFiled(document, "TextThickness", TextThickness);
- tzc::json::setFiled(document, "BackgroundColor", BackgroundColor);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, TextInfo & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return FALSE;
- }
- value.Text = tzc::json::getFiled(document, "Text", "");
- value.TextLTX = tzc::json::getFiled(document, "TextLTX", 0.0f);
- value.TextLTY = tzc::json::getFiled(document, "TextLTY", 0.0f);
- value.TextColor = tzc::json::getFiled(document, "TextColor", "#000000");
- value.TextSize = tzc::json::getFiled(document, "TextSize", 0);
- value.TextThickness = tzc::json::getFiled(document, "TextThickness", 0);
- value.BackgroundColor = tzc::json::getFiled(document, "BackgroundColor", "");
- return TRUE;
- }
- };
- struct RectInfo {
- TZ_FLOAT LTX;
- TZ_FLOAT LTY;
- TZ_FLOAT RBX;
- TZ_FLOAT RBY;
- std::string Color;
- TZ_INT Thickness;
- TextInfo Text;
- RectInfo() : LTX(-1), LTY(-1), RBX(-1), RBY(-1),
- Color("#000000"), Thickness(1), Text(TextInfo()) {}
- RectInfo(TZ_FLOAT x1, TZ_FLOAT y1, TZ_FLOAT x2, TZ_FLOAT y2,
- const std::string & color = "#000000", TZ_INT thickness = 1,
- const TextInfo & text = TextInfo()) :
- LTX(x1) , LTY(y1), RBX(x2), RBY(y2), Color(color),
- Thickness(thickness), Text(text) {}
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "LTX", LTX);
- tzc::json::setFiled(document, "LTY", LTY);
- tzc::json::setFiled(document, "RBX", RBX);
- tzc::json::setFiled(document, "RBY", RBY);
- tzc::json::setFiled(document, "Color", Color);
- tzc::json::setFiled(document, "Thickness", Thickness);
- tzc::json::setFiledParams(document, "Text", Text);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, RectInfo & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return FALSE;
- }
- value.LTX = tzc::json::getFiled(document, "LTX", 0.0f);
- value.LTY = tzc::json::getFiled(document, "LTY", 0.0f);
- value.RBX = tzc::json::getFiled(document, "RBX", 0.0f);
- value.RBY = tzc::json::getFiled(document, "RBY", 0.0f);
- value.Color = tzc::json::getFiled(document, "Color", "#000000");
- value.Thickness = tzc::json::getFiled(document, "Thickness", 0);
- tzc::json::getFiledParams(document, "Text", value.Text);
- return TRUE;
- }
- };
- struct PointInfo {
- TZ_FLOAT X;
- TZ_FLOAT Y;
- std::string Color;
- TZ_INT Thickness;
- TZ_INT Shape;
- TextInfo Text;
- PointInfo() : X(-1), Y(-1), Color("#000000"), Thickness(0),
- Shape(-1), Text(TextInfo()) {}
- PointInfo(TZ_FLOAT x, TZ_FLOAT y,
- const std::string & color = "#000000",
- TZ_INT thickness = 0, TZ_INT shape = 0,
- const TextInfo & text = TextInfo()) :
- X(x), Y(y), Color(color),
- Thickness(thickness), Shape(shape), Text(text) {}
-
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "X", X);
- tzc::json::setFiled(document, "Y", Y);
- tzc::json::setFiled(document, "Color", Color);
- tzc::json::setFiled(document, "Thickness", Thickness);
- tzc::json::setFiled(document, "Shape", Shape);
- tzc::json::setFiledParams(document, "Text", Text);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, PointInfo & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return FALSE;
- }
- value.X = tzc::json::getFiled(document, "X", 0.0f);
- value.Y = tzc::json::getFiled(document, "Y", 0.0f);
- value.Color = tzc::json::getFiled(document, "Color", "#000000");
- value.Thickness = tzc::json::getFiled(document, "Thickness", 0);
- value.Shape = tzc::json::getFiled(document, "Shape", 0);
- tzc::json::getFiledParams(document, "Text", value.Text);
- return TRUE;
- }
- };
- struct LineInfo {
- TZ_FLOAT StartX;
- TZ_FLOAT StartY;
- TZ_FLOAT EndX;
- TZ_FLOAT EndY;
- std::string Color;
- TZ_INT Thickness;
- TZ_INT Shape;
- TextInfo Text;
- LineInfo() : StartX(-1), StartY(-1), EndX(-1), EndY(-1),
- Color("#000000"), Thickness(0),
- Shape(-1), Text(TextInfo()) {}
- LineInfo(TZ_FLOAT x1, TZ_FLOAT y1, TZ_FLOAT x2, TZ_FLOAT y2,
- const std::string & color = "#000000",
- TZ_INT thickness = 0, TZ_INT shape = 0,
- const TextInfo & text = TextInfo()) :
- StartX(x1), StartY(y1), EndX(x2), EndY(y2), Color(color),
- Thickness(thickness), Shape(shape), Text(text) {}
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "StartX", StartX);
- tzc::json::setFiled(document, "StartY", StartY);
- tzc::json::setFiled(document, "EndX", EndX);
- tzc::json::setFiled(document, "EndY", EndY);
- tzc::json::setFiled(document, "Color", Color);
- tzc::json::setFiled(document, "Thickness", Thickness);
- tzc::json::setFiled(document, "Shape", Shape);
- tzc::json::setFiledParams(document, "Text", Text);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, LineInfo & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return FALSE;
- }
- value.StartX = tzc::json::getFiled(document, "StartX", 0.0f);
- value.StartY = tzc::json::getFiled(document, "StartY", 0.0f);
- value.EndX = tzc::json::getFiled(document, "EndX", 0.0f);
- value.EndY = tzc::json::getFiled(document, "EndY", 0.0f);
- value.Color = tzc::json::getFiled(document, "Color", "#000000");
- value.Thickness = tzc::json::getFiled(document, "Thickness", 0);
- value.Shape = tzc::json::getFiled(document, "Shape", 0);
- tzc::json::getFiledParams(document, "Text", value.Text);
- return TRUE;
- }
- };
- struct DrawInfo {
- std::vector<RectInfo> Rects;
- std::vector<PointInfo> Points;
- std::vector<LineInfo> Lines;
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiledArrayObject(document, "Rects", Rects);
- tzc::json::setFiledArrayObject(document, "Points", Points);
- tzc::json::setFiledArrayObject(document, "Lines", Lines);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, DrawInfo & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return FALSE;
- }
- TZ_BOOL rst = TRUE;
- rst &= tzc::json::ConverArrayObject(document, "Rects", value.Rects);
- rst &= tzc::json::ConverArrayObject(document, "Points", value.Points);
- rst &= tzc::json::ConverArrayObject(document, "Lines", value.Lines);
- return TRUE;
- }
- void clear()
- {
- Rects.clear();
- Points.clear();
- Lines.clear();
- }
- };
- struct DetectCfg {
- TZ_INT Type; // EN_INIT_CODE
- std::string Key;
- std::string Name;
- std::string DefaultValue;
- std::string MinValue;
- std::string MaxValue;
- std::string StepValue;
- std::vector<std::string> Form; // 用于 Yolo。待改进 TODO
- DetectCfg() {}
- DetectCfg(TZ_INT type, const std::string & key, const std::string & name,
- const std::string & defaultValue, const std::string & minValue,
- const std::string & maxValue, const std::string & stepValue,
- const std::vector<std::string> & form = {}) :
- Type(type), Key(key), Name(name), DefaultValue(defaultValue),
- MinValue(minValue), MaxValue(maxValue), StepValue(stepValue),
- Form(form) {}
- DetectCfg(const DetectCfg & origin) :
- Type(origin.Type), Key(origin.Key), Name(origin.Name),
- DefaultValue(origin.DefaultValue), MinValue(origin.MinValue),
- MaxValue(origin.MaxValue), StepValue(origin.StepValue),
- Form(origin.Form) {}
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "Type", Type);
- tzc::json::setFiled(document, "Key", Key);
- tzc::json::setFiled(document, "Name", Name);
- tzc::json::setFiled(document, "DefaultValue", DefaultValue);
- tzc::json::setFiled(document, "MinValue", MinValue);
- tzc::json::setFiled(document, "MaxValue", MaxValue);
- tzc::json::setFiled(document, "StepValue", StepValue);
- tzc::json::setFiledParams(document, "Form", Form);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, DetectCfg & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return false;
- }
- value.Type = tzc::json::getFiled(document, "Type", 0);
- value.Key = tzc::json::getFiled(document, "Key", "");
- value.Name = tzc::json::getFiled(document, "Name", "");
- value.DefaultValue = tzc::json::getFiled(document, "DefaultValue", "");
- value.MinValue = tzc::json::getFiled(document, "MinValue", "");
- value.MaxValue = tzc::json::getFiled(document, "MaxValue", "");
- value.StepValue = tzc::json::getFiled(document, "StepValue", "");
- tzc::json::getFiledParams(document, "Form", value.Form);
- return TRUE;
- }
- };
- struct StraCfg {
- TZ_INT Type; // EN_INIT_CODE
- std::string Key;
- std::string Name;
-
- std::string Value;
- std::string DefaultValue;
- std::string MinValue;
- std::string MaxValue;
- std::string StepValue;
- std::string Explanation;
- StraCfg() {}
- StraCfg(TZ_INT type, const std::string & key, const std::string & name,
- const std::string & defaultvalue, const std::string & minValue,
- const std::string & maxValue, const std::string & step,
- const std::string & explanation) :
- Type(type), Key(key), Name(name), DefaultValue(defaultvalue),
- MinValue(minValue), MaxValue(maxValue), StepValue(step),
- Explanation(explanation) {}
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "Type", Type);
- tzc::json::setFiled(document, "Key", Key);
- tzc::json::setFiled(document, "Name", Name);
- tzc::json::setFiled(document, "DefaultValue", DefaultValue);
- tzc::json::setFiled(document, "MinValue", MinValue);
- tzc::json::setFiled(document, "MaxValue", MaxValue);
- tzc::json::setFiled(document, "StepValue", StepValue);
- tzc::json::setFiled(document, "Explanation", Explanation);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, StraCfg & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return FALSE;
- }
- value.Type = tzc::json::getFiled(document, "Type", 0);
- value.Key = tzc::json::getFiled(document, "Key", "");
- value.Name = tzc::json::getFiled(document, "Name", "");
- value.DefaultValue = tzc::json::getFiled(document, "DefaultValue", "");
- value.MinValue = tzc::json::getFiled(document, "MinValue", "");
- value.MaxValue = tzc::json::getFiled(document, "MaxValue", "");
- value.StepValue = tzc::json::getFiled(document, "StepValue", "");
- value.Explanation = tzc::json::getFiled(document, "Explanation", "");
- return TRUE;
- }
- };
- struct DetectorInfo {
- std::string Key;
- std::string Name;
- std::string Version;
- std::string Author;
- std::string UpdateDate;
- std::string ParamTemp; // 参数配置模板
- std::string RstTemp; // 结果模板
- std::string BuildTemp; // 创建条件模板
- std::string AreaTemp; // 检测区域设置模板
- TZ_INT Id;
- TZ_INT InputType; // 输入数据类型 EN_BUFFER_TYPE
- std::string Path;
- std::string InitParam;
- std::string Description;
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "Id", Id);
- tzc::json::setFiled(document, "InputType", InputType);
- tzc::json::setFiled(document, "Path", Path);
- tzc::json::setFiled(document, "InitParam", InitParam);
- tzc::json::setFiled(document, "Description", Description);
- tzc::json::setFiled(document, "Key", Key);
- tzc::json::setFiled(document, "Name", Name);
- tzc::json::setFiled(document, "Version", Version);
- tzc::json::setFiled(document, "Author", Author);
- tzc::json::setFiled(document, "UpdateDate", UpdateDate);
- tzc::json::setFiled(document, "ParamTemp", ParamTemp);
- tzc::json::setFiled(document, "RstTemp", RstTemp);
- tzc::json::setFiled(document, "BuildTemp", BuildTemp);
- tzc::json::setFiled(document, "AreaTemp", AreaTemp);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, DetectorInfo & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return FALSE;
- }
- value.Id = tzc::json::getFiled(document, "Id", 0);
- value.InputType = tzc::json::getFiled(document, "InputType", 0);
- value.Path = tzc::json::getFiled(document, "Path", "");
- value.InitParam = tzc::json::getFiled(document, "InitParam", "");
- value.Description = tzc::json::getFiled(document, "Description", "");
- value.Key = tzc::json::getFiled(document, "Key", "");
- value.Name = tzc::json::getFiled(document, "Name", "");
- value.Version = tzc::json::getFiled(document, "Version", "");
- value.Author = tzc::json::getFiled(document, "Author", "");
- value.UpdateDate = tzc::json::getFiled(document, "UpdateDate", "");
- value.ParamTemp = tzc::json::getFiled(document, "ParamTemp", "");
- value.RstTemp = tzc::json::getFiled(document, "RstTemp", "");
- value.BuildTemp = tzc::json::getFiled(document, "BuildTemp", "");
- value.AreaTemp = tzc::json::getFiled(document, "AreaTemp", "");
- return TRUE;
- }
- };
- struct StraDet {
-
- TZ_INT DetId;
-
- TZ_INT Idx;
- TZ_INT SIdx;
- std::string Key;
- std::string Name;
- StraDet() {}
- StraDet(TZ_INT idx, TZ_INT sidx,
- const std::string & key, const std::string & name) :
- Idx(idx), SIdx(sidx), Key(key), Name(name) {}
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "DetId", DetId);
- tzc::json::setFiled(document, "Idx", Idx);
- tzc::json::setFiled(document, "SIdx", SIdx);
- tzc::json::setFiled(document, "Key", Key);
- tzc::json::setFiled(document, "Name", Name);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, StraDet & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return FALSE;
- }
- value.DetId = tzc::json::getFiled(document, "DetId", 0);
- value.Idx = tzc::json::getFiled(document, "Idx", 0);
- value.SIdx = tzc::json::getFiled(document, "SIdx", 0);
- value.Key = tzc::json::getFiled(document, "Key", "");
- value.Name = tzc::json::getFiled(document, "Name", "");
- return TRUE;
- }
- };
- struct StraRst {
- TZ_INT RstType; // EN_STRA_RESULT
- TZ_INT SceneId;
- std::string RstName;
- std::string SceneName;
- TZ_Int64 BeginTime;
- std::string Externs;
- StraRst()
- {
- RstType = SRT_NONE;
- SceneId = -1;
- RstName = "";
- SceneName = "";
- BeginTime = 0;
- Externs = "";
- }
-
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "RstType", RstType);
- tzc::json::setFiled(document, "SceneId", SceneId);
- tzc::json::setFiled(document, "RstName", RstName);
- tzc::json::setFiled(document, "SceneName", SceneName);
- tzc::json::setFiled(document, "BeginTime", BeginTime);
- tzc::json::setFiled(document, "Externs", Externs);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, StraRst & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return FALSE;
- }
- value.RstType = tzc::json::getFiled(document, "RstType", 0);
- value.SceneId = tzc::json::getFiled(document, "SceneId", 0);
- value.RstName = tzc::json::getFiled(document, "RstName", "");
- value.SceneName = tzc::json::getFiled(document, "SceneName", "");
- value.BeginTime = tzc::json::getFiled(document, "BeginTime", 0);
- value.Externs = tzc::json::getFiled(document, "Externs", "");
- return TRUE;
- }
- };
- struct StraSamples {
- TZ_INT Type;
- std::string Name;
- StraSamples() {}
- StraSamples(TZ_INT type, const std::string & name) :
- Type(type), Name(name) {}
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "Type", Type);
- tzc::json::setFiled(document, "Name", Name);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, StraSamples & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return FALSE;
- }
- value.Type = tzc::json::getFiled(document, "Type", 0);
- value.Name = tzc::json::getFiled(document, "Name", "");
- return TRUE;
- }
- };
- struct StrategyInfo {
- std::string Key;
- std::string Name;
- std::string Version;
- std::string Author;
- std::string UpdateDate;
- std::string Description;
- std::vector<StraDet> StraDets; // 关联检测单元列表
- std::vector<StraCfg> StraCfgs; // 详细配置项模板列表
- std::vector<StraSamples> StraRsts; // 结果模板列表
- TZ_INT Id;
- std::string Path;
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "Id", Id);
- tzc::json::setFiled(document, "Path", Path);
- tzc::json::setFiled(document, "Key", Key);
- tzc::json::setFiled(document, "Name", Name);
- tzc::json::setFiled(document, "Version", Version);
- tzc::json::setFiled(document, "Author", Author);
- tzc::json::setFiled(document, "UpdateDate", UpdateDate);
- tzc::json::setFiled(document, "Description", Description);
- tzc::json::setFiledParams(document, "StraDets", StraDets);
- tzc::json::setFiledParams(document, "StraCfgs", StraCfgs);
- tzc::json::setFiledParams(document, "StraRsts", StraRsts);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, StrategyInfo & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return FALSE;
- }
- value.Id = tzc::json::getFiled(document, "Id", 0);
- value.Path = tzc::json::getFiled(document, "Path", "");
- value.Key = tzc::json::getFiled(document, "Key", "");
- value.Name = tzc::json::getFiled(document, "Name", "");
- value.Version = tzc::json::getFiled(document, "Version", "");
- value.Author = tzc::json::getFiled(document, "Author", "");
- value.UpdateDate = tzc::json::getFiled(document, "UpdateDate", "");
- value.Description = tzc::json::getFiled(document, "Description", "");
- TZ_BOOL rst = TRUE;
- rst &= tzc::json::getFiledParams(document, "StraDets", value.StraDets);
- rst &= tzc::json::getFiledParams(document, "StraCfgs", value.StraCfgs);
- rst &= tzc::json::getFiledParams(document, "StraRsts", value.StraRsts);
- return TRUE;
- }
- };
- // ROI
- struct AreaBox {
- TZ_DOUBLE LTX;
- TZ_DOUBLE LTY;
- TZ_DOUBLE RBX;
- TZ_DOUBLE RBY;
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "LTX", LTX);
- tzc::json::setFiled(document, "LTY", LTY);
- tzc::json::setFiled(document, "RBX", RBX);
- tzc::json::setFiled(document, "RBY", RBY);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, AreaBox & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return FALSE;
- }
- value.LTX = tzc::json::getFiled(document, "LTX", -1.0f);
- value.LTY = tzc::json::getFiled(document, "LTY", -1.0f);
- value.RBX = tzc::json::getFiled(document, "RBX", -1.0f);
- value.RBY = tzc::json::getFiled(document, "RBY", -1.0f);
- return TRUE;
- }
- };
- NAMESPACE_MAS_END
- #endif
|