You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This error means that OpenCV doesn't like one of the images you've given to matchTemplate(). Either it's not a valid image, or OpenCV just doesn't like how your image is formatted. So the problem could be anywhere along the chain from when you first capture or load the image, to where you give it to matchTemplate().
Most likely this will be your haystack_img that it has a problem with. When I was working on this project, I saw this error most often when I was calling find() before the window capture had successfully taken a screenshot. This usually happens when the program is first started.
So the first thing to try is adding something like:
if screenshot is None:
continue
to your main while loop, so it'll only call find() once it has a screenshot.
If that doesn't solve it, I would try saving your screenshot image to a file to confirm it looks how you expect it to. If it looks fine, then there's some sort of conversion you'll need to apply/remove from the image. You can see in WindowCapture get_screenshot() where I've left a comment about a similar error and needing to do a conversion to remove the alpha channel.
File "main.py", line 31, in
points = vision_limestone.find(screenshot, 0.5, 'rectangles')
File "C:\Users\x\Documents\x\lx\vision.py", line 29, in find
result = cv.matchTemplate(haystack_img, self.needle_img, self.method)
cv2.error: OpenCV(4.4.0) C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-52oirelq\opencv\modules\imgproc\src\templmatch.cpp:1163: error: (-215:Assertion failed) (depth == CV_8U || depth == CV_32F) && type == _templ.type() && _img.dims() <= 2 in function 'cv::matchTemplate'
Not sure what's causing this. My own version of the code causes it and then I tried directly copying the file structure and this still happens
The text was updated successfully, but these errors were encountered: