环境准备:
Python 2.7 or Python 3
需要安装的包
pytesseract
pytesser
Pillow
达成目标
比较两张图片是不是一个图片
如何运行
python file.py
代码如下
#!C:/Python27 & Python3
#coding=utf-8
# 1. pip install pillow
# 2. pip install pytesseract
# 3. pip install pytesser
# Run: python comporePicture.py
import pytesseract
from pytesser import *
from PIL import Image,ImageEnhance,ImageFilter
import os
import fnmatch
import re,time
import urllib, random
#import hashlib
def getGray(image_file):
tmpls=[]
for h in range(0, image_file.size[1]):#h
for w in range(0, image_file.size[0]):#w
tmpls.append( image_file.getpixel((w,h)) )
return tmpls
#获取平均灰度值
def getAvg(ls):
return sum(ls)/len(ls)
#比较100个字符有几个字符相同
def getMH(a,b):
dist = 0;