Files
PerfectCoffee/model_assets/juicer/validate_minex_video.py
T
Yanchen 94bdea5506 feat(juicer): revise housing, curved hopper and independent collectors
Rework the Minex mechanism to the 2026-11-19 housing revision:

- split the exterior into a fixed rear spine / base / control pod plus a
  removable open collection deck, transparent hood and lower side covers
- replace the flat L-shaped feeder with an open-top curved trough hopper
  (circular-arc centreline, recessed U section) per the 01:50-01:52 frames
- rebuild the bins as independent shallow front collectors with 172 mm
  residue and 134 mm juice depth, no divider, rails or detents
- drive the LCD through Ready / Processing / Stopped states on the shot
  timeline (frames 1-27 / 28-321 / 322-360)
- drop the decorative latches and keep the juice guide supported only by
  the removable deck; record contact-fit and backplate-connection notes
- regenerate mechanism/video validation records and update the Minex
  reference README, manifest and mechanism review to match
2026-11-22 11:02:39 +08:00

73 lines
7.5 KiB
Python

import hashlib
import json
import shutil
import subprocess
from pathlib import Path
OUT = Path(__file__).resolve().parent
VIDEO = OUT/'preview_operation.mp4'
BLEND = OUT/'PerfectCoffee_Minex_Mechanism.blend'
ffmpeg = shutil.which('ffmpeg')
ffprobe = shutil.which('ffprobe')
if not ffmpeg or not ffprobe:
raise RuntimeError('FFmpeg and ffprobe are required')
probe = json.loads(subprocess.check_output([ffprobe,'-v','error','-count_frames','-show_streams','-show_format','-of','json',str(VIDEO)],text=True))
stream = next(s for s in probe['streams'] if s['codec_type']=='video')
control_clip = OUT/'preview_controls.mp4'
control_probe = json.loads(subprocess.check_output([ffprobe,'-v','error','-count_frames','-show_streams','-show_format','-of','json',str(control_clip)],text=True))
control_stream = next(s for s in control_probe['streams'] if s['codec_type']=='video')
result = subprocess.run([ffmpeg,'-v','error','-xerror','-i',str(VIDEO),'-f','null','-'],capture_output=True,text=True)
if result.returncode:
raise RuntimeError(result.stderr)
expected = [f'{f:04d}.png' for f in range(1,361,2)]
frames_dir = OUT/'render_frames'
frames_present = frames_dir.is_dir()
missing = [name for name in expected if not (frames_dir/name).is_file()] if frames_present else []
unexpected = sorted(path.name for path in frames_dir.glob('*.png') if path.name not in expected) if frames_present else []
selection = 'eq(n,0)+eq(n,27)+eq(n,64)+eq(n,92)+eq(n,96)+eq(n,106)+eq(n,127)+eq(n,154)+eq(n,161)+eq(n,162)+eq(n,164)+eq(n,166)+eq(n,168)+eq(n,172)+eq(n,174)+eq(n,179)'
subprocess.run([ffmpeg,'-v','error','-y','-i',str(VIDEO),'-vf',f"select='{selection}',scale=360:450,tile=4x4",'-frames:v','1',str(OUT/'preview_contact_sheet.png')],check=True)
report = {
'file':VIDEO.name,
'source_blend':BLEND.name,
'source_blend_sha256':hashlib.sha256(BLEND.read_bytes()).hexdigest(),
'build_script_sha256':hashlib.sha256((OUT/'build_minex_mechanism.py').read_bytes()).hexdigest(),
'render_script_sha256':hashlib.sha256((OUT/'render_minex_mechanism.py').read_bytes()).hexdigest(),
'motion_reference':{'file':'model_assets/reference/juicer/ZMUEX_working_video.mp4','segment_seconds':[119,126],'inspected_views':['front mechanism','side close-up']},
'hopper_reference':{'file':'model_assets/reference/juicer/ZMUEX_working_video.mp4','segment_seconds':[110,112],'screenshot':'Curved_Hopper_Reference.png','geometry':'Circular-arc open-top U-shaped trough with seated fruit and recessed outlet ramp','placement':'Lengthened circular trough with in-plane rotation -8 degrees; local translation -101 mm, +15.1 mm before front-facing assembly; footprint verified','roof_entry':'Rounded opening aligned with the outlet ramp in global machine coordinates; ray checks confirm no roof intersection'},
'collector_reference':{'file':'model_assets/reference/juicer/ZMUEX_working_video.mp4','assembly_segment_seconds':[233,249],'left':'Shallow 172 mm front residue collector with deck-fitted side/rear walls and integrated pull','right':'Shallow 134 mm front juice collector with through-cut side grip; only this bin slides forward','plinth':'Shared front support surface at Z=39 mm; no rails, detents or individual islands','backplate':'Fixed continuous 22 mm rear load spine; separate removable lower side covers; no center divider','collector_wall_gap_m':0.007,'collector_depths_m':{'residue':0.172,'juice':0.134},'standalone_files':['PerfectCoffee_Residue_Bin.blend','PerfectCoffee_Juice_Bin.blend','PerfectCoffee_Collector_Pair.blend'],'standalone_assembly_files':['PerfectCoffee_Fixed_Chassis.blend','PerfectCoffee_Collection_Deck.blend','PerfectCoffee_Lower_Service_Covers.blend','PerfectCoffee_Transparent_Hood.blend'],'rotor_intersection_frames':0,'fixed_part_intersection_frames':0},
'control_display':{'apron':'Inclined collection deck covering the residue bin except for its discharge inlet; open juice mouth; LCD and start button belong to the fixed control pod','states':['Ready','Processing','Stopped'],'state_source_frames':[[1,27],[28,321],[322,360]],'start_button_travel_m':0.0025,'fault_state_present':False,'electrical_interlock_simulated':False,'press_visible_in_video':True},
'control_clip':{'file':control_clip.name,'decoded_frames':int(control_stream.get('nb_read_frames',control_stream['nb_frames'])),'duration_seconds':float(control_probe['format']['duration']),'content':'Ready, 2.5 mm button press and return, then Processing'},
'housing_revision':{'assembly_reference':{'video':'model_assets/reference/juicer/ZMUEX_working_video.mp4','segment_seconds':[233,283],'keyframes':'mechanism_diagrams/sequence_analysis/assembly_review/'},'hood_rear_y_m':-0.138,'compact_forward_shift_m':0.040,'base_y_depth_m':0.326,'backplate_front_y_m':-0.111,'backplate_thickness_m':0.022,'backplate_material':'Backplate_Green','fixed_control_pod':True,'removable_collection_deck':True,'removable_lower_service_covers':True,'separate_residue_door_present':False,'collector_wall_gap_m':0.007,'functional_backplate_mounts':4,'decorative_latches_removed':True,'support_collision_frames':0,'rear_liner_to_glazing_gap_m':0.0042,'rear_glazing_thickness_m':0.0016,'backplate_top':'Curved to follow the hood roof','contact_fit':{'rear_liner_seat_offset_m':0.0009,'lower_backplate_apron_clearance_m':0.0002,'collector_bottom_and_sill_z_m':0.039,'surface_intersection_pairs':0,'residue_clearance':'Covered residue bin with bounded discharge inlet; wall tops sit 7 mm below the inclined deck; 8 mm front fitting allowance; separate graphite rear side covers have 4 mm side clearance'},'manufacturer_dimensions_claimed':False},
'inspection_view':'Front cover is hidden only in internal mechanism renders. Final lower-body sequence shows shallow installed bins, both side fits, shared front sill, fixed rear spine/control pod, removable side covers and juice-bin slide; separate assembly views show fixed chassis, collection deck, covers and exploded state',
'video_sha256':hashlib.sha256(VIDEO.read_bytes()).hexdigest(),
'codec':stream['codec_name'],
'pixel_format':stream['pix_fmt'],
'width':int(stream['width']),
'height':int(stream['height']),
'frame_rate':stream['avg_frame_rate'],
'decoded_frames':int(stream.get('nb_read_frames',stream['nb_frames'])),
'duration_seconds':float(probe['format']['duration']),
'bytes':VIDEO.stat().st_size,
'source_blender_timeline':{'start':1,'end':360,'fps':24,'seconds':15},
'preview_sampling':'Every second Blender frame, encoded at 12 fps for the same 15-second duration',
'expected_source_images':len(expected),
'source_frames_present_at_validation':frames_present,
'missing_source_images':missing,
'unexpected_source_images':unexpected,
'decoded_without_errors':True,
'contact_sheet':'preview_contact_sheet.png',
'visual_review':'Pending final video and contact-sheet review',
}
report['technical_checks_passed'] = (
stream['codec_name']=='h264' and (report['width'],report['height'])==(720,900)
and report['frame_rate']=='12/1' and report['decoded_frames']==180
and abs(report['duration_seconds']-15.0)<0.01 and not missing and not unexpected
and report['control_clip']['decoded_frames']==18 and abs(report['control_clip']['duration_seconds']-1.5)<0.01
)
report['visual_review_passed'] = False
report['passed'] = report['technical_checks_passed'] and report['visual_review_passed']
(OUT/'video_validation.json').write_text(json.dumps(report,ensure_ascii=False,indent=2)+'\n',encoding='utf-8')
print(json.dumps(report,ensure_ascii=False,indent=2))
if not report['passed']:
raise RuntimeError('Video validation failed: technical checks or required visual review')