#include"f_MakeupBase.h"
#include"f_EyeBrow.h"
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<iostream>
#include <Poco/Stopwatch.h>
#include "Poco/Net/HTTPSClientSession.h"
#include <Poco/URI.h>
#include <Poco/StreamCopier.h>
#include <Poco/Net/HTTPRequest.h>
#include <Poco/Net/HTMLForm.h>
#include <Poco/Net/HTTPResponse.h>
#include "Poco/JSON/Parser.h"
#include "Poco/Dynamic/Var.h"
#include "ZBase64.h"
#include "fstream"
#include <opencv2/opencv.hpp>
#include <opencv2/dnn.hpp>
#include <opencv2/imgcodecs/legacy/constants_c.h>
using namespace cv;
using namespace Poco;
using namespace Poco::Net;
using namespace std;


int f_EyeBrow(unsigned char* srcData, int width, int height, int stride, int srcFacePoints[2*3], unsigned char* mskData, int mWidth, int mHeight, int mStride, int maskKeyPoints[2 * 3], bool isLeft, int ratio)
{
    return f_MakeupBase(srcData, width, height, stride,srcFacePoints, mskData, mWidth, mHeight, mStride, maskKeyPoints, ratio);
};

int f_EyeBrowTest(Mat& srcData, int width, int height, int stride, int srcFacePoints[2*3],Mat& mskData, int mWidth, int mHeight, int mStride, int maskKeyPoints[2 * 3], bool isLeft, int ratio,Mat& maskMat)
{
    int srcKeyPoints[2 * 3] = {srcFacePoints[2 * 0], srcFacePoints[2 * 0 + 1], srcFacePoints[2 * 1], srcFacePoints[2 * 1 + 1], srcFacePoints[2 * 2], srcFacePoints[2 * 2 + 1]};
    return f_MakeupBaseTest(srcData, width, height, stride,srcKeyPoints, mskData, mWidth, mHeight, mStride, maskKeyPoints, ratio,maskMat);
};




double getDistance (Point pointO,Point pointA)
{
    double distance;
    distance = powf(((float)pointO.x - (float)pointA.x),2) + powf(((float)pointO.y - (float)pointA.y),2);
    distance = sqrtf(distance);
    return distance;
}

void hMirrorTrans(const Mat &src, Mat &dst)
{
    CV_Assert(src.depth() == CV_8U);
    dst.create(src.rows, src.cols, src.type());
     int rows = src.rows;
     int cols = src.cols;

     switch (src.channels())
     {
     case 1:
         const uchar *origal;
         uchar *p;
         for (int i = 0; i < rows; i++){
             origal = src.ptr<uchar>(i);//ptr<>函数得到一行的指针，并用[]操作符访问某一列的像素值
            p = dst.ptr<uchar>(i);
           for (int j = 0; j < cols; j++){
                p[j] = origal[cols - 1 - j];
           }
        }
       break;
     case 3:
        const Vec3b *origal3;
       Vec3b *p3;
      for (int i = 0; i < rows; i++) {
           origal3 = src.ptr<Vec3b>(i);
           p3 = dst.ptr<Vec3b>(i);
           for (int j = 0; j < cols; j++){
               p3[j] = origal3[cols - 1 - j];
           }
       }
        break;
    default:
        break;
    }

}


