Skip to content

Commit 889f00b

Browse files
committed
added imageset plugin
1 parent 8083191 commit 889f00b

32 files changed

+992
-131
lines changed

source/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
imagesets

source/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ configure_file(version.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/AnnotatorLib/${M
1616
set(IDE_FOLDER "")
1717
add_subdirectory(annotatorlib)
1818

19+
add_subdirectory(imagesets)
1920
add_subdirectory(storages)
2021

2122
# Tests

source/annotatorlib/include/AnnotatorLib/ImageSet/ImageSet.h renamed to source/annotatorlib/include/AnnotatorLib/ImageSet/AbstractImageSet.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
1-
// Copyright 2016 Annotator Team
1+
// Copyright 2016-2017 Annotator Team
22
#ifndef ANNOTATOR_ANNOTATORLIB_IMAGESET_H
33
#define ANNOTATOR_ANNOTATORLIB_IMAGESET_H
44

55
/************************************************************
66
ImageSet class header
77
************************************************************/
8+
9+
#include <memory>
810
#include <string>
911

1012
#include <AnnotatorLib/AnnotatorLibDatastructs.h>
1113
#include <AnnotatorLib/Image.h>
1214
#include <AnnotatorLib/annotatorlib_api.h>
1315

1416
namespace AnnotatorLib {
15-
17+
namespace ImageSet {
1618
/************************************************************/
1719

18-
class ANNOTATORLIB_API ImageSet {
20+
class ANNOTATORLIB_API AbstractImageSet {
1921
public:
2022
/**
2123
*
@@ -78,16 +80,17 @@ class ANNOTATORLIB_API ImageSet {
7880

7981
virtual std::string getPath() = 0;
8082

81-
virtual bool equals(ImageSet *other) = 0;
83+
virtual bool equals(std::shared_ptr<AbstractImageSet> other) = 0;
8284

83-
virtual ~ImageSet() {}
85+
virtual ~AbstractImageSet() {}
8486
};
8587
/************************************************************/
8688
/* External declarations (package visibility) */
8789
/************************************************************/
8890

8991
/* Inline functions */
9092

93+
} // of namespace ImageSet
9194
} // of namespace AnnotatorLib
9295

9396
/************************************************************

source/annotatorlib/include/AnnotatorLib/ImageSet/ImageFolder.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
************************************************************/
88

99
#include <AnnotatorLib/AnnotatorLibDatastructs.h>
10-
#include <AnnotatorLib/ImageSet/ImageSet.h>
10+
#include <AnnotatorLib/ImageSet/AbstractImageSet.h>
1111
#include <AnnotatorLib/annotatorlib_api.h>
1212

1313
#include <string>
@@ -16,12 +16,12 @@
1616
#include <boost/filesystem.hpp>
1717

1818
namespace AnnotatorLib {
19-
19+
namespace ImageSet {
2020
/************************************************************/
2121
/**
2222
*
2323
*/
24-
class ANNOTATORLIB_API ImageFolder : public ImageSet {
24+
class ANNOTATORLIB_API ImageFolder : public AbstractImageSet {
2525
public:
2626
ImageFolder(std::string path);
2727

@@ -66,7 +66,7 @@ class ANNOTATORLIB_API ImageFolder : public ImageSet {
6666

6767
virtual std::string getPath() override;
6868

69-
virtual bool equals(ImageSet *other) override;
69+
virtual bool equals(std::shared_ptr<AbstractImageSet> other) override;
7070

7171
protected:
7272
void loadFolder();
@@ -82,7 +82,7 @@ class ANNOTATORLIB_API ImageFolder : public ImageSet {
8282
/************************************************************/
8383

8484
/* Inline functions */
85-
85+
} // of namespace ImageSet
8686
} // of namespace AnnotatorLib
8787

8888
/************************************************************

source/annotatorlib/include/AnnotatorLib/ImageSet/ImageSetFactory.h

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,17 @@
66
ImageSetFactory class header
77
************************************************************/
88

9+
#include <list>
10+
#include <map>
11+
#include <memory>
12+
913
#include <AnnotatorLib/AnnotatorLibDatastructs.h>
14+
#include <AnnotatorLib/ImageSet/AbstractImageSet.h>
15+
#include <AnnotatorLib/ImageSet/ImageSetPlugin.h>
1016
#include <AnnotatorLib/annotatorlib_api.h>
1117

12-
#include <AnnotatorLib/ImageSet/ImageSet.h>
13-
1418
namespace AnnotatorLib {
19+
namespace ImageSet {
1520

1621
/************************************************************/
1722
/**
@@ -24,21 +29,40 @@ class ANNOTATORLIB_API ImageSetFactory {
2429
* @param type
2530
* @return imageSet
2631
*/
27-
static ImageSet *createImageSet(ImageSetType type, std::string path);
32+
std::shared_ptr<AbstractImageSet> createImageSet(std::string type,
33+
std::string path);
34+
35+
std::list<std::string> availableImageSets();
2836

2937
/**
30-
*
31-
* @param type
32-
* @return imageSet
38+
* @brief loadPlugins
39+
* @param dir the path to plugins
3340
*/
34-
static ImageSet *createImageSet(std::string type, std::string path);
41+
void loadPlugins(std::string dir);
42+
43+
/**
44+
* @brief instance
45+
* @return singleton for StorageFactory
46+
*/
47+
static ImageSetFactory* instance();
48+
49+
~ImageSetFactory();
50+
51+
protected:
52+
void addAvailableImageSet(ImageSetPlugin* plugin);
53+
54+
private:
55+
ImageSetFactory() {}
56+
std::list<std::string> _availableImageSets{"images", "imagefolder"};
57+
std::map<std::string, std::shared_ptr<ImageSetPlugin>> plugins;
3558
};
3659
/************************************************************/
3760
/* External declarations (package visibility) */
3861
/************************************************************/
3962

4063
/* Inline functions */
4164

65+
} // of namespace ImageSet
4266
} // of namespace AnnotatorLib
4367

4468
/************************************************************
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Copyright 2017 Annotator Team
2+
#pragma once
3+
4+
#include <memory>
5+
#include <string>
6+
7+
#include <AnnotatorLib/ImageSet/AbstractImageSet.h>
8+
#include <AnnotatorLib/annotatorlib_api.h>
9+
10+
namespace AnnotatorLib {
11+
namespace ImageSet {
12+
13+
/**
14+
* @brief The StoragePlugin class
15+
* Base Class for storage plugins.
16+
*/
17+
class ANNOTATORLIB_API ImageSetPlugin {
18+
public:
19+
ImageSetPlugin() {}
20+
virtual ~ImageSetPlugin() {}
21+
22+
/**
23+
* @brief name
24+
* @return name of the imageset plugin
25+
*/
26+
virtual const std::string name() = 0;
27+
28+
/**
29+
* @brief description
30+
* @return description for the imageset plugin
31+
*/
32+
virtual const std::string description() = 0;
33+
34+
/**
35+
* @brief createLoader
36+
* @return new instance of loader
37+
*/
38+
virtual std::shared_ptr<AnnotatorLib::ImageSet::AbstractImageSet> create(
39+
std::string path) = 0;
40+
};
41+
}
42+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright 2016-2017 Annotator Team
2+
#ifndef PKG_ANNOTATOR_ANNOTATORLIB_IMAGESET
3+
#define PKG_ANNOTATOR_ANNOTATORLIB_IMAGESET
4+
5+
/************************************************************
6+
Pkg_Loader package header
7+
************************************************************/
8+
#include <AnnotatorLib/AnnotatorLibDatastructs.h>
9+
10+
#ifndef _IN_
11+
#define _IN_
12+
#endif
13+
#ifndef _OUT_
14+
#define _OUT_
15+
#endif
16+
#ifndef _INOUT_
17+
#define _INOUT_
18+
#endif
19+
20+
/* Package dependency header include */
21+
22+
namespace AnnotatorLib {
23+
namespace ImageSet {
24+
25+
// Types defined within the package
26+
} // of namespace ImageSet
27+
} // of namespace AnnotatorLib
28+
29+
/************************************************************
30+
End of Pkg_Storage package header
31+
************************************************************/
32+
33+
#endif

source/annotatorlib/include/AnnotatorLib/Project.h

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Project class header
77
************************************************************/
88
#include <AnnotatorLib/AnnotatorLibDatastructs.h>
9-
#include <AnnotatorLib/ImageSet/ImageSet.h>
9+
#include <AnnotatorLib/ImageSet/AbstractImageSet.h>
1010
#include <AnnotatorLib/Session.h>
1111
#include <AnnotatorLib/annotatorlib_api.h>
1212

@@ -27,19 +27,6 @@ class AbstractStorage;
2727
*/
2828
class ANNOTATORLIB_API Project {
2929
public:
30-
/**
31-
* @brief create
32-
* @param name
33-
* @param imageSetType
34-
* @param imageSetPath
35-
* @param storageType
36-
* @param storagePath
37-
* @return
38-
*/
39-
static std::shared_ptr<AnnotatorLib::Project> create(
40-
std::string name, ImageSetType imageSetType, std::string imageSetPath,
41-
std::string storageType, std::string storagePath);
42-
4330
/**
4431
* @brief create
4532
* @param name
@@ -78,7 +65,7 @@ class ANNOTATORLIB_API Project {
7865
*/
7966
unsigned long getDuration();
8067

81-
ImageSet *getImageSet() const;
68+
std::shared_ptr<ImageSet::AbstractImageSet> getImageSet() const;
8269

8370
/**
8471
* @brief load
@@ -149,7 +136,7 @@ class ANNOTATORLIB_API Project {
149136
protected:
150137
Project();
151138

152-
Project(std::string name, ImageSetType imageSetType, std::string imageSetPath,
139+
Project(std::string name, std::string imageSetType, std::string imageSetPath,
153140
std::string storageType, std::string storagePath);
154141

155142
/**
@@ -180,9 +167,9 @@ class ANNOTATORLIB_API Project {
180167

181168
unsigned long total_duration_sec = 0;
182169

183-
ImageSetType imageSetType = ImageSetType::UNKNOWN;
170+
std::string imageSetType = "unknown";
184171

185-
ImageSet *imageSet = nullptr;
172+
std::shared_ptr<ImageSet::AbstractImageSet> imageSet = nullptr;
186173

187174
std::string storageType = "unknown";
188175

source/annotatorlib/source/ImageSet/ImageFolder.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
// Derived includes directives
1919

2020
namespace AnnotatorLib {
21+
namespace ImageSet {
2122

2223
const std::set<std::string> imagetypes = {
2324
(".bmp"), (".pbm"), (".pgm"), (".ppm"), (".jpg"), (".jpeg"),
@@ -72,8 +73,8 @@ unsigned int ImageFolder::getFPS() { return 24; }
7273

7374
std::string ImageFolder::getPath() { return path; }
7475

75-
bool ImageFolder::equals(ImageSet *other) {
76-
if (this == other) return true;
76+
bool ImageFolder::equals(std::shared_ptr<AbstractImageSet> other) {
77+
if (this == other.get()) return true;
7778
if (other->getType() != ImageSetType::IMAGEFOLDER) return false;
7879
if (this->getPath() != other->getPath()) return false;
7980
return true;
@@ -100,7 +101,7 @@ void ImageFolder::loadFolder() {
100101
}
101102

102103
// static attributes (if any)
103-
104+
} // of namespace ImageSet
104105
} // of namespace AnnotatorLib
105106

106107
/************************************************************

0 commit comments

Comments
 (0)