mishig/so101-block-sorting / verify_result.py
mishig's picture
download
raw
1.41 kB
"""Verify the final result from the RGB camera, without object-state queries."""
import json
from pathlib import Path
import sys
import cv2
import numpy as np
ROOT = Path(__file__).resolve().parent
sys.path.insert(0, str(ROOT / 'scripts'))
from block_vision import detect_blocks
from sort_blocks import Controller
def main():
controller = Controller()
rgb, state = controller.observe('verify-all-blocks-in-box')
_, box = controller.locate_box(rgb)
hull = cv2.convexHull(box.contour.astype(np.float32))
results = {}
for color, detection in detect_blocks(rgb).items():
inside = detection is not None and cv2.pointPolygonTest(hull, tuple(map(float, detection.centroid)), False) >= 0
results[color] = dict(visible_inside_box=bool(inside), pixel=detection.centroid.tolist() if detection else None)
report = dict(blocks=results, warning_counts=state['warning_counts'],
method='RGB block centroids inside the visible box outline; no object-state query')
(ROOT / 'results/verification.json').write_text(json.dumps(report, indent=2))
if any(state['warning_counts']) or not all(item['visible_inside_box'] for item in results.values()):
raise RuntimeError(f'Final verification failed: {report}')
print('PASS: red, green, and blue are visible inside the box; no physics warnings.', flush=True)
if __name__ == '__main__':
main()

Xet Storage Details

Size:
1.41 kB
·
Xet hash:
50bdc33a8af8c65c6a9b231fb4c7b82d213785d940a74fb6eae3ed546652444c

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.