def drawMatches(img1, kp1, img2, kp2, matches):
<EOL>rows1 = img1.shape[<NUM_LIT:0>]<EOL>cols1 = img1.shape[<NUM_LIT:1>]<EOL>rows2 = img2.shape[<NUM_LIT:0>]<EOL>cols2 = img2.shape[<NUM_LIT:1>]<EOL>out = np.zeros((max([rows1, rows2]), cols1 + cols2, <NUM_LIT:3>), dtype='<STR_LIT>')<EOL>out[:rows1, :cols1, :] = np.dstack([img1, img1, img1])<EOL>out[:rows2, cols1:cols1 + cols2, :] = np.dstack([img2, img2, img2])<EOL>for mat in matches:<EOL><INDENT>mat = mat<EOL>img1_idx = mat.queryIdx<EOL>img2_idx = mat.trainIdx<EOL>(x1, y1) = kp1[img1_idx].pt<EOL>(x2, y2) = kp2[img2_idx].pt<EOL>cv2.circle(out, (int(x1), int(y1)), <NUM_LIT:4>, (<NUM_LIT:255>, <NUM_LIT:0>, <NUM_LIT:0>), <NUM_LIT:1>)<EOL>cv2.circle(out, (int(x2) + cols1, int(y2)), <NUM_LIT:4>, (<NUM_LIT:255>, <NUM_LIT:0>, <NUM_LIT:0>), <NUM_LIT:1>)<EOL>f = lambda : random.randint(<NUM_LIT:1>, <NUM_LIT:255>)<EOL>line_color = (f(), f(), f())<EOL>cv2.line(out, (int(x1), int(y1)), (int(x2) + cols1, int(y2)), line_color, <NUM_LIT:1>)<EOL><DEDENT>cv2.imshow('<STR_LIT>', out)<EOL>cv2.waitKey(<NUM_LIT:0>)<EOL>cv2.destroyAllWindows()<EOL>
My own implementation of cv2.drawMatches as OpenCV 2.4.9
does not have this function available but it's supported in
OpenCV 3.0.0

This function takes in two images with their associated 
keypoints, as well as a list of DMatch data structure (matches) 
that contains which keypoints matched in which images.

An image will be produced where a montage is shown with
the first image followed by the second image beside it.

Keypoints are delineated with circles, while lines are connected
between matching keypoints.

img1,img2 - Grayscale images
kp1,kp2 - Detected list of keypoints through any of the OpenCV keypoint 
          detection algorithms
matches - A list of matches of corresponding keypoints through any
          OpenCV keypoint matching algorithm