+
    STj                     P   R t ^ RIt^ RIt^ RIt^ RIt^ RIt]P                  P                  ]P                  P                  ]
4      4      t]P                  P                  ]R4      t]P                  P                  ]R4      tR^ R^/tRt^(]3R ltR tR tR	 tR
 tR tRR ltR# )ux  Camera registration + intrinsics I/O for ar_view.

Cameras are referenced by ROLE ("scene" / "wrist"), not by raw index:
  cameras.json            -> {role: {"index": N, "width": W, "height": H}}
  intrinsics/<role>.json  -> {"width","height","K","dist","rms","num_frames"}

`open_named` resolves a role to a live capture. If the registered index no longer has the
registered native resolution (indices shuffled), it scans for the index whose resolution
matches and uses that — so identical-resolution cameras still need a stable port, but
differently-sized cameras (e.g. a webcam vs the B0332) self-identify regardless of index.
Nzcameras.json
intrinsicsscenewristc                   \        \        R\        P                  4      \        P                  3 F  p\        P                  ! W4      pVP	                  4       '       g   K1  V'       dO   VP                  \        P                  V^ ,          4       VP                  \        P                  V^,          4       \        V4       F>  pVP                  4       w  rgV'       d   Ve   WG3u u # \        P                  ! R4       K@  	  VR3u # 	  R# )z_Open + warm up a camera index at a high resolution. Returns (cap, first_frame) or (None, None).CAP_AVFOUNDATIONNg?)NN)getattrcv2CAP_ANYVideoCaptureisOpenedsetCAP_PROP_FRAME_WIDTHCAP_PROP_FRAME_HEIGHTrangereadtimesleep)idxwarmcap_whbackendcap_okfrs   &&&     ar_view/cameras.py
open_indexr      s    C!3S[[A3;;Os,||~~GGC,,fQi8GGC--vay9tAXXZFBbnwJJt	 
 Dy P     c                  p     \         P                  ! \        \        4      4      #   \         d    / u # i ; iN)jsonloadopen	CAMS_FILEFileNotFoundError r   r   load_camerasr&   .   s.    yyi)) 	s   "% 55c                     \        4       pR \        V4      R\        V4      R\        V4      /W@&   \        P                  ! V\	        \
        R4      ^R7       R# )indexwidthheightwindentN)r&   intr    dumpr"   r#   )roler(   r)   r*   camss   &&&& r   registerr2   5   s@    >D3u:wE
Hc&kRDJIIdDC(3r   c                 t   \         P                  P                  \        V  R 24      p\         P                  P	                  V4      '       g   R# \
        P                  ! \        V4      4      p\        P                  ! VR,          \        4      VR&   \        P                  ! VR,          \        4      VR&   V# ).jsonNKdist)ospathjoinINTR_DIRexistsr    r!   r"   nparrayfloat)r0   pds   &  r   load_intrinsicsrA   ;   sy    
X$u~.A77>>!		$q'AXXafe$AcF6E*AfIHr   c                    \         P                  ! \        R R7       \        P                  ! R\        V4      R\        V4      R\        P                  ! V4      P                  4       R\        P                  ! V4      P                  4       P                  4       R\        V4      R\        V4      /\        \         P                  P                  \        V  R24      R	4      ^R
7       R# )T)exist_okr)   r*   r5   r6   rms
num_framesr4   r+   r,   N)r7   makedirsr:   r    r/   r.   r<   asarraytolistravelr>   r"   r8   r9   )r0   r5   r6   r)   r*   rD   rE   s   &&&&&&&r   save_intrinsicsrJ   E   s    KK4(IIwE
Hc&kBJJqM((*FBJJt4D4J4J4L4S4S4UeCj,JA 277<<TF%.93?Kr   c                 Z    V e'   V P                   ^,          V P                   ^ ,          3# R # r   )shape)r   s   &r   _resrM   M   s&    )+BHHQK!%ATAr   c                   Ve   \        V4      w  r4W1V3# \        4       P                  V / 4      pVP                  R4      '       d   VR,          VR,          3MRpVP                  R\        P                  V ^ 4      4      p\        V4      w  r4Ve   Ve   \	        V4      V8X  d   W7V3# Ve   VP                  4        Ve   \        V4       Fq  pW8X  d   K  \        V4      w  rV	e@   \	        V
4      V8X  d0   \        RV  RV RV RV^ ,           R	V^,           R
24       WV
3u # V	f   Ka  V	P                  4        Ks  	  \        V4      w  r4W7V3# )z-> (cap, index, first_frame). An explicit override_index is used as-is; otherwise
resolve via the registered index, auto-healing by the registered resolution.Nr)   r*   r(   z  [z] registered index z moved; using index z
 (matched x))r   r&   getDEFAULT_INDEXrM   releaser   print)r0   override_indexscanr   r   entrywantr   jcfs   &&&        r   
open_namedr\   Q   sM    !^,B&&NtR(E05		'0B0BE'NE(O,D
))G]..tQ7
8CoGC
DLDH,<|
tAxa=DA}aDD6!4SE9MaSPZ[_`a[bZccdeijkeldmmnopQw}		  oGCR<r   )i  i8  )N   )__doc__r    r7   r   numpyr<   r   r8   dirnameabspath__file__HEREr9   r#   r:   rR   CAP_WHr   r&   r2   rA   rJ   rM   r\   r%   r   r   <module>re      s   
  	   
	wwrwwx01GGLL~.	77<<l+!Wa( 
 F $4KBr   