#NoPayJan Offer - Access all CloudxLab Courses for free between 1st to 31st Jan

  Enroll Now >>

Viewing the Best Matches

From all the keypoints extracted by the BFMatcher, let us plot and view 30 of the best common key-points between the left and right images.

We shall do this in 3 steps:

  • Create a dictionary draw_paramswhich mentions the color of the lines marking the matches between the images, and flags=2 which says to show only those 30 key-points and not any other key-points. (You could experiment this by removing flags)

  • Use cv2.drawMatches which returns the image drawn with the 30 common key-points between the right and left images img_right and img_left, as per the properties mentioned in draw_params. We need to pass the fixColor(img_right), kp1, fixColor(img_left), kp2, matches[:30] as arguments for this method.

  • Finally, display the image returned by cv2.drawMatches using matplotlib's plt.imshow.

INSTRUCTIONS
  • Declare the dictionary draw_params that mentions the color to be used(matchColor) and flags value.

    draw_params = dict(matchColor = (255,255,0), # draw matches in yellow color
               flags = 2)
    

    Here, we have chosen to use yellow color to draw the matches, and used flags=2 that indicates to show only those 30 key-points which are being drawn now and don't show others for a neater look.

  • Use the following code to get the image with 30 of the common key-points matched between left and right images.

    matched_features_image = cv2.drawMatches(fixColor(img_right), kp1, fixColor(img_left), kp2, matches[:30], None,**draw_params)
    
    plt.figure(figsize=(30,20))
    plt.imshow(matched_features_image)
    

No hints are availble for this assesment

Answer is not availble for this assesment


Note - Having trouble with the assessment engine? Follow the steps listed here

Loading comments...