]> granicus.if.org Git - libvpx/commitdiff
add output of frame info
authorDan Zhu <zxdan@google.com>
Thu, 20 Jun 2019 04:34:22 +0000 (21:34 -0700)
committerDan Zhu <zxdan@google.com>
Mon, 24 Jun 2019 21:46:28 +0000 (14:46 -0700)
Change-Id: I70d750be13d9a654d1f21d7809d8d44c491ae477

tools/3D-Reconstruction/sketch_3D_reconstruction/MotionField.pde
tools/3D-Reconstruction/sketch_3D_reconstruction/Scene.pde
tools/3D-Reconstruction/sketch_3D_reconstruction/sketch_3D_reconstruction.pde

index dbba327b77e5780e573028d48a1cd79e16bb3d4e..883a8f83103a21b653e2d57be55da90d6709bc0d 100644 (file)
@@ -76,4 +76,19 @@ class MotionField {
         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);
+  }
 }
index 6189bc0d019754ee4a87bc3b8b4668614d00e35f..cf79ab714189c0b667a8e6f7c0233f3ab3584ae0 100644 (file)
@@ -5,6 +5,7 @@ class Scene {
   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,12 +27,14 @@ class Scene {
     bvh = new BVH(mesh);
     last_cam = camera.copy();
     current_cam = camera;
+    frame_count = 0;
   }
 
   void run() {
     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) {
@@ -47,4 +50,10 @@ class Scene {
       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");
+  }
 }
index f9745c8e916fef9d775710e44de6eadb665332ca..22a495432df0b687e8b166b016522374ac2c9cec 100644 (file)
@@ -10,7 +10,7 @@ void setup() {
   // 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 @@ void draw() {
     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");
 }