Commit 16f32f40 authored by Aaron Gokaslan's avatar Aaron Gokaslan Committed by Yuxin Wu

Atari Visualization Bugfix (#529)

* Atari Visualization Bugfix

OpenCV2 does not always display the visualization properly. 

For imshow to properly update, cv2.waitKey should be called. Without this line, the cv2 window does not refresh on my system with OpenCV version 2.4.9.1 on Debian with Python 2.7.9. More info can be found on [StackOverflow](https://stackoverflow.com/questions/44854699/why-does-the-cv2-imshow-does-not-render-without-cv2-waitkey).

* Remove unused import
parent 18967172
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
# Author: Yuxin Wu <ppwwyyxxc@gmail.com> # Author: Yuxin Wu <ppwwyyxxc@gmail.com>
import numpy as np import numpy as np
import time
import os import os
import cv2 import cv2
import threading import threading
...@@ -121,7 +120,7 @@ class AtariPlayer(gym.Env): ...@@ -121,7 +120,7 @@ class AtariPlayer(gym.Env):
if self.viz: if self.viz:
if isinstance(self.viz, float): if isinstance(self.viz, float):
cv2.imshow(self.windowname, ret) cv2.imshow(self.windowname, ret)
time.sleep(self.viz) cv2.waitKey(int(self.viz * 1000))
ret = ret.astype('float32') ret = ret.astype('float32')
# 0.299,0.587.0.114. same as rgb2y in torch/image # 0.299,0.587.0.114. same as rgb2y in torch/image
ret = cv2.cvtColor(ret, cv2.COLOR_RGB2GRAY) ret = cv2.cvtColor(ret, cv2.COLOR_RGB2GRAY)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment