View Javadoc

1   /**
2    * Copyright (c) 2011, The University of Southampton and the individual contributors.
3    * All rights reserved.
4    *
5    * Redistribution and use in source and binary forms, with or without modification,
6    * are permitted provided that the following conditions are met:
7    *
8    *   * 	Redistributions of source code must retain the above copyright notice,
9    * 	this list of conditions and the following disclaimer.
10   *
11   *   *	Redistributions in binary form must reproduce the above copyright notice,
12   * 	this list of conditions and the following disclaimer in the documentation
13   * 	and/or other materials provided with the distribution.
14   *
15   *   *	Neither the name of the University of Southampton nor the names of its
16   * 	contributors may be used to endorse or promote products derived from this
17   * 	software without specific prior written permission.
18   *
19   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20   * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21   * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
23   * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24   * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25   * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26   * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27   * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28   * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29   */
30  package org.openimaj.tools.imagecollection.collection;
31  
32  import java.util.List;
33  import org.openimaj.image.Image;
34  import org.openimaj.tools.imagecollection.collection.config.ImageCollectionConfig;
35  
36  /**
37   * An image collection knows how to load itself from a given type of configuration. 
38   * Image collections are iterable and they can also give all their stored images at once
39   * @author Sina Samangooei (ss@ecs.soton.ac.uk)
40   *
41   * @param <ImageType>
42   */
43  public interface ImageCollection<ImageType extends Image<?,ImageType>> extends Iterable<ImageCollectionEntry<ImageType>>{
44  	/**
45  	 * Setup this collection using the provided collection config.
46  	 * @param config
47  	 * @throws ImageCollectionSetupException 
48  	 */
49  	public void setup(ImageCollectionConfig config) throws ImageCollectionSetupException;
50  	/**
51  	 * Is the contents of the provided image colleciton config sufficient for this collection to run. 
52  	 * 
53  	 * @param config
54  	 * @return < 0 if this collection is not useable with this configuration. >= 0 otherwise, higher numbers 
55  	 * give a clue as to ability to deal with configuration when compared to other collections
56  	 */
57  	public int useable(ImageCollectionConfig config);
58  	
59  	/**
60  	 * Given a raw string which might define a URL, file location or whatever, can this collection construct a default configuration
61  	 * which works.
62  	 * 
63  	 * @param rawInput string
64  	 * @return < 0 if this collection is not useable with this configuration. >= 0 otherwise, higher numbers 
65  	 * give a clue as to ability to deal with configuration when compared to other collections
66  	 */
67  	public int useable(String rawInput);
68  	
69  	/**
70  	 * If possible, will return a default configuration using the raw input
71  	 * 
72  	 * @param rawInput string
73  	 * @return a default configuration, might be null if the raw input is not useable
74  	 */
75  	public ImageCollectionConfig defaultConfig(String rawInput);
76  	
77  	/**
78  	 * @return List of all images in this collection
79  	 */
80  	public List<ImageCollectionEntry<ImageType>> getAll();
81  	
82  	/**
83  	 * @return The number of images in this collection (might be an estimate or 0, don't rely on this)
84  	 */
85  	public int countImages();
86  	
87  	/**
88  	 * Control how an image collection is to accept or ignore a given entry of the collection
89  	 * @param selection
90  	 */
91  	public void setEntrySelection(ImageCollectionEntrySelection<ImageType> selection);
92  	
93  }