shithub: libvpx

Download patch

ref: 4b0bfe8f7d5cc99e6b803a57c1092e593ee28986
parent: 0fc1b220a4bd7c22c4f9cc1b4aa9b42c4a0023c6
parent: 4c89f06b3cc20affaa95e89e16d8db6637f1c86b
author: Angie Chiang <[email protected]>
date: Wed Jul 31 15:55:29 EDT 2019

Merge "Change the child classes methods names to align with parent's"

--- a/tools/3D-Reconstruction/MotionEST/Exhaust.py
+++ b/tools/3D-Reconstruction/MotionEST/Exhaust.py
@@ -30,7 +30,7 @@
     """
 
   def search(self, cur_r, cur_c):
-    min_loss = self.dist(cur_r, cur_c, [0, 0], self.metric)
+    min_loss = self.block_dist(cur_r, cur_c, [0, 0], self.metric)
     cur_x = cur_c * self.blk_sz
     cur_y = cur_r * self.blk_sz
     ref_x = cur_x
@@ -39,7 +39,8 @@
     for y in xrange(cur_y - self.wnd_sz, cur_y + self.wnd_sz):
       for x in xrange(cur_x - self.wnd_sz, cur_x + self.wnd_sz):
         if 0 <= x < self.width - self.blk_sz and 0 <= y < self.height - self.blk_sz:
-          loss = self.dist(cur_r, cur_c, [y - cur_y, x - cur_x], self.metric)
+          loss = self.block_dist(cur_r, cur_c, [y - cur_y, x - cur_x],
+                                 self.metric)
           if loss < min_loss:
             min_loss = loss
             ref_x = x
@@ -46,7 +47,7 @@
             ref_y = y
     return ref_x, ref_y
 
-  def est(self):
+  def motion_field_estimation(self):
     for i in xrange(self.num_row):
       for j in xrange(self.num_col):
         ref_x, ref_y = self.search(i, j)
@@ -101,7 +102,7 @@
     """
 
   def search(self, cur_r, cur_c):
-    dist_loss = self.dist(cur_r, cur_c, [0, 0], self.metric)
+    dist_loss = self.block_dist(cur_r, cur_c, [0, 0], self.metric)
     nb_loss = self.neighborLoss(cur_r, cur_c, np.array([0, 0]))
     min_loss = dist_loss + self.beta * nb_loss
     cur_x = cur_c * self.blk_sz
@@ -113,8 +114,8 @@
     for y in xrange(cur_y - self.wnd_sz, cur_y + self.wnd_sz):
       for x in xrange(cur_x - self.wnd_sz, cur_x + self.wnd_sz):
         if 0 <= x < self.width - self.blk_sz and 0 <= y < self.height - self.blk_sz:
-          dist_loss = self.dist(cur_r, cur_c, [y - cur_y, x - cur_x],
-                                self.metric)
+          dist_loss = self.block_dist(cur_r, cur_c, [y - cur_y, x - cur_x],
+                                      self.metric)
           nb_loss = self.neighborLoss(cur_r, cur_c, [y - cur_y, x - cur_x])
           loss = dist_loss + self.beta * nb_loss
           if loss < min_loss:
@@ -123,7 +124,7 @@
             ref_y = y
     return ref_x, ref_y
 
-  def est(self):
+  def motion_field_estimation(self):
     for i in xrange(self.num_row):
       for j in xrange(self.num_col):
         ref_x, ref_y = self.search(i, j)
--- a/tools/3D-Reconstruction/MotionEST/HornSchunck.py
+++ b/tools/3D-Reconstruction/MotionEST/HornSchunck.py
@@ -120,7 +120,7 @@
             avg[i, j] += self.mf[i + r, j + c] / 12.0
     return avg
 
-  def est(self):
+  def motion_field_estimation(self):
     count = 0
     """
         u_{n+1} = ~u_n - Ix(Ix.~u_n+Iy.~v+It)/(IxIx+IyIy+alpha^2)
@@ -136,7 +136,7 @@
       count += 1
     self.mf *= self.blk_sz
 
-  def est_mat(self):
+  def motion_field_estimation_mat(self):
     row_idx = []
     col_idx = []
     data = []
@@ -145,8 +145,7 @@
     b = np.zeros((N, 1))
     for i in xrange(self.num_row):
       for j in xrange(self.num_col):
-        """(IxIx+alpha^2)u+IxIy.v-alpha^2~u IxIy.u+(IyIy+alpha^2)v-alpha^2~v
-        """
+        """(IxIx+alpha^2)u+IxIy.v-alpha^2~u IxIy.u+(IyIy+alpha^2)v-alpha^2~v"""
         u_idx = i * 2 * self.num_col + 2 * j
         v_idx = u_idx + 1
         b[u_idx, 0] = -self.Ix[i, j] * self.It[i, j]
--- a/tools/3D-Reconstruction/MotionEST/Util.py
+++ b/tools/3D-Reconstruction/MotionEST/Util.py
@@ -32,6 +32,8 @@
   for i in xrange(num_row):
     for j in xrange(num_col):
       center = (j * blk_sz + 0.5 * blk_sz, i * blk_sz + 0.5 * blk_sz)
+      """mf[i,j][0] is the row shift and mf[i,j][1] is the column shift In PIL coordinates, head[0] is x (column shift) and head[1] is y (row shift).
+      """
       head = (center[0] + mf[i, j][1], center[1] + mf[i, j][0])
       draw.line([center, head], fill=(255, 0, 0, 255))
   return Image.alpha_composite(img_rgba, mf_layer)