import shutil
class PIG(object):
def __init__(self):
##图片还原的顺序 ,固定不变 除非版本更新
self.sx=[39,38,48,49,41,40,46,47,35,34,50,51,33,32,28,29,27,26,36,37,31,30,44,45,43,42,12,13,23,22,14,15,21,20,8,9,25,24,6,7,3,2,0,1,11,10,4,5,19,18,16,17]
def create_dir_not_exist(self,path):
if not os.path.exists(path):
os.mkdir(path)
def get_img(self):
###拿到图片还原的坐标 xy
s=80
u=10
self.all=[]
for i in range(0,52):
c=self.sx%26*12+1
# f=k
if self.sx>25:
f=80
else:
f=0
tuple=(c, f, u, s)
self.all.append(tuple)
if abs(pix1[0] - pix2[0]) < threshold and abs(pix1[1] - pix2[1]) < threshold and abs(
pix1[2] - pix2[2]) < threshold:
return True
else:
return False
def get_gap(self, img1, img2):
"""
获取缺口偏移量
:param img1: 不带缺口图片
:param img2: 带缺口图片
:return:
"""
left = 0
for i in range(left, img1.size[0]):
for j in range(img1.size[1]):
if not self.is_px_equal(img1, img2, i, j):
left = i
return left
return left
if __name__ == '__main__':
start=PIG()
path=start.work("images/old/test.jpg")
path1=start.work("images/old/test1.jpg")
print(start.get_gap(Image.open(path),Image.open(path1)))
os.remove(path1)
os.remove(path)[/mw_shl_code]