pansen
2018-12-26 e1d7e82725a6ee591b399f89544b64a4f07b624d
QiaoJiaSystem/DataManagerServer/http_configserver.cpp
@@ -2001,27 +2001,11 @@
            auto t_results = m_curlDownloadImg.download_jpeg(const_cast<char *>(img_url.c_str()));
            cvutil.buffer2CvMat(t_results.buffer, image);
        } else if (img_base64.size() > 0) {
            img_url = "http://";
            auto str_img = base64.Decode(img_base64.c_str(), img_base64.size());
            std::vector<unsigned char> buffer(str_img.size());
            memcpy(buffer.data(), str_img.data(), str_img.size());
            cvutil.buffer2CvMat(buffer, image);
            fdfsClient.rwLock.rdlock();
            if (fdfsClient.fastFds != nullptr) {
                img_url.append(fdfsClient.fastFds->getIp() + "/");
                std::string t_strImg = "";
                if (!fdfsClient.fastFds->uploadFile(buffer, t_strImg, "jpg")) {
                    img_url = "upload image fail";
                } else {
                    img_url.append(t_strImg);
                    img_url.clear();
                    img_url = t_strImg;
//                    img_url.append("/").append(t_strImg);
                }
            }
            fdfsClient.rwLock.unlock();
        } else {
            response->write(SimpleWeb::StatusCode::server_error_not_implemented, "{\"error\":\"not found img\"}");
            return "";
@@ -2046,10 +2030,39 @@
//            cv::imwrite(str_path, image);
            return "";
//            return "{\"error\":\"not found face\"}";
        } else if (faceResults.size() > 1) {
            response->write(SimpleWeb::StatusCode::server_error_not_implemented, "{\"error\":\" 仅支持单人脸图片 \"}");
            return "";
        }
        for (auto &item : faceResults) {
            feature_base64 = base64.Encode(item.feature.data(), item.feature.size());
            int x = item.left;
            int y = item.top;
            int w = item.width;
            int h = item.height;
            cv::Rect t_rect = {x, y, w, h};
            auto t_image = image(CvUtil::zoomRect(t_rect, 1.5, 1.5) & cv::Rect(0, 0, image.cols, image.rows)).clone();
            std::vector<uchar> buffer;
            cvutil.cvMat2Buffer(t_image, buffer);
            img_url = "http://";
            fdfsClient.rwLock.rdlock();
            if (fdfsClient.fastFds != nullptr) {
                img_url.append(fdfsClient.fastFds->getIp() + "/");
                std::string t_strImg = "";
                if (!fdfsClient.fastFds->uploadFile(buffer, t_strImg, "jpg")) {
                    img_url = "upload image fail";
                } else {
                    img_url.append(t_strImg);
                    img_url.clear();
                    img_url = t_strImg;
//                    img_url.append("/").append(t_strImg);
                }
            }
            fdfsClient.rwLock.unlock();
        }
        auto size = feature_base64.size();
//        std::string uuid = "";