MCPcopy
hub / github.com/TencentARC/Pixal3D / _pbr_voxelize_view

Function _pbr_voxelize_view

data_toolkit/voxelize_pbr_view.py:266–390  ·  view source on GitHub ↗

Process multi-view PBR voxelization for a single sha256. Args: file: local_path from metadata sha256: sha256 string pbr_dump_root: directory containing PBR dump files transform_root: directory containing transform json files root: output directory fo

(file, sha256, pbr_dump_root, transform_root, root, view_indices=None)

Source from the content-addressed store, hash-verified

264
265
266def _pbr_voxelize_view(file, sha256, pbr_dump_root, transform_root, root, view_indices=None):
267 """
268 Process multi-view PBR voxelization for a single sha256.
269
270 Args:
271 file: local_path from metadata
272 sha256: sha256 string
273 pbr_dump_root: directory containing PBR dump files
274 transform_root: directory containing transform json files
275 root: output directory for PBR voxels
276 view_indices: list of view indices to process, None for all views
277 """
278 try:
279 pack = {'sha256': sha256}
280 dump = None
281
282 # Load transforms
283 transform_path = os.path.join(transform_root, sha256, 'transforms.json')
284 if not os.path.exists(transform_path):
285 print(f'Transform file not found for {sha256}, skipping')
286 return {'sha256': sha256, 'error': 'Transform file not found'}
287
288 with open(transform_path, 'r') as f:
289 transforms_json = json.load(f)
290 transform_mats = transforms_json['frames']
291
292 # Determine views to process
293 if view_indices is None:
294 view_indices = list(range(len(transform_mats)))
295 else:
296 view_indices = [i for i in view_indices if i < len(transform_mats)]
297
298 # Track processed and skipped counts
299 processed_count = 0
300 skipped_count = 0
301
302 for view_idx in view_indices:
303 for res in opt.resolution:
304 need_process = False
305
306 # Check if already processed
307 # Path structure: pbr_voxels_view_fix_{res}/{sha256}/view{idx:02d}.vxz
308 sha256_dir = os.path.join(root, f'pbr_voxels_view_fix_{res}', sha256)
309 vxz_path = os.path.join(sha256_dir, f'view{view_idx:02d}.vxz')
310 if os.path.exists(vxz_path):
311 try:
312 info = o_voxel.io.read_vxz_info(vxz_path)
313 pack[f'pbr_voxelized_view_fix{view_idx:02d}_{res}'] = True
314 pack[f'num_pbr_voxels_view_fix{view_idx:02d}_{res}'] = info['num_voxel']
315 skipped_count += 1
316 except Exception as e:
317 print(f'Error reading {sha256}/view{view_idx:02d}.vxz: {e}, will reprocess')
318 need_process = True
319 else:
320 need_process = True
321
322 # Process PBR dump
323 if need_process:

Callers

nothing calls this directly

Calls 3

prepare_pbr_dumpFunction · 0.85
transform_pbr_dumpFunction · 0.85
loadMethod · 0.45

Tested by

no test coverage detected