Open
Description
I was trying to train using the Virtual Fighter 2 environment on Saturn, and I came across a problem: the observations are appearing cut off. The image frame is cut off. I believe the resolution of the original game would be around 640x480, but the shape is showing in the observation as 320x240.
I used the code below to do the preliminary work of doing the training:
import retro
from stable_baselines3.common.atari_wrappers import ClipRewardEnv, WarpFrame
from gymnasium.wrappers import RecordVideo
import cv2
import numpy as np
import matplotlib.pyplot as plt
def preprocess_observation(obs):
resized = cv2.resize(obs, (640, 480))
padded = cv2.copyMakeBorder(resized, 20, 20, 10, 10, cv2.BORDER_CONSTANT, value=[0, 0, 0])
return padded
env = retro.make(
game="VirtuaFighter2-Saturn",
render_mode="human",
inttype=retro.data.Integrations.ALL,
)
# env = display.GameDisplayEnv(env)
env = WarpFrame(env)
obs = env.reset()
while True:
env.render()
action = env.action_space.sample()
env.render()
observation, reward, terminated, truncated, info = env.step(action)
processed = preprocess_observation(observation)
cv2.imshow("Processed Frame", processed)
cv2.waitKey(1)
if terminated or truncated:
break
env.close()
cv2.destroyAllWindows()
Images of the problem: