Is there an OCR library that outputs coordinates o

2019-01-30 20:17发布

In my experience, OCR libraries tend to merely output the text found within an image but not where the text was found. Is there an OCR library that outputs both the words found within an image as well as the coordinates (x, y, width, height) where those words were found?

标签: ocr
9条回答
Juvenile、少年°
2楼-- · 2019-01-30 20:30

Google Vision API does this. https://cloud.google.com/vision/docs/detecting-text

"description": "Wake up human!\n",
      "boundingPoly": {
        "vertices": [
          {
            "x": 29,
            "y": 394
          },
          {
            "x": 570,
            "y": 394
          },
          {
            "x": 570,
            "y": 466
          },
          {
            "x": 29,
            "y": 466
          }
        ]
      }
查看更多
戒情不戒烟
3楼-- · 2019-01-30 20:30

ABCocr.NET (our component) will allow you to obtain the coordinates of each word found. The values are accessible through the Word.Bounds property, which simply returns a System.Drawing.Rectangle.

The example below shows how you can OCR an image using ABCocr.NET and output the information you need:

using System;
using System.Drawing;
using WebSupergoo.ABCocr3;

namespace abcocr {
    class Program {
        static void Main(string[] args) {

            Bitmap bitmap = (Bitmap)Bitmap.FromFile("example.png");
            Ocr ocr = new Ocr();
            ocr.SetBitmap(bitmap);

            foreach (Word word in ocr.Page.Words) {
                Console.WriteLine("{0}, X: {1}, Y: {2}, Width: {3}, Height: {4}",
                    word.Text,
                    word.Bounds.X,
                    word.Bounds.Y,
                    word.Bounds.Width,
                    word.Bounds.Height);
            }
        }
    }
}

Disclosure: posted by a member of the WebSupergoo team.

查看更多
我命由我不由天
4楼-- · 2019-01-30 20:42

The free OCR.space OCR API returns word coordinates once you set the parameter isOverlayRequired = true :

 "ParsedResults" : [
            {
                "TextOverlay" : {
                    "Lines" : [
                        {
                            "Words": [
                                {
                                "WordText": "Word 1",
                                "Left": 106,
                                "Top": 91,
                                "Height": 9,
                                "Width": 11
                                },
                                {
                                "WordText": "Word 2",
                                "Left": 121,
                                "Top": 90,
                                "Height": 13,
                                "Width": 51
                                }
                                .
查看更多
登录 后发表回答