              image = self.load_video_frame(filename)
          else:
              src = os.path.join(self.folder, filename)
              logger.trace("Loading image: '%s'", src)
              image = cv2.imread(src)  # pylint: disable=no-member
          return image
  
      def load_video_frame(self, filename):
          """ Load a requested frame from video """
          frame = os.path.splitext(filename)[0]
 
</s> remove             retval = cv2.imread(filename)  # pylint: disable=no-member
 </s> add             retval = cv2_read_img(filename, raise_error=True) </s> remove             logger.trace("Loading image: '%s'", filename)
            try:
                image = cv2.imread(filename)  # pylint: disable=no-member
            except Exception as err:  # pylint: disable=broad-except
                logger.error("Failed to load image '%s'. Original Error: %s", filename, err)
 </s> add             image = cv2_read_img(filename, raise_error=False)
            if image is None: </s> remove         image = cv2.imread(filename)
 </s> add         image = cv2_read_img(filename, raise_error=True) </s> remove         try:
            image = cv2.imread(filename)  # pylint: disable=no-member
        except TypeError:
            raise Exception("Error while reading image", filename)

 </s> add         image = cv2_read_img(filename, raise_error=True) </s> remove         image = cv2.imread(self.images["a"][0])  # pylint: disable=no-member
 </s> add         image = cv2_read_img(self.images["a"][0], raise_error=True)
            image = cv2_read_img(src, raise_error=True)
              image = self.load_video_frame(filename)
          else:
              src = os.path.join(self.folder, filename)
              logger.trace("Loading image: '%s'", src)
            image = cv2_read_img(src, raise_error=True)
          return image
  
      def load_video_frame(self, filename):
          """ Load a requested frame from video """
          frame = os.path.splitext(filename)[0]
keep keep keep keep replace keep keep keep keep keep
 Centralize cv2 image reading and handle bad filenames 
tools/lib_alignments/media.py