palletdatagenerator.modes.single_pallet module

Single Pallet Mode - Based on original one_pallet_generator.py

Implements the exact camera positioning, movement, and generation logic from the original single pallet generator.

class palletdatagenerator.modes.single_pallet.SinglePalletMode(config)[source]

Bases: BaseGenerator

Single pallet generation mode with camera movement around a stationary pallet. Replicates the exact behavior of the original one_pallet_generator.py

__init__(config)[source]
position_camera_for_side_face(cam_obj, target_obj, cfg)[source]

Position camera to focus on side faces of the pallet, EXACT as in original. Includes ground-safe positioning to prevent camera going below floor.

generate_frames()[source]

Main generation loop exactly as in original one_pallet_generator.py

apply_pallet_movement(pallets)[source]

Apply optional XY movement to pallets while keeping vertical stack.

prepare_pallets(base)[source]

Prepare pallet objects (duplicates, materials, etc.) exactly as original.

duplicate_pallets_if_needed(base_obj)[source]

Create duplicate pallets if requested in config.

position_pallets(pallets, base_mat)[source]

Position pallets according to stacking configuration.

setup_lighting(base_obj)[source]

Setup lighting system.

create_random_lights(anchor_obj, replace_existing=False)[source]

Create random lighting around the anchor object - uses base class method.

handle_attached_boxes(pallets)[source]

Handle attached box variants per frame - EXACT from original.

ATTACHED_GROUP_PREFIX = 'AttachedGroup_'
get_detections(pallets, cam_obj, sc)[source]

Get 2D and 3D bounding boxes for all visible pallets - EXACT from original.

auto_expose_frame(sc, cam_obj)[source]

Auto-exposure adjustment for the frame - uses base class method.

save_frame(img_path, b2d_list, b3d_list, pockets_list, cam_obj, sc, valid, fn, coco, ann_id, meta, pallets, keypoints_data=None)[source]

Save all outputs for a single frame: analysis, YOLO, VOC, COCO, metadata - EXACT from original.

project_holes_and_write_labels(pockets_world, cam, sc, yolo_dir, img_idx, coco, ann_id_start, img_w, img_h)[source]

Project holes and write YOLO/COCO labels - EXACT from original.

save_final_outputs(coco, meta)[source]

Save final COCO and metadata files.

apply_initial_transform(pallets, base_mat)[source]

Apply random initial transform to pallets.

save_generated_scene()[source]

Save the current generated scene to a .blend file in the scenes folder. This allows inspection and reuse of the randomized single pallet layout.