Note

This notebook can be downloaded here: Projet+calibration-Paul.ipynb

import numpy as np
import cv2, PIL, os
from cv2 import aruco
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import matplotlib as mpl
import pandas as pd
%matplotlib nbagg
imagesFolder = "E:\Desktop\S8\Projet 851\data"

aruco_dict = aruco.Dictionary_get(aruco.DICT_6X6_250)

fig = plt.figure()
nx = 8
ny = 6
for i in range(1, nx*ny+1):
    ax = fig.add_subplot(ny,nx, i)
    img = aruco.drawMarker(aruco_dict,i-1, 700)
    plt.imshow(img, cmap = mpl.cm.gray, interpolation = "nearest")
    ax.axis("off")

plt.savefig(imagesFolder + "/markers.pdf")
plt.show()
#plt.close()
<IPython.core.display.Javascript object>
board = aruco.CharucoBoard_create(3, 3, 1, 0.8, aruco_dict)
imboard = board.draw((4000, 4000))
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
plt.imshow(imboard, cmap = mpl.cm.gray, interpolation = "nearest")
ax.axis("off")
cv2.imwrite(imagesFolder + "/chessboard.tiff",imboard)
#plt.savefig(imagesFolder + "/chessboard.pdf")
plt.grid()
plt.show()
print("Imprimer le damier de calibration!")
<IPython.core.display.Javascript object>
Imprimer le damier de calibration!
import cv2
import math

videoFile = "E:/Desktop/S8/Projet 851/outpy.avi"
imagesFolder = "E:/Desktop/S8/Projet 851/data/"
cap = cv2.VideoCapture(videoFile)
frameRate = cap.get(5) #frame rate
while(cap.isOpened()):
    frameId = cap.get(1) #current frame number
    ret, frame = cap.read()
    if (ret != True):
        break
    if (frameId <150):
        filename = imagesFolder + "\image_" +  str(int(frameId)) + ".jpg"
        cv2.imwrite(filename, frame)
cap.release()
print ("Done!")
Done!
im = PIL.Image.open(imagesFolder + "\image_0.jpg")
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
plt.imshow(im)
ax.axis('off')
plt.show()
<IPython.core.display.Javascript object>
def read_chessboards(images):
    """
    Charuco base pose estimation.
    """
    print("POSE ESTIMATION STARTS:")
    allCorners = []
    allIds = []
    decimator = 0

    for im in images:
        print("=> Processing image {0}".format(im))
        frame = cv2.imread(im)
        gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
        res = cv2.aruco.detectMarkers(gray, aruco_dict)

        if len(res[0])>0:
            res2 = cv2.aruco.interpolateCornersCharuco(res[0],res[1],gray,board)
            if res2[1] is not None and res2[2] is not None and len(res2[1])>3 and decimator%1==0:
                allCorners.append(res2[1])
                allIds.append(res2[2])

        decimator+=1

    imsize = gray.shape
    return allCorners,allIds,imsize
    print("finished")
#%%time
images = [imagesFolder + f for f in os.listdir(imagesFolder) if f.startswith("image_")]
allCorners,allIds,imsize=read_chessboards(images)
POSE ESTIMATION STARTS:
=> Processing image E:/Desktop/S8/Projet 851/data/image_69.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_139.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_15.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_145.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_12.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_142.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_60.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_130.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_67.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_137.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_52.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_2.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_83.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_102.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_29.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_5.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_55.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_84.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_105.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_27.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_20.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_31.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_36.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_38.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_114.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_95.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_44.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_113.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_92.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_43.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_126.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_76.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_121.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_71.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_128.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_78.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_21.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_26.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_28.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_54.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_4.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_85.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_104.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_3.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_53.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_82.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_103.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_66.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_136.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_61.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_131.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_13.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_143.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_68.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_138.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_14.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_144.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_129.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_79.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_120.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_70.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_127.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_77.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_112.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_93.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_42.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_39.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_115.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_94.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_45.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_37.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_30.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_124.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_74.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_123.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_73.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_116.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_97.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_46.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_111.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_90.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_41.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_33.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_34.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_118.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_99.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_48.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_25.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_59.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_9.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_88.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_109.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_22.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_0.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_50.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_81.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_100.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_57.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_7.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_86.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_107.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_62.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_132.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_65.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_135.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_19.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_149.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_17.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_147.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_10.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_140.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_35.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_119.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_98.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_49.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_32.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_110.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_91.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_40.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_117.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_96.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_47.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_122.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_72.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_125.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_75.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_11.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_141.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_16.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_146.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_64.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_134.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_18.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_148.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_63.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_133.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_6.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_56.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_87.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_106.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_51.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_1.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_80.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_101.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_23.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_24.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_8.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_58.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_89.jpg
=> Processing image E:/Desktop/S8/Projet 851/data/image_108.jpg
def calibrate_camera(allCorners,allIds,imsize):
    """
    Calibrates the camera using the dected corners.
    """
    print("CAMERA CALIBRATION")

    cameraMatrixInit = np.array([[ 2000.,    0., imsize[0]/2.],
                                 [    0., 2000., imsize[1]/2.],
                                 [    0.,    0.,           1.]])

    distCoeffsInit = np.zeros((5,1))
    flags = (cv2.CALIB_USE_INTRINSIC_GUESS + cv2.CALIB_RATIONAL_MODEL)
    (ret, camera_matrix, distortion_coefficients0,
     rotation_vectors, translation_vectors,
     stdDeviationsIntrinsics, stdDeviationsExtrinsics,
     perViewErrors) = cv2.aruco.calibrateCameraCharucoExtended(
                      charucoCorners=allCorners,
                      charucoIds=allIds,
                      board=board,
                      imageSize=imsize,
                      cameraMatrix=cameraMatrixInit,
                      distCoeffs=distCoeffsInit,
                      flags=flags,
                      criteria=(cv2.TERM_CRITERIA_EPS & cv2.TERM_CRITERIA_COUNT, 10000, 1e-9))

    return ret, camera_matrix, distortion_coefficients0, rotation_vectors, translation_vectors
    print("finished")
%%time
ret, mtx, dist, rvecs, tvecs = calibrate_camera(allCorners,allIds,imsize)
ret
CAMERA CALIBRATION
Wall time: 12min 46s
mtx
array([[  1.46963466e+03,   0.00000000e+00,   2.63094117e+02],
       [  0.00000000e+00,   1.47297770e+03,   3.19127464e+02],
       [  0.00000000e+00,   0.00000000e+00,   1.00000000e+00]])
