java 数字识别,识别图像中的数字

I'm trying to write an application to find the numbers inside an image and add them up.

How can I identify the written number in an image?

aqaM1.png

There are many boxes in the image I need to get the numbers in the left side and sum them to give total. How can I achieve this?

Edit: i did a java tesseract ocr on the image but i didnt get any correct results. how can i train it?

also

i did a edge detection i got this:

LIVcB.png

解决方案

You will most likely need to do the following:

Apply the Hough Transform algorithm on the entire page, this should should yield a series of page sections.

For each section you get, apply it again. If the current section yielded 2 elements, then you should be dealing with a rectangle similar to the above.

Once that you are done, you can use an OCR to extract the numeric value.

In this case, I would recommend you take a look at JavaCV (OpenCV Java Wrapper) which should allow you to tackle the Hough Transform part. You would then need something akin to Tess4j (Tesseract Java Wrapper) which should allow you to extract the numbers you are after.

As an extra note, to reduce the amount of false positives, you might want to do the following:

Crop the image if you are certain that certain coordinates will never contain data you are after. This should give you a smaller picture to work with.

It might be wise to change the image to grey scale (assuming you are working with a colour image). Colours can have a negative impact on the OCR's ability to resolve the image.

EDIT: As per your comment, given something like this:

+------------------------------+

| +---+---+ |

| | | | |

| +---+---+ |

| +---+---+ |

| | | | |

| +---+---+ |

| +---+---+ |

| | | | |

| +---+---+ |

| +---+---+ |

| | | | |

| +---+---+ |

+------------------------------+

You would crop the image so that your remove the area which does not have relevant data (the part on the left) by cropping the image, you would get something like so:

+-------------+

|+---+---+ |

|| | | |

|+---+---+ |

|+---+---+ |

|| | | |

|+---+---+ |

|+---+---+ |

|| | | |

|+---+---+ |

|+---+---+ |

|| | | |

|+---+---+ |

+-------------+

The idea would be to run the Hough Transform so that you can get segments of the page which contain rectangles like so:

+---+---+

| | |

+---+---+

Which you would then apply the Hough Transform again and end up with two segments, and you take the left one.

Once that you have the left segment, you would then apply the OCR.

You can try to apply the OCR before hand, but at best, the OCR will recognize both numeric values, both written and both typed, which from what I get, is not what you are after.

Also, the extra lines which depict the rectangles might throw the OCR off track, and make it yield bad results.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值