"""Validate a portable RGB-only release without the processing stack.""" from pathlib import Path import sys,json,hashlib,argparse,subprocess sys.dont_write_bytecode=True import cv2 import numpy as np import polars as pl def validate(root): root=Path(root).resolve();sys.path.insert(0,str(root)) from observation_reader import ObservationDataset,camera_points import pyarrow.parquet as pq ds=ObservationDataset(root) assert ds.info['capture_mode']=='rgb_only' and ds.info['license']=='cc-by-4.0' assert ds.episodes report={'status':'passed','scope':'Full video decode, displayed PTS, frame identity tables, missing modalities, segment bounds, embedded preview schema and all checksums. No annotation accuracy or model training evaluation.','episodes':[]} for key,e in ds.episodes.items(): mapping=ds.table(key,'frame_mapping');n=e['frame_count'] assert mapping.height==n and mapping['rgb_frame_index'].to_list()==list(range(n)) source=mapping['source_frame_index'].to_numpy() assert np.all(np.diff(source)==1) and source[0]==e['source']['selection']['first_source_frame'] and source[-1]==e['source']['selection']['last_source_frame'] ts=mapping['t_s'].to_numpy();assert ts[0]==0 and np.all(np.isfinite(ts)) and np.all(np.diff(ts)>0) assert np.max(np.abs(np.diff(mapping['source_pts_s'].to_numpy())-np.diff(ts)))<1e-6 assert mapping['rgb_decodable'].all() probe=json.loads(subprocess.check_output(['ffprobe','-v','error','-show_streams','-show_packets','-of','json',str(root/e['video'])])) assert len(probe['streams'])==1 stream=probe['streams'][0] assert stream['codec_name']=='h264' and stream['pix_fmt']=='yuv420p' and stream['color_transfer']=='bt709' pts=sorted(float(p['pts_time']) for p in probe['packets'] if 'pts_time' in p and 'D' not in p.get('flags','')) assert len(pts)==n and np.max(np.abs(np.array(pts)-mapping['video_pts_s'].to_numpy()))<2e-6 cap=cv2.VideoCapture(str(root/e['video']));decoded=0 try: while True: ok,frame=cap.read() if not ok:break assert frame.shape==(e['height'],e['width'],3) decoded+=1 finally:cap.release() assert decoded==n,(key,decoded,n) indices=sorted({0,n//4,n//2,3*n//4,n-1}) for index in indices: frame=ds.frame(key,index) assert frame['source_frame_index']==int(source[index]) and frame['timestamp_s']==ts[index] assert all(frame[k] is None for k in ('depth_m','depth_valid','confidence','K_rgb','camera_pose_xyzw','sensor_timestamp_s')) assert not any(v for k,v in frame['modalities'].items() if k!='rgb') try:camera_points(frame) except ValueError:pass else:raise AssertionError('RGB-only geometry must be unavailable') for name in ('hand_pose_raw','hand_pose'): if name not in e['signals']:continue hand=ds.table(key,name) assert all(hand[k].null_count()==hand.height for k in ('z','wx','wy','wz')) assert ds.annotations_near(key,name,1e6).height==0 assert hashlib.file_digest((root/e['video']).open('rb'),'sha256').hexdigest()==e['video_sha256'] report['episodes'].append({'capture_id':key,'decoded_frames':decoded,'timestamp_rows':n,'random_access_indices':indices,'metric_channels_absent':True}) print(key,decoded,'decoded frames and timestamps verified',flush=True) segments=pl.read_parquet(root/'annotations/action_segments.parquet') for row in segments.to_dicts(): assert row['capture_id'] in ds.episodes assert 0<=row['start_s']