dist
array([[ -4.15557150e+00],
       [  8.04563425e+02],
       [  1.72644822e-01],
       [ -4.62914356e-02],
       [ -1.41439828e+04],
       [  4.99936408e+00],
       [ -2.89968864e+02],
       [  1.96691829e+04],
       [  0.00000000e+00],
       [  0.00000000e+00],
       [  0.00000000e+00],
       [  0.00000000e+00],
       [  0.00000000e+00],
       [  0.00000000e+00]])
np.savetxt(imagesFolder+"calib_mtx_webcam.csv", mtx)
np.savetxt(imagesFolder+"calib_dist_webcam.csv", dist)

Check calibration¶

i=24 # select image id
plt.figure()
frame = cv2.imread(imagesFolder + "image_100.jpg".format(i))
img_undist = cv2.undistort(frame,mtx,dist,None)
plt.subplot(211)
plt.imshow(frame)
plt.title("Raw image")
plt.axis("off")
plt.subplot(212)
plt.imshow(img_undist)
plt.title("Corrected image")
plt.axis("off")
plt.show()
<IPython.core.display.Javascript object>

Use of camera calibration to estimate 3D translation and rotation of each marker on a scene¶

frame = cv2.imread(imagesFolder + "image_10.jpg")
plt.figure()
plt.imshow(frame)
plt.show()
<IPython.core.display.Javascript object>

Post processing¶

%%time

gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
aruco_dict = aruco.Dictionary_get(aruco.DICT_6X6_250)
parameters =  aruco.DetectorParameters_create()
corners, ids, rejectedImgPoints = aruco.detectMarkers(gray, aruco_dict, parameters=parameters)
frame_markers = aruco.drawDetectedMarkers(frame.copy(), corners, ids)
Wall time: 38.1 ms

Result¶

conn = np.array([0, 1, 2, 3, 0])
plt.figure()
plt.imshow(frame_markers)
plt.legend()
plt.show()
<IPython.core.display.Javascript object>
No handles with labels found to put in legend.

Add local axis on each maker¶

size_of_marker =  0.0145 # side lenght of the marker in meter
rvecs,tvecs, trash = aruco.estimatePoseSingleMarkers(corners, size_of_marker , mtx, dist)
tvecs
array([[[ 0.03625717,  0.04684617,  0.46653871]],

       [[ 0.07796683,  0.00174052,  0.44514342]],

       [[ 0.0131153 , -0.02022943,  0.44694283]],

       [[-0.11509333, -0.02061886,  0.4465331 ]],

       [[ 0.07544442, -0.0398416 ,  0.43262915]],

       [[ 0.09802467, -0.06131984,  0.44035666]],

       [[ 0.05448294, -0.06054667,  0.4326234 ]],

       [[ 0.05369867,  0.0631415 ,  0.42116605]],

       [[-0.11193155,  0.06244439,  0.427018  ]],

       [[ 0.05551877,  0.02247846,  0.43705436]],

       [[ 0.05492523, -0.01945728,  0.43442988]],

       [[-0.00789508, -0.03981689,  0.42867534]],

       [[-0.07027212, -0.06136102,  0.43652852]],

       [[ 0.07773333,  0.08803092,  0.43954609]],

       [[ 0.03309225,  0.08473541,  0.42561175]],

       [[-0.0083905 ,  0.08445285,  0.42618681]],

       [[-0.05225633,  0.08741113,  0.4432211 ]],

       [[-0.09553183,  0.08714634,  0.44444085]],

       [[ 0.09551237,  0.06367101,  0.42236155]],

       [[ 0.01270016,  0.0654016 ,  0.43867211]],

       [[-0.02963197,  0.06396202,  0.4309523 ]],

       [[-0.07063805,  0.06274348,  0.42591115]],

       [[ 0.07741211,  0.04443328,  0.43943835]],

       [[-0.00828486,  0.04297415,  0.42962259]],

       [[-0.05158105,  0.04377289,  0.44160457]],

       [[-0.09398191,  0.04328224,  0.44114026]],

       [[ 0.09948571,  0.02302646,  0.44172269]],

       [[ 0.01301304,  0.02262962,  0.44414953]],

       [[-0.02986066,  0.02198689,  0.4362466 ]],

       [[-0.07277628,  0.02201956,  0.44309408]],

       [[-0.11713915,  0.0219428 ,  0.45057945]],

       [[ 0.03385166,  0.00165063,  0.43509877]],

       [[-0.00814628,  0.00132911,  0.42935713]],

       [[-0.05144476,  0.00123526,  0.44487906]],

       [[-0.09568427,  0.00092015,  0.45336912]],

       [[ 0.10089582, -0.01985325,  0.45093768]],

       [[-0.02939441, -0.0199319 ,  0.4364838 ]],

       [[-0.07200425, -0.0203373 ,  0.44242592]],

       [[-0.05016834, -0.04077952,  0.43744884]],

       [[-0.0918302 , -0.04095322,  0.43837771]],

       [[ 0.01312589, -0.06296745,  0.44912868]],

       [[-0.0291022 , -0.06147094,  0.4378132 ]],

       [[-0.11297562, -0.0621073 ,  0.44228741]]])
