Skip to content

Instantly share code, notes, and snippets.

@zlx
Last active August 29, 2015 14:14
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zlx/7c3532189d17fe8ab906 to your computer and use it in GitHub Desktop.
Save zlx/7c3532189d17fe8ab906 to your computer and use it in GitHub Desktop.
支付宝朋友圈红包识别程序
# 支付宝分享到微信的红包识别
# 依赖: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