Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions chainerrl/wrappers/atari_wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,20 @@

from collections import deque

import cv2
import gym
import numpy as np

from gym import spaces

import chainerrl

cv2.ocl.setUseOpenCL(False)

try:
import cv2
cv2.ocl.setUseOpenCL(False)
_is_cv2_available = True
except Exception:
_is_cv2_available = False


class NoopResetEnv(gym.Wrapper):
Expand Down Expand Up @@ -151,7 +156,12 @@ def _reward(self, reward):

class WarpFrame(gym.ObservationWrapper):
def __init__(self, env, channel_order='hwc'):
"""Warp frames to 84x84 as done in the Nature paper and later work."""
"""Warp frames to 84x84 as done in the Nature paper and later work.

To use this wrapper, OpenCV-Python is required.
"""
if not _is_cv2_available:
raise RuntimeError('Cannot import cv2 module. Please install OpenCV-Python to use WarpFrame.') # NOQA
gym.ObservationWrapper.__init__(self, env)
self.width = 84
self.height = 84
Expand Down