xingzilong
2017-08-18 9e5babf9db52e64bdae60137be7696e56241fca6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
 
#ifndef OPENCV_CVX_TEXT_2007_08_31_H  
#define OPENCV_CVX_TEXT_2007_08_31_H
 
#include <freetype/freetype.h>
#include <opencv/cv.h>
#include <opencv/highgui.h>
 
class CvxText
{
 
    CvxText& operator=(const CvxText&);
 
    //================================================================  
    //================================================================  
 
public:
 
 
    CvxText(const char *freeType);
    virtual ~CvxText();
 
    //================================================================  
    //================================================================  
 
 
    void getFont(int *type,
        CvScalar *size = NULL, bool *underline = NULL, float *diaphaneity = NULL);
 
//    void setScale(float scale);
//
//    void getScale(float* scale);
 
    void setBackColor(CvScalar color)
    {
        m_backcolor = color;
    }
 
    void getBackColor(CvScalar* color)
    {
        *color = m_backcolor;
    }
 
    void setBackColorEnable(bool enable)
    {
        m_backcolorEnable = enable;
    }
 
    void getBackColorEnable(bool* enable)
    {
        *enable = m_backcolorEnable;
    }
 
    void setFont(int *type,
        CvScalar *size = NULL, bool *underline = NULL, float *diaphaneity = NULL);
 
    void restoreFont();
 
    //================================================================  
    //================================================================  
 
 
    int putText(IplImage *img, const char    *text, CvPoint pos);
 
    int putText(cv::Mat img, const char    *text, CvPoint pos);
 
    int putText(IplImage *img, const wchar_t *text, CvPoint pos);
 
    int putText(cv::Mat img, const wchar_t *text, CvPoint pos);
 
    int putText(IplImage *img, const char    *text, CvPoint pos, CvScalar color);
 
    int putText(cv::Mat img, const char      *text, CvPoint pos, CvScalar color);
 
    int putText(IplImage *img, const wchar_t *text, CvPoint pos, CvScalar color);
 
    int putText(cv::Mat img, const wchar_t   *text, CvPoint pos, CvScalar color);
 
private:
 
    void putWChar(IplImage *img, wchar_t wc, CvPoint &pos, CvScalar color);
    void drawBackGround(IplImage *img, CvPoint pos, int w, int h);
 
private:
 
    FT_Library   m_library;
    FT_Face      m_face;
    CvScalar     m_backcolor;
 
    int         m_fontType;
    CvScalar   m_fontSize;
    bool      m_fontUnderline;
    float      m_fontDiaphaneity;
    bool       m_backcolorEnable;
    float      m_scale;
};
 
#endif // OPENCV_CVX_TEXT_2007_08_31_H