码迷,mamicode.com
首页 > 其他好文 > 详细

wechat

时间:2017-07-03 10:10:46      阅读:201      评论:0      收藏:0      [点我收藏+]

标签:bash   nbsp   ima   bsp   ash   app   main   print   sdc   

#!/bin/bash

adb shell screencap -p /sdcard/a.png
adb pull /sdcard/a.png ./
adb shell rm /sdcard/a.png

echo "screencap [done]"

 

#!/usr/bin/env python

from PIL import Image
from PIL import ImageDraw

img = Image.open("./a.png")

print img.size

sx = 990 #970
sy = 1395 #1375
dx = 51 #86
dy = 36 #66

rL = []
draw = ImageDraw.Draw(img)
for i in range(sx,sx+dx):
    row = ‘‘
    for j in range(sy,sy+dy):
        col = img.getpixel((i,j))
        draw.point((i-sx,j-sy),col)
        row += str(col[0])+,+str(col[1])+,+str(col[2])+,+str(col[3])+-

    rL.append(row[:-1]+\n)
img.save("./r.png")

f = open(./g.txt, w)
f.writelines(rL)
f.close()

 

#!/usr/bin/env python

from PIL import Image  

####################################################################
dx = 51
dy = 36
g_block = [[] for i in range(dx)]


####################################################################
def init():
    global g_block

    f = open(./g.txt, r)
    t = f.readlines()
    f.close()

    for index,i in enumerate(t):
        #print index
        e = i[:-1].split(-)
        for index2, j in enumerate(e):
            w = j.split(,)
            g_block[index].append((int(w[0]),int(w[1]),int(w[2]),int(w[3])))
            pass

def check():
    global g_block
    rslt = []

    img = Image.open("./a.png")
    imgw, imgh = img.size
    for x in range(imgw):
        for y in range(imgh):
            if x + dx >= imgw or y + dy >= imgh:
                continue
            fg = True
#print x,y,
            for xx in range(dx):
                if fg == False:
                    break
                for yy in range(dy):
                    col1 = img.getpixel((x+xx,y+yy))  
                    if col1 != g_block[xx][yy]:
#print xx, yy, col1, g_block[xx][yy]
                        fg = False
                        break
            if fg == True:
                  rslt.append((x,y))

    print rslt



####################################################################
if __name__ == __main__:
    init()
    print [finished]
    check()

 技术分享

 

wechat

标签:bash   nbsp   ima   bsp   ash   app   main   print   sdc   

原文地址:http://www.cnblogs.com/fish7/p/7109386.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!