Motion detection in surroundings from a moving robot car

Hello, I’m currently working on a project that’s basically a surveillance car. For the surveillance part I’m using the esp32 cam. I wanted the car to detect motion while it’s moving and when motion is detected (or a human) the camera captures a photo. I was using PIR sensors but when the sensor itself moves it gives false positives so it’s not ideal for this project. What can I do to implement this feature in a moving car?

It's very difficult, I think. When the car is moving, everything else seems to be moving also.

The only way I can think of is to somehow measure the speed of other objects relative to the car, and then, knowing the speed of the car, compensate for that to calculate the absolute speed of the object.

Perhaps a laser time-of-flight sensor like VL53L0X could be used to measure the distance to an object in front of or behind the car. Multiple measurements taken a few moments apart could be used to estimate the speed of the object relative to the car.

Either a TOF sensor, as @PaulRB already mentioned, or a 'radar' type like the RCWL-0516, but in analogue mode, or maybe both digital and analogue. To determine object movement, you will need to subtract the movement of your vehicle. It can probably be done, but it will be very difficult. It is simpler to stop the vehicle and take a sample; if no movement, move on; if movement, process it.

Read about mmw sensors. mmWave Radar Sensor Arduino-Human Presence Detection Wiki - DFRobot

Long before even thinking about doing this with an Arduino, can you do the math to determine the angle between to moving objects? Once you can do this on paper, you can figure out how to do it in code.