houxiao
2017-07-19 24651eecd31eb0d7d499702e33c6b6a171747322
PL_Paint add rgb565

git-svn-id: http://192.168.1.226/svn/proxy@744 454eff88-639b-444f-9e54-f578c98de674
2个文件已修改
64 ■■■■ 已修改文件
RtspFace/PL_Paint.cpp 62 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
RtspFace/PL_Paint.h 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
RtspFace/PL_Paint.cpp
@@ -199,7 +199,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 +231,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,11 +298,11 @@
    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;
@@ -350,8 +394,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 +404,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;
RtspFace/PL_Paint.h
@@ -4,7 +4,7 @@
#include "PipeLine.h"
#include "GraphicHelper.h"
//#define ENABLE_WTEXT
#define ENABLE_WTEXT
/*
PLPaint Language: