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. */ 008public class VideoMode { 009 public enum PixelFormat { 010 kUnknown(0), 011 kMJPEG(1), 012 kYUYV(2), 013 kRGB565(3), 014 kBGR(4), 015 kGray(5); 016 017 private final int value; 018 019 PixelFormat(int value) { 020 this.value = value; 021 } 022 023 public int getValue() { 024 return value; 025 } 026 } 027 028 private static final PixelFormat[] m_pixelFormatValues = PixelFormat.values(); 029 030 public static PixelFormat getPixelFormatFromInt(int pixelFormat) { 031 return m_pixelFormatValues[pixelFormat]; 032 } 033 034 /** 035 * Create a new video mode. 036 * 037 * @param pixelFormat The pixel format enum as an integer. 038 * @param width The image width in pixels. 039 * @param height The image height in pixels. 040 * @param fps The camera's frames per second. 041 */ 042 public VideoMode(int pixelFormat, int width, int height, int fps) { 043 this.pixelFormat = getPixelFormatFromInt(pixelFormat); 044 this.width = width; 045 this.height = height; 046 this.fps = fps; 047 } 048 049 /** 050 * Create a new video mode. 051 * 052 * @param pixelFormat The pixel format. 053 * @param width The image width in pixels. 054 * @param height The image height in pixels. 055 * @param fps The camera's frames per second. 056 */ 057 public VideoMode(PixelFormat pixelFormat, int width, int height, int fps) { 058 this.pixelFormat = pixelFormat; 059 this.width = width; 060 this.height = height; 061 this.fps = fps; 062 } 063 064 /** Pixel format. */ 065 @SuppressWarnings("MemberName") 066 public PixelFormat pixelFormat; 067 068 /** Width in pixels. */ 069 @SuppressWarnings("MemberName") 070 public int width; 071 072 /** Height in pixels. */ 073 @SuppressWarnings("MemberName") 074 public int height; 075 076 /** Frames per second. */ 077 @SuppressWarnings("MemberName") 078 public int fps; 079}