View Javadoc
1   /*
2    * Copyright (C) 2017 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  
20  /**
21   * Contains configuration for a two view sparse re-constructor assuming that the
22   * baseline (separation between cameras) is known.
23   */
24  public class KnownBaselineTwoViewsSparseReconstructorConfiguration extends
25          BaseTwoViewsSparseReconstructorConfiguration<KnownBaselineTwoViewsSparseReconstructorConfiguration> implements
26          Serializable {
27  
28      /**
29       * Default camera baseline (expressed in a unit of distance such as meters).
30       * Methods such as DIAC or Essential assume that the camera baseline is 1.0,
31       * which yields a reconstruction up to scale, unless the real baseline is
32       * provided.
33       */
34      public static final double DEFAULT_BASELINE = 1.0;
35  
36      /**
37       * Camera baseline (expressed in a unit of distance such as meters).
38       * Contains the real separation between camera centers so that the real
39       * scale of cameras and reconstructed points can be retrieved.
40       */
41      private double baseline = DEFAULT_BASELINE;
42  
43      /**
44       * Creates an instance of a two views sparse re-constructor configuration
45       * with known camera baseline.
46       *
47       * @return configuration instance.
48       */
49      public static KnownBaselineTwoViewsSparseReconstructorConfiguration make() {
50          return new KnownBaselineTwoViewsSparseReconstructorConfiguration();
51      }
52  
53      /**
54       * Gets camera baseline (expressed in a unit of distance such as meters).
55       * Contains the real separation between camera centers so that the real
56       * scale of cameras and reconstructed points can be retrieved.
57       *
58       * @return camera baseline.
59       */
60      public double getBaseline() {
61          return baseline;
62      }
63  
64      /**
65       * Sets camera baseline (expressed in a unit of distance such as meters).
66       * Contains the real separation between camera centers so that the real
67       * scale of cameras and reconstructed points can be retrieved.
68       *
69       * @param baseline camera baseline.
70       * @return this instance so that method can be easily chained.
71       */
72      public KnownBaselineTwoViewsSparseReconstructorConfiguration setBaseline(final double baseline) {
73          this.baseline = baseline;
74          return this;
75      }
76  }