<commit_before>﻿using ArucoUnity.Cameras;
using ArucoUnity.Controllers.CalibrationFlagsControllers;
using ArucoUnity.Objects;
using ArucoUnity.Plugin;
using System;
using System.IO;
using UnityEngine;

namespace ArucoUnity
{
  /// \addtogroup aruco_unity_package
  /// \{

  namespace Controllers
  {
    public class ArucoCalibrator : ArucoObjectDetector
    {
      // Editor fields

      [SerializeField]
      [Tooltip("The ArUco board to use for calibrate.")]
      private ArucoBoard calibrationBoard;

      [SerializeField]
      private bool refineMarkersDetection = false;

      [SerializeField]
      private CalibrationFlagsBaseController calibrationFlagsController;

      [SerializeField]
      [Tooltip("The output folder for the calibration files, relative to the Application.persistentDataPath folder.")]
      private string outputFolder = "ArucoUnity/Calibrations/";

      [SerializeField]
      [Tooltip("The saved calibration name. The extension (.xml) is added automatically. If empty, it will be generated automatically from the "
        + "camera name and the current datetime.")]
      private string calibrationFilename;

      // Properties

      public ArucoBoard CalibrationBoard { get { return calibrationBoard; } set { calibrationBoard = value; } }

      public bool RefineMarkersDetection { get { return refineMarkersDetection; } set { refineMarkersDetection = value; } }

      public CalibrationFlagsBaseController CalibrationFlagsController { get { return calibrationFlagsController; } set { calibrationFlagsController = value; } }

      /// <summary>
      /// The output folder for the calibration files, relative to the Application.persistentDataPath folder.
      /// </summary>
      public string OutputFolder { get { return outputFolder; } set { outputFolder = value; } }

      /// <summary>
      /// The saved calibration name. The extension (.xml) is added automatically. If empty, it will be generated automatically from the camera name
      /// and the current datetime.
      /// </summary>
      public string CalibrationFilename { get { return calibrationFilename; } set { calibrationFilename = value; } }

      public Cv.Core.TermCriteria CalibrationTermCriteria { get; set; }

      public Std.VectorVectorVectorPoint2f[] AllCorners { get; protected set; }

      public Std.VectorVectorInt[] AllIds { get; protected set; }

      public Std.VectorMat[] AllImages { get; protected set; }

      public Std.VectorVectorPoint2f[] AllCharucoCorners { get; protected set; }

      public Std.VectorVectorInt[] AllCharucoIds { get; protected set; }

      public Std.VectorMat[] Rvecs { get; protected set; }

      public Std.VectorMat[] Tvecs { get; protected set; }

      public CameraParameters CameraParameters { get; protected set; }

      public Std.VectorVectorPoint2f[] MarkerCornersCurrentImage { get; protected set; }

      public Std.VectorInt[] MarkerIdsCurrentImage { get; protected set; }

      public bool IsCalibrated { get; protected set; }

      // MonoBehaviour methods

      protected override void Awake()
      {
        base.Awake();

        if (CalibrationTermCriteria == null)
        {
          CalibrationTermCriteria = new Cv.Core.TermCriteria(Cv.Core.TermCriteria.Type.Count | Cv.Core.TermCriteria.Type.Eps, 100, 1E-5);
        }
      }

      // ArucoDetector Methods

      protected override void PreConfigure()
      {<commit_msg>refacto(ArucoCalibrator.cs): don't use a default CalibrationTermCriteria, there is already a default one with the OpenCV library.<commit_after>﻿using ArucoUnity.Cameras;
using ArucoUnity.Controllers.CalibrationFlagsControllers;
using ArucoUnity.Objects;
using ArucoUnity.Plugin;
using System;
using System.IO;
using UnityEngine;

namespace ArucoUnity
{
  /// \addtogroup aruco_unity_package
  /// \{

  namespace Controllers
  {
    public class ArucoCalibrator : ArucoObjectDetector
    {
      // Editor fields

      [SerializeField]
      [Tooltip("The ArUco board to use for calibrate.")]
      private ArucoBoard calibrationBoard;

      [SerializeField]
      private bool refineMarkersDetection = false;

      [SerializeField]
      private CalibrationFlagsBaseController calibrationFlagsController;

      [SerializeField]
      [Tooltip("The output folder for the calibration files, relative to the Application.persistentDataPath folder.")]
      private string outputFolder = "ArucoUnity/Calibrations/";

      [SerializeField]
      [Tooltip("The saved calibration name. The extension (.xml) is added automatically. If empty, it will be generated automatically from the "
        + "camera name and the current datetime.")]
      private string calibrationFilename;

      // Properties

      public ArucoBoard CalibrationBoard { get { return calibrationBoard; } set { calibrationBoard = value; } }

      public bool RefineMarkersDetection { get { return refineMarkersDetection; } set { refineMarkersDetection = value; } }

      public CalibrationFlagsBaseController CalibrationFlagsController { get { return calibrationFlagsController; } set { calibrationFlagsController = value; } }

      /// <summary>
      /// The output folder for the calibration files, relative to the Application.persistentDataPath folder.
      /// </summary>
      public string OutputFolder { get { return outputFolder; } set { outputFolder = value; } }

      /// <summary>
      /// The saved calibration name. The extension (.xml) is added automatically. If empty, it will be generated automatically from the camera name
      /// and the current datetime.
      /// </summary>
      public string CalibrationFilename { get { return calibrationFilename; } set { calibrationFilename = value; } }

      public Cv.Core.TermCriteria CalibrationTermCriteria { get; set; }

      public Std.VectorVectorVectorPoint2f[] AllCorners { get; protected set; }

      public Std.VectorVectorInt[] AllIds { get; protected set; }

      public Std.VectorMat[] AllImages { get; protected set; }

      public Std.VectorVectorPoint2f[] AllCharucoCorners { get; protected set; }

      public Std.VectorVectorInt[] AllCharucoIds { get; protected set; }

      public Std.VectorMat[] Rvecs { get; protected set; }

      public Std.VectorMat[] Tvecs { get; protected set; }

      public CameraParameters CameraParameters { get; protected set; }

      public Std.VectorVectorPoint2f[] MarkerCornersCurrentImage { get; protected set; }

      public Std.VectorInt[] MarkerIdsCurrentImage { get; protected set; }

      public bool IsCalibrated { get; protected set; }

      // ArucoDetector Methods

      protected override void PreConfigure()
      {
{'fraction_non_alphanumeric': 0.08269548251538346, 'fraction_numerical': 0.0016509079993996699, 'mean_word_length': 3.3244646333549643, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6349408', 'n_tokens_mistral': 1820, 'n_tokens_neox': 1720, 'n_words': 543}