History

add output of frame info

Dan Zhu committed 7 years ago

Commit 729da3d1 parent a709b693 files · +33 −2Browse files

Unified · Split

3 files
  1. tools/3D-Reconstruction/sketch_3D_reconstruction/MotionField.pde +15 −0
  2. tools/3D-Reconstruction/sketch_3D_reconstruction/Scene.pde +9 −0
  3. tools/3D-Reconstruction/sketch_3D_reconstruction/sketch_3D_reconstruction.pde +9 −2
tools/3D-Reconstruction/sketch_3D_reconstruction/MotionField.pde+15−0
@@ -76,4 +76,19 @@ class MotionField { · 75 unmodified lines
7676 line(ox, oy, ox + mv.x, oy + mv.y);
7777 }
7878 }
79+
80+ void save(String path) {
81+ int r_num = height / block_size;
82+ int c_num = width / block_size;
83+ String[] mvs = new String[r_num];
84+ for (int i = 0; i < r_num; i++) {
85+ mvs[i] = "";
86+ for (int j = 0; j < c_num; j++) {
87+ PVector mv = motion_field.get(i * c_num + j);
88+ mvs[i] += str(mv.x) + "," + str(mv.y);
89+ if (j != c_num - 1) mvs[i] += ";";
90+ }
91+ }
92+ saveStrings(path, mvs);
93+ }
7994 }
tools/3D-Reconstruction/sketch_3D_reconstruction/Scene.pde+9−0
@@ -5,6 +5,7 @@ class Scene { · 4 unmodified lines
55 MotionField motion_field;
66 Camera last_cam;
77 Camera current_cam;
8+ int frame_count;
89
910 Scene(Camera camera, PointCloud point_cloud, MotionField motion_field) {
1011 this.point_cloud = point_cloud;
@@ -26,12 +27,14 @@ class Scene { · 15 unmodified lines
2627 bvh = new BVH(mesh);
2728 last_cam = camera.copy();
2829 current_cam = camera;
30+ frame_count = 0;
2931 }
3032
3133 void run() {
3234 last_cam = current_cam.copy();
3335 current_cam.run();
3436 motion_field.update(last_cam, current_cam, point_cloud, bvh);
37+ frame_count += 1;
3538 }
3639
3740 void render(boolean show_motion_field) {
@@ -47,4 +50,10 @@ class Scene { · 9 unmodified lines
4750 motion_field.render();
4851 }
4952 }
53+
54+ void save(String path) { saveFrame(path + "_" + str(frame_count) + ".png"); }
55+
56+ void saveMotionField(String path) {
57+ motion_field.save(path + "_" + str(frame_count) + ".txt");
58+ }
5059 }
tools/3D-Reconstruction/sketch_3D_reconstruction/sketch_3D_reconstruction.pde+9−2
@@ -10,7 +10,7 @@ void setup() { · 9 unmodified lines
1010 // default settings
1111 int frame_no = 0; // frame number
1212 float fov = PI / 3; // field of view
13− int block_size = 32; // block size
13+ int block_size = 8; // block size
1414 float normalizer = 5000.0f; // normalizer
1515 // initialize
1616 PointCloud point_cloud = new PointCloud();
@@ -62,6 +62,13 @@ void draw() { · 45 unmodified lines
6262 inter = true;
6363 }
6464 scene.render(
65− true); // true: turn on motion field; false: turn off motion field
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);
6670 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");
6774 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t