diff options
author | Dan Zhu <zxdan@google.com> | 2019-06-19 21:34:22 -0700 |
---|---|---|
committer | Dan Zhu <zxdan@google.com> | 2019-06-24 14:46:28 -0700 |
commit | 729da3df8dc5cff807cb3278f419dd1601a673db (patch) | |
tree | 3163b21cd8422a0bf38aefc1e5afd50925c2bb5c /tools | |
parent | a709b694435c23d63689f2146b2764a5bc736dd0 (diff) | |
download | libvpx-729da3df8dc5cff807cb3278f419dd1601a673db.tar.gz libvpx-729da3df8dc5cff807cb3278f419dd1601a673db.tar.bz2 libvpx-729da3df8dc5cff807cb3278f419dd1601a673db.zip |
add output of frame info
Change-Id: I70d750be13d9a654d1f21d7809d8d44c491ae477
Diffstat (limited to 'tools')
3 files changed, 33 insertions, 2 deletions
diff --git a/tools/3D-Reconstruction/sketch_3D_reconstruction/MotionField.pde b/tools/3D-Reconstruction/sketch_3D_reconstruction/MotionField.pde index dbba327b7..883a8f831 100644 --- a/tools/3D-Reconstruction/sketch_3D_reconstruction/MotionField.pde +++ b/tools/3D-Reconstruction/sketch_3D_reconstruction/MotionField.pde @@ -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); + } } diff --git a/tools/3D-Reconstruction/sketch_3D_reconstruction/Scene.pde b/tools/3D-Reconstruction/sketch_3D_reconstruction/Scene.pde index 6189bc0d0..cf79ab714 100644 --- a/tools/3D-Reconstruction/sketch_3D_reconstruction/Scene.pde +++ b/tools/3D-Reconstruction/sketch_3D_reconstruction/Scene.pde @@ -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"); + } } diff --git a/tools/3D-Reconstruction/sketch_3D_reconstruction/sketch_3D_reconstruction.pde b/tools/3D-Reconstruction/sketch_3D_reconstruction/sketch_3D_reconstruction.pde index f9745c8e9..22a495432 100644 --- 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 @@ 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"); } |