In pretty much every case, automatic braking is part of a suite of safety system technology that works together to save your sorry butt. The system in a Subaru is called EyeSight; in a Volvo, it's called City Safety. Other manufacturers, including Cadillac and Mercedes-Benz, have something similar.
"The system works very simply from an engineering perspective," said Adam Kopstein, a safety and compliance manager at Volvo. "Making the car stop is easy; we've got the sensors and ABS. The trick is making sure it only does it when it's supposed to." Kopstein is a very funny guy, because after calling this an easy and simple system, he explained in detail how that trick is accomplished.
Every manufacturer uses a different setup, so we'll use Subaru and Volvo's systems as examples of what's out there.
Subaru's EyeSight, not surprisingly, uses two black and white cameras that work like your eyes to triangulate the speed and distance of the vehicle in front of you. They're mounted at the top of the windshield, and they scan every 0.1 seconds, looking for contrast with the background and vertical surfaces. The software is programmed to recognize several types of images, like the rear ends of vehicles, motorcycles, bicycles and pedestrians.
Volvo uses lidar (which is not related to the lion-tiger mashup we all know as a liger) in its City Safety system. Lidar is laser radar, and it sends out a signal that pings off objects in front of it to determine distance and speed. Since lidar works best at short range, Volvo also has a camera mounted in the windshield and radar in the bumper that work together at high speeds as part of its collision warning system with full braking capability. The radar can see several hundred yards in front of the car, but it can't tell what it's seeing. The camera picks up on what the radar is seeing and can identify the object as a problem or something to ignore.
So far, this is just how your car knows that there's a Humvee in front of you, and that the Humvee has slammed on its brakes. While your car's computer does some panicky calculations, let's move to the next page.