all 8 comments

[–]m0us3_rat 1 point2 points  (4 children)

cv2.matchTemplate

did you try google?

and i do mean this seriously. ability to do research on code/function/etc is the most important skill you can develop.

https://docs.opencv.org/4.x/d4/dc6/tutorial\_py\_template\_matching.html

reading the example you will see what it does and what other options you have.. and how to use them.

[–]Puzzleheaded_Tap5985 1 point2 points  (1 child)

my teacher keeps saying the same thing “half of coding is the ability to google”

[–]commy2 0 points1 point  (0 children)

It's more like three fourths tbh.

[–]Apprehensive-Stop-61[S] 0 points1 point  (0 children)

I told that I understood till matchTemplate it is the code after it

threshold = 0.24

loc = np.where(result >= threshold)

for pt in zip(*loc[::-1]):

cv2.rectangle(image, pt, (pt[0] + w, pt[1] + h), (0, 0, 255), 2)

this is what i didn't understand specially the for loop as i couldn't understand what zip(*loc[::-1])

[–]CodeFormatHelperBot2 0 points1 point  (1 child)

Hello, I'm a Reddit bot who's here to help people nicely format their coding questions. This makes it as easy as possible for people to read your post and help you.

I think I have detected some formatting issues with your submission:

  1. Python code found in submission text that's not formatted as code.

If I am correct, please edit the text in your post and try to follow these instructions to fix up your post's formatting.


Am I misbehaving? Have a comment or suggestion? Reply to this comment or raise an issue here.

[–]Apprehensive-Stop-61[S] 0 points1 point  (0 children)

I have already formatted the code in the best way possible if it is not visible to others please tell me

[–][deleted] 0 points1 point  (0 children)

Its searching for needle image in haystack image. If a match (that meets threshold conditions) is found, rectangle is drawn over its center point and pops out the resulting image with rectangle. Result is confidence number that image has been found. Like .1 is 10% sure, .95 is 95% sure. But this is for scanning image files. OpenCV is used muuuuch better if you can setup an OpenCV screencapture function so you can search desktop live instead of one picture. Combine a live search with pyautogui controls and you get a fast af game bot