Spaces:
Running
Running
Download source/scripts/reference/check_meas.py from Segizu/geometria3d-lab: direct link, hf CLI and curl.
- Browser
- Download file 854 Bytes
-
https://huggingface.co/spaces/Segizu/geometria3d-lab/resolve/main/source/scripts/reference/check_meas.py
- Command line
-
hf download hf://spaces/Segizu/geometria3d-lab/source/scripts/reference/check_meas.py
-
curl -L -o check_meas.py https://huggingface.co/spaces/Segizu/geometria3d-lab/resolve/main/source/scripts/reference/check_meas.py
854 Bytes
| import numpy as np, json, re | |
| from PIL import Image | |
| cfg = open('../src/config.js').read() | |
| ex = {'desk-laptop': [((385,645),(808,483)),((838,282),(961,282))], 'bicycle-street': [((412,352),(419,812)),((208,588),(614,525))], | |
| 'synthetic-room': [((208,606),(417,606)),((645,323),(645,570)),((591,447),(699,447))]} | |
| for k, ms in ex.items(): | |
| f = f'../public/examples/example-{k}.jpg'; w, h = Image.open(f).size | |
| P = np.load('/workspace/geometria3d-lab/_work/' + f.split('/')[-1] + '.points.npy'); H, W = P.shape[:2] | |
| def at(x, y): | |
| cx, cy = round(x * W / w - 0.5), round(y * H / h - 0.5) | |
| win = P[max(0,cy-1):cy+2, max(0,cx-1):cx+2].reshape(-1,3); return np.median(win, 0) | |
| for a, b in ms: | |
| A, B = at(*a), at(*b); print(k, a, b, round(float(np.linalg.norm(A-B)),3), 'zA', round(float(A[2]),2), 'zB', round(float(B[2]),2)) | |