tvecs.shape
(43, 1, 3)
np.degrees(rvecs)
array([[[  1.62516394e+02,   2.46355609e+00,  -1.09402896e+01]],

       [[  1.79457420e+02,   7.19277484e-02,  -1.32140582e+00]],

       [[  1.77773147e+02,  -9.91113450e-01,   5.53146653e+00]],

       [[ -1.85403347e+02,  -2.23002873e-01,   1.24063729e+01]],

       [[  1.81444729e+02,  -7.25485937e-01,   1.04275177e+01]],

       [[  1.77398449e+02,  -2.71016859e-01,   7.89579400e+00]],

       [[  1.73242093e+02,   1.79338050e+00,  -5.06408000e+00]],

       [[  1.66617310e+02,  -7.61331890e-01,  -1.96025399e+01]],

       [[ -1.79129608e+02,  -4.21227613e+00,  -6.45245428e+01]],

       [[  1.81282644e+02,  -1.57056435e-01,  -6.86839568e-01]],

       [[  1.65840660e+02,   9.53216792e-01,  -4.33656312e+00]],

       [[  1.76040502e+02,   1.50523348e+00,  -1.30437940e+01]],

       [[  1.72773893e+02,   9.89154542e-01,  -6.18063691e+00]],

       [[ -1.83491628e+02,  -2.23552817e+00,  -8.18637179e-01]],

       [[ -1.76798040e+02,  -1.43834284e+00,   2.15416822e-01]],

       [[ -1.77092833e+02,   2.28512214e-02,   6.79815955e-01]],

       [[ -1.91819997e+02,  -4.62989175e+00,  -2.72407766e+01]],

       [[ -1.88598008e+02,  -4.31571915e+00,  -4.45937173e+01]],

       [[  1.72422229e+02,   2.36525196e+00,   1.21332142e+01]],

       [[  1.70530658e+02,   9.57492283e-01,  -7.11983884e+00]],

       [[ -1.87682503e+02,  -2.04001941e+00,  -3.27632552e+00]],

       [[  1.72237634e+02,   2.40773992e-01,  -7.26850888e+00]],

       [[  1.76200826e+02,   2.12251694e+00,   8.50244737e+00]],

       [[ -1.70882183e+02,  -1.02785140e+00,  -1.36475536e+00]],

       [[  1.66528971e+02,   7.38399741e-01,   2.02590218e+01]],

       [[  1.74711765e+02,   6.94637499e-01,  -1.47345906e+01]],

       [[ -1.82368806e+02,  -8.91134423e-01,  -3.14684799e+00]],

       [[ -1.79633708e+02,  -8.69525993e-01,   1.46194101e+01]],

       [[ -1.71473555e+02,  -2.21806078e+00,  -5.66001095e+00]],

       [[  1.83622188e+02,   2.59067337e+00,   1.22927092e+01]],

       [[  1.74751206e+02,   7.16637262e-01,  -3.74674508e+00]],

       [[  1.93004493e+02,  -5.16294249e-01,  -1.14421246e+01]],

       [[  1.63289047e+02,   5.75137737e-01,   3.98558399e-01]],

       [[  1.76744726e+02,   2.63313500e-01,  -1.71716506e+01]],

       [[  1.78244412e+02,   1.48455510e+00,  -4.94199360e+00]],

       [[ -1.67227497e+02,   1.13991745e+00,   3.64310604e+01]],

       [[  1.96110861e+02,   1.20281778e+00,   4.91750442e+00]],

       [[ -1.90395446e+02,  -2.17143285e-01,  -8.94562363e+00]],

       [[  1.80592357e+02,   2.08727304e+00,  -2.16501956e+01]],

       [[  1.77081940e+02,   3.29046736e+00,  -1.88123338e+01]],

       [[  1.86433786e+02,   2.42004714e+00,  -2.39405027e+01]],

       [[ -1.60978143e+02,  -1.03801207e-01,  -1.69359969e+01]],

       [[  1.74702391e+02,   3.89745168e+00,  -1.58659988e+01]]])
length_of_axis = 0.01
imaxis = aruco.drawDetectedMarkers(frame.copy(), corners, ids)
for i in range(len(tvecs)):
    imaxis = aruco.drawAxis(imaxis, mtx, dist, rvecs[i], tvecs[i], length_of_axis)
plt.figure()
plt.imshow(imaxis)
plt.show()
<IPython.core.display.Javascript object>
data=pd.DataFrame(data=tvecs.reshape(43,3),columns=["tx","ty","tz"],index=ids.flatten())
data.index.name="makers"
data.sort_index(inplace=True)
data
tx ty tz
makers
0 -0.112976 -0.062107 0.442287
1 -0.070272 -0.061361 0.436529
2 -0.029102 -0.061471 0.437813
3 0.013126 -0.062967 0.449129
4 0.054483 -0.060547 0.432623
5 0.098025 -0.061320 0.440357
6 -0.091830 -0.040953 0.438378
7 -0.050168 -0.040780 0.437449
8 -0.007895 -0.039817 0.428675
10 0.075444 -0.039842 0.432629
11 -0.115093 -0.020619 0.446533
12 -0.072004 -0.020337 0.442426
13 -0.029394 -0.019932 0.436484
14 0.013115 -0.020229 0.446943
15 0.054925 -0.019457 0.434430
16 0.100896 -0.019853 0.450938
17 -0.095684 0.000920 0.453369
18 -0.051445 0.001235 0.444879
19 -0.008146 0.001329 0.429357
20 0.033852 0.001651 0.435099
21 0.077967 0.001741 0.445143
22 -0.117139 0.021943 0.450579
23 -0.072776 0.022020 0.443094
24 -0.029861 0.021987 0.436247
25 0.013013 0.022630 0.444150
26 0.055519 0.022478 0.437054
27 0.099486 0.023026 0.441723
28 -0.093982 0.043282 0.441140
29 -0.051581 0.043773 0.441605
30 -0.008285 0.042974 0.429623
31 0.036257 0.046846 0.466539
32 0.077412 0.044433 0.439438
33 -0.111932 0.062444 0.427018
34 -0.070638 0.062743 0.425911
35 -0.029632 0.063962 0.430952
36 0.012700 0.065402 0.438672
37 0.053699 0.063141 0.421166
38 0.095512 0.063671 0.422362
39 -0.095532 0.087146 0.444441
40 -0.052256 0.087411 0.443221
41 -0.008390 0.084453 0.426187
42 0.033092 0.084735 0.425612
43 0.077733 0.088031 0.439546
p=data.values
((p[1]-p[0])**2.).sum()**.5,((p[2]-p[1])**2.).sum()**.5,((p[3]-p[2])**2.).sum()**.5
(0.04309652659780655, 0.041190101023714003, 0.043743470242086288)
((data.loc[11]-data.loc[0]).values**2).sum()
0.001743801337263979
V0_1= p[1]-p[0]
V0_11=p[11]-p[0]
V0_1,V0_11
(array([ 0.0427035 ,  0.00074629, -0.00575889]),
 array([ 0.04097137,  0.04177   ,  0.00013852]))
np.dot(V0_1,V0_11)
0.0017799953347752665
fig=plt.figure()
ax= fig.add_subplot(1,1,1)
ax.set_aspect("equal")
plt.plot(data.tx[:10], data.ty[:10],"or-")
plt.grid()
plt.show()
<IPython.core.display.Javascript object>
data.tx
corners=np.array(corners)
data2=pd.DataFrame({"px":corners[:,0,0,1],"py":corners[:,0,0,0]},index=ids.flatten())
data2.sort_index(inplace=True)

