def get_image_features(self, img_file, stride=5, padding=True):
"""
Take an image file as input, and output an array of image features whose matrix size is
based on the image size. When no padding, and the image size is smaller than the required
feature space size (in x or y direction), the image is not checked, and this method will
return a tuple of two empty lists; When padding is True, and the image size is more than
4 pixels smaller than the require feature space size (in x or y direction), the image is
not checked either. This method can be used by both the trainer and predictor.
Args:
img_file: The file name of the image.
stride: Optional. The stride of the sliding.
padding: Optional. Whether to pad the image to fit the feature space size or to
discard the extra pixels if padding is False.
Returns:
coordinates: A list of coordinates, each of which contains y and x that are the top
left corner offsets of the sliding window.
features: A matrix (python list), in which each row contains the features of the
sampling sliding window, while the number of rows depends on the image size of
the input.
"""
img = cv2.imread(img_file)
img_arr = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
return self.get_image_array_features(img_arr, stride, padding)
评论列表
文章目录