1 /* 2 * Copyright (C) 2016 Alberto Irurueta Carro (alberto@irurueta.com) 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.irurueta.ar.sfm; 17 18 import com.irurueta.algebra.Matrix; 19 import com.irurueta.geometry.Point2D; 20 21 import java.io.Serializable; 22 23 /** 24 * Contains data of a 2D point sample on a given view. 25 */ 26 public class Sample2D implements Serializable { 27 28 /** 29 * Default quality score value. 30 */ 31 public static final double DEFAULT_QUALITY_SCORE = 1.0; 32 33 /** 34 * ID to identify this instance. This is useful in case that this data is 35 * stored in some sort of database and must be set externally. 36 */ 37 private String id; 38 39 /** 40 * ID of view where 2D point has been sampled. 41 */ 42 private int viewId; 43 44 /** 45 * 2D sampled point coordinates. 46 */ 47 private Point2D point; 48 49 /** 50 * 3D reconstructed point. 51 */ 52 private ReconstructedPoint3D reconstructedPoint; 53 54 /** 55 * Quality score of sampled point. The larger the value, the 56 * better the quality. This is used for robust estimators such 57 * as PROSAC or PROMedS. 58 * This value is typically obtained from algorithms determining quality of 59 * points of interest. 60 */ 61 private double qualityScore = DEFAULT_QUALITY_SCORE; 62 63 /** 64 * Covariance of sampled points. This is obtained from the algorithms 65 * determining points of interest or point correspondences. 66 * If covariance cannot be determined, a typical value might be to 67 * consider 1 pixel accuracy. 68 * This might be null if covariance cannot be determined. 69 */ 70 private Matrix covariance; 71 72 /** 73 * Color data of sampled point (i.e. RGB or YUV values), if available. 74 */ 75 private PointColorData colorData; 76 77 /** 78 * Gets id to identify this instance. This is useful in case that this data 79 * is stored in some sort of database and must be set externally. 80 * 81 * @return id to identify this instance. 82 */ 83 public String getId() { 84 return id; 85 } 86 87 /** 88 * Sets id to identify this instance. This is useful in case that this data 89 * is stored in some sort of database and must be set externally. 90 * 91 * @param id id to identify this instance. 92 */ 93 public void setId(final String id) { 94 this.id = id; 95 } 96 97 /** 98 * Gets id of view where 2D point has been sampled. 99 * 100 * @return id of view where 2D point has been sampled. 101 */ 102 public int getViewId() { 103 return viewId; 104 } 105 106 /** 107 * Sets id of view where 2D point has been sampled. 108 * 109 * @param viewId id of view where 2D point has been sampled. 110 */ 111 public void setViewId(final int viewId) { 112 this.viewId = viewId; 113 } 114 115 /** 116 * Gets 2D sampled point coordinates. 117 * 118 * @return 2D sampled point coordinates. 119 */ 120 public Point2D getPoint() { 121 return point; 122 } 123 124 /** 125 * Sets 2D sampled point coordinates. 126 * 127 * @param point 2D sampled point coordinates. 128 */ 129 public void setPoint(final Point2D point) { 130 this.point = point; 131 } 132 133 /** 134 * Gets 3D reconstructed point. 135 * 136 * @return 3D reconstructed point. 137 */ 138 public ReconstructedPoint3D getReconstructedPoint() { 139 return reconstructedPoint; 140 } 141 142 /** 143 * Sets 3D reconstructed point. 144 * 145 * @param reconstructedPoint 3D reconstructed point. 146 */ 147 public void setReconstructedPoint(final ReconstructedPoint3D reconstructedPoint) { 148 this.reconstructedPoint = reconstructedPoint; 149 } 150 151 /** 152 * Gets quality score of sampled point. The larger the value, the 153 * better the quality. This is used for robust estimators such as 154 * PROSAC or PROMEdS. 155 * This value is typically obtained from algorithms determining quality of 156 * points of interest. 157 * 158 * @return quality score of sampled point. 159 */ 160 public double getQualityScore() { 161 return qualityScore; 162 } 163 164 /** 165 * Sets quality score of sampled point. The larger the value, the better 166 * the quality. This is used for robust estimators such as PROSAC or 167 * PROMedS. 168 * This value is typically obtained from algorithms determining quality of 169 * points of interest. 170 * 171 * @param qualityScore quality score of sampled point. 172 */ 173 public void setQualityScore(final double qualityScore) { 174 this.qualityScore = qualityScore; 175 } 176 177 /** 178 * Gets covariance of sampled points. This is obtained from the algorithms 179 * determining points of interest or point correspondences. 180 * If covariance cannot be determined, a typical value might be to 181 * consider 1 pixel accuracy. 182 * This might be null if covariance cannot be determined. 183 * 184 * @return covariance of sampled points or null. 185 */ 186 public Matrix getCovariance() { 187 return covariance; 188 } 189 190 /** 191 * Sets covariance of sampled points. This is obtained from the algorithms 192 * determining points of interest or point correspondences. 193 * If covariance cannot be determined, a typical value might be to 194 * consider 1 pixel accuracy. 195 * This might be null if covariance cannot be determined. 196 * 197 * @param covariance covariance of sampled points. 198 */ 199 public void setCovariance(final Matrix covariance) { 200 this.covariance = covariance; 201 } 202 203 /** 204 * Gets color data of sampled point (i.e. RGB or YUV values), if available. 205 * 206 * @return color data of sampled point or null. 207 */ 208 public PointColorData getColorData() { 209 return colorData; 210 } 211 212 /** 213 * Sets color data of sampled point (i.e. RGB or YUV values), if available. 214 * 215 * @param colorData color data of sampled point or null. 216 */ 217 public void setColorData(final PointColorData colorData) { 218 this.colorData = colorData; 219 } 220 }