Description
I've got this program with a for loop which runs through a list.
However when I put the x1 and y1 cords in at non-zero I start getting problems.
I threw together a gui where I input the region to grab, but as soon as I put in x1 and y1 as something non-zero I start getting issues, different issues depending on values.
400, 400, 400, 400 gives me:
...Programs\Python\Python39\lib\site-packages\mss\windows.py", line 285, in _grab_impl
raise ScreenShotError("gdi32.GetDIBits() failed.")
mss.exception.ScreenShotError: gdi32.GetDIBits() failed.
200, 200, 400, 400 gives me
...Programs\Python\Python39\lib\site-packages\python_imagesearch\imagesearch.py", line 73, in imagesearcharea
img_gray = cv2.cvtColor(img_rgb, cv2.COLOR_BGR2GRAY)
cv2.error: OpenCV(4.5.1) C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-wvn_it83\opencv\modules\imgproc\src\color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor'
Exception: Line: 0 Callable failed || error occured in a callback
if I put in something like 200, 200, 500, 500 it does run but it doesn't seem to find the images.
def findPicOpt3(sender, data):
t = Timer(name="random stuff")
t.start()
confidence = get_value("inputint4")
print("searching with confidence level", confidence)
# im = region_grabber((confidence[0], confidence[1], confidence[2], confidence[3]))
for num, name in enumerate(imagelist.testImages):
pos = imagesearcharea(
imagelist.testImages[num],
confidence[0],
confidence[1],
confidence[2],
confidence[3],
# im,
)
if pos[0] != -1:
print("Found", imagelist.testNames[num], "at", pos)
else:
print("image not found")
t.stop()
I wonder if it has to do with the fact that when I try to debug using im.save it tells me screenshot has no attribute called save:
python_imagesearch\imagesearch.py", line 70, in imagesearcharea
im.save(
AttributeError: 'ScreenShot' object has no attribute 'save'
Exception: Line: 0 Callable failed || error occured in a callback
Might I be missing a package or an import? If so I haven't been able to spot which and what
I've seen this being reported when people have their path wrong, but it works with regular imagesearch and makes an absolute path
I have triple monitor 1920x1080 setup (one vertical) but I tried disconnecting two of them and this was still a problem.
I'm on windows.
is this a bug or should I just give up programming and become a truck driver?
edit: btw lets say I want to grap the middle 800x800 region on a (theoretical) monitor of 1200x1200, I assume I should put in 200, 200, 1000,1000? or 200,200,800,800?.. ive tried both anyway, both don't seem to work.. it's like the region_grabber is accepting widthxheight, and something else is working on topx, topy, bottomx, bottomy? is this possible?