<commit_before>﻿using System.IO;
using UnityEngine;

namespace ArucoUnity
{
  namespace Examples
  {
    public class CreateBoard : MonoBehaviour
    {
      public Dictionary dictionary;

      public GridBoard board;
      public Utility.Mat image;
      public Utility.Size size;

      [HideInInspector]
      public Texture2D imageTexture;

      [Header("Board configuration")]
      [SerializeField]
      [Tooltip("Number of markers in X direction")]
      public int markersNumberX;

      [SerializeField]
      [Tooltip("Number of markers in Y direction")]
      public int markersNumberY;

      [SerializeField]
      [Tooltip("Marker side length (in pixels)")]
      public int markerLength;

      [SerializeField]
      [Tooltip("Separation between two consecutive markers in the grid (in pixels)")]
      public int markerSeparation;

      [SerializeField]
      private PREDEFINED_DICTIONARY_NAME dictionaryName;

      [SerializeField]
      [Tooltip("Margins size (in pixels). Default is marker separation")]
      public int marginsSize;

      [SerializeField]
      [Tooltip("Number of bits in marker borders")]
      public int markerBorderBits;

      [Header("Draw the board")]
      [SerializeField]
      private bool drawBoard;

      [SerializeField]
      private GameObject boardPlane;

      [Header("Save the board")]
      [SerializeField]
      [Tooltip("Save the generated image")]
      private bool saveBoard;

      [SerializeField]
      [Tooltip("Output image")]
      private string outputImage = "ArucoUnity/board.png";

      void Start()
      {
        dictionary = Methods.GetPredefinedDictionary(dictionaryName);
        Create();

        if (drawBoard)
        {
          Draw(boardPlane);

          if (saveBoard && outputImage.Length > 0)
          {
            Save(outputImage);
          }
        }
      }

      // Call it first if you're using the Script alone, not with the Prefab.
      public void Configurate(Dictionary dictionary, int markersNumberX, int markersNumberY, int markerLength, int markerSeparation, int marginsSize, int markerBorderBits)
      {
        this.dictionary = dictionary;
        this.markersNumberX = markersNumberX;
        this.markersNumberY = markersNumberY;
        this.markerLength = markerLength;
        this.markerSeparation = markerSeparation;
        this.marginsSize = marginsSize;
        this.markerBorderBits = markerBorderBits;
      }

      public void Create()
      {
        size = new Utility.Size();
        size.width = markersNumberX * (markerLength + markerSeparation) - markerSeparation + 2 * marginsSize;
        size.height = markersNumberY * (markerLength + markerSeparation) - markerSeparation + 2 * marginsSize;

        GridBoard board = GridBoard.Create(markersNumberX, markersNumberY, markerLength, markerSeparation, dictionary);

        image = new Utility.Mat();
        board.Draw(size, ref image, marginsSize, markerBorderBits);

        imageTexture = new Texture2D(image.cols, image.rows, TextureFormat.RGB24, false);
      }
<commit_msg>fix(CreateBoard.cs): added a out modifier to the Mat image argument of the GridBoard.Draw() method<commit_after>﻿using System.IO;
using UnityEngine;

namespace ArucoUnity
{
  namespace Examples
  {
    public class CreateBoard : MonoBehaviour
    {
      public Dictionary dictionary;

      public GridBoard board;
      public Utility.Mat image;
      public Utility.Size size;

      [HideInInspector]
      public Texture2D imageTexture;

      [Header("Board configuration")]
      [SerializeField]
      [Tooltip("Number of markers in X direction")]
      public int markersNumberX;

      [SerializeField]
      [Tooltip("Number of markers in Y direction")]
      public int markersNumberY;

      [SerializeField]
      [Tooltip("Marker side length (in pixels)")]
      public int markerLength;

      [SerializeField]
      [Tooltip("Separation between two consecutive markers in the grid (in pixels)")]
      public int markerSeparation;

      [SerializeField]
      private PREDEFINED_DICTIONARY_NAME dictionaryName;

      [SerializeField]
      [Tooltip("Margins size (in pixels). Default is marker separation")]
      public int marginsSize;

      [SerializeField]
      [Tooltip("Number of bits in marker borders")]
      public int markerBorderBits;

      [Header("Draw the board")]
      [SerializeField]
      private bool drawBoard;

      [SerializeField]
      private GameObject boardPlane;

      [Header("Save the board")]
      [SerializeField]
      [Tooltip("Save the generated image")]
      private bool saveBoard;

      [SerializeField]
      [Tooltip("Output image")]
      private string outputImage = "ArucoUnity/board.png";

      void Start()
      {
        dictionary = Methods.GetPredefinedDictionary(dictionaryName);
        Create();

        if (drawBoard)
        {
          Draw(boardPlane);

          if (saveBoard && outputImage.Length > 0)
          {
            Save(outputImage);
          }
        }
      }

      // Call it first if you're using the Script alone, not with the Prefab.
      public void Configurate(Dictionary dictionary, int markersNumberX, int markersNumberY, int markerLength, int markerSeparation, int marginsSize, int markerBorderBits)
      {
        this.dictionary = dictionary;
        this.markersNumberX = markersNumberX;
        this.markersNumberY = markersNumberY;
        this.markerLength = markerLength;
        this.markerSeparation = markerSeparation;
        this.marginsSize = marginsSize;
        this.markerBorderBits = markerBorderBits;
      }

      public void Create()
      {
        size = new Utility.Size();
        size.width = markersNumberX * (markerLength + markerSeparation) - markerSeparation + 2 * marginsSize;
        size.height = markersNumberY * (markerLength + markerSeparation) - markerSeparation + 2 * marginsSize;

        GridBoard board = GridBoard.Create(markersNumberX, markersNumberY, markerLength, markerSeparation, dictionary);

        board.Draw(size, out image, marginsSize, markerBorderBits);

        imageTexture = new Texture2D(image.cols, image.rows, TextureFormat.RGB24, false);
      }

{'fraction_non_alphanumeric': 0.0832258064516129, 'fraction_numerical': 0.0022580645161290325, 'mean_word_length': 2.7377938517179023, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '5541656', 'n_tokens_mistral': 1679, 'n_tokens_neox': 1604, 'n_words': 460}