| | |
| | | /** |
| | | * #todo sqlite -> Qt.sqlite |
| | | */ |
| | | |
| | | /*** |
| | | * sqlite3 操作工具类 |
| | | */ |
| | | class SqliteFaceEncap : public sqliteEncapsulation { |
| | | public: |
| | | explicit SqliteFaceEncap(std::string t_string); |
| | | |
| | | /*** |
| | | * 创建布控底库 |
| | | * 不通用,因为内部有一个insert函数调用 |
| | | * @param t_tableName |
| | | * @param fieldValues |
| | | * @return |
| | | */ |
| | | bool createTable(std::string t_tableName, FieldValues &fieldValues); |
| | | |
| | | /*** |
| | | * 通用的单表更新 |
| | | * @param t_tableName |
| | | * @param fieldValues |
| | | * @return |
| | | */ |
| | | bool updateTable(std::string t_tableName, FieldValues &fieldValues); |
| | | |
| | | /*** |
| | | * 删除表 |
| | | * @param t_tableName |
| | | * @return |
| | | */ |
| | | bool deleteTable(std::string t_tableName); |
| | | |
| | | /*** |
| | |
| | | */ |
| | | std::vector<std::string> getTableNameList(std::string type); |
| | | |
| | | /*** |
| | | * 获取所有已创建的表信息 |
| | | * @return |
| | | */ |
| | | TableInfos getTableInfos(); |
| | | |
| | | public: |
| | | |
| | | /*** |
| | | * 添加人脸 |
| | | * @param t_tableName 表名 |
| | | * @param faceData 人脸特征结构体 |
| | | * @param fieldValues 字段集合 |
| | | * @return |
| | | */ |
| | | std::string addFace(std::string t_tableName, AddFaceData &faceData, FieldValues &fieldValues); |
| | | |
| | | /*** |
| | | * 更新人脸 |
| | | * @param t_tableName 表名 |
| | | * @param faceData 人脸特征结构体 |
| | | * @param fieldValues 字段集合 |
| | | * @return |
| | | */ |
| | | bool updateFace(std::string t_tableName, AddFaceData &faceData, FieldValues &fieldValues); |
| | | |
| | | /*** |
| | | * 向人脸特征表插入记录 |
| | | * @param t_tableName |
| | | * @param faceData |
| | | * @return |
| | | */ |
| | | std::string addFaceData(std::string t_tableName, AddFaceData &faceData); |
| | | |
| | | //#todo |
| | | /*** |
| | | * 添加人脸业务信息 |
| | | * @param t_tableName |
| | | * @param fieldValues |
| | | * @return |
| | | */ |
| | | bool addFaceInfo(std::string t_tableName, FieldValues &fieldValues); |
| | | |
| | | /*** |
| | | * |
| | | * @param t_tableName |
| | | * @param faceData |
| | | * @return |
| | | */ |
| | | bool updateFaceData(std::string t_tableName, AddFaceData &faceData); |
| | | |
| | | /*** |
| | | * |
| | | * @param t_tableName |
| | | * @param fieldValues |
| | | * @return |
| | | */ |
| | | bool updateFaceInfo(std::string t_tableName, FieldValues &fieldValues); |
| | | |
| | | /*** |
| | | * |
| | | * @param t_tableName |
| | | * @param uuid |
| | | * @return |
| | | */ |
| | | bool deleteFace(std::string t_tableName, std::string uuid); |
| | | |
| | | private: |
| | | /*** |
| | | * |
| | | * @param t_tableName |
| | | * @param uuid |
| | | * @return |
| | | */ |
| | | bool deleteFaceData(std::string t_tableName, std::string uuid); |
| | | |
| | | public: |
| | |
| | | // |
| | | // Created by pans on 4/28/18. |
| | | // |
| | | /*** |
| | | * 说明,本文件主要是sql语句拼接及获取已定义的sql语句 |
| | | * 目前仅支持单表sql语句拼接 |
| | | */ |
| | | |
| | | #ifndef TESTSQLITE_SQLITETOOLKIT_HPP |
| | | #define TESTSQLITE_SQLITETOOLKIT_HPP |
| | |
| | | */ |
| | | typedef std::vector<unsigned char> FaceFeature; |
| | | |
| | | /*** |
| | | * 添加人脸的数据结构 |
| | | */ |
| | | struct AddFaceData { |
| | | std::string uuid; |
| | | FaceFeature feature; |
| | |
| | | std::string feature_base64; |
| | | }; |
| | | |
| | | /*** |
| | | * 人脸信息的数据结构 |
| | | */ |
| | | struct FaceInfo { |
| | | std::string uuid; |
| | | std::string personName; |
| | |
| | | typedef std::vector<FaceInfo> FaceInfos; |
| | | typedef std::map<std::string, FaceInfo> FaceInfosCache; |
| | | |
| | | /*** |
| | | * 表信息数据结构 |
| | | */ |
| | | struct TableInfo { |
| | | std::string uuid; |
| | | std::string tableName; |
| | |
| | | |
| | | //typedef std::map<std::string, FaceFeatures> FeatureDBCache; |
| | | |
| | | /*** |
| | | * 带有URL和其他属性的人脸特征数据结构 |
| | | */ |
| | | struct FaceFeatureWithUrl { |
| | | std::string uuid; |
| | | std::string faceurl; |
| | |
| | | #define SQLERR(message) fprintf(stderr, "%s->%d-> SQLite error: %s\n",__FILE__,__LINE__, message); |
| | | |
| | | |
| | | //#todo 数据库wenjian名称 |
| | | //#todo 数据库文件名称 |
| | | //是否需要从配置文件读取? |
| | | static std::string file_dbName = "TestFaceDB.db"; |
| | | //#todo 数据库名称 |
| | | static std::string g_dbName = "main"; |
| | | //#todo 管理表的表名 |
| | | static std::string g_tableName = "sys_o_tables"; |
| | | |
| | | // |
| | | /*** |
| | | * 获取人脸特征查询的sqlite语句 |
| | | * @param tableName 表名,不带 _fea |
| | | * @return |
| | | */ |
| | | std::string getFacesFromTableSql(std::string tableName) { |
| | | // #todo get monLevel 联合查询 |
| | | std::string sql = |
| | |
| | | return sql; |
| | | } |
| | | |
| | | /*** |
| | | * 根据表类型获取数据表列表 |
| | | * @param type |
| | | * @return |
| | | */ |
| | | std::string getTableListSqlWithType(std::string type) { |
| | | std::string sql = "select tableName,del_flag from '" + g_tableName + "' where del_flag = 0"; |
| | | if (type.size() > 0) { |
| | |
| | | return sql; |
| | | } |
| | | |
| | | /*** |
| | | * 查询任意表的所有字段 |
| | | * @param tableName |
| | | * @return |
| | | */ |
| | | std::string getTableInfosSql(std::string tableName) { |
| | | std::string sql = "select * from '" + tableName + "';";// + " where del_flag = 0"; |
| | | return sql; |
| | | } |
| | | |
| | | |
| | | /*** |
| | | * 获取当前已创建的表 |
| | | * @return |
| | | */ |
| | | std::string getTableInfosSql() { |
| | | //uuid,tableName,tableDesc,tableType,bwType,startTime,endTime |
| | | std::string sql = |
| | |
| | | return sql; |
| | | } |
| | | |
| | | |
| | | /*** |
| | | * 获取更新人脸业务信息表的sql语句 |
| | | * @param tableName |
| | | * @param fieldValues |
| | | * @return |
| | | */ |
| | | std::string getUpdateFaceTableSql(std::string tableName, FieldValues &fieldValues) { |
| | | if (tableName.size() == 0) { |
| | | //#todo errInfo |
| | |
| | | |
| | | |
| | | //#TODO 人脸表需要删除两个 |
| | | /*** |
| | | * 获取删除人脸表的sql语句 |
| | | * @param tableName |
| | | * @return |
| | | */ |
| | | std::string getDeleteFaceTableSql(std::string tableName) { |
| | | if (tableName.size() == 0) { |
| | | //#todo errInfo |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | static std::string rtspAddrBuild(std::string ip, const int port, std::string username, |
| | | std::string passwd, std::string brand) { |
| | | std::string rtsp_url; |
| | |
| | | INFO("StartCamNO: "<<startCamNO<<" CamStep: "<<CamCount); |
| | | auto itor = lst.begin(); |
| | | |
| | | if(startCamNO >= lst.size()) |
| | | { |
| | | if (startCamNO >= lst.size()) { |
| | | ERR("startCamNO > lst.size()"); |
| | | return; |
| | | } |
| | |
| | | } |
| | | |
| | | for (int i = 0; i < CamCount; i++) { |
| | | if (itor == lst.end()) |
| | | { |
| | | if (itor == lst.end()) { |
| | | ERR("itor == lst.end()"); |
| | | return; |
| | | } |
| | |
| | | |
| | | |
| | | //录取视频的RPC的接口函数 |
| | | ::std::string RtspAnalysManager::recordVideo(const ::std::string& name, const ::Ice::Current&) |
| | | { |
| | | ::std::string RtspAnalysManager::recordVideo(const ::std::string &name, const ::Ice::Current &) { |
| | | INFO("Record Video For: "<<name); |
| | | ImageName_s_t nameSt=ImageName_s_t::fromString(name); |
| | | if(nameSt.Valid()) |
| | | { |
| | | if (nameSt.Valid()) { |
| | | auto pCaptureElem = m_controllers.find(nameSt.m_camId); |
| | | if(pCaptureElem!= m_controllers.end()) |
| | | { |
| | | if (pCaptureElem != m_controllers.end()) { |
| | | pCaptureElem->second->SaveVideo(name); |
| | | } else{ |
| | | ERR("Can not Find CamId "<<nameSt.m_camId); |
| | | } |
| | | } |
| | | else{ |
| | | } else { |
| | | ERR("Record Video Failed:Name Not Valid Name: "<<name); |
| | | } |
| | | return name; |
| | | } |
| | | |
| | | //保存视频到RtspImageRedis的队列,由RtspCaptureElement调用 |
| | | bool RtspAnalysManager::SaveImageToRedis(const std::string& camId,const std::string& imageName,const cv::Mat& img) |
| | | { |
| | | bool RtspAnalysManager::SaveImageToRedis(const std::string &camId, const std::string &imageName, const cv::Mat &img) { |
| | | INFO("MYH DEBUG HERE"); |
| | | auto item = m_imgRedisControllers.find(camId); |
| | | if(item!=m_imgRedisControllers.end()) |
| | | { |
| | | if (item != m_imgRedisControllers.end()) { |
| | | INFO("Save Succeed Cam: "<<camId<<" ImageKey: "<<imageName); |
| | | item->second->SaveImage(imageName,img); |
| | | } else { |
| | |
| | | // return -1; |
| | | // } |
| | | |
| | | int gpuindex = 1; |
| | | int gpuindex = 0; |
| | | int poolNum = 1; |
| | | int portNum = 10003; |
| | | |
| | | appPref.setIntData("gpu.index", gpuindex); |
| | | appPref.setFloatData("thresh.detect", 0.7); |
| | | appPref.setFloatData("thresh.detect", 0.85); |
| | | appPref.setIntData("poolNum", poolNum); |
| | | |
| | | IceRpcServer<YoloDetectServerI> server("yoloServer", portNum, "tcp"); |