-
Notifications
You must be signed in to change notification settings - Fork 19
/
vrplayer.py
executable file
·40 lines (34 loc) · 1.42 KB
/
vrplayer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import cv2
import numpy as np
import sys
from math import radians, cos, sin, asin, sqrt, log
import math
from scipy.misc import imsave
import subprocess
from read_yuv import yuv_import
import PIL.Image as Image
from numpy import *
import os
def get_view(input_width,input_height,view_fov_x,view_fov_y,view_center_lat,view_center_lon,output_width,output_height,cur_frame,file_,is_render=False,temp_dir=""):
temp_1=temp_dir+"/1.yuv"
import config
devnull = open(os.devnull, 'w')
subprocess.call(["./remap", "-i", "rect", "-o", "view", "-m", str(input_height), "-b", str(input_width), "-w", str(output_width), "-h", str(output_height), "-x", str(view_fov_x), "-y", str(view_fov_y), "-p", str(view_center_lat), "-l", str(view_center_lon), "-z", "1", "-s", str(cur_frame), file_, temp_1], stdout=devnull, stderr=devnull)
frame=yuv_import(temp_1,(output_height,output_width),1,0)
subprocess.call(["rm", temp_1])
if(is_render==True):
print("this is debugging, not trainning")
YY=frame[0]
im=Image.frombytes('L',(output_height,output_width),YY.tostring())
im.show()
frame = np.zeros((42,42,1))
frame = np.reshape(frame, [42, 42, 1])
else:
frame = np.array(frame)
frame = frame.astype(np.float32)
frame *= (1.0 / 255.0)
# print(frame)
# print(frame.shape)
# print(s)
frame = np.reshape(frame, [42, 42, 1])
return frame