001// Copyright (c) FIRST and other WPILib contributors.
002// Open Source Software; you can modify and/or share it under the terms of
003// the WPILib BSD license file in the root directory of this project.
004
005package edu.wpi.first.cscore;
006
007/** Video mode. */
008@SuppressWarnings("MemberName")
009public class VideoMode {
010  public enum PixelFormat {
011    kUnknown(0),
012    kMJPEG(1),
013    kYUYV(2),
014    kRGB565(3),
015    kBGR(4),
016    kGray(5),
017    kY16(6),
018    kUYVY(7);
019
020    private final int value;
021
022    PixelFormat(int value) {
023      this.value = value;
024    }
025
026    public int getValue() {
027      return value;
028    }
029  }
030
031  private static final PixelFormat[] m_pixelFormatValues = PixelFormat.values();
032
033  public static PixelFormat getPixelFormatFromInt(int pixelFormat) {
034    return m_pixelFormatValues[pixelFormat];
035  }
036
037  /**
038   * Create a new video mode.
039   *
040   * @param pixelFormat The pixel format enum as an integer.
041   * @param width The image width in pixels.
042   * @param height The image height in pixels.
043   * @param fps The camera's frames per second.
044   */
045  public VideoMode(int pixelFormat, int width, int height, int fps) {
046    this.pixelFormat = getPixelFormatFromInt(pixelFormat);
047    this.width = width;
048    this.height = height;
049    this.fps = fps;
050  }
051
052  /**
053   * Create a new video mode.
054   *
055   * @param pixelFormat The pixel format.
056   * @param width The image width in pixels.
057   * @param height The image height in pixels.
058   * @param fps The camera's frames per second.
059   */
060  public VideoMode(PixelFormat pixelFormat, int width, int height, int fps) {
061    this.pixelFormat = pixelFormat;
062    this.width = width;
063    this.height = height;
064    this.fps = fps;
065  }
066
067  /** Pixel format. */
068  public PixelFormat pixelFormat;
069
070  /** Width in pixels. */
071  public int width;
072
073  /** Height in pixels. */
074  public int height;
075
076  /** Frames per second. */
077  public int fps;
078}