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.calibration; 019 020import com.fasterxml.jackson.annotation.JsonCreator; 021import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 022import com.fasterxml.jackson.annotation.JsonProperty; 023import edu.wpi.first.math.geometry.Pose3d; 024import java.nio.file.Path; 025import java.util.List; 026import org.jetbrains.annotations.Nullable; 027import org.opencv.core.Point; 028import org.opencv.core.Point3; 029 030// Ignore the previous calibration data that was stored in the json file. 031@JsonIgnoreProperties(ignoreUnknown = true) 032public final class BoardObservation implements Cloneable { 033 // Expected feature 3d location in the camera frame 034 @JsonProperty("locationInObjectSpace") 035 public List<Point3> locationInObjectSpace; 036 037 // Observed location in pixel space 038 @JsonProperty("locationInImageSpace") 039 public List<Point> locationInImageSpace; 040 041 // (measured location in pixels) - (expected from FK) 042 @JsonProperty("reprojectionErrors") 043 public List<Point> reprojectionErrors; 044 045 // Solver optimized board poses 046 @JsonProperty("optimisedCameraToObject") 047 public Pose3d optimisedCameraToObject; 048 049 // If we should use this observation when re-calculating camera calibration 050 @JsonProperty("includeObservationInCalibration") 051 public boolean includeObservationInCalibration; 052 053 @JsonProperty("snapshotName") 054 public String snapshotName; 055 056 @JsonProperty("snapshotDataLocation") 057 @Nullable 058 public Path snapshotDataLocation; 059 060 @JsonCreator 061 public BoardObservation( 062 @JsonProperty("locationInObjectSpace") List<Point3> locationInObjectSpace, 063 @JsonProperty("locationInImageSpace") List<Point> locationInImageSpace, 064 @JsonProperty("reprojectionErrors") List<Point> reprojectionErrors, 065 @JsonProperty("optimisedCameraToObject") Pose3d optimisedCameraToObject, 066 @JsonProperty("includeObservationInCalibration") boolean includeObservationInCalibration, 067 @JsonProperty("snapshotName") String snapshotName, 068 @JsonProperty("snapshotDataLocation") Path snapshotDataLocation) { 069 this.locationInObjectSpace = locationInObjectSpace; 070 this.locationInImageSpace = locationInImageSpace; 071 this.reprojectionErrors = reprojectionErrors; 072 this.optimisedCameraToObject = optimisedCameraToObject; 073 this.includeObservationInCalibration = includeObservationInCalibration; 074 this.snapshotName = snapshotName; 075 this.snapshotDataLocation = snapshotDataLocation; 076 } 077 078 @Override 079 public String toString() { 080 return "BoardObservation [locationInObjectSpace=" 081 + locationInObjectSpace 082 + ", locationInImageSpace=" 083 + locationInImageSpace 084 + ", reprojectionErrors=" 085 + reprojectionErrors 086 + ", optimisedCameraToObject=" 087 + optimisedCameraToObject 088 + ", includeObservationInCalibration=" 089 + includeObservationInCalibration 090 + ", snapshotName=" 091 + snapshotName 092 + ", snapshotDataLocation=" 093 + snapshotDataLocation 094 + "]"; 095 } 096 097 @Override 098 public BoardObservation clone() { 099 try { 100 return (BoardObservation) super.clone(); 101 } catch (CloneNotSupportedException e) { 102 System.err.println("Guhhh clone buh"); 103 return null; 104 } 105 } 106}