data2
px py
0 229.0 335.0
1 230.0 465.0
2 230.0 595.0
3 231.0 729.0
4 231.0 861.0
5 232.0 995.0
6 316.0 399.0
7 317.0 530.0
8 318.0 662.0
10 319.0 928.0
11 405.0 331.0
12 405.0 462.0
13 406.0 594.0
14 407.0 728.0
15 408.0 861.0
16 409.0 996.0
17 494.0 396.0
18 495.0 529.0
19 496.0 661.0
20 497.0 794.0
21 497.0 929.0
22 580.0 328.0
23 581.0 460.0
24 582.0 593.0
25 583.0 728.0
26 584.0 862.0
27 585.0 998.0
28 670.0 394.0
29 672.0 526.0
30 673.0 660.0
31 676.0 796.0
32 675.0 931.0
33 758.0 324.0
34 760.0 458.0
35 761.0 592.0
36 762.0 728.0
37 764.0 862.0
38 765.0 999.0
39 851.0 390.0
40 852.0 525.0
41 854.0 659.0
42 855.0 794.0
43 857.0 931.0
n0=data2.loc[0]
n1=data2.loc[1]
d01=((n0-n1).values**2).sum()**.5
d=42.5e-3
factor=d/d01
data2["x"]=data2.px*factor
data2["y"]=data2.py*factor
d1_0=data2.loc[2].y-data2.loc[1].y
d11_0=data2.loc[11].x-data2.loc[0].x
d1_0
0.042498738
d11_0
0.057536766
imagesFolder = "E:\Desktop\S8\Projet 851\data"
dictionary = cv2.aruco.getPredefinedDictionary(cv2.aruco.DICT_6X6_250)
board = cv2.aruco.CharucoBoard_create(3,3,.025,.0125,dictionary)
img = board.draw((200*3,200*3))
cv2.imwrite(imagesFolder + '\charucotest.png',img)
True
help (aruco)
Help on module cv2.aruco in cv2:

NAME
    cv2.aruco

