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 java.util.List; 20 21 /** 22 * Listener to retrieve and store required data to compute a 3D reconstruction 23 * from sparse image point correspondences in two views. 24 * 25 * @param <R> type of re-constructor. 26 */ 27 public interface BaseTwoViewsSparseReconstructorListener<R extends BaseTwoViewsSparseReconstructor<?, ?, ?>> { 28 /** 29 * Called to determine whether there are more views available to attempt to 30 * use for the reconstruction. 31 * 32 * @param reconstructor re-constructor raising this event. 33 * @return true if there are more views available, false otherwise. 34 */ 35 boolean hasMoreViewsAvailable(final R reconstructor); 36 37 /** 38 * Called when samples containing points of interest for current view must 39 * be retrieved. 40 * 41 * @param reconstructor re-constructor raising this event. 42 * @param viewId id of view where points will be used. 43 * @param samples samples containing points of interest for current view to 44 * test. 45 */ 46 void onRequestSamplesForCurrentView(final R reconstructor, final int viewId, final List<Sample2D> samples); 47 48 /** 49 * Called when requested samples have been accepted. 50 * This method can be used to determine whether samples can be stored or 51 * not. 52 * 53 * @param reconstructor re-constructor raising this event. 54 * @param viewId id of view whose samples have been accepted. 55 * @param samples accepted samples. 56 */ 57 void onSamplesAccepted(final R reconstructor, final int viewId, final List<Sample2D> samples); 58 59 /** 60 * Called when requested samples have been rejected. 61 * This method can be used to remove provided samples. 62 * 63 * @param reconstructor re-constructor raising this event. 64 * @param viewId id of view whose samples have been rejected. 65 * @param samples rejected samples. 66 */ 67 void onSamplesRejected(final R reconstructor, final int viewId, final List<Sample2D> samples); 68 69 /** 70 * Finds matches for provided samples. 71 * 72 * @param reconstructor re-constructor raising this event. 73 * @param samples1 samples on first view. 74 * @param samples2 samples on second view. 75 * @param viewId1 id of first view. 76 * @param viewId2 id of second view. 77 * @param matches instance where matches must be stored. 78 */ 79 void onRequestMatches(final R reconstructor, final List<Sample2D> samples1, final List<Sample2D> samples2, 80 final int viewId1, final int viewId2, final List<MatchedSamples> matches); 81 82 /** 83 * Called when a fundamental matrix relating two views has been estimated. 84 * This event can be used to store estimated fundamental matrix relating 85 * two views. 86 * 87 * @param reconstructor re-constructor raising this event. 88 * @param estimatedFundamentalMatrix estimated fundamental matrix. 89 */ 90 void onFundamentalMatrixEstimated(final R reconstructor, 91 final EstimatedFundamentalMatrix estimatedFundamentalMatrix); 92 93 /** 94 * Notifies when cameras for provided matched pair of views have been 95 * estimated. This event can be used to store points associated to such 96 * view. 97 * 98 * @param reconstructor re-constructor raising this event. 99 * @param viewId1 id of first view. 100 * @param viewId2 id of second view. 101 * @param camera1 estimated camera for first view. 102 * @param camera2 estimated camera for second view. 103 */ 104 void onCamerasEstimated(final R reconstructor, final int viewId1, final int viewId2, final EstimatedCamera camera1, 105 final EstimatedCamera camera2); 106 107 /** 108 * Called when reconstructed points have been estimated from a series of 2D 109 * matches. This event can be used to store reconstructed points and their 110 * associated data. 111 * 112 * @param reconstructor re-constructor raising this event. 113 * @param matches 2D matches associated to estimated reconstructed points. 114 * @param points reconstructed 3D points. 115 */ 116 void onReconstructedPointsEstimated(final R reconstructor, final List<MatchedSamples> matches, 117 final List<ReconstructedPoint3D> points); 118 119 /** 120 * Called when reconstruction starts. 121 * 122 * @param reconstructor re-constructor raising this event. 123 */ 124 void onStart(final R reconstructor); 125 126 /** 127 * Called when reconstruction stops. 128 * 129 * @param reconstructor re-constructor raising this event. 130 */ 131 void onFinish(final R reconstructor); 132 133 /** 134 * Called when reconstruction is cancelled before it has finished. 135 * 136 * @param reconstructor re-constructor raising this event. 137 */ 138 void onCancel(final R reconstructor); 139 140 /** 141 * Called when reconstruction fails. 142 * 143 * @param reconstructor re-constructor raising this event. 144 */ 145 void onFail(final R reconstructor); 146 }