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
17 package com.irurueta.ar.sfm;
18
19 import com.irurueta.ar.slam.BaseCalibrationData;
20
21 import java.io.Serializable;
22
23 /**
24 * Contains base configuration for a two view sparse re-constructor using SLAM
25 * (Simultaneous Location And Mapping) to determine the scale of the scene
26 * (i.e. the baseline or separation between cameras) by fusing both camera data
27 * and data from sensors like an accelerometer or gyroscope.
28 *
29 * @param <C> type defining calibration data.
30 * @param <T> an actual implementation of a configuration class.
31 */
32 public abstract class BaseSlamTwoViewsSparseReconstructorConfiguration<
33 C extends BaseCalibrationData,
34 T extends BaseSlamTwoViewsSparseReconstructorConfiguration<C, T>> extends
35 BaseTwoViewsSparseReconstructorConfiguration<T> implements Serializable {
36
37 /**
38 * Indicates that by default new available SLAM state is notified each time that a whole set of IMU
39 * (Inertial Measurement Unit) data is received (accelerometer, gyroscope and orientation). SLAM state
40 * contains position, velocity, linear acceleration, orientation and angular speed.
41 */
42 public static final boolean DEFAULT_NOTIFY_SLAM_DATA_AVAILABLE = true;
43
44 /**
45 * Indicates that by default any new camera that can be estimated by means of SLAM using IMU data,
46 * will be notified each time that accelerometer, gyroscope and orientation data is received.
47 */
48 public static final boolean DEFAULT_NOTIFY_ESTIMATED_SLAM_CAMERA = true;
49
50 /**
51 * Calibration data for accelerometer and gyroscope.
52 * This data is usually captured and estimated in an offline step previous
53 * to the actual scene reconstruction.
54 * Calibration data is usually obtained by keeping the system in a constant
55 * state of motion (e.g. acceleration and rotation).
56 * If this is null, no calibration data will be used.
57 */
58 private C calibrationData;
59
60 /**
61 * Indicates whether new available SLAM state is notified each time that a whole set of IMU (Inertial
62 * Measurement Unit) data is received.
63 */
64 private boolean notifyAvailableSlamData = DEFAULT_NOTIFY_SLAM_DATA_AVAILABLE;
65
66 /**
67 * Indicates whether any new camera that can be estimated by means of SLAM using IMU data, will be
68 * notified each time that accelerometer, gyroscope and orientation data is received.
69 */
70 private boolean notifyEstimatedSlamCamera = DEFAULT_NOTIFY_ESTIMATED_SLAM_CAMERA;
71
72 /**
73 * Constructor.
74 */
75 protected BaseSlamTwoViewsSparseReconstructorConfiguration() {
76 }
77
78 /**
79 * Gets calibration data for accelerometer and gyroscope.
80 * This data is usually captured and estimated in an offline step previous
81 * to the actual scene reconstruction.
82 * Calibration data is usually obtained by keeping the system in a constant
83 * state of motion (e.g. acceleration and rotation).
84 * If this is null, no calibration data will be used.
85 *
86 * @return calibration data or null.
87 */
88 public C getCalibrationData() {
89 return calibrationData;
90 }
91
92 /**
93 * Specifies calibration data for accelerometer and gyroscope.
94 * This data is usually captured and estimated in an offline step previous
95 * to the actual scene reconstruction.
96 * Calibration data is usually obtained by keeping the system in a constant
97 * state of motion (e.g. acceleration and rotation).
98 * If set to null, no calibration data will be used.
99 *
100 * @param calibrationData calibration data or null.
101 * @return this instance so that method can be easily chained.
102 */
103 public T setCalibrationData(final C calibrationData) {
104 this.calibrationData = calibrationData;
105 //noinspection unchecked
106 return (T) this;
107 }
108
109 /**
110 * Indicates whether new available SLAM state is notified each time that a whole set of IMU (Inertial
111 * Measurement Unit) data is received. IMU data contains accelerometer, gyroscope and orientation
112 * samples.
113 *
114 * @return true if new available SLAM state is notified each time that a whole set of IMU data is
115 * received.
116 */
117 public boolean isNotifyAvailableSlamDataEnabled() {
118 return notifyAvailableSlamData;
119 }
120
121 /**
122 * Specifies whether new available SLAM state is notified each time that a whole set of IMU (Inertial
123 * Measurement Unit) data is received. IMU data contains accelerometer, gyroscope and orientation
124 * samples.
125 *
126 * @param notifyAvailableSlamData true is new available SLAM state is notified each time that a whole
127 * set of IMU data is received, false otherwise.
128 * @return this instance so that method can be easily chained.
129 */
130 public T setNotifyAvailableSlamDataEnabled(final boolean notifyAvailableSlamData) {
131 this.notifyAvailableSlamData = notifyAvailableSlamData;
132
133 //noinspection unchecked
134 return (T) this;
135 }
136
137 /**
138 * Indicates whether any new camera that can be estimated by means of SLAM using IMU data, will be
139 * notified each time that accelerometer, gyroscope and orientation data is received.
140 *
141 * @return true if any newly estimated camera is notified, false otherwise.
142 */
143 public boolean isNotifyEstimatedSlamCameraEnabled() {
144 return notifyEstimatedSlamCamera;
145 }
146
147 /**
148 * Specifies whether any new camera that can be estimated by means of SLAM using IMU data, will be
149 * notified each time that accelerometer, gyroscope and orientation data is received.
150 *
151 * @param notifyEstimatedSlamCamera true if any newly estimated camera is notified, false otherwise.
152 * @return this instance so that method can be easily chained.
153 */
154 public T setNotifyEstimatedSlamCameraEnabled(final boolean notifyEstimatedSlamCamera) {
155 this.notifyEstimatedSlamCamera = notifyEstimatedSlamCamera;
156
157 //noinspection unchecked
158 return (T) this;
159 }
160 }