0

How to detect and extract the position of text from images. For ex the text "pepsi" from pepsi bottle image. http://www.csmonitor.com/var/ezflow_site/storage/images/media/content/2013/0321-new-pepsi-bottle.jpg/15343519-1-eng-US/0321-new-pepsi-bottle.jpg_full_600.jpg

user4897
  • 31
  • 2

2 Answers2

1

At first you need a two pictures like this. Use a canny in opencv or photoshop.

enter image description here enter image description here

Then make the background differencing as following

    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
    Mat model = Highgui.imread("D:\\BKDiff\\can1.jpg",Highgui.CV_LOAD_IMAGE_GRAYSCALE);
    Mat scene = Highgui.imread("D:\\BKDiff\\can2.jpg",Highgui.CV_LOAD_IMAGE_GRAYSCALE);
    Mat diff = new Mat();
    Core.absdiff(model,scene,diff);
    Imgproc.threshold(diff,diff,15,1000,Imgproc.THRESH_BINARY);
    int distortion = Core.countNonZero(diff);
    Highgui.imwrite("D:\\BKDiff\\out.jpg",diff);

After that, you will get this.

enter image description here

zawhtut
  • 8,335
  • 5
  • 52
  • 76
  • yeah thanks its working fine, now i need to draw a rectangular box on this logo we got, how can i do this.. – user4897 Oct 06 '14 at 07:11
  • i am using the below code to find bounding box cv::Mat threshold_output; cv::Mat m = img.clone(); cv::blur(m, m, cv::Size(5,5)); std::vector< std::vector > contours; std::vector points; cv::findContours(m, contours, CV_RETR_LIST, CV_CHAIN_APPROX_NONE); m.release(); for (size_t i=0; i – user4897 Oct 06 '14 at 07:22
  • You can use submat to retrive the text. – zawhtut Oct 06 '14 at 07:44
  • I tried using opencv, but unable to retrive text and its position from image. Anyway thanks zawhtut. – user4897 Oct 07 '14 at 10:47
0

You can also see the following paper on Stroke Width transform. Its simple to implement and gives quite high accuracy.

I see there is an implementation also.

Dib
  • 317
  • 1
  • 4
  • 13