123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- #ifndef __ABANDCLIP_CFG_H
- #define __ABANDCLIP_CFG_H
- #include "MAS_AlgoDef.h"
- #define NAMESPACE_ABANDCLIP_BEGIN namespace abandclip {
- #define NAMESPACE_ABANDCLIP_END };
- NAMESPACE_MAS_BEGIN
- NAMESPACE_ABANDCLIP_BEGIN
- struct DataItem {
- TZ_FLOAT val;
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "val", val);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string& json, DataItem& value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return FALSE;
- }
- value.val = tzc::json::getFiled(document, "val", 0.0f);
- return TRUE;
- }
- };
- struct TextFeature {
- std::string text;
- std::vector<DataItem> features;
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "text", text);
- tzc::json::setFiledArrayObject(document, "features", features);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, TextFeature & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return false;
- }
- value.text = tzc::json::getFiled(document, "text", "");
- TZ_BOOL rst = TRUE;
- rst &= tzc::json::ConverArrayObject(document, "features", value.features);
- return true;
- }
- };
- struct AbandClipCfg {
-
- TZ_DOUBLE FeatureThreshold;
- std::string FeatureFilePath;
- AbandClipCfg() : FeatureThreshold(10.0){}
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "FeatureThreshold", FeatureThreshold);
- tzc::json::setFiled(document, "FeatureFilePath", FeatureFilePath);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, AbandClipCfg & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return false;
- }
- value.FeatureThreshold = tzc::json::getFiled(document, "FeatureThreshold", 10.0);
- value.FeatureFilePath = tzc::json::getFiled(document, "FeatureFilePath", "");
- return true;
- }
- };
- struct AbandClipStrategyExterns {
- std::string Description;
- AbandClipStrategyExterns() : Description("") {}
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "Description", Description);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, AbandClipStrategyExterns & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return false;
- }
- value.Description = tzc::json::getFiled(document, "Description", "");
- return true;
- }
- };
- NAMESPACE_ABANDCLIP_END
- NAMESPACE_MAS_END
- #endif
|