Hungary has declared a state of emergency in two border counties, and imposed tough new checks at its frontiers.