Esempio n. 1
0
def preprocess(img):
    img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
    img = Image.fromarray(img)
    img = Scale(120)(img)
    img = ToTensor()(img)
    img = img.view(1, 3, 120, 160)
    img = img.cuda()
    return img
Esempio n. 2
0
def preprocess(state):
    img = state.screen_buffer
    depth = state.depth_buffer
    img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
    img = Image.fromarray(img)
    img = Scale(120)(img)
    img = ToTensor()(img)
    img = img.view(1, 3, 120, 160)
    depth = Image.fromarray(depth)
    depth = Scale(120)(depth)
    depth = ToTensor()(depth)
    depth = depth.view(1, 1, 120, 160)
    img = torch.cat((img, depth), 1)
    img = img.cuda()
    return img