int main123321(int argc, char* argv[]){

    int ratio=100;
    string modelName = string(argv[2]);
    char modelNameChar = modelName[0];
    cout << modelName << endl;
    cout << modelNameChar << endl;
    string motePath = string(argv[1]);
    string maskPath = "./"+modelName+".png";
    int* rightMaskKeyPoints;
    int* leftMaskKeyPoints;
    int rightTemp1[] = {136,527, 821,186, 1438,178};
    int leftTemp1[] = {41,174, 648,181, 1343,525};
    int rightTemp2[] = {95,346,780,154,1471,243};
    int leftTemp2[] = {2,245,665,139,1383,332};
    int rightTemp3[] = {28,214,631,110,1239,254};
    int leftTemp3[] = {5,253,626,106,1220,220};
    int rightTemp4[] = {82,317,717,100,1318,349};
    int leftTemp4[] = {4,349,572,95,1247,313};

    int rightTemp5[] = {130,283,821,134,1474,197};
    int leftTemp5[] = {2,196,619,113,1357,272};
    switch (modelNameChar) {
        case '1': {
            rightMaskKeyPoints = rightTemp1;//1
            leftMaskKeyPoints = leftTemp1;//1
            break;
        }
        case '2': {
            rightMaskKeyPoints = rightTemp2;//2
            leftMaskKeyPoints = leftTemp2;//2
            break;
        }
        case '3': {
            rightMaskKeyPoints = rightTemp3;//3
            leftMaskKeyPoints = leftTemp3;//3
            break;
        }
        case '4': {
            rightMaskKeyPoints = rightTemp4;//4
            leftMaskKeyPoints = leftTemp4;//4
            break;
        }
        case '5': {
            rightMaskKeyPoints = rightTemp5;//4
            leftMaskKeyPoints = leftTemp5;//4
            break;
        }
    }
//    int rightMaskKeyPoints[2 * 3]={1,48,125,17,262,45};//test
//    int leftMaskKeyPoints[2 * 3]={1,48,125,17,262,45};//test
//    int rightMaskKeyPoints[2 * 3]={136,526,725,221,1439,178};//1
//    int leftMaskKeyPoints[2 * 3]={40,170,701,198,1341,527};//1
//    int rightMaskKeyPoints[2 * 3]={43,459,733,256,1456,358};//2
//    int leftMaskKeyPoints[2 * 3]={8,366,729,246,1441,444};//2
//    int rightMaskKeyPoints[2 * 3]={137,332,729,238,1357,379};//3
//    int leftMaskKeyPoints[2 * 3]={118,382,744,234,1340,339};//3
//    int rightMaskKeyPoints[2 * 3]={99,472,766,216,1420,469};//4
//    int leftMaskKeyPoints[2 * 3]={59,472,679,216,1378,469};//4
//    int rightMaskKeyPoints[2 * 3]={52,116,238,62,445,128};//运营眉毛1
//    int rightMaskKeyPoints[2 * 3]={31,132,109,102,196,117};//UI1
//    int rightMaskKeyPoints[2 * 3]={48,141,242,87,469,97};//UI2
//    int rightMaskKeyPoints[2 * 3]={99,469,744,220,1420,470};//UI3
//    int rightMaskKeyPoints[2 * 3]={13,162,251,86,504,106};//UI4
//    int rightMaskKeyPoints[2 * 3]={65,144,286,85,537,104};//一字眉
//    int rightMaskKeyPoints[2 * 3]={69,183,253,108,482,142};//新月眉
//    int rightMaskKeyPoints[2 * 3]={58,157,281,73,530,140};//柳叶眉
//    int rightMaskKeyPoints[2 * 3]={38,103,181,63,349,117};//野生眉
//    int leftMaskKeyPoints[2 * 3]={54,131,237,62,447,121};//运营眉毛1
//    int leftMaskKeyPoints[2 * 3]={21,118,109,103,187,131};//UI1
//    int leftMaskKeyPoints[2 * 3]={53,96,245,84,476,138};//UI2
//    int leftMaskKeyPoints[2 * 3]={59,474,670,214,1382,470};//UI3
//    int leftMaskKeyPoints[2 * 3]={18,107,257,81,508,161};//UI4
//    int leftMaskKeyPoints[2 * 3]={47,106,288,80,523,138};//一字眉
//    int leftMaskKeyPoints[2 * 3]={91,142,308,101,504,185};//新月眉
//    int leftMaskKeyPoints[2 * 3]={26,140,269,70,497,156};//柳叶眉
//    int leftMaskKeyPoints[2 * 3]={34,118,195,62,344,104};//野生眉



    //计时
    Poco::Stopwatch stopwatch;
    stopwatch.start();
    //获取人脸1000关键点
    URI uri("https://api-cn.faceplusplus.com/facepp/v1/face/thousandlandmark");
    const Poco::Net::Context::Ptr context(
            new Poco::Net::Context(Poco::Net::Context::CLIENT_USE, "", "", "",
                                   Poco::Net::Context::VERIFY_NONE));
    Poco::Net::HTTPSClientSession session(uri.getHost(), uri.getPort(), context);
    HTTPRequest es_request(HTTPRequest::HTTP_POST,uri.getPathAndQuery(),HTTPRequest::HTTP_1_1);
    es_request.setContentType("multipart/form-data");
    HTMLForm form;
    form.setEncoding(HTMLForm::ENCODING_MULTIPART);
    form.add("api_key", "-6zs61jR1M4GqzE9jIO3eiL1W1sojaeE");
    form.add("api_secret", "J82yKgSplMDppw9oPpHeTVTA4hYxp0iB");
    form.add("return_landmark", "left_eyebrow,right_eyebrow");
    //图片base64编码
    //读取图片,获得字节数组和Mat
    vector<unsigned char> data;
    ifstream ifs(motePath,ios::binary);
    if(ifs.is_open()){
        char buf[1024];
        while(ifs.read(buf, sizeof(buf))){
            streamsize gcount = ifs.gcount();
            for (int i = 0; i < gcount; ++i){
                data.push_back(buf[i]);
            }
        }
        streamsize gcount = ifs.gcount();
        if(gcount>0){
            for (int i = 0; i < gcount; ++i){
                data.push_back(buf[i]);
            }
        }
        cv::Mat mat = cv::imdecode(data,CV_LOAD_IMAGE_COLOR);
        unsigned char tmp[data.size()];
        for (int i = 0; i < data.size(); ++i){
            tmp[i] = data.at(i);
        }
        ZBase64 zBase64;
        string base64Str;
        zBase64.Encode(tmp,data.size(),base64Str);
        form.add("image_base64",base64Str);
        form.prepareSubmit(es_request);
        form.write(session.sendRequest(es_request));
        HTTPResponse es_response;
        std::istream &istream = session.receiveResponse(es_response);
        const HTTPResponse::HTTPStatus &status = es_response.getStatus();
        if(HTTPResponse::HTTPStatus::HTTP_OK == status) {
//        if(true) {
            std::string stRes;
            StreamCopier::copyToString(istream, stRes);
            std::cout << stRes << std::endl;
//            string stRes = "{\"time_used\": 155, \"request_id\": \"1618825817,bbcc62bb-db7b-4f65-ac74-8c3c408f27c6\", \"face\": {\"landmark\": {\"right_eyebrow\": {\"right_eyebrow_56\": {\"y\": 363, \"x\": 529}, \"right_eyebrow_57\": {\"y\": 363, \"x\": 532}, \"right_eyebrow_54\": {\"y\": 362, \"x\": 523}, \"right_eyebrow_55\": {\"y\": 362, \"x\": 526}, \"right_eyebrow_38\": {\"y\": 366, \"x\": 477}, \"right_eyebrow_39\": {\"y\": 365, \"x\": 480}, \"right_eyebrow_50\": {\"y\": 362, \"x\": 512}, \"right_eyebrow_51\": {\"y\": 362, \"x\": 514}, \"right_eyebrow_34\": {\"y\": 365, \"x\": 465}, \"right_eyebrow_35\": {\"y\": 366, \"x\": 468}, \"right_eyebrow_36\": {\"y\": 366, \"x\": 471}, \"right_eyebrow_37\": {\"y\": 366, \"x\": 474}, \"right_eyebrow_30\": {\"y\": 355, \"x\": 465}, \"right_eyebrow_31\": {\"y\": 358, \"x\": 464}, \"right_eyebrow_32\": {\"y\": 361, \"x\": 463}, \"right_eyebrow_33\": {\"y\": 364, \"x\": 464}, \"right_eyebrow_12\": {\"y\": 349, \"x\": 520}, \"right_eyebrow_13\": {\"y\": 349, \"x\": 517}, \"right_eyebrow_10\": {\"y\": 350, \"x\": 527}, \"right_eyebrow_11\": {\"y\": 349, \"x\": 524}, \"right_eyebrow_16\": {\"y\": 349, \"x\": 508}, \"right_eyebrow_17\": {\"y\": 349, \"x\": 505}, \"right_eyebrow_14\": {\"y\": 349, \"x\": 514}, \"right_eyebrow_15\": {\"y\": 349, \"x\": 511}, \"right_eyebrow_52\": {\"y\": 362, \"x\": 517}, \"right_eyebrow_18\": {\"y\": 349, \"x\": 502}, \"right_eyebrow_19\": {\"y\": 349, \"x\": 499}, \"right_eyebrow_53\": {\"y\": 362, \"x\": 520}, \"right_eyebrow_44\": {\"y\": 363, \"x\": 494}, \"right_eyebrow_41\": {\"y\": 364, \"x\": 485}, \"right_eyebrow_58\": {\"y\": 363, \"x\": 535}, \"right_eyebrow_40\": {\"y\": 365, \"x\": 482}, \"right_eyebrow_43\": {\"y\": 364, \"x\": 491}, \"right_eyebrow_49\": {\"y\": 362, \"x\": 509}, \"right_eyebrow_48\": {\"y\": 362, \"x\": 506}, \"right_eyebrow_61\": {\"y\": 365, \"x\": 543}, \"right_eyebrow_42\": {\"y\": 364, \"x\": 488}, \"right_eyebrow_29\": {\"y\": 354, \"x\": 468}, \"right_eyebrow_28\": {\"y\": 352, \"x\": 471}, \"right_eyebrow_27\": {\"y\": 352, \"x\": 474}, \"right_eyebrow_26\": {\"y\": 351, \"x\": 477}, \"right_eyebrow_25\": {\"y\": 351, \"x\": 480}, \"right_eyebrow_24\": {\"y\": 350, \"x\": 483}, \"right_eyebrow_23\": {\"y\": 350, \"x\": 486}, \"right_eyebrow_22\": {\"y\": 350, \"x\": 489}, \"right_eyebrow_21\": {\"y\": 350, \"x\": 492}, \"right_eyebrow_20\": {\"y\": 349, \"x\": 495}, \"right_eyebrow_59\": {\"y\": 364, \"x\": 538}, \"right_eyebrow_47\": {\"y\": 363, \"x\": 503}, \"right_eyebrow_60\": {\"y\": 365, \"x\": 541}, \"right_eyebrow_46\": {\"y\": 363, \"x\": 500}, \"right_eyebrow_45\": {\"y\": 363, \"x\": 497}, \"right_eyebrow_8\": {\"y\": 352, \"x\": 533}, \"right_eyebrow_9\": {\"y\": 351, \"x\": 530}, \"right_eyebrow_0\": {\"y\": 366, \"x\": 552}, \"right_eyebrow_1\": {\"y\": 363, \"x\": 551}, \"right_eyebrow_2\": {\"y\": 361, \"x\": 549}, \"right_eyebrow_3\": {\"y\": 359, \"x\": 546}, \"right_eyebrow_4\": {\"y\": 357, \"x\": 544}, \"right_eyebrow_5\": {\"y\": 355, \"x\": 541}, \"right_eyebrow_6\": {\"y\": 354, \"x\": 538}, \"right_eyebrow_7\": {\"y\": 353, \"x\": 536}, \"right_eyebrow_62\": {\"y\": 366, \"x\": 546}, \"right_eyebrow_63\": {\"y\": 367, \"x\": 549}}, \"left_eyebrow\": {\"left_eyebrow_54\": {\"y\": 361, \"x\": 331}, \"left_eyebrow_55\": {\"y\": 361, \"x\": 329}, \"left_eyebrow_52\": {\"y\": 361, \"x\": 337}, \"left_eyebrow_53\": {\"y\": 361, \"x\": 334}, \"left_eyebrow_50\": {\"y\": 361, \"x\": 343}, \"left_eyebrow_51\": {\"y\": 361, \"x\": 340}, \"left_eyebrow_56\": {\"y\": 362, \"x\": 326}, \"left_eyebrow_57\": {\"y\": 362, \"x\": 323}, \"left_eyebrow_18\": {\"y\": 349, \"x\": 352}, \"left_eyebrow_19\": {\"y\": 349, \"x\": 356}, \"left_eyebrow_16\": {\"y\": 349, \"x\": 346}, \"left_eyebrow_17\": {\"y\": 349, \"x\": 349}, \"left_eyebrow_14\": {\"y\": 348, \"x\": 340}, \"left_eyebrow_15\": {\"y\": 348, \"x\": 343}, \"left_eyebrow_12\": {\"y\": 349, \"x\": 334}, \"left_eyebrow_13\": {\"y\": 349, \"x\": 337}, \"left_eyebrow_10\": {\"y\": 349, \"x\": 328}, \"left_eyebrow_11\": {\"y\": 349, \"x\": 331}, \"left_eyebrow_34\": {\"y\": 364, \"x\": 389}, \"left_eyebrow_35\": {\"y\": 365, \"x\": 386}, \"left_eyebrow_36\": {\"y\": 365, \"x\": 383}, \"left_eyebrow_37\": {\"y\": 365, \"x\": 380}, \"left_eyebrow_30\": {\"y\": 354, \"x\": 388}, \"left_eyebrow_31\": {\"y\": 357, \"x\": 390}, \"left_eyebrow_32\": {\"y\": 360, \"x\": 391}, \"left_eyebrow_33\": {\"y\": 363, \"x\": 390}, \"left_eyebrow_38\": {\"y\": 365, \"x\": 378}, \"left_eyebrow_39\": {\"y\": 364, \"x\": 375}, \"left_eyebrow_4\": {\"y\": 355, \"x\": 311}, \"left_eyebrow_5\": {\"y\": 354, \"x\": 313}, \"left_eyebrow_6\": {\"y\": 352, \"x\": 316}, \"left_eyebrow_7\": {\"y\": 351, \"x\": 319}, \"left_eyebrow_0\": {\"y\": 364, \"x\": 303}, \"left_eyebrow_1\": {\"y\": 361, \"x\": 304}, \"left_eyebrow_2\": {\"y\": 359, \"x\": 306}, \"left_eyebrow_3\": {\"y\": 357, \"x\": 308}, \"left_eyebrow_8\": {\"y\": 350, \"x\": 322}, \"left_eyebrow_9\": {\"y\": 350, \"x\": 325}, \"left_eyebrow_45\": {\"y\": 362, \"x\": 358}, \"left_eyebrow_44\": {\"y\": 363, \"x\": 360}, \"left_eyebrow_47\": {\"y\": 362, \"x\": 352}, \"left_eyebrow_46\": {\"y\": 362, \"x\": 355}, \"left_eyebrow_41\": {\"y\": 364, \"x\": 369}, \"left_eyebrow_40\": {\"y\": 364, \"x\": 372}, \"left_eyebrow_43\": {\"y\": 363, \"x\": 363}, \"left_eyebrow_42\": {\"y\": 363, \"x\": 366}, \"left_eyebrow_63\": {\"y\": 364, \"x\": 305}, \"left_eyebrow_62\": {\"y\": 364, \"x\": 308}, \"left_eyebrow_61\": {\"y\": 363, \"x\": 311}, \"left_eyebrow_60\": {\"y\": 363, \"x\": 314}, \"left_eyebrow_49\": {\"y\": 362, \"x\": 346}, \"left_eyebrow_48\": {\"y\": 362, \"x\": 349}, \"left_eyebrow_27\": {\"y\": 351, \"x\": 380}, \"left_eyebrow_26\": {\"y\": 350, \"x\": 377}, \"left_eyebrow_25\": {\"y\": 350, \"x\": 374}, \"left_eyebrow_24\": {\"y\": 350, \"x\": 371}, \"left_eyebrow_23\": {\"y\": 349, \"x\": 368}, \"left_eyebrow_22\": {\"y\": 349, \"x\": 365}, \"left_eyebrow_21\": {\"y\": 349, \"x\": 362}, \"left_eyebrow_20\": {\"y\": 349, \"x\": 359}, \"left_eyebrow_58\": {\"y\": 362, \"x\": 320}, \"left_eyebrow_29\": {\"y\": 353, \"x\": 386}, \"left_eyebrow_28\": {\"y\": 352, \"x\": 383}, \"left_eyebrow_59\": {\"y\": 363, \"x\": 317}}}, \"face_rectangle\": {\"width\": 301, \"top\": 342, \"height\": 300, \"left\": 280}}}";
            Poco::JSON::Parser parser;
            const Dynamic::Var &var = parser.parse(stRes);
            if(!var.isEmpty()){
                const JSON::Object::Ptr &resObj = var.extract<Poco::JSON::Object::Ptr>();
                const JSON::Object::Ptr &landmarkObj = resObj->getObject("face")->getObject("landmark");
                const JSON::Object::Ptr &right_eyebrow = landmarkObj->getObject("right_eyebrow");
                const JSON::Object::Ptr &left_eyebrow = landmarkObj->getObject("left_eyebrow");
                //画出眉毛轮廓
                std::vector<cv::Point> rightContours;
                std::vector<cv::Point> leftContours;
                //找出眼周leftContours中x坐标最大,最小值;y最大最小值
                int l_x_min = 0x7FFFFFFF,l_x_max=0,l_y_min = 0x7FFFFFFF,l_y_max=0;
                //找出眼周rightContours中x坐标最大,最小值;y最大最小值
                int r_x_min = 0x7FFFFFFF,r_x_max=0,r_y_min = 0x7FFFFFFF,r_y_max=0;
                for(int i=0;i<64;++i){
                    const JSON::Object::Ptr &pPtr = right_eyebrow->getObject("right_eyebrow_" + to_string(i));
                    int x = pPtr->get("x");
                    int y = pPtr->get("y");
                    if(x>r_x_max){
                        r_x_max = x;
                    }
                    if(x<r_x_min){
                        r_x_min = x;
                    }
                    if(y>r_y_max){
                        r_y_max = y;
                    }
                    if(y<r_y_min){
                        r_y_min = y;
                    }
//                    circle(mat,cv::Point(x,y),1,cv::Scalar(0,0,255));
                    rightContours.push_back(cv::Point(x,y));
                }
                for(int i=0;i<64;++i){
                    const JSON::Object::Ptr &pPtr = left_eyebrow->getObject("left_eyebrow_" + to_string(i));
                    int x = pPtr->get("x");
                    int y = pPtr->get("y");
                    if(x>l_x_max){
                        l_x_max = x;
                    }
                    if(x<l_x_min){
                        l_x_min = x;
                    }
                    if(y>l_y_max){
                        l_y_max = y;
                    }
                    if(y<l_y_min){
                        l_y_min = y;
                    }
//                    circle(mat,cv::Point(x,y),1,cv::Scalar(0,0,255));
                    leftContours.push_back(cv::Point(x,y));
                }
                //创建修补模板
                cv::Mat repairMask;
                int width = mat.cols,height = mat.rows;
                repairMask.create(height,width,CV_8UC1);
                //判断出不在轮廓中的点,用肤色像素值填充
                for(int y=0;y<height;++y){
                    for(int x=0;x<width;++x){
                        if(cv::pointPolygonTest(leftContours,cv::Point(x,y),false)==1||cv::pointPolygonTest(rightContours,cv::Point(x,y),false)==1){
                            repairMask.at<uchar>(y,x)=255;
                        }
                    }
                }
//                imshow("repairMask",repairMask);
                //将轮廓附近的点也做肤色填充
                for(int y=0;y<height;++y){
                    for(int x=0;x<width;++x){
                        if(x>l_x_min-6&&x<l_x_max+6&&y>l_y_min-6&&y<l_y_max+6) {
                            for (auto &point:leftContours) {
                                if (getDistance(point, cv::Point(x, y)) <= 4) {
                                    repairMask.at<uchar>(y, x) = 255;
                                }
                            }
                        }
                        if(x>r_x_min-6&&x<r_x_max+6&&y>r_y_min-6&&y<r_y_max+6) {
                            for (auto &point:rightContours) {
                                if (getDistance(point, cv::Point(x, y)) <= 6) {
                                    repairMask.at<uchar>(y, x) = 255;
                                }
                            }
                        }
                    }
                }
                //inpaint 修复
                inpaint(mat,repairMask,mat,4,INPAINT_NS);
//                inpaint(mat,repairMask,mat,4,cv::INPAINT_TELEA);
                //获取右眉毛3个关键点坐标
                JSON::Object::Ptr pointPtr;
                JSON::Object::Ptr eyebrow = right_eyebrow;
                int srcFacePoints[2*3];
                pointPtr = eyebrow->getObject("right_eyebrow_0");
                int x_0 = pointPtr->get("x");
                int y_0 = pointPtr->get("y");
                srcFacePoints[2*2] = x_0;
                srcFacePoints[2*2+1] = y_0;
//                    circle(mat,cv::Point(pointPtr->get("x"),pointPtr->get("y")),1,cv::Scalar(0,0,255));
                pointPtr = eyebrow->getObject("right_eyebrow_32");
                int x_32 = pointPtr->get("x");
                int y_32 = pointPtr->get("y");
                srcFacePoints[2*0] = x_32-4;
                srcFacePoints[2*0+1] = y_32+4;
//                    circle(mat,Point(srcFacePoints[2*0],srcFacePoints[2*0+1]),1,cv::Scalar(0,0,255));
                pointPtr = eyebrow->getObject("right_eyebrow_15");
                int x_15 = pointPtr->get("x");
                int y_15 = pointPtr->get("y");
//                    circle(mat,cv::Point(pointPtr->get("x"),pointPtr->get("y")),1,cv::Scalar(0,0,255));
                pointPtr = eyebrow->getObject("right_eyebrow_47");
                int x_47 = pointPtr->get("x");
                int y_47 = pointPtr->get("y");
//                    circle(mat,cv::Point(pointPtr->get("x"),pointPtr->get("y")),1,cv::Scalar(0,0,255));
                srcFacePoints[2*1] = (x_15+x_47)/2;
                srcFacePoints[2*1+1] = (y_15+y_47)/2;
//                circle(mat,cv::Point(srcFacePoints[2*1],srcFacePoints[2*1+1]),1,cv::Scalar(0,0,255));
                //右眉毛融合
                cv::Mat mask = cv::imread(maskPath, CV_LOAD_IMAGE_UNCHANGED);
                cout << "mask.type():" << mask.type() << endl;
                cout << "A:" << int(mask.at<Vec4b>(Point(241,76))[3]) << endl;
//                imshow("mask",mask);
                cv::cvtColor(mat,mat,cv::COLOR_BGR2BGRA);
                unsigned char* srcData = mat.data;
                int stride=width*mat.channels();
                unsigned char* mskData = mask.data;
                cout << mask.channels() << endl;
                int mWidth=mask.cols, mHeight=mask.rows,  mStride=mWidth*mask.channels();

                //右眉毛模板融合
//                f_EyeBrowTest(mat,  width,  height,  stride,  srcFacePoints,  mask,  mWidth,  mHeight,  mStride,  rightMaskKeyPoints,  false,  ratio,mask);
                f_EyeBrow(srcData,  width,  height,  stride,  srcFacePoints,  mskData,  mWidth,  mHeight,  mStride,  rightMaskKeyPoints,  false,  ratio);
                //左眉毛融合
                srcData = mat.data;
                //模板翻转
                cv::Mat mirrorMask;
                cv::flip(mask,mirrorMask,1);
//                imshow("mirrorMask",mirrorMask);
//                imwrite("./mirrorMask.png",mirrorMask);
                mskData = mirrorMask.data;
                mWidth=mirrorMask.cols, mHeight=mirrorMask.rows,  mStride=mWidth*mirrorMask.channels();
                //获取左眉毛3个关键点坐标
                eyebrow = left_eyebrow;
                pointPtr = eyebrow->getObject("left_eyebrow_0");
                x_0 = pointPtr->get("x");
                y_0 = pointPtr->get("y");
                srcFacePoints[2*0] = x_0;
                srcFacePoints[2*0+1] = y_0;
//                    circle(mat,cv::Point(pointPtr->get("x"),pointPtr->get("y")),1,cv::Scalar(0,0,255));
                pointPtr = eyebrow->getObject("left_eyebrow_32");
                x_32 = pointPtr->get("x");
                y_32 = pointPtr->get("y");
                srcFacePoints[2*2] = x_32+4;
                srcFacePoints[2*2+1] = y_32+4;
//                    circle(mat,cv::Point(srcFacePoints[2*2],srcFacePoints[2*2+1]),1,cv::Scalar(0,0,255));
                pointPtr = eyebrow->getObject("left_eyebrow_15");
                x_15 = pointPtr->get("x");
                y_15 = pointPtr->get("y");
//                    circle(mat,cv::Point(pointPtr->get("x"),pointPtr->get("y")),1,cv::Scalar(0,0,255));
                pointPtr = eyebrow->getObject("left_eyebrow_47");
                x_47 = pointPtr->get("x");
                y_47 = pointPtr->get("y");
//                    circle(mat,cv::Point(pointPtr->get("x"),pointPtr->get("y")),1,cv::Scalar(0,0,255));
                srcFacePoints[2*1] = (x_15+x_47)/2;
                srcFacePoints[2*1+1] = (y_15+y_47)/2;
                f_EyeBrow(srcData,  width,  height,  stride,  srcFacePoints,  mskData,  mWidth,  mHeight,  mStride,  leftMaskKeyPoints,  true,  ratio);
//                circle(mat,cv::Point(srcFacePoints[2*1],srcFacePoints[2*1+1]),1,cv::Scalar(255,0,0));
                imwrite("美眉"+modelName+".jpg",mat);
                cv::cvtColor(mat,mat,cv::COLOR_BGRA2BGR);
                imshow("美眉"+modelName,mat);
                waitKey(0);
            }
        }

    }else{
        return 1;
    }

    return 0;
}

