提交 0c0a296c authored 作者: bruce.lu's avatar bruce.lu

init

上级 edc8960b
......@@ -203,6 +203,12 @@ namespace LVDB {
int getValue(string &value, string key, string fileName, cb_verify_str cb) {
int ret = 0;
DB* pdb = NULL;
if(fileName.empty()){
fileName = LVDB_FILE_GENERAL;
}
ret = _getDB(fileName, &pdb);
if(ret < 0) {
return ret;
......@@ -231,6 +237,10 @@ namespace LVDB {
}
}
if(fileName.empty()){
fileName = LVDB_FILE_GENERAL;
}
DB* pdb = NULL;
ret = _getDB(fileName, &pdb);
if(ret < 0) {
......
......@@ -67,10 +67,27 @@ class HttpSrv{
try{
json newConfig = json::parse(req.body);
if(newConfig.count("data") == 0 || newConfig["data"].size() == 0) {
ret["code"] = 1;
ret["msg"] = "evcloudsvc invalid config body received: " + req.body;
spdlog::error(ret["msg"]);
}else{
//LVDB::setLocalConfig(newConfig);
//this->configMap = newConfig;
json &data = newConfig["data"];
for(auto &[k, v]: data.items()) {
if(v.count(k) == 0||v[k].size()==0) {
ret["code"] = 2;
ret["msg"] = "evcloudsvc invalid value for key " + k;
spdlog::error(ret["msg"]);
}else{
//
LVDB::setLocalConfig(v, k);
this->configMap[k]=v;
LVDB::setValue(this->configMap, "configmap")
}
}
LVDB::setLocalConfig(newConfig);
this->configMap = newConfig;
}
// TODO: restart other components
//
......
......@@ -37,7 +37,8 @@ using namespace std;
using namespace zmqhelper;
#define URLOUT_DEFAULT "frames"
#define NUM_PKT_IGNORE 18*2
#define NUM_PKT_IGNORE 18*10
#define FRAME_SIZE 500
#define DEBUG
......@@ -157,6 +158,7 @@ private:
pullerGid = evpuller["sn"].get<string>() + ":evpuller:" + to_string(evpuller["iid"]);
mgrSn = evmgr["sn"];
// TODO: connect to the first slicer
json evslicer = ipc["modules"]["evslicer"][0];
slicerGid = evslicer["sn"].get<string>()+":evslicer:" + to_string(evslicer["iid"]);
......@@ -166,7 +168,7 @@ private:
// TODO: multiple protocols support
if(evmlmotion.count("path") == 0) {
spdlog::warn("evslicer {} no params for path, using default: {}", selfId, URLOUT_DEFAULT);
spdlog::warn("evmlmotion {} no params for path, using default: {}", selfId, URLOUT_DEFAULT);
urlOut = URLOUT_DEFAULT;
}
else {
......@@ -179,6 +181,35 @@ private:
return -1;
}
// detection params
if(evmlmotion.count("thresh") == 0||evmlmotion["thresh"] < 10 ||evmlmotion["thresh"] >= 255) {
spdlog::warn("evmlmotion {} invalid thresh value. should be in (10,255), default to 80", selfId);
detPara.thre = 80;
}else{
detPara.thre = evmlmotion["thresh"];
}
if(evmlmotion.count("area") == 0||evmlmotion["area"] < 10 ||evmlmotion["area"] >= int(FRAME_SIZE*FRAME_SIZE)*9/10) {
spdlog::warn("evmlmotion {} invalid area value. should be in (10, 500*500*/10), default to 500", selfId);
detPara.area = FRAME_SIZE;
}else{
detPara.area = evmlmotion["area"];
}
if(evmlmotion.count("pre") == 0||evmlmotion["pre"] < 1 ||evmlmotion["pre"] >= 120) {
spdlog::warn("evmlmotion {} invalid pre value. should be in (1, 120), default to 3", selfId);
detPara.pre = 3;
}else{
detPara.pre = evmlmotion["pre"];
}
if(evmlmotion.count("post") == 0||evmlmotion["post"] < 6 ||evmlmotion["post"] >= 120) {
spdlog::warn("evmlmotion {} invalid post value. should be in (6, 120), default to 30", selfId);
detPara.post = 30;
}else{
detPara.post = evmlmotion["post"];
}
// setup sub
pSubCtx = zmq_ctx_new();
pSub = zmq_socket(pSubCtx, ZMQ_SUB);
......@@ -408,7 +439,7 @@ private:
static vector<vector<cv::Point> > cnts;
cv::Mat origin, gray, thresh;
avcvhelpers::frame2mat(format, pFrame, origin);
cv::resize(origin, gray, cv::Size(500,500));
cv::resize(origin, gray, cv::Size(FRAME_SIZE,FRAME_SIZE));
cv::cvtColor(gray, thresh, cv::COLOR_BGR2GRAY);
cv::GaussianBlur(thresh, gray, cv::Size(21, 21), cv::THRESH_BINARY);
if(first) {
......@@ -430,7 +461,7 @@ private:
#endif
// TODO:
cv::threshold(thresh, gray, 25, 255, cv::THRESH_BINARY);
cv::threshold(thresh, gray, detPara.thre, 255, cv::THRESH_BINARY);
cv::dilate(gray, thresh, cv::Mat(), cv::Point(-1,-1), 2);
#ifdef DEBUG
......@@ -441,7 +472,7 @@ private:
bool hasEvent = false;
for(int i =0; i < cnts.size(); i++) {
// TODO:
if(cv::contourArea(cnts[i]) < 200) {
if(cv::contourArea(cnts[i]) < detPara.area) {
// nothing
}
else {
......
......@@ -25,10 +25,10 @@ namespace LVDB {
typedef int (*cb_verify_json)(const json&);
int setValue(const string &value, string key, string fileName, cb_verify_str cb);
int getValue(string &value, string key, string fileName, cb_verify_str cb);
int setValue(const json &value, string key, string fileName, cb_verify_json cb);
int getValue(json &value, string key, string fileName, cb_verify_json cb);
int setValue(const string &value, string key, string fileName="", cb_verify_str cb=NULL);
int getValue(string &value, string key, string fileName="", cb_verify_str cb=NULL);
int setValue(const json &value, string key, string fileName="", cb_verify_json cb=NULL);
int getValue(json &value, string key, string fileName="", cb_verify_json cb=NULL);
//
json * findConfigModule(json &config, string sn, string moduleName, int iid);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论