0
我正在創建一個應用程序,它使用OpenCV和其他Python庫來抓取某人的屏幕區域,並將其與模板圖像進行比較。此代碼完美工作,直到「dst」行。在這一點上我收到錯誤Python OpenCV錯誤:輸入參數的大小不匹配
141 825 3 141 825 3 OpenCV Error: Sizes of input arguments do not match (The operation is neither 'array op array' (where arrays have the same size and the same number of channels), nor 'array op scalar', nor 'scalar op array')
通常我會覺得,因爲不同的圖像大小的出現這個錯誤。但他們完全一樣。我通過印刷它們的高度,寬度和深度來證實這一點。正如你在上面看到的,它們是相同的。
import win32api, win32con, win32gui
import os
import sys
import time
import Image
import ImageGrab
import cv2
import numpy as np
player = cv2.imread('./images/bg_eagle_player.png')
#User Settings:
SaveDirectory=r'C:\Users\something\somethingeelse'
while (1):
img=ImageGrab.grab()
saveas=os.path.join(SaveDirectory,'test.png')
img.save(saveas)
img = cv2.imread('test.png')
player_border = img[436:577, 378:1203]
height, width, depth = player.shape
print height, width, depth
height, width, depth = player_border.shape
print height, width, depth
dst = cv2.addWeighted(player,0.7,img,0.3,0)
cv2.imshow('image',dst)
cv2.waitKey(0)
cv2.destroyAllWindows()
time.sleep(0.1)
任何想法?
這兩幅圖像的高度寬度和深度(141 825 3,141 825 3)表明不然。 – Harangue
您檢查'img'和'player_border'是相同的大小,但是您在'img'和'player'上調用'addWeighted()'。這是相同的尺寸嗎? – holdenweb
謝謝,就是這樣。尷尬,它讓我難住。 – Harangue