Generating .area file from previously recorded SVO

I have a bunch of saved SVO files and I’m trying to generate .area files for them.

I load the file with PositionalTrackingParameters and am able to get the orientations, translations, and rotations, but when I call save_area_map or disable_positional_tracking with a file name followed by get_area_export_state. I get the error SPATIAL MEMORY DISABLED. I didn’t enable_positional_tracking when I recorded the files, is that the cause of the error? I don’t want to incur the extra computational cost of positional tracking when the file is originally recorded.

sdk version is 3.7.2

Hi @stevenson32
the SVO recording mode does not affect this behavior.
Can you post a snippet code with the parameters used to enable the positional tracking module and to stop it?

Okay good to know.

Here’s a code example, it’s nothing special. Just loading and SVO and looping over it, then following the directions for an area file export.

init_params = sl.InitParameters(
coordinate_units=sl.UNIT.METER,
coordinate_system=sl.COORDINATE_SYSTEM.RIGHT_HANDED_Y_UP,
sdk_verbose=True
)
init_params.set_from_svo_file(<filename.svo>)
init_params.depth_mode = sl.DEPTH_MODE.ULTRA

zed = sl.Camera()
status = zed.open(init_params)
if status != sl.ERROR_CODE.SUCCESS:
print(repr(status))
exit()
runtime = sl.RuntimeParameters(
confidence_threshold=100
)
camera_pose = sl.Pose()
zed_translation = sl.Translation()
zed_orientation = sl.Orientation()
tracking_params = sl.PositionalTrackingParameters()

zed.enable_positional_tracking(tracking_params)
offset_l_to_c = zed.get_camera_information().calibration_parameters.T[0]
tx_translation = sl.Translation()
tx_translation.init_vector(offset_l_to_c,0,0)
point_cloud_mat = sl.Mat()

   #processing loop
    while True:
        svo_position = zed.get_svo_position()

        if svo_position >= (zed.get_svo_number_of_frames() - 5):
 
            break # End of SVO

        if(zed.grab(runtime) == sl.ERROR_CODE.SUCCESS):
            tracking_state = zed.get_position(
                camera_pose, 
                sl.REFERENCE_FRAME.WORLD
                )
            
        if tracking_state == sl.POSITIONAL_TRACKING_STATE.OK:
            transform_pose(
                camera_pose.pose_data(sl.Transform()), 
                tx_translation)
            orientation = camera_pose.get_orientation(zed_orientation)
            translation = camera_pose.get_translation(zed_translation).get()
            rotation = orientation.get_rotation_matrix().get_rotation_vector()
            if svo_position % 100 == 0:
               print(
                    f"{np.round(translation,2)} "
                    f"{svo_position} / {zed.get_svo_number_of_frames()}"
                )

            zed.retrieve_measure(
                point_cloud_mat, 
                sl.MEASURE.DEPTH, 
                )

            zed.get_sensors_data(sensors_data, sl.TIME_REFERENCE.IMAGE)
            imu_data = sensors_data.get_imu_data()

    
    if True:
            area_file =  <filename.area>
            print(area_file)
            zed.save_area_map(area_file) #also tried disable_positional_tracking(<filename.area>)

            print(zed.get_area_export_state())
    zed.close()

In the tracking_params variable you must set enable_area_memory to true to enable area memory.

I’ve tried that, it doesn’t help.

tracking_params = sl.PositionalTrackingParameters(_enable_memory=True)

also tried

tracking_params.enable_area_memory = True

Per the code here: zed-python-api/sl.pyx at master · stereolabs/zed-python-api · GitHub and the docs here Area Memory and Relocalization | Stereolabs

That shouldn’t be necessary. It’s on by default. Which explains why setting it to True, doesn’t solve anything.

Also tried, reinstalling the pyzed package in my environment. Same SPAITAL MEMORY DISABLED error every time.

Hello,
We’ve investigated that and it seems to be a bug in the SDK. We’ll fix this soon :slight_smile:

Antoine