Hi All,
I’m using the json_export.py example from the Samples as a base for the task I’m trying to accomplish.
I would like to use an already recorded SVO file as input and, for each frame, calculate body position using this code and body tracking system. My sampling rate is 60 Hz.
I was able to ‘trick’ the code by providing the video as input (so not live data like in original code), but I realised that all I can obtain is max 6 Hz. I’m just losing some information in this approach (like I have 10 % of all the data).
Is there any way to force the program to go through all frames? I don’t need it to be fast, I just don’t want to lose information.
Here is the piece of code:
if name == “main”:
# common parameters
input_type = sl.InputType()
input_type.set_from_svo_file("/home/user/Downloads/movie_test.svo2")
start_time = time.time()
# common parameters
init_params = sl.InitParameters(input_t=input_type, svo_real_time_mode=True)
init_params.camera_fps = 60
init_params.sdk_verbose = 1
init_params.coordinate_system = sl.COORDINATE_SYSTEM.RIGHT_HANDED_Y_UP
init_params.coordinate_units = sl.UNIT.METER
init_params.depth_mode = sl.DEPTH_MODE.NEURAL
zed = sl.Camera()
error_code = zed.open(init_params)
if(error_code != sl.ERROR_CODE.SUCCESS):
print("Can't open camera: ", error_code)
positional_tracking_parameters = sl.PositionalTrackingParameters()
error_code = zed.enable_positional_tracking(positional_tracking_parameters)
if(error_code != sl.ERROR_CODE.SUCCESS):
print("Can't enable positionnal tracking: ", error_code)
body_tracking_parameters = sl.BodyTrackingParameters()
body_tracking_parameters.detection_model = sl.BODY_TRACKING_MODEL.HUMAN_BODY_FAST
body_tracking_parameters.body_format = sl.BODY_FORMAT.BODY_18
body_tracking_parameters.enable_body_fitting = True
body_tracking_parameters.enable_tracking = False
error_code = zed.enable_body_tracking(body_tracking_parameters)
if(error_code != sl.ERROR_CODE.SUCCESS):
print("Can't enable positionnal tracking: ", error_code)
# Get ZED camera information
#camera_info = zed.get_camera_information()
viewer = gl.GLViewer()
viewer.init()
# Create ZED objects filled in the main loop
bodies = sl.Bodies()
# single_bodies = [sl.Bodies]
skeleton_file_data = {}
while (viewer.is_available()):
if zed.grab() == sl.ERROR_CODE.SUCCESS:
zed.retrieve_bodies(bodies)
skeleton_file_data[str(bodies.timestamp.get_milliseconds())] = serializeBodies(bodies)
#viewer.update_bodies(bodies)
# Save data into JSON file:
file_sk = open("bodies_18model_no_viewer.json", 'w')
file_sk.write(json.dumps(skeleton_file_data, cls=NumpyEncoder, indent=4))
file_sk.close()
viewer.exit()
I would appreciate your help.
Julia