From 663104b9be90ed303b87c8acddac8421583a9e39 Mon Sep 17 00:00:00 2001
From: houxiao <houxiao@454eff88-639b-444f-9e54-f578c98de674>
Date: 星期三, 16 八月 2017 12:38:59 +0800
Subject: [PATCH] aaaaa
---
RtspFace/PL_Paint.cpp | 104 ++++++++++++++++++++++++++++++++++------------------
1 files changed, 68 insertions(+), 36 deletions(-)
diff --git a/RtspFace/PL_Paint.cpp b/RtspFace/PL_Paint.cpp
index 7d33743..cb069dd 100644
--- a/RtspFace/PL_Paint.cpp
+++ b/RtspFace/PL_Paint.cpp
@@ -5,7 +5,6 @@
#include <string.h> // for memcpy
#include <opencv2/core/mat.hpp>
#include <opencv2/imgproc.hpp>
-
#ifdef ENABLE_WTEXT
#include "CvUtil/CvxText.h"
#endif
@@ -31,6 +30,12 @@
delete (CvxText*)cvxText;
cvxText = nullptr;
#endif
+}
+
+void PLPLContext::clear()
+{
+ cmds.clear();
+ params.clear();
}
struct PL_Paint_Internal
@@ -186,7 +191,7 @@
bool plplDraw_Rect_RGB565(PLPLContext* plplCtx, MB_Frame* paintMb, int& paramOffset)
{
- int LTX = plplCtx->params[paramOffset + 0].val_i;
+ int LTX = plplCtx->params[paramOffset + 0].val_i;
int LTY = plplCtx->params[paramOffset + 1].val_i;
int RBX = plplCtx->params[paramOffset + 2].val_i;
int RBY = plplCtx->params[paramOffset + 3].val_i;
@@ -199,7 +204,7 @@
// void rectangle(Mat& img, Point pt1, Point pt2, const Scalar& color, int thickness=1, int lineType=8, int shift=0)
- const uint16_t RGB565 = plplCtx->color_front.toY();
+ const uint16_t RGB565 = plplCtx->color_front.toRGB565();
cv::rectangle(rgbMat, cv::Point(LTX, LTY), cv::Point(RBX, RBY), CV_RGB(RGB565, RGB565, RGB565), 4);
return true;
@@ -231,14 +236,58 @@
cv::putText(yMat, TXT, cv::Point(LTX, LTY), CV_FONT_HERSHEY_COMPLEX, 1, CV_RGB(Y, Y, Y));
cv::putText(uvMat, TXT, cv::Point(MH_SUBSAMPLE1(LTX, 2), MH_SUBSAMPLE1(LTY, 2)), CV_FONT_HERSHEY_COMPLEX, 0.5, CV_RGB(UV, UV, UV));
-
+
return true;
+}
+
+bool plplDraw_Text_RGB565(PLPLContext* plplCtx, MB_Frame* paintMb, int& paramOffset)
+{
+ int LTX = plplCtx->params[paramOffset + 0].val_i;
+ int LTY = plplCtx->params[paramOffset + 1].val_i;
+ const char* TXT = plplCtx->params[paramOffset + 2].val_s;
+ paramOffset += 3;
+
+ int src_width = paintMb->width;
+ int src_height = paintMb->height;
+ uint8_t* src_rgb = (uint8_t*)(paintMb->buffer);
+ cv::Mat rgbMat(cv::Size(src_width, src_height), CV_16UC1, src_rgb);
+
+ const uint16_t RGB565 = plplCtx->color_front.toRGB565();
+ cv::putText(rgbMat, TXT, cv::Point(LTX, LTY), CV_FONT_HERSHEY_COMPLEX, 1, CV_RGB(RGB565, RGB565, RGB565));
+
+ return true;
+}
+
+bool plplDraw_WText_RGB565(PLPLContext* plplCtx, MB_Frame* paintMb, int& paramOffset)
+{
+#ifdef ENABLE_WTEXT
+ int LTX = plplCtx->params[paramOffset + 0].val_i;
+ int LTY = plplCtx->params[paramOffset + 1].val_i;
+ const char* WTXT = plplCtx->params[paramOffset + 2].val_s;
+ paramOffset += 3;
+
+ int src_width = paintMb->width;
+ int src_height = paintMb->height;
+ uint8_t* src_rgb = (uint8_t*)(paintMb->buffer);
+ cv::Mat rgbMat(cv::Size(src_width, src_height), CV_16UC1, src_rgb);
+
+ // void rectangle(Mat& img, Point pt1, Point pt2, const Scalar& color, int thickness=1, int lineType=8, int shift=0)
+
+ const uint16_t RGB565 = plplCtx->color_front.toRGB565();
+
+ CvxText* cvText = (CvxText*)plplCtx->cvxText;
+ cvText->putText(rgbMat, (const wchar_t*)WTXT, cv::Point(LTX, LTY), CV_RGB(RGB565, RGB565, RGB565));
+
+ return true;
+#else
+ return false;
+#endif
}
bool plplDraw_WText_NV12(PLPLContext* plplCtx, MB_Frame* paintMb, int& paramOffset)
{
#ifdef ENABLE_WTEXT
- int LTX = plplCtx->params[paramOffset + 0].val_i;
+ int LTX = plplCtx->params[paramOffset + 0].val_i;
int LTY = plplCtx->params[paramOffset + 1].val_i;
const char* WTXT = plplCtx->params[paramOffset + 2].val_s;
paramOffset += 3;
@@ -254,18 +303,18 @@
const uint16_t Y = plplCtx->color_front.toY();
const uint16_t UV = plplCtx->color_front.toUV();
-
+
CvxText* cvText = (CvxText*)plplCtx->cvxText;
cvText->putText(yMat, (const wchar_t*)WTXT, cv::Point(LTX, LTY), CV_RGB(Y, Y, Y)); // L"涓枃ABCDabcd"
cvText->putText(uvMat, (const wchar_t*)WTXT, cv::Point(MH_SUBSAMPLE1(LTX, 2), MH_SUBSAMPLE1(LTY, 2)), CV_RGB(UV, UV, UV)); // L"涓枃ABCDabcd"
-
+
return true;
#else
return false;
#endif
}
-bool plplExecutor_YUV(PL_Paint_Internal *in)
+bool plpl_executor(PL_Paint_Internal *in)
{
MB_Frame* paintMb = &(in->lastMbfBuffOrigin);
int ret = true;
@@ -350,8 +399,8 @@
ret = plplDraw_Text_YUV420(plplCtx, paintMb, paramOffset);
else if (paintMb->type == MB_Frame::MBFT_NV12)
ret = plplDraw_Text_NV12(plplCtx, paintMb, paramOffset);
- //else if (paintMb->type == MB_Frame::MBFT_RGB565)
- // ret = plplDraw_Text_RGB565(plplCtx, paintMb, paramOffset);
+ else if (paintMb->type == MB_Frame::MBFT_RGB565)
+ ret = plplDraw_Text_RGB565(plplCtx, paintMb, paramOffset);
else
ret = false;
break;
@@ -360,8 +409,8 @@
//WTEXT LTX,LTY,"STR"
if (paintMb->type == MB_Frame::MBFT_NV12)
ret = plplDraw_WText_NV12(plplCtx, paintMb, paramOffset);
- //else if (paintMb->type == MB_Frame::MBFT_RGB565)
- // ret = plplDraw_WText_RGB565(plplCtx, paintMb, paramOffset);
+ else if (paintMb->type == MB_Frame::MBFT_RGB565)
+ ret = plplDraw_WText_RGB565(plplCtx, paintMb, paramOffset);
else
ret = false;
break;
@@ -383,7 +432,7 @@
in->lastMbfBuffOrigin.height = frame->height;
in->lastMbfBuffOrigin.pts = frame->pts;
- in->payError = !plplExecutor_YUV(in);
+ in->payError = !plpl_executor(in);
return false;
}
@@ -392,29 +441,12 @@
{
PL_Paint_Internal* in = (PL_Paint_Internal*)internal;
in->payError = true;
-
- if (pm.type != PipeMaterial::PMT_FRAME)
- {
- LOG_ERROR << "Only support PMT_FRAME" << LOG_ENDL;
- return false;
- }
-
- if (pm.buffer == nullptr)
- return false;
-
- MB_Frame* frame = (MB_Frame*)pm.buffer;
- switch(frame->type)
- {
- case MB_Frame::MBFT_YUV420:
- case MB_Frame::MBFT_NV12:
- case MB_Frame::MBFT_RGB565:
- pm.breake(PipeMaterial::PMT_FRAME, MB_Frame::MBFT_RGB565, PL_Paint::pay_breaker_MBFT, in);
- return !(in->payError);
- default:
- LOG_ERROR << "Only support MBFT_YUV420 / MBFT_NV12 / MBFT_RGB565" << LOG_ENDL;
- in->payError = true;
- break;
- }
+ if (in->payError)
+ pm.breake(PipeMaterial::PMT_FRAME, MB_Frame::MBFT_YUV420, PL_Paint::pay_breaker_MBFT, in);
+ if (in->payError)
+ pm.breake(PipeMaterial::PMT_FRAME, MB_Frame::MBFT_NV12, PL_Paint::pay_breaker_MBFT, in);
+ if (in->payError)
+ pm.breake(PipeMaterial::PMT_FRAME, MB_Frame::MBFT_RGB565, PL_Paint::pay_breaker_MBFT, in);
return !(in->payError);
}
--
Gitblit v1.8.0