001/* 002 * Copyright (C) Photon Vision. 003 * 004 * This program is free software: you can redistribute it and/or modify 005 * it under the terms of the GNU General Public License as published by 006 * the Free Software Foundation, either version 3 of the License, or 007 * (at your option) any later version. 008 * 009 * This program is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 012 * GNU General Public License for more details. 013 * 014 * You should have received a copy of the GNU General Public License 015 * along with this program. If not, see <https://www.gnu.org/licenses/>. 016 */ 017 018package org.photonvision.vision.aruco; 019 020import java.util.Arrays; 021import org.photonvision.common.logging.LogGroup; 022import org.photonvision.common.logging.Logger; 023 024public class ArucoDetectionResult { 025 private static final Logger logger = 026 new Logger(ArucoDetectionResult.class, LogGroup.VisionModule); 027 028 private final double[] xCorners; 029 private final double[] yCorners; 030 031 private final int id; 032 033 public ArucoDetectionResult(double[] xCorners, double[] yCorners, int id) { 034 this.xCorners = xCorners; 035 this.yCorners = yCorners; 036 this.id = id; 037 // logger.debug("Creating a new detection result: " + this.toString()); 038 } 039 040 public double[] getXCorners() { 041 return xCorners; 042 } 043 044 public double[] getYCorners() { 045 return yCorners; 046 } 047 048 public int getId() { 049 return id; 050 } 051 052 public double getCenterX() { 053 return (xCorners[0] + xCorners[1] + xCorners[2] + xCorners[3]) / 4.0; 054 } 055 056 public double getCenterY() { 057 return (yCorners[0] + yCorners[1] + yCorners[2] + yCorners[3]) / 4.0; 058 } 059 060 @Override 061 public String toString() { 062 return "ArucoDetectionResult{" 063 + "xCorners=" 064 + Arrays.toString(xCorners) 065 + ", yCorners=" 066 + Arrays.toString(yCorners) 067 + ", id=" 068 + id 069 + '}'; 070 } 071}