Python cv2.INTER_AREA Examples
The following are 30 code examples for showing how to use cv2.INTER_AREA(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.
You may check out the related API usage on the sidebar.
You may also want to check out all available functions/classes of the module
cv2
, or try the search function
.
Example 1
Project: signature-recognition Author: gnbaron File: preprocessor.py License: MIT License | 6 votes |
def prepare(input): # preprocessing the image input clean = cv2.fastNlMeansDenoising(input) ret, tresh = cv2.threshold(clean, 127, 1, cv2.THRESH_BINARY_INV) img = crop(tresh) # 40x10 image as a flatten array flatten_img = cv2.resize(img, (40, 10), interpolation=cv2.INTER_AREA).flatten() # resize to 400x100 resized = cv2.resize(img, (400, 100), interpolation=cv2.INTER_AREA) columns = np.sum(resized, axis=0) # sum of all columns lines = np.sum(resized, axis=1) # sum of all lines h, w = img.shape aspect = w / h return [*flatten_img, *columns, *lines, aspect]
Example 2
Project: exposure Author: yuanming-hu File: histogram_intersection.py License: MIT License | 6 votes |
def read_images(src, tag=None, set=None): files = os.listdir(src) images = [] if set is not None: set = read_set(set) for f in files: if tag and f.find(tag) == -1: continue if set is not None: if int(f.split('.')[0]) not in set: continue image = (cv2.imread(os.path.join(src, f))[:, :, ::-1] / 255.0).astype(np.float32) longer_edge = min(image.shape[0], image.shape[1]) for i in range(4): sx = random.randrange(0, image.shape[0] - longer_edge + 1) sy = random.randrange(0, image.shape[1] - longer_edge + 1) new_image = image[sx:sx + longer_edge, sy:sy + longer_edge] patch = cv2.resize(new_image, dsize=(80, 80), interpolation=cv2.INTER_AREA) for j in range(4): target_size = 64 ssx = random.randrange(0, patch.shape[0] - target_size) ssy = random.randrange(0, patch.shape[1] - target_size) images.append(patch[ssx:ssx + target_size, ssy:ssy + target_size]) return images
Example 3
Project: insightface Author: deepinsight File: detect_face.py License: MIT License | 6 votes |
def imresample(img, sz): im_data = cv2.resize(img, (sz[1], sz[0]), interpolation=cv2.INTER_AREA) #@UndefinedVariable return im_data # This method is kept for debugging purpose # h=img.shape[0] # w=img.shape[1] # hs, ws = sz # dx = float(w) / ws # dy = float(h) / hs # im_data = np.zeros((hs,ws,3)) # for a1 in range(0,hs): # for a2 in range(0,ws): # for a3 in range(0,3): # im_data[a1,a2,a3] = img[int(floor(a1*dy)),int(floor(a2*dx)),a3] # return im_data
Example 4
Project: derplearning Author: notkarol File: label.py License: MIT License | 6 votes |
def seek(self, frame_id=None): """Update the current frame to the given frame_id, otherwise advances by 1 frame""" if frame_id is None: frame_id = self.frame_id + 1 if frame_id < 0: frame_id = 0 self.paused = True if frame_id >= self.n_frames: frame_id = self.n_frames - 1 self.paused = True self.update_quality(self.frame_id, frame_id, self.quality) self.frame = cv2.resize( derp.util.decode_jpg(self.topics["camera"][frame_id].jpg), None, fx=self.scale, fy=self.scale, interpolation=cv2.INTER_AREA, ) self.frame_id = frame_id return True
Example 5
Project: DeblurGAN-tf Author: LeeDoYup File: data_loader.py License: MIT License | 6 votes |
def read_image_pair(pair_path, resize_or_crop=None, image_size=(256,256)): image_blur = cv2.imread(pair_path[0], cv2.IMREAD_COLOR) image_blur = image_blur / 255.0 * 2.0 - 1.0 image_real = cv2.imread(pair_path[1], cv2.IMREAD_COLOR) image_real = image_real / 255.0 * 2.0 - 1.0 if resize_or_crop != None: assert image_size != None if resize_or_crop == 'resize': image_blur = cv2.resize(image_blur, image_size, interpolation=cv2.INTER_AREA) image_real = cv2.resize(image_real, image_size, interpolation=cv2.INTER_AREA) elif resize_or_crop == 'crop': image_blur = cv2.crop(image_blur, image_size) image_real = cv2.crop(image_real, image_size) else: raise if np.size(np.shape(image_blur)) == 3: image_blur = np.expand_dims(image_blur, axis=0) if np.size(np.shape(image_real)) == 3: image_real = np.expand_dims(image_real, axis=0) image_blur = np.array(image_blur, dtype=np.float32) image_real = np.array(image_real, dtype=np.float32) return image_blur, image_real
Example 6
Project: DeblurGAN-tf Author: LeeDoYup File: data_loader.py License: MIT License | 6 votes |
def read_image(path, resize_or_crop=None, image_size=(256,256)): image = cv2.imread(path, cv2.IMREAD_COLOR) image = image/255.0 * 2.0 - 1.0 assert resize_or_crop != None assert image_size != None if resize_or_crop == 'resize': image = cv2.resize(image, image_size, interpolation=cv2.INTER_AREA) elif resize_or_crop == 'crop': image = cv2.crop(image, image_size) if np.size(np.shape(image)) == 3: image = np.expand_dims(image, axis=0) image = np.array(image, dtype=np.float32) return image
Example 7
Project: PracticalPythonAndOpenCV_CaseStudies Author: hsSam File: imutils.py License: GNU General Public License v3.0 | 6 votes |
def resize(image, width=None, height=None, inter=cv2.INTER_AREA): # Grab the image size (h, w) = image.shape[:2] # If both the width and height are None, then return the original image if width is None and height is None: return image # Check to see if the width is None if width is None: # Calculate the ratio of the height and construct the dimensions r = height / float(h) dim = (int(w * r), height) # Otherwise, the height is None else: # Calculate the ratio of the width and construct the dimensions r = width / float(w) dim = (width, int(h * r)) # Resize the image resized = cv2.resize(image, dim, interpolation=inter) # Return the resized image return resized
Example 8
Project: PracticalPythonAndOpenCV_CaseStudies Author: hsSam File: imutils.py License: GNU General Public License v3.0 | 6 votes |
def resize(image, width=None, height=None, inter=cv2.INTER_AREA): # Grab the image size (h, w) = image.shape[:2] # If both the width and height are None, then return the original image if width is None and height is None: return image # Check to see if the width is None if width is None: # Calculate the ratio of the height and construct the dimensions r = height / float(h) dim = (int(w * r), height) # Otherwise, the height is None else: # Calculate the ratio of the width and construct the dimensions r = width / float(w) dim = (width, int(h * r)) # Resize the image resized = cv2.resize(image, dim, interpolation=inter) # Return the resized image return resized
Example 9
Project: PracticalPythonAndOpenCV_CaseStudies Author: hsSam File: imutils.py License: GNU General Public License v3.0 | 6 votes |
def resize(image, width=None, height=None, inter=cv2.INTER_AREA): # Grab the image size (h, w) = image.shape[:2] # If both the width and height are None, then return the original image if width is None and height is None: return image # Check to see if the width is None if width is None: # Calculate the ratio of the height and construct the dimensions r = height / float(h) dim = (int(w * r), height) # Otherwise, the height is None else: # Calculate the ratio of the width and construct the dimensions r = width / float(w) dim = (width, int(h * r)) # Resize the image resized = cv2.resize(image, dim, interpolation=inter) # Return the resized image return resized
Example 10
Project: tf-lcnn Author: ildoonet File: data_feeder.py License: GNU General Public License v3.0 | 6 votes |
def get_mnist_data(is_train, image_size, batchsize): ds = MNISTCh('train' if is_train else 'test', shuffle=True) if is_train: augs = [ imgaug.RandomApplyAug(imgaug.RandomResize((0.8, 1.2), (0.8, 1.2)), 0.3), imgaug.RandomApplyAug(imgaug.RotationAndCropValid(15), 0.5), imgaug.RandomApplyAug(imgaug.SaltPepperNoise(white_prob=0.01, black_prob=0.01), 0.25), imgaug.Resize((224, 224), cv2.INTER_AREA) ] ds = AugmentImageComponent(ds, augs) ds = PrefetchData(ds, 128*10, multiprocessing.cpu_count()) ds = BatchData(ds, batchsize) ds = PrefetchData(ds, 256, 4) else: # no augmentation, only resizing augs = [ imgaug.Resize((image_size, image_size), cv2.INTER_CUBIC), ] ds = AugmentImageComponent(ds, augs) ds = BatchData(ds, batchsize) ds = PrefetchData(ds, 20, 2) return ds
Example 11
Project: tf-pose Author: SrikanthVelpuri File: pose_dataset.py License: Apache License 2.0 | 6 votes |
def get_heatmap(self, target_size): heatmap = np.zeros((CocoMetadata.__coco_parts, self.height, self.width), dtype=np.float32) for joints in self.joint_list: for idx, point in enumerate(joints): if point[0] < 0 or point[1] < 0: continue CocoMetadata.put_heatmap(heatmap, idx, point, self.sigma) heatmap = heatmap.transpose((1, 2, 0)) # background heatmap[:, :, -1] = np.clip(1 - np.amax(heatmap, axis=2), 0.0, 1.0) if target_size: heatmap = cv2.resize(heatmap, target_size, interpolation=cv2.INTER_AREA) return heatmap.astype(np.float16)
Example 12
Project: TNT Author: GaoangW File: detect_face.py License: GNU General Public License v3.0 | 6 votes |
def imresample(img, sz): im_data = cv2.resize(img, (sz[1], sz[0]), interpolation=cv2.INTER_AREA) #@UndefinedVariable return im_data # This method is kept for debugging purpose # h=img.shape[0] # w=img.shape[1] # hs, ws = sz # dx = float(w) / ws # dy = float(h) / hs # im_data = np.zeros((hs,ws,3)) # for a1 in range(0,hs): # for a2 in range(0,ws): # for a3 in range(0,3): # im_data[a1,a2,a3] = img[int(floor(a1*dy)),int(floor(a2*dx)),a3] # return im_data
Example 13
Project: MazeExplorer Author: microsoft File: vizdoom_gym.py License: MIT License | 6 votes |
def _resize(img, shape): """Resize the specified image. :param img: image to resize :param shape: desired shape in the format (rows, columns) :return: resized image """ if not (OPENCV_AVAILABLE or PILLOW_AVAILABLE): raise ValueError('No image library backend found.'' Install either ' 'OpenCV or Pillow to support image processing.') if OPENCV_AVAILABLE: return cv2.resize(img, shape, interpolation=cv2.INTER_AREA) if PILLOW_AVAILABLE: return np.array(PIL.Image.fromarray(img).resize(shape)) raise NotImplementedError
Example 14
Project: tf2rl Author: keiohta File: atari_wrapper.py License: MIT License | 6 votes |
def observation(self, obs): if self._key is None: frame = obs else: frame = obs[self._key] if self._grayscale: frame = cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY) frame = cv2.resize( frame, (self._width, self._height), interpolation=cv2.INTER_AREA ) if self._grayscale: frame = np.expand_dims(frame, -1) if self._key is None: obs = frame else: obs = obs.copy() obs[self._key] = frame return obs
Example 15
Project: Photoroid Author: 0xPrateek File: new_algo.py License: GNU General Public License v3.0 | 6 votes |
def custom_hashing(image, hash_size=8): image = cv2.resize(image, (hash_size + 1, hash_size), cv2.INTER_AREA) pixel = [] [rows, cols] = image.shape for i in range(0, rows): for j in range(0, cols): pixel.append(image.item(i, j)) pixels = list(pixel) difference = [] for row in range(hash_size - 1): for col in range(hash_size - 1): pixel_left = image.item(row, col) pixel_right = image.item(row, col + 1) difference.append(pixel_left > pixel_right) decimal_value = 0 hex_string = [] for index, value in enumerate(difference): if value: decimal_value += 2 ** (index % 8) if (index % 8) == 7: hex_string.append(hex(decimal_value)[2:].rjust(2, "0")) decimal_value = 0 return "".join(hex_string)
Example 16
Project: visual_foresight Author: SudeepDasari File: topic_utils.py License: MIT License | 6 votes |
def process_image(self, img): assert self._bot + self._top < img.shape[0], "Overcrop! bot + top crop >= image height!" assert self._right + self._left < img.shape[1], "Overcrop! right + left crop >= image width!" bot, right = self._bot, self._right if self._bot <= 0: bot = -(img.shape[0] + 10) if self._right <= 0: right = -(img.shape[1] + 10) img = img[self._top:-bot, self._left:-right] if self.flip: img = img[::-1, ::-1] if (self.height, self.width) != img.shape[:2]: return cv2.resize(img, (self.width, self.height), interpolation=cv2.INTER_AREA) return img
Example 17
Project: ngraph-python Author: NervanaSystems File: gym_wrapper.py License: Apache License 2.0 | 6 votes |
def _modify_observation(self, observation): # convert color to grayscale using luma component observation = ( observation[:, :, 0] * 0.299 + observation[:, :, 1] * 0.587 + observation[:, :, 2] * 0.114 ) observation = cv2.resize( observation, (84, 110), interpolation=cv2.INTER_AREA ) observation = observation[18:102, :] assert observation.shape == (84, 84) # convert to values between 0 and 1 observation = np.array(observation, dtype=np.uint8) return observation
Example 18
Project: pruning_yolov3 Author: zbyuan File: datasets.py License: GNU General Public License v3.0 | 5 votes |
def letterbox(img, new_shape=416, color=(128, 128, 128), mode='auto', interp=cv2.INTER_AREA): # Resize a rectangular image to a 32 pixel multiple rectangle # https://github.com/ultralytics/yolov3/issues/232 shape = img.shape[:2] # current shape [height, width] if isinstance(new_shape, int): r = float(new_shape) / max(shape) # ratio = new / old else: r = max(new_shape) / max(shape) ratio = r, r # width, height ratios new_unpad = (int(round(shape[1] * r)), int(round(shape[0] * r))) # Compute padding https://github.com/ultralytics/yolov3/issues/232 if mode is 'auto': # minimum rectangle dw = np.mod(new_shape - new_unpad[0], 32) / 2 # width padding dh = np.mod(new_shape - new_unpad[1], 32) / 2 # height padding elif mode is 'square': # square dw = (new_shape - new_unpad[0]) / 2 # width padding dh = (new_shape - new_unpad[1]) / 2 # height padding elif mode is 'rect': # square dw = (new_shape[1] - new_unpad[0]) / 2 # width padding dh = (new_shape[0] - new_unpad[1]) / 2 # height padding elif mode is 'scaleFill': dw, dh = 0.0, 0.0 new_unpad = (new_shape, new_shape) ratio = new_shape / shape[1], new_shape / shape[0] # width, height ratios if shape[::-1] != new_unpad: # resize img = cv2.resize(img, new_unpad, interpolation=interp) # INTER_AREA is better, INTER_LINEAR is faster top, bottom = int(round(dh - 0.1)), int(round(dh + 0.1)) left, right = int(round(dw - 0.1)), int(round(dw + 0.1)) img = cv2.copyMakeBorder(img, top, bottom, left, right, cv2.BORDER_CONSTANT, value=color) # add border return img, ratio, dw, dh
Example 19
Project: lirpg Author: Hwhitetooth File: atari_wrappers.py License: MIT License | 5 votes |
def observation(self, frame): frame = cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY) frame = cv2.resize(frame, (self.width, self.height), interpolation=cv2.INTER_AREA) return frame[:, :, None]
Example 20
Project: HardRLWithYoutube Author: MaxSobolMark File: atari_wrappers.py License: MIT License | 5 votes |
def observation(self, frame): frame = cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY) frame = cv2.resize(frame, (self.width, self.height), interpolation=cv2.INTER_AREA) return frame[:, :, None]
Example 21
Project: pytorch-trpo Author: mjacar File: atari_wrapper.py License: MIT License | 5 votes |
def _observation(self, frame): frame = cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY) frame = cv2.resize(frame, (self.width, self.height), interpolation=cv2.INTER_AREA) return frame[:, :, None].transpose(2, 0, 1)
Example 22
Project: chainerrl Author: chainer File: atari_wrappers.py License: MIT License | 5 votes |
def observation(self, frame): frame = cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY) frame = cv2.resize(frame, (self.width, self.height), interpolation=cv2.INTER_AREA) return frame.reshape(self.observation_space.low.shape)
Example 23
Project: exposure Author: yuanming-hu File: folder_data_provider.py License: MIT License | 5 votes |
def __init__(self, folder, read_limit=-1, main_size=80, crop_size=64, augmentation_factor=4, *args, **kwargs): files = os.listdir(folder) files = sorted(files) if read_limit != -1: files = files[:read_limit] data = [] files.sort() for f in files: image = (cv2.imread(os.path.join(folder, f))[:, :, ::-1] / 255.0).astype(np.float32) image = get_image_center(image) # image = cv2.resize(image, (64, 64), interpolation=cv2.INTER_AREA) # data.append(image) image = cv2.resize( image, (main_size, main_size), interpolation=cv2.INTER_AREA) for i in range(augmentation_factor): new_image = image if random.random() < 0.5: new_image = new_image[:, ::-1, :] sx, sy = random.randrange(main_size - crop_size + 1), random.randrange( main_size - crop_size + 1) data.append(new_image[sx:sx + crop_size, sy:sy + crop_size]) data = np.stack(data, axis=0) print("# image after augmentation =", len(data)) super(FolderDataProvider, self).__init__(data, *args, bnw=False, augmentation=1.0, output_size=crop_size, **kwargs)
Example 24
Project: hand-detection.PyTorch Author: zllrunning File: data_augment.py License: MIT License | 5 votes |
def _resize_subtract_mean(image, insize, rgb_mean): interp_methods = [cv2.INTER_LINEAR, cv2.INTER_CUBIC, cv2.INTER_AREA, cv2.INTER_NEAREST, cv2.INTER_LANCZOS4] interp_method = interp_methods[random.randrange(5)] image = cv2.resize(image, (insize, insize), interpolation=interp_method) image = image.astype(np.float32) image -= rgb_mean return image.transpose(2, 0, 1)
Example 25
Project: derplearning Author: notkarol File: util.py License: MIT License | 5 votes |
def resize(image, size): """ Resize the image to the target (w, h) """ is_larger = size[0] > image.shape[1] or size[1] > image.shape[0] interpolation = cv2.INTER_LINEAR if is_larger else cv2.INTER_AREA return cv2.resize(image, size, interpolation=interpolation)
Example 26
Project: 3D-HourGlass-Network Author: Naman-ntc File: functions.py License: MIT License | 5 votes |
def resizeAndPad(img, size, padColor=0): h, w = img.shape[:2] sh, sw = size # interpolation method if h > sh or w > sw: # shrinking image interp = cv2.INTER_AREA else: # stretching image interp = cv2.INTER_CUBIC # aspect ratio of image aspect = w/h # if on Python 2, you might need to cast as a float: float(w)/h # compute scaling and pad sizing if aspect > 1: # horizontal image new_w = sw new_h = np.round(new_w/aspect).astype(int) pad_vert = (sh-new_h)/2 pad_top, pad_bot = np.floor(pad_vert).astype(int), np.ceil(pad_vert).astype(int) pad_left, pad_right = 0, 0 elif aspect < 1: # vertical image new_h = sh new_w = np.round(new_h*aspect).astype(int) pad_horz = (sw-new_w)/2 pad_left, pad_right = np.floor(pad_horz).astype(int), np.ceil(pad_horz).astype(int) pad_top, pad_bot = 0, 0 else: # square image new_h, new_w = sh, sw pad_left, pad_right, pad_top, pad_bot = 0, 0, 0, 0 # set pad color if len(img.shape) is 3 and not isinstance(padColor, (list, tuple, np.ndarray)): # color image but only one color provided padColor = [padColor]*3 # scale and pad scaled_img = cv2.resize(img, (new_w, new_h), interpolation=interp) scaled_img = cv2.copyMakeBorder(scaled_img, pad_top, pad_bot, pad_left, pad_right, borderType=cv2.BORDER_CONSTANT, value=padColor) return scaled_img
Example 27
Project: 3D-HourGlass-Network Author: Naman-ntc File: functions.py License: MIT License | 5 votes |
def resizeAndPad(img, size, padColor=0): h, w = img.shape[:2] sh, sw = size # interpolation method if h > sh or w > sw: # shrinking image interp = cv2.INTER_AREA else: # stretching image interp = cv2.INTER_CUBIC # aspect ratio of image aspect = w/h # if on Python 2, you might need to cast as a float: float(w)/h # compute scaling and pad sizing if aspect > 1: # horizontal image new_w = sw new_h = np.round(new_w/aspect).astype(int) pad_vert = (sh-new_h)/2 pad_top, pad_bot = np.floor(pad_vert).astype(int), np.ceil(pad_vert).astype(int) pad_left, pad_right = 0, 0 elif aspect < 1: # vertical image new_h = sh new_w = np.round(new_h*aspect).astype(int) pad_horz = (sw-new_w)/2 pad_left, pad_right = np.floor(pad_horz).astype(int), np.ceil(pad_horz).astype(int) pad_top, pad_bot = 0, 0 else: # square image new_h, new_w = sh, sw pad_left, pad_right, pad_top, pad_bot = 0, 0, 0, 0 # set pad color if len(img.shape) is 3 and not isinstance(padColor, (list, tuple, np.ndarray)): # color image but only one color provided padColor = [padColor]*3 # scale and pad scaled_img = cv2.resize(img, (new_w, new_h), interpolation=interp) scaled_img = cv2.copyMakeBorder(scaled_img, pad_top, pad_bot, pad_left, pad_right, borderType=cv2.BORDER_CONSTANT, value=padColor) return scaled_img
Example 28
Project: opencv_transforms Author: jbohnslav File: functional.py License: MIT License | 5 votes |
def affine(img, angle, translate, scale, shear, interpolation=cv2.INTER_LINEAR, mode=cv2.BORDER_CONSTANT, fillcolor=0): """Apply affine transformation on the image keeping image center invariant Args: img (numpy ndarray): numpy ndarray to be transformed. angle (float or int): rotation angle in degrees between -180 and 180, clockwise direction. translate (list or tuple of integers): horizontal and vertical translations (post-rotation translation) scale (float): overall scale shear (float): shear angle value in degrees between -180 to 180, clockwise direction. interpolation (``cv2.INTER_NEAREST` or ``cv2.INTER_LINEAR`` or ``cv2.INTER_AREA``, ``cv2.INTER_CUBIC``): An optional resampling filter. See `filters`_ for more information. If omitted, it is set to ``cv2.INTER_CUBIC``, for bicubic interpolation. mode (``cv2.BORDER_CONSTANT`` or ``cv2.BORDER_REPLICATE`` or ``cv2.BORDER_REFLECT`` or ``cv2.BORDER_REFLECT_101``) Method for filling in border regions. Defaults to cv2.BORDER_CONSTANT, meaning areas outside the image are filled with a value (val, default 0) val (int): Optional fill color for the area outside the transform in the output image. Default: 0 """ if not _is_numpy_image(img): raise TypeError('img should be numpy Image. Got {}'.format(type(img))) assert isinstance(translate, (tuple, list)) and len(translate) == 2, \ "Argument translate should be a list or tuple of length 2" assert scale > 0.0, "Argument scale should be positive" output_size = img.shape[0:2] center = (img.shape[1] * 0.5 + 0.5, img.shape[0] * 0.5 + 0.5) matrix = _get_affine_matrix(center, angle, translate, scale, shear) if img.shape[2]==1: return cv2.warpAffine(img, matrix, output_size[::-1],interpolation, borderMode=mode, borderValue=fillcolor)[:,:,np.newaxis] else: return cv2.warpAffine(img, matrix, output_size[::-1],interpolation, borderMode=mode, borderValue=fillcolor)
Example 29
Project: ssds.pytorch Author: ShuangXieIrene File: data_augment.py License: MIT License | 5 votes |
def preproc_for_test(image, insize, mean): interp_methods = [cv2.INTER_LINEAR, cv2.INTER_CUBIC, cv2.INTER_AREA, cv2.INTER_NEAREST, cv2.INTER_LANCZOS4] interp_method = interp_methods[random.randrange(5)] image = cv2.resize(image, (insize[0], insize[1]),interpolation=interp_method) image = image.astype(np.float32) image -= mean return image.transpose(2, 0, 1)
Example 30
Project: Reinforcement_Learning_for_Traffic_Light_Control Author: quantumiracle File: atari_wrappers.py License: Apache License 2.0 | 5 votes |
def observation(self, frame): frame = cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY) frame = cv2.resize(frame, (self.width, self.height), interpolation=cv2.INTER_AREA) return frame[:, :, None]