private double CalibrateCameraAruco(List <List <Mat> > allCorners, List <Mat> allIds, CharucoBoard board, Size imageSize, Mat cameraMatrix, Mat distCoeffs, List <Mat> rvecs = null, List <Mat> tvecs = null, int calibrationFlags = 0)
        {
            // prepare data for calibration
            int nFrames = allCorners.Count;
            int allLen  = 0;

            int[] markerCounterPerFrameArr = new int[allCorners.Count];
            for (int i = 0; i < nFrames; ++i)
            {
                markerCounterPerFrameArr[i] = allCorners[i].Count;
                allLen += allCorners[i].Count;
            }

            int[] allIdsConcatenatedArr = new int[allLen];
            int   index = 0;

            for (int j = 0; j < allIds.Count; ++j)
            {
                int[] idsArr = new int[(int)allIds[j].total()];
                allIds[j].get(0, 0, idsArr);

                for (int k = 0; k < idsArr.Length; ++k)
                {
                    allIdsConcatenatedArr[index + k] = (int)idsArr[k];
                }
                index += idsArr.Length;
            }

            using (Mat allIdsConcatenated = new Mat(1, allLen, CvType.CV_32SC1))
                using (Mat markerCounterPerFrame = new Mat(1, nFrames, CvType.CV_32SC1))
                {
                    List <Mat> allCornersConcatenated = new List <Mat>();
                    foreach (var c in allCorners)
                    {
                        foreach (var m in c)
                        {
                            allCornersConcatenated.Add(m);
                        }
                    }

                    allIdsConcatenated.put(0, 0, allIdsConcatenatedArr);
                    markerCounterPerFrame.put(0, 0, markerCounterPerFrameArr);

                    if (rvecs == null)
                    {
                        rvecs = new List <Mat>();
                    }
                    if (tvecs == null)
                    {
                        tvecs = new List <Mat>();
                    }

                    return(Aruco.calibrateCameraAruco(allCornersConcatenated, allIdsConcatenated, markerCounterPerFrame, board, imageSize, cameraMatrix, distCoeffs, rvecs, tvecs, calibrationFlags));
                }
        }