From 943e709dfb580c4aa277611ef169c54c446078b7 Mon Sep 17 00:00:00 2001
From: xuxiuxi <xuxiuxi@454eff88-639b-444f-9e54-f578c98de674>
Date: 星期一, 27 三月 2017 12:53:25 +0800
Subject: [PATCH]
---
VisitFace/RtspNativeCodec/app/src/main/cpp/FaceCache.cpp | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 115 insertions(+), 0 deletions(-)
diff --git a/VisitFace/RtspNativeCodec/app/src/main/cpp/FaceCache.cpp b/VisitFace/RtspNativeCodec/app/src/main/cpp/FaceCache.cpp
index bca2543..0b8e658 100644
--- a/VisitFace/RtspNativeCodec/app/src/main/cpp/FaceCache.cpp
+++ b/VisitFace/RtspNativeCodec/app/src/main/cpp/FaceCache.cpp
@@ -1,3 +1,118 @@
#include "FaceCache.h"
+#include "PipeLine.h"
+#include "MaterialBuffer.h"
+#include "PL_SensetimeFaceTrack.h"
#include <logger.h>
#include <Logger/src/logger.hpp>
+
+struct FcPmBreackerContext
+{
+ uint8_t frameYUV[1920*1080*4];
+ size_t frameYUVSize;
+
+ uint8_t frameRGB[1920*1080*4];
+ size_t frameRGBSize;
+
+ st_ff_vect_t faceFeatures;
+
+ bool dataAvailable;
+
+ FcPmBreackerContext() : frameYUV(), frameYUVSize(0), frameRGB(), frameRGBSize(0), faceFeatures(), dataAvailable(false)
+ {
+ }
+
+ void reset()
+ {
+ frameYUVSize = 0;
+ frameRGBSize = 0;
+ dataAvailable = false;
+ faceFeatures.clear();
+ }
+
+ bool convertYUV420ToRGB()
+ {
+ }
+};
+
+bool fc_pm_breaker_ptr(const PipeMaterial* pm, void* args)
+{
+ FcPmBreackerContext* ctx = (FcPmBreackerContext*)args;
+
+ const st_ff_vect_t& faceFeatures(*(const st_ff_vect_t*)(pm->buffer));
+
+ ctx->faceFeatures = faceFeatures;
+
+ ctx->dataAvailable &= true;
+ return false;
+}
+
+bool fc_pm_breaker_frame(const PipeMaterial* pm, void* args)
+{
+ FcPmBreackerContext* ctx = (FcPmBreackerContext*)args;
+
+ const MB_Frame* lastFrame((const MB_Frame*)(pm->buffer));
+ if (lastFrame->type != MB_Frame::MBFT_YUV420)
+ {
+ ctx->dataAvailable &= false;
+ return false;
+ }
+
+ if (lastFrame->buffSize == 0)
+ {
+ ctx->dataAvailable &= false;
+ return false;
+ }
+
+ ctx->frameYUVSize = lastFrame->buffSize;
+ memcpy(ctx->frameYUV, lastFrame->buffer, ctx->frameYUVSize);
+
+ ctx->dataAvailable &= true;
+ return false;
+}
+
+FaceCache::FaceCache() : _ctx(new FcPmBreackerContext)
+{
+}
+
+FaceCache::~FaceCache()
+{
+ delete (FcPmBreackerContext*)_ctx;
+}
+
+// returns count of face
+int FaceCache::cachePm(const PipeMaterial& pm)
+{
+ FcPmBreackerContext& ctx(*(FcPmBreackerContext*)_ctx);
+ ctx.reset();
+ ctx.dataAvailable = true;
+ pm.breake(PipeMaterial::PMT_PTR, MB_Frame::MBFT__FIRST, fc_pm_breaker_ptr, _ctx);
+ pm.breake(PipeMaterial::PMT_FRAME, MB_Frame::MBFT__FIRST, fc_pm_breaker_frame, _ctx);
+
+ if (ctx.dataAvailable)
+ return ctx.faceFeatures.size();
+ else
+ return 0;
+}
+
+bool FaceCache::getFaceListPb(uint8_t* buffer, size_t& buffSize)
+{
+ return false;
+}
+
+bool FaceCache::getFaceListImage(int* buffIdx, size_t& count, uint8_t* buffImg, size_t& buffImgSize)
+{
+ return false;
+}
+
+bool FaceCache::extractFace()
+{
+ FcPmBreackerContext& ctx(*(FcPmBreackerContext*)_ctx);
+
+ if (ctx.frameRGBSize == 0)
+ {
+ if (! ctx.convertYUV420ToRGB())
+ return false;
+ }
+
+
+}
--
Gitblit v1.8.0