<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

using Emgu.CV;
using Emgu.CV.Structure;

namespace Parsley.Core {
  
  /// <summary>
  /// High level access to a camera
  /// </summary>
  public class Camera : SharedResource {
    private Emgu.CV.Capture _device;
    private Emgu.CV.IntrinsicCameraParameters _intrinsics;
    private Emgu.CV.ExtrinsicCameraParameters _extrinsics;

    public Camera(int device_index) {
      try {
        _device = new Emgu.CV.Capture(device_index);
      } catch (NullReferenceException) {
        throw new ArgumentException(String.Format("No camera device found at slot {0}.", device_index));
      }
      _intrinsics = null;
      _extrinsics = null;
    }

    public Camera(Emgu.CV.Capture device) {
      _device = device;
    }

    [Description("Determines if camera has an instrinsic calibration")]
    public bool HasIntrinsics {
      get { return _intrinsics != null; }
    }

    [Description("Determines if camera has an extrinsic calibration")]
    public bool HasExtrinsics {
      get { return _extrinsics != null; }
    }

    [Browsable(false)]
    public Emgu.CV.IntrinsicCameraParameters Intrinsics {
      get { return _intrinsics; }
      set { _intrinsics = value; }
    }

    [Browsable(false)]
    public Emgu.CV.ExtrinsicCameraParameters Extrinsics {
      get { return _extrinsics; }
      set { _extrinsics = value; }
    }

    [Description("Frame Width")]
    public int FrameWidth {
      get { return (int)_device.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_WIDTH); }
    }

    [Description("Frame Height")]
    public int FrameHeight {
      get { return (int)_device.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT); }
    }

    [Description("Frame Aspect Ratio of Width/Height")]
    public double FrameAspectRatio {
      get { return ((double)FrameWidth) / FrameHeight; }
    }

    public Image<Bgr, Byte> Frame() {
      return _device.QueryFrame();
    }

    protected override void DisposeManaged() {
      _device.Dispose();
    }
  }
}<commit_msg>extrinsics is now a collection. added documentation<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

using Emgu.CV;
using Emgu.CV.Structure;

namespace Parsley.Core {
  
  /// <summary>
  /// Represents a camera.
  /// </summary>
  public class Camera : SharedResource {
    private Emgu.CV.Capture _device;
    private Emgu.CV.IntrinsicCameraParameters _intrinsics;
    private List<Emgu.CV.ExtrinsicCameraParameters> _extrinsics;

    /// <summary>
    /// Initialize camera from device index
    /// </summary>
    /// <param name="device_index">Device index starting at zero.</param>
    public Camera(int device_index) {
      try {
        _device = new Emgu.CV.Capture(device_index);
      } catch (NullReferenceException) {
        throw new ArgumentException(String.Format("No camera device found at slot {0}.", device_index));
      }
      _intrinsics = null;
      _extrinsics = new List<ExtrinsicCameraParameters>();
    }

    /// <summary>
    /// Initialize with pre-existing device
    /// </summary>
    /// <remarks>Device is disposed when camera is disposed.</remarks>
    /// <param name="device">Device to initialize from</param>
    public Camera(Emgu.CV.Capture device) {
      _device = device;
    }

    /// <summary>
    /// True if camera has an intrinsic calibration associated.
    /// </summary>
    [Description("Determines if camera has an instrinsic calibration")]
    public bool HasIntrinsics {
      get { return _intrinsics != null; }
    }

    /// <summary>
    /// True if camera has at least one extrinsic calibration associated.
    /// </summary>
    [Description("Determines if camera has an extrinsic calibration")]
    public bool HasExtrinsics {
      get { return _extrinsics.Count > 0; }
    }

    /// <summary>
    /// Access intrinsic calibration
    /// </summary>
    [Browsable(false)]
    public Emgu.CV.IntrinsicCameraParameters Intrinsics {
      get { return _intrinsics; }
      set { _intrinsics = value; }
    }

    /// <summary>
    /// Access associated extrinsic calibrations
    /// </summary>
    [Browsable(false)]
    public List<Emgu.CV.ExtrinsicCameraParameters> Extrinsics {
      get { return _extrinsics; }
    }

    /// <summary>
    /// Frame width of device
    /// </summary>
    [Description("Frame Width")]
    public int FrameWidth {
      get { return (int)_device.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_WIDTH); }
    }

    /// <summary>
    /// Frame height of device
    /// </summary>
    [Description("Frame Height")]
    public int FrameHeight {
      get { return (int)_device.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT); }
    }

    /// <summary>
    /// Aspect ratio of FrameWidth / FrameHeight
    /// </summary>
    [Description("Frame Aspect Ratio of Width/Height")]
    public double FrameAspectRatio {
      get { return ((double)FrameWidth) / FrameHeight; }
    }

    /// <summary>
    /// Retrieve the current frame.
    /// </summary>
    /// <returns></returns>
    public Image<Bgr, Byte> Frame() {
      return _device.QueryFrame();
    }

    protected override void DisposeManaged() {
      _device.Dispose();
    }
  }
}
{'fraction_non_alphanumeric': 0.11657121743949751, 'fraction_numerical': 0.0005542213190467394, 'mean_word_length': 2.744121715076072, 'pattern_counts': {'":': 0, '<': 40, '<?xml version=': 0, '>': 41, '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': '4294994', 'n_tokens_mistral': 1638, 'n_tokens_neox': 1591, 'n_words': 395}