From 2ffee7e4b21e81ce420b1a2f57075ca00306606a Mon Sep 17 00:00:00 2001
From: xuxiuxi <xuxiuxi@454eff88-639b-444f-9e54-f578c98de674>
Date: 星期三, 19 七月 2017 16:03:22 +0800
Subject: [PATCH]
---
VisitFace/RtspNativeCodec/app/src/main/cpp/CameraWrapper.cpp | 65 +++++++++++++++++++++++---------
1 files changed, 47 insertions(+), 18 deletions(-)
diff --git a/VisitFace/RtspNativeCodec/app/src/main/cpp/CameraWrapper.cpp b/VisitFace/RtspNativeCodec/app/src/main/cpp/CameraWrapper.cpp
index 45da629..6147424 100644
--- a/VisitFace/RtspNativeCodec/app/src/main/cpp/CameraWrapper.cpp
+++ b/VisitFace/RtspNativeCodec/app/src/main/cpp/CameraWrapper.cpp
@@ -20,7 +20,7 @@
LOG_INFO << "CameraWrapper::start" << LOG_ENDL;
running = true;
- int ret = pthread_create(&live_daemon_thid, NULL, CameraWrapper::live_daemon_thd, this);
+ int ret = pthread_create(&decoder_thid, NULL, CameraWrapper::decoder_thd, this);
if(ret != 0)
{
LOGP(ERROR, "pthread_create: %s/n", strerror(ret));
@@ -39,7 +39,7 @@
return;
running = false;
- pthread_join(live_daemon_thid, NULL);
+ pthread_join(decoder_thid, NULL);
}
static float pl_analizer_plbg_user_score_2_func(const MB_Frame* frame, const PLGH_Rect& rects, uint8_t* croppedData)
@@ -56,6 +56,7 @@
RectWrapper rw;
rw.rect = iter->rect;
rw.user_score_1 = ((90.0f - std::abs(iter->yaw)) + (90.0f - std::abs(iter->pitch)) + (90.0f - std::abs(iter->roll))) / 90.0f / 3 * iter->score;
+ rw.userData = (void*)(iter->id);
rects.push_back(rw);
}
}
@@ -193,7 +194,8 @@
bool cw_pm_breaker_ptr_paint(const PipeMaterial* pm, void* args)
{
- PLPLContext& plplContext(*(PLPLContext*)args);
+ CameraWrapper& cameraWrapper = *(CameraWrapper*)args;
+ PLPLContext& plplContext(cameraWrapper.plplContext);
const st_ff_vect_t& faceFeatures(*(const st_ff_vect_t*)(pm->buffer));
plplContext.cmds.clear();
@@ -233,6 +235,16 @@
plplContext.params.push_back(iter->rect.leftTop.Y);
plplContext.params.push_back(iter->rect.rightBottom.X);
plplContext.params.push_back(iter->rect.rightBottom.Y);
+
+ std::map<int, std::string>::iterator iterFaceLabel = cameraWrapper.faceLabels.find(iter->id);
+ if (iterFaceLabel != cameraWrapper.faceLabels.end())
+ {
+ plplContext.cmds.push_back(PLPLC_TEXT);
+ plplContext.params.push_back(iter->rect.leftTop.X);
+ plplContext.params.push_back(iter->rect.leftTop.Y);
+ const char* label = iterFaceLabel->second.c_str();
+ plplContext.params.push_back(PLPLType(label));
+ }
}
return false;
@@ -255,9 +267,28 @@
return false;
}
-/*static*/ void* CameraWrapper::live_daemon_thd(void* arg)
+void test_paint(CameraWrapper& cameraWrapper)
{
- LOG_INFO << "CameraWrapper::live_daemon_thd start" << LOG_ENDL;
+ cameraWrapper.setFaceLabel(0, "vip");
+ cameraWrapper.setFaceLabel(1, "abc");
+ cameraWrapper.setFaceLabel(2, "wrn");
+
+ cameraWrapper.plplContext.cmds.push_back(PLPLC_COLOR);
+ cameraWrapper.plplContext.params.push_back('F');
+ cameraWrapper.plplContext.params.push_back(255);
+ cameraWrapper.plplContext.params.push_back(0);
+ cameraWrapper.plplContext.params.push_back(0);
+ cameraWrapper.plplContext.params.push_back(255);
+ cameraWrapper.plplContext.cmds.push_back(PLPLC_RECT);
+ cameraWrapper.plplContext.params.push_back(20);
+ cameraWrapper.plplContext.params.push_back(20);
+ cameraWrapper.plplContext.params.push_back(100);
+ cameraWrapper.plplContext.params.push_back(100);
+}
+
+/*static*/ void* CameraWrapper::decoder_thd(void* arg)
+{
+ LOG_INFO << "CameraWrapper::decoder_thd start" << LOG_ENDL;
CameraWrapper& cameraWrapper = *(CameraWrapper*)arg;
@@ -284,25 +315,15 @@
pmAnalizer.breake(PipeMaterial::PMT_PTR, MB_Frame::MBFT__FIRST, cw_pm_breaker_ptr_face, &(cameraWrapper));
}
- pm.breake(PipeMaterial::PMT_PTR, MB_Frame::MBFT__FIRST, cw_pm_breaker_ptr_paint, &(cameraWrapper.plplContext));
+ pm.breake(PipeMaterial::PMT_PTR, MB_Frame::MBFT__FIRST, cw_pm_breaker_ptr_paint, &(cameraWrapper));
//#debug
- //cameraWrapper.plplContext.cmds.push_back(PLPLC_COLOR);
- //cameraWrapper.plplContext.params.push_back('F');
- //cameraWrapper.plplContext.params.push_back(255);
- //cameraWrapper.plplContext.params.push_back(0);
- //cameraWrapper.plplContext.params.push_back(0);
- //cameraWrapper.plplContext.params.push_back(255);
- //cameraWrapper.plplContext.cmds.push_back(PLPLC_RECT);
- //cameraWrapper.plplContext.params.push_back(20);
- //cameraWrapper.plplContext.params.push_back(20);
- //cameraWrapper.plplContext.params.push_back(100);
- //cameraWrapper.plplContext.params.push_back(100);
+ //test_paint(cameraWrapper);
cameraWrapper.pipeLineRender->pipe(&pm);
}
- LOG_INFO << "CameraWrapper::live_daemon_thd stop, ret=" << LOG_ENDL;
+ LOG_INFO << "CameraWrapper::decoder_thd stop, ret=" << LOG_ENDL;
}
void CameraWrapper::lockFace()
@@ -314,3 +335,11 @@
{
faceCacheLocked = false;
}
+
+void CameraWrapper::setFaceLabel(int st_track_id, const std::string& label)
+{
+ if (faceLabels.size() > 32)
+ faceLabels.clear();
+
+ faceLabels.insert(std::make_pair(st_track_id, label));
+}
--
Gitblit v1.8.0