Project - Mask R-CNN with OpenCV for Object Detection

You are currently auditing this course.
2 / 8

Importing the Modules

Let us begin by importing the necessary modules, setting the seed to get reproducible results, and defining a function fixColor.

Note:

  • By default, a color image with Red, Green, and Blue channels will be read in reverse order; ie, Blue, Green, and Red by OpenCv.

    We could fix this issue by using cv2.COLOR_BGR2RGB transformation effect on the image.

    So, we shall define a function fixColor to return the RGB form of the given image.

  • cv2.cvtColor() method is used to convert an image from one color space to another.

  • cv2.COLOR_BGR2RGB returns image in RGB format, which was initially in BGR format as read by cv2.imread().

INSTRUCTIONS
  • Import numpy as np.

     import << your code comes here >> as  << your code comes here >>
    
  • Set the numpy seed:

    np.random.seed(42)
    
  • Import matplotlib.pyplot as plt.

    import << your code comes here >> as << your code comes here >>
    
  • Import cv2.

    import << your code comes here >>
    
  • Define fixColor function which takes an image as the input argument ad returns the RGB format of the image. Pass cv2.COLOR_BGR2RGB as an input argument along with image to the cv2.cvtColor method.

    def fixColor(image):
        return(cv2.cvtColor(image, << your code comes here >>))
    
Get Hint See Answer

Loading comments...