Traceback (most recent call last):
File "C:\Users\A\Desktop\waterRPA\waterRPA.py", line 158, in
mainWork(sheet1)
File "C:\Users\A\Desktop\waterRPA\waterRPA.py", line 99, in mainWork
mouseClick(1,"left",img,reTry)
File "C:\Users\A\Desktop\waterRPA\waterRPA.py", line 13, in mouseClick
location=pyautogui.locateCenterOnScreen(img)
File "C:\Users\A\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyautogui__init.py", line 175, in wrapper
return wrappedFunction(*args, **kwargs)
File "C:\Users\A\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyautogui\init.py", line 207, in locateCenterOnScreen
return pyscreeze.locateCenterOnScreen(*args, **kwargs)
File "C:\Users\A\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyscreeze\init.py", line 413, in locateCenterOnScreen
coords = locateOnScreen(image, **kwargs)
File "C:\Users\A\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyscreeze\init.py", line 373, in locateOnScreen
retVal = locate(image, screenshotIm, **kwargs)
File "C:\Users\A\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyscreeze\init.py", line 353, in locate
points = tuple(locateAll(needleImage, haystackImage, **kwargs))
File "C:\Users\A\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyscreeze\init__.py", line 229, in _locateAll_opencv
result = cv2.matchTemplate(haystackImage, needleImage, cv2.TM_CCOEFF_NORMED)
cv2.error: OpenCV(4.5.4) D:\a\opencv-python\opencv-python\opencv\modules\core\src\alloc.cpp:73: error: (-4:Insufficient memory) Failed to allocate 199209624 bytes in function 'cv::OutOfMemoryError'
And the picture use to locateCenterOnScreen() just 16.5KB.But it throw OutOfMemoryError.
while Ture:
location=pyautogui.locateCenterOnScreen(img,confidence=0.9)
if location is not None:
pyautogui.click(location.x,location.y,clicks=clickTimes,interval=0.2,duration=0.2,button=lOrR)
break
print("Not found,retry after 0.1s")
time.sleep(0.1)
I have the same problem. It happens when i use pyautogui.locateCenterOnScreen(path_img) on loop.
My image has only 24.4Kb.
In my case happened in iteration 1784.
I would do a total of 3000 iterations.
This is error imformation:
And the picture use to locateCenterOnScreen() just 16.5KB.But it throw OutOfMemoryError.
This error will happend after 10 times or more.