BEIJING — The toilet paper thieves of the Temple of Heaven Park were an elusive bunch.

They looked like most park visitors, practicing tai chi, dancing in the courtyards and stopping to take in the scent of ancient cypress and juniper trees. But hidden in their oversize shopping bags and backpacks was a secret: sheet upon sheet of crumpled toilet paper, plucked surreptitiously from public restrooms.

Now the authorities in Beijing are fighting back, going so far as to install high-tech toilet paper dispensers equipped with facial recognition software in several restrooms.

Before entering restrooms in the park, visitors must now stare into a computer mounted on the wall for three seconds before a machine dispenses a sheet of toilet paper, precisely two feet in length. If visitors require more, they are out of luck. The machine will not dispense a second roll to the same person for nine minutes.

At the Temple of Heaven Park, one of Beijing’s busiest tourist sites, many people said on Monday they were pleased by the new machines.