Zed2i - detect backwards movement


I’m working with a Zed2i.
We will put it in a car, heading front. We detect objects, that we place on a map.
The car’s heading (and so the camera’s) is given by a GPS.
The problem is, when we drive backwards, the heading is going backwards too and we project objects behind the car.

How can I detect that the car is running backwards ?
I tried using the IMU. I recorded a SVO, walking forwards then backwards.

        sensors_data = sl.SensorsData()
        accelerometer_csv = open('/home/georges/Workspace/test_accelerometre/accelerometer.csv', 'w+')
        while zed.grab(rt_param) == sl.ERROR_CODE.SUCCESS and svo_position < end_frame:
            svo_position = zed.get_svo_position()
            zed.get_sensors_data(sensors_data, sl.TIME_REFERENCE.IMAGE)  # Retrieve only frame synchronized data
            # Extract IMU data
            imu_data = sensors_data.get_imu_data()
            # Retrieve linear acceleration and angular velocity
            linear_acceleration = imu_data.get_linear_acceleration()
            angular_velocity = imu_data.get_angular_velocity()

But I cannot read the graph, telling on which part I was walking forwards (frames 40 to 100), and which part I was walking backwards (frames 120 to 190).

Note that I tried with sl.TIME_REFERENCE.LAST and sl.TIME_REFERENCE.CURRENT too.

Hello and thank you for contacting us,

Rather than using the IMU, you should use our Positional tracking. Check our positional tracking on github https://github.com/stereolabs/zed-examples/tree/master/positional%20tracking
Take care of the reference. If you use WORLD, you get an absolute position. If you use CAMERA, you get a position relative to the previous frame.

Best regards,

Antoine Lassagne
Senior Developer - ZED SDK
Stereolabs Support

Thanks a lot, it seems to work.