1/*The dataset is from 2 *Computer Vision Group 3 *TUM Department of Informatics Technical 4 *University of Munich 5 *https://vision.in.tum.de/data/datasets/rgbd-dataset/download#freiburg1_xyz 6 */ 7Scene scene; 8void setup() { 9 size(640, 480, P3D); 10 // default settings 11 int frame_no = 0; // frame number 12 float fov = PI / 3; // field of view 13 int block_size = 8; // block size 14 float normalizer = 5000.0f; // normalizer 15 // initialize 16 PointCloud point_cloud = new PointCloud(); 17 // synchronized rgb, depth and ground truth 18 String head = "../data/"; 19 String[] rgb_depth_gt = loadStrings(head + "rgb_depth_groundtruth.txt"); 20 // read in rgb and depth image file paths as well as corresponding camera 21 // posiiton and quaternion 22 String[] info = split(rgb_depth_gt[frame_no], ' '); 23 String rgb_path = head + info[1]; 24 String depth_path = head + info[3]; 25 float tx = float(info[7]), ty = float(info[8]), 26 tz = float(info[9]); // real camera position 27 float qx = float(info[10]), qy = float(info[11]), qz = float(info[12]), 28 qw = float(info[13]); // quaternion 29 30 // build transformer 31 Transform trans = 32 new Transform(tx, ty, tz, qx, qy, qz, qw, fov, width, height, normalizer); 33 PImage rgb = loadImage(rgb_path); 34 PImage depth = loadImage(depth_path); 35 // generate point cloud 36 point_cloud.generate(rgb, depth, trans); 37 // initialize camera 38 Camera camera = new Camera(fov, new PVector(0, 0, 0), new PVector(0, 0, 1), 39 new PVector(0, 1, 0)); 40 // initialize motion field 41 MotionField motion_field = new MotionField(block_size); 42 // initialize scene 43 scene = new Scene(camera, point_cloud, motion_field); 44} 45boolean inter = false; 46void draw() { 47 background(0); 48 // run camera dragged mouse to rotate camera 49 // w: go forward 50 // s: go backward 51 // a: go left 52 // d: go right 53 // up arrow: go up 54 // down arrow: go down 55 //+ increase move speed 56 //- decrease move speed 57 // r: rotate the camera 58 // b: reset to initial position 59 scene.run(); // true: make interpolation; false: do not make 60 // interpolation 61 if (keyPressed && key == 'o') { 62 inter = true; 63 } 64 scene.render( 65 false); // true: turn on motion field; false: turn off motion field 66 // save frame with no motion field 67 scene.save("../data/frame/raw"); 68 background(0); 69 scene.render(true); 70 showGrids(scene.motion_field.block_size); 71 // save frame with motion field 72 scene.save("../data/frame/raw_mv"); 73 scene.saveMotionField("../data/frame/mv"); 74} 75