Last active
August 29, 2015 14:14
-
-
Save zlx/7c3532189d17fe8ab906 to your computer and use it in GitHub Desktop.
支付宝朋友圈红包识别程序
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 支付宝分享到微信的红包识别 | |
# 依赖:tesseract, gems(mini_magick, rtesseract) | |
# 使用: ruby alipay_red_packet.rb xxx.jpg | |
# xxx.jpg 就是支付宝红包图片 | |
require 'mini_magick' | |
require 'rtesseract' | |
img = MiniMagick::Image.new(ARGV[0]) | |
img.crop("#{1080-220}x#{1600-1360}+220+1360") | |
img.colorspace("GRAY") | |
img.monochrome | |
image = RTesseract.new(img.path) | |
STDOUT << image.to_s.sub(/\s+$/, "") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment