Tesla claims to have software in every car that does what the OP is asking for. In the OPs scenario, he claims to have been 'about to hit the accelerator', not that he did hit the accelerator. Perhaps, had he actually hit the accelerator, he would have found out if Tesla's system works. Of course, nobody wants to find out for themselves!
Last year, Tesla stated that the software in place was preventing about 40 accidents of this sort every day. As I recall, they used a specific example where someone was standing behind a car when the driver mistakenly thought he was in Drive, but was actually in reverse. When the driver attempted to accelerate, the car disabled the accelerator and applied the brakes, thus preventing striking the person.