From edd6597ee775032cba556d34669edfd696c9f97b Mon Sep 17 00:00:00 2001 From: houxiao <houxiao@454eff88-639b-444f-9e54-f578c98de674> Date: 星期三, 19 七月 2017 16:52:29 +0800 Subject: [PATCH] code review --- RtspFace/PL_Paint.cpp | 32 ++++++++++++++++++++------------ 1 files changed, 20 insertions(+), 12 deletions(-) diff --git a/RtspFace/PL_Paint.cpp b/RtspFace/PL_Paint.cpp index 6f724ff..e9318aa 100644 --- a/RtspFace/PL_Paint.cpp +++ b/RtspFace/PL_Paint.cpp @@ -85,15 +85,23 @@ in->config = *config; } + if(in->config.plplCtx->cvxText != nullptr) + { + delete (CvxText*)in->config.plplCtx->cvxText; + } + if(in->config.fontPath.empty()) { LOG_ERROR << "fontPath is null!" << LOG_ENDL; return false; } - - if(in->config.plplCtx->cvxText != nullptr) + else if (in->config.fontPath == " ") { - delete (CvxText*)in->config.plplCtx->cvxText; + CvxText* cvxText = new CvxText(in->config.fontPath.c_str()); + in->config.plplCtx->cvxText = cvxText; + cvxText->setBackColor(cvScalar(128, 33, 14)); + CvScalar font = cvScalar(40, 1, 0.2, 1); + cvxText->setFont(0, &font); } return true; @@ -129,6 +137,8 @@ cv::rectangle(yMat, cv::Point(LTX, LTY), cv::Point(RBX, RBY), CV_RGB(yuvColor.Y, yuvColor.Y, yuvColor.Y), 4); cv::rectangle(uMat, cv::Point(MH_SUBSAMPLE1(LTX, 2), MH_SUBSAMPLE1(LTY, 2)), cv::Point(MH_SUBSAMPLE1(RBX, 2), MH_SUBSAMPLE1(RBY, 2)), CV_RGB(yuvColor.U, yuvColor.U, yuvColor.U), 2); cv::rectangle(vMat, cv::Point(MH_SUBSAMPLE1(LTX, 2), MH_SUBSAMPLE1(LTY, 2)), cv::Point(MH_SUBSAMPLE1(RBX, 2), MH_SUBSAMPLE1(RBY, 2)), CV_RGB(yuvColor.V, yuvColor.V, yuvColor.V), 2); + + return true; } bool plplDraw_Rect_NV12(PLPLContext* plplCtx, MB_Frame* paintMb, int& paramOffset) @@ -153,10 +163,13 @@ cv::rectangle(yMat, cv::Point(LTX, LTY), cv::Point(RBX, RBY), CV_RGB(Y, Y, Y), 4); cv::rectangle(uvMat, cv::Point(MH_SUBSAMPLE1(LTX, 2), MH_SUBSAMPLE1(LTY, 2)), cv::Point(MH_SUBSAMPLE1(RBX, 2), MH_SUBSAMPLE1(RBY, 2)), CV_RGB(UV, UV, UV), 2); + + return true; } bool plplDraw_Text_YUV420(PLPLContext* plplCtx, MB_Frame* paintMb, int& paramOffset) { + return false; } bool plplDraw_Text_NV12(PLPLContext* plplCtx, MB_Frame* paintMb, int& paramOffset) @@ -180,6 +193,8 @@ 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_WText_NV12(PLPLContext* plplCtx, MB_Frame* paintMb, int& paramOffset) @@ -198,21 +213,14 @@ // void rectangle(Mat& img, Point pt1, Point pt2, const Scalar& color, int thickness=1, int lineType=8, int shift=0) - if (in->config.plplCtx->cvxText == nullptr) - { - CvxText* cvxText = new CvxText(in->config.fontPath.c_str()); - in->config.plplCtx->cvxText = cvxText; - cvxText->setBackColor(cvScalar(128, 33, 14)); - CvScalar font = cvScalar(40, 1, 0.2, 1); - cvxText->setFont(0, &font); - } - 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; } bool plplExecutor_YUV(PL_Paint_Internal *in) -- Gitblit v1.8.0