calculating diff in successive frames