View Javadoc
1   /*
2    * Copyright (C) 2015 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.calibration;
17  
18  import com.irurueta.geometry.Point2D;
19  
20  import java.util.List;
21  
22  /**
23   * Abstract representation of the 2D samples contained in a pattern.
24   * Implementations for each pattern type will return the ideal coordinates
25   * of a pattern to be used for camera calibration.
26   * Coordinates of points returned by a pattern will be measured values in
27   * the real world (expressed in meters). Measures are ideal values not affected
28   * by any kind of distortion and as precise as possible, so they can be used for
29   * camera calibration.
30   */
31  public abstract class Pattern2D {
32  
33      /**
34       * Returns ideal points coordinates contained in a pattern and expressed
35       * in meters. These values are use for calibration purposes.
36       *
37       * @return ideal points coordinates.
38       */
39      public abstract List<Point2D> getIdealPoints();
40  
41      /**
42       * Returns number of 2D points used by this pattern.
43       *
44       * @return number of 2D points used by this pattern.
45       */
46      public abstract int getNumberOfPoints();
47  
48      /**
49       * Returns type of pattern.
50       *
51       * @return type of pattern.
52       */
53      public abstract Pattern2DType getType();
54  
55      /**
56       * Creates an instance of a 2D pattern using provided type.
57       *
58       * @param type type of 2D pattern to create.
59       * @return an instance of a 2D pattern.
60       */
61      public static Pattern2D create(final Pattern2DType type) {
62          return type == Pattern2DType.QR ? new QRPattern2D() : new CirclesPattern2D();
63      }
64  }