+
    HTj
                         R t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIHtH	t	H
t
 ^ RIHt ^ RIHtHt ^ RIHtHtHt R]	R]
R]/tR	 t]R
8X  d
   ]! 4        R# R# )u>  Multi-frame PINHOLE intrinsics calibration for a named camera (scene / wrist).

Same pinhole model as the rest of the pipeline (calib_utils.estimate_focal): principal
point fixed at the image center, square pixels, ZERO distortion — we solve only the focal
length. The only change from the old single-image estimate is that we feed it ~60 board
views instead of one (a proper multi-view solve). No fisheye / distortion / pp offset.

Hold the arm-base ArUco board in front of the camera and move it around. It auto-captures
frames where the board is seen, then runs the pinhole solve and saves intrinsics/<name>.json
+ registers the camera in cameras.json.

Usage:
  python calibrate_camera.py <name> [--index N] [--board arm_base] [--frames 60]

Keys while collecting: 'c' capture now, 'q' finish early (>=8 frames), ESC abort.
N)DICTARM_BASEUMI_V2)CALIB_BOARD)detect_boardsestimate_focal)
open_indexregistersave_intrinsicsarm_baseumi_v2calibc                  
   \         P                  ! 4       p V P                  R RR7       V P                  R\        ^ R7       V P                  R\	        \
        4      RR7       V P                  R\        ^<R7       V P                  4       p\
        VP                  ,          pVR ,          p\        P                  P                  \        \        P                  P                  4       4      p\        VP                  4      w  rVVe   Vf%   \        P                   ! R
VP                   R24       VP"                  ^,          VP"                  ^ ,          r\%        RVP&                   RVP                   RV RV RVP                   R24       \%        R4       . p	Rp
\)        V	4      VP*                  8  Ed   VP-                  4       w  rV'       d   Vf   K;  \        P.                  ! V\        P0                  4      p\3        W.4      pVP5                  V4      w  pppVf   ^ M
\)        V4      pVP7                  4       pV'       d"   \        P                  P9                  VVV4       \        P:                  ! ^4      ^,          p\<        P<                  ! 4       pW>9   d8   V\?        R4      8X  g   VV
,
          R8  d   V	PA                  W,          4       Tp
W>9   pV'       d   R0MR1p\        PB                  ! VVP&                   R\)        V	4       RVP*                   RV 2R2\        PD                  RV^4       \        PF                  ! RV4       V\?        R4      8X  d   \)        V	4      ^8  d   MHV^8X  g   EK  VPI                  4        \        PJ                  ! 4        \        P                   ! R4       EK  VPI                  4        \        PJ                  ! 4        \)        V	4      ^8  d$   \        P                   ! R\)        V	4       R24       \%        R\)        V	4       R 24       \M        WV3R!\O        Wx4      ,          R"7      w  ppp\P        PR                  ! ^4      p\%        R#VR$ R%24       \%        R&VR3,          R' R(^\P        PT                  ! \P        PV                  ! V^,          VR3,          ,          4      4      ,          R' R)VR4,          R* R+VR5,          R* R,2	4       \Y        VP&                  VP                  Wx4       \[        VP&                  VVWxV\)        V	4      4       \%        R-VP&                   R.VP&                   R/24       R	# )6namez.camera role to save under (e.g. scene / wrist))helpz--index)typedefaultz--boardr   )choicesr   z--framesNzCamera z$ did not open / delivered no frames.zCalibrating 'z' on camera z (xz) with the z board.zQMove the board around to vary pose/position. 'c' capture, 'q' finish, ESC abort.
g        cg?z: captured /z   markers gffffff?zcalibrate camera (c/q/ESC)qzAborted.zOnly u>    frames — need at least 8. Try again with more board motion.z
Pinhole solve over z
 frames...g?)f_guessz  reprojection error: z.3fz pxz  focal f = z.1fzpx   (fovy z! deg), principal point fixed at (z.0fz, )z
Saved intrinsics/z1.json (pinhole, zero distortion) and registered 'z' in cameras.json.)       r   )r      r   )
      )r   r   )r      )   r   ).argparseArgumentParseradd_argumentintlistBOARDS
parse_argsboardcv2arucoArucoDetectorr   DetectorParametersr   indexsysexitshapeprintr   lenframesreadcvtColorCOLOR_BGR2GRAYr   detectMarkerscopydrawDetectedMarkerswaitKeytimeordappendputTextFONT_HERSHEY_SIMPLEXimshowreleasedestroyAllWindowsr   maxnpzerosdegreesarctanr	   r
   )apaspecr   detectorcapfrWnHnviewslast_tokframegraydetscornersids_nviskeynowok_boardcolorKerrdists                              ar_view/calibrate_camera.pymainrc       s   		 	 	"BOOF!QOROOICO3OOItF|WOEOOJS"O5
A!''?D<Dyy&&tSYY-I-I-KLH!GC
{bj7177)#GHIXXa["((1+	M!&&aggYbAbTQWWIU\
]^	
^_EF
e*qxx
HHJ	U]||E3#5#56T6*"006aA#c(jjlII))#w<kk!nt#iik<SCH_fs0BLL$F<']CAFF8;s5zl!AHH:[QRPSTc66UA	G

/5#c(?s5zQ"9KKM!!#HHZ KKM
5zA~5U$bcd	!#e*Z
89u2hc"k8IJIAq#88A;D	"3s)3
/0	L3K"**RYYr!tAcF{=S2T0TUX/Y Z''(vcl"QsVCLC D QVVQWWb%AFFAtRS#e*=	x'XYZY_Y_X``r
st    __main__)__doc__r!   r.   r;   numpyrD   r)   aruco_boardsr   r   r   calib_boardr   calib_utilsr   r   camerasr   r	   r
   r&   rc   __name__ rd   rb   <module>rn      s[      
   
 / / # 5 9 9
h&';	GAuH zF rd   