-1

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

PersianMan
  • 924
  • 1
  • 12
  • 29
berkayld
  • 9
  • 1

1 Answers1

2

remove the * in imshow , you must pass the image matrix in one argument

cv.imshow("cropped", crop_img)

What does ** (double star/asterisk) and * (star/asterisk) do for parameters?

PersianMan
  • 924
  • 1
  • 12
  • 29
  • Thank you so much for helping. i did like you said but result is same. i see nothing. I put star in file1 path so can it about it? – berkayld Oct 29 '21 at 13:54
  • @berkayld what is the error? what is your IDE? – PersianMan Oct 29 '21 at 15:16
  • There is no error. I am using Visiual Studio Code. I just want to crop template result and i want to see it but its feels like skiping this code ` cv.imshow("cropped", crop_img)` showing me nothing after that my terminal waiting next command like everything completed. I can see which picture templated but i cant see crop result. Thank you so much again – berkayld Oct 30 '21 at 11:42