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 org.wpilib.vision.camera; 006 007import java.util.Objects; 008import org.wpilib.util.PixelFormat; 009 010/** Video mode. */ 011public class VideoMode { 012 /** 013 * Create a new video mode. 014 * 015 * @param pixelFormat The pixel format enum as an integer. 016 * @param width The image width in pixels. 017 * @param height The image height in pixels. 018 * @param fps The camera's frames per second. 019 */ 020 public VideoMode(int pixelFormat, int width, int height, int fps) { 021 this.pixelFormat = PixelFormat.getFromInt(pixelFormat); 022 this.width = width; 023 this.height = height; 024 this.fps = fps; 025 } 026 027 /** 028 * Create a new video mode. 029 * 030 * @param pixelFormat The pixel format. 031 * @param width The image width in pixels. 032 * @param height The image height in pixels. 033 * @param fps The camera's frames per second. 034 */ 035 public VideoMode(PixelFormat pixelFormat, int width, int height, int fps) { 036 this.pixelFormat = pixelFormat; 037 this.width = width; 038 this.height = height; 039 this.fps = fps; 040 } 041 042 /** Pixel format. */ 043 public PixelFormat pixelFormat; 044 045 /** Width in pixels. */ 046 public int width; 047 048 /** Height in pixels. */ 049 public int height; 050 051 /** Frames per second. */ 052 public int fps; 053 054 @Override 055 public boolean equals(Object other) { 056 if (this == other) { 057 return true; 058 } 059 if (other == null) { 060 return false; 061 } 062 063 return other instanceof VideoMode mode 064 && pixelFormat == mode.pixelFormat 065 && width == mode.width 066 && height == mode.height 067 && fps == mode.fps; 068 } 069 070 @Override 071 public int hashCode() { 072 return Objects.hash(pixelFormat, width, height, fps); 073 } 074}