pansen
2019-04-02 c56015c5c73861b5f794cac48064d0394f8fd37d
QiaoJiaSystem/StructureApp/FaceExtractElement.cpp
@@ -92,6 +92,20 @@
            auto sharedImage = cv::Mat(image.rows, image.cols, CV_8UC3, sharedMemory->data());
            image.copyTo(sharedImage);
            // 上传大图
            string strBigImgUrl;
            if (fdfsClient != nullptr && fdfsClient->fastFds != nullptr) {
                fdfsClient->rwLock.rdlock();
                std::vector<unsigned char> buffer;
                CvUtil::cvMat2Buffer(image, buffer);
                fdfsClient->fastFds->uploadFile(buffer, strBigImgUrl, "jpg");
                fdfsClient->rwLock.unlock();
            } else {
                strBigImgUrl = "";
                ERR("fdfsClient is nullptr ???");
            }
            unsigned long size = faceExtractQueueTmp[i].facesPos.size();
            for (int j = 0; j < size; j++) {
                auto feature = extractServer->faceExtract(image.cols, image.rows, faceExtractQueueTmp[i].facesPos[j],
@@ -109,7 +123,6 @@
                }
                features.clear();
                features.emplace_back(feature);
                std::string strImgUrl = "http://";
                if (fdfsClient != nullptr && fdfsClient->fastFds != nullptr) {
                    fdfsClient->rwLock.rdlock();
@@ -127,7 +140,18 @@
                    strImgUrl = "";
                    ERR("fdfsClient is nullptr ???");
                }
                InsertToESDB(faceExtractQueueTmp, t_com_sc, i, j, feature, strImgUrl, strBigImgUrl);
            }
        }
    } catch (std::exception &e) {
        ERR(e.what())
    }
    if (!features.empty())fireConnectors();
}
void FaceExtractElement::InsertToESDB(const vector<FaceToExtract> &faceExtractQueueTmp, float t_com_sc, int i, int j,
                                      FaceDetect::Data &feature, string &strImgUrl, string &strBigImgUrl) {
                //拼接json
                string str_uuid;
                uuid_t t_uuid;
@@ -139,7 +163,7 @@
                Json::Value t_json;
                t_json["Id"] = str_uuid; //主键
                std::string feature_base64;
    string feature_base64;
                feature_base64 = base64.Encode(feature.data(), feature.size());
                //#在对比中添加特征值
@@ -156,7 +180,7 @@
                t_json["personPicUrl"] = "";//人员图片 store
                t_json["picAddress"] = getProperty("str_addr");//抓拍地址
                DBG("picAddress=" << t_json["picAddress"]);
                t_json["picMaxUrl"] = "";//大图路径
    t_json["picMaxUrl"] = strBigImgUrl;//大图路径
                t_json["picLocalUrl"] = "";//本地路径
                t_json["picSmUrl"] = strImgUrl;//人员抓小图
                //#todo
@@ -167,7 +191,7 @@
                t_json["content"] = "";
                //t_json["viType"] = "2";//只有4种类型 1:personface 2:personbody 3:car 4:bicycle 5:none 未知类型
                t_json["sdkType"] = std::to_string(
    t_json["sdkType"] = to_string(
                    m_sdkRule.nSdkType);//只有4种类型 1:personface 2:personbody 3:car 4:bicycle 5:none 未知类型
                t_json["personIsHub"] = "4";//1: 报警  2: 可疑  3: 安全  4: 未知
@@ -223,7 +247,7 @@
                t_json["indeviceid"] = appPref.getStringData("fxDevID");
                t_json["indevicename"] = appPref.getStringData("fxDevNAME");
                std::string strImageKey = faceExtractQueueTmp[i].scoredRects[j].properties["imgKey"];
    string strImageKey = faceExtractQueueTmp[i].scoredRects[j].properties["imgKey"];
                INFO("SaveImageKey To ES: " << strImageKey);
                t_json["imgKey"] = strImageKey;
@@ -235,7 +259,7 @@
                    }
                    INFO("Record Video " << strImageKey);
                    server->recordVideo(strImageKey);
                } catch (std::exception &e) {
    } catch (exception &e) {
                    ERR("Record Video Err: " << strImageKey << "   Message: " << e.what());
                    //return;
                }
@@ -257,14 +281,9 @@
                                                                              t_com_sc);
                }
            }
        }
    } catch (std::exception &e) {
        ERR(e.what())
    }
    if (!features.empty())fireConnectors();
}
std::vector<::FaceDetect::Data> FaceExtractElement::getFeatures() const {
    return features;
}