1

I'm not sure is this possible in cv2 to look specific line print position if matched.

When I'm trying to compare template image it is comparing entire template image (whole block all whites and blacks) inside the main image. And because of that the template isn't matched at threshold of 70%.

Is there any way that cv2 doesn't compare entire template image but only black lines? Lines like in the image bellow where the template images are not recognized because on main image there are some additional lines

enter image description here

Is anyone familiar how to solve this?

here is my code:

import cv2
import numpy as np

threshold = 75

img_rgb = cv2.imread("master_image.bmp")
img_gray = cv2.cvtColor(img_rgb, cv2.COLOR_BGR2GRAY)

template = cv2.imread("7test.png",0)

w, h = template.shape[::-1]
res = cv2.matchTemplate(img_gray, template, cv2.TM_CCOEFF_NORMED)
location = np.where(res >= threshold)
eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Dragon.M
  • 249
  • 1
  • 4
  • 11

0 Answers0