int main2(int argc, char* argv[]){
    Poco::Stopwatch stopwatch;
    stopwatch.start();
//    string direct = string(argv[1]);
    URI uri("https://api-cn.faceplusplus.com/facepp/v1/face/thousandlandmark");
    const Poco::Net::Context::Ptr context(
            new Poco::Net::Context(Poco::Net::Context::CLIENT_USE, "", "", "",
                                   Poco::Net::Context::VERIFY_NONE));
    Poco::Net::HTTPSClientSession session(uri.getHost(), uri.getPort(), context);
    HTTPRequest es_request(HTTPRequest::HTTP_POST,uri.getPathAndQuery(),HTTPRequest::HTTP_1_1);
    es_request.setContentType("multipart/form-data");
    HTMLForm form;
    form.setEncoding(HTMLForm::ENCODING_MULTIPART);
    form.add("api_key", "-6zs61jR1M4GqzE9jIO3eiL1W1sojaeE");
    form.add("api_secret", "J82yKgSplMDppw9oPpHeTVTA4hYxp0iB");
    form.add("return_landmark", "left_eyebrow,right_eyebrow");
    //图片base64编码
    //读取图片,获得字节数组和Mat
    vector<unsigned char> data;
    string imgPath = "/Users/edz/Downloads/合集/模特/自然唇.png";
    ifstream ifs(imgPath,ios::binary);
    if(ifs.is_open()){
        char buf[1024];
        while(ifs.read(buf, sizeof(buf))){
            streamsize gcount = ifs.gcount();
            for (int i = 0; i < gcount; ++i){
                data.push_back(buf[i]);
            }
        }
        streamsize gcount = ifs.gcount();
        if(gcount>0){
            for (int i = 0; i < gcount; ++i){
                data.push_back(buf[i]);
            }
        }
        cv::Mat mat = cv::imdecode(data,CV_LOAD_IMAGE_COLOR);
        unsigned char tmp[data.size()];
        for (int i = 0; i < data.size(); ++i){
            tmp[i] = data.at(i);
        }
        ZBase64 zBase64;
        string base64Str;
        zBase64.Encode(tmp,data.size(),base64Str);
        form.add("image_base64",base64Str);
//        form.prepareSubmit(es_request);
//        form.write(session.sendRequest(es_request));
//        HTTPResponse es_response;
//        std::istream &istream = session.receiveResponse(es_response);
//        const HTTPResponse::HTTPStatus &status = es_response.getStatus();
//        if(HTTPResponse::HTTPStatus::HTTP_OK == status) {
        if(true) {
//            std::string stRes;
//            StreamCopier::copyToString(istream, stRes);
//            std::cout << stRes << std::endl;
            string stRes = "{\"time_used\": 155, \"request_id\": \"1618825817,bbcc62bb-db7b-4f65-ac74-8c3c408f27c6\", \"face\": {\"landmark\": {\"right_eyebrow\": {\"right_eyebrow_56\": {\"y\": 363, \"x\": 529}, \"right_eyebrow_57\": {\"y\": 363, \"x\": 532}, \"right_eyebrow_54\": {\"y\": 362, \"x\": 523}, \"right_eyebrow_55\": {\"y\": 362, \"x\": 526}, \"right_eyebrow_38\": {\"y\": 366, \"x\": 477}, \"right_eyebrow_39\": {\"y\": 365, \"x\": 480}, \"right_eyebrow_50\": {\"y\": 362, \"x\": 512}, \"right_eyebrow_51\": {\"y\": 362, \"x\": 514}, \"right_eyebrow_34\": {\"y\": 365, \"x\": 465}, \"right_eyebrow_35\": {\"y\": 366, \"x\": 468}, \"right_eyebrow_36\": {\"y\": 366, \"x\": 471}, \"right_eyebrow_37\": {\"y\": 366, \"x\": 474}, \"right_eyebrow_30\": {\"y\": 355, \"x\": 465}, \"right_eyebrow_31\": {\"y\": 358, \"x\": 464}, \"right_eyebrow_32\": {\"y\": 361, \"x\": 463}, \"right_eyebrow_33\": {\"y\": 364, \"x\": 464}, \"right_eyebrow_12\": {\"y\": 349, \"x\": 520}, \"right_eyebrow_13\": {\"y\": 349, \"x\": 517}, \"right_eyebrow_10\": {\"y\": 350, \"x\": 527}, \"right_eyebrow_11\": {\"y\": 349, \"x\": 524}, \"right_eyebrow_16\": {\"y\": 349, \"x\": 508}, \"right_eyebrow_17\": {\"y\": 349, \"x\": 505}, \"right_eyebrow_14\": {\"y\": 349, \"x\": 514}, \"right_eyebrow_15\": {\"y\": 349, \"x\": 511}, \"right_eyebrow_52\": {\"y\": 362, \"x\": 517}, \"right_eyebrow_18\": {\"y\": 349, \"x\": 502}, \"right_eyebrow_19\": {\"y\": 349, \"x\": 499}, \"right_eyebrow_53\": {\"y\": 362, \"x\": 520}, \"right_eyebrow_44\": {\"y\": 363, \"x\": 494}, \"right_eyebrow_41\": {\"y\": 364, \"x\": 485}, \"right_eyebrow_58\": {\"y\": 363, \"x\": 535}, \"right_eyebrow_40\": {\"y\": 365, \"x\": 482}, \"right_eyebrow_43\": {\"y\": 364, \"x\": 491}, \"right_eyebrow_49\": {\"y\": 362, \"x\": 509}, \"right_eyebrow_48\": {\"y\": 362, \"x\": 506}, \"right_eyebrow_61\": {\"y\": 365, \"x\": 543}, \"right_eyebrow_42\": {\"y\": 364, \"x\": 488}, \"right_eyebrow_29\": {\"y\": 354, \"x\": 468}, \"right_eyebrow_28\": {\"y\": 352, \"x\": 471}, \"right_eyebrow_27\": {\"y\": 352, \"x\": 474}, \"right_eyebrow_26\": {\"y\": 351, \"x\": 477}, \"right_eyebrow_25\": {\"y\": 351, \"x\": 480}, \"right_eyebrow_24\": {\"y\": 350, \"x\": 483}, \"right_eyebrow_23\": {\"y\": 350, \"x\": 486}, \"right_eyebrow_22\": {\"y\": 350, \"x\": 489}, \"right_eyebrow_21\": {\"y\": 350, \"x\": 492}, \"right_eyebrow_20\": {\"y\": 349, \"x\": 495}, \"right_eyebrow_59\": {\"y\": 364, \"x\": 538}, \"right_eyebrow_47\": {\"y\": 363, \"x\": 503}, \"right_eyebrow_60\": {\"y\": 365, \"x\": 541}, \"right_eyebrow_46\": {\"y\": 363, \"x\": 500}, \"right_eyebrow_45\": {\"y\": 363, \"x\": 497}, \"right_eyebrow_8\": {\"y\": 352, \"x\": 533}, \"right_eyebrow_9\": {\"y\": 351, \"x\": 530}, \"right_eyebrow_0\": {\"y\": 366, \"x\": 552}, \"right_eyebrow_1\": {\"y\": 363, \"x\": 551}, \"right_eyebrow_2\": {\"y\": 361, \"x\": 549}, \"right_eyebrow_3\": {\"y\": 359, \"x\": 546}, \"right_eyebrow_4\": {\"y\": 357, \"x\": 544}, \"right_eyebrow_5\": {\"y\": 355, \"x\": 541}, \"right_eyebrow_6\": {\"y\": 354, \"x\": 538}, \"right_eyebrow_7\": {\"y\": 353, \"x\": 536}, \"right_eyebrow_62\": {\"y\": 366, \"x\": 546}, \"right_eyebrow_63\": {\"y\": 367, \"x\": 549}}, \"left_eyebrow\": {\"left_eyebrow_54\": {\"y\": 361, \"x\": 331}, \"left_eyebrow_55\": {\"y\": 361, \"x\": 329}, \"left_eyebrow_52\": {\"y\": 361, \"x\": 337}, \"left_eyebrow_53\": {\"y\": 361, \"x\": 334}, \"left_eyebrow_50\": {\"y\": 361, \"x\": 343}, \"left_eyebrow_51\": {\"y\": 361, \"x\": 340}, \"left_eyebrow_56\": {\"y\": 362, \"x\": 326}, \"left_eyebrow_57\": {\"y\": 362, \"x\": 323}, \"left_eyebrow_18\": {\"y\": 349, \"x\": 352}, \"left_eyebrow_19\": {\"y\": 349, \"x\": 356}, \"left_eyebrow_16\": {\"y\": 349, \"x\": 346}, \"left_eyebrow_17\": {\"y\": 349, \"x\": 349}, \"left_eyebrow_14\": {\"y\": 348, \"x\": 340}, \"left_eyebrow_15\": {\"y\": 348, \"x\": 343}, \"left_eyebrow_12\": {\"y\": 349, \"x\": 334}, \"left_eyebrow_13\": {\"y\": 349, \"x\": 337}, \"left_eyebrow_10\": {\"y\": 349, \"x\": 328}, \"left_eyebrow_11\": {\"y\": 349, \"x\": 331}, \"left_eyebrow_34\": {\"y\": 364, \"x\": 389}, \"left_eyebrow_35\": {\"y\": 365, \"x\": 386}, \"left_eyebrow_36\": {\"y\": 365, \"x\": 383}, \"left_eyebrow_37\": {\"y\": 365, \"x\": 380}, \"left_eyebrow_30\": {\"y\": 354, \"x\": 388}, \"left_eyebrow_31\": {\"y\": 357, \"x\": 390}, \"left_eyebrow_32\": {\"y\": 360, \"x\": 391}, \"left_eyebrow_33\": {\"y\": 363, \"x\": 390}, \"left_eyebrow_38\": {\"y\": 365, \"x\": 378}, \"left_eyebrow_39\": {\"y\": 364, \"x\": 375}, \"left_eyebrow_4\": {\"y\": 355, \"x\": 311}, \"left_eyebrow_5\": {\"y\": 354, \"x\": 313}, \"left_eyebrow_6\": {\"y\": 352, \"x\": 316}, \"left_eyebrow_7\": {\"y\": 351, \"x\": 319}, \"left_eyebrow_0\": {\"y\": 364, \"x\": 303}, \"left_eyebrow_1\": {\"y\": 361, \"x\": 304}, \"left_eyebrow_2\": {\"y\": 359, \"x\": 306}, \"left_eyebrow_3\": {\"y\": 357, \"x\": 308}, \"left_eyebrow_8\": {\"y\": 350, \"x\": 322}, \"left_eyebrow_9\": {\"y\": 350, \"x\": 325}, \"left_eyebrow_45\": {\"y\": 362, \"x\": 358}, \"left_eyebrow_44\": {\"y\": 363, \"x\": 360}, \"left_eyebrow_47\": {\"y\": 362, \"x\": 352}, \"left_eyebrow_46\": {\"y\": 362, \"x\": 355}, \"left_eyebrow_41\": {\"y\": 364, \"x\": 369}, \"left_eyebrow_40\": {\"y\": 364, \"x\": 372}, \"left_eyebrow_43\": {\"y\": 363, \"x\": 363}, \"left_eyebrow_42\": {\"y\": 363, \"x\": 366}, \"left_eyebrow_63\": {\"y\": 364, \"x\": 305}, \"left_eyebrow_62\": {\"y\": 364, \"x\": 308}, \"left_eyebrow_61\": {\"y\": 363, \"x\": 311}, \"left_eyebrow_60\": {\"y\": 363, \"x\": 314}, \"left_eyebrow_49\": {\"y\": 362, \"x\": 346}, \"left_eyebrow_48\": {\"y\": 362, \"x\": 349}, \"left_eyebrow_27\": {\"y\": 351, \"x\": 380}, \"left_eyebrow_26\": {\"y\": 350, \"x\": 377}, \"left_eyebrow_25\": {\"y\": 350, \"x\": 374}, \"left_eyebrow_24\": {\"y\": 350, \"x\": 371}, \"left_eyebrow_23\": {\"y\": 349, \"x\": 368}, \"left_eyebrow_22\": {\"y\": 349, \"x\": 365}, \"left_eyebrow_21\": {\"y\": 349, \"x\": 362}, \"left_eyebrow_20\": {\"y\": 349, \"x\": 359}, \"left_eyebrow_58\": {\"y\": 362, \"x\": 320}, \"left_eyebrow_29\": {\"y\": 353, \"x\": 386}, \"left_eyebrow_28\": {\"y\": 352, \"x\": 383}, \"left_eyebrow_59\": {\"y\": 363, \"x\": 317}}}, \"face_rectangle\": {\"width\": 301, \"top\": 342, \"height\": 300, \"left\": 280}}}";
            Poco::JSON::Parser parser;
            const Dynamic::Var &var = parser.parse(stRes);
            if(!var.isEmpty()){
                const JSON::Object::Ptr &resObj = var.extract<Poco::JSON::Object::Ptr>();
                const JSON::Object::Ptr &landmarkObj = resObj->getObject("face")->getObject("landmark");
                const JSON::Object::Ptr &right_eyebrow = landmarkObj->getObject("right_eyebrow");
                const JSON::Object::Ptr &left_eyebrow = landmarkObj->getObject("left_eyebrow");
                JSON::Object::Ptr pointPtr;
                JSON::Object::Ptr eyebrow;
                vector<string> directs = {"right"};
                int srcFacePoints[2*3];
                for(auto direct:directs){
                    if(direct=="right"){
                        eyebrow = right_eyebrow;
                    }else{
                        eyebrow = left_eyebrow;
                    }
                    pointPtr = eyebrow->getObject(direct+"_eyebrow_0");
                    int x_0 = pointPtr->get("x");
                    int y_0 = pointPtr->get("y");
                    srcFacePoints[2*2] = x_0;
                    srcFacePoints[2*2+1] = y_0;
//                    circle(mat,cv::Point(pointPtr->get("x"),pointPtr->get("y")),1,cv::Scalar(0,0,255));
                    pointPtr = eyebrow->getObject(direct+"_eyebrow_32");
                    int x_32 = pointPtr->get("x");
                    int y_32 = pointPtr->get("y");
                    srcFacePoints[2*0] = x_32;
                    srcFacePoints[2*0+1] = y_32;
//                    circle(mat,cv::Point(pointPtr->get("x"),pointPtr->get("y")),1,cv::Scalar(0,0,255));
                    pointPtr = eyebrow->getObject(direct+"_eyebrow_15");
                    int x_15 = pointPtr->get("x");
                    int y_15 = pointPtr->get("y");
//                    circle(mat,cv::Point(pointPtr->get("x"),pointPtr->get("y")),1,cv::Scalar(0,0,255));
                    pointPtr = eyebrow->getObject(direct+"_eyebrow_47");
                    int x_47 = pointPtr->get("x");
                    int y_47 = pointPtr->get("y");
//                    circle(mat,cv::Point(pointPtr->get("x"),pointPtr->get("y")),1,cv::Scalar(0,0,255));
                    srcFacePoints[2*1] = (x_15+x_47)/2;
                    srcFacePoints[2*1+1] = (y_15+y_47)/2;
                }
                string imgPath = "/Users/edz/Downloads/meimao2.png";
                int maskKeyPoints[2 * 3]={1,48,125,17,262,45};
//                cv::Mat mask = cv::imread(imgPath);
                cv::Mat mask = cv::imread(imgPath, CV_LOAD_IMAGE_UNCHANGED);
                //模板翻转
                cv::Mat mirrorMask;
                cv::flip(mask,mirrorMask,1);
                imshow("mirrorMask",mirrorMask);



                circle(mask,cv::Point(maskKeyPoints[2*0],maskKeyPoints[2*0+1]),1,cv::Scalar(0,0,255));
                circle(mask,cv::Point(maskKeyPoints[2*1],maskKeyPoints[2*1+1]),1,cv::Scalar(0,0,255));
                circle(mask,cv::Point(maskKeyPoints[2*2],maskKeyPoints[2*2+1]),1,cv::Scalar(0,0,255));
//                imshow("mask",mask);
                cv::Mat maskBGR;
//                cv::cvtColor(mask,maskBGR,cv::COLOR_BGRA2RGB);
//                imshow("maskBGR",maskBGR);
//                waitKey(0);
                //画出眉毛轮廓
                std::vector<cv::Point> contours;
                for(int i=0;i<64;++i){
                    const JSON::Object::Ptr &pPtr = landmarkObj->getObject("right_eyebrow")->getObject("right_eyebrow_" + to_string(i));
                    int x = pPtr->get("x");
                    int y = pPtr->get("y");
//                    circle(mat,cv::Point(x,y),1,cv::Scalar(0,0,255));
                    contours.push_back(cv::Point(x,y));
                }
                cout << cv::pointPolygonTest(contours,cv::Point(497,360),false) << endl;
                cout << cv::pointPolygonTest(contours,cv::Point(431,355),false) << endl;

//                cv::cvtColor(mask,mask,cv::COLOR_RGB2BGRA);
                unsigned char* srcData = mat.data;
                int width=mat.cols,height=mat.rows;
                //获取肤色像素值(428,337)
                Vec3b &vec3b = mat.at<Vec3b>(Point(428, 337));
                //创建修补模板
                cv::Mat repairMask;
                repairMask.create(height,width,CV_8UC1);
                //判断出不在轮廓中的点,用肤色像素值填充
                vector<Point> points;
                unsigned char* pSrc = srcData;
                for(int y=0;y<height;++y){
                    for(int x=0;x<width;++x){
                        if(cv::pointPolygonTest(contours,cv::Point(x,y),false)==1){
//                            pSrc[0] = vec3b[0];
//                            pSrc[1] = vec3b[1];
//                            pSrc[2] = vec3b[2];
                            repairMask.at<uchar>(y,x)=255;
                        }
                        pSrc += 3;
                        points.push_back(cv::Point(x,y));
                    }
                }
                imshow("repairMask",repairMask);
                //将轮廓附近的点也做肤色填充
                pSrc = srcData;
                for(int y=0;y<height;++y){
                    for(int x=0;x<width;++x){
                        for(auto& point:contours){
                            if(getDistance(point,cv::Point(x,y))<=6){
//                                pSrc[0] = vec3b[0];
//                                pSrc[1] = vec3b[1];
//                                pSrc[2] = vec3b[2];
                                repairMask.at<uchar>(y,x)=255;
                            }
                        }
                        pSrc += 3;
                    }
                }
                //inpaint 修复
                inpaint(mat,repairMask,mat,4,INPAINT_NS);

                cv::cvtColor(mat,mat,cv::COLOR_RGB2BGRA);
                int stride=width*mat.channels();
                unsigned char* mskData = mask.data;
                int mWidth=mask.cols, mHeight=mask.rows,  mStride=mWidth*mask.channels();
                bool isLeft = false;
                int ratio=100;
                srcData = mat.data;

                //眉毛模板融合
                f_EyeBrow(srcData,  width,  height,  stride,  srcFacePoints,  mskData,  mWidth,  mHeight,  mStride,  maskKeyPoints,  isLeft,  ratio);
                cv::cvtColor(mat,mat,cv::COLOR_BGRA2RGB);
                imshow("a",mat);
                waitKey(0);
            }
        }

    }else{
        return 1;
    }

    return 0;
}
int main1(int argc, char* argv[]){
    Poco::Stopwatch stopwatch;
    stopwatch.start();
    int x = stoi(string(argv[1]));
    int y = stoi(string(argv[2]));
    URI uri("https://api-cn.faceplusplus.com/facepp/v1/face/thousandlandmark");
    const Poco::Net::Context::Ptr context(
            new Poco::Net::Context(Poco::Net::Context::CLIENT_USE, "", "", "",
                                   Poco::Net::Context::VERIFY_NONE));
    Poco::Net::HTTPSClientSession session(uri.getHost(), uri.getPort(), context);
    HTTPRequest es_request(HTTPRequest::HTTP_POST,uri.getPathAndQuery(),HTTPRequest::HTTP_1_1);
    es_request.setContentType("multipart/form-data");
    HTMLForm form;
    form.setEncoding(HTMLForm::ENCODING_MULTIPART);
    form.add("api_key", "-6zs61jR1M4GqzE9jIO3eiL1W1sojaeE");
    form.add("api_secret", "J82yKgSplMDppw9oPpHeTVTA4hYxp0iB");
    form.add("return_landmark", "left_eyebrow,right_eyebrow");
    //图片base64编码
    //读取图片,获得字节数组和Mat
    vector<unsigned char> data;
    string imgPath = "/Users/edz/Downloads/meimao.jpeg";
    cv::Mat mat = cv::imread(imgPath);
    cout << mat.rows << endl;
    cout << mat.cols << endl;
    circle(mat,cv::Point(x,y),5,cv::Scalar(0,0,255));
    imshow("b",mat);
    waitKey(0);
    int arr[] = {161,205,378,202,270,177};
    return 0;
}
