|
@@ -44,66 +44,65 @@ namespace gsd
|
|
|
* @return {*}
|
|
|
*/
|
|
|
void MonitorPlugin::MonitorProThrd(){
|
|
|
- // FrameInferData::Ptr result = std::make_shared<FrameInferData>();
|
|
|
- // if(!this->ConsumeData(result)) return;
|
|
|
- // if(result->Num == 0) return;
|
|
|
- // if(!app().getPlugin<TcpPlugin>()->getAlive()){
|
|
|
- // result->uuid = uuid::generate();
|
|
|
- // std::string sql = result->ObjectToSql();
|
|
|
- // SqlWriter insert(sql.c_str());
|
|
|
- // vector<vector<std::string>> ret;
|
|
|
- // insert << ret;
|
|
|
- // InfoL << "Save inferential Data, uuid:" << result->uuid << endl;
|
|
|
- // return;
|
|
|
- // }
|
|
|
-
|
|
|
- // config::Ptr m_config = config::getPtr();
|
|
|
- // // 发送鸟情数据至后端
|
|
|
- // SendBird sendBird;
|
|
|
- // sendBird.birdImageBase64 = "";
|
|
|
- // if(!config::getPtr()->debug){
|
|
|
- // sendBird.birdImageBase64 = result->ImageBase64;
|
|
|
- // }
|
|
|
- // sendBird.birdNum = result->Num;
|
|
|
- // sendBird.birdType = (NettyClientCommandEnum().bird_info);
|
|
|
+ FrameInferData::Ptr result = std::make_shared<FrameInferData>();
|
|
|
+ if(!this->ConsumeData(result)) return;
|
|
|
+ if(result->Num == 0) return;
|
|
|
+ if(!TcpPlugin::getPtr()->Alive()){
|
|
|
+ result->uuid = uuid::generate();
|
|
|
+ std::string sql = result->ObjectToSql();
|
|
|
+ SqlWriter insert(sql.c_str());
|
|
|
+ vector<vector<std::string>> ret;
|
|
|
+ insert << ret;
|
|
|
+ InfoL << "Save inferential Data, uuid:" << result->uuid << endl;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ config::Ptr m_config = config::getPtr();
|
|
|
+ // 发送鸟情数据至后端
|
|
|
+ SendBird sendBird;
|
|
|
+ sendBird.birdImageBase64 = "";
|
|
|
+ if(!config::getPtr()->debug){
|
|
|
+ sendBird.birdImageBase64 = result->ImageBase64;
|
|
|
+ }
|
|
|
+ sendBird.birdNum = result->Num;
|
|
|
+ sendBird.birdType = (NettyClientCommandEnum().bird_info);
|
|
|
|
|
|
- // if(!config::getPtr()->LowVersion) sendBird.deviceUuid = m_config->SimCode;
|
|
|
- // else sendBird.deviceUuid = m_config->vpnIP;
|
|
|
+ if(!config::getPtr()->LowVersion) sendBird.deviceUuid = m_config->SimCode;
|
|
|
+ else sendBird.deviceUuid = m_config->vpnIP;
|
|
|
|
|
|
- // sendBird.degree = 2;
|
|
|
- // sendBird.remark = result->Remark;
|
|
|
- // sendBird.heightRange = "0";
|
|
|
- // sendBird.warningTime = result->WarningTime;
|
|
|
- // sendBird.attr4 = result->VideoPath;
|
|
|
- // sendBird.attr5 = "";
|
|
|
+ sendBird.degree = 2;
|
|
|
+ sendBird.remark = result->Remark;
|
|
|
+ sendBird.heightRange = "0";
|
|
|
+ sendBird.warningTime = result->WarningTime;
|
|
|
+ sendBird.attr4 = result->VideoPath;
|
|
|
+ sendBird.attr5 = "";
|
|
|
|
|
|
- // HistoryVideo historyVideo;
|
|
|
- // historyVideo.fileName = result->VideoPath;
|
|
|
- // historyVideo.UpdateTime = result->WarningTime;
|
|
|
- // this->SaveVideoRecord(historyVideo);
|
|
|
+ HistoryVideo historyVideo;
|
|
|
+ historyVideo.fileName = result->VideoPath;
|
|
|
+ historyVideo.UpdateTime = result->WarningTime;
|
|
|
+ this->SaveVideoRecord(historyVideo);
|
|
|
|
|
|
- // NettyClientResultMsg <SendBird> nettyClientResultMsg;
|
|
|
- // std::string RequestId = uuid::generate();
|
|
|
- // result->uuid = RequestId;
|
|
|
- // nettyClientResultMsg.setRequestId(RequestId);
|
|
|
- // nettyClientResultMsg.setData(sendBird);
|
|
|
- // nettyClientResultMsg.setDataType((NettyClientCommandEnum().bird_info));
|
|
|
+ NettyClientResultMsg <SendBird> nettyClientResultMsg;
|
|
|
+ std::string RequestId = uuid::generate();
|
|
|
+ result->uuid = RequestId;
|
|
|
+ nettyClientResultMsg.setRequestId(RequestId);
|
|
|
+ nettyClientResultMsg.setData(sendBird);
|
|
|
+ nettyClientResultMsg.setDataType((NettyClientCommandEnum().bird_info));
|
|
|
|
|
|
- // std::string json;
|
|
|
- // nettyClientResultMsg.objectToJson(json);
|
|
|
- // json += "\r\n";
|
|
|
- // std::string sql = result->ObjectToSql();
|
|
|
+ std::string json;
|
|
|
+ nettyClientResultMsg.objectToJson(json);
|
|
|
+ json += "\r\n";
|
|
|
+ std::string sql = result->ObjectToSql();
|
|
|
|
|
|
- // if(app().getPlugin<TcpPlugin>()->getAlive()){
|
|
|
- // app().getPlugin<TcpPlugin>()->sendRequest(RequestId, NettyClientCommandEnum().bird_info, json, [&, sql](int status,std::string pbuf){
|
|
|
- // if(!config::getPtr()->LowVersion){
|
|
|
- // if(status == 200) return;
|
|
|
- // SqlWriter insert(sql.c_str());
|
|
|
- // vector<vector<std::string>> ret;
|
|
|
- // insert << ret;
|
|
|
- // }
|
|
|
- // });
|
|
|
- // }
|
|
|
+ if(TcpPlugin::getPtr()->Alive()){
|
|
|
+ TcpPlugin::getPtr()->sendRequest(RequestId, NettyClientCommandEnum().bird_info, json, [&, sql](int status,std::string pbuf){
|
|
|
+ if(!config::getPtr()->LowVersion){
|
|
|
+ if(status == 200) return;
|
|
|
+ SqlWriter insert(sql.c_str());
|
|
|
+ vector<vector<std::string>> ret;
|
|
|
+ insert << ret;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -112,107 +111,106 @@ namespace gsd
|
|
|
* @return {*}
|
|
|
*/
|
|
|
bool MonitorPlugin::sendRequest(CNStreamInferData::Ptr data){
|
|
|
- // FrameInferData::Ptr result = std::make_shared<FrameInferData>();
|
|
|
- // InfineFilter::Ptr infineFilter = InfineFilter::getPtr();
|
|
|
- // config::Ptr m_config = config::getPtr();
|
|
|
-
|
|
|
- // if(!config::getPtr()->debug){
|
|
|
- // infineFilter->bboxSize = m_config->bboxSize;
|
|
|
- // // 设置
|
|
|
- // infineFilter->setSensitivity(m_config->sensitivity);
|
|
|
- // infineFilter->setInterval(m_config->interval);
|
|
|
- // infineFilter->setTimeOut(m_config->TimeOut);
|
|
|
- // if(infineFilter != nullptr) {
|
|
|
- // if(infineFilter->judgementResult(data) != OK){
|
|
|
- // return false;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
-
|
|
|
- // rapidjson::StringBuffer buffer;
|
|
|
- // rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
|
|
|
- // writer.StartArray();
|
|
|
- // for(auto &obj : data->Objects)
|
|
|
- // {
|
|
|
- // writer.StartObject();
|
|
|
- // writer.Key("x");
|
|
|
- // writer.Double(obj.BBox.x * 1920);
|
|
|
- // writer.Key("y");
|
|
|
- // writer.Double(obj.BBox.y * 1080);
|
|
|
- // writer.Key("width");
|
|
|
- // writer.Double(obj.BBox.w * 1920);
|
|
|
- // writer.Key("height");
|
|
|
- // writer.Double(obj.BBox.h * 1080);
|
|
|
- // writer.EndObject();
|
|
|
- // }
|
|
|
- // writer.EndArray();
|
|
|
- // // 获取时间
|
|
|
- // char ctime[80];
|
|
|
- // time_t rawtime;
|
|
|
- // struct tm *info;
|
|
|
- // time(&rawtime);
|
|
|
- // info = localtime(&rawtime);
|
|
|
- // strftime(ctime, 80, "%Y-%m-%d %H:%M:%S", info);
|
|
|
- // result->ClassId = 1;
|
|
|
- // result->ImageBase64 = data->ImageBase64;
|
|
|
- // result->Remark = buffer.GetString();
|
|
|
- // result->Num = data->Objects.size();
|
|
|
- // result->WarningTime = ctime;
|
|
|
- // result->VideoPath = data->videoPath;
|
|
|
- // if(result->Num == 0) return false;
|
|
|
+ FrameInferData::Ptr result = std::make_shared<FrameInferData>();
|
|
|
+ InfineFilter::Ptr infineFilter = InfineFilter::getPtr();
|
|
|
+ config::Ptr m_config = config::getPtr();
|
|
|
+ if(!config::getPtr()->debug){
|
|
|
+ infineFilter->bboxSize = m_config->bboxSize;
|
|
|
+ // 设置
|
|
|
+ infineFilter->setFilterLevel(m_config->filterLevel);
|
|
|
+ infineFilter->setInterval(m_config->interval);
|
|
|
+ infineFilter->setTimeOut(m_config->TimeOut);
|
|
|
+ if(infineFilter != nullptr) {
|
|
|
+ if(infineFilter->judgementResult(data) != OK){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ rapidjson::StringBuffer buffer;
|
|
|
+ rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
|
|
|
+ writer.StartArray();
|
|
|
+ for(auto &obj : data->Objects)
|
|
|
+ {
|
|
|
+ writer.StartObject();
|
|
|
+ writer.Key("x");
|
|
|
+ writer.Double(obj.BBox.x * 1920);
|
|
|
+ writer.Key("y");
|
|
|
+ writer.Double(obj.BBox.y * 1080);
|
|
|
+ writer.Key("width");
|
|
|
+ writer.Double(obj.BBox.w * 1920);
|
|
|
+ writer.Key("height");
|
|
|
+ writer.Double(obj.BBox.h * 1080);
|
|
|
+ writer.EndObject();
|
|
|
+ }
|
|
|
+ writer.EndArray();
|
|
|
+ // 获取时间
|
|
|
+ char ctime[80];
|
|
|
+ time_t rawtime;
|
|
|
+ struct tm *info;
|
|
|
+ time(&rawtime);
|
|
|
+ info = localtime(&rawtime);
|
|
|
+ strftime(ctime, 80, "%Y-%m-%d %H:%M:%S", info);
|
|
|
+ result->ClassId = 1;
|
|
|
+ result->ImageBase64 = data->ImageBase64;
|
|
|
+ result->Remark = buffer.GetString();
|
|
|
+ result->Num = data->Objects.size();
|
|
|
+ result->WarningTime = ctime;
|
|
|
+ result->VideoPath = data->videoPath;
|
|
|
+ if(result->Num == 0) return false;
|
|
|
|
|
|
- // if(!app().getPlugin<TcpPlugin>()->getAlive()){
|
|
|
- // result->uuid = uuid::generate();
|
|
|
- // std::string sql = result->ObjectToSql();
|
|
|
- // SqlWriter insert(sql.c_str());
|
|
|
- // vector<vector<std::string>> ret;
|
|
|
- // insert << ret;
|
|
|
- // return true;
|
|
|
- // }
|
|
|
- // // 发送鸟情数据至后端
|
|
|
- // SendBird sendBird;
|
|
|
- // sendBird.birdImageBase64 = "";
|
|
|
- // if(!config::getPtr()->debug){
|
|
|
- // sendBird.birdImageBase64 = result->ImageBase64;
|
|
|
- // }
|
|
|
- // sendBird.birdNum = result->Num;
|
|
|
- // sendBird.birdType = (NettyClientCommandEnum().bird_info);
|
|
|
- // sendBird.deviceUuid = "";
|
|
|
+ if(!TcpPlugin::getPtr()->Alive()){
|
|
|
+ result->uuid = uuid::generate();
|
|
|
+ std::string sql = result->ObjectToSql();
|
|
|
+ SqlWriter insert(sql.c_str());
|
|
|
+ vector<vector<std::string>> ret;
|
|
|
+ insert << ret;
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ // 发送鸟情数据至后端
|
|
|
+ SendBird sendBird;
|
|
|
+ sendBird.birdImageBase64 = "";
|
|
|
+ if(!config::getPtr()->debug){
|
|
|
+ sendBird.birdImageBase64 = result->ImageBase64;
|
|
|
+ }
|
|
|
+ sendBird.birdNum = result->Num;
|
|
|
+ sendBird.birdType = (NettyClientCommandEnum().bird_info);
|
|
|
+ sendBird.deviceUuid = "";
|
|
|
|
|
|
- // if(!config::getPtr()->LowVersion) sendBird.deviceUuid = config::getPtr()->getSimCode();
|
|
|
- // else sendBird.deviceUuid = config::getPtr()->vpnIP;
|
|
|
+ if(!config::getPtr()->LowVersion) sendBird.deviceUuid = config::getPtr()->getSimCode();
|
|
|
+ else sendBird.deviceUuid = config::getPtr()->vpnIP;
|
|
|
|
|
|
- // sendBird.degree = 2;
|
|
|
- // sendBird.remark = result->Remark;
|
|
|
- // sendBird.heightRange = "0";
|
|
|
- // sendBird.warningTime = result->WarningTime;
|
|
|
- // sendBird.attr4 = result->VideoPath;
|
|
|
- // sendBird.attr5 = "";
|
|
|
- // HistoryVideo historyVideo;
|
|
|
- // historyVideo.fileName = result->VideoPath;
|
|
|
- // historyVideo.UpdateTime = result->WarningTime;
|
|
|
- // this->SaveVideoRecord(historyVideo);
|
|
|
+ sendBird.degree = 2;
|
|
|
+ sendBird.remark = result->Remark;
|
|
|
+ sendBird.heightRange = "0";
|
|
|
+ sendBird.warningTime = result->WarningTime;
|
|
|
+ sendBird.attr4 = result->VideoPath;
|
|
|
+ sendBird.attr5 = "";
|
|
|
+ HistoryVideo historyVideo;
|
|
|
+ historyVideo.fileName = result->VideoPath;
|
|
|
+ historyVideo.UpdateTime = result->WarningTime;
|
|
|
+ this->SaveVideoRecord(historyVideo);
|
|
|
|
|
|
- // NettyClientResultMsg <SendBird> nettyClientResultMsg;
|
|
|
- // std::string RequestId = uuid::generate();
|
|
|
- // result->uuid = RequestId;
|
|
|
- // nettyClientResultMsg.setRequestId(RequestId);
|
|
|
- // nettyClientResultMsg.setData(sendBird);
|
|
|
- // nettyClientResultMsg.setDataType((NettyClientCommandEnum().bird_info));
|
|
|
- // std::string json;
|
|
|
- // nettyClientResultMsg.objectToJson(json);
|
|
|
- // json += "\r\n";
|
|
|
- // std::string sql = result->ObjectToSql();
|
|
|
- // if(app().getPlugin<TcpPlugin>()->getAlive()){
|
|
|
- // app().getPlugin<TcpPlugin>()->sendRequest(RequestId, NettyClientCommandEnum().bird_info, json, [&, sql](int status,std::string pbuf){
|
|
|
- // if(!config::getPtr()->debug){
|
|
|
- // if(status == 200) return;
|
|
|
- // SqlWriter insert(sql.c_str());
|
|
|
- // vector<vector<std::string>> ret;
|
|
|
- // insert << ret;
|
|
|
- // }
|
|
|
- // });
|
|
|
- // }else ErrorL;
|
|
|
+ NettyClientResultMsg <SendBird> nettyClientResultMsg;
|
|
|
+ std::string RequestId = uuid::generate();
|
|
|
+ result->uuid = RequestId;
|
|
|
+ nettyClientResultMsg.setRequestId(RequestId);
|
|
|
+ nettyClientResultMsg.setData(sendBird);
|
|
|
+ nettyClientResultMsg.setDataType((NettyClientCommandEnum().bird_info));
|
|
|
+ std::string json;
|
|
|
+ nettyClientResultMsg.objectToJson(json);
|
|
|
+ json += "\r\n";
|
|
|
+ std::string sql = result->ObjectToSql();
|
|
|
+ if(TcpPlugin::getPtr()->Alive()){
|
|
|
+ TcpPlugin::getPtr()->sendRequest(RequestId, NettyClientCommandEnum().bird_info, json, [&, sql](int status,std::string pbuf){
|
|
|
+ if(!config::getPtr()->debug){
|
|
|
+ if(status == 200) return;
|
|
|
+ SqlWriter insert(sql.c_str());
|
|
|
+ vector<vector<std::string>> ret;
|
|
|
+ insert << ret;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }else ErrorL;
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -252,6 +250,7 @@ namespace gsd
|
|
|
* @return {*}
|
|
|
*/
|
|
|
void MonitorPlugin::Destroy(){
|
|
|
+ InfoL;
|
|
|
stop_ = true;
|
|
|
}
|
|
|
|