Skip to content

Commit

Permalink
fix frame_step error
Browse files Browse the repository at this point in the history
  • Loading branch information
S22560 committed Oct 18, 2024
1 parent 8ee2265 commit 8fa2b6f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions blenderproc/python/writer/WriterUtility.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,18 @@ def write_hdf5(output_dir_path: str, output_data_dict: Dict[str, List[Union[np.n
else:
frame_offset = 0

if amount_of_frames != bpy.context.scene.frame_end - bpy.context.scene.frame_start:
if amount_of_frames != (bpy.context.scene.frame_end - bpy.context.scene.frame_start-1)//bpy.context.scene.frame_step+1:
raise Exception("The amount of images stored in the output_data_dict does not correspond with the amount"
"of images specified by frame_start to frame_end.")

for frame in range(bpy.context.scene.frame_start, bpy.context.scene.frame_end):
for frame in range(bpy.context.scene.frame_start, bpy.context.scene.frame_end, bpy.context.scene.frame_step):
# for each frame a new .hdf5 file is generated
hdf5_path = os.path.join(output_dir_path, str(frame + frame_offset) + ".hdf5")
with h5py.File(hdf5_path, "w") as file:
# Go through all the output types
print(f"Merging data for frame {frame} into {hdf5_path}")

adjusted_frame = frame - bpy.context.scene.frame_start
adjusted_frame = (frame - bpy.context.scene.frame_start-1)//bpy.context.scene.frame_step+1
for key, data_block in output_data_dict.items():
if adjusted_frame < len(data_block):
# get the current data block for the current frame
Expand Down Expand Up @@ -111,7 +111,7 @@ def load_registered_outputs(keys: Set[str], keys_with_alpha_channel: Set[str] =
'key'] in keys_with_alpha_channel
if '%' in reg_out['path']:
# per frame outputs
for frame_id in range(bpy.context.scene.frame_start, bpy.context.scene.frame_end):
for frame_id in range(bpy.context.scene.frame_start, bpy.context.scene.frame_end, bpy.context.scene.frame_step):
output_path = resolve_path(reg_out['path'] % frame_id)
if os.path.exists(output_path):
output_file = _WriterUtility.load_output_file(output_path, key_has_alpha_channel)
Expand Down

0 comments on commit 8fa2b6f

Please sign in to comment.