Hey,

currently I have a simple program that seems to detect whole sentences 
precisely in pictures not as clear but it cannot detect black block letters 
on a white background such as the one below.

The code to reproducing the error is below, just provide it the word search.
Output from the program is:
SEDBEWLEE
RTCELEMSU

MNSJARPEPRUARJR

Q

HRDHGTCJFPE

IWCLL

Z

CACQAOZATNT
TJERREEN

GN

DAAVP
RCNYE

SOQ STG
BDSYDGEA
PUHSCFCR
LPZNE

LC

OROYEVRUSO
YPGCUPXHDE

UMTTSSOTTNATNUOCCA
SKCOURTREPORTERKMAL

D

SCJOCKEYWUEAEWOAP

BQGMASYMPYPO

YHXC

As you can see most of it is not precise

#include <leptonica/allheaders.h>
#include "tesseract/baseapi.h"
#include "tesseract/ocrclass.h"

#include <QApplication>
#include <QImage>
#include <QtCore>
#include <iostream>
#include <QString>
#include <string>

class Task : public QObject
{
    Q_OBJECT
public:
    Task(QObject *parent = 0) : QObject(parent) {}

signals:
        void finished();

public slots:
    void run()
    {
        //###########################################
        tesseract::TessBaseAPI tess;
        QString m_text;
        char *text;
        int min_conf = 50;

        tess.Init(NULL, "eng");
        tess.SetPageSegMode(tesseract::PSM_AUTO_OSD);

        std::string s;
        std::cout << "Enter picture's name to tesser: ";
        std::cin >> s;
        QImage image(s.c_str());

        if (image.isNull())
            emit finished();

        image = image.convertToFormat(QImage::Format_Grayscale8);

        tess.SetImage(image.bits(), image.width(), image.height(), 1, image.
bytesPerLine());
        tess.SetSourceResolution(300);
        tess.DetectOS(0);

        Boxa* boxes = tess.GetComponentImages(tesseract::RIL_BLOCK, true, 
NULL, NULL);

        for (int i = 0; i < boxes->n; i++) {
            BOX* box = boxaGetBox(boxes, i, L_CLONE);
            tess.SetRectangle(box->x, box->y, box->w, box->h);
            text = tess.GetUTF8Text();

            if (tess.MeanTextConf() > min_conf)
                m_text.append(text);
        }

        std::cout << m_text.toStdString() << std::endl;
        //###################################################
        emit finished();
    }
};

#include "main.moc"

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    // Task parented to the application so that it
    // will be deleted by the application.
    Task *task = new Task(&a);

    // This will cause the application to exit when
    // the task signals finished.
    QObject::connect(task, SIGNAL(finished()), &a, SLOT(quit()));

    // This will run the task from the application event loop.
    QTimer::singleShot(0, task, SLOT(run()));

    return a.exec();
}
Enter code here...



<https://lh3.googleusercontent.com/-LpaGzyC0hoI/VrkGhaJ5wXI/AAAAAAAAABc/FRicRSe-bDE/s1600/careers.png>

-- 
You received this message because you are subscribed to the Google Groups 
"tesseract-ocr" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/tesseract-ocr.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tesseract-ocr/be7c2212-07d1-44f6-b71a-128608adee28%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to