入侵算修改为法人数一致才报警,靠右行增加容忍时间,编辑设备接口修改,人员静止灵敏度调整
| | |
| | | ../../BasicPlatForm/libs/libuuid/include |
| | | ) |
| | | |
| | | #add_subdirectory(StructureApp) |
| | | add_subdirectory(StructureApp) |
| | | add_subdirectory(FaceDetectServer) |
| | | add_subdirectory(YoloServer) |
| | | add_subdirectory(FaceSearchServer) |
| | |
| | | /*sdk login*/ |
| | | ulRet = IMOS_MW_Login(username, passwd, ip, 0, szUserID); |
| | | if (ERR_COMMON_SUCCEED != ulRet) { |
| | | (VOID) IMOS_MW_Cleanup(); |
| | | printf("Login error ulRet[%lu]", ulRet); |
| | | return false; |
| | | } |
| | |
| | | pstBasicInfo = (IMOS_MW_BASIC_DEVICE_INFO_S *) malloc(sizeof(IMOS_MW_BASIC_DEVICE_INFO_S)); |
| | | ulRet = IMOS_MW_GetDeviceStatus(szUserID, 0, IMOS_MW_STATUS_BASIC_INFO, (void *) pstBasicInfo); |
| | | if (ERR_COMMON_SUCCEED != ulRet) { |
| | | (VOID) IMOS_MW_Logout(szUserID); |
| | | (VOID) IMOS_MW_Cleanup(); |
| | | printf("GetDeviceStatus Error[%lu]\n", ulRet); |
| | | return false; |
| | | } |
| | |
| | | { |
| | | if(is_exist) |
| | | { |
| | | return "{\"ret_status\": \"内容有误,请检查!\"}"; |
| | | return "{\"ret_status\": \"请勿重复添加!\"}"; |
| | | } |
| | | else |
| | | { |
| | |
| | | std::string pass = value["str_password"].asString(); |
| | | std::string brand = value["str_brand"].asString(); |
| | | std::string rtsp_url = rtspAddrBuild(ip, port, username, pass, brand); |
| | | if (rtsp_url.empty()) { |
| | | if (rtsp_url.empty() ) |
| | | { |
| | | return "{\"ret_status\":\"内容有误,请检查!\"}"; |
| | | } |
| | | // unsigned char serialnumber[SERIALNO_LEN] = {0}; |
| | | // int ret = getDevSerialNumber(ip.c_str(), port,username.c_str(),pass.c_str(),brand.c_str(),serialnumber); |
| | | |
| | | |
| | | // if ((!ret) || (serialnumber[0] == 0)) |
| | | // { |
| | | // return "{\"ret_status\": \"内容有误,请检查!\"}"; |
| | | // } |
| | | |
| | | // std::string str_cam_dev_id = std::string((char *) serialnumber);//摄像机id cam_mac |
| | | |
| | | std::string str_imgName = appConfig.getStringProperty("cutPath"); |
| | | if (str_imgName.back() != '/') { |
| | | str_imgName.push_back('/'); |
| | | } |
| | | str_imgName +=ip; |
| | | str_imgName +="-"; |
| | | str_imgName += "snapshot.jpg"; |
| | | //admin:a1234567@192.168.1.201:554/h264/ch1/main/av_stream -r 1/25 -f image2 -s 1920*1080 /home/basic/work_src/a.jpg |
| | | std::string cmd("ffmpeg -i " + rtsp_url + " -r 1/25 -f image2 -s 1920*1080 -y " + str_imgName); |
| | |
| | | lastDown = 0; |
| | | triggerType = DOWN; |
| | | } |
| | | void TriggerElement::resetTriggerState() |
| | | { |
| | | |
| | | //state=false; |
| | | triggerState=false; |
| | | triggerTimes=0; |
| | | } |
| | | |
| | | void TriggerElement::timerFunc() { |
| | | |
| | |
| | | |
| | | bool getTriggerState() const; |
| | | |
| | | void resetTriggerState(); |
| | | |
| | | private: |
| | | bool state; |
| | | bool triggerState; |
| | |
| | | mutex.lock(); |
| | | cv::Mat imageTemp = videoCaptureElement.getImage(); |
| | | |
| | | std::string strNewTime; |
| | | strNewTime = AppUtil::getTimeUSecString(); |
| | | |
| | | std::string strNewTime = AppUtil::getTimeUSecString();; |
| | | mutex.unlock(); |
| | | //DBG("m_camId="<<m_camId<<" strNewTime="<<strNewTime); |
| | | // cv::putText(imageTemp, strNewTime, cv::Point(408, 540), cv::HersheyFonts::FONT_HERSHEY_PLAIN, 5, |
| | | // cv::Scalar(255, 255, 0), 2); |
| | | if (m_camId.size() > 0) { |
| | |
| | | imageDrawElement.setImage(imageTemp); |
| | | imageDrawElement.submit(); |
| | | } |
| | | mutex.unlock(); |
| | | |
| | | // if (bRecordVideoEnable) { |
| | | // registerElement(triggerElement); |
| | | // } |
| | |
| | | { |
| | | leftJudgment.setYoloObjects(yoloRpcElement.getLastScoreRects()); |
| | | leftJudgment.setImage(yoloRpcElement.getImage()); |
| | | leftJudgment.submit(); |
| | | } |
| | | if(!rightJudgment.isBusy()) |
| | | { |
| | | rightJudgment.setYoloObjects(yoloRpcElement.getLastScoreRects()); |
| | | |
| | | rightJudgment.setImage(yoloRpcElement.getImage()); |
| | | rightJudgment.submit(); |
| | | } |
| | | |
| | | }); |
| | |
| | | HiredisTool.cpp |
| | | PersonElement.cpp |
| | | PerStaticElement.cpp |
| | | IntAreaCalcUtil.cpp |
| | | |
| | | TrackingTrigger.cpp |
| | | FaceRpcElement.cpp |
New file |
| | |
| | | #include "IntAreaCalcUtil.h" |
| | | |
New file |
| | |
| | | #ifndef INTAREACALCUTIL_H |
| | | #define INTAREACALCUTIL_H |
| | | #include <iostream> |
| | | #include <vector> |
| | | #include <map> |
| | | using namespace std; |
| | | struct Point |
| | | { |
| | | Point(){} |
| | | Point(int x1,int y1) |
| | | { |
| | | x=x1; |
| | | y=y1; |
| | | } |
| | | int x; |
| | | int y; |
| | | }; |
| | | class IntAreaCalcUtil |
| | | { |
| | | |
| | | |
| | | public: |
| | | //若点a大于点b,即点a在点b顺时针方向,返回true,否则返回false |
| | | static bool PointCmp(const Point &a,const Point &b,const Point ¢er) |
| | | { |
| | | if (a.x >= 0 && b.x < 0) |
| | | return true; |
| | | if (a.x == 0 && b.x == 0) |
| | | return a.y > b.y; |
| | | //向量OA和向量OB的叉积 |
| | | int det = (a.x - center.x) * (b.y - center.y) - (b.x - center.x) * (a.y - center.y); |
| | | if (det < 0) |
| | | return true; |
| | | if (det > 0) |
| | | return false; |
| | | //向量OA和向量OB共线,以距离判断大小 |
| | | int d1 = (a.x - center.x) * (a.x - center.x) + (a.y - center.y) * (a.y - center.y); |
| | | int d2 = (b.x - center.x) * (b.x - center.y) + (b.y - center.y) * (b.y - center.y); |
| | | return d1 > d2; |
| | | } |
| | | static void ClockwiseSortPoints(std::vector<Point> &vPoints) |
| | | { |
| | | //计算重心 |
| | | Point center; |
| | | double x = 0,y = 0; |
| | | for (int i = 0;i < vPoints.size();i++) |
| | | { |
| | | x += vPoints[i].x; |
| | | y += vPoints[i].y; |
| | | } |
| | | center.x = (int)x/vPoints.size(); |
| | | center.y = (int)y/vPoints.size(); |
| | | |
| | | //冒泡排序 |
| | | for(int i = 0;i < vPoints.size() - 1;i++) |
| | | { |
| | | for (int j = 0;j < vPoints.size() - i - 1;j++) |
| | | { |
| | | if (PointCmp(vPoints[j],vPoints[j+1],center)) |
| | | { |
| | | Point tmp = vPoints[j]; |
| | | vPoints[j] = vPoints[j + 1]; |
| | | vPoints[j + 1] = tmp; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | // The function will return YES if the point x,y is inside the polygon, or |
| | | // NO if it is not. If the point is exactly on the edge of the polygon, |
| | | // then the function may return YES or NO. |
| | | static bool IsPointInPolygon(std::vector<Point> poly,Point pt) |
| | | { |
| | | int i,j; |
| | | bool c = false; |
| | | for (i = 0,j = poly.size() - 1;i < poly.size();j = i++) |
| | | { |
| | | if ((((poly[i].y <= pt.y) && (pt.y < poly[j].y)) || |
| | | ((poly[j].y <= pt.y) && (pt.y < poly[i].y))) |
| | | && (pt.x < (poly[j].x - poly[i].x) * (pt.y - poly[i].y)/(poly[j].y - poly[i].y) + poly[i].x)) |
| | | { |
| | | c = !c; |
| | | } |
| | | } |
| | | return c; |
| | | } |
| | | //排斥实验 |
| | | static bool IsRectCross(const Point &p1,const Point &p2,const Point &q1,const Point &q2) |
| | | { |
| | | bool ret = min(p1.x,p2.x) <= max(q1.x,q2.x) && |
| | | min(q1.x,q2.x) <= max(p1.x,p2.x) && |
| | | min(p1.y,p2.y) <= max(q1.y,q2.y) && |
| | | min(q1.y,q2.y) <= max(p1.y,p2.y); |
| | | return ret; |
| | | } |
| | | //跨立判断 |
| | | static bool IsLineSegmentCross(const Point &pFirst1,const Point &pFirst2,const Point &pSecond1,const Point &pSecond2) |
| | | { |
| | | long line1,line2; |
| | | line1 = pFirst1.x * (pSecond1.y - pFirst2.y) + |
| | | pFirst2.x * (pFirst1.y - pSecond1.y) + |
| | | pSecond1.x * (pFirst2.y - pFirst1.y); |
| | | line2 = pFirst1.x * (pSecond2.y - pFirst2.y) + |
| | | pFirst2.x * (pFirst1.y - pSecond2.y) + |
| | | pSecond2.x * (pFirst2.y - pFirst1.y); |
| | | if (((line1 ^ line2) >= 0) && !(line1 == 0 && line2 == 0)) |
| | | return false; |
| | | |
| | | line1 = pSecond1.x * (pFirst1.y - pSecond2.y) + |
| | | pSecond2.x * (pSecond1.y - pFirst1.y) + |
| | | pFirst1.x * (pSecond2.y - pSecond1.y); |
| | | line2 = pSecond1.x * (pFirst2.y - pSecond2.y) + |
| | | pSecond2.x * (pSecond1.y - pFirst2.y) + |
| | | pFirst2.x * (pSecond2.y - pSecond1.y); |
| | | if (((line1 ^ line2) >= 0) && !(line1 == 0 && line2 == 0)) |
| | | return false; |
| | | return true; |
| | | } |
| | | |
| | | static bool GetCrossPoint(const Point &p1,const Point &p2,const Point &q1,const Point &q2,long &x,long &y) |
| | | { |
| | | if(IsRectCross(p1,p2,q1,q2)) |
| | | { |
| | | if (IsLineSegmentCross(p1,p2,q1,q2)) |
| | | { |
| | | //求交点 |
| | | long tmpLeft,tmpRight; |
| | | tmpLeft = (q2.x - q1.x) * (p1.y - p2.y) - (p2.x - p1.x) * (q1.y - q2.y); |
| | | tmpRight = (p1.y - q1.y) * (p2.x - p1.x) * (q2.x - q1.x) + q1.x * (q2.y - q1.y) * (p2.x - p1.x) - p1.x * (p2.y - p1.y) * (q2.x - q1.x); |
| | | |
| | | x = (int)((double)tmpRight/(double)tmpLeft); |
| | | |
| | | tmpLeft = (p1.x - p2.x) * (q2.y - q1.y) - (p2.y - p1.y) * (q1.x - q2.x); |
| | | tmpRight = p2.y * (p1.x - p2.x) * (q2.y - q1.y) + (q2.x- p2.x) * (q2.y - q1.y) * (p1.y - p2.y) - q2.y * (q1.x - q2.x) * (p2.y - p1.y); |
| | | y = (int)((double)tmpRight/(double)tmpLeft); |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | static bool PolygonClip(const vector<Point> &poly1,const vector<Point> &poly2, std::vector<Point> &interPoly) |
| | | { |
| | | if (poly1.size() < 3 || poly2.size() < 3) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | long x,y; |
| | | //计算多边形交点vector<Point> poly1; |
| | | for (int i = 0;i < poly1.size();i++) |
| | | { |
| | | int poly1_next_idx = (i + 1) % poly1.size(); |
| | | for (int j = 0;j < poly2.size();j++) |
| | | { |
| | | int poly2_next_idx = (j + 1) % poly2.size(); |
| | | if (GetCrossPoint(poly1[i],poly1[poly1_next_idx], |
| | | poly2[j],poly2[poly2_next_idx], |
| | | x,y)) |
| | | { |
| | | if(x<0 || y<0) continue; |
| | | interPoly.push_back(Point(x,y)); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //计算多边形内部点 |
| | | for(int i = 0;i < poly1.size();i++) |
| | | { |
| | | if (IsPointInPolygon(poly2,poly1[i])) |
| | | { |
| | | interPoly.push_back(poly1[i]); |
| | | } |
| | | } |
| | | for (int i = 0;i < poly2.size();i++) |
| | | { |
| | | if (IsPointInPolygon(poly1,poly2[i])) |
| | | { |
| | | interPoly.push_back(poly2[i]); |
| | | } |
| | | } |
| | | |
| | | if(interPoly.size() <= 0) |
| | | return false; |
| | | |
| | | //点集排序 |
| | | ClockwiseSortPoints(interPoly); |
| | | return true; |
| | | } |
| | | static float intAreaCalc(vector<Point> &vecPoly)//求解多边形的面积(知道多边形的顶点,按顺时针或者逆时针) |
| | | { |
| | | int i_count=vecPoly.size(); |
| | | // iCycle=0; |
| | | int area_temp=0; |
| | | for(int i=0;i<i_count;i++) |
| | | { |
| | | area_temp=area_temp+(vecPoly[i].x*vecPoly[(i+1) % i_count].y-vecPoly[(i+1) % i_count].x*vecPoly[i].y); |
| | | } |
| | | return abs(area_temp*100/2); |
| | | } |
| | | |
| | | //int main() |
| | | //{ |
| | | // vector<Point> poly1; |
| | | // poly1.push_back(Point(1,0)); |
| | | // poly1.push_back(Point(1,2)); |
| | | // poly1.push_back(Point(3,0)); |
| | | // // poly1.push_back(Point(1,2)); |
| | | // vector<Point> poly2; |
| | | //// poly2.push_back(Point(2,0)); |
| | | //// poly2.push_back(Point(7,0)); |
| | | //// poly2.push_back(Point(7,5)); |
| | | //// poly2.push_back(Point(2,5)); |
| | | // poly2.push_back(Point(0,0)); |
| | | // poly2.push_back(Point(4,0)); |
| | | // poly2.push_back(Point(4,4)); |
| | | // poly2.push_back(Point(0,4)); |
| | | // vector<Point> poly3; |
| | | // PolygonClip(poly1,poly2,poly3); |
| | | // float inter = intAreaCalc(poly3); |
| | | // float total = intAreaCalc(poly2); |
| | | // int perset1 = (int)(inter / total * 100); |
| | | // if(ALARM_PERCENT <= perset) |
| | | // { |
| | | |
| | | // } |
| | | |
| | | |
| | | |
| | | |
| | | // for(int i=0;i<poly3.size();++i) |
| | | // { |
| | | |
| | | // } |
| | | // return 0; |
| | | //} |
| | | |
| | | }; |
| | | |
| | | #endif // INTAREACALCUTIL_H |
| | |
| | | #include <basic/util/app/AppPreference.hpp> |
| | | |
| | | JudgmentRetrogradeTool::JudgmentRetrogradeTool(const SdkRule &rule) : |
| | | m_triggerElement(rule.nTriggerDelay * 8, 0), |
| | | m_triggerElement(0, 0), |
| | | m_sdkRule(rule), |
| | | pManagerEsDB(nullptr) |
| | | { |
| | |
| | | } |
| | | |
| | | void JudgmentRetrogradeTool::setYoloObjects(std::vector<ScoredRect> value) { |
| | | if (!isInWeek(m_sdkRule.weekRuleVec)) |
| | | return; |
| | | mObjs = value; |
| | | for (auto &item :value) { |
| | | if (item.score < m_sdkRule.fSensitivity)continue; |
| | | |
| | | setPerRect(item.id, item.rect); |
| | | } |
| | | mObjs = value; |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | bool JudgmentRetrogradeTool::getPerRet(const long &id) { |
| | | bool ret = (m_mapPerRet.find(id) == m_mapPerRet.end()) ? true : m_mapPerRet[id]; |
| | | bool ret = (m_mapPerRet.find(id) == m_mapPerRet.end()) ? false :m_mapPerRet[id]>=m_sdkRule.nTriggerDelay * 8; |
| | | return ret; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | void JudgmentRetrogradeTool::func() { |
| | | if (!isInWeek(m_sdkRule.weekRuleVec)) |
| | | return; |
| | | bool state=false; |
| | | for (auto &scoredRect :mObjs) { |
| | | if (scoredRect.score < m_sdkRule.fSensitivity)continue; |
| | | |
| | | if (getPerRet(scoredRect.id))//judgment.bool |
| | | { |
| | | DBG("scoredRect.id" << scoredRect.id << " val=" << m_mapPerRet[scoredRect.id]); |
| | | m_mapPerRet[scoredRect.id] -=2400; |
| | | auto t_image = image( |
| | | CvUtil::zoomRectEqual(scoredRect.rect, 1.2, 1.2) & cv::Rect(0, 0, image.cols, image.rows)).clone(); |
| | | // auto t_image = image(scoredRect.rect& cv::Rect(0, 0, image.cols, image.rows)).clone(); |
| | | std::string imgUrl = uploadImgToFdfs(t_image); |
| | | saveInfoToEs(imgUrl, scoredRect); |
| | | state=true; |
| | | |
| | | |
| | | // break; |
| | | } |
| | | // m_triggerElement.triggerOnce(); |
| | | // if(m_triggerElement.getState()) |
| | | // { |
| | | |
| | | // auto t_image = image( |
| | | // CvUtil::zoomRectEqual(scoredRect.rect, 1.2, 1.2) & cv::Rect(0, 0, image.cols, image.rows)).clone(); |
| | | // // auto t_image = image(scoredRect.rect& cv::Rect(0, 0, image.cols, image.rows)).clone(); |
| | | // std::string imgUrl = uploadImgToFdfs(t_image); |
| | | // saveInfoToEs(imgUrl, scoredRect); |
| | | // } |
| | | |
| | | setPerRect(scoredRect.id, scoredRect.rect); |
| | | } |
| | | m_triggerElement.setState(state); |
| | | m_triggerElement.triggerOnce(); |
| | | for (auto &item : m_mapPerDirection) { |
| | | int a = 0; |
| | | int b = 0; |
| | |
| | | a++; |
| | | } |
| | | } |
| | | // DBG("id="<<item.first<<" a="<<a<<" b="<<b); |
| | | bool ret = a >= b ? true : false; |
| | | if (!ret) { |
| | | m_mapPerRet.insert(std::make_pair(item.first, false)); |
| | | // m_mapPerRet[item.first] = false; |
| | | if(b!=0) |
| | | { |
| | | bool ret = a >= b ? true : false; |
| | | // DBG("id="<<item.first<<" a="<<a<<" b="<<b<<" ret="<<ret); |
| | | if (!ret) { |
| | | m_mapPerRet[item.first]+=1; |
| | | // m_mapPerRet.insert(std::make_pair(item.first, false)); |
| | | // m_mapPerRet[item.first] = false; |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | if (temp.size() > 9) { |
| | |
| | | } |
| | | } |
| | | |
| | | for (auto scoredRect:mObjs) { |
| | | if (!getPerRet(scoredRect.id))//judgment.bool |
| | | { |
| | | DBG("scoredRect.id" << scoredRect.id << " val=" << m_mapPerRet[scoredRect.id]); |
| | | m_mapPerRet[scoredRect.id] = true; |
| | | |
| | | m_triggerElement.setState(true); |
| | | |
| | | |
| | | break; |
| | | } else { |
| | | m_triggerElement.setState(false); |
| | | |
| | | } |
| | | m_triggerElement.triggerOnce(); |
| | | if(m_triggerElement.getTriggerState()) |
| | | { |
| | | auto t_image = image( |
| | | CvUtil::zoomRectEqual(scoredRect.rect, 1.2, 1.2) & cv::Rect(0, 0, image.cols, image.rows)).clone(); |
| | | // auto t_image = image(scoredRect.rect& cv::Rect(0, 0, image.cols, image.rows)).clone(); |
| | | std::string imgUrl = uploadImgToFdfs(t_image); |
| | | saveInfoToEs(imgUrl, scoredRect); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | CvUtil::cvMat2Buffer(image, buffer); |
| | | std::string strImgUrlTmp = ""; |
| | | fdfsClient->fastFds->uploadFile(buffer, strImgUrlTmp, "jpg"); |
| | | strImgUrl.append(fdfsClient->fastFds->getIp() + "/" + strImgUrlTmp); |
| | | // strImgUrl.append(fdfsClient->fastFds->getIp() + "/" + strImgUrlTmp); |
| | | strImgUrl.clear(); |
| | | strImgUrl = strImgUrlTmp; |
| | | // strImgUrl.append("/").append(strImgUrlTmp); |
| | |
| | | std::map<long, std::list<float>> m_mapPerDirection; |
| | | |
| | | //跟踪id,逆行状态 |
| | | std::map<long, bool> m_mapPerRet; |
| | | // std::map<long, bool> m_mapPerRet; |
| | | std::map<long, int> m_mapPerRet; |
| | | |
| | | QPolygon m_polygon; |
| | | |
| | |
| | | { |
| | | if(ele.id==obj.id) |
| | | { |
| | | if((obj.rect&ele.rect).area()>ele.rect.area()*0.8) |
| | | if((obj.rect&ele.rect).area()>ele.rect.area()*m_sdkRule.fSensitivity) |
| | | { |
| | | //not moving |
| | | obj.isMove = true; |
| | |
| | | CvUtil::cvMat2Buffer(image, buffer); |
| | | std::string strImgUrlTmp = ""; |
| | | fdfsClient->fastFds->uploadFile(buffer, strImgUrlTmp, "jpg"); |
| | | strImgUrl.append(fdfsClient->fastFds->getIp() + "/" + strImgUrlTmp); |
| | | //strImgUrl.append(fdfsClient->fastFds->getIp() + "/" + strImgUrlTmp); |
| | | strImgUrl.clear(); |
| | | strImgUrl = strImgUrlTmp; |
| | | // strImgUrl.append("/").append(strImgUrlTmp); |
| | |
| | | #include <uuid/uuid.h> |
| | | #include <jsoncpp/json/json.h> |
| | | |
| | | #define ALARM_PERCENT (10) //10% |
| | | PerimeterElement::PerimeterElement(const SdkRule &rule) : |
| | | m_sdkRule(rule), |
| | | PipeElement(true), |
| | |
| | | |
| | | void PerimeterElement::threadFunc() { |
| | | |
| | | // ClockTimer ct("PerimeterElement::threadFunc"); |
| | | //ClockTimer ct("PerimeterElement::threadFunc"); |
| | | if (!isInWeek(m_sdkRule.weekRuleVec)) |
| | | return; |
| | | int num = 0; |
| | |
| | | |
| | | QRect rect(obj.rect.x, obj.rect.y, obj.rect.width, obj.rect.height); |
| | | QPoint center = rect.center(); |
| | | if (mPolygon.containsPoint(center, Qt::OddEvenFill) || !m_bIsMask) { |
| | | m_recVec.push_back(obj.rect); |
| | | if (picDate.empty()) { |
| | | picDate = obj.properties["time"]; |
| | | // DBG("picDate="<<picDate); |
| | | |
| | | if (picDate.empty()) { |
| | | picDate = obj.properties["time"]; |
| | | // DBG("picDate="<<picDate); |
| | | |
| | | } |
| | | if (m_sdkRule.nSdkType == PerimeterSdk) |
| | | { |
| | | |
| | | if(m_bIsMask) |
| | | { |
| | | std::vector<Point> poly2; |
| | | std::vector<Point> interPoly; |
| | | poly2.push_back(Point(rect.x(),rect.y())); |
| | | poly2.push_back(Point(rect.x()+rect.width(),rect.y())); |
| | | poly2.push_back(Point(rect.x()+rect.width(),rect.y()+rect.height())); |
| | | poly2.push_back(Point(rect.x(),rect.y()+rect.height())); |
| | | IntAreaCalcUtil::PolygonClip(poly1,poly2,interPoly); |
| | | float inter = IntAreaCalcUtil::intAreaCalc(interPoly); |
| | | float total1 =IntAreaCalcUtil::intAreaCalc(poly1); |
| | | float total2 = IntAreaCalcUtil::intAreaCalc(poly2); |
| | | int per1 = (int)(inter / total1 * 100); |
| | | int per2 = (int)(inter / total2 * 100); |
| | | int per=std::max(per1,per2); |
| | | |
| | | if(ALARM_PERCENT <= per) |
| | | { |
| | | //DBG("per 1="<<per1<<" per2="<<per2<<" per="<<per); |
| | | m_recVec.push_back(obj.rect); |
| | | num++; |
| | | } |
| | | } |
| | | |
| | | num++; |
| | | |
| | | |
| | | } |
| | | else |
| | | else if (mPolygon.containsPoint(center, Qt::OddEvenFill) || !m_bIsMask) |
| | | { |
| | | // DBG("id="<< obj.properties["id"]<<" no containts x="<<rect.center().x()<<" y="<<rect.center().y()); |
| | | m_recVec.push_back(obj.rect); |
| | | |
| | | |
| | | num++; |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | switch (m_sdkRule.nSdkType) { |
| | | case PerimeterSdk: |
| | | state = num > 0 ; |
| | | //state = num > 0 ; |
| | | state =( num !=mRealNum); |
| | | // DBG("num="<<num<< "time="<< picDate); |
| | | |
| | | |
| | | break; |
| | | case CrowdSdk: |
| | | state = num > m_sdkRule.nAlarmNumLowerLimit ; |
| | | state = num > m_sdkRule.nAlarmNumLowerLimit && num !=mRealNum; |
| | | |
| | | break; |
| | | case PerHubSdk: |
| | | state = num > m_sdkRule.nAlarmNumLowerLimit && num < m_sdkRule.nAlarmNumUpperLimit ; |
| | | // if(m_sdkRule.nAlarmNumLowerLimit>0) |
| | | state = num > m_sdkRule.nAlarmNumLowerLimit && num < m_sdkRule.nAlarmNumUpperLimit && num !=mRealNum; |
| | | |
| | | |
| | | // if(m_sdkRule.nAlarmNumLowerLimit>=0) |
| | | // { |
| | | // if( m_sdkRule.nAlarmNumUpperLimit>m_sdkRule.nAlarmNumLowerLimit+1) |
| | | // if( m_sdkRule.nAlarmNumUp2019-01-16 09:49:57perLimit>m_sdkRule.nAlarmNumLowerLimit+1) |
| | | // { |
| | | |
| | | // m_triggerElement.setState(num>m_sdkRule.nAlarmNumLowerLimit && num<m_sdkRule.nAlarmNumUpperLimit); |
| | |
| | | |
| | | m_triggerElement.setState(state); |
| | | m_triggerElement.triggerOnce(); |
| | | // DBG("imgUrl="<<imgUrl); |
| | | if (m_triggerElement.getTriggerState() && num!=mRealNum) |
| | | if (m_triggerElement.getTriggerState() ) |
| | | { |
| | | |
| | | cv::Mat t_image = image(CutMask()).clone(); |
| | | if(t_image.empty()) |
| | | { |
| | | if(image.empty()) |
| | | if(num > 0) { |
| | | cv::Mat t_image = image(CutMask()).clone(); |
| | | if(t_image.empty()) |
| | | { |
| | | DBG("image empty"); |
| | | DBG("t_image empty"); |
| | | return; |
| | | } |
| | | DBG("t_image empty"); |
| | | return; |
| | | std::string imgUrl = uploadImgToFdfs(t_image); |
| | | saveInfoToEs(imgUrl, picDate); |
| | | } |
| | | std::string imgUrl = uploadImgToFdfs(t_image); |
| | | saveInfoToEs(imgUrl, picDate); |
| | | DBG("num=" << num << " lastnum=" << mRealNum); |
| | | mRealNum = num; |
| | | } |
| | | // if(state) |
| | | //DBG("mRealNum=" << mRealNum <<"m_triggerElement.getTriggerState()="<<m_triggerElement.getTriggerState()); |
| | | |
| | | // if (m_triggerElement.getTriggerState() && num!=mRealNum) |
| | | // { |
| | | |
| | | // cv::Mat t_image = image(CutMask()).clone(); |
| | | // if(t_image.empty()) |
| | | // { |
| | | // DBG("t_image empty"); |
| | | // return; |
| | | // } |
| | | // std::string imgUrl = uploadImgToFdfs(t_image); |
| | | // saveInfoToEs(imgUrl, picDate); |
| | | // DBG("num=" << num << " lastnum=" << mRealNum); |
| | | // mRealNum = num; |
| | | // } |
| | | |
| | | |
| | | if(!state) |
| | | { |
| | | mRealNum = num; |
| | | } |
| | | |
| | | // if(!state) |
| | | // { |
| | | // mRealNum = num; |
| | | // } |
| | | |
| | | |
| | | // DBG("m_sdkRule.nSdkType="<<m_sdkRule.nSdkType<<" num="<<num); |
| | |
| | | QJsonObject obj = jsonValue.toObject(); |
| | | int x = obj.value("x").toDouble() * 4; |
| | | int y = obj.value("y").toDouble() * 4; |
| | | if(m_sdkRule.nSdkType == PerimeterSdk) |
| | | { |
| | | poly1.push_back(Point(x,y)); |
| | | } |
| | | else |
| | | { |
| | | mPolygon << (QPoint(x, y)); |
| | | } |
| | | |
| | | mPolygon << (QPoint(x, y)); |
| | | |
| | | |
| | | } |
| | | } |
| | |
| | | #include <basic/util/fastdfs/FastFds.hpp> |
| | | #include "DBStruct.h" |
| | | #include <basic/db/Elasticsearch/EsDBTool.h> |
| | | #include "IntAreaCalcUtil.h" |
| | | class PerimeterElement : public basic::PipeElement |
| | | { |
| | | public: |
| | |
| | | |
| | | |
| | | int npts; |
| | | vector<cv::Rect> m_recVec; |
| | | std::vector<cv::Rect> m_recVec; |
| | | |
| | | bool m_bIsMask; |
| | | std::vector<Point> poly1; |
| | | |
| | | |
| | | }; |
| | | |
| | | #endif // PAELEMENT_H |
| | |
| | | |
| | | void YoloRpcElement::threadFunc() |
| | | { |
| | | // ClockTimer ct("YoloRpcElement::threadFunc"); |
| | | // ClockTimer ct("YoloRpcElement::threadFunc"); |
| | | triggerScoredRects.clear(); |
| | | try { |
| | | auto server = rpcClient.getServer(); |
| | |
| | | { |
| | | ERR(e.what()) |
| | | } |
| | | int size=objs.size(); |
| | | if(size>30) |
| | | { |
| | | // int size=objs.size(); |
| | | // if(size>30) |
| | | // { |
| | | |
| | | // cv::imshow("image", image); |
| | | |
| | | // cv::waitKey(); |
| | | |
| | | DBG("size="<<size); |
| | | return; |
| | | } |
| | | // DBG("size="<<size); |
| | | // return; |
| | | // } |
| | | |
| | | for (auto &obj: objs) |
| | | { |
| | |
| | | ../StructureApp/HiredisTool.cpp |
| | | ../StructureApp/PersonElement.cpp |
| | | ../StructureApp/PerStaticElement.cpp |
| | | ../StructureApp/IntAreaCalcUtil.cpp |
| | | |
| | | ../YoloServer/rpc/YoloServer.cpp |
| | | ../FaceDetectServer/rpc/FaceServer.cpp |
| | |
| | | rule.second.strAddr = item.str_addr; |
| | | rule.second.weekRuleVec = m_lDBTool->searchCameraWeekRuleByCamId(item.str_cam_dev_id, rule.first); |
| | | |
| | | if(rule.second.nSdkType == FaceSdk) continue; |
| | | if(rule.second.nSdkType == PerStaticSdk) |
| | | { |
| | | float temp=1-(float)(rule.second.nThreshold)/100; |
| | | rule.second.fSensitivity=(75+25*temp)/100; |
| | | |
| | | if (rule.second.nThreshold < 5 ) |
| | | { |
| | | rule.second.fSensitivity=0.95; |
| | | } |
| | | else if(rule.second.nThreshold > 95) |
| | | else if(rule.second.nSdkType != FaceSdk) |
| | | { |
| | | rule.second.fSensitivity=0.05; |
| | | float temp=1-(float)(rule.second.nThreshold)/100; |
| | | rule.second.fSensitivity=(5+90*temp)/100; |
| | | } |
| | | else |
| | | { |
| | | rule.second.fSensitivity = 1-(float) (rule.second.nThreshold) / 100; |
| | | } |
| | | // if (rule.second.nThreshold < 5 ) |
| | | // { |
| | | // rule.second.fSensitivity=0.95; |
| | | // } |
| | | // else if(rule.second.nThreshold > 95) |
| | | // { |
| | | // rule.second.fSensitivity=0.05; |
| | | // } |
| | | // else |
| | | // { |
| | | // rule.second.fSensitivity = 1-(float) (rule.second.nThreshold) / 100; |
| | | // } |
| | | |
| | | DBG("fSensitivity" << rule.second.fSensitivity); |
| | | } |
| | |
| | | pModel_cam.setEditStrategy(QSqlTableModel::OnManualSubmit);//OnManualSubmit OnFieldChange |
| | | pModel_cam.select(); |
| | | |
| | | // QSqlTableModel pModel_sdk(NULL, m_db); |
| | | // pModel_sdk.setTable("cam_sdk"); |
| | | // pModel_sdk.setFilter(QObject::tr("cam_dev_id = '%1'").arg(strCamId)); |
| | | // pModel_sdk.setEditStrategy(QSqlTableModel::OnManualSubmit);//OnManualSubmit OnFieldChange |
| | | // pModel_sdk.select(); |
| | | |
| | | QSqlTableModel pModel_sdk(NULL, m_db); |
| | | pModel_sdk.setTable("cam_sdk"); |
| | | pModel_sdk.setFilter(QObject::tr("cam_dev_id = '%1'").arg(strCamId)); |
| | | pModel_sdk.setTable("sdk_rule"); |
| | | pModel_sdk.setFilter(QObject::tr("cam_id = '%1'").arg(strCamId)); |
| | | pModel_sdk.setEditStrategy(QSqlTableModel::OnManualSubmit);//OnManualSubmit OnFieldChange |
| | | pModel_sdk.select(); |
| | | |
| | | QSqlTableModel pModel_week(NULL, m_db); |
| | | pModel_week.setTable("rule_week"); |
| | | pModel_week.setFilter(QObject::tr("camera_id = '%1'").arg(strCamId)); |
| | | pModel_week.setEditStrategy(QSqlTableModel::OnManualSubmit);//OnManualSubmit OnFieldChange |
| | | pModel_week.select(); |
| | | |
| | | int rowCount_cam = pModel_cam.rowCount(); |
| | | if (rowCount_cam >= 1) { |
| | |
| | | } |
| | | } |
| | | |
| | | int rowCount_week = pModel_week.rowCount(); |
| | | if (rowCount_week >= 1) { |
| | | for (int i = 0; i < rowCount_week; i++) { |
| | | pModel_week.removeRow(i);//TODO |
| | | } |
| | | } |
| | | |
| | | m_db.transaction();//开始事务操作 |
| | | |
| | | if (pModel_cam.submitAll() && \ |
| | | pModel_sdk.submitAll()) { |
| | | pModel_sdk.submitAll() && pModel_week.submitAll()) { |
| | | m_db.commit();//提交 |
| | | return true; |
| | | } else { |
| | | m_db.rollback();//回滚 |
| | | ERR("deleteLDeviceTable err ,Database Error: " \ |
| | | << pModel_cam.lastError().text().toStdString() \ |
| | | << pModel_sdk.lastError().text().toStdString()); |
| | | << pModel_sdk.lastError().text().toStdString() \ |
| | | << pModel_week.lastError().text().toStdString() ); |
| | | // QMessageBox::warning(NULL,QObject::tr("deleteLDeviceTable"),QObject::tr("Database Error: %1").arg(pModel.lastError().text())); |
| | | return false; |
| | | } |
| | |
| | | int nboxes = 0; |
| | | detection *dets = get_network_boxes(m_net, im.w, im.h, m_thresh, m_hier_thresh, 0, 1, &nboxes); |
| | | if (nboxes > 30) { |
| | | DBG("nboxes="<<nboxes); |
| | | return objInfos; |
| | | } |
| | | if (m_nms) do_nms_sort(dets, nboxes, l.classes, m_nms); |
| | |
| | | // adapter->activate(); |
| | | // ich->waitForShutdown(); |
| | | |
| | | if (argc < 3) { |
| | | ERR("argc error"); |
| | | return -1; |
| | | } |
| | | // if (argc < 3) { |
| | | // ERR("argc error"); |
| | | // return -1; |
| | | // } |
| | | |
| | | int gpuindex = atoi(argv[1]); |
| | | int poolNum = atoi(argv[2]); |
| | | int portNum = atoi(argv[3]); |
| | | int gpuindex = 1; |
| | | int poolNum = 1; |
| | | int portNum = 10003; |
| | | |
| | | appPref.setIntData("gpu.index", gpuindex); |
| | | appPref.setFloatData("thresh.detect", 0.7); |
old mode 100644
new mode 100755
Binary files differ
| | |
| | | echo $1 |
| | | des_pass=123 |
| | | expect -c " |
| | | # spawn scp -P44100 ${CUR_PATH}"/"$1 dell@58.118.225.79:/home/dell/Apps/QiaoJiaSystem/build |
| | | # spawn scp -P41100 ${CUR_PATH}"/"$1 basic@58.118.225.79:/home/basic/Apps/QiaoJiaSystem/build |
| | | spawn scp ${CUR_PATH}"/"$1 basic@192.168.1.203:/home/basic/Apps/QiaoJiaSystem/build |
| | | expect \"password:\" |
| | | send \"${des_pass}\r\" |