b797f7f by Enrico Ros at 2009-02-25 1
/***************************************************************************
0e5745d by Enrico Ros at 2009-05-31 2
 * Copyright (c) 2009 Enrico Ros                                           *
3
 *         2009 Enrico Ros <enrico.ros@email.it>                           *
4
 *         2009 Alberto Scarpa <skaal.sl@gmail.com>                        *
b797f7f by Enrico Ros at 2009-02-25 5
 *                                                                         *
6
 * Permission is hereby granted, free of charge, to any person             *
7
 * obtaining a copy of this software and associated documentation          *
8
 * files (the "Software"), to deal in the Software without                 *
9
 * restriction, including without limitation the rights to use,            *
10
 * copy, modify, merge, publish, distribute, sublicense, and/or sell       *
11
 * copies of the Software, and to permit persons to whom the               *
12
 * Software is furnished to do so, subject to the following                *
13
 * conditions:                                                             *
14
 *                                                                         *
15
 * The above copyright notice and this permission notice shall be          *
16
 * included in all copies or substantial portions of the Software.         *
17
 *                                                                         *
18
 ***************************************************************************/
19
20
#ifndef __Ocr_h__
21
#define __Ocr_h__
22
23
#include <QObject>
24
#include <QFont>
25
#include <QImage>
26
#include <QRect>
27
#include <QList>
28
#include <QChar>
29
#include <QFontDatabase>
30
class OcrGlyph;
31
32
struct OcrResult {
33
    QChar character;
34
    double confidence;
35
};
36
37
class Ocr
38
{
39
    public:
40
        Ocr();
41
        ~Ocr();
42
43
        // train the OCR
44
        void trainFont( const QFont & font, QFontDatabase::WritingSystem writingSystem = QFontDatabase::Latin );
45
        void trainGlyph( const QImage & image, const QChar & character );
46
        void clearTraning();
47
48
        // recognize a glyph
e45848b by Enrico Ros at 2009-05-31 49
        OcrResult recognizeGlyph( const QImage & image, const QRect & rect = QRect() ) const;
b797f7f by Enrico Ros at 2009-02-25 50
51
    private:
52
        QList< OcrGlyph * > m_glyphs;
53
};
54
55
#endif