shithub: libvpx

Download patch

ref: 729da3df8dc5cff807cb3278f419dd1601a673db
parent: a709b694435c23d63689f2146b2764a5bc736dd0
author: Dan Zhu <zxdan@google.com>
date: Wed Jun 19 17:34:22 EDT 2019

add output of frame info

Change-Id: I70d750be13d9a654d1f21d7809d8d44c491ae477

--- a/tools/3D-Reconstruction/sketch_3D_reconstruction/MotionField.pde
+++ b/tools/3D-Reconstruction/sketch_3D_reconstruction/MotionField.pde
@@ -76,4 +76,19 @@
         line(ox, oy, ox + mv.x, oy + mv.y);
       }
   }
+
+  void save(String path) {
+    int r_num = height / block_size;
+    int c_num = width / block_size;
+    String[] mvs = new String[r_num];
+    for (int i = 0; i < r_num; i++) {
+      mvs[i] = "";
+      for (int j = 0; j < c_num; j++) {
+        PVector mv = motion_field.get(i * c_num + j);
+        mvs[i] += str(mv.x) + "," + str(mv.y);
+        if (j != c_num - 1) mvs[i] += ";";
+      }
+    }
+    saveStrings(path, mvs);
+  }
 }
--- a/tools/3D-Reconstruction/sketch_3D_reconstruction/Scene.pde
+++ b/tools/3D-Reconstruction/sketch_3D_reconstruction/Scene.pde
@@ -5,6 +5,7 @@
   MotionField motion_field;
   Camera last_cam;
   Camera current_cam;
+  int frame_count;
 
   Scene(Camera camera, PointCloud point_cloud, MotionField motion_field) {
     this.point_cloud = point_cloud;
@@ -26,6 +27,7 @@
     bvh = new BVH(mesh);
     last_cam = camera.copy();
     current_cam = camera;
+    frame_count = 0;
   }
 
   void run() {
@@ -32,6 +34,7 @@
     last_cam = current_cam.copy();
     current_cam.run();
     motion_field.update(last_cam, current_cam, point_cloud, bvh);
+    frame_count += 1;
   }
 
   void render(boolean show_motion_field) {
@@ -46,5 +49,11 @@
       current_cam.close();
       motion_field.render();
     }
+  }
+
+  void save(String path) { saveFrame(path + "_" + str(frame_count) + ".png"); }
+
+  void saveMotionField(String path) {
+    motion_field.save(path + "_" + str(frame_count) + ".txt");
   }
 }
--- a/tools/3D-Reconstruction/sketch_3D_reconstruction/sketch_3D_reconstruction.pde
+++ b/tools/3D-Reconstruction/sketch_3D_reconstruction/sketch_3D_reconstruction.pde
@@ -10,7 +10,7 @@
   // default settings
   int frame_no = 0;            // frame number
   float fov = PI / 3;          // field of view
-  int block_size = 32;         // block size
+  int block_size = 8;          // block size
   float normalizer = 5000.0f;  // normalizer
   // initialize
   PointCloud point_cloud = new PointCloud();
@@ -62,6 +62,13 @@
     inter = true;
   }
   scene.render(
-      true);  // true: turn on motion field; false: turn off motion field
+      false);  // true: turn on motion field; false: turn off motion field
+  // save frame with no motion field
+  scene.save("../data/frame/raw");
+  background(0);
+  scene.render(true);
   showGrids(scene.motion_field.block_size);
+  // save frame with motion field
+  scene.save("../data/frame/raw_mv");
+  scene.saveMotionField("../data/frame/mv");
 }