How to find text in image

asked 2015-11-15 15:37:28 -0600

asdhjk gravatar image

Hi everybody I want to find text in image but how can ı can do it ? Firstly I have done rectangle for text and done it succesfully but I dont know how ı can improve this and ı can save only text another image Can I use artifical intellegance for this project If ı can it which method Thanks advance

edit retag flag offensive close merge delete

Comments

2

You should search in the litterature as it is a very common subject. Stroke Width Transform to detect potential text location combined with Tesseract OCR for example.

Also with OpenCV 3.0 and contrib module you have this.

Eduardo gravatar imageEduardo ( 2015-11-16 09:50:36 -0600 )edit

Thanks for your advance Actually I can find text in image but I want to save this text in .txt format My code here:

#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>

using namespace cv;
using namespace std;
int main(int argc, char** argv)
{
    Mat large = imread("test_002.jpg");
    Mat rgb;
    // downsample and use it for processing
    pyrDown(large, rgb);
    Mat small;
    cvtColor(rgb, small, CV_BGR2GRAY);
    // morphological gradient
    Mat grad;
    Mat morphKernel = getStructuringElement(MORPH_ELLIPSE, Size(3, 3));
    morphologyEx(small, grad, MORPH_GRADIENT, morphKernel);
asdhjk gravatar imageasdhjk ( 2015-11-17 10:09:04 -0600 )edit

Im sorry I can 't use pre code tag

asdhjk gravatar imageasdhjk ( 2015-11-17 10:12:18 -0600 )edit

in addition ı use opencv 2.4.6 how can ı integrate

asdhjk gravatar imageasdhjk ( 2015-11-17 10:39:10 -0600 )edit

As far as I know, you cannot do ocr (optical character recognition) directly in OpenCV 2.4.6. You should look at the documentation of Tesseract Open Source OCR Engine.

Eduardo gravatar imageEduardo ( 2015-11-17 11:06:29 -0600 )edit

Start by stop using OpenCV 2.4.6. It is old deprecated and absolete and contains TONS of bugs. Go either for 2.4.12 or for latest master 3.0 branch! Like said by @Eduardo, tesseract has been interfaced with OpenCV in a contributed module and makes your life soooo much easier!

StevenPuttemans gravatar imageStevenPuttemans ( 2015-11-19 07:25:48 -0600 )edit