I think what ericvdb said with the IR sensors is probably close to the best solution. If you figure out a way to count people at each doorway you could do a sudo presence detection.
So, if you count people as they enter, and at each threshold remove a person from the room they are leaving and add to the one they are going to you should have something that is rather accurate.
This could have issues if you carry someone from one room to another, but you could add pir to rooms to correct exceptions. Something along the lines of, you carry someone into the living room, it counts one person there, you go to kitchen, it reduces to 0 and turns off lights, but you have an exception that if there is motion and zero people it changes to one person in the room. Would just have to be sure your hvac does not set of the pir.