FUNCTIONS
    Board_create(...)
        Board_create(objPoints, dictionary, ids) -> retval
        .   * @brief Provide way to create Board by passing nessesary data. Specially needed in Python.
        .   *
        .   * @param objPoints array of object points of all the marker corners in the board
        .   * @param dictionary the dictionary of markers employed for this board
        .   * @param ids vector of the identifiers of the markers in the board
        .   *

    CharucoBoard_create(...)
        CharucoBoard_create(squaresX, squaresY, squareLength, markerLength, dictionary) -> retval
        .   * @brief Create a CharucoBoard object
        .   *
        .   * @param squaresX number of chessboard squares in X direction
        .   * @param squaresY number of chessboard squares in Y direction
        .   * @param squareLength chessboard square side length (normally in meters)
        .   * @param markerLength marker side length (same unit than squareLength)
        .   * @param dictionary dictionary of markers indicating the type of markers.
        .   * The first markers in the dictionary are used to fill the white chessboard squares.
        .   * @return the output CharucoBoard object
        .   *
        .   * This functions creates a CharucoBoard object given the number of squares in each direction
        .   * and the size of the markers and chessboard squares.

    DetectorParameters_create(...)
        DetectorParameters_create() -> retval
        .

    Dictionary_create(...)
        Dictionary_create(nMarkers, markerSize) -> retval
        .   * @see generateCustomDictionary

    Dictionary_create_from(...)
        Dictionary_create_from(nMarkers, markerSize, baseDictionary) -> retval
        .   * @see generateCustomDictionary

    Dictionary_get(...)
        Dictionary_get(dict) -> retval
        .   * @see getPredefinedDictionary

    GridBoard_create(...)
        GridBoard_create(markersX, markersY, markerLength, markerSeparation, dictionary[, firstMarker]) -> retval
        .   * @brief Create a GridBoard object
        .   *
        .   * @param markersX number of markers in X direction
        .   * @param markersY number of markers in Y direction
        .   * @param markerLength marker side length (normally in meters)
        .   * @param markerSeparation separation between two markers (same unit as markerLength)
        .   * @param dictionary dictionary of markers indicating the type of markers
        .   * @param firstMarker id of first marker in dictionary to use on board.
        .   * @return the output GridBoard object
        .   *
        .   * This functions creates a GridBoard object given the number of markers in each direction and
        .   * the marker size and marker separation.

    calibrateCameraAruco(...)
        calibrateCameraAruco(corners, ids, counter, board, imageSize, cameraMatrix, distCoeffs[, rvecs[, tvecs[, flags[, criteria]]]]) -> retval, cameraMatrix, distCoeffs, rvecs, tvecs
        .   @brief It's the same function as #calibrateCameraAruco but without calibration error estimation.

    calibrateCameraArucoExtended(...)
        calibrateCameraArucoExtended(corners, ids, counter, board, imageSize, cameraMatrix, distCoeffs[, rvecs[, tvecs[, stdDeviationsIntrinsics[, stdDeviationsExtrinsics[, perViewErrors[, flags[, criteria]]]]]]]) -> retval, cameraMatrix, distCoeffs, rvecs, tvecs, stdDeviationsIntrinsics, stdDeviationsExtrinsics, perViewErrors
        .   * @brief Calibrate a camera using aruco markers
        .   *
        .   * @param corners vector of detected marker corners in all frames.
        .   * The corners should have the same format returned by detectMarkers (see #detectMarkers).
        .   * @param ids list of identifiers for each marker in corners
        .   * @param counter number of markers in each frame so that corners and ids can be split
        .   * @param board Marker Board layout
        .   * @param imageSize Size of the image used only to initialize the intrinsic camera matrix.
        .   * @param cameraMatrix Output 3x3 floating-point camera matrix
        .   * f$A = vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}f$ . If CV_CALIB_USE_INTRINSIC_GUESS
        .   * and/or CV_CALIB_FIX_ASPECT_RATIO are specified, some or all of fx, fy, cx, cy must be
        .   * initialized before calling the function.
        .   * @param distCoeffs Output vector of distortion coefficients
        .   * f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6],[s_1, s_2, s_3, s_4]])f$ of 4, 5, 8 or 12 elements
        .   * @param rvecs Output vector of rotation vectors (see Rodrigues ) estimated for each board view
        .   * (e.g. std::vector<cv::Mat>>). That is, each k-th rotation vector together with the corresponding
        .   * k-th translation vector (see the next output parameter description) brings the board pattern
        .   * from the model coordinate space (in which object points are specified) to the world coordinate
        .   * space, that is, a real position of the board pattern in the k-th pattern view (k=0.. M -1).
        .   * @param tvecs Output vector of translation vectors estimated for each pattern view.
        .   * @param stdDeviationsIntrinsics Output vector of standard deviations estimated for intrinsic parameters.
        .   * Order of deviations values:
        .   * f$(f_x, f_y, c_x, c_y, k_1, k_2, p_1, p_2, k_3, k_4, k_5, k_6 , s_1, s_2, s_3,
        .   * s_4, tau_x, tau_y)f$ If one of parameters is not estimated, it's deviation is equals to zero.
        .   * @param stdDeviationsExtrinsics Output vector of standard deviations estimated for extrinsic parameters.
        .   * Order of deviations values: f$(R_1, T_1, dotsc , R_M, T_M)f$ where M is number of pattern views,
        .   * f$R_i, T_if$ are concatenated 1x3 vectors.
        .   * @param perViewErrors Output vector of average re-projection errors estimated for each pattern view.
        .   * @param flags flags Different flags  for the calibration process (see #calibrateCamera for details).
        .   * @param criteria Termination criteria for the iterative optimization algorithm.
        .   *
        .   * This function calibrates a camera using an Aruco Board. The function receives a list of
        .   * detected markers from several views of the Board. The process is similar to the chessboard
        .   * calibration in calibrateCamera(). The function returns the final re-projection error.

    calibrateCameraCharuco(...)
        calibrateCameraCharuco(charucoCorners, charucoIds, board, imageSize, cameraMatrix, distCoeffs[, rvecs[, tvecs[, flags[, criteria]]]]) -> retval, cameraMatrix, distCoeffs, rvecs, tvecs
        .   @brief It's the same function as #calibrateCameraCharuco but without calibration error estimation.

    calibrateCameraCharucoExtended(...)
        calibrateCameraCharucoExtended(charucoCorners, charucoIds, board, imageSize, cameraMatrix, distCoeffs[, rvecs[, tvecs[, stdDeviationsIntrinsics[, stdDeviationsExtrinsics[, perViewErrors[, flags[, criteria]]]]]]]) -> retval, cameraMatrix, distCoeffs, rvecs, tvecs, stdDeviationsIntrinsics, stdDeviationsExtrinsics, perViewErrors
        .   * @brief Calibrate a camera using Charuco corners
        .   *
        .   * @param charucoCorners vector of detected charuco corners per frame
        .   * @param charucoIds list of identifiers for each corner in charucoCorners per frame
        .   * @param board Marker Board layout
        .   * @param imageSize input image size
        .   * @param cameraMatrix Output 3x3 floating-point camera matrix
        .   * f$A = vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}f$ . If CV_CALIB_USE_INTRINSIC_GUESS
        .   * and/or CV_CALIB_FIX_ASPECT_RATIO are specified, some or all of fx, fy, cx, cy must be
        .   * initialized before calling the function.
        .   * @param distCoeffs Output vector of distortion coefficients
        .   * f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6],[s_1, s_2, s_3, s_4]])f$ of 4, 5, 8 or 12 elements
        .   * @param rvecs Output vector of rotation vectors (see Rodrigues ) estimated for each board view
        .   * (e.g. std::vector<cv::Mat>>). That is, each k-th rotation vector together with the corresponding
        .   * k-th translation vector (see the next output parameter description) brings the board pattern
        .   * from the model coordinate space (in which object points are specified) to the world coordinate
        .   * space, that is, a real position of the board pattern in the k-th pattern view (k=0.. M -1).
        .   * @param tvecs Output vector of translation vectors estimated for each pattern view.
        .   * @param stdDeviationsIntrinsics Output vector of standard deviations estimated for intrinsic parameters.
        .   * Order of deviations values:
        .   * f$(f_x, f_y, c_x, c_y, k_1, k_2, p_1, p_2, k_3, k_4, k_5, k_6 , s_1, s_2, s_3,
        .   * s_4, tau_x, tau_y)f$ If one of parameters is not estimated, it's deviation is equals to zero.
        .   * @param stdDeviationsExtrinsics Output vector of standard deviations estimated for extrinsic parameters.
        .   * Order of deviations values: f$(R_1, T_1, dotsc , R_M, T_M)f$ where M is number of pattern views,
        .   * f$R_i, T_if$ are concatenated 1x3 vectors.
        .   * @param perViewErrors Output vector of average re-projection errors estimated for each pattern view.
        .   * @param flags flags Different flags  for the calibration process (see #calibrateCamera for details).
        .   * @param criteria Termination criteria for the iterative optimization algorithm.
        .   *
        .   * This function calibrates a camera using a set of corners of a  Charuco Board. The function
        .   * receives a list of detected corners and its identifiers from several views of the Board.
        .   * The function returns the final re-projection error.

    custom_dictionary(...)
        custom_dictionary(nMarkers, markerSize) -> retval
        .   * @see generateCustomDictionary

    custom_dictionary_from(...)
        custom_dictionary_from(nMarkers, markerSize, baseDictionary) -> retval
        .   * @brief Generates a new customizable marker dictionary
        .   *
        .   * @param nMarkers number of markers in the dictionary
        .   * @param markerSize number of bits per dimension of each markers
        .   * @param baseDictionary Include the markers in this dictionary at the beginning (optional)
        .   *
        .   * This function creates a new dictionary composed by nMarkers markers and each markers composed
        .   * by markerSize x markerSize bits. If baseDictionary is provided, its markers are directly
        .   * included and the rest are generated based on them. If the size of baseDictionary is higher
        .   * than nMarkers, only the first nMarkers in baseDictionary are taken and no new marker is added.

    detectCharucoDiamond(...)
        detectCharucoDiamond(image, markerCorners, markerIds, squareMarkerLengthRate[, diamondCorners[, diamondIds[, cameraMatrix[, distCoeffs]]]]) -> diamondCorners, diamondIds
        .   * @brief Detect ChArUco Diamond markers
        .   *
        .   * @param image input image necessary for corner subpixel.
        .   * @param markerCorners list of detected marker corners from detectMarkers function.
        .   * @param markerIds list of marker ids in markerCorners.
        .   * @param squareMarkerLengthRate rate between square and marker length:
        .   * squareMarkerLengthRate = squareLength/markerLength. The real units are not necessary.
        .   * @param diamondCorners output list of detected diamond corners (4 corners per diamond). The order
        .   * is the same than in marker corners: top left, top right, bottom right and bottom left. Similar
        .   * format than the corners returned by detectMarkers (e.g std::vector<std::vector<cv::Point2f> > ).
        .   * @param diamondIds ids of the diamonds in diamondCorners. The id of each diamond is in fact of
        .   * type Vec4i, so each diamond has 4 ids, which are the ids of the aruco markers composing the
        .   * diamond.
        .   * @param cameraMatrix Optional camera calibration matrix.
        .   * @param distCoeffs Optional camera distortion coefficients.
        .   *
        .   * This function detects Diamond markers from the previous detected ArUco markers. The diamonds
        .   * are returned in the diamondCorners and diamondIds parameters. If camera calibration parameters
        .   * are provided, the diamond search is based on reprojection. If not, diamond search is based on
        .   * homography. Homography is faster than reprojection but can slightly reduce the detection rate.

    detectMarkers(...)
        detectMarkers(image, dictionary[, corners[, ids[, parameters[, rejectedImgPoints[, cameraMatrix[, distCoeff]]]]]]) -> corners, ids, rejectedImgPoints
        .   * @brief Basic marker detection
        .   *
        .   * @param image input image
        .   * @param dictionary indicates the type of markers that will be searched
        .   * @param corners vector of detected marker corners. For each marker, its four corners
        .   * are provided, (e.g std::vector<std::vector<cv::Point2f> > ). For N detected markers,
        .   * the dimensions of this array is Nx4. The order of the corners is clockwise.
        .   * @param ids vector of identifiers of the detected markers. The identifier is of type int
        .   * (e.g. std::vector<int>). For N detected markers, the size of ids is also N.
        .   * The identifiers have the same order than the markers in the imgPoints array.
        .   * @param parameters marker detection parameters
        .   * @param rejectedImgPoints contains the imgPoints of those squares whose inner code has not a
        .   * correct codification. Useful for debugging purposes.
        .   * @param cameraMatrix optional input 3x3 floating-point camera matrix
        .   * f$A = vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}f$
        .   * @param distCoeff optional vector of distortion coefficients
        .   * f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6],[s_1, s_2, s_3, s_4]])f$ of 4, 5, 8 or 12 elements
        .   *
        .   * Performs marker detection in the input image. Only markers included in the specific dictionary
        .   * are searched. For each detected marker, it returns the 2D position of its corner in the image
        .   * and its corresponding identifier.
        .   * Note that this function does not perform pose estimation.
        .   * @sa estimatePoseSingleMarkers,  estimatePoseBoard
        .   *

    drawAxis(...)
        drawAxis(image, cameraMatrix, distCoeffs, rvec, tvec, length) -> image
        .   * @brief Draw coordinate system axis from pose estimation
        .   *
        .   * @param image input/output image. It must have 1 or 3 channels. The number of channels is not
        .   * altered.
        .   * @param cameraMatrix input 3x3 floating-point camera matrix
        .   * f$A = vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}f$
        .   * @param distCoeffs vector of distortion coefficients
        .   * f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6],[s_1, s_2, s_3, s_4]])f$ of 4, 5, 8 or 12 elements
        .   * @param rvec rotation vector of the coordinate system that will be drawn. (@sa Rodrigues).
        .   * @param tvec translation vector of the coordinate system that will be drawn.
        .   * @param length length of the painted axis in the same unit than tvec (usually in meters)
        .   *
        .   * Given the pose estimation of a marker or board, this function draws the axis of the world
        .   * coordinate system, i.e. the system centered on the marker/board. Useful for debugging purposes.

    drawDetectedCornersCharuco(...)
        drawDetectedCornersCharuco(image, charucoCorners[, charucoIds[, cornerColor]]) -> image
        .   * @brief Draws a set of Charuco corners
        .   * @param image input/output image. It must have 1 or 3 channels. The number of channels is not
        .   * altered.
        .   * @param charucoCorners vector of detected charuco corners
        .   * @param charucoIds list of identifiers for each corner in charucoCorners
        .   * @param cornerColor color of the square surrounding each corner
        .   *
        .   * This function draws a set of detected Charuco corners. If identifiers vector is provided, it also
        .   * draws the id of each corner.

    drawDetectedDiamonds(...)
        drawDetectedDiamonds(image, diamondCorners[, diamondIds[, borderColor]]) -> image
        .   * @brief Draw a set of detected ChArUco Diamond markers
        .   *
        .   * @param image input/output image. It must have 1 or 3 channels. The number of channels is not
        .   * altered.
        .   * @param diamondCorners positions of diamond corners in the same format returned by
        .   * detectCharucoDiamond(). (e.g std::vector<std::vector<cv::Point2f> > ). For N detected markers,
        .   * the dimensions of this array should be Nx4. The order of the corners should be clockwise.
        .   * @param diamondIds vector of identifiers for diamonds in diamondCorners, in the same format
        .   * returned by detectCharucoDiamond() (e.g. std::vector<Vec4i>).
        .   * Optional, if not provided, ids are not painted.
        .   * @param borderColor color of marker borders. Rest of colors (text color and first corner color)
        .   * are calculated based on this one.
        .   *
        .   * Given an array of detected diamonds, this functions draws them in the image. The marker borders
        .   * are painted and the markers identifiers if provided.
        .   * Useful for debugging purposes.

    drawDetectedMarkers(...)
        drawDetectedMarkers(image, corners[, ids[, borderColor]]) -> image
        .   * @brief Draw detected markers in image
        .   *
        .   * @param image input/output image. It must have 1 or 3 channels. The number of channels is not
        .   * altered.
        .   * @param corners positions of marker corners on input image.
        .   * (e.g std::vector<std::vector<cv::Point2f> > ). For N detected markers, the dimensions of
        .   * this array should be Nx4. The order of the corners should be clockwise.
        .   * @param ids vector of identifiers for markers in markersCorners .
        .   * Optional, if not provided, ids are not painted.
        .   * @param borderColor color of marker borders. Rest of colors (text color and first corner color)
        .   * are calculated based on this one to improve visualization.
        .   *
        .   * Given an array of detected marker corners and its corresponding ids, this functions draws
        .   * the markers in the image. The marker borders are painted and the markers identifiers if provided.
        .   * Useful for debugging purposes.

    drawMarker(...)
        drawMarker(dictionary, id, sidePixels[, img[, borderBits]]) -> img
        .   * @brief Draw a canonical marker image
        .   *
        .   * @param dictionary dictionary of markers indicating the type of markers
        .   * @param id identifier of the marker that will be returned. It has to be a valid id
        .   * in the specified dictionary.
        .   * @param sidePixels size of the image in pixels
        .   * @param img output image with the marker
        .   * @param borderBits width of the marker border.
        .   *
        .   * This function returns a marker image in its canonical form (i.e. ready to be printed)

    drawPlanarBoard(...)
        drawPlanarBoard(board, outSize[, img[, marginSize[, borderBits]]]) -> img
        .   * @brief Draw a planar board
        .   * @sa _drawPlanarBoardImpl
        .   *
        .   * @param board layout of the board that will be drawn. The board should be planar,
        .   * z coordinate is ignored
        .   * @param outSize size of the output image in pixels.
        .   * @param img output image with the board. The size of this image will be outSize
        .   * and the board will be on the center, keeping the board proportions.
        .   * @param marginSize minimum margins (in pixels) of the board in the output image
        .   * @param borderBits width of the marker borders.
        .   *
        .   * This function return the image of a planar board, ready to be printed. It assumes
        .   * the Board layout specified is planar by ignoring the z coordinates of the object points.

    estimatePoseBoard(...)
        estimatePoseBoard(corners, ids, board, cameraMatrix, distCoeffs[, rvec[, tvec[, useExtrinsicGuess]]]) -> retval, rvec, tvec
        .   * @brief Pose estimation for a board of markers
        .   *
        .   * @param corners vector of already detected markers corners. For each marker, its four corners
        .   * are provided, (e.g std::vector<std::vector<cv::Point2f> > ). For N detected markers, the
        .   * dimensions of this array should be Nx4. The order of the corners should be clockwise.
        .   * @param ids list of identifiers for each marker in corners
        .   * @param board layout of markers in the board. The layout is composed by the marker identifiers
        .   * and the positions of each marker corner in the board reference system.
        .   * @param cameraMatrix input 3x3 floating-point camera matrix
        .   * f$A = vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}f$
        .   * @param distCoeffs vector of distortion coefficients
        .   * f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6],[s_1, s_2, s_3, s_4]])f$ of 4, 5, 8 or 12 elements
        .   * @param rvec Output vector (e.g. cv::Mat) corresponding to the rotation vector of the board
        .   * (see cv::Rodrigues). Used as initial guess if not empty.
        .   * @param tvec Output vector (e.g. cv::Mat) corresponding to the translation vector of the board.
        .   * @param useExtrinsicGuess defines whether initial guess for b rvec and b tvec will be used or not.
        .   * Used as initial guess if not empty.
        .   *
        .   * This function receives the detected markers and returns the pose of a marker board composed
        .   * by those markers.
        .   * A Board of marker has a single world coordinate system which is defined by the board layout.
        .   * The returned transformation is the one that transforms points from the board coordinate system
        .   * to the camera coordinate system.
        .   * Input markers that are not included in the board layout are ignored.
        .   * The function returns the number of markers from the input employed for the board pose estimation.
        .   * Note that returning a 0 means the pose has not been estimated.

    estimatePoseCharucoBoard(...)
        estimatePoseCharucoBoard(charucoCorners, charucoIds, board, cameraMatrix, distCoeffs[, rvec[, tvec[, useExtrinsicGuess]]]) -> retval, rvec, tvec
        .   * @brief Pose estimation for a ChArUco board given some of their corners
        .   * @param charucoCorners vector of detected charuco corners
        .   * @param charucoIds list of identifiers for each corner in charucoCorners
        .   * @param board layout of ChArUco board.
        .   * @param cameraMatrix input 3x3 floating-point camera matrix
        .   * f$A = vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}f$
        .   * @param distCoeffs vector of distortion coefficients
        .   * f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6],[s_1, s_2, s_3, s_4]])f$ of 4, 5, 8 or 12 elements
        .   * @param rvec Output vector (e.g. cv::Mat) corresponding to the rotation vector of the board
        .   * (see cv::Rodrigues).
        .   * @param tvec Output vector (e.g. cv::Mat) corresponding to the translation vector of the board.
        .   * @param useExtrinsicGuess defines whether initial guess for b rvec and b tvec will be used or not.
        .   *
        .   * This function estimates a Charuco board pose from some detected corners.
        .   * The function checks if the input corners are enough and valid to perform pose estimation.
        .   * If pose estimation is valid, returns true, else returns false.

    estimatePoseSingleMarkers(...)
        estimatePoseSingleMarkers(corners, markerLength, cameraMatrix, distCoeffs[, rvecs[, tvecs[, _objPoints]]]) -> rvecs, tvecs, _objPoints
        .   * @brief Pose estimation for single markers
        .   *
        .   * @param corners vector of already detected markers corners. For each marker, its four corners
        .   * are provided, (e.g std::vector<std::vector<cv::Point2f> > ). For N detected markers,
        .   * the dimensions of this array should be Nx4. The order of the corners should be clockwise.
        .   * @sa detectMarkers
        .   * @param markerLength the length of the markers' side. The returning translation vectors will
        .   * be in the same unit. Normally, unit is meters.
        .   * @param cameraMatrix input 3x3 floating-point camera matrix
        .   * f$A = vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}f$
        .   * @param distCoeffs vector of distortion coefficients
        .   * f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6],[s_1, s_2, s_3, s_4]])f$ of 4, 5, 8 or 12 elements
        .   * @param rvecs array of output rotation vectors (@sa Rodrigues) (e.g. std::vector<cv::Vec3d>).
        .   * Each element in rvecs corresponds to the specific marker in imgPoints.
        .   * @param tvecs array of output translation vectors (e.g. std::vector<cv::Vec3d>).
        .   * Each element in tvecs corresponds to the specific marker in imgPoints.
        .   * @param _objPoints array of object points of all the marker corners
        .   *
        .   * This function receives the detected markers and returns their pose estimation respect to
        .   * the camera individually. So for each marker, one rotation and translation vector is returned.
        .   * The returned transformation is the one that transforms points from each marker coordinate system
        .   * to the camera coordinate system.
        .   * The marker corrdinate system is centered on the middle of the marker, with the Z axis
        .   * perpendicular to the marker plane.
        .   * The coordinates of the four corners of the marker in its own coordinate system are:
        .   * (-markerLength/2, markerLength/2, 0), (markerLength/2, markerLength/2, 0),
        .   * (markerLength/2, -markerLength/2, 0), (-markerLength/2, -markerLength/2, 0)

    getBoardObjectAndImagePoints(...)
        getBoardObjectAndImagePoints(board, detectedCorners, detectedIds[, objPoints[, imgPoints]]) -> objPoints, imgPoints
        .   * @brief Given a board configuration and a set of detected markers, returns the corresponding
        .   * image points and object points to call solvePnP
        .   *
        .   * @param board Marker board layout.
        .   * @param detectedCorners List of detected marker corners of the board.
        .   * @param detectedIds List of identifiers for each marker.
        .   * @param objPoints Vector of vectors of board marker points in the board coordinate space.
        .   * @param imgPoints Vector of vectors of the projections of board marker corner points.

    getPredefinedDictionary(...)
        getPredefinedDictionary(dict) -> retval
        .   * @brief Returns one of the predefined dictionaries referenced by DICT_*.

    interpolateCornersCharuco(...)
        interpolateCornersCharuco(markerCorners, markerIds, image, board[, charucoCorners[, charucoIds[, cameraMatrix[, distCoeffs[, minMarkers]]]]]) -> retval, charucoCorners, charucoIds
        .   * @brief Interpolate position of ChArUco board corners
        .   * @param markerCorners vector of already detected markers corners. For each marker, its four
        .   * corners are provided, (e.g std::vector<std::vector<cv::Point2f> > ). For N detected markers, the
        .   * dimensions of this array should be Nx4. The order of the corners should be clockwise.
        .   * @param markerIds list of identifiers for each marker in corners
        .   * @param image input image necesary for corner refinement. Note that markers are not detected and
        .   * should be sent in corners and ids parameters.
        .   * @param board layout of ChArUco board.
        .   * @param charucoCorners interpolated chessboard corners
        .   * @param charucoIds interpolated chessboard corners identifiers
        .   * @param cameraMatrix optional 3x3 floating-point camera matrix
        .   * f$A = vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}f$
        .   * @param distCoeffs optional vector of distortion coefficients
        .   * f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6],[s_1, s_2, s_3, s_4]])f$ of 4, 5, 8 or 12 elements
        .   * @param minMarkers number of adjacent markers that must be detected to return a charuco corner
        .   *
        .   * This function receives the detected markers and returns the 2D position of the chessboard corners
        .   * from a ChArUco board using the detected Aruco markers. If camera parameters are provided,
        .   * the process is based in an approximated pose estimation, else it is based on local homography.
        .   * Only visible corners are returned. For each corner, its corresponding identifier is
        .   * also returned in charucoIds.
        .   * The function returns the number of interpolated corners.

    refineDetectedMarkers(...)
        refineDetectedMarkers(image, board, detectedCorners, detectedIds, rejectedCorners[, cameraMatrix[, distCoeffs[, minRepDistance[, errorCorrectionRate[, checkAllOrders[, recoveredIdxs[, parameters]]]]]]]) -> detectedCorners, detectedIds, rejectedCorners, recoveredIdxs
        .   * @brief Refind not detected markers based on the already detected and the board layout
        .   *
        .   * @param image input image
        .   * @param board layout of markers in the board.
        .   * @param detectedCorners vector of already detected marker corners.
        .   * @param detectedIds vector of already detected marker identifiers.
        .   * @param rejectedCorners vector of rejected candidates during the marker detection process.
        .   * @param cameraMatrix optional input 3x3 floating-point camera matrix
        .   * f$A = vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}f$
        .   * @param distCoeffs optional vector of distortion coefficients
        .   * f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6],[s_1, s_2, s_3, s_4]])f$ of 4, 5, 8 or 12 elements
        .   * @param minRepDistance minimum distance between the corners of the rejected candidate and the
        .   * reprojected marker in order to consider it as a correspondence.
        .   * @param errorCorrectionRate rate of allowed erroneous bits respect to the error correction
        .   * capability of the used dictionary. -1 ignores the error correction step.
        .   * @param checkAllOrders Consider the four posible corner orders in the rejectedCorners array.
        .   * If it set to false, only the provided corner order is considered (default true).
        .   * @param recoveredIdxs Optional array to returns the indexes of the recovered candidates in the
        .   * original rejectedCorners array.
        .   * @param parameters marker detection parameters
        .   *
        .   * This function tries to find markers that were not detected in the basic detecMarkers function.
        .   * First, based on the current detected marker and the board layout, the function interpolates
        .   * the position of the missing markers. Then it tries to find correspondence between the reprojected
        .   * markers and the rejected candidates based on the minRepDistance and errorCorrectionRate
        .   * parameters.
        .   * If camera parameters and distortion coefficients are provided, missing markers are reprojected
        .   * using projectPoint function. If not, missing marker projections are interpolated using global
        .   * homography, and all the marker corners in the board must have the same Z coordinate.

