Commit a9f4e2f4 authored by Vadim Pisarevsky's avatar Vadim Pisarevsky

Merge pull request #117 from avdmitry/datasets_enh

datasets module: enhancements
parents f8d7711e b9daaf14
set(the_description "datasets framework")
ocv_define_module(datasets opencv_core opencv_face opencv_ml opencv_flann)
ocv_define_module(datasets opencv_core opencv_face opencv_ml opencv_flann opencv_text)
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4267) # flann, Win64
......@@ -4,16 +4,24 @@ datasets. Framework for working with different datasets
.. highlight:: cpp
The datasets module includes classes for working with different datasets: load data, evaluate different algorithms on them, etc.
The datasets module includes classes for working with different datasets: load data, evaluate different algorithms on them, contains benchmarks, etc.
It is planned to have:
* basic: loading code for all datasets to help start work with them.
* next stage: quick benchmarks for all datasets to show how to solve them using OpenCV and implement evaluation code.
* finally: implement on OpenCV state-of-the-art algorithms, which solve these tasks.
.. toctree::
:hidden:
datasets/ar_hmdb
datasets/ar_sports
datasets/fr_adience
datasets/fr_lfw
datasets/gr_chalearn
datasets/gr_skig
datasets/hpe_humaneva
datasets/hpe_parse
datasets/ir_affine
datasets/ir_robot
......@@ -33,14 +41,16 @@ The datasets module includes classes for working with different datasets: load d
Action Recognition
------------------
:doc:`datasets/ar_hmdb`
:doc:`datasets/ar_hmdb` [#f1]_
:doc:`datasets/ar_sports`
Face Recognition
----------------
:doc:`datasets/fr_lfw`
:doc:`datasets/fr_adience`
:doc:`datasets/fr_lfw` [#f1]_
Gesture Recognition
-------------------
......@@ -52,6 +62,8 @@ Gesture Recognition
Human Pose Estimation
---------------------
:doc:`datasets/hpe_humaneva`
:doc:`datasets/hpe_parse`
Image Registration
......@@ -80,14 +92,14 @@ Object Recognition
:doc:`datasets/or_imagenet`
:doc:`datasets/or_mnist`
:doc:`datasets/or_mnist` [#f2]_
:doc:`datasets/or_sun`
Pedestrian Detection
--------------------
:doc:`datasets/pd_caltech`
:doc:`datasets/pd_caltech` [#f2]_
SLAM
----
......@@ -101,5 +113,9 @@ Text Recognition
:doc:`datasets/tr_chars`
:doc:`datasets/tr_svt`
:doc:`datasets/tr_svt` [#f1]_
*Footnotes*
.. [#f1] Benchmark implemented
.. [#f2] Not used in Vision Challenge
......@@ -17,7 +17,7 @@ _`"HMDB: A Large Human Motion Database"`: http://serre-lab.clps.brown.edu/resour
Benchmark
"""""""""
For this dataset was implemented benchmark, which gives accuracy: 0.107407 (using precomputed HOG/HOF "STIP" features from site, averaging for 3 splits)
For this dataset was implemented benchmark with accuracy: 0.107407 (using precomputed HOG/HOF "STIP" features from site, averaging for 3 splits)
To run this benchmark execute:
......@@ -27,3 +27,10 @@ To run this benchmark execute:
(precomputed features should be unpacked in the same folder: /home/user/path_to_unpacked_folders/hmdb51_org_stips/)
**References:**
.. [Kuehne11] H. Kuehne, H. Jhuang, E. Garrote, T. Poggio, and T. Serre. HMDB: A Large Video Database for Human Motion Recognition. ICCV, 2011
.. [Laptev08] I. Laptev, M. Marszalek, C. Schmid, and B. Rozenfeld. Learning Realistic Human Actions From Movies. CVPR, 2008
......@@ -12,3 +12,7 @@ _`"Sports-1M Dataset"`: http://cs.stanford.edu/people/karpathy/deepvideo/
2. To load data run: ./opencv/build/bin/example_datasets_ar_sports -p=/home/user/path_to_downloaded_folders/
**References:**
.. [KarpathyCVPR14] Andrej Karpathy and George Toderici and Sanketh Shetty and Thomas Leung and Rahul Sukthankar and Li Fei-Fei. Large-scale Video Classification with Convolutional Neural Networks. CVPR, 2014
Adience
=======
.. ocv:class:: FR_adience
Implements loading dataset:
_`"Adience"`: http://www.openu.ac.il/home/hassner/Adience/data.html
.. note:: Usage
1. From link above download any dataset file: faces.tar.gz\\aligned.tar.gz and files with splits: fold_0_data.txt-fold_4_data.txt, fold_frontal_0_data.txt-fold_frontal_4_data.txt. (For face recognition task another splits should be created)
2. Unpack dataset file to some folder and place split files into the same folder.
3. To load data run: ./opencv/build/bin/example_datasets_fr_adience -p=/home/user/path_to_created_folder/
**References:**
.. [Eidinger] E. Eidinger, R. Enbar, and T. Hassner. Age and Gender Estimation of Unfiltered Faces
......@@ -8,7 +8,7 @@ _`"Labeled Faces in the Wild"`: http://vis-www.cs.umass.edu/lfw/
.. note:: Usage
1. From link above download any dataset file: lfw.tgz\lfwa.tar.gz\lfw-deepfunneled.tgz\lfw-funneled.tgz and files with pairs: 10 test splits: pairs.txt and developer train split: pairsDevTrain.txt.
1. From link above download any dataset file: lfw.tgz\\lfwa.tar.gz\\lfw-deepfunneled.tgz\\lfw-funneled.tgz and files with pairs: 10 test splits: pairs.txt and developer train split: pairsDevTrain.txt.
2. Unpack dataset file and place pairs.txt and pairsDevTrain.txt in created folder.
......@@ -17,7 +17,7 @@ _`"Labeled Faces in the Wild"`: http://vis-www.cs.umass.edu/lfw/
Benchmark
"""""""""
For this dataset was implemented benchmark, which gives accuracy: 0.623833 +- 0.005223 (train split: pairsDevTrain.txt, dataset: lfwa)
For this dataset was implemented benchmark with accuracy: 0.623833 +- 0.005223 (train split: pairsDevTrain.txt, dataset: lfwa)
To run this benchmark execute:
......@@ -25,3 +25,7 @@ To run this benchmark execute:
./opencv/build/bin/example_datasets_fr_lfw_benchmark -p=/home/user/path_to_unpacked_folder/lfw2/
**References:**
.. [Huang07] G.B. Huang, M. Ramesh, T. Berg, and E. Learned-Miller. Labeled Faces in the Wild: A Database for Studying Face Recognition in Unconstrained Environments. 2007
......@@ -16,3 +16,7 @@ _`"ChaLearn Looking at People"`: http://gesture.chalearn.org/
4. To load data run: ./opencv/build/bin/example_datasets_gr_chalearn -p=/home/user/path_to_unpacked_folders/
**References:**
.. [Escalera14] S. Escalera, X. Baró, J. Gonzàlez, M.A. Bautista, M. Madadi, M. Reyes, V. Ponce-López, H.J. Escalante, J. Shotton, I. Guyon, "ChaLearn Looking at People Challenge 2014: Dataset and Results", ECCV Workshops, 2014
......@@ -14,3 +14,7 @@ _`"Sheffield Kinect Gesture Dataset"`: http://lshao.staff.shef.ac.uk/data/Sheffi
3. To load data run: ./opencv/build/bin/example_datasets_gr_skig -p=/home/user/path_to_unpacked_folders/
**References:**
.. [Liu13] L. Liu and L. Shao, “Learning Discriminative Representations from RGB-D Video Data”, In Proc. International Joint Conference on Artificial Intelligence (IJCAI), Beijing, China, 2013.
HumanEva Dataset
================
.. ocv:class:: HPE_humaneva
Implements loading dataset:
_`"HumanEva Dataset"`: http://humaneva.is.tue.mpg.de
.. note:: Usage
1. From link above download dataset files for HumanEva-I (tar) & HumanEva-II.
2. Unpack them to HumanEva_1 & HumanEva_2 accordingly.
3. To load data run: ./opencv/build/bin/example_datasets_hpe_humaneva -p=/home/user/path_to_unpacked_folders/
**References:**
.. [Sigal10] L. Sigal, A. Balan and M. J. Black. HumanEva: Synchronized Video and Motion Capture Dataset and Baseline Algorithm for Evaluation of Articulated Human Motion, In International Journal of Computer Vision, Vol. 87 (1-2), 2010
.. [Sigal06] L. Sigal and M. J. Black. HumanEva: Synchronized Video and Motion Capture Dataset for Evaluation of Articulated Human Motion, Techniacl Report CS-06-08, Brown University, 2006
......@@ -14,3 +14,7 @@ _`"PARSE Dataset"`: http://www.ics.uci.edu/~dramanan/papers/parse/
3. To load data run: ./opencv/build/bin/example_datasets_hpe_parse -p=/home/user/path_to_unpacked_folder/people_all/
**References:**
.. [Ramanan06] D. Ramanan "Learning to Parse Images of Articulated Bodies." Neural Info. Proc. Systems (NIPS) To appear. Dec 2006.
......@@ -14,3 +14,7 @@ _`"Affine Covariant Regions Datasets"`: http://www.robots.ox.ac.uk/~vgg/data/dat
3. To load data, for example, for "bark", run: ./opencv/build/bin/example_datasets_ir_affine -p=/home/user/path_to_unpacked_folder/bark/
**References:**
.. [Mikolajczyk05] K. Mikolajczyk, T. Tuytelaars, C. Schmid, A. Zisserman, J. Matas, F. Schaffalitzky, T. Kadir, L. Van Gool. A Comparison of Affine Region Detectors. International Journal of Computer Vision, Volume 65, Number 1/2, page 43--72, 2005
......@@ -4,12 +4,17 @@ Robot Data Set
Implements loading dataset:
_`"Robot Data Set"`: http://roboimagedata.compute.dtu.dk/?page_id=24
_`"Robot Data Set, Point Feature Data Set – 2010"`: http://roboimagedata.compute.dtu.dk/?page_id=24
.. note:: Usage
1. From link above download files for dataset "Point Feature Data Set – 2010": SET001_6.tar.gz-SET055_60.tar.gz (there are two data sets: - Full resolution images (1200×1600), ~500 Gb and - Half size image (600×800), ~115 Gb.)
1. From link above download dataset files: SET001_6.tar.gz-SET055_60.tar.gz
2. Unpack them to one folder.
3. To load data run: ./opencv/build/bin/example_datasets_ir_robot -p=/home/user/path_to_unpacked_folder/
**References:**
.. [aanæsinteresting] Aan{\ae}s, H. and Dahl, A.L. and Steenstrup Pedersen, K. Interesting Interest Points. International Journal of Computer Vision. 2012.
......@@ -14,3 +14,7 @@ _`"The Berkeley Segmentation Dataset and Benchmark"`: https://www.eecs.berkeley.
3. To load data run: ./opencv/build/bin/example_datasets_is_bsds -p=/home/user/path_to_unpacked_folder/BSDS300/
**References:**
.. [MartinFTM01] D. Martin and C. Fowlkes and D. Tal and J. Malik. A Database of Human Segmented Natural Images and its Application to Evaluating Segmentation Algorithms and Measuring Ecological Statistics. 2001
......@@ -14,3 +14,7 @@ _`"Weizmann Segmentation Evaluation Database"`: http://www.wisdom.weizmann.ac.il
3. To load data, for example, for 1 object dataset, run: ./opencv/build/bin/example_datasets_is_weizmann -p=/home/user/path_to_unpacked_folder/1obj/
**References:**
.. [AlpertGBB07] Sharon Alpert and Meirav Galun and Ronen Basri and Achi Brandt. Image Segmentation by Probabilistic Bottom-Up Aggregation and Cue Integration. 2007
......@@ -14,3 +14,7 @@ _`"EPFL Multi-View Stereo"`: http://cvlabwww.epfl.ch/~strecha/multiview/denseMVS
3. To load data, for example, for "fountain", run: ./opencv/build/bin/example_datasets_msm_epfl -p=/home/user/path_to_unpacked_folder/fountain/
**References:**
.. [Strecha08] C. Strecha, W. von Hansen, L. Van Gool, P. Fua, U. Thoennessen. On Benchmarking Camera Calibration and Multi-View Stereo for High Resolution Imagery. CVPR, 2008
......@@ -14,3 +14,7 @@ _`"Stereo – Middlebury Computer Vision"`: http://vision.middlebury.edu/mview/
3. To load data, for example "temple" dataset, run: ./opencv/build/bin/example_datasets_msm_middlebury -p=/home/user/path_to_unpacked_folder/temple/
**References:**
.. [Seitz06] S. M. Seitz, B. Curless, J. Diebel, D. Scharstein, R. Szeliski. A Comparison and Evaluation of Multi-View Stereo Reconstruction Algorithms, CVPR, 2006
......@@ -6,13 +6,34 @@ Implements loading dataset:
_`"ImageNet"`: http://www.image-net.org/
Currently implemented loading full list with urls. Planned to implement dataset from ILSVRC challenge.
.. note:: Usage
1. From link above download dataset file: imagenet_fall11_urls.tgz
1. From link above download dataset files: ILSVRC2010_images_train.tar\\ILSVRC2010_images_test.tar\\ILSVRC2010_images_val.tar & devkit: ILSVRC2010_devkit-1.0.tar.gz (Implemented loading of 2010 dataset as only this dataset has ground truth for test data, but structure for ILSVRC2014 is similar)
2. Unpack them to: some_folder/train/\\some_folder/test/\\some_folder/val & some_folder/ILSVRC2010_validation_ground_truth.txt\\some_folder/ILSVRC2010_test_ground_truth.txt.
3. Create file with labels: some_folder/labels.txt, for example, using :ref:`python script <python-script>` below (each file's row format: synset,labelID,description. For example: "n07751451,18,plum").
4. Unpack all tar files in train.
5. To load data run: ./opencv/build/bin/example_datasets_or_imagenet -p=/home/user/some_folder/
.. _python-script:
Python script to parse meta.mat:
::
import scipy.io
meta_mat = scipy.io.loadmat("devkit-1.0/data/meta.mat")
labels_dic = dict((m[0][1][0], m[0][0][0][0]-1) for m in meta_mat['synsets']
label_names_dic = dict((m[0][1][0], m[0][2][0]) for m in meta_mat['synsets']
for label in labels_dic.keys():
print "{0},{1},{2}".format(label, labels_dic[label], label_names_dic[label])
2. Unpack it.
**References:**
3. To load data run: ./opencv/build/bin/example_datasets_or_imagenet -p=/home/user/path_to_unpacked_file/
.. [ILSVRCarxiv14] Olga Russakovsky and Jia Deng and Hao Su and Jonathan Krause and Sanjeev Satheesh and Sean Ma and Zhiheng Huang and Andrej Karpathy and Aditya Khosla and Michael Bernstein and Alexander C. Berg and Li Fei-Fei. ImageNet Large Scale Visual Recognition Challenge. 2014
......@@ -14,3 +14,7 @@ _`"MNIST"`: http://yann.lecun.com/exdb/mnist/
3. To load data run: ./opencv/build/bin/example_datasets_or_mnist -p=/home/user/path_to_unpacked_files/
**References:**
.. [LeCun98a] Y. LeCun, L. Bottou, Y. Bengio, and P. Haffner. Gradient-based learning applied to document recognition. Proceedings of the IEEE, 1998.
......@@ -4,15 +4,19 @@ SUN Database
Implements loading dataset:
_`"SUN Database"`: http://sundatabase.mit.edu/
Currently implemented loading "Scene Recognition Benchmark. SUN397". Planned to implement also "Object Detection Benchmark. SUN2012".
_`"SUN Database, Scene Recognition Benchmark. SUN397"`: http://vision.cs.princeton.edu/projects/2010/SUN/
.. note:: Usage
1. From link above download dataset file: SUN397.tar
1. From link above download dataset file: SUN397.tar & file with splits: Partitions.zip
2. Unpack SUN397.tar into folder: SUN397/ & Partitions.zip into folder: SUN397/Partitions/
3. To load data run: ./opencv/build/bin/example_datasets_or_sun -p=/home/user/path_to_unpacked_files/SUN397/
**References:**
2. Unpack it.
.. [Xiao10] J. Xiao, J. Hays, K. Ehinger, A. Oliva, and A. Torralba. SUN Database: Large-scale Scene Recognition from Abbey to Zoo. IEEE Conference on Computer Vision and Pattern Recognition. CVPR, 2010
3. To load data run: ./opencv/build/bin/example_datasets_or_sun -p=/home/user/path_to_unpacked_folder/SUN397/
.. [Xiao14] J. Xiao, K. A. Ehinger, J. Hays, A. Torralba, and A. Oliva. SUN Database: Exploring a Large Collection of Scene Categories. International Journal of Computer Vision. IJCV, 2014
......@@ -21,3 +21,9 @@ _`"Caltech Pedestrian Detection Benchmark"`: http://www.vision.caltech.edu/Image
3. To load data run: ./opencv/build/bin/example_datasets_pd_caltech -p=/home/user/path_to_unpacked_folders/
**References:**
.. [Dollár12] P. Dollár, C. Wojek, B. Schiele and P. Perona. Pedestrian Detection: An Evaluation of the State of the Art. PAMI, 2012.
.. [DollárCVPR09] P. Dollár, C. Wojek, B. Schiele and P. Perona. Pedestrian Detection: A Benchmark. CVPR, 2009
......@@ -14,3 +14,11 @@ _`"KITTI Vision Benchmark"`: http://www.cvlibs.net/datasets/kitti/eval_odometry.
3. To load data run: ./opencv/build/bin/example_datasets_slam_kitti -p=/home/user/path_to_unpacked_folder/dataset/
**References:**
.. [Geiger2012CVPR] Andreas Geiger and Philip Lenz and Raquel Urtasun. Are we ready for Autonomous Driving? The KITTI Vision Benchmark Suite. CVPR, 2012
.. [Geiger2013IJRR] Andreas Geiger and Philip Lenz and Christoph Stiller and Raquel Urtasun. Vision meets Robotics: The KITTI Dataset. IJRR, 2013
.. [Fritsch2013ITSC] Jannik Fritsch and Tobias Kuehnl and Andreas Geiger. A New Performance Measure and Evaluation Benchmark for Road Detection Algorithms. ITSC, 2013
......@@ -14,3 +14,7 @@ _`"TUMindoor Dataset"`: http://www.navvis.lmt.ei.tum.de/dataset/
3. To load each dataset run: ./opencv/build/bin/example_datasets_slam_tumindoor -p=/home/user/path_to_unpacked_folders/
**References:**
.. [TUMindoor] R. Huitl and G. Schroth and S. Hilsenbeck and F. Schweiger and E. Steinbach. {TUM}indoor: An Extensive Image and Point Cloud Dataset for Visual Indoor Localization and Mapping. 2012
......@@ -16,3 +16,7 @@ _`"The Chars74K Dataset"`: http://www.ee.surrey.ac.uk/CVSSP/demos/chars74k/
4. To load data, for example "EnglishImg", run: ./opencv/build/bin/example_datasets_tr_chars -p=/home/user/path_to_unpacked_folder/English/
**References:**
.. [Campos09] T. E. de Campos, B. R. Babu and M. Varma. Character recognition in natural images. In Proceedings of the International Conference on Computer Vision Theory and Applications (VISAPP), 2009
......@@ -14,3 +14,20 @@ _`"The Street View Text Dataset"`: http://vision.ucsd.edu/~kai/svt/
3. To load data run: ./opencv/build/bin/example_datasets_tr_svt -p=/home/user/path_to_unpacked_folder/svt/svt1/
Benchmark
"""""""""
For this dataset was implemented benchmark with accuracy (mean f1): 0.217
To run benchmark execute:
.. code-block:: bash
./opencv/build/bin/example_datasets_tr_svt_benchmark -p=/home/user/path_to_unpacked_folders/svt/svt1/
**References:**
.. [Wang11] Kai Wang, Boris Babenko and Serge Belongie. End-to-end Scene Text Recognition. ICCV, 2011
.. [Wang10] Kai Wang and Serge Belongie. Word Spotting in the Wild. ECCV, 2010
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2014, Itseez Inc, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Itseez Inc or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#ifndef OPENCV_DATASETS_FR_ADIENCE_HPP
#define OPENCV_DATASETS_FR_ADIENCE_HPP
#include <string>
#include <vector>
#include "opencv2/datasets/dataset.hpp"
#include <opencv2/core.hpp>
namespace cv
{
namespace datasets
{
enum genderType
{
male = 0,
female,
none
};
struct FR_adienceObj : public Object
{
std::string user_id;
std::string original_image;
int face_id;
std::string age;
genderType gender;
int x;
int y;
int dx;
int dy;
int tilt_ang;
int fiducial_yaw_angle;
int fiducial_score;
};
class CV_EXPORTS FR_adience : public Dataset
{
public:
virtual void load(const std::string &path) = 0;
static Ptr<FR_adience> create();
std::vector<std::string> paths;
};
}
}
#endif
......@@ -39,12 +39,47 @@
//
//M*/
#ifndef __OPENCV_PRECOMP_H__
#define __OPENCV_PRECOMP_H__
#ifndef OPENCV_DATASETS_HPE_HUMANEVA_HPP
#define OPENCV_DATASETS_HPE_HUMANEVA_HPP
#include <cstdio>
#include <cstdlib> // atoi, atof
#include <string>
#include <vector>
#include <fstream>
#include "opencv2/datasets/dataset.hpp"
#include <opencv2/core.hpp>
namespace cv
{
namespace datasets
{
struct HPE_humanevaObj : public Object
{
char person; // 1..4
std::string action;
int type1;
std::string type2;
Matx13d ofs;
std::string fileName;
std::vector<std::string> imageNames; // for HumanEva_II
};
enum datasetType
{
humaneva_1 = 1,
humaneva_2
};
class CV_EXPORTS HPE_humaneva : public Dataset
{
public:
virtual void load(const std::string &path) = 0;
static Ptr<HPE_humaneva> create(int num=humaneva_1);
};
}
}
#endif
......@@ -56,9 +56,8 @@ namespace datasets
struct OR_imagenetObj : public Object
{
std::string wnid;
int id2;
std::string imageUrl;
int id;
std::string image;
};
class CV_EXPORTS OR_imagenet : public Dataset
......
......@@ -56,8 +56,8 @@ namespace datasets
struct OR_sunObj : public Object
{
int label;
std::string name;
std::vector<std::string> imageNames;
};
class CV_EXPORTS OR_sun : public Dataset
......@@ -66,6 +66,8 @@ public:
virtual void load(const std::string &path) = 0;
static Ptr<OR_sun> create();
std::vector<std::string> paths;
};
}
......
......@@ -45,6 +45,11 @@
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib> // atoi, atof
#include <fstream>
#include <opencv2/core.hpp>
namespace cv
......
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2014, Itseez Inc, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Itseez Inc or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "opencv2/datasets/fr_adience.hpp"
#include <opencv2/core.hpp>
#include <cstdio>
#include <string>
#include <vector>
using namespace std;
using namespace cv;
using namespace cv::datasets;
int main(int argc, char *argv[])
{
const char *keys =
"{ help h usage ? | | show this message }"
"{ path p |true| path to dataset folder and splits }";
CommandLineParser parser(argc, argv, keys);
string path(parser.get<string>("path"));
if (parser.has("help") || path=="true")
{
parser.printMessage();
return -1;
}
Ptr<FR_adience> dataset = FR_adience::create();
dataset->load(path);
// ***************
// dataset contains for each object its images.
// For example, let output splits number, dataset size and last image.
int numSplits = dataset->getNumSplits();
printf("splits number: %u\n", numSplits);
printf("dataset size: %u\n", (unsigned int)dataset->getTrain().size());
FR_adienceObj *example = static_cast<FR_adienceObj *>(dataset->getTrain().back().get());
printf("last image:\n");
printf("user_id: %s\n", example->user_id.c_str());
printf("original_image: %s\n", example->original_image.c_str());
printf("face_id: %u\n", example->face_id);
printf("age: %s\n", example->age.c_str());
printf("gender: ");
if (example->gender == male)
{
printf("m\n");
} else
if (example->gender == female)
{
printf("f\n");
} else
{
printf("none\n");
}
printf("x: %u\n", example->x);
printf("y: %u\n", example->y);
printf("dx: %u\n", example->dx);
printf("dy: %u\n", example->dy);
printf("tilt_ang: %u\n", example->tilt_ang);
printf("fiducial_yaw_angle: %u\n", example->fiducial_yaw_angle);
printf("fiducial_score: %u\n", example->fiducial_score);
return 0;
}
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2014, Itseez Inc, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Itseez Inc or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "opencv2/datasets/hpe_humaneva.hpp"
#include <opencv2/core.hpp>
#include <cstdio>
#include <cstdlib> // atoi
#include <string>
#include <vector>
using namespace std;
using namespace cv;
using namespace cv::datasets;
int main(int argc, char *argv[])
{
const char *keys =
"{ help h usage ? | | show this message }"
"{ path p |true| path to dataset folder }";
CommandLineParser parser(argc, argv, keys);
string path(parser.get<string>("path"));
if (parser.has("help") || path=="true")
{
parser.printMessage();
return -1;
}
for (unsigned int i=1; i<=2; ++i)
{
printf("\tHumanEva %u\n", i);
char number[2];
sprintf(number, "%u", i);
string pathCurr(path+"HumanEva_"+number+"/");
Ptr<HPE_humaneva> dataset = HPE_humaneva::create(i);
dataset->load(pathCurr);
// ***************
// dataset contains pair of rgb\dep images
// For example, let output train size and last element.
HPE_humanevaObj *example = static_cast<HPE_humanevaObj *>(dataset->getTrain().back().get());
printf("train size: %u\n", (unsigned int)dataset->getTrain().size());
printf("last train video:\n");
printf("person: %u\n", example->person);
printf("action: %s\n", example->action.c_str());
printf("type1: %u\n", example->type1);
printf("type2: %s\n", example->type2.c_str());
printf("filename: %s\n", example->fileName.c_str());
printf("num images: %u\n", (int)example->imageNames.size());
printf("ofs:");
for (int j=0; j<3; ++j)
{
printf(" %f", example->ofs(0, j));
}
printf("\n");
}
return 0;
}
......@@ -58,7 +58,7 @@ int main(int argc, char *argv[])
{
const char *keys =
"{ help h usage ? | | show this message }"
"{ path p |true| path to file with urls: fall11_urls.txt }";
"{ path p |true| path to folder with dataset }";
CommandLineParser parser(argc, argv, keys);
string path(parser.get<string>("path"));
if (parser.has("help") || path=="true")
......@@ -71,13 +71,28 @@ int main(int argc, char *argv[])
dataset->load(path);
// ***************
// dataset contains for each object its id & image url.
// For example, let output dataset size and first object.
printf("dataset size: %u\n", (unsigned int)dataset->getTrain().size());
OR_imagenetObj *example = static_cast<OR_imagenetObj *>(dataset->getTrain()[0].get());
printf("first object url: %s\n", example->imageUrl.c_str());
printf("first object wnid: %s\n", example->wnid.c_str());
printf("first object id2: %u\n", example->id2);
// dataset contains for each object its id & image path
// For example, let output train\test\validation size and first image.
vector< Ptr<Object> > &curr = dataset->getTrain();
printf("train:\nsize: %u\n", (unsigned int)curr.size());
OR_imagenetObj *example = static_cast<OR_imagenetObj *>(curr[0].get());
printf("first image:\n");
printf("image: %s\n", example->image.c_str());
printf("id: %u\n", example->id);
vector< Ptr<Object> > &currT = dataset->getTest();
printf("test:\nsize: %u\n", (unsigned int)currT.size());
example = static_cast<OR_imagenetObj *>(currT[0].get());
printf("first image:\n");
printf("image: %s\n", example->image.c_str());
printf("id: %u\n", example->id);
vector< Ptr<Object> > &currV = dataset->getValidation();
printf("validation:\nsize: %u\n", (unsigned int)currV.size());
example = static_cast<OR_imagenetObj *>(currV[0].get());
printf("first image:\n");
printf("image: %s\n", example->image.c_str());
printf("id: %u\n", example->id);
return 0;
}
......@@ -70,16 +70,15 @@ int main(int argc, char *argv[])
// ***************
// dataset contains for each object its images.
// For example, let output dataset size and last object.
// For example, let output splits number, dataset size and last image.
int numSplits = dataset->getNumSplits();
printf("splits number: %u\n", numSplits);
printf("dataset size: %u\n", (unsigned int)dataset->getTrain().size());
OR_sunObj *example = static_cast<OR_sunObj *>(dataset->getTrain().back().get());
printf("last object name: %s\n", example->name.c_str());
printf("last object images number: %u\n", (unsigned int)example->imageNames.size());
vector<string> &imageNames = example->imageNames;
for (vector<string>::iterator it=imageNames.begin(); it!=imageNames.end(); ++it)
{
printf("%s\n", (*it).c_str());
}
printf("last image:\nname: %s\n", example->name.c_str());
printf("label: %u\n", example->label);
printf("label path: %s\n", dataset->paths[example->label].c_str());
return 0;
}
This diff is collapsed.
......@@ -41,7 +41,6 @@
#include "opencv2/datasets/ar_hmdb.hpp"
#include "opencv2/datasets/util.hpp"
#include "precomp.hpp"
namespace cv
{
......@@ -50,7 +49,7 @@ namespace datasets
using namespace std;
class CV_EXPORTS AR_hmdbImp : public AR_hmdb
class AR_hmdbImp : public AR_hmdb
{
public:
AR_hmdbImp() {}
......
......@@ -41,7 +41,6 @@
#include "opencv2/datasets/ar_sports.hpp"
#include "opencv2/datasets/util.hpp"
#include "precomp.hpp"
namespace cv
{
......@@ -50,7 +49,7 @@ namespace datasets
using namespace std;
class CV_EXPORTS AR_sportsImp : public AR_sports
class AR_sportsImp : public AR_sports
{
public:
AR_sportsImp() {}
......
......@@ -41,7 +41,6 @@
#include "opencv2/datasets/dataset.hpp"
#include "opencv2/datasets/util.hpp"
#include "precomp.hpp"
namespace cv
{
......
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2014, Itseez Inc, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Itseez Inc or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "opencv2/datasets/fr_adience.hpp"
#include "opencv2/datasets/util.hpp"
namespace cv
{
namespace datasets
{
using namespace std;
class FR_adienceImp : public FR_adience
{
public:
FR_adienceImp() {}
//FR_adienceImp(const string &path);
virtual ~FR_adienceImp() {}
virtual void load(const string &path);
private:
void loadDataset(const string &path);
void loadFile(const string &filename, vector< Ptr<FR_adienceObj> > &out);
void cv5ToSplits(vector< Ptr<FR_adienceObj> > fileList[5]);
};
/*FR_adienceImp::FR_adienceImp(const string &path)
{
loadDataset(path);
}*/
void FR_adienceImp::load(const string &path)
{
loadDataset(path);
}
void FR_adienceImp::loadFile(const string &filename, vector< Ptr<FR_adienceObj> > &out)
{
string line;
ifstream infile(filename.c_str());
while (getline(infile, line))
{
Ptr<FR_adienceObj> curr(new FR_adienceObj);
vector<string> elems;
split(line, elems, ',');
curr->user_id = elems[0];
curr->original_image = elems[1];
curr->face_id = atoi(elems[2].c_str());
curr->age = elems[3];
if (elems[4]=="m")
{
curr->gender = male;
} else
if (elems[4]=="f")
{
curr->gender = female;
} else
{
curr->gender = none;
}
curr->x = atoi(elems[5].c_str());
curr->y = atoi(elems[6].c_str());
curr->dx = atoi(elems[7].c_str());
curr->dy = atoi(elems[8].c_str());
curr->tilt_ang = atoi(elems[9].c_str());
curr->fiducial_yaw_angle = atoi(elems[10].c_str());
curr->fiducial_score = atoi(elems[11].c_str());
out.push_back(curr);
}
}
void FR_adienceImp::cv5ToSplits(vector< Ptr<FR_adienceObj> > fileList[5])
{
for (unsigned int i=0; i<5; ++i)
{
train.push_back(vector< Ptr<Object> >());
test.push_back(vector< Ptr<Object> >());
validation.push_back(vector< Ptr<Object> >());
for (unsigned int j=0; j<5; ++j)
{
vector< Ptr<FR_adienceObj> > &currlist = fileList[j];
if (i!=j)
{
for (vector< Ptr<FR_adienceObj> >::iterator it=currlist.begin(); it!=currlist.end(); ++it)
{
train.back().push_back(*it);
}
} else
{
for (vector< Ptr<FR_adienceObj> >::iterator it=currlist.begin(); it!=currlist.end(); ++it)
{
test.back().push_back(*it);
}
}
}
}
}
void FR_adienceImp::loadDataset(const string &path)
{
vector< Ptr<FR_adienceObj> > fileList[5];
for (unsigned int i=0; i<5; ++i)
{
char tmp[3];
sprintf(tmp, "%u", i);
string filename(path+"fold_"+string(tmp)+"_data.txt");
loadFile(filename, fileList[i]);
}
cv5ToSplits(fileList);
for (unsigned int i=0; i<5; ++i)
{
char tmp[3];
sprintf(tmp, "%u", i);
string filename(path+"fold_frontal_"+string(tmp)+"_data.txt");
fileList[i].clear();
loadFile(filename, fileList[i]);
}
cv5ToSplits(fileList);
}
Ptr<FR_adience> FR_adience::create()
{
return Ptr<FR_adienceImp>(new FR_adienceImp);
}
}
}
......@@ -41,7 +41,6 @@
#include "opencv2/datasets/fr_lfw.hpp"
#include "opencv2/datasets/util.hpp"
#include "precomp.hpp"
#include <map>
......@@ -52,7 +51,7 @@ namespace datasets
using namespace std;
class CV_EXPORTS FR_lfwImp : public FR_lfw
class FR_lfwImp : public FR_lfw
{
public:
FR_lfwImp() {}
......
......@@ -41,7 +41,6 @@
#include "opencv2/datasets/gr_chalearn.hpp"
#include "opencv2/datasets/util.hpp"
#include "precomp.hpp"
namespace cv
{
......@@ -50,7 +49,7 @@ namespace datasets
using namespace std;
class CV_EXPORTS GR_chalearnImp : public GR_chalearn
class GR_chalearnImp : public GR_chalearn
{
public:
GR_chalearnImp() {}
......
......@@ -41,7 +41,6 @@
#include "opencv2/datasets/gr_skig.hpp"
#include "opencv2/datasets/util.hpp"
#include "precomp.hpp"
#include <cstring>
......@@ -52,7 +51,7 @@ namespace datasets
using namespace std;
class CV_EXPORTS GR_skigImp : public GR_skig
class GR_skigImp : public GR_skig
{
public:
GR_skigImp() {}
......
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2014, Itseez Inc, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Itseez Inc or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "opencv2/datasets/hpe_humaneva.hpp"
#include "opencv2/datasets/util.hpp"
#include <cstring>
namespace cv
{
namespace datasets
{
using namespace std;
class HPE_humanevaImp : public HPE_humaneva
{
public:
HPE_humanevaImp() {}
//HPE_humanevaImp(const string &path);
virtual ~HPE_humanevaImp() {}
virtual void load(const string &path);
private:
void loadDataset(const string &path);
};
/*HPE_humanevaImp::HPE_humanevaImp(const string &path)
{
loadDataset(path);
}*/
void HPE_humanevaImp::load(const string &path)
{
loadDataset(path);
}
void HPE_humanevaImp::loadDataset(const string &path)
{
train.push_back(vector< Ptr<Object> >());
test.push_back(vector< Ptr<Object> >());
validation.push_back(vector< Ptr<Object> >());
for (unsigned int i=1; i<=4; ++i)
{
char number[2];
sprintf(number, "%u", i);
string pathDatasetI(path + "S" + number + "/Image_Data/");
string pathDatasetS(path + "S" + number + "/Sync_Data/");
vector<string> fileNames;
getDirList(pathDatasetI, fileNames);
for (vector<string>::iterator it=fileNames.begin(); it!=fileNames.end(); ++it)
{
string &file = *it;
vector<string> elems;
split(file, elems, '_');
if (elems.size() != 3)
{
continue;
}
Ptr<HPE_humanevaObj> curr(new HPE_humanevaObj);
curr->person = (char)i;
curr->action = elems[0];
curr->type1 = atoi(elems[1].c_str());
curr->fileName = pathDatasetI+file;
unsigned int type2End = 2;
if (elems[2][type2End+1] != ')')
{
type2End = 3;
}
curr->type2 = elems[2].substr(1, type2End);
file = file.substr(0, file.length()-3) + "ofs";
ifstream infileOFS((pathDatasetS + file).c_str());
string line;
unsigned int j = 0;
while (getline(infileOFS, line))
{
curr->ofs(0, j) = atof(line.c_str());
++j;
}
train.back().push_back(curr);
}
}
}
//
// HumanEva II
//
class HPE_humanevaImpII : public HPE_humaneva
{
public:
HPE_humanevaImpII() {}
//HPE_humanevaImpII(const string &path);
virtual ~HPE_humanevaImpII() {}
virtual void load(const string &path);
private:
void loadDataset(const string &path);
};
/*HPE_humanevaImpII::HPE_humanevaImpII(const string &path)
{
loadDataset(path);
}*/
void HPE_humanevaImpII::load(const string &path)
{
loadDataset(path);
}
void HPE_humanevaImpII::loadDataset(const string &path)
{
train.push_back(vector< Ptr<Object> >());
test.push_back(vector< Ptr<Object> >());
validation.push_back(vector< Ptr<Object> >());
for (unsigned int i=1; i<=2; ++i)
{
char number[2];
sprintf(number, "%u", i*2); // 2 & 4
string pathDatasetI(path + "S" + number + "/Image_Data/");
string pathDatasetS(path + "S" + number + "/Sync_Data/");
vector<string> fileNames;
getDirList(pathDatasetI, fileNames);
for (vector<string>::iterator it=fileNames.begin(); it!=fileNames.end(); ++it)
{
string &file = *it;
vector<string> elems;
split(file, elems, '_');
if (elems.size() != 3)
{
continue;
}
Ptr<HPE_humanevaObj> curr(new HPE_humanevaObj);
curr->person = (char)i;
curr->action = elems[0];
curr->type1 = atoi(elems[1].c_str());
curr->fileName = pathDatasetI+file;
unsigned int type2End = 2;
if (elems[2][type2End+1] != ')')
{
type2End = 3;
}
curr->type2 = elems[2].substr(1, type2End);
vector<string> imageNames;
getDirList(curr->fileName, imageNames);
for (vector<string>::iterator itI=imageNames.begin(); itI!=imageNames.end(); ++itI)
{
string &image = *itI;
if (image.substr(image.length()-3) == "png")
{
curr->imageNames.push_back(image);
}
}
file = file.substr(0, file.length()) + ".ofs";
ifstream infileOFS((pathDatasetS + file).c_str());
string line;
unsigned int j = 0;
while (getline(infileOFS, line))
{
curr->ofs(0, j) = atof(line.c_str());
++j;
}
train.back().push_back(curr);
}
}
}
Ptr<HPE_humaneva> HPE_humaneva::create(int num)
{
if (humaneva_2==num)
{
return Ptr<HPE_humanevaImpII>(new HPE_humanevaImpII);
}
return Ptr<HPE_humanevaImp>(new HPE_humanevaImp);
}
}
}
......@@ -41,7 +41,6 @@
#include "opencv2/datasets/hpe_parse.hpp"
#include "opencv2/datasets/util.hpp"
#include "precomp.hpp"
namespace cv
{
......@@ -50,7 +49,7 @@ namespace datasets
using namespace std;
class CV_EXPORTS HPE_parseImp : public HPE_parse
class HPE_parseImp : public HPE_parse
{
public:
HPE_parseImp() {}
......
......@@ -41,7 +41,6 @@
#include "opencv2/datasets/ir_affine.hpp"
#include "opencv2/datasets/util.hpp"
#include "precomp.hpp"
namespace cv
{
......@@ -50,7 +49,7 @@ namespace datasets
using namespace std;
class CV_EXPORTS IR_affineImp : public IR_affine
class IR_affineImp : public IR_affine
{
public:
IR_affineImp() {}
......
......@@ -41,7 +41,6 @@
#include "opencv2/datasets/ir_robot.hpp"
#include "opencv2/datasets/util.hpp"
#include "precomp.hpp"
namespace cv
{
......@@ -50,7 +49,7 @@ namespace datasets
using namespace std;
class CV_EXPORTS IR_robotImp : public IR_robot
class IR_robotImp : public IR_robot
{
public:
IR_robotImp() {}
......
......@@ -41,7 +41,6 @@
#include "opencv2/datasets/is_bsds.hpp"
#include "opencv2/datasets/util.hpp"
#include "precomp.hpp"
namespace cv
{
......@@ -50,7 +49,7 @@ namespace datasets
using namespace std;
class CV_EXPORTS IS_bsdsImp : public IS_bsds
class IS_bsdsImp : public IS_bsds
{
public:
IS_bsdsImp() {}
......
......@@ -41,7 +41,6 @@
#include "opencv2/datasets/is_weizmann.hpp"
#include "opencv2/datasets/util.hpp"
#include "precomp.hpp"
namespace cv
{
......@@ -50,7 +49,7 @@ namespace datasets
using namespace std;
class CV_EXPORTS IS_weizmannImp : public IS_weizmann
class IS_weizmannImp : public IS_weizmann
{
public:
IS_weizmannImp() {}
......
......@@ -41,7 +41,6 @@
#include "opencv2/datasets/msm_epfl.hpp"
#include "opencv2/datasets/util.hpp"
#include "precomp.hpp"
namespace cv
{
......@@ -50,7 +49,7 @@ namespace datasets
using namespace std;
class CV_EXPORTS MSM_epflImp : public MSM_epfl
class MSM_epflImp : public MSM_epfl
{
public:
MSM_epflImp() {}
......
......@@ -41,7 +41,6 @@
#include "opencv2/datasets/msm_middlebury.hpp"
#include "opencv2/datasets/util.hpp"
#include "precomp.hpp"
namespace cv
{
......@@ -50,7 +49,7 @@ namespace datasets
using namespace std;
class CV_EXPORTS MSM_middleburyImp : public MSM_middlebury
class MSM_middleburyImp : public MSM_middlebury
{
public:
MSM_middleburyImp() {}
......
......@@ -41,7 +41,8 @@
#include "opencv2/datasets/or_imagenet.hpp"
#include "opencv2/datasets/util.hpp"
#include "precomp.hpp"
#include <map>
namespace cv
{
......@@ -50,7 +51,7 @@ namespace datasets
using namespace std;
class CV_EXPORTS OR_imagenetImp : public OR_imagenet
class OR_imagenetImp : public OR_imagenet
{
public:
OR_imagenetImp() {}
......@@ -61,6 +62,8 @@ public:
private:
void loadDataset(const string &path);
void numberToString(int number, string &out);
};
/*OR_imagenetImp::OR_imagenetImp(const string &path)
......@@ -73,30 +76,87 @@ void OR_imagenetImp::load(const string &path)
loadDataset(path);
}
void OR_imagenetImp::numberToString(int number, string &out)
{
char numberStr[9];
sprintf(numberStr, "%u", number);
for (unsigned int i=0; i<8-strlen(numberStr); ++i)
{
out += "0";
}
out += numberStr;
}
void OR_imagenetImp::loadDataset(const string &path)
{
train.push_back(vector< Ptr<Object> >());
test.push_back(vector< Ptr<Object> >());
validation.push_back(vector< Ptr<Object> >());
ifstream infile((path + "fall11_urls.txt").c_str());
map<string, int> labels;
ifstream infile((path + "labels.txt").c_str());
string line;
while (getline(infile, line))
{
vector<string> elems;
split(line, elems, '\t');
split(line, elems, ',');
string syn = elems[0];
int number = atoi(elems[1].c_str());
labels.insert(make_pair(syn, number));
}
string pathTrain(path + "train/");
vector<string> fileNames;
getDirList(pathTrain, fileNames);
for (vector<string>::iterator it=fileNames.begin(); it!=fileNames.end(); ++it)
{
string pathSyn((*it) + "/");
vector<string> fileNamesSyn;
getDirList((pathTrain + pathSyn), fileNamesSyn);
for (vector<string>::iterator itSyn=fileNamesSyn.begin(); itSyn!=fileNamesSyn.end(); ++itSyn)
{
Ptr<OR_imagenetObj> curr(new OR_imagenetObj);
curr->image = "train/" + pathSyn + *itSyn;
curr->id = labels[*it];
train.back().push_back(curr);
}
}
ifstream infileVal((path + "ILSVRC2010_validation_ground_truth.txt").c_str());
while (getline(infileVal, line))
{
Ptr<OR_imagenetObj> curr(new OR_imagenetObj);
curr->imageUrl = elems[1];
curr->id = atoi(line.c_str());
numberToString(validation.back().size()+1, curr->image);
curr->image = "val/ILSVRC2010_val_" + curr->image + ".JPEG";
string id(elems[0]);
elems.clear();
split(id, elems, '_');
validation.back().push_back(curr);
}
vector<int> testGT;
ifstream infileTest((path + "ILSVRC2010_test_ground_truth.txt").c_str());
while (getline(infileTest, line))
{
testGT.push_back(atoi(line.c_str()));
}
if (testGT.size()==0) // have no test labels, set them to 1000 - unknown
{
for (int i=0; i<150000; ++i)
{
testGT.push_back(1000); // unknown
}
}
curr->wnid = elems[0];
curr->id2 = atoi(elems[1].c_str());
for (vector<int>::iterator it=testGT.begin(); it!=testGT.end(); ++it)
{
Ptr<OR_imagenetObj> curr(new OR_imagenetObj);
curr->id = *it;
numberToString(test.back().size()+1, curr->image);
curr->image = "test/ILSVRC2010_test_" + curr->image + ".JPEG";
train.back().push_back(curr);
test.back().push_back(curr);
}
}
......
......@@ -41,7 +41,6 @@
#include "opencv2/datasets/or_mnist.hpp"
#include "opencv2/datasets/util.hpp"
#include "precomp.hpp"
namespace cv
{
......@@ -50,7 +49,7 @@ namespace datasets
using namespace std;
class CV_EXPORTS OR_mnistImp : public OR_mnist
class OR_mnistImp : public OR_mnist
{
public:
OR_mnistImp() {}
......
......@@ -41,7 +41,8 @@
#include "opencv2/datasets/or_sun.hpp"
#include "opencv2/datasets/util.hpp"
#include "precomp.hpp"
#include <map>
namespace cv
{
......@@ -50,7 +51,7 @@ namespace datasets
using namespace std;
class CV_EXPORTS OR_sunImp : public OR_sun
class OR_sunImp : public OR_sun
{
public:
OR_sunImp() {}
......@@ -61,6 +62,10 @@ public:
private:
void loadDataset(const string &path);
void loadDatasetPart(const string &path, vector< Ptr<Object> > &dataset_);
map<string, int> pathLabel;
};
/*OR_sunImp::OR_sunImp(const string &path)
......@@ -73,13 +78,40 @@ void OR_sunImp::load(const string &path)
loadDataset(path);
}
void OR_sunImp::loadDataset(const string &path)
void OR_sunImp::loadDatasetPart(const string &path, vector< Ptr<Object> > &dataset_)
{
train.push_back(vector< Ptr<Object> >());
test.push_back(vector< Ptr<Object> >());
validation.push_back(vector< Ptr<Object> >());
string line;
ifstream infile(path.c_str());
while (getline(infile, line))
{
Ptr<OR_sunObj> curr(new OR_sunObj);
curr->label = 397;
curr->name = line;
size_t pos = curr->name.rfind('/');
if (pos != string::npos)
{
string labelStr(curr->name.substr(0, pos+1));
map<string, int>::iterator it = pathLabel.find(labelStr);
if (it != pathLabel.end())
{
curr->label = (*it).second;
} else
{
curr->label = pathLabel.size();
pathLabel.insert(make_pair(labelStr, curr->label));
paths.push_back(labelStr);
}
curr->name = curr->name.substr(pos+1);
}
string classNameFile(path + "ClassName.txt");
dataset_.push_back(curr);
}
}
void OR_sunImp::loadDataset(const string &path)
{
/*string classNameFile(path + "ClassName.txt");
ifstream infile(classNameFile.c_str());
string line;
while (getline(infile, line))
......@@ -96,6 +128,29 @@ void OR_sunImp::loadDataset(const string &path)
}
train.back().push_back(curr);
}*/
for (unsigned int i=1; i<=10; ++i)
{
char tmp[3];
sprintf(tmp, "%u", i);
string numStr;
if (i<10)
{
numStr = string("0") + string(tmp);
} else
{
numStr = tmp;
}
string trainFile(path + "Partitions/Training_" + numStr + ".txt");
string testFile(path + "Partitions/Testing_" + numStr + ".txt");
train.push_back(vector< Ptr<Object> >());
test.push_back(vector< Ptr<Object> >());
validation.push_back(vector< Ptr<Object> >());
loadDatasetPart(trainFile, train.back());
loadDatasetPart(testFile, test.back());
}
}
......
......@@ -41,7 +41,6 @@
#include "opencv2/datasets/pd_caltech.hpp"
#include "opencv2/datasets/util.hpp"
#include "precomp.hpp"
namespace cv
{
......@@ -50,7 +49,7 @@ namespace datasets
using namespace std;
class CV_EXPORTS PD_caltechImp : public PD_caltech
class PD_caltechImp : public PD_caltech
{
public:
PD_caltechImp() {}
......
......@@ -41,7 +41,6 @@
#include "opencv2/datasets/slam_kitti.hpp"
#include "opencv2/datasets/util.hpp"
#include "precomp.hpp"
namespace cv
{
......@@ -50,7 +49,7 @@ namespace datasets
using namespace std;
class CV_EXPORTS SLAM_kittiImp : public SLAM_kitti
class SLAM_kittiImp : public SLAM_kitti
{
public:
SLAM_kittiImp() {}
......
......@@ -41,7 +41,6 @@
#include "opencv2/datasets/slam_tumindoor.hpp"
#include "opencv2/datasets/util.hpp"
#include "precomp.hpp"
#include <cstring>
......@@ -52,7 +51,7 @@ namespace datasets
using namespace std;
class CV_EXPORTS SLAM_tumindoorImp : public SLAM_tumindoor
class SLAM_tumindoorImp : public SLAM_tumindoor
{
public:
SLAM_tumindoorImp() {}
......
......@@ -41,7 +41,6 @@
#include "opencv2/datasets/tr_chars.hpp"
#include "opencv2/datasets/util.hpp"
#include "precomp.hpp"
namespace cv
{
......@@ -50,7 +49,7 @@ namespace datasets
using namespace std;
class CV_EXPORTS TR_charsImp : public TR_chars
class TR_charsImp : public TR_chars
{
public:
TR_charsImp() {}
......
......@@ -41,7 +41,6 @@
#include "opencv2/datasets/tr_svt.hpp"
#include "opencv2/datasets/util.hpp"
#include "precomp.hpp"
#include <opencv2/datasets/tinyxml2/tinyxml2.h>
......@@ -53,7 +52,7 @@ namespace datasets
using namespace std;
using namespace tinyxml2;
class CV_EXPORTS TR_svtImp : public TR_svt
class TR_svtImp : public TR_svt
{
public:
TR_svtImp() {}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment