#!/usr/bin/python

import caffe
import os
import sys
import argparse
from pymill import Toolbox as tb
import numpy as np

parser = argparse.ArgumentParser()
parser.add_argument('diff1', help='first file (.float3)')
parser.add_argument('diff2', help='second file (.float3)')

args = parser.parse_args()
#tb.readDisparity(..)
diff1 = tb.readDisparity(args.diff1)  \
        if args.diff1.endswith('png') \
        else tb.readFloat(args.diff1).squeeze()
diff2 = tb.readDisparity(args.diff2)  \
        if args.diff2.endswith('png') \
        else tb.readFloat(args.diff2).squeeze()
#diff2 = tb.readFloat(args.diff2).squeeze()

## Exclude NaN values from evaluation
nanmask = ~(np.isnan(diff1-diff2))

print np.average(np.abs(diff1[nanmask]-diff2[nanmask]))

