How to do template matching without opencv? How to do template matching without opencv ?  

I have a order invoice of documents belonging to Amazon ,ebay,flipkart,snapdeal and i want to extract few information from the order invoice .
Since the fields like order number,customer name ,order details will be present at different position in these 4 templates ,

i need to first classify to which of these 4 templates the input image will belong to and after identifying the template i can do my next work of text extraction using tesseract and regex buy writing code for specific templates .

when i searched i found only openCV had this feature i was not able to find any convolution neural network model .Are there any such neural network model available for template matching and classification ? 

i cannot use the standard model available for classifying dogs and cat because here im dealing with image of an invoice templates which has only text with rows and columns in some format .
import numpy as np
import matplotlib.image as img
import matplotlib.pyplot as plt
from skimage.metrics import structural_similarity as ssim

def rgb2gray(rgb):
    return np.dot(rgb[...,:3], [0.299, 0.587, 0.144])

full_image = rgb2gray(img.imread(&quot;img/full_image.png&quot;))
sub_image = rgb2gray(img.imread(&quot;img/sub_image.png&quot;))

full_w,full_h = full_image.shape[:2]
sub_w,sub_h = sub_image.shape[:2]

print(full_w,full_h)
print(sub_w,sub_h)

winW = 0
found = False
while winW &lt; full_w - sub_w and found == False:
    winH = 0
    while winH &lt; full_h - sub_h:
        window = full_image[winW:winW+sub_w, winH:winH+sub_h]
        if ssim(sub_image, window) &gt; 0.80:
            found = True
            print(&quot;found&quot;, ssim(sub_image, window))
            plt.imshow(window)
            break
        winH += 2
    winW += 2