As hundreds of celebrities poured into St. George’s Chapel for the lavish wedding of Prince Harry and Meghan Markle last weekend, Sky News’s webcast performed an incredible feat. As guests moved across the screen, they were automatically identified, their names appearing next to their faces as subtitles. The seamless display wasn’t the result of some nimble-fingered typist sitting in a control room, however, but the product of Amazon’s Rekognition technology, which uses artificial intelligence to detect human faces and compare their unique signatures to private or public databases. The same facial recognition software used at Harry and Meghan’s nuptials, of course, can also be deployed for more sinister purposes—including, as the American Civil Liberties Union highlighted on Tuesday, the mass surveillance of U.S. citizens by law enforcement.

Like other controversial Silicon Valley technologies, Rekognition wasn’t invented with its most Orwellian use-case in mind. According to Amazon’s marketing materials, Rekognition promises to “perform real-time recognition of persons of interest from camera livestreams against your private database of face metadata.” When synched with a database of videos or pictures, its uses image-recognition algorithms to identify people and objects. The software itself is not new—Amazon introduced it in November 2016 as part of its Amazon Web Services cloud, and corporate clients—companies like Pinterest, organizations like C-SPAN—rely on it for analytics and object-recognition services.

What is new is how law-enforcement agencies are deploying Rekognition: as a tool to track, identify, and analyze people in real time. It’s a remarkably efficient system, able to recognize as many as 100 people in a single image, and to compare that information to databases containing tens of millions of faces. According to documents obtained by the A.C.L.U., Amazon has sold Rekognition to police departments in two states, as well as to Motorola Solutions and BodyWorn, which supply police body cameras, and Data Fusion Systems, a data-analytics company “[providing] actionable intelligence to authorities.” At Amazon’s A.W.S. Summit in Seoul last month, Ranju Das, the director of Rekognition, said the Orlando, Florida, police department is a “launch partner” for the software. “It’s a smart city, they have cameras all over the city,” Das said. “The authorized cameras are then streaming the data to [Amazon]. We analyze the video in real time, search against the collection of faces that they have.”

To Amazon’s credit, the tech is both cheap and effective. Oregon’s Washington County, for instance, reportedly pays just $6 to $12 a month for access to the software, allowing police officers to compare mug-shot pictures with real-time footage. According to The New York Times, the partnership has been largely successful:

Chris Adzima, a systems analyst in the office, told Amazon officials that he fed about 300,000 images from the county’s mug-shot database into Amazon’s system.