一位女性朋友和我PK别踩白块儿,输了私藏照片给我,冠希哥用Python轻松赢下

前言:前些天一位女性朋友和我打赌,说她游戏玩的很厉害,首先以为是王者,结果谁能想到是别踩白块,我后面跟她说PK赢了发照片给我!

视频奉上:

Python代码制作

完整代码:

#!/usr/local/bin/python3.7
import cv2
import numpy as np
from mss import mss
from collections import Counter
from pynput.mouse import Button, Controller
import time

mouse = Controller()

cords = {'top':140 , 'left': 2090 , 'width': 570, 'height': 540 }
A =time.time()
while time.time() - A < 61:
with mss() as sct :
img = np.array(sct.grab(cords)) #sct.grab(cords/monitor)
#
img[img==img[0,-1]] =0 # remove the boarder
img[img==img[0,0]] =0 # remove the boarder
img[img==img[10,10]] = 0 # first bin
Ra=6 # rsize to reduce the unnecessary calculates
# if the first bin is the target
if np.sum(img[520,10])> 0 and np.sum(img[520,500]) >0:
print("First bin")
#mouse.position = (2090+30, 140+30)
#mouse.press(Button.left)
#mouse.release(Button.left)
else:
Signal = "Run"
for i in range(int(540/Ra)-5):
i = i*Ra
for ii in range(int(570/Ra)-10):
ii = ii*Ra
if np.sum(img[i,ii])>0 and np.sum(img[i,ii] - img[i+3,ii+4])==0:
img[i:i+4,ii:ii+4] = 255
print(i,ii)
#mouse.position = (2090+ii+10, 140+i+10)
#mouse.press(Button.left)
#mouse.release(Button.left)
Signal = "Break"
break
if Signal == "Break":
break

cv2.imshow('image',img)
cv2.moveWindow("image",2800,0)
if cv2.waitKey(1) & 0xFF == ord('q'):
cv2.destroyAllWindows()
break

cv2.destroyAllWindows()

之后应该是大家最想要的照片了

 

  • 22
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 30
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 30
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值