<commit_before><commit_msg>Add Ground Truth Estimator<commit_after>#!/usr/bin/env python
# coding: utf-8
import numpy as np
import numpy.linalg as LA
from MotionEST import MotionEST
"""Ground Truth:

    Load in ground truth motion field and mask
"""


class GroundTruth(MotionEST):
  """
    constructor:
        cur_f: current frame
        ref_f: reference frame
        blk_sz: block size
        gt_path: ground truth motion field file path
    """

  def __init__(self, cur_f, ref_f, blk_sz, gt_path):
    self.name = 'ground truth'
    super(GroundTruth, self).__init__(cur_f, ref_f, blk_sz)
    self.mask = np.zeros((self.num_row, self.num_col), dtype=np.bool)
    with open(gt_path) as gt_file:
      lines = gt_file.readlines()
      for i in xrange(len(lines)):
        info = lines[i].split(';')
        for j in xrange(len(info)):
          x, y = info[j].split(',')
          #-,- stands for nothing
          if x == '-' or y == '-':
            self.mask[i, -j - 1] = True
            continue
          #the order of original file is flipped on the x axis
          self.mf[i, -j - 1] = np.array([float(y), -float(x)], dtype=np.int)

{'fraction_non_alphanumeric': 0.12869565217391304, 'fraction_numerical': 0.0026086956521739132, 'mean_word_length': 2.487878787878788, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2644490', 'n_tokens_mistral': 399, 'n_tokens_neox': 385, 'n_words': 113}