Skip to content

Commit 47131fd

Browse files
committed
Merge pull request #84 from avdmitry/datasetstools2
datasets loading module: continue
2 parents bc5d9c5 + ee12bc1 commit 47131fd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1441
-543
lines changed

modules/datasetstools/doc/datasetstools.rst

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ datasetstools. Tools for working with different datasets.
66

77
The datasetstools module includes classes for working with different datasets.
88

9-
First version of this module was implemented for **Fall2014 OpenCV Challenge**.
10-
119
Action Recognition
1210
------------------
1311

@@ -50,13 +48,13 @@ FR_lfw
5048
5149
Implements loading dataset:
5250

53-
_`"Labeled Faces in the Wild-a"`: http://www.openu.ac.il/home/hassner/data/lfwa/
51+
_`"Labeled Faces in the Wild"`: http://vis-www.cs.umass.edu/lfw/
5452

5553
.. note:: Usage
5654

57-
1. From link above download dataset file: lfwa.tar.gz.
55+
1. From link above download any dataset file: lfw.tgz\lfwa.tar.gz\lfw-deepfunneled.tgz\lfw-funneled.tgz and file with 10 test splits: pairs.txt.
5856

59-
2. Unpack it.
57+
2. Unpack dataset file and place pairs.txt in created folder.
6058

6159
3. To load data run: ./opencv/build/bin/example_datasetstools_fr_lfw -p=/home/user/path_to_unpacked_folder/lfw2/
6260

@@ -75,9 +73,11 @@ _`"ChaLearn Looking at People"`: http://gesture.chalearn.org/
7573

7674
1. Follow instruction from site above, download files for dataset "Track 3: Gesture Recognition": Train1.zip-Train5.zip, Validation1.zip-Validation3.zip (Register on site: www.codalab.org and accept the terms and conditions of competition: https://www.codalab.org/competitions/991#learn_the_details There are three mirrors for downloading dataset files. When I downloaded data only mirror: "Universitat Oberta de Catalunya" works).
7775

78-
2. Unpack train archives Train1.zip-Train5.zip to one folder (currently loading validation files wasn't implemented)
76+
2. Unpack train archives Train1.zip-Train5.zip to folder Train/, validation archives Validation1.zip-Validation3.zip to folder Validation/
7977

80-
3. To load data run: ./opencv/build/bin/example_datasetstools_gr_chalearn -p=/home/user/path_to_unpacked_folder/
78+
3. Unpack all archives in Train/ & Validation/ in the folders with the same names, for example: Sample0001.zip to Sample0001/
79+
80+
4. To load data run: ./opencv/build/bin/example_datasetstools_gr_chalearn -p=/home/user/path_to_unpacked_folders/
8181

8282
GR_skig
8383
=======
@@ -239,13 +239,29 @@ Currently implemented loading full list with urls. Planned to implement dataset
239239

240240
3. To load data run: ./opencv/build/bin/example_datasetstools_or_imagenet -p=/home/user/path_to_unpacked_file/
241241

242+
OR_mnist
243+
===========
244+
.. ocv:class:: OR_mnist
245+
246+
Implements loading dataset:
247+
248+
_`"MNIST"`: http://yann.lecun.com/exdb/mnist/
249+
250+
.. note:: Usage
251+
252+
1. From link above download dataset files: t10k-images-idx3-ubyte.gz, t10k-labels-idx1-ubyte.gz, train-images-idx3-ubyte.gz, train-labels-idx1-ubyte.gz.
253+
254+
2. Unpack them.
255+
256+
3. To load data run: ./opencv/build/bin/example_datasetstools_or_mnist -p=/home/user/path_to_unpacked_files/
257+
242258
OR_sun
243259
======
244260
.. ocv:class:: OR_sun
245261
246262
Implements loading dataset:
247263

248-
_`"SUN Database"`: http://sun.cs.princeton.edu/
264+
_`"SUN Database"`: http://sundatabase.mit.edu/
249265

250266
Currently implemented loading "Scene Recognition Benchmark. SUN397". Planned to implement also "Object Detection Benchmark. SUN2012".
251267

modules/datasetstools/include/opencv2/datasetstools/ar_hmdb.hpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,9 @@ struct AR_hmdbObj : public Object
6363
class CV_EXPORTS AR_hmdb : public Dataset
6464
{
6565
public:
66-
AR_hmdb() {}
67-
AR_hmdb(const std::string &path, int number = 0);
68-
virtual ~AR_hmdb() {}
66+
virtual void load(const std::string &path) = 0;
6967

70-
virtual void load(const std::string &path, int number = 0);
71-
72-
private:
73-
void loadDataset(const std::string &path, int number = 0);
74-
75-
void loadAction(const std::string &fileName, std::vector<std::string> &train_, std::vector<std::string> &test_);
68+
static Ptr<AR_hmdb> create();
7669
};
7770

7871
}

modules/datasetstools/include/opencv2/datasetstools/ar_sports.hpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,9 @@ struct AR_sportsObj : public Object
6363
class CV_EXPORTS AR_sports : public Dataset
6464
{
6565
public:
66-
AR_sports() {}
67-
AR_sports(const std::string &path);
68-
virtual ~AR_sports() {}
66+
virtual void load(const std::string &path) = 0;
6967

70-
virtual void load(const std::string &path, int number = 0);
71-
72-
private:
73-
void loadDataset(const std::string &path);
74-
75-
void loadDatasetPart(const std::string &fileName, std::vector< Ptr<Object> > &dataset_);
68+
static Ptr<AR_sports> create();
7669
};
7770

7871
}

