I am new for coding. I am trying to make a little project for myself. OpenCV showing template matching result but its seems like i can't crop it or imshow not giving me crop result
Here are my codes:
for myfile in files1:
image = cv.imread(myfile,0)
template_data.append(image)
for tmp in template_data:
w, h = tmp.shape[::-1]
result = cv.matchTemplate(img_gray,myfile,cv.TM_CCOEFF_NORMED)
_, _, _, maxLoc=cv.minMaxLoc(result)
topLeft = maxLoc
bottom_right = (topLeft[0] + w , topLeft[1] + h)
cv.rectangle(img_rgb,topLeft, bottom_right,255, 2)
crop_img = img_rgb[maxLoc[1]:maxLoc[1]+w, maxLoc[0]:maxLoc[0]+h, :]
cv.imshow("cropped", *crop_img)
cv.waitKey()
Thanks for helping