Check this code out, might help... takes a picture when IR sensor detect someone and then sleeps...
In my case I use the RCWL-0516 (Microwave Radar Sensor) to detect anyone in the vicinity and as the output go hight on detection, I change the wake up to positive trigger in the code..
Edit this line for wake-up on positive or negative going trigger, 0 = negative, 1 = positive
esp_sleep_enable_ext0_wakeup(GPIO_NUM_13, 1);
Even if this is not exactly what you want, check the code, it may prove useful...
Mike