这是我的代码:
import numpy as np
from PIL import ImageGrab
import cv2
while(True):
printscreen_pil = ImageGrab.grab(bbox=(781, 925, 814, 941))
printscreen_numpy = np.array(printscreen_pil.getdata(),dtype='uint8')\
.reshape((printscreen_pil.size[1],printscreen_pil.size[0],3))
cv2.imshow('window',printscreen_numpy)
if cv2.waitKey(25) & 0xFF == ord('q'):
cv2.destroyAllWindows()
break
答案 0 :(得分:1)
请注意,bbox为(x1,y1,x2,y2),因此(781、925、814、941)是一个狭窄的屏幕。
这是我的示例:
def triangle(n, choice):
k = 2*n-2
for i in range(0, n):
for j in range(0, k):
print(end = ' ')
k = k-1
for t in range(0, i+1):
print(choice, end = " ")
print("\r")
def main():
n = int(input("Input a number: "))
choice = input("Enter a character to draw: ")
triangle(n, choice)
main()