Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Opencv exact match

I have two images, and I need to find one image in another.

Source image: link

Need find this image: link

There is a simple python code that finds a match

import cv2
import numpy as np

source = cv2.imread('screen1.jpg')
template = cv2.imread('tpl.jpg')

result = cv2.matchTemplate(source,template,cv2.TM_CCOEFF_NORMED)
y,x = np.unravel_index(result.argmax(), result.shape)
print x,y

It returns coordinates

185 3

But they are wrong, because the image that we are looking for is not available in our image

How to make to return an exact match, and if not found then return false or 0 0

Opencv exact match

I have two images, and I need to find one image in another.

Source image: link

Need find this image: link

There is a simple python code that finds a match

import cv2
import numpy as np

source = cv2.imread('screen1.jpg')
template = cv2.imread('tpl.jpg')

result = cv2.matchTemplate(source,template,cv2.TM_CCOEFF_NORMED)
y,x = np.unravel_index(result.argmax(), result.shape)
print x,y

It returns coordinates

185 3

But they are wrong, because the image that we are looking for is not available in our image

How to make to return an exact match, and if not found then return false or 0 0

click to hide/show revision 3
retagged

updated 2014-03-05 09:11:30 -0600

berak gravatar image

Opencv exact match

I have two images, and I need to find one image in another.

Source image: link

Need find this image: link

There is a simple python code that finds a match

import cv2
import numpy as np

source = cv2.imread('screen1.jpg')
template = cv2.imread('tpl.jpg')

result = cv2.matchTemplate(source,template,cv2.TM_CCOEFF_NORMED)
y,x = np.unravel_index(result.argmax(), result.shape)
print x,y

It returns coordinates

185 3

But they are wrong, because the image that we are looking for is not available in our image

How to make to return an exact match, and if not found then return false or 0 0