houxiao
2017-04-25 521e435d5d63fc76097e6667ba5ef9bcd1393a7b
VisitFace/RtspNativeCodec/app/src/main/cpp/FaceCache.cpp
@@ -191,7 +191,7 @@
      cv::Mat roiMat(roiMat1.clone()); // #todo copy data should be avoid!!!!
      size_t s = roiMat.total() * roiMat.elemSize();
      PbFaceList_FaceListImage pbFaceListImage;
      PbFaceList_FaceListImage& pbFaceListImage(*(pbFaceList.add_images()));
      pbFaceListImage.set_idx(i);
      pbFaceListImage.set_size(s);
      pbFaceListImage.set_type(PbFaceList_FaceListImage_ImageType_IT_Y);
@@ -211,11 +211,32 @@
        //    fclose(pFile);
        //    if (f > 20)exit(0);
        //}
        //{
        //    static size_t f = 0;
        //    char fname[50];
        //    sprintf(fname, "/sdcard/face-%u.yuv", ++f);
        //    FILE *pFile = fopen(fname, "wb");
        //    const std::string* img(*pbFaceListImage.img().data());
        //    fwrite(img->data(), 1, img->size(), pFile);
        //    fclose(pFile);
        //    if (f > 20)exit(0);
        //}
    }
   size_t s = pbFaceList.ByteSize();
   buffMaxSize = std::min(s, buffMaxSize);
   pbFaceList.SerializeToArray(buffer, buffMaxSize);
    //{
    //    static size_t f = 0;
    //    char fname[50];
    //    sprintf(fname, "/sdcard/facelist-%u.pb", ++f);
    //    FILE *pFile = fopen(fname, "wb");
    //    fwrite(buffer, 1, buffMaxSize, pFile);
    //    fclose(pFile);
    //    if (f > 10)exit(0);
    //}
    return buffMaxSize > 0;
}
@@ -338,6 +359,16 @@
            return false;
        }
        /*
        uint8_t* pbuf = buffImg + imgidx.offset;
        uint8_t* psrc = ctx.frameRGB + (ctx.width * faceRect.leftTop.y + faceRect.leftTop.x) * 2;
        for (int row = 0; row < faceRect.height(); row++)
        {
            memcpy(pbuf, psrc, imgidx.width * 2);
            pbuf += imgidx.width * 2;
            psrc += ctx.width * 2;
        }
         */
        uint8_t* pbuf = buffImg + imgidx.offset;
        memcpy(pbuf, roiMat.ptr(), imgidx.size);
@@ -345,7 +376,7 @@
        //{
        //    static size_t f = 0;
        //    char fname[50];
        //    sprintf(fname, "/sdcard/face-%u.rgb565", ++f);
        //    sprintf(fname, "/sdcard/face-%u-w%d-h%d.rgb565", ++f, imgidx.width, imgidx.height);
        //    FILE *pFile = fopen(fname, "wb");
        //    fwrite(pbuf, 1, imgidx.size, pFile);
        //    fclose(pFile);