DATA
    CORNER_REFINE_CONTOUR = 2
    CORNER_REFINE_NONE = 0
    CORNER_REFINE_SUBPIX = 1
    DICT_4X4_100 = 1
    DICT_4X4_1000 = 3
    DICT_4X4_250 = 2
    DICT_4X4_50 = 0
    DICT_5X5_100 = 5
    DICT_5X5_1000 = 7
    DICT_5X5_250 = 6
    DICT_5X5_50 = 4
    DICT_6X6_100 = 9
    DICT_6X6_1000 = 11
    DICT_6X6_250 = 10
    DICT_6X6_50 = 8
    DICT_7X7_100 = 13
    DICT_7X7_1000 = 15
    DICT_7X7_250 = 14
    DICT_7X7_50 = 12
    DICT_ARUCO_ORIGINAL = 16

FILE
    (built-in)
charucoCorners=allCorners,
                      charucoIds=allIds,
                      board=board,
                      imageSize=imsize,
                      cameraMatrix=cameraMatrixInit,
                      distCoeffs=distCoeffsInit,
                      flags=flags,
                      criteria=(cv2.TERM_CRITERIA_EPS & cv2.TERM_CRITERIA_COUNT, 10000, 1e-9)
help (aruco.calibrateCameraCharucoExtended)
Help on built-in function calibrateCameraCharuco:

calibrateCameraCharuco(...)
    calibrateCameraCharuco(charucoCorners, charucoIds, board, imageSize, cameraMatrix, distCoeffs[, rvecs[, tvecs[, flags[, criteria]]]]) -> retval, cameraMatrix, distCoeffs, rvecs, tvecs
    .   @brief It's the same function as #calibrateCameraCharuco but without calibration error estimation.