]> granicus.if.org Git - libvpx/commitdiff
Change the child classes methods names to align with parent's
authorDan Zhu <zxdan@google.com>
Tue, 23 Jul 2019 17:03:15 +0000 (10:03 -0700)
committerDan Zhu <zxdan@google.com>
Tue, 23 Jul 2019 18:14:18 +0000 (11:14 -0700)
Add comments to explain the coordinate system

Change-Id: Ib87ae479e08b4e3c3e7d9a3d1b4ab30718b42cfd

tools/3D-Reconstruction/MotionEST/Exhaust.py
tools/3D-Reconstruction/MotionEST/HornSchunck.py
tools/3D-Reconstruction/MotionEST/Util.py

index 3c0346814bc87d9125545fb937ef04e321ece731..83ca157d4ada9d06f04868aa63c91717f3169f55 100644 (file)
@@ -30,7 +30,7 @@ class Exhaust(MotionEST):
     """
 
   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,14 +39,15 @@ class Exhaust(MotionEST):
     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
             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 @@ class ExhaustNeighbor(MotionEST):
     """
 
   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 @@ class ExhaustNeighbor(MotionEST):
     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 @@ class ExhaustNeighbor(MotionEST):
             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)
index 0bf431cf6be2c4269f97477e65b29d10ed101fc2..38fcae1e71bdee8688e31bc4b91946fb8eb09602 100644 (file)
@@ -120,7 +120,7 @@ class HornSchunck(MotionEST):
             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 @@ class HornSchunck(MotionEST):
       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 @@ class HornSchunck(MotionEST):
     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]
index f1a0cd42fe12ac0398f16cb50f8c98028ba11069..d52e8a5c40faf3712e81da9882055e3e8f61cdea 100644 (file)
@@ -32,6 +32,8 @@ def drawMF(img, blk_sz, mf):
   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)