Created
December 24, 2014 05:52
-
-
Save heaven00/3e1fd8052bde8ec648f3 to your computer and use it in GitHub Desktop.
Template matching trial
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#sign to be detected | |
template = cv2.imread('sign.png') | |
#image in which it is to be directed | |
image = cv2.imread('iamge.jpg') | |
template_gray = cv2.cvtColor(template, cv2.COLOR_BGR2GRAY) | |
image_gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) | |
res = cv2.matchTemplate(image_gray, template_gray, cv2.TM_CCOEFF_NORMED) | |
threshold = 0.7 | |
loc = np.where(res >= threshold) | |
print loc | |
for point in zip(*loc[::-1]): | |
cv2.rectangle(image, point, (20, 20), (0, 0, 255), 2) | |
cv2.imwrite('test.jpg', image) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment