There are two parts that need to be invented which do exist today but aren't integrated into a rifle and would pose serious ethical problems to do so.
The first component would be an electronic fire control system. Basically a "fly-by-wire" all digital trigger group that isn't mechanically linked to the trigger at all. Instead, the trigger is an electrical switch. Pulling the trigger would close that switch and provide one of two signals needed to cycle the firing mechanism. For simplicity's sake, let's say the output signal is gated by a diode since they need two input signals to send an output. The output will go to a solenoid or DC coil that pulls the mechanism into motion.
//-- as an aside,
I don't like this idea because you're adding complexity and increasing the risk of malfunction. Stuck firing coil contacts? Now you've either accidentally created a fully automatic rifle, or it won't fire at all. Damage to the diode or wiring? Now it won't fire, even with a full magazine and full battery. It would have to be a very well engineered, maybe even with redundant control channels and a polling system that averages their inputs to determine weather it's really being asked to fire or not. That means occasionally it will have error codes that need debugging, and I'm guessing based on the theme here that isn't something the average Joe is going to be allowed to do on their own but only at a licensed service center, which means $$$. This needs to be a very rugged component that can take just as much punishment as the rifle can, plus the vibration and heat from the firing sequence itself, plus hazards like EMI shielding.
Lastly, someone could just short out the diode and directly link the trigger to the solenoid, bypassing the camera's input entirely. You can try to make that hard, but it comes down to two wires and almost anyone could do that.
The second component would be a smart-camera. This part is more complicated, because said camera not only has to recognize a human body (not hard, there are open source algorithms right now that can do that), but it also has to know which bodies this rifle has fired at and judge if each shooting was justified. That part is in my opinion, virtually impossible to automate. Situations requiring lethal use of force run a wide gamut. If a battered spouse pulls a gun on her abusive husband and he's unarmed, the gun decides a shooting isn't justified then the software just disarmed her. But assuming that algorithm worked perfectly, if the software said OK then it would send the second signal to bias the diode and let out the output signal to close the solenoid and cycle the firing mechanism.
And that gets worse. Since whoever designed that software is really the one deciding if you're armed or not, why stop there? There's going to be a temptation in today's authoritarian environment to pad extra software like preventing the gun from shooting at cops or soldiers. Now the weapon is useless to rebels. It's really not your gun at all anymore. I wouldn't buy a system like that willingly, for one thing it would probably cost more than the rifle, for another it would probably be illegal to tamper with it. It would only be a matter of time before you realize you're not the one in control of the trigger.