modules/datasetstools/include/opencv2/datasetstools/dataset.hpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,21 @@ class CV_EXPORTS Dataset
6262
Dataset() {}
6363
virtual ~Dataset() {}
6464

65-
virtual void load(const std::string &path, int number = 0) = 0;
65+
virtual void load(const std::string &path) = 0;
6666

67-
std::vector< Ptr<Object> > train;
68-
std::vector< Ptr<Object> > test;
67+
std::vector< Ptr<Object> >& getTrain(int splitNum = 0);
68+
std::vector< Ptr<Object> >& getTest(int splitNum = 0);
69+
std::vector< Ptr<Object> >& getValidation(int splitNum = 0);
70+
71+
int getNumSplits() const;
72+
73+
protected:
74+
std::vector< std::vector< Ptr<Object> > > train;
75+
std::vector< std::vector< Ptr<Object> > > test;
76+
std::vector< std::vector< Ptr<Object> > > validation;
77+
78+
private:
79+
std::vector< Ptr<Object> > empty;
6980
};
7081

7182
}

modules/datasetstools/include/opencv2/datasetstools/fr_lfw.hpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,16 @@ namespace datasetstools
5656

5757
struct FR_lfwObj : public Object
5858
{
59-
std::string name;
60-
std::vector<std::string> images;
59+
std::string image1, image2;
60+
bool same;
6161
};
6262

6363
class CV_EXPORTS FR_lfw : public Dataset
6464
{
6565
public:
66-
FR_lfw() {}
67-
FR_lfw(const std::string &path);
68-
virtual ~FR_lfw() {}
66+
virtual void load(const std::string &path) = 0;
6967

70-
virtual void load(const std::string &path, int number = 0);
71-
72-
private:
73-
void loadDataset(const std::string &path);
68+
static Ptr<FR_lfw> create();
7469
};
7570

7671
}

modules/datasetstools/include/opencv2/datasetstools/gr_chalearn.hpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,9 @@ struct GR_chalearnObj : public Object
8080
class CV_EXPORTS GR_chalearn : public Dataset
8181
{
8282
public:
83-
GR_chalearn() {}
84-
GR_chalearn(const std::string &path);
85-
virtual ~GR_chalearn() {}
83+
virtual void load(const std::string &path) = 0;
8684

87-
virtual void load(const std::string &path, int number = 0);
88-
89-
private:
90-
void loadDataset(const std::string &path);
85+
static Ptr<GR_chalearn> create();
9186
};
9287

9388
}

modules/datasetstools/include/opencv2/datasetstools/gr_skig.hpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,9 @@ struct GR_skigObj : public Object
102102
class CV_EXPORTS GR_skig : public Dataset
103103
{
104104
public:
105-
GR_skig() {}
106-
GR_skig(const std::string &path);
107-
virtual ~GR_skig() {}
105+
virtual void load(const std::string &path) = 0;
108106

109-
virtual void load(const std::string &path, int number = 0);
110-
111-
private:
112-
void loadDataset(const std::string &path);
107+
static Ptr<GR_skig> create();
113108
};
114109

115110
}

modules/datasetstools/include/opencv2/datasetstools/hpe_parse.hpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,9 @@ struct HPE_parseObj : public Object
6262
class CV_EXPORTS HPE_parse : public Dataset
6363
{
6464
public:
65-
HPE_parse() {}
66-
HPE_parse(const std::string &path);
67-
virtual ~HPE_parse() {}
65+
virtual void load(const std::string &path) = 0;
6866

69-
virtual void load(const std::string &path, int number = 0);
70-
71-
private:
72-
void loadDataset(const std::string &path);
67+
static Ptr<HPE_parse> create();
7368
};
7469

7570
}

modules/datasetstools/include/opencv2/datasetstools/ir_affine.hpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,9 @@ struct IR_affineObj : public Object
6464
class CV_EXPORTS IR_affine : public Dataset
6565
{
6666
public:
67-
IR_affine() {}
68-
IR_affine(const std::string &path);
69-
virtual ~IR_affine() {}
67+
virtual void load(const std::string &path) = 0;
7068

71-
virtual void load(const std::string &path, int number = 0);
72-
73-
private:
74-
void loadDataset(const std::string &path);
69+
static Ptr<IR_affine> create();
7570
};
7671

7772
}

modules/datasetstools/include/opencv2/datasetstools/ir_robot.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,23 +59,23 @@ namespace datasetstools
5959
// 0.0000e+00 2.8285e+03 6.1618e+02
6060
// 0.0000e+00 0.0000e+00 1.0000e+00
6161

62+
struct cameraPos
63+
{
64+
std::vector<std::string> images;
65+
};
66+
6267
struct IR_robotObj : public Object
6368
{
6469
std::string name;
65-
std::vector<std::string> images; // TODO: implement more complex structure
70+
std::vector<cameraPos> pos;
6671
};
6772

6873
class CV_EXPORTS IR_robot : public Dataset
6974
{
7075
public:
71-
IR_robot() {}
72-
IR_robot(const std::string &path);
73-
virtual ~IR_robot() {}
74-
75-
virtual void load(const std::string &path, int number = 0);
76+
virtual void load(const std::string &path) = 0;
7677

77-
private:
78-
void loadDataset(const std::string &path);
78+
static Ptr<IR_robot> create();
7979
};
8080

8181
}

0 commit comments

Comments
 (0)