【发布时间】:2017-10-10 18:03:02
【问题描述】:
我对 python 有点陌生,我正在使用 OpenAI 的 miniWOB。我想用 cv2 打印出我对代理的观察。但真的无所谓。我的问题是我不知道我从健身房收到的用于“观察”的确切数据类型。但我希望它是一个简单的 3Dimensional numpy 数组。这种格式我可以使用 cv2 打印出来。那么任何人都可以帮我将我的
import cv2
import random
import gym
import universe
import go_vncdriver
import numpy as np
def main():
env = gym.make('wob.mini.ClickTest-v0')
env.configure(remotes=1) # create one flashgames Docker container
observation = env.reset()
while True:
env.render()
x = 110
y = 270
action_n = [universe.spaces.PointerEvent(x, y, 1), universe.spaces.PointerEvent(x, y, 0),
universe.spaces.PointerEvent(x, y, 1)]
action_n = [action_n for ob in observation]
observation, reward_n, done_n, info = env.step(action_n)
observation = np.asarray(observation) #this one converts to nd array but then I got the mat data type = 17 error
if (observation != None):
print(type(observation))
cv2.imshow('pong voor net', observation)
cv2.waitKey(0)
cv2.destroyAllWindows()
main()
我收到这个:
[{'vision': array([[[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
...,
[0, 0, 0],
[0, 0, 0],
[0, 0, 0]],
[[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
...,
[0, 0, 0],
[0, 0, 0],
[0, 0, 0]],
[[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
...,
[0, 0, 0],
[0, 0, 0],
[0, 0, 0]],
...,
[[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
...,
[0, 0, 0],
[0, 0, 0],
[0, 0, 0]],
[[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
...,
[0, 0, 0],
[0, 0, 0],
[0, 0, 0]],
[[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
...,
[0, 0, 0],
[0, 0, 0],
[0, 0, 0]]], dtype=uint8), 'text': []}]
我想把它转成这种类型:
[[[144 72 17]
[144 72 17]
[144 72 17]
...,
[144 72 17]
[144 72 17]
[144 72 17]]
[[144 72 17]
[144 72 17]
[144 72 17]
...,
[144 72 17]
[144 72 17]
[144 72 17]]
[[144 72 17]
[144 72 17]
[144 72 17]
...,
[144 72 17]
[144 72 17]
[144 72 17]]
【问题讨论】:
标签: python opencv numpy openai-gym