View Javadoc
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 java.io.Serializable;
19  import java.util.BitSet;
20  
21  /**
22   * Contains data relating matched 2D points and their reconstructions.
23   */
24  public class MatchedSamples implements Serializable {
25  
26      /**
27       * Default quality score value.
28       */
29      public static final double DEFAULT_QUALITY_SCORE = 1.0;
30  
31      /**
32       * 2D matched samples on different views.
33       * Each of these points correspond to projections of the same 3D point into
34       * different views.
35       */
36      private Sample2D[] samples;
37  
38      /**
39       * Cameras associated to the views of each of the matched points.
40       */
41      private EstimatedCamera[] cameras;
42  
43      /**
44       * ID's of views where matched points belong to.
45       */
46      private int[] viewIds;
47  
48      /**
49       * 3D reconstructed point. Initially, might not be available
50       */
51      private ReconstructedPoint3D reconstructedPoint;
52  
53      /**
54       * Quality score of a match.
55       */
56      private double qualityScore = DEFAULT_QUALITY_SCORE;
57  
58      /**
59       * Indicates whether match between a pair of views has been considered an
60       * inlier or not.
61       * Position 0 of this bitset corresponds to viewIds in positions 0 and 1,
62       * position 1 of bitset corresponds to viewIds in positions 1 and 2, and so
63       * on.
64       */
65      private BitSet inliers;
66  
67      /**
68       * Gets 2D matched samples on different views containing matched points.
69       * Each of these points correspond to projections of the same 3D point into
70       * different views.
71       *
72       * @return 2D matched samples on different views.
73       */
74      public Sample2D[] getSamples() {
75          return samples;
76      }
77  
78      /**
79       * Sets 2D matched samples on different views containing matched points.
80       * Each of these points correspond to projections of the same 3D point into
81       * different views.
82       *
83       * @param samples 2D matched samples on different views.
84       */
85      public void setSamples(final Sample2D[] samples) {
86          this.samples = samples;
87      }
88  
89      /**
90       * Gets cameras associated to the views of each of the matched points.
91       *
92       * @return cameras associated to the views of each of the matched points.
93       */
94      public EstimatedCamera[] getCameras() {
95          return cameras;
96      }
97  
98      /**
99       * Sets cameras associated to the views of each of the matched points.
100      *
101      * @param cameras cameras associated to the views of each of the matched
102      *                points.
103      */
104     public void setCameras(final EstimatedCamera[] cameras) {
105         this.cameras = cameras;
106     }
107 
108     /**
109      * Gets id's of views where matched points belong to.
110      *
111      * @return id's of view where matched points belong to.
112      */
113     public int[] getViewIds() {
114         return viewIds;
115     }
116 
117     /**
118      * Sets id's of views where matched points belong to.
119      *
120      * @param viewIds id's of views where matched points belong to.
121      */
122     public void setViewIds(final int[] viewIds) {
123         this.viewIds = viewIds;
124     }
125 
126     /**
127      * Gets 3D reconstructed point.
128      *
129      * @return 3D reconstructed point.
130      */
131     public ReconstructedPoint3D getReconstructedPoint() {
132         return reconstructedPoint;
133     }
134 
135     /**
136      * Sets 3D reconstructed point.
137      *
138      * @param reconstructedPoint 3D reconstructed point.
139      */
140     public void setReconstructedPoint(final ReconstructedPoint3D reconstructedPoint) {
141         this.reconstructedPoint = reconstructedPoint;
142         if (samples != null) {
143             for (final var sample : samples) {
144                 sample.setReconstructedPoint(reconstructedPoint);
145             }
146         }
147     }
148 
149     /**
150      * Gets quality score of match. The larger the value, the better the
151      * quality. This is used for robust estimators such as PROSAC or PROMedS.
152      * This value is typically obtained from algorithms determining scores for
153      * matches.
154      *
155      * @return quality score of match.
156      */
157     public double getQualityScore() {
158         return qualityScore;
159     }
160 
161     /**
162      * Sets quality score of match. The larger the value, the better the
163      * quality. This is used for robust estimators such as PROSAC or PROMedS.
164      * This value is typically obtained from algorithms determining scores for
165      * matches.
166      *
167      * @param qualityScore quality score of match.
168      */
169     public void setQualityScore(final double qualityScore) {
170         this.qualityScore = qualityScore;
171     }
172 
173     /**
174      * Indicates whether match between a pair of views has been considered an
175      * inlier or not.
176      * Position 0 of this bitset corresponds to viewIds in positions 0 and 1,
177      * position 1 of bitset corresponds to viewIds in positions 1 and 2, and so
178      * on.
179      *
180      * @return indicates whether match between a pair of views has been
181      * considered an inlier or not.
182      */
183     public BitSet getInliers() {
184         return inliers;
185     }
186 
187     /**
188      * Specifies whether match between a pair of views has been considered an
189      * inlier or not.
190      * Position 0 of this bitset corresponds to viewIds in positions 0 and 1,
191      * position 1 of bitset corresponds to viewIds in positions 1 and 2, and so
192      * on.
193      *
194      * @param inliers set indicating whether a match between a pair of views has
195      *                been considered an inlier or not.
196      */
197     public void setInliers(final BitSet inliers) {
198         this.inliers = inliers;
199     }
200 }