所以我有32位python,我想下载64位,以便它可以支持tensorflow,但现在它根本不起作用。它以前可以使用,但现在在64位或32位IDLE中不起作用。
我已经重新安装了python,并且是编程的新手,所以不知道还有什么尝试
from PIL import ImageGrab
import cv2
import time
def roi(img, vertices):
mask = np.zeros_like(img)
cv2.fillPoly(mask, vertices, (250*250*250))
masked = cv2.bitwise_and(img, mask)
return masked
def process_img(original_image):
processed_img = cv2.cvtColor(np.array(screen), cv2.COLOR_BGR2GRAY)
## processed_img = cv2.Canny(processed_img, 400,400)
vertices = np.array([[85,75],[85,15],[150,15],[150,75]])
processed_img = roi(processed_img, [vertices])
return processed_img
def process_img2(original_image):
processed_img2 = cv2.cvtColor(np.array(screen2), cv2.COLOR_BGR2GRAY)
## processed_img = cv2.Canny(processed_img, 400,400)
## vertices2 = np.array([])
## processed_img2 = roi(processed_img2, [vertices])
return processed_img2
last_time = time.time()
while (True):
screen = np.array(ImageGrab.grab(bbox =(750, 400, 950, 500)))
screen2 = np.array(ImageGrab.grab(bbox =(405, 210, 650, 290)))
new_screen = process_img(screen)
new_screen2 = process_img2(screen2)
print("Loop took {} seconds".format(time.time()-last_time))
last_time = time.time()
cv2.imshow("window", new_screen)
cv2.imshow("window2", new_screen2)
## cv2.imshow("window",cv2.cvtColor(np.array(screen), cv2.COLOR_BGR2RGB))
if cv2.waitKey(25) & 0xFF == ord("q"):
cv2.destroyAllWindows
break
它应该显示来自不同位置的2个不同的“流”,但它仅在64位时给出此错误:
Traceback (most recent call last):
File "F:\Käyttäjät\Roope Kärkkäinen\Desktop\Image grab\Gitgut.py", line 1, in <module>
import numpy as np
File "C:\Users\Roope Kärkkäinen\AppData\Roaming\Python\Python37\site-packages\numpy\__init__.py", line 142, in <module>
from . import core
File "C:\Users\Roope Kärkkäinen\AppData\Roaming\Python\Python37\site-packages\numpy\core\__init__.py", line 23, in <module>
WinDLL(os.path.abspath(filename))
File "C:\Users\Roope Kärkkäinen\AppData\Local\Programs\Python\Python37\lib\ctypes\__init__.py", line 356, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 193] %1 ei ole kelvollinen Win32-sovellus
和这一个32位元:
Traceback (most recent call last):
File "F:\Käyttäjät\Roope Kärkkäinen\Desktop\Image grab\Gitgut.py", line 2, in <module>
from PIL import ImageGrab
File "C:\Users\Roope Kärkkäinen\AppData\Roaming\Python\Python37\site-packages\PIL\ImageGrab.py", line 18, in <module>
from . import Image
File "C:\Users\Roope Kärkkäinen\AppData\Roaming\Python\Python37\site-packages\PIL\Image.py", line 93, in <module>
from . import _imaging as core
ImportError: cannot import name '_imaging' from 'PIL' (C:\Users\Roope Kärkkäinen\AppData\Roaming\Python\Python37\site-packages\PIL\__init__.py)
请帮助。