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.ar.epipolar.FundamentalMatrix; 20 21 import java.io.Serializable; 22 import java.util.BitSet; 23 import java.util.List; 24 25 /** 26 * Contains data of estimated fundamental matrix. 27 */ 28 public class EstimatedFundamentalMatrix implements Serializable { 29 30 /** 31 * Default quality score value. 32 */ 33 public static final double DEFAULT_QUALITY_SCORE = 1.0; 34 35 /** 36 * ID to identify this instance. This is useful in case that this data is 37 * stored in some sort of database and must be set externally. 38 */ 39 private String id; 40 41 /** 42 * Estimated fundamental matrix. 43 */ 44 private FundamentalMatrix fundamentalMatrix; 45 46 /** 47 * Quality score of estimated fundamental matrix. The larger the value, 48 * the better the quality. 49 */ 50 private double qualityScore = DEFAULT_QUALITY_SCORE; 51 52 /** 53 * Covariance of estimated fundamental matrix. This can be computed during 54 * estimation. 55 */ 56 private Matrix covariance; 57 58 /** 59 * ID of first view related by fundamental matrix. 60 */ 61 private int viewId1; 62 63 /** 64 * ID of second view related by fundamental matrix. 65 */ 66 private int viewId2; 67 68 /** 69 * Indicates which samples used for fundamental matrix estimation where 70 * considered inliers. 71 */ 72 private BitSet inliers; 73 74 /** 75 * Left samples used for fundamental matrix estimation. 76 */ 77 private List<Sample2D> leftSamples; 78 79 /** 80 * Right samples used for fundamental matrix estimation. 81 */ 82 private List<Sample2D> rightSamples; 83 84 /** 85 * Gets id to identify this instance. This is useful in case that this data 86 * is stored in some sort of database and must be set externally. 87 * 88 * @return id to identify this instance. 89 */ 90 public String getId() { 91 return id; 92 } 93 94 /** 95 * Sets id to identify this instance. This is useful in case that this data 96 * is stored in some sort of database and must be set externally. 97 * 98 * @param id id to identify this instance. 99 */ 100 public void setId(final String id) { 101 this.id = id; 102 } 103 104 /** 105 * Gets estimated fundamental matrix. 106 * 107 * @return estimated fundamental matrix. 108 */ 109 public FundamentalMatrix getFundamentalMatrix() { 110 return fundamentalMatrix; 111 } 112 113 /** 114 * Sets estimated fundamental matrix. 115 * 116 * @param fundamentalMatrix estimated fundamental matrix. 117 */ 118 public void setFundamentalMatrix(final FundamentalMatrix fundamentalMatrix) { 119 this.fundamentalMatrix = fundamentalMatrix; 120 } 121 122 /** 123 * Gets quality score of estimated fundamental matrix. The larger the value, 124 * the better the quality. 125 * 126 * @return quality score of estimated fundamental matrix. 127 */ 128 public double getQualityScore() { 129 return qualityScore; 130 } 131 132 /** 133 * Sets quality score of estimated fundamental matrix. The larger the value, 134 * the better the quality. 135 * 136 * @param qualityScore quality score of estimated fundamental matrix. 137 */ 138 public void setQualityScore(final double qualityScore) { 139 this.qualityScore = qualityScore; 140 } 141 142 /** 143 * Gets covariance of estimated fundamental matrix. This can be computed 144 * during estimation. 145 * 146 * @return covariance of estimated fundamental matrix. 147 */ 148 public Matrix getCovariance() { 149 return covariance; 150 } 151 152 /** 153 * Sets covariance of estimated fundamental matrix. This can be computed 154 * during estimation. 155 * 156 * @param covariance covariance of estimated fundamental matrix. 157 */ 158 public void setCovariance(final Matrix covariance) { 159 this.covariance = covariance; 160 } 161 162 /** 163 * Gets id of first view related by fundamental matrix. 164 * 165 * @return id of first view related by fundamental matrix. 166 */ 167 public int getViewId1() { 168 return viewId1; 169 } 170 171 /** 172 * Sets id of first view related by fundamental matrix. 173 * 174 * @param viewId1 id of first view related by fundamental matrix. 175 */ 176 public void setViewId1(final int viewId1) { 177 this.viewId1 = viewId1; 178 } 179 180 /** 181 * Gets id of second view related by fundamental matrix. 182 * 183 * @return id of second view related by fundamental matrix. 184 */ 185 public int getViewId2() { 186 return viewId2; 187 } 188 189 /** 190 * Sets id of second view related by fundamental matrix. 191 * 192 * @param viewId2 id of second view related by fundamental matrix. 193 */ 194 public void setViewId2(final int viewId2) { 195 this.viewId2 = viewId2; 196 } 197 198 /** 199 * Indicates which samples used for fundamental matrix estimation where 200 * considered inliers. 201 * 202 * @return which samples used for fundamental matrix estimation where 203 * considered inliers. 204 */ 205 public BitSet getInliers() { 206 return inliers; 207 } 208 209 /** 210 * Specifies which samples used for fundamental matrix estimation where 211 * considered inliers. 212 * 213 * @param inliers which samples used for fundamental matrix estimation where 214 * considered inliers. 215 */ 216 public void setInliers(final BitSet inliers) { 217 this.inliers = inliers; 218 } 219 220 /** 221 * Gets left samples used for fundamental matrix estimation. 222 * 223 * @return left samples used for fundamental matrix estimation. 224 */ 225 public List<Sample2D> getLeftSamples() { 226 return leftSamples; 227 } 228 229 /** 230 * Sets left samples used for fundamental matrix estimation. 231 * 232 * @param leftSamples left samples used for fundamental matrix estimation. 233 */ 234 public void setLeftSamples(final List<Sample2D> leftSamples) { 235 this.leftSamples = leftSamples; 236 } 237 238 /** 239 * Gets right samples used for fundamental matrix estimation. 240 * 241 * @return right samples used for fundamental matrix estimation. 242 */ 243 public List<Sample2D> getRightSamples() { 244 return rightSamples; 245 } 246 247 /** 248 * Sets right samples used for fundamental matrix estimation. 249 * 250 * @param rightSamples right samples used for fundamental matrix estimation. 251 */ 252 public void setRightSamples(final List<Sample2D> rightSamples) { 253 this.rightSamples = rightSamples; 254 } 255 }