vendor: OpenCV 5.0.0 snapshot at 755e50675d97db9b7d449d8bd6b09888646f6c6e

This commit is contained in:
Gitea Mirror Bot
2026-08-22 00:11:13 +08:00
commit 12022378a3
3872 changed files with 2513409 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
set(the_description "datasets framework")
set(filter_srcs "${CMAKE_CURRENT_LIST_DIR}/src/tinyxml2/tinyxml2.cpp")
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
ocv_append_source_files_cxx_compiler_options(filter_srcs "-Wno-suggest-override") # GCC
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
ocv_append_source_files_cxx_compiler_options(filter_srcs "-Wno-inconsistent-missing-override") # Clang
endif()
ocv_define_module(datasets opencv_core opencv_imgcodecs opencv_ml opencv_flann OPTIONAL opencv_text WRAP python)
ocv_warnings_disable(CMAKE_CXX_FLAGS
/wd4267 # flann, Win64
-Wimplicit-fallthrough # tinyxml2.cpp
)
+6
View File
@@ -0,0 +1,6 @@
Interface for interfacing with existing computer vision databases
=================================================================
In the src directory, there is code for reading many of the existing computer vision databases.
In the samples directory, there are examples of using the above code to read, train and test on the data.
@@ -0,0 +1,80 @@
/*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_AR_HMDB_HPP
#define OPENCV_DATASETS_AR_HMDB_HPP
#include <string>
#include <vector>
#include "opencv2/datasets/dataset.hpp"
#include <opencv2/core.hpp>
namespace cv
{
namespace datasets
{
//! @addtogroup datasets_ar
//! @{
struct AR_hmdbObj : public Object
{
int id;
std::string name;
std::string videoName;
};
class CV_EXPORTS AR_hmdb : public Dataset
{
public:
virtual void load(const std::string &path) CV_OVERRIDE = 0;
static Ptr<AR_hmdb> create();
};
//! @}
}
}
#endif
@@ -0,0 +1,79 @@
/*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_AR_SPORTS_HPP
#define OPENCV_DATASETS_AR_SPORTS_HPP
#include <string>
#include <vector>
#include "opencv2/datasets/dataset.hpp"
#include <opencv2/core.hpp>
namespace cv
{
namespace datasets
{
//! @addtogroup datasets_ar
//! @{
struct AR_sportsObj : public Object
{
std::string videoUrl;
std::vector<int> labels;
};
class CV_EXPORTS AR_sports : public Dataset
{
public:
virtual void load(const std::string &path) CV_OVERRIDE = 0;
static Ptr<AR_sports> create();
};
//! @}
}
}
#endif
@@ -0,0 +1,592 @@
/*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_DATASET_HPP
#define OPENCV_DATASETS_DATASET_HPP
#include <string>
#include <vector>
#include <opencv2/core.hpp>
/** @defgroup datasets Framework for working with different datasets
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.
@{
@defgroup datasets_ar Action Recognition
### HMDB: A Large Human Motion Database
Implements loading dataset:
"HMDB: A Large Human Motion Database": <http://serre-lab.clps.brown.edu/resource/hmdb-a-large-human-motion-database/>
Usage:
-# From link above download dataset files: `hmdb51_org.rar` & `test_train_splits.rar`.
-# Unpack them. Unpack all archives from directory: `hmdb51_org/` and remove them.
-# To load data run:
~~~
./opencv/build/bin/example_datasets_ar_hmdb -p=/home/user/path_to_unpacked_folders/
~~~
#### Benchmark
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:
~~~
./opencv/build/bin/example_datasets_ar_hmdb_benchmark -p=/home/user/path_to_unpacked_folders/
~~~
@note
Precomputed features should be unpacked in the same folder: `/home/user/path_to_unpacked_folders/hmdb51_org_stips/`.
Also unpack all archives from directory: `hmdb51_org_stips/` and remove them.
### Sports-1M %Dataset
Implements loading dataset:
"Sports-1M Dataset": <http://cs.stanford.edu/people/karpathy/deepvideo/>
Usage:
-# From link above download dataset files (`git clone https://code.google.com/p/sports-1m-dataset/`).
-# To load data run:
~~~
./opencv/build/bin/example_datasets_ar_sports -p=/home/user/path_to_downloaded_folders/
~~~
@defgroup datasets_fr Face Recognition
### Adience
Implements loading dataset:
"Adience": <http://www.openu.ac.il/home/hassner/Adience/data.html>
Usage:
-# 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)
-# Unpack dataset file to some folder and place split files into the same folder.
-# To load data run:
~~~
./opencv/build/bin/example_datasets_fr_adience -p=/home/user/path_to_created_folder/
~~~
### Labeled Faces in the Wild
Implements loading dataset:
"Labeled Faces in the Wild": <http://vis-www.cs.umass.edu/lfw/>
Usage:
-# 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`.
-# Unpack dataset file and place `pairs.txt` and `pairsDevTrain.txt` in created folder.
-# To load data run:
~~~
./opencv/build/bin/example_datasets_fr_lfw -p=/home/user/path_to_unpacked_folder/lfw2/
~~~
#### Benchmark
For this dataset was implemented benchmark with accuracy: 0.623833 +- 0.005223 (train split:
`pairsDevTrain.txt`, dataset: lfwa)
To run this benchmark execute:
~~~
./opencv/build/bin/example_datasets_fr_lfw_benchmark -p=/home/user/path_to_unpacked_folder/lfw2/
~~~
@defgroup datasets_gr Gesture Recognition
### ChaLearn Looking at People
Implements loading dataset:
"ChaLearn Looking at People": <http://gesture.chalearn.org/>
Usage
-# 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).
-# Unpack train archives `Train1.zip`-`Train5.zip` to folder `Train/`, validation archives
`Validation1.zip`-`Validation3.zip` to folder `Validation/`
-# Unpack all archives in `Train/` & `Validation/` in the folders with the same names, for example:
`Sample0001.zip` to `Sample0001/`
-# To load data run:
~~~
./opencv/build/bin/example_datasets_gr_chalearn -p=/home/user/path_to_unpacked_folders/
~~~
### Sheffield Kinect Gesture Dataset
Implements loading dataset:
"Sheffield Kinect Gesture Dataset": <http://lshao.staff.shef.ac.uk/data/SheffieldKinectGesture.htm>
Usage:
-# From link above download dataset files: `subject1_dep.7z`-`subject6_dep.7z`, `subject1_rgb.7z`-`subject6_rgb.7z`.
-# Unpack them.
-# To load data run:
~~~
./opencv/build/bin/example_datasets_gr_skig -p=/home/user/path_to_unpacked_folders/
~~~
@defgroup datasets_hpe Human Pose Estimation
### HumanEva Dataset
Implements loading dataset:
"HumanEva Dataset": <http://humaneva.is.tue.mpg.de>
Usage:
-# From link above download dataset files for `HumanEva-I` (tar) & `HumanEva-II`.
-# Unpack them to `HumanEva_1` & `HumanEva_2` accordingly.
-# To load data run:
~~~
./opencv/build/bin/example_datasets_hpe_humaneva -p=/home/user/path_to_unpacked_folders/
~~~
### PARSE Dataset
Implements loading dataset:
"PARSE Dataset": <http://www.ics.uci.edu/~dramanan/papers/parse/>
Usage:
-# From link above download dataset file: `people.zip`.
-# Unpack it.
-# To load data run:
~~~
./opencv/build/bin/example_datasets_hpe_parse -p=/home/user/path_to_unpacked_folder/people_all/
~~~
@defgroup datasets_ir Image Registration
### Affine Covariant Regions Datasets
Implements loading dataset:
"Affine Covariant Regions Datasets": <http://www.robots.ox.ac.uk/~vgg/data/data-aff.html>
Usage:
-# From link above download dataset files:
`bark\bikes\boat\graf\leuven\trees\ubc\wall.tar.gz`.
-# Unpack them.
-# To load data, for example, for "bark", run:
```
./opencv/build/bin/example_datasets_ir_affine -p=/home/user/path_to_unpacked_folder/bark/
```
### Robot Data Set
Implements loading dataset:
"Robot Data Set, Point Feature Data Set 2010": <http://roboimagedata.compute.dtu.dk/?page_id=24>
Usage:
-# From link above download dataset files: `SET001_6.tar.gz`-`SET055_60.tar.gz`
-# Unpack them to one folder.
-# To load data run:
~~~
./opencv/build/bin/example_datasets_ir_robot -p=/home/user/path_to_unpacked_folder/
~~~
@defgroup datasets_is Image Segmentation
### The Berkeley Segmentation Dataset and Benchmark
Implements loading dataset:
"The Berkeley Segmentation Dataset and Benchmark": <https://www.eecs.berkeley.edu/Research/Projects/CS/vision/bsds/>
Usage:
-# From link above download dataset files: `BSDS300-human.tgz` & `BSDS300-images.tgz`.
-# Unpack them.
-# To load data run:
~~~
./opencv/build/bin/example_datasets_is_bsds -p=/home/user/path_to_unpacked_folder/BSDS300/
~~~
### Weizmann Segmentation Evaluation Database
Implements loading dataset:
"Weizmann Segmentation Evaluation Database": <http://www.wisdom.weizmann.ac.il/~vision/Seg_Evaluation_DB/>
Usage:
-# From link above download dataset files: `Weizmann_Seg_DB_1obj.ZIP` & `Weizmann_Seg_DB_2obj.ZIP`.
-# Unpack them.
-# 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/
~~~
@defgroup datasets_msm Multiview Stereo Matching
### EPFL Multi-View Stereo
Implements loading dataset:
"EPFL Multi-View Stereo": <http://cvlab.epfl.ch/data/strechamvs>
Usage:
-# From link above download dataset files:
`castle_dense\castle_dense_large\castle_entry\fountain\herzjesu_dense\herzjesu_dense_large_bounding\cameras\images\p.tar.gz`.
-# Unpack them in separate folder for each object. For example, for "fountain", in folder `fountain/` :
`fountain_dense_bounding.tar.gz -> bounding/`,
`fountain_dense_cameras.tar.gz -> camera/`,
`fountain_dense_images.tar.gz -> png/`,
`fountain_dense_p.tar.gz -> P/`
-# To load data, for example, for "fountain", run:
~~~
./opencv/build/bin/example_datasets_msm_epfl -p=/home/user/path_to_unpacked_folder/fountain/
~~~
### Stereo Middlebury Computer Vision
Implements loading dataset:
"Stereo Middlebury Computer Vision": <http://vision.middlebury.edu/mview/>
Usage:
-# From link above download dataset files:
`dino\dinoRing\dinoSparseRing\temple\templeRing\templeSparseRing.zip`
-# Unpack them.
-# To load data, for example "temple" dataset, run:
~~~
./opencv/build/bin/example_datasets_msm_middlebury -p=/home/user/path_to_unpacked_folder/temple/
~~~
@defgroup datasets_or Object Recognition
### ImageNet
Implements loading dataset: "ImageNet": <http://www.image-net.org/>
Usage:
-# 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)
-# 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`.
-# Create file with labels: `some_folder/labels.txt`, for example, using python script below (each
file's row format: `synset,labelID,description`. For example: "n07751451,18,plum").
-# Unpack all tar files in train.
-# To load data run:
~~~
./opencv/build/bin/example_datasets_or_imagenet -p=/home/user/some_folder/
~~~
Python script to parse `meta.mat`:
~~~{py}
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])
~~~
### MNIST
Implements loading dataset:
"MNIST": <http://yann.lecun.com/exdb/mnist/>
Usage:
-# 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`.
-# Unpack them.
-# To load data run:
~~~
./opencv/build/bin/example_datasets_or_mnist -p=/home/user/path_to_unpacked_files/
~~~
### SUN Database
Implements loading dataset:
"SUN Database, Scene Recognition Benchmark. SUN397": <http://vision.cs.princeton.edu/projects/2010/SUN/>
Usage:
-# From link above download dataset file: `SUN397.tar` & file with splits: `Partitions.zip`
-# Unpack `SUN397.tar` into folder: `SUN397/` & `Partitions.zip` into folder: `SUN397/Partitions/`
-# To load data run:
~~~
./opencv/build/bin/example_datasets_or_sun -p=/home/user/path_to_unpacked_files/SUN397/
~~~
@defgroup datasets_pd Pedestrian Detection
### Caltech Pedestrian Detection Benchmark
Implements loading dataset:
"Caltech Pedestrian Detection Benchmark": <http://www.vision.caltech.edu/Image_Datasets/CaltechPedestrians/>
@note First version of Caltech Pedestrian dataset loading. Code to unpack all frames from seq files
commented as their number is huge! So currently load only meta information without data. Also
ground truth isn't processed, as need to convert it from mat files first.
Usage:
-# From link above download dataset files: `set00.tar`-`set10.tar`.
-# Unpack them to separate folder.
-# To load data run:
~~~
./opencv/build/bin/example_datasets_pd_caltech -p=/home/user/path_to_unpacked_folders/
~~~
@defgroup datasets_slam SLAM
### KITTI Vision Benchmark
Implements loading dataset:
"KITTI Vision Benchmark": <http://www.cvlibs.net/datasets/kitti/eval_odometry.php>
Usage:
-# From link above download "Odometry" dataset files:
`data_odometry_gray\data_odometry_color\data_odometry_velodyne\data_odometry_poses\data_odometry_calib.zip`.
-# Unpack `data_odometry_poses.zip`, it creates folder `dataset/poses/`. After that unpack
`data_odometry_gray.zip`, `data_odometry_color.zip`, `data_odometry_velodyne.zip`. Folder
`dataset/sequences/` will be created with folders `00/..21/`. Each of these folders will contain:
`image_0/`, `image_1/`, `image_2/`, `image_3/`, `velodyne/` and files `calib.txt` & `times.txt`.
These two last files will be replaced after unpacking `data_odometry_calib.zip` at the end.
-# To load data run:
~~~
./opencv/build/bin/example_datasets_slam_kitti -p=/home/user/path_to_unpacked_folder/dataset/
~~~
### TUMindoor Dataset
Implements loading dataset:
"TUMindoor Dataset": <http://www.navvis.lmt.ei.tum.de/dataset/>
Usage:
-# From link above download dataset files: `dslr\info\ladybug\pointcloud.tar.bz2` for each dataset:
`11-11-28 (1st floor)\11-12-13 (1st floor N1)\11-12-17a (4th floor)\11-12-17b (3rd floor)\11-12-17c (Ground I)\11-12-18a (Ground II)\11-12-18b (2nd floor)`
-# Unpack them in separate folder for each dataset.
`dslr.tar.bz2 -> dslr/`,
`info.tar.bz2 -> info/`,
`ladybug.tar.bz2 -> ladybug/`,
`pointcloud.tar.bz2 -> pointcloud/`.
-# To load each dataset run:
~~~
./opencv/build/bin/example_datasets_slam_tumindoor -p=/home/user/path_to_unpacked_folders/
~~~
@defgroup datasets_sr Super Resolution
### The Berkeley Segmentation Dataset and Benchmark
Implements loading dataset:
"The Berkeley Segmentation Dataset and Benchmark": <https://www2.eecs.berkeley.edu/Research/Projects/CS/vision/grouping/segbench/>
Usage:
-# From link above download `BSDS300-images.tgz`.
-# Unpack.
-# To load data run:
~~~
./opencv/build/bin/example_datasets_sr_bsds -p=/home/user/path_to_unpacked_folder/
~~~
### DIV2K dataset: DIVerse 2K
Implements loading dataset:
"DIV2K dataset: DIVerse 2K": <https://data.vision.ee.ethz.ch/cvl/DIV2K/>
Usage:
-# From link above download 'Train data (HR images)' or any other of the dataset files.
-# Unpack.
-# To load data run:
~~~
./opencv/build/bin/example_datasets_sr_div2k -p=/home/user/path_to_unpacked_folder/folder_containing_the_images/
~~~
### The General-100 Dataset
Implements loading dataset:
"General-100 dataset contains 100 bmp-format images (with no compression).
We used this dataset in our FSRCNN ECCV 2016 paper. The size of these 100 images ranges from 710 x 704 (large) to 131 x 112 (small).
They are all of good quality with clear edges but fewer smooth regions (e.g., sky and ocean), thus are very suitable for the super-resolution training.":
<http://mmlab.ie.cuhk.edu.hk/projects/FSRCNN.html>
Usage:
-# From link above download `General-100.zip`.
-# Unpack.
-# To load data run:
~~~
./opencv/build/bin/example_datasets_sr_general100 -p=/home/user/path_to_unpacked_folder/
~~~
@defgroup datasets_tr Text Recognition
### The Chars74K Dataset
Implements loading dataset:
"The Chars74K Dataset": <http://www.ee.surrey.ac.uk/CVSSP/demos/chars74k/>
Usage:
-# From link above download dataset files:
`EnglishFnt\EnglishHnd\EnglishImg\KannadaHnd\KannadaImg.tgz`, `ListsTXT.tgz`.
-# Unpack them.
-# Move `.m` files from folder `ListsTXT/` to appropriate folder. For example,
`English/list_English_Img.m` for `EnglishImg.tgz`.
-# To load data, for example "EnglishImg", run:
~~~
./opencv/build/bin/example_datasets_tr_chars -p=/home/user/path_to_unpacked_folder/English/
~~~
### The Street View Text Dataset
Implements loading dataset:
"The Street View Text Dataset": <http://vision.ucsd.edu/~kai/svt/>
Usage:
-# From link above download dataset file: `svt.zip`.
-# Unpack it.
-# 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:
~~~
./opencv/build/bin/example_datasets_tr_svt_benchmark -p=/home/user/path_to_unpacked_folders/svt/svt1/
~~~
@defgroup datasets_track Tracking
### VOT 2015 Database
Implements loading dataset:
"VOT 2015 dataset comprises 60 short sequences showing various objects in challenging backgrounds.
The sequences were chosen from a large pool of sequences including the ALOV dataset, OTB2 dataset,
non-tracking datasets, Computer Vision Online, Professor Bob Fisher's Image Database, Videezy,
Center for Research in Computer Vision, University of Central Florida, USA, NYU Center for Genomics
and Systems Biology, Data Wrangling, Open Access Directory and Learning and Recognition in Vision
Group, INRIA, France. The VOT sequence selection protocol was applied to obtain a representative
set of challenging sequences.": <http://box.vicos.si/vot/vot2015.zip>
Usage:
-# From link above download dataset file: `vot2015.zip`
-# Unpack `vot2015.zip` into folder: `VOT2015/`
-# To load data run:
~~~
./opencv/build/bin/example_datasets_track_vot -p=/home/user/path_to_unpacked_files/VOT2015/
~~~
@}
*/
namespace cv
{
namespace datasets
{
//! @addtogroup datasets
//! @{
struct Object
{
};
class CV_EXPORTS Dataset
{
public:
Dataset() {}
virtual ~Dataset() {}
virtual void load(const std::string &path) = 0;
std::vector< Ptr<Object> >& getTrain(int splitNum = 0);
std::vector< Ptr<Object> >& getTest(int splitNum = 0);
std::vector< Ptr<Object> >& getValidation(int splitNum = 0);
int getNumSplits() const;
protected:
std::vector< std::vector< Ptr<Object> > > train;
std::vector< std::vector< Ptr<Object> > > test;
std::vector< std::vector< Ptr<Object> > > validation;
private:
std::vector< Ptr<Object> > empty;
};
//! @}
}
}
#endif
@@ -0,0 +1,98 @@
/*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
{
//! @addtogroup datasets_fr
//! @{
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) CV_OVERRIDE = 0;
static Ptr<FR_adience> create();
std::vector<std::string> paths;
};
//! @}
}
}
#endif
@@ -0,0 +1,79 @@
/*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_LFW_HPP
#define OPENCV_DATASETS_FR_LFW_HPP
#include <string>
#include <vector>
#include "opencv2/datasets/dataset.hpp"
#include <opencv2/core.hpp>
namespace cv
{
namespace datasets
{
//! @addtogroup datasets_fr
//! @{
struct FR_lfwObj : public Object
{
std::string image1, image2;
bool same;
};
class CV_EXPORTS FR_lfw : public Dataset
{
public:
virtual void load(const std::string &path) CV_OVERRIDE = 0;
static Ptr<FR_lfw> create();
};
//! @}
}
}
#endif
@@ -0,0 +1,96 @@
/*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_GR_CHALEARN_HPP
#define OPENCV_DATASETS_GR_CHALEARN_HPP
#include <string>
#include <vector>
#include "opencv2/datasets/dataset.hpp"
#include <opencv2/core.hpp>
namespace cv
{
namespace datasets
{
//! @addtogroup datasets_gr
//! @{
struct groundTruth
{
int gestureID, initialFrame, lastFrame;
};
struct join
{
double Wx, Wy, Wz, Rx, Ry, Rz, Rw, Px, Py;
};
struct skeleton
{
join s[20];
};
struct GR_chalearnObj : public Object
{
std::string name, nameColor, nameDepth, nameUser;
int numFrames, fps, depth;
std::vector<groundTruth> groundTruths;
std::vector<skeleton> skeletons;
};
class CV_EXPORTS GR_chalearn : public Dataset
{
public:
virtual void load(const std::string &path) CV_OVERRIDE = 0;
static Ptr<GR_chalearn> create();
};
//! @}
}
}
#endif
@@ -0,0 +1,118 @@
/*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_GR_SKIG_HPP
#define OPENCV_DATASETS_GR_SKIG_HPP
#include <string>
#include <vector>
#include "opencv2/datasets/dataset.hpp"
#include <opencv2/core.hpp>
namespace cv
{
namespace datasets
{
//! @addtogroup datasets_gr
//! @{
enum actionType
{
circle = 1,
triangle,
updown,
rightleft,
wave,
z,
cross,
comehere,
turnaround,
pat
};
enum poseType
{
fist = 1,
index,
flat
};
enum illuminationType
{
light = 1,
dark
};
enum backgroundType
{
woodenBoard = 1,
whitePaper,
paperWithCharacters
};
struct GR_skigObj : public Object
{
std::string rgb;
std::string dep;
char person; // 1..6
backgroundType background;
illuminationType illumination;
poseType pose;
actionType type;
};
class CV_EXPORTS GR_skig : public Dataset
{
public:
virtual void load(const std::string &path) CV_OVERRIDE = 0;
static Ptr<GR_skig> create();
};
//! @}
}
}
#endif
@@ -0,0 +1,90 @@
/*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_HPE_HUMANEVA_HPP
#define OPENCV_DATASETS_HPE_HUMANEVA_HPP
#include <string>
#include <vector>
#include "opencv2/datasets/dataset.hpp"
#include <opencv2/core.hpp>
namespace cv
{
namespace datasets
{
//! @addtogroup datasets_hpe
//! @{
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) CV_OVERRIDE = 0;
static Ptr<HPE_humaneva> create(int num=humaneva_1);
};
//! @}
}
}
#endif
@@ -0,0 +1,78 @@
/*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_HPE_PARSE_HPP
#define OPENCV_DATASETS_HPE_PARSE_HPP
#include <string>
#include <vector>
#include "opencv2/datasets/dataset.hpp"
#include <opencv2/core.hpp>
namespace cv
{
namespace datasets
{
//! @addtogroup datasets_hpe
//! @{
struct HPE_parseObj : public Object
{
std::string name;
};
class CV_EXPORTS HPE_parse : public Dataset
{
public:
virtual void load(const std::string &path) CV_OVERRIDE = 0;
static Ptr<HPE_parse> create();
};
//! @}
}
}
#endif
@@ -0,0 +1,80 @@
/*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_IR_AFFINE_HPP
#define OPENCV_DATASETS_IR_AFFINE_HPP
#include <string>
#include <vector>
#include "opencv2/datasets/dataset.hpp"
#include <opencv2/core.hpp>
#include <opencv2/core/matx.hpp>
namespace cv
{
namespace datasets
{
//! @addtogroup datasets_ir
//! @{
struct IR_affineObj : public Object
{
std::string imageName;
Matx33d mat;
};
class CV_EXPORTS IR_affine : public Dataset
{
public:
virtual void load(const std::string &path) CV_OVERRIDE = 0;
static Ptr<IR_affine> create();
};
//! @}
}
}
#endif
@@ -0,0 +1,89 @@
/*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_IR_ROBOT_HPP
#define OPENCV_DATASETS_IR_ROBOT_HPP
#include <string>
#include <vector>
#include "opencv2/datasets/dataset.hpp"
#include <opencv2/core.hpp>
namespace cv
{
namespace datasets
{
//! @addtogroup datasets_ir
//! @{
// calibration matrix from calibrationFile.mat
// 2.8290e+03 0.0000e+00 8.0279e+02
// 0.0000e+00 2.8285e+03 6.1618e+02
// 0.0000e+00 0.0000e+00 1.0000e+00
struct cameraPos
{
std::vector<std::string> images;
};
struct IR_robotObj : public Object
{
std::string name;
std::vector<cameraPos> pos;
};
class CV_EXPORTS IR_robot : public Dataset
{
public:
virtual void load(const std::string &path) CV_OVERRIDE = 0;
static Ptr<IR_robot> create();
};
//! @}
}
}
#endif
@@ -0,0 +1,78 @@
/*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_IS_BSDS_HPP
#define OPENCV_DATASETS_IS_BSDS_HPP
#include <string>
#include <vector>
#include "opencv2/datasets/dataset.hpp"
#include <opencv2/core.hpp>
namespace cv
{
namespace datasets
{
//! @addtogroup datasets_is
//! @{
struct IS_bsdsObj : public Object
{
std::string name;
};
class CV_EXPORTS IS_bsds : public Dataset
{
public:
virtual void load(const std::string &path) CV_OVERRIDE = 0;
static Ptr<IS_bsds> create();
};
//! @}
}
}
#endif
@@ -0,0 +1,81 @@
/*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_IS_WEIZMANN_HPP
#define OPENCV_DATASETS_IS_WEIZMANN_HPP
#include <string>
#include <vector>
#include "opencv2/datasets/dataset.hpp"
#include <opencv2/core.hpp>
namespace cv
{
namespace datasets
{
//! @addtogroup datasets_is
//! @{
struct IS_weizmannObj : public Object
{
std::string imageName;
std::string srcBw;
std::string srcColor;
std::string humanSeg; // TODO: read human segmented
};
class CV_EXPORTS IS_weizmann : public Dataset
{
public:
virtual void load(const std::string &path) CV_OVERRIDE = 0;
static Ptr<IS_weizmann> create();
};
//! @}
}
}
#endif
@@ -0,0 +1,90 @@
/*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_MSM_EPFL_HPP
#define OPENCV_DATASETS_MSM_EPFL_HPP
#include <string>
#include <vector>
#include "opencv2/datasets/dataset.hpp"
#include <opencv2/core.hpp>
namespace cv
{
namespace datasets
{
//! @addtogroup datasets_msm
//! @{
struct cameraParam
{
Matx33d mat1;
double mat2[3];
Matx33d mat3;
double mat4[3];
int imageWidth, imageHeight;
};
struct MSM_epflObj : public Object
{
std::string imageName;
Matx23d bounding;
Matx34d p;
cameraParam camera;
};
class CV_EXPORTS MSM_epfl : public Dataset
{
public:
virtual void load(const std::string &path) CV_OVERRIDE = 0;
static Ptr<MSM_epfl> create();
};
//! @}
}
}
#endif
@@ -0,0 +1,81 @@
/*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_MSM_MIDDLEBURY_HPP
#define OPENCV_DATASETS_MSM_MIDDLEBURY_HPP
#include <string>
#include <vector>
#include "opencv2/datasets/dataset.hpp"
#include <opencv2/core.hpp>
namespace cv
{
namespace datasets
{
//! @addtogroup datasets_msm
//! @{
struct MSM_middleburyObj : public Object
{
std::string imageName;
Matx33d k;
Matx33d r;
double t[3];
};
class CV_EXPORTS MSM_middlebury : public Dataset
{
public:
virtual void load(const std::string &path) CV_OVERRIDE = 0;
static Ptr<MSM_middlebury> create();
};
//! @}
}
}
#endif
@@ -0,0 +1,79 @@
/*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_OR_IMAGENET_HPP
#define OPENCV_DATASETS_OR_IMAGENET_HPP
#include <string>
#include <vector>
#include "opencv2/datasets/dataset.hpp"
#include <opencv2/core.hpp>
namespace cv
{
namespace datasets
{
//! @addtogroup datasets_or
//! @{
struct OR_imagenetObj : public Object
{
int id;
std::string image;
};
class CV_EXPORTS OR_imagenet : public Dataset
{
public:
virtual void load(const std::string &path) CV_OVERRIDE = 0;
static Ptr<OR_imagenet> create();
};
//! @}
}
}
#endif
@@ -0,0 +1,79 @@
/*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_OR_MNIST_HPP
#define OPENCV_DATASETS_OR_MNIST_HPP
#include <string>
#include <vector>
#include "opencv2/datasets/dataset.hpp"
#include <opencv2/core.hpp>
namespace cv
{
namespace datasets
{
//! @addtogroup datasets_or
//! @{
struct OR_mnistObj : public Object
{
char label; // 0..9
Mat image; // [28][28]
};
class CV_EXPORTS OR_mnist : public Dataset
{
public:
virtual void load(const std::string &path) CV_OVERRIDE = 0;
static Ptr<OR_mnist> create();
};
//! @}
}
}
#endif
@@ -0,0 +1,102 @@
/*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) 2015, 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_VOC_PASCAL_HPP
#define OPENCV_DATASETS_VOC_PASCAL_HPP
#include <string>
#include <vector>
#include "opencv2/datasets/dataset.hpp"
#include <opencv2/core.hpp>
namespace cv
{
namespace datasets
{
//! @addtogroup datasets_or
//! @{
struct PascalPart: public Object
{
std::string name;
int xmin;
int ymin;
int xmax;
int ymax;
};
struct PascalObj: public PascalPart
{
std::string pose;
bool truncated;
bool difficult;
bool occluded;
std::vector<PascalPart> parts;
};
struct OR_pascalObj : public Object
{
std::string filename;
int width;
int height;
int depth;
std::vector<PascalObj> objects;
};
class CV_EXPORTS OR_pascal : public Dataset
{
public:
virtual void load(const std::string &path) CV_OVERRIDE = 0;
static Ptr<OR_pascal> create();
};
//! @}
}// namespace dataset
}// namespace cv
#endif
@@ -0,0 +1,81 @@
/*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_OR_SUN_HPP
#define OPENCV_DATASETS_OR_SUN_HPP
#include <string>
#include <vector>
#include "opencv2/datasets/dataset.hpp"
#include <opencv2/core.hpp>
namespace cv
{
namespace datasets
{
//! @addtogroup datasets_or
//! @{
struct OR_sunObj : public Object
{
int label;
std::string name;
};
class CV_EXPORTS OR_sun : public Dataset
{
public:
virtual void load(const std::string &path) CV_OVERRIDE = 0;
static Ptr<OR_sun> create();
std::vector<std::string> paths;
};
//! @}
}
}
#endif
@@ -0,0 +1,89 @@
/*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_PD_CALTECH_HPP
#define OPENCV_DATASETS_PD_CALTECH_HPP
#include <string>
#include <vector>
#include "opencv2/datasets/dataset.hpp"
#include <opencv2/core.hpp>
namespace cv
{
namespace datasets
{
//! @addtogroup datasets_pd
//! @{
struct PD_caltechObj : public Object
{
//double groundTrue[][];
//Mat image;
std::string name;
std::vector< std::string > imageNames;
};
//
// first version of Caltech Pedestrian dataset loading
// code to unpack all frames from seq files commented as their number is huge
// so currently load only meta information without data
//
// also ground truth isn't processed, as need to convert it from mat files first
//
class CV_EXPORTS PD_caltech : public Dataset
{
public:
virtual void load(const std::string &path) CV_OVERRIDE = 0;
static Ptr<PD_caltech> create();
};
//! @}
}
}
#endif
@@ -0,0 +1,96 @@
/*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) 2015, 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_PD_INRIA_HPP
#define OPENCV_DATASETS_PD_INRIA_HPP
#include <string>
#include <vector>
#include "opencv2/datasets/dataset.hpp"
#include <opencv2/core.hpp>
namespace cv
{
namespace datasets
{
//! @addtogroup datasets_pd
//! @{
enum sampleType
{
POS = 0,
NEG = 1
};
struct PD_inriaObj : public Object
{
// image file name
std::string filename;
// positive or negative
sampleType sType;
// image size
int width;
int height;
int depth;
// bounding boxes
std::vector< Rect > bndboxes;
};
class CV_EXPORTS PD_inria : public Dataset
{
public:
virtual void load(const std::string &path) CV_OVERRIDE = 0;
static Ptr<PD_inria> create();
};
//! @}
}
}
#endif
@@ -0,0 +1,87 @@
/*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_SLAM_KITTI_HPP
#define OPENCV_DATASETS_SLAM_KITTI_HPP
#include <string>
#include <vector>
#include "opencv2/datasets/dataset.hpp"
#include <opencv2/core.hpp>
namespace cv
{
namespace datasets
{
//! @addtogroup datasets_slam
//! @{
struct pose
{
double elem[12];
};
struct SLAM_kittiObj : public Object
{
std::string name;
std::vector<std::string> images[4];
std::vector<std::string> velodyne;
std::vector<double> times, p[4];
std::vector<pose> posesArray;
};
class CV_EXPORTS SLAM_kitti : public Dataset
{
public:
virtual void load(const std::string &path) CV_OVERRIDE = 0;
static Ptr<SLAM_kitti> create();
};
//! @}
}
}
#endif
@@ -0,0 +1,87 @@
/*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_SLAM_TUMINDOOR_HPP
#define OPENCV_DATASETS_SLAM_TUMINDOOR_HPP
#include <string>
#include <vector>
#include "opencv2/datasets/dataset.hpp"
#include <opencv2/core.hpp>
namespace cv
{
namespace datasets
{
//! @addtogroup datasets_slam
//! @{
enum imageType
{
LEFT = 0,
RIGHT,
LADYBUG
};
struct SLAM_tumindoorObj : public Object
{
std::string name;
Matx44d transformMat;
imageType type;
};
class CV_EXPORTS SLAM_tumindoor : public Dataset
{
public:
virtual void load(const std::string &path) CV_OVERRIDE = 0;
static Ptr<SLAM_tumindoor> create();
};
//! @}
}
}
#endif
@@ -0,0 +1,41 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#ifndef OPENCV_DATASETS_SR_BSDS_HPP
#define OPENCV_DATASETS_SR_BSDS_HPP
#include <string>
#include <vector>
#include "opencv2/datasets/dataset.hpp"
#include <opencv2/core.hpp>
namespace cv
{
namespace datasets
{
//! @addtogroup datasets_sr
//! @{
struct SR_bsdsObj : public Object
{
std::string imageName;
};
class CV_EXPORTS SR_bsds : public Dataset
{
public:
virtual void load(const std::string &path) CV_OVERRIDE = 0;
static Ptr<SR_bsds> create();
};
//! @}
}
}
#endif
@@ -0,0 +1,41 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#ifndef OPENCV_DATASETS_SR_DIV2K_HPP
#define OPENCV_DATASETS_SR_DIV2K_HPP
#include <string>
#include <vector>
#include "opencv2/datasets/dataset.hpp"
#include <opencv2/core.hpp>
namespace cv
{
namespace datasets
{
//! @addtogroup datasets_sr
//! @{
struct SR_div2kObj : public Object
{
std::string imageName;
};
class CV_EXPORTS SR_div2k : public Dataset
{
public:
virtual void load(const std::string &path) CV_OVERRIDE = 0;
static Ptr<SR_div2k> create();
};
//! @}
}
}
#endif
@@ -0,0 +1,41 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#ifndef OPENCV_DATASETS_SR_GENERAL100_HPP
#define OPENCV_DATASETS_SR_GENERAL100_HPP
#include <string>
#include <vector>
#include "opencv2/datasets/dataset.hpp"
#include <opencv2/core.hpp>
namespace cv
{
namespace datasets
{
//! @addtogroup datasets_sr
//! @{
struct SR_general100Obj : public Object
{
std::string imageName;
};
class CV_EXPORTS SR_general100 : public Dataset
{
public:
virtual void load(const std::string &path) CV_OVERRIDE = 0;
static Ptr<SR_general100> create();
};
//! @}
}
}
#endif
@@ -0,0 +1,79 @@
/*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_TR_CHARS_HPP
#define OPENCV_DATASETS_TR_CHARS_HPP
#include <string>
#include <vector>
#include "opencv2/datasets/dataset.hpp"
#include <opencv2/core.hpp>
namespace cv
{
namespace datasets
{
//! @addtogroup datasets_tr
//! @{
struct TR_charsObj : public Object
{
std::string imgName;
int label;
};
class CV_EXPORTS TR_chars : public Dataset
{
public:
virtual void load(const std::string &path) CV_OVERRIDE = 0;
static Ptr<TR_chars> create();
};
//! @}
}
}
#endif
@@ -0,0 +1,87 @@
/*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_TR_ICDAR_HPP
#define OPENCV_DATASETS_TR_ICDAR_HPP
#include <string>
#include <vector>
#include "opencv2/datasets/dataset.hpp"
#include <opencv2/core.hpp>
namespace cv
{
namespace datasets
{
//! @addtogroup datasets_tr
//! @{
struct word
{
std::string value;
int height, width, x, y;
};
struct TR_icdarObj : public Object
{
std::string fileName;
std::vector<std::string> lex100;
std::vector<std::string> lexFull;
std::vector<word> words;
};
class CV_EXPORTS TR_icdar : public Dataset
{
public:
virtual void load(const std::string &path) CV_OVERRIDE = 0;
static Ptr<TR_icdar> create();
};
//! @}
}
}
#endif
@@ -0,0 +1,86 @@
/*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_TR_SVT_HPP
#define OPENCV_DATASETS_TR_SVT_HPP
#include <string>
#include <vector>
#include "opencv2/datasets/dataset.hpp"
#include <opencv2/core.hpp>
namespace cv
{
namespace datasets
{
//! @addtogroup datasets_tr
//! @{
struct tag
{
std::string value;
int height, width, x, y;
};
struct TR_svtObj : public Object
{
std::string fileName;
std::vector<std::string> lex;
std::vector<tag> tags;
};
class CV_EXPORTS TR_svt : public Dataset
{
public:
virtual void load(const std::string &path) CV_OVERRIDE = 0;
static Ptr<TR_svt> create();
};
//! @}
}
}
#endif
@@ -0,0 +1,107 @@
/*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_TRACK_ALOV_HPP
#define OPENCV_DATASETS_TRACK_ALOV_HPP
#include <string>
#include <vector>
#include "opencv2/datasets/dataset.hpp"
#include "opencv2/datasets/util.hpp"
using namespace std;
namespace cv
{
namespace datasets
{
//! @addtogroup datasets_track
//! @{
struct TRACK_alovObj : public Object
{
int id;
std::string imagePath;
vector <Point2f> gtbb;
};
const string sectionNames[] = { "01-Light", "02-SurfaceCover", "03-Specularity", "04-Transparency", "05-Shape", "06-MotionSmoothness", "07-MotionCoherence",
"08-Clutter", "09-Confusion", "10-LowContrast", "11-Occlusion", "12-MovingCamera", "13-ZoomingCamera", "14-LongDuration" };
const int sectionSizes[] = { 33, 15, 18, 20, 24, 22, 12, 15, 37, 23, 34, 22, 29, 10 };
class CV_EXPORTS TRACK_alov : public Dataset
{
public:
static Ptr<TRACK_alov> create();
virtual void load(const std::string &path) CV_OVERRIDE = 0;
//Load only frames with annotations (~every 5-th frame)
virtual void loadAnnotatedOnly(const std::string &path) = 0;
virtual int getDatasetsNum() = 0;
virtual int getDatasetLength(int id) = 0;
virtual bool initDataset(int id) = 0;
virtual bool getNextFrame(Mat &frame) = 0;
virtual vector <Point2f> getNextGT() = 0;
//Get frame/GT by datasetID (1..N) frameID (1..K)
virtual bool getFrame(Mat &frame, int datasetID, int frameID) = 0;
virtual vector <Point2f> getGT(int datasetID, int frameID) = 0;
protected:
vector <vector <Ptr<TRACK_alovObj> > > data;
int activeDatasetID;
int frameCounter;
};
//! @}
}
}
#endif
@@ -0,0 +1,96 @@
/*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_TRACK_VOT_HPP
#define OPENCV_DATASETS_TRACK_VOT_HPP
#include <string>
#include <vector>
#include "opencv2/datasets/dataset.hpp"
#include "opencv2/datasets/util.hpp"
using namespace std;
namespace cv
{
namespace datasets
{
//! @addtogroup datasets_track
//! @{
struct TRACK_votObj : public Object
{
int id;
std::string imagePath;
vector <Point2d> gtbb;
};
class CV_EXPORTS TRACK_vot : public Dataset
{
public:
static Ptr<TRACK_vot> create();
virtual void load(const std::string &path) CV_OVERRIDE = 0;
virtual int getDatasetsNum() = 0;
virtual int getDatasetLength(int id) = 0;
virtual bool initDataset(int id) = 0;
virtual bool getNextFrame(Mat &frame) = 0;
virtual vector <Point2d> getGT() = 0;
protected:
vector <vector <Ptr<TRACK_votObj> > > data;
int activeDatasetID;
int frameCounter;
};
//! @}
}
}
#endif
@@ -0,0 +1,74 @@
/*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_UTIL_HPP
#define OPENCV_DATASETS_UTIL_HPP
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib> // atoi, atof
#include <fstream>
#include <opencv2/core.hpp>
namespace cv
{
namespace datasets
{
//! @addtogroup datasets
//! @{
void CV_EXPORTS split(const std::string &s, std::vector<std::string> &elems, char delim);
void CV_EXPORTS createDirectory(const std::string &path);
void CV_EXPORTS getDirList(const std::string &dirName, std::vector<std::string> &fileNames);
//! @}
}
}
#endif
+87
View File
@@ -0,0 +1,87 @@
/*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/ar_hmdb.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 }";
CommandLineParser parser(argc, argv, keys);
string path(parser.get<string>("path"));
if (parser.has("help") || path=="true")
{
parser.printMessage();
return -1;
}
Ptr<AR_hmdb> dataset = AR_hmdb::create();
dataset->load(path);
// ***************
// dataset contains for each split: a set of video file names for each action.
// For example, let output all training video file names for second split and first action.
// And its size.
int numSplits = dataset->getNumSplits();
printf("splits number: %u\n", numSplits);
printf("train 1 size: %u\n", (unsigned int)dataset->getTrain(1).size());
printf("test 1 size: %u\n", (unsigned int)dataset->getTest(1).size());
AR_hmdbObj *example = static_cast<AR_hmdbObj *>(dataset->getTrain(1)[0].get());
printf("first image:\n");
printf("action id: %u\n", example->id);
printf("action: %s\n", example->name.c_str());
printf("file: %s\n", example->videoName.c_str());
return 0;
}
@@ -0,0 +1,245 @@
/*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/ar_hmdb.hpp"
#include "opencv2/datasets/util.hpp"
#include <opencv2/core.hpp>
#include <opencv2/flann.hpp>
#include <opencv2/ml.hpp>
#include <cstdio>
#include <string>
#include <vector>
#include <fstream>
using namespace std;
using namespace cv;
using namespace cv::datasets;
using namespace cv::flann;
using namespace cv::ml;
void fillData(const string &path, vector< Ptr<Object> > &curr, Index &flann_index, Mat1f &data, Mat1i &labels);
void fillData(const string &path, vector< Ptr<Object> > &curr, Index &flann_index, Mat1f &data, Mat1i &labels)
{
const unsigned int descriptorNum = 162;
Mat1f sample(1, descriptorNum);
Mat1i nresps(1, 1);
Mat1f dists(1, 1);
unsigned int numFiles = 0;
for (unsigned int i=0; i<curr.size(); ++i)
{
AR_hmdbObj *example = static_cast<AR_hmdbObj *>(curr[i].get());
string featuresFullPath = path + "hmdb51_org_stips/" + example->name + "/" + example->videoName + ".txt";
ifstream infile(featuresFullPath.c_str());
string line;
// skip header
for (unsigned int j=0; j<3; ++j)
{
getline(infile, line);
}
while (getline(infile, line))
{
// 7 skip, hog+hof: 72+90 read
vector<string> elems;
split(line, elems, '\t');
for (unsigned int j=0; j<descriptorNum; ++j)
{
sample(0, j) = (float)atof(elems[j+7].c_str());
}
flann_index.knnSearch(sample, nresps, dists, 1, SearchParams());
data(numFiles, nresps(0, 0)) ++;
}
labels(numFiles, 0) = example->id;
numFiles++;
}
}
int main(int argc, char *argv[])
{
const char *keys =
"{ help h usage ? | | show this message }"
"{ path p |true| path to dataset }";
CommandLineParser parser(argc, argv, keys);
string path(parser.get<string>("path"));
if (parser.has("help") || path=="true")
{
parser.printMessage();
return -1;
}
// loading dataset
Ptr<AR_hmdb> dataset = AR_hmdb::create();
dataset->load(path);
int numSplits = dataset->getNumSplits();
printf("splits number: %u\n", numSplits);
const unsigned int descriptorNum = 162;
const unsigned int clusterNum = 4000;
const unsigned int sampleNum = 5613856; // max for all 3 splits
vector<double> res;
for (int currSplit=0; currSplit<numSplits; ++currSplit)
{
Mat1f samples(sampleNum, descriptorNum);
unsigned int currSample = 0;
vector< Ptr<Object> > &curr = dataset->getTrain(currSplit);
unsigned int numFeatures = 0;
for (unsigned int i=0; i<curr.size(); ++i)
{
AR_hmdbObj *example = static_cast<AR_hmdbObj *>(curr[i].get());
string featuresFullPath = path + "hmdb51_org_stips/" + example->name + "/" + example->videoName + ".txt";
ifstream infile(featuresFullPath.c_str());
string line;
// skip header
for (unsigned int j=0; j<3; ++j)
{
getline(infile, line);
}
while (getline(infile, line))
{
numFeatures++;
if (currSample < sampleNum)
{
// 7 skip, hog+hof: 72+90 read
vector<string> elems;
split(line, elems, '\t');
for (unsigned int j=0; j<descriptorNum; ++j)
{
samples(currSample, j) = (float)atof(elems[j+7].c_str());
}
currSample++;
}
}
}
printf("split %u, train features number: %u, samples number: %u\n", currSplit, numFeatures, currSample);
// clustering
Mat1f centers(clusterNum, descriptorNum);
::cvflann::KMeansIndexParams kmean_params;
unsigned int resultClusters = hierarchicalClustering< L2<float> >(samples, centers, kmean_params);
if (resultClusters < clusterNum)
{
centers = centers.rowRange(Range(0, resultClusters));
}
Index flann_index(centers, KDTreeIndexParams());
printf("resulted clusters number: %u\n", resultClusters);
unsigned int numTrainFiles = curr.size();
Mat1f trainData(numTrainFiles, resultClusters);
Mat1i trainLabels(numTrainFiles, 1);
for (unsigned int i=0; i<numTrainFiles; ++i)
{
for (unsigned int j=0; j<resultClusters; ++j)
{
trainData(i, j) = 0;
}
}
printf("calculating train histograms\n");
fillData(path, curr, flann_index, trainData, trainLabels);
printf("train svm\n");
Ptr<SVM> svm = SVM::create();
svm->setType(SVM::C_SVC);
svm->setKernel(SVM::POLY); //SVM::RBF;
svm->setDegree(0.5);
svm->setGamma(1);
svm->setCoef0(1);
svm->setC(1);
svm->setNu(0.5);
svm->setP(0);
svm->setTermCriteria(TermCriteria(TermCriteria::MAX_ITER+TermCriteria::EPS, 1000, 0.01));
svm->train(trainData, ROW_SAMPLE, trainLabels);
// prepare to predict
curr = dataset->getTest(currSplit);
unsigned int numTestFiles = curr.size();
Mat1f testData(numTestFiles, resultClusters);
Mat1i testLabels(numTestFiles, 1); // ground true
for (unsigned int i=0; i<numTestFiles; ++i)
{
for (unsigned int j=0; j<resultClusters; ++j)
{
testData(i, j) = 0;
}
}
printf("calculating test histograms\n");
fillData(path, curr, flann_index, testData, testLabels);
printf("predicting\n");
Mat1f testPredicted(numTestFiles, 1);
svm->predict(testData, testPredicted);
unsigned int correct = 0;
for (unsigned int i=0; i<numTestFiles; ++i)
{
if ((int)testPredicted(i, 0) == testLabels(i, 0))
{
correct++;
}
}
double accuracy = 1.0*correct/numTestFiles;
printf("correctly recognized actions: %f\n", accuracy);
res.push_back(accuracy);
}
double accuracy = 0.0;
for (unsigned int i=0; i<res.size(); ++i)
{
accuracy += res[i];
}
printf("average: %f\n", accuracy/res.size());
return 0;
}
+90
View File
@@ -0,0 +1,90 @@
/*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/ar_sports.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 description }";
CommandLineParser parser(argc, argv, keys);
string path(parser.get<string>("path"));
if (parser.has("help") || path=="true")
{
parser.printMessage();
return -1;
}
Ptr<AR_sports> dataset = AR_sports::create();
dataset->load(path);
// ***************
// dataset. train & test contains for each video url in dataset all it's labels.
// For example, let output the first element in test dataset and it's labels.
// And sizes of both datasets.
printf("train size: %u\n", (unsigned int)dataset->getTrain().size());
printf("test size: %u\n", (unsigned int)dataset->getTest().size());
AR_sportsObj *example = static_cast<AR_sportsObj *>(dataset->getTest()[0].get());
printf("url: %s\n", example->videoUrl.c_str());
printf("labels: ");
vector<int> &labels = example->labels;
for (vector<int>::iterator it=labels.begin(); it!=labels.end(); ++it)
{
printf("%u ", *it);
}
printf("\n");
return 0;
}
+105
View File
@@ -0,0 +1,105 @@
/*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: %d\n", example->tilt_ang);
printf("fiducial_yaw_angle: %d\n", example->fiducial_yaw_angle);
printf("fiducial_score: %u\n", example->fiducial_score);
return 0;
}
+89
View File
@@ -0,0 +1,89 @@
/*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_lfw.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 (lfw2 folder) }";
CommandLineParser parser(argc, argv, keys);
string path(parser.get<string>("path"));
if (parser.has("help") || path=="true")
{
parser.printMessage();
return -1;
}
Ptr<FR_lfw> dataset = FR_lfw::create();
dataset->load(path);
// ***************
// test contains two images and flag that they belong to one person.
// For example, let output splits number, test size and split 1, elements: 1, 301.
int numSplits = dataset->getNumSplits();
printf("splits number: %u\n", numSplits);
printf("test size: %u\n", (unsigned int)dataset->getTest().size());
FR_lfwObj *example = static_cast<FR_lfwObj *>(dataset->getTest()[0].get());
printf("first test, first image: %s\n", example->image1.c_str());
printf("first test, second image: %s\n", example->image2.c_str());
printf("first test, same: %s\n", example->same?"yes":"no");
example = static_cast<FR_lfwObj *>(dataset->getTest()[300].get());
printf("300 test, first image: %s\n", example->image1.c_str());
printf("300 test, second image: %s\n", example->image2.c_str());
printf("300 test, same: %s\n", example->same?"yes":"no");
return 0;
}
@@ -0,0 +1,171 @@
/*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/core.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/datasets/fr_lfw.hpp"
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
using namespace std;
using namespace cv;
using namespace cv::datasets;
int main(int argc, const char *argv[])
{
const char *keys =
"{ help h usage ? | | show this message }"
"{ path p |true| path to dataset (lfw2 folder) }"
"{ train t |dev | train method: 'dev'(pairsDevTrain.txt) or 'split'(pairs.txt) }";
CommandLineParser parser(argc, argv, keys);
string path(parser.get<string>("path"));
if (parser.has("help") || path=="true")
{
parser.printMessage();
return -1;
}
string trainMethod(parser.get<string>("train"));
// our trained threshold for "same":
double threshold = 0;
// load dataset
Ptr<FR_lfw> dataset = FR_lfw::create();
dataset->load(path);
unsigned int numSplits = dataset->getNumSplits();
printf("splits number: %u\n", numSplits);
if (trainMethod == "dev")
printf("train size: %u\n", (unsigned int)dataset->getTrain().size());
else
printf("train size: %u\n", (numSplits-1) * (unsigned int)dataset->getTest().size());
printf("test size: %u\n", (unsigned int)dataset->getTest().size());
if (trainMethod == "dev") // train on personsDevTrain.txt
{
// collect average same-distances:
double avg = 0;
int count = 0;
for (unsigned int i=0; i<dataset->getTrain().size(); ++i)
{
FR_lfwObj *example = static_cast<FR_lfwObj *>(dataset->getTrain()[i].get());
Mat a = imread(path+example->image1, IMREAD_GRAYSCALE);
Mat b = imread(path+example->image2, IMREAD_GRAYSCALE);
double dist = norm(a,b);
if (example->same)
{
avg += dist;
count ++;
}
}
threshold = avg / count;
}
vector<double> p;
for (unsigned int j=0; j<numSplits; ++j)
{
if (trainMethod == "split") // train on the remaining 9 splits from pairs.txt
{
double avg = 0;
int count = 0;
for (unsigned int j2=0; j2<numSplits; ++j2)
{
if (j==j2) continue; // skip test split for training
vector < Ptr<Object> > &curr = dataset->getTest(j2);
for (unsigned int i=0; i<curr.size(); ++i)
{
FR_lfwObj *example = static_cast<FR_lfwObj *>(curr[i].get());
Mat a = imread(path+example->image1, IMREAD_GRAYSCALE);
Mat b = imread(path+example->image2, IMREAD_GRAYSCALE);
double dist = norm(a,b);
if (example->same)
{
avg += dist;
count ++;
}
}
}
threshold = avg / count;
}
unsigned int incorrect = 0, correct = 0;
vector < Ptr<Object> > &curr = dataset->getTest(j);
for (unsigned int i=0; i<curr.size(); ++i)
{
FR_lfwObj *example = static_cast<FR_lfwObj *>(curr[i].get());
Mat a = imread(path+example->image1, IMREAD_GRAYSCALE);
Mat b = imread(path+example->image2, IMREAD_GRAYSCALE);
bool same = (norm(a,b) <= threshold);
if (same == example->same)
correct++;
else
incorrect++;
}
p.push_back(1.0*correct/(correct+incorrect));
printf("correct: %u, from: %u -> %f\n", correct, correct+incorrect, p.back());
}
double mu = 0.0;
for (vector<double>::iterator it=p.begin(); it!=p.end(); ++it)
{
mu += *it;
}
mu /= p.size();
double sigma = 0.0;
for (vector<double>::iterator it=p.begin(); it!=p.end(); ++it)
{
sigma += (*it - mu)*(*it - mu);
}
sigma = sqrt(sigma/p.size());
double se = sigma/sqrt(double(p.size()));
printf("estimated mean accuracy: %f and the standard error of the mean: %f\n", mu, se);
return 0;
}
+97
View File
@@ -0,0 +1,97 @@
/*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/gr_chalearn.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 }";
CommandLineParser parser(argc, argv, keys);
string path(parser.get<string>("path"));
if (parser.has("help") || path=="true")
{
parser.printMessage();
return -1;
}
Ptr<GR_chalearn> dataset = GR_chalearn::create();
dataset->load(path);
// ***************
// dataset contains information for each sample.
// For example, let output dataset size and first element.
printf("train size: %u\n", (unsigned int)dataset->getTrain().size());
printf("validation size: %u\n", (unsigned int)dataset->getValidation().size());
GR_chalearnObj *example = static_cast<GR_chalearnObj *>(dataset->getTrain()[0].get());
printf("first dataset sample:\n%s\n", example->name.c_str());
printf("color video:\n%s\n", example->nameColor.c_str());
printf("depth video:\n%s\n", example->nameDepth.c_str());
printf("user video:\n%s\n", example->nameUser.c_str());
printf("video:\nnumber of frames: %u\nfps: %u\nmaximum depth: %u\n", example->numFrames, example->fps, example->depth);
for (vector<groundTruth>::iterator it=example->groundTruths.begin(); it!=example->groundTruths.end(); ++it)
{
printf("gestureID: %u, initial frame: %u, last frame: %u\n", (*it).gestureID, (*it).initialFrame, (*it).lastFrame);
}
printf("skeletons number: %u\n", (unsigned int)example->skeletons.size());
skeleton &last = example->skeletons.back();
printf("last skeleton:\n");
for (unsigned int i=0; i<20; ++i)
{
printf("Wx: %f, Wy: %f, Wz: %f, Rx: %f, Ry: %f, Rz: %f, Rw: %f, Px: %f, Py: %f\n",
last.s[i].Wx, last.s[i].Wy, last.s[i].Wz, last.s[i].Rx,
last.s[i].Ry, last.s[i].Rz, last.s[i].Rw, last.s[i].Px, last.s[i].Py);
}
return 0;
}
+82
View File
@@ -0,0 +1,82 @@
/*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/gr_skig.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 (subject* folders) }";
CommandLineParser parser(argc, argv, keys);
string path(parser.get<string>("path"));
if (parser.has("help") || path=="true")
{
parser.printMessage();
return -1;
}
Ptr<GR_skig> dataset = GR_skig::create();
dataset->load(path);
// ***************
// dataset contains pair of rgb\dep images
// For example, let output train size and second element.
GR_skigObj *example = static_cast<GR_skigObj *>(dataset->getTrain()[1].get());
printf("train size: %u\n", (unsigned int)dataset->getTrain().size());
printf("second train image:\nrgb: %s\ndep: %s\n", example->rgb.c_str(), example->dep.c_str());
printf("person: %u, backgroud: %u, illumination: %u, pose: %u, actionType: %u\n",
example->person, example->background, example->illumination, example->pose, example->type);
return 0;
}
+100
View File
@@ -0,0 +1,100 @@
/*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;
}
+82
View File
@@ -0,0 +1,82 @@
/*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_parse.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 (people_all folder) }";
CommandLineParser parser(argc, argv, keys);
string path(parser.get<string>("path"));
if (parser.has("help") || path=="true")
{
parser.printMessage();
return -1;
}
Ptr<HPE_parse> dataset = HPE_parse::create();
dataset->load(path);
// ***************
// dataset. train & test contain appropriate images
// For example, let output their sizes and first elements.
printf("train size: %u\n", (unsigned int)dataset->getTrain().size());
printf("test size: %u\n", (unsigned int)dataset->getTest().size());
HPE_parseObj *example1 = static_cast<HPE_parseObj *>(dataset->getTrain()[0].get());
HPE_parseObj *example2 = static_cast<HPE_parseObj *>(dataset->getTest()[0].get());
printf("first train image: %s\n", example1->name.c_str());
printf("first test image: %s\n", example2->name.c_str());
return 0;
}
+92
View File
@@ -0,0 +1,92 @@
/*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/ir_affine.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;
}
// loading dataset
Ptr<IR_affine> dataset = IR_affine::create();
dataset->load(path);
// ***************
// dataset contains for each image in dataset it's matrix.
// For example, let output the last element in dataset and it's matrix.
// And dataset size.
printf("size: %u\n", (unsigned int)dataset->getTrain().size());
IR_affineObj *example = static_cast<IR_affineObj *>(dataset->getTrain().back().get());
printf("image name: %s\n", example->imageName.c_str());
printf("matrix:\n");
for (int i=0; i<3; ++i)
{
for (int j=0; j<3; ++j)
{
printf("%f ", example->mat(i, j));
}
printf("\n");
}
return 0;
}
+90
View File
@@ -0,0 +1,90 @@
/*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/ir_robot.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 folders }";
CommandLineParser parser(argc, argv, keys);
string path(parser.get<string>("path"));
if (parser.has("help") || path=="true")
{
parser.printMessage();
return -1;
}
Ptr<IR_robot> dataset = IR_robot::create();
dataset->load(path);
// ***************
// dataset contains object with name and its images.
// For example, let output last element and dataset size.
IR_robotObj *example = static_cast<IR_robotObj *>(dataset->getTrain().back().get());
printf("last dataset object:\n");
printf("name: %s\n", example->name.c_str());
printf("number postitions: %u\n", (unsigned int)example->pos.size());
string currPath(path + example->name + "/");
for (vector<cameraPos>::iterator itP=example->pos.begin(); itP!=example->pos.end(); ++itP)
{
for (vector<string>::iterator it=itP->images.begin(); it!=itP->images.end(); ++it)
{
printf("%s\n", (currPath+(*it)).c_str());
}
}
printf("dataset size: %u\n", (unsigned int)dataset->getTrain().size());
return 0;
}
+88
View File
@@ -0,0 +1,88 @@
/*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/is_bsds.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 (images, iids_train.txt, iids_test.txt) }";
CommandLineParser parser(argc, argv, keys);
string path(parser.get<string>("path"));
if (parser.has("help") || path=="true")
{
parser.printMessage();
return -1;
}
Ptr<IS_bsds> dataset = IS_bsds::create();
dataset->load(path);
// TODO: read human/ folder for evaluation
// ***************
// dataset. train & test contain names of appropriate images.
// For example, let output full path & name for first train and test images.
// And sets size.
printf("train size: %u\n", (unsigned int)dataset->getTrain().size());
printf("test size: %u\n", (unsigned int)dataset->getTest().size());
IS_bsdsObj *example1 = static_cast<IS_bsdsObj *>(dataset->getTrain()[0].get());
string fullPath(path + "images/train/" + example1->name + ".jpg");
printf("first train image: %s\n", fullPath.c_str());
IS_bsdsObj *example2 = static_cast<IS_bsdsObj *>(dataset->getTest()[0].get());
fullPath = path + "images/test/" + example2->name + ".jpg";
printf("first test image: %s\n", fullPath.c_str());
return 0;
}
+80
View File
@@ -0,0 +1,80 @@
/*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/is_weizmann.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 (1obj/2obj folders) }";
CommandLineParser parser(argc, argv, keys);
string path(parser.get<string>("path"));
if (parser.has("help") || path=="true")
{
parser.printMessage();
return -1;
}
Ptr<IS_weizmann> dataset = IS_weizmann::create();
dataset->load(path);
// ***************
// dataset contains all information for each image.
// For example, let output dataset size and first object.
printf("dataset size: %u\n", (unsigned int)dataset->getTrain().size());
IS_weizmannObj *example = static_cast<IS_weizmannObj *>(dataset->getTrain()[0].get());
printf("first image:\nname: %s\n", example->imageName.c_str());
printf("src bw: %s\nsrc color: %s\n", example->srcBw.c_str(), example->srcColor.c_str());
return 0;
}
+134
View File
@@ -0,0 +1,134 @@
/*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/msm_epfl.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 (bounding/, camera/, P/, png/ folders) }";
CommandLineParser parser(argc, argv, keys);
string path(parser.get<string>("path"));
if (parser.has("help") || path=="true")
{
parser.printMessage();
return -1;
}
Ptr<MSM_epfl> dataset = MSM_epfl::create();
dataset->load(path);
// ***************
// dataset contains all information for each image.
// For example, let output dataset size and first object.
printf("dataset size: %u\n", (unsigned int)dataset->getTrain().size());
MSM_epflObj *example = static_cast<MSM_epflObj *>(dataset->getTrain()[0].get());
printf("first image:\nname: %s\n", example->imageName.c_str());
printf("\nbounding:\n");
for (int i=0; i<2; ++i)
{
for (int j=0; j<3; ++j)
{
printf("%f ", example->bounding(i, j));
}
printf("\n");
}
printf("\ncamera:\n");
for (int i=0; i<3; ++i)
{
for (int j=0; j<3; ++j)
{
printf("%f ", example->camera.mat1(i, j));
}
printf("\n");
}
printf("\n");
for (int i=0; i<3; ++i)
{
printf("%f ", example->camera.mat2[i]);
}
printf("\n\n");
for (int i=0; i<3; ++i)
{
for (int j=0; j<3; ++j)
{
printf("%f ", example->camera.mat3(i, j));
}
printf("\n");
}
printf("\n");
for (int i=0; i<3; ++i)
{
printf("%f ", example->camera.mat4[i]);
}
printf("\n\n");
printf("image width: %u, height: %u\n", example->camera.imageWidth, example->camera.imageHeight);
printf("\nP:\n");
for (int i=0; i<3; ++i)
{
for (int j=0; j<4; ++j)
{
printf("%f ", example->p(i, j));
}
printf("\n");
}
return 0;
}
+103
View File
@@ -0,0 +1,103 @@
/*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/msm_middlebury.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 description }";
CommandLineParser parser(argc, argv, keys);
string path(parser.get<string>("path"));
if (parser.has("help") || path=="true")
{
parser.printMessage();
return -1;
}
Ptr<MSM_middlebury> dataset = MSM_middlebury::create();
dataset->load(path);
// ***************
// dataset contains camera parameters for each image.
// For example, let output number of elements and last element.
printf("images number: %u\n", (unsigned int)dataset->getTrain().size());
MSM_middleburyObj *example = static_cast<MSM_middleburyObj *>(dataset->getTrain().back().get());
printf("last image name: %s\n", (path + example->imageName).c_str());
printf("K:\n");
for (int i=0; i<3; ++i)
{
for (int j=0; j<3; ++j)
{
printf("%f ", example->k(i, j));
}
printf("\n");
}
printf("R:\n");
for (int i=0; i<3; ++i)
{
for (int j=0; j<3; ++j)
{
printf("%f ", example->r(i, j));
}
printf("\n");
}
printf("t:\n");
for (int i=0; i<3; ++i)
{
printf("%f ", example->t[i]);
}
printf("\n");
return 0;
}
+98
View File
@@ -0,0 +1,98 @@
/*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/or_imagenet.hpp"
#include <opencv2/core.hpp>
#include <cstdio>
#include <cstdlib> // atoi
#include <string>
#include <vector>
#include <set>
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 folder with dataset }";
CommandLineParser parser(argc, argv, keys);
string path(parser.get<string>("path"));
if (parser.has("help") || path=="true")
{
parser.printMessage();
return -1;
}
Ptr<OR_imagenet> dataset = OR_imagenet::create();
dataset->load(path);
// ***************
// 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;
}
+89
View File
@@ -0,0 +1,89 @@
/*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/or_mnist.hpp"
#include <opencv2/core.hpp>
#include <opencv2/imgcodecs.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 }";
CommandLineParser parser(argc, argv, keys);
string path(parser.get<string>("path"));
if (parser.has("help") || path=="true")
{
parser.printMessage();
return -1;
}
Ptr<OR_mnist> dataset = OR_mnist::create();
dataset->load(path);
// ***************
// dataset contains for each object its image and label.
// For example, let output train & test sizes and their first elements.
printf("train size: %u\n", (unsigned int)dataset->getTrain().size());
printf("test size: %u\n", (unsigned int)dataset->getTest().size());
OR_mnistObj *example = static_cast<OR_mnistObj *>(dataset->getTrain()[0].get());
printf("first train:\nlabel: %u\n", example->label);
printf("image was saved to train0.png\n");
imwrite("train0.png", example->image);
example = static_cast<OR_mnistObj *>(dataset->getTest()[0].get());
printf("first test:\nlabel: %u\n", example->label);
printf("image was saved to test0.png\n");
imwrite("test0.png", example->image);
return 0;
}
+112
View File
@@ -0,0 +1,112 @@
/*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) 2015, 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/or_pascal.hpp"
#include <opencv2/core.hpp>
#include <cstdio>
#include <cstdlib> // atoi
#include <string>
#include <vector>
#include <set>
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 folder with dataset }";
CommandLineParser parser(argc, argv, keys);
string path(parser.get<string>("path"));
if (parser.has("help") || path=="true")
{
parser.printMessage();
return -1;
}
Ptr<OR_pascal> dataset = OR_pascal::create();
dataset->load(path);
// Print train/test/validation size and first example
OR_pascalObj *example;
vector< Ptr<Object> > &train = dataset->getTrain();
printf("\ntrain:\nsize: %u", (unsigned int)train.size());
example = static_cast<OR_pascalObj *>(train[0].get());
printf("\nfirst image: \n%s", example->filename.c_str());
printf("\nsize:");
printf("\n - width: %d", example->width);
printf("\n - height: %d", example->height);
printf("\n - depth: %d", example->depth);
for (unsigned int i = 0; i < example->objects.size(); i++)
{
printf("\nobject %d", i);
printf("\nname: %s", example->objects[i].name.c_str());
printf("\npose: %s", example->objects[i].pose.c_str());
printf("\ntruncated: %d", example->objects[i].truncated);
printf("\ndifficult: %d", example->objects[i].difficult);
printf("\noccluded: %d", example->objects[i].occluded);
printf("\nbounding box:");
printf("\n - xmin: %d", example->objects[i].xmin);
printf("\n - ymin: %d", example->objects[i].ymin);
printf("\n - xmax: %d", example->objects[i].xmax);
printf("\n - ymax: %d", example->objects[i].ymax);
}
vector< Ptr<Object> > &test = dataset->getTest();
printf("\ntest:\nsize: %u", (unsigned int)test.size());
example = static_cast<OR_pascalObj *>(test[0].get());
printf("\nfirst image: \n%s", example->filename.c_str());
vector< Ptr<Object> > &validation = dataset->getValidation();
printf("\nvalidation:\nsize: %u", (unsigned int)validation.size());
example = static_cast<OR_pascalObj *>(validation[0].get());
printf("\nfirst image: \n%s\n", example->filename.c_str());
return 0;
}
+84
View File
@@ -0,0 +1,84 @@
/*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/or_sun.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 (SUN397 folder) }";
CommandLineParser parser(argc, argv, keys);
string path(parser.get<string>("path"));
if (parser.has("help") || path=="true")
{
parser.printMessage();
return -1;
}
Ptr<OR_sun> dataset = OR_sun::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());
OR_sunObj *example = static_cast<OR_sunObj *>(dataset->getTrain().back().get());
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;
}
+86
View File
@@ -0,0 +1,86 @@
/*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/pd_caltech.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 }";
CommandLineParser parser(argc, argv, keys);
string path(parser.get<string>("path"));
if (parser.has("help") || path=="true")
{
parser.printMessage();
return -1;
}
Ptr<PD_caltech> dataset = PD_caltech::create();
dataset->load(path);
// ***************
// dataset contains for each object its images.
// currently on loading extract all images to folder path/../images/
// For example, let output train size and first element of first object
// and number of it's images.
printf("train size: %u\n", (unsigned int)dataset->getTrain().size());
PD_caltechObj *example = static_cast<PD_caltechObj *>(dataset->getTrain()[0].get());
printf("first train object:\n");
printf("name: %s\n", example->name.c_str());
printf("images number: %u\n", (unsigned int)example->imageNames.size());
printf("first image name: %s\n", example->imageNames[0].c_str());
printf("images were extracted to path/../images/\n");
return 0;
}
+102
View File
@@ -0,0 +1,102 @@
#include "opencv2/datasets/pd_inria.hpp"
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <iostream>
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 }"
"{ save s |false| save resized positive images }"
"{ rwidth rw |64 | width of resized positive images }"
"{ rheight rh |128 | height of resized positive images }"
"{ padding |8 | vertical padding of resized positive images }";
CommandLineParser parser(argc, argv, keys);
bool savebbox = parser.get<bool>("save");
int rwidth = parser.get<int>("rwidth");
int rheight = parser.get<int>("rheight");
int padding = parser.get<int>("padding");
string path(parser.get<string>("path"));
if (parser.has("help") || path=="true")
{
parser.printMessage();
return -1;
}
Ptr<PD_inria> dataset = PD_inria::create();
dataset->load(path);
size_t train_size = dataset->getTrain().size();
size_t test_size = dataset->getTest().size();
cout << "train size: " << train_size << endl;
cout << "test size: " << test_size << endl;
int bbox_count = 0;
for( size_t i = 0; i < train_size; i++ )
{
PD_inriaObj *example = static_cast<PD_inriaObj *>(dataset->getTrain()[i].get());
cout << "\ntrain object index: " << i << endl;
cout << "file name: " << example->filename << endl;
// image size
cout << "image size: " << endl;
cout << " - width: " << example->width << endl;
cout << " - height: " << example->height << endl;
cout << " - depth: " << example->depth << endl;
Mat img = imread( example->filename );
// bounding boxes
for ( size_t j = 0; j < example->bndboxes.size(); j++ )
{
Rect obj_bndbox = example->bndboxes[j]; // bounding box of object
cout << " - bounding box: " << j << " - " << obj_bndbox << endl;
int vpadding, hpadding;
Rect ex_bndbox; // variable used for calculating expanded bounding box
vpadding = cvRound(padding * obj_bndbox.height / rheight); // calculate vertical padding
ex_bndbox.y = obj_bndbox.y - vpadding;
ex_bndbox.height = 2 * vpadding + obj_bndbox.height;
ex_bndbox.x = obj_bndbox.x + (obj_bndbox.width / 2);
ex_bndbox.width = ex_bndbox.height * rwidth / rheight;
ex_bndbox.x -= (ex_bndbox.width + 1) / 2;
if (obj_bndbox.width > ex_bndbox.width)
{
obj_bndbox.x += (obj_bndbox.width - ex_bndbox.width + 1) / 2;
obj_bndbox.width = ex_bndbox.width;
}
hpadding = obj_bndbox.x - ex_bndbox.x; // calculate horizontal padding
if(savebbox)
{
Mat dst;
copyMakeBorder(img(obj_bndbox), dst, vpadding, vpadding, hpadding, hpadding, BORDER_REFLECT);
resize(dst, dst, Size(rwidth, rheight), 0, 0, INTER_AREA);
imwrite(path + format("person_%04d.png", bbox_count++), dst);
}
else
rectangle(img, obj_bndbox, Scalar(0, 0, 255), 2);
}
if (savebbox)
continue; // skip UI updates
imshow("INRIAPerson Dataset Train Images", img);
cout << "\nPress a key to continue or ESC to exit." << endl;
int key = waitKey();
if( key == 27 ) break;
}
return 0;
}
+129
View File
@@ -0,0 +1,129 @@
/*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/slam_kitti.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 folders }";
CommandLineParser parser(argc, argv, keys);
string path(parser.get<string>("path"));
if (parser.has("help") || path=="true")
{
parser.printMessage();
return -1;
}
Ptr<SLAM_kitti> dataset = SLAM_kitti::create();
dataset->load(path);
// ***************
// dataset contains sequence with name and its data.
// For example, let output first sequence and dataset size.
printf("dataset size: %u\n", (unsigned int)dataset->getTrain().size());
SLAM_kittiObj *example = static_cast<SLAM_kittiObj *>(dataset->getTrain()[0].get());
printf("first dataset sequence:\n%s\n", example->name.c_str());
/*string pathVelodyne(path + "sequences/" + example->name + "/velodyne/");
for (vector<string>::iterator it=example->velodyne.begin(); it!=example->velodyne.end(); ++it)
{
printf("%s\n", (pathVelodyne + (*it)).c_str());
}*/
printf("number of velodyne images: %u\n", (unsigned int)example->velodyne.size());
for (unsigned int i=0; i<=3; ++i)
{
/*char tmp[2];
sprintf(tmp, "%u", i);
// 0,1 - gray, 2,3 - color
string currPath(path + "sequences/" + example->name + "/image_" + tmp + "/");
for (vector<string>::iterator it=example->images[i].begin(); it!=example->images[i].end(); ++it)
{
printf("%s\n", (currPath + (*it)).c_str());
}*/
printf("number of images %u: %u\n", i, (unsigned int)example->images[i].size());
}
/*printf("times:\n");
for (vector<double>::iterator it=example->times.begin(); it!=example->times.end(); ++it)
{
printf("%f ", *it);
}
printf("\n");*/
printf("number of times: %u\n", (unsigned int)example->times.size());
/*printf("poses:\n");
for (vector<pose>::iterator it=example->posesArray.begin(); it!=example->posesArray.end(); ++it)
{
for (unsigned int i=0; i<12; ++i)
{
printf("%f ", (*it).elem[i]);
}
printf("\n");
}*/
printf("number of poses: %u\n", (unsigned int)example->posesArray.size());
for (unsigned int i=0; i<4; ++i)
{
printf("calibration %u:\n", i);
for (vector<double>::iterator it=example->p[i].begin(); it!=example->p[i].end(); ++it)
{
printf("%f ", *it);
}
printf("\n");
}
return 0;
}
+100
View File
@@ -0,0 +1,100 @@
/*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/slam_tumindoor.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 folders }";
CommandLineParser parser(argc, argv, keys);
string path(parser.get<string>("path"));
if (parser.has("help") || path=="true")
{
parser.printMessage();
return -1;
}
Ptr<SLAM_tumindoor> dataset = SLAM_tumindoor::create();
dataset->load(path);
// ***************
// dataset contains image and its information.
// For example, let output first image information and dataset size.
printf("dataset size: %u\n", (unsigned int)dataset->getTrain().size());
SLAM_tumindoorObj *example = static_cast<SLAM_tumindoorObj *>(dataset->getTrain()[0].get());
printf("first image:\ntype: %u\n", example->type);
string imagePath(path);
if (LADYBUG == example->type)
{
imagePath += "ladybug/";
} else
{
imagePath += "dslr/";
}
printf("file name: %s\n", (imagePath + example->name).c_str());
printf("\ntransformation matrix:\n");
for (unsigned int i=0; i<4; ++i)
{
for (unsigned int j=0; j<4; ++j)
{
printf("%f ", example->transformMat(i, j));
}
printf("\n");
}
return 0;
}
+50
View File
@@ -0,0 +1,50 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "opencv2/datasets/sr_bsds.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 (images, iids_train.txt, iids_test.txt) }";
CommandLineParser parser(argc, argv, keys);
string path(parser.get<string>("path"));
if (parser.has("help") || path=="true")
{
parser.printMessage();
return -1;
}
Ptr<SR_bsds> dataset = SR_bsds::create();
dataset->load(path);
// ***************
// Dataset train & test contain names of appropriate images.
// For example, let's output full path & name for first train and test images.
// And dataset sizes.
printf("train size: %u\n", (unsigned int)dataset->getTrain().size());
printf("test size: %u\n", (unsigned int)dataset->getTest().size());
SR_bsdsObj *example1 = static_cast<SR_bsdsObj *>(dataset->getTrain()[0].get());
string fullPath(path + "images/train/" + example1->imageName + ".jpg");
printf("first train image: %s\n", fullPath.c_str());
SR_bsdsObj *example2 = static_cast<SR_bsdsObj *>(dataset->getTest()[0].get());
fullPath = path + "images/test/" + example2->imageName + ".jpg";
printf("first test image: %s\n", fullPath.c_str());
return 0;
}
+47
View File
@@ -0,0 +1,47 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "opencv2/datasets/sr_div2k.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 (Div2k dataset folder containing the images) }";
CommandLineParser parser(argc, argv, keys);
string path(parser.get<string>("path"));
if (parser.has("help") || path=="true")
{
parser.printMessage();
return -1;
}
Ptr<SR_div2k> dataset = SR_div2k::create();
dataset->load(path);
// ***************
// Dataset contains all images.
// For example, let's output dataset size; first image name; and second image full path.
printf("dataset size: %u\n", (unsigned int)dataset->getTrain().size());
SR_div2kObj *example = static_cast<SR_div2kObj *>(dataset->getTrain()[0].get());
printf("first image name: %s\n", example->imageName.c_str());
SR_div2kObj *example2 = static_cast<SR_div2kObj *>(dataset->getTrain()[1].get());
string fullPath = path + "/" + example2->imageName.c_str();
printf("second image full path: %s\n", fullPath.c_str());
return 0;
}
@@ -0,0 +1,47 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "opencv2/datasets/sr_general100.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 (General-100 dataset folder) }";
CommandLineParser parser(argc, argv, keys);
string path(parser.get<string>("path"));
if (parser.has("help") || path=="true")
{
parser.printMessage();
return -1;
}
Ptr<SR_general100> dataset = SR_general100::create();
dataset->load(path);
// ***************
// Dataset contains all images.
// For example, let's output dataset size; first image name; and second image full path.
printf("dataset size: %u\n", (unsigned int)dataset->getTrain().size());
SR_general100Obj *example = static_cast<SR_general100Obj *>(dataset->getTrain()[0].get());
printf("first image name: %s\n", example->imageName.c_str());
SR_general100Obj *example2 = static_cast<SR_general100Obj *>(dataset->getTrain()[1].get());
string fullPath = path + "/" + example2->imageName.c_str();
printf("second image full path: %s\n", fullPath.c_str());
return 0;
}
+97
View File
@@ -0,0 +1,97 @@
/*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/tr_chars.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 description file: list_English_Img.m }";
CommandLineParser parser(argc, argv, keys);
string path(parser.get<string>("path"));
if (parser.has("help") || path=="true")
{
parser.printMessage();
return -1;
}
Ptr<TR_chars> dataset = TR_chars::create();
dataset->load(path);
// ***************
// dataset. train, test contain information about each element of appropriate sets and splits.
// For example, let output first elements of these vectors and their sizes for last split.
// And number of splits.
int numSplits = dataset->getNumSplits();
printf("splits number: %u\n", numSplits);
vector< Ptr<Object> > &currTrain = dataset->getTrain(numSplits-1);
vector< Ptr<Object> > &currTest = dataset->getTest(numSplits-1);
vector< Ptr<Object> > &currValidation = dataset->getValidation(numSplits-1);
printf("train size: %u\n", (unsigned int)currTrain.size());
printf("test size: %u\n", (unsigned int)currTest.size());
printf("validation size: %u\n", (unsigned int)currValidation.size());
TR_charsObj *exampleTrain = static_cast<TR_charsObj *>(currTrain[0].get());
TR_charsObj *exampleTest = static_cast<TR_charsObj *>(currTest[0].get());
TR_charsObj *exampleValidation = static_cast<TR_charsObj *>(currValidation[0].get());
printf("first train element:\nname: %s\n", exampleTrain->imgName.c_str());
printf("label: %u\n", exampleTrain->label);
printf("first test element:\nname: %s\n", exampleTest->imgName.c_str());
printf("label: %u\n", exampleTest->label);
printf("first validation element:\nname: %s\n", exampleValidation->imgName.c_str());
printf("label: %u\n", exampleValidation->label);
return 0;
}
@@ -0,0 +1,142 @@
/*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 <iostream>
#include <opencv2/opencv_modules.hpp>
#ifdef HAVE_OPENCV_TEXT
#include "opencv2/datasets/tr_chars.hpp"
#include <opencv2/core.hpp>
#include "opencv2/text.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/imgcodecs.hpp"
#include <cstdio>
#include <cstdlib> // atoi
#include <string>
#include <vector>
using namespace std;
using namespace cv;
using namespace cv::datasets;
using namespace cv::text;
int main(int argc, char *argv[])
{
const char *keys =
"{ help h usage ? | | show this message }"
"{ path p |true| path to dataset description file ( list_English_Img.m ) and Img folder.}";
CommandLineParser parser(argc, argv, keys);
string path(parser.get<string>("path"));
if (parser.has("help") || path=="true")
{
parser.printMessage();
return -1;
}
Ptr<TR_chars> dataset = TR_chars::create();
dataset->load(path);
// ***************
// dataset. train, test contain information about each element of appropriate sets and splits.
// For example, let output first elements of these vectors and their sizes for last split.
// And number of splits.
int numSplits = dataset->getNumSplits();
printf("splits number: %u\n", numSplits);
vector< Ptr<Object> > &currTrain = dataset->getTrain(numSplits-1);
vector< Ptr<Object> > &currTest = dataset->getTest(numSplits-1);
vector< Ptr<Object> > &currValidation = dataset->getValidation(numSplits-1);
printf("train size: %u\n", (unsigned int)currTrain.size());
printf("test size: %u\n", (unsigned int)currTest.size());
printf("validation size: %u\n", (unsigned int)currValidation.size());
// WARNING: The order of classes' labels is different in Chars74k and in the output of our classifier
string src_classes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; // labels order as in the clasifier output
string tar_classes = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; // labels order as in the Chars74k dataset
Ptr<OCRHMMDecoder::ClassifierCallback> ocr = loadOCRHMMClassifierCNN("OCRBeamSearch_CNN_model_data.xml.gz");
int numOK = 0;
int upperNumOK = 0;
for (unsigned int i=0; i<(unsigned int)currTest.size(); i++)
{
TR_charsObj *exampleTest = static_cast<TR_charsObj *>(currTest[i].get());
printf("processed image: %u, name: %s\n", i, exampleTest->imgName.c_str());
printf(" label: %u,", exampleTest->label);
string imfilename = path+string("/Img/")+exampleTest->imgName.c_str()+string(".png");
Mat image = imread(imfilename);
vector<int> out_classes;
vector<double> out_confidences;
ocr->eval(image, out_classes, out_confidences);
int prediction = 1 + tar_classes.find_first_of(src_classes[out_classes[0]]);
printf(" prediction: %u\n", prediction);
if (exampleTest->label == prediction)
numOK++;
char l = tar_classes[exampleTest->label];
char p = tar_classes[prediction];
if (toupper(l) == toupper(p))
upperNumOK++;
}
printf("\n---------------------------------------------\n");
printf("Chars74k Classification Accuracy (case-sensitive): %f\n",(float)numOK/currTest.size());
printf("Chars74k Classification Accuracy (case-insensitive): %f\n",(float)upperNumOK/currTest.size());
return 0;
}
#else
int main()
{
std::cerr << "OpenCV was built without text module" << std::endl;
return 0;
}
#endif // HAVE_OPENCV_TEXT
+101
View File
@@ -0,0 +1,101 @@
/*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/tr_icdar.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 root folder }";
CommandLineParser parser(argc, argv, keys);
string path(parser.get<string>("path"));
if (parser.has("help") || path=="true")
{
parser.printMessage();
return -1;
}
// loading train & test images description
Ptr<TR_icdar> dataset = TR_icdar::create();
dataset->load(path);
// ***************
// dataset. train & test contains images description.
// For example, let output the last element in train set and it's description.
// And their sizes.
printf("train size: %u\n", (unsigned int)dataset->getTrain().size());
printf("test size: %u\n", (unsigned int)dataset->getTest().size());
TR_icdarObj *example = static_cast<TR_icdarObj *>(dataset->getTrain().back().get());
printf("last element:\nfile name: %s", example->fileName.c_str());
printf("\nlex100: ");
for (vector<string>::iterator it=example->lex100.begin(); it!=example->lex100.end(); ++it)
{
printf("%s,", (*it).c_str());
}
printf("\nlexFULL: ");
for (vector<string>::iterator it=example->lexFull.begin(); it!=example->lexFull.end(); ++it)
{
printf("%s,", (*it).c_str());
}
printf("\nwords:\n");
for (vector<word>::iterator it=example->words.begin(); it!=example->words.end(); ++it)
{
word &t = (*it);
printf("%s\nheight: %u, width: %u, x: %u, y: %u\n",
t.value.c_str(), t.height, t.width, t.x, t.y);
}
return 0;
}
@@ -0,0 +1,522 @@
/*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 <iostream>
#include <opencv2/opencv_modules.hpp>
#ifdef HAVE_OPENCV_TEXT
#include "opencv2/datasets/tr_icdar.hpp"
#include <opencv2/core.hpp>
#include "opencv2/text.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/imgcodecs.hpp"
#include <cstdio>
#include <cstdlib> // atoi
#include <string>
#include <vector>
using namespace std;
using namespace cv;
using namespace cv::datasets;
using namespace cv::text;
//Calculate edit distance between two words
size_t edit_distance(const string& A, const string& B);
size_t min(size_t x, size_t y, size_t z);
bool isRepetitive(const string& s);
bool sort_by_length(const string &a, const string &b);
//Draw ER's in an image via floodFill
void er_draw(vector<Mat> &channels, vector<vector<ERStat> > &regions, vector<Vec2i> group, Mat& segmentation);
size_t min(size_t x, size_t y, size_t z)
{
return x < y ? min(x,z) : min(y,z);
}
size_t edit_distance(const string& A, const string& B)
{
size_t NA = A.size();
size_t NB = B.size();
vector< vector<size_t> > M(NA + 1, vector<size_t>(NB + 1));
for (size_t a = 0; a <= NA; ++a)
M[a][0] = a;
for (size_t b = 0; b <= NB; ++b)
M[0][b] = b;
for (size_t a = 1; a <= NA; ++a)
for (size_t b = 1; b <= NB; ++b)
{
size_t x = M[a-1][b] + 1;
size_t y = M[a][b-1] + 1;
size_t z = M[a-1][b-1] + (A[a-1] == B[b-1] ? 0 : 1);
M[a][b] = min(x,y,z);
}
return M[A.size()][B.size()];
}
bool sort_by_length(const string &a, const string &b){return (a.size()>b.size());}
bool isRepetitive(const string& s)
{
int count = 0;
for (int i=0; i<(int)s.size(); i++)
{
if ((s[i] == 'i') ||
(s[i] == 'l') ||
(s[i] == 'I'))
count++;
}
if (count > ((int)s.size()+1)/2)
{
return true;
}
return false;
}
void er_draw(vector<Mat> &channels, vector<vector<ERStat> > &regions, vector<Vec2i> group, Mat& segmentation)
{
for (int r=0; r<(int)group.size(); r++)
{
ERStat er = regions[group[r][0]][group[r][1]];
if (er.parent != NULL) // deprecate the root region
{
int newMaskVal = 255;
int flags = 4 + (newMaskVal << 8) + FLOODFILL_FIXED_RANGE + FLOODFILL_MASK_ONLY;
floodFill(channels[group[r][0]],segmentation,Point(er.pixel%channels[group[r][0]].cols,er.pixel/channels[group[r][0]].cols),
Scalar(255),0,Scalar(er.level),Scalar(0),flags);
}
}
}
// std::toupper is int->int
static char char_toupper(char ch)
{
return (char)std::toupper((int)ch);
}
int main(int argc, char *argv[])
{
const char *keys =
"{ help h usage ? | | show this message }"
"{ path p |true| path to dataset root folder }"
"{ ws wordspotting| | evaluate \"word spotting\" results }"
"{ lex lexicon |1 | 0:no-lexicon, 1:100-words, 2:full-lexicon }";
CommandLineParser parser(argc, argv, keys);
string path(parser.get<string>("path"));
if (parser.has("help") || path=="true")
{
parser.printMessage();
return -1;
}
bool is_word_spotting = parser.has("ws");
int selected_lex = parser.get<int>("lex");
if ((selected_lex < 0) || (selected_lex > 2))
{
parser.printMessage();
printf("Unsupported lex value.\n");
return -1;
}
// loading train & test images description
Ptr<TR_icdar> dataset = TR_icdar::create();
dataset->load(path);
vector<double> f1Each;
unsigned int correctNum = 0;
unsigned int returnedNum = 0;
unsigned int returnedCorrectNum = 0;
vector< Ptr<Object> >& test = dataset->getTest();
unsigned int num = 0;
for (vector< Ptr<Object> >::iterator itT=test.begin(); itT!=test.end(); ++itT)
{
TR_icdarObj *example = static_cast<TR_icdarObj *>((*itT).get());
num++;
printf("processed image: %u, name: %s\n", num, example->fileName.c_str());
vector<string> empty_lexicon;
vector<string> *lex;
switch (selected_lex)
{
case 0:
lex = &empty_lexicon;
break;
case 2:
lex = &example->lexFull;
break;
default:
lex = &example->lex100;
break;
}
correctNum += example->words.size();
unsigned int correctNumEach = example->words.size();
// Take care of dontcare regions t.value == "###"
for (size_t w=0; w<example->words.size(); w++)
{
string w_upper = example->words[w].value;
transform(w_upper.begin(), w_upper.end(), w_upper.begin(), char_toupper);
if ((find (lex->begin(), lex->end(), w_upper) == lex->end()) &&
(is_word_spotting) && (selected_lex != 0))
example->words[w].value = "###";
if ( (example->words[w].value == "###") || (example->words[w].value.size()<3) )
{
correctNum --;
correctNumEach --;
}
}
unsigned int returnedNumEach = 0;
unsigned int returnedCorrectNumEach = 0;
Mat image = imread((path+"/test/"+example->fileName).c_str());
/*Text Detection*/
// Extract channels to be processed individually
vector<Mat> channels;
Mat grey;
cvtColor(image,grey,COLOR_RGB2GRAY);
// Notice here we are only using grey channel, see textdetection.cpp for example with more channels
channels.push_back(grey);
channels.push_back(255-grey);
// Create ERFilter objects with the 1st and 2nd sworde default classifiers
Ptr<ERFilter> er_filter1 = createERFilterNM1(loadClassifierNM1("trained_classifierNM1.xml"),8,0.00015f,0.13f,0.2f,true,0.1f);
Ptr<ERFilter> er_filter2 = createERFilterNM2(loadClassifierNM2("trained_classifierNM2.xml"),0.5);
vector<vector<ERStat> > regions(channels.size());
// Apply the default cascade classifier to each independent channel (could be done in parallel)
for (int c=0; c<(int)channels.size(); c++)
{
er_filter1->run(channels[c], regions[c]);
er_filter2->run(channels[c], regions[c]);
}
// Detect character groups
vector< vector<Vec2i> > nm_region_groups;
vector<Rect> nm_boxes;
erGrouping(image, channels, regions, nm_region_groups, nm_boxes, ERGROUPING_ORIENTATION_HORIZ);
/*Text Recognition (OCR)*/
Ptr<OCRTesseract> ocr = OCRTesseract::create();
bool ocr_is_tesseract = true;
vector<string> final_words;
vector<Rect> final_boxes;
vector<float> final_confs;
for (int i=0; i<(int)nm_boxes.size(); i++)
{
Mat group_img = Mat::zeros(image.rows+2, image.cols+2, CV_8UC1);
er_draw(channels, regions, nm_region_groups[i], group_img);
if (ocr_is_tesseract)
{
group_img(nm_boxes[i]).copyTo(group_img);
copyMakeBorder(group_img,group_img,15,15,15,15,BORDER_CONSTANT,Scalar(0));
} else {
group_img(Rect(1,1,image.cols,image.rows)).copyTo(group_img);
}
string output;
vector<Rect> boxes;
vector<string> words;
vector<float> confidences;
ocr->run(grey, group_img, output, &boxes, &words, &confidences, OCR_LEVEL_WORD);
output.erase(remove(output.begin(), output.end(), '\n'), output.end());
//cout << "OCR output = \"" << output << "\" length = " << output.size() << endl;
if (output.size() < 3)
continue;
for (int j=0; j<(int)boxes.size(); j++)
{
if (ocr_is_tesseract)
{
boxes[j].x += nm_boxes[i].x-15;
boxes[j].y += nm_boxes[i].y-15;
}
float min_confidence = (ocr_is_tesseract)? (float)51. : (float)0.;
float min_confidence4 = (ocr_is_tesseract)? (float)60. : (float)0.;
//cout << " word = " << words[j] << "\t confidence = " << confidences[j] << endl;
if ((words[j].size() < 2) || (confidences[j] < min_confidence) ||
((words[j].size()==2) && (words[j][0] == words[j][1])) ||
((words[j].size()< 4) && (confidences[j] < min_confidence4)) ||
isRepetitive(words[j]))
{
continue;
}
std::transform(words[j].begin(), words[j].end(), words[j].begin(), char_toupper);
/* Increase confidence of predicted words matching a word in the lexicon */
if (lex->size() > 0)
{
if (find(lex->begin(), lex->end(), words[j]) == lex->end())
confidences[j] = 200;
}
final_words.push_back(words[j]);
final_boxes.push_back(boxes[j]);
final_confs.push_back(confidences[j]);
}
}
/* Non Maximal Suppression using OCR confidence */
float thr = 0.5;
for (size_t i=0; i<final_words.size(); )
{
int to_delete = -1;
for (size_t j=i+1; j<final_words.size(); )
{
to_delete = -1;
Rect intersection = final_boxes[i] & final_boxes[j];
float IoU = (float)intersection.area() / (final_boxes[i].area() + final_boxes[j].area() - intersection.area());
if ((IoU > thr) || (intersection.area() > 0.8*final_boxes[i].area()) || (intersection.area() > 0.8*final_boxes[j].area()))
{
// if regions overlap more than thr delete the one with lower confidence
to_delete = (final_confs[i] < final_confs[j]) ? i : j;
if (to_delete == (int)j )
{
final_words.erase(final_words.begin()+j);
final_boxes.erase(final_boxes.begin()+j);
final_confs.erase(final_confs.begin()+j);
continue;
} else {
break;
}
}
j++;
}
if (to_delete == (int)i )
{
final_words.erase(final_words.begin()+i);
final_boxes.erase(final_boxes.begin()+i);
final_confs.erase(final_confs.begin()+i);
continue;
}
i++;
}
/* Predicted words which are not in the lexicon are filtered
or changed to match one (when edit distance ratio < 0.34)*/
float max_edit_distance_ratio = (float)0.34;
for (size_t j=0; j<final_boxes.size(); j++)
{
if (lex->size() > 0)
{
if (find(lex->begin(), lex->end(), final_words[j]) == lex->end())
{
int best_match = -1;
int best_dist = final_words[j].size();
for (size_t l=0; l<lex->size(); l++)
{
int dist = edit_distance(lex->at(l),final_words[j]);
if (dist < best_dist)
{
best_match = l;
best_dist = dist;
}
}
if (best_dist/final_words[j].size() < max_edit_distance_ratio)
final_words[j] = lex->at(best_match);
else
continue;
}
}
if ((find (lex->begin(), lex->end(), final_words[j])
== lex->end()) && (is_word_spotting) && (selected_lex != 0))
continue;
// Output final recognition in csv format compatible with the ICDAR Competition
/*cout << final_boxes[j].tl().x << ","
<< final_boxes[j].tl().y << ","
<< min(final_boxes[j].br().x,image.cols-2)
<< "," << final_boxes[j].tl().y << ","
<< min(final_boxes[j].br().x,image.cols-2) << ","
<< min(final_boxes[j].br().y,image.rows-2) << ","
<< final_boxes[j].tl().x << ","
<< min(final_boxes[j].br().y,image.rows-2) << ","
<< final_words[j] << endl ;*/
returnedNum++;
returnedNumEach++;
bool matched = false;
for (vector<word>::iterator it=example->words.begin(); it!=example->words.end(); ++it)
{
word &t = (*it);
// ICDAR protocol accepts recognition up to the first non alphanumeric char
string alnum_value = t.value;
for (size_t c=0; c<alnum_value.size(); c++)
{
if (!isalnum(alnum_value[c]))
{
alnum_value = alnum_value.substr(0,c);
break;
}
}
std::transform(t.value.begin(), t.value.end(), t.value.begin(), char_toupper);
if (((t.value==final_words[j]) || (alnum_value==final_words[j])) &&
!(final_boxes[j].tl().x > t.x+t.width || final_boxes[j].br().x < t.x ||
final_boxes[j].tl().y > t.y+t.height || final_boxes[j].br().y < t.y))
{
matched = true;
returnedCorrectNum++;
returnedCorrectNumEach++;
//cout << "OK!" << endl;
break;
}
}
if (!matched) // Take care of dontcare regions t.value == "###"
for (vector<word>::iterator it=example->words.begin(); it!=example->words.end(); ++it)
{
word &t = (*it);
std::transform(t.value.begin(), t.value.end(), t.value.begin(), char_toupper);
if ((t.value == "###") &&
!(final_boxes[j].tl().x > t.x+t.width || final_boxes[j].br().x < t.x ||
final_boxes[j].tl().y > t.y+t.height || final_boxes[j].br().y < t.y))
{
matched = true;
returnedNum--;
returnedNumEach--;
//cout << "DontCare!" << endl;
break;
}
}
//if (!matched) cout << "FAIL." << endl;
}
double p = 0.0;
if (0 != returnedNumEach)
{
p = 1.0*returnedCorrectNumEach/returnedNumEach;
}
double r = 0.0;
if (0 != correctNumEach)
{
r = 1.0*returnedCorrectNumEach/correctNumEach;
}
double f1 = 0.0;
if (0 != p+r)
{
f1 = 2*(p*r)/(p+r);
}
if ( (correctNumEach == 0) && (returnedNumEach == 0) )
{
p = 1.;
r = 1.;
f1 = 1.;
}
//printf("|%f|%f|%f|\n",r,p,f1);
f1Each.push_back(f1);
}
double p = 1.0*returnedCorrectNum/returnedNum;
double r = 1.0*returnedCorrectNum/correctNum;
double f1 = 2*(p*r)/(p+r);
printf("\n-------------------------------------------------------------------------\n");
printf("ICDAR2015 -- Challenge 2: \"Focused Scene Text\" -- Task 4 \"End-to-End\"\n");
if (is_word_spotting) printf(" Word spotting results -- ");
else printf(" End-to-End recognition results -- ");
switch (selected_lex)
{
case 0:
printf("generic recognition (no given lexicon)\n");
break;
case 2:
printf("weakly contextualized lexicon (624 words)\n");
break;
default:
printf("strongly contextualized lexicon (100 words)\n");
break;
}
printf(" Recall: %f | Precision: %f | F-score: %f\n", r, p, f1);
printf("-------------------------------------------------------------------------\n\n");
/*double mf1 = 0.0;
for (vector<double>::iterator it=f1Each.begin(); it!=f1Each.end(); ++it)
{
mf1 += *it;
}
mf1 /= f1Each.size();
printf("mean f1: %f\n", mf1);*/
return 0;
}
#else
int main()
{
std::cerr << "OpenCV was built without text module" << std::endl;
return 0;
}
#endif // HAVE_OPENCV_TEXT
+96
View File
@@ -0,0 +1,96 @@
/*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/tr_svt.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 xml files }";
CommandLineParser parser(argc, argv, keys);
string path(parser.get<string>("path"));
if (parser.has("help") || path=="true")
{
parser.printMessage();
return -1;
}
// loading train & test images description
Ptr<TR_svt> dataset = TR_svt::create();
dataset->load(path);
// ***************
// dataset. train & test contains images description.
// For example, let output the last element in train set and it's description.
// And their sizes.
printf("train size: %u\n", (unsigned int)dataset->getTrain().size());
printf("test size: %u\n", (unsigned int)dataset->getTest().size());
TR_svtObj *example = static_cast<TR_svtObj *>(dataset->getTrain().back().get());
printf("last element:\nfile name: %s", example->fileName.c_str());
printf("\nlex: ");
for (vector<string>::iterator it=example->lex.begin(); it!=example->lex.end(); ++it)
{
printf("%s,", (*it).c_str());
}
printf("\ntags:\n");
for (vector<tag>::iterator it=example->tags.begin(); it!=example->tags.end(); ++it)
{
tag &t = (*it);
printf("%s\nheight: %u, width: %u, x: %u, y: %u\n",
t.value.c_str(), t.height, t.width, t.x, t.y);
}
return 0;
}
@@ -0,0 +1,322 @@
/*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 <iostream>
#include <opencv2/opencv_modules.hpp>
#ifdef HAVE_OPENCV_TEXT
#include "opencv2/datasets/tr_svt.hpp"
#include <opencv2/core.hpp>
#include "opencv2/text.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/imgcodecs.hpp"
#include <cstdio>
#include <cstdlib> // atoi
#include <string>
#include <vector>
using namespace std;
using namespace cv;
using namespace cv::datasets;
using namespace cv::text;
//Calculate edit distance between two words
size_t edit_distance(const string& A, const string& B);
size_t min(size_t x, size_t y, size_t z);
bool isRepetitive(const string& s);
bool sort_by_length(const string &a, const string &b);
//Draw ER's in an image via floodFill
void er_draw(vector<Mat> &channels, vector<vector<ERStat> > &regions, vector<Vec2i> group, Mat& segmentation);
size_t min(size_t x, size_t y, size_t z)
{
return x < y ? min(x,z) : min(y,z);
}
size_t edit_distance(const string& A, const string& B)
{
size_t NA = A.size();
size_t NB = B.size();
vector< vector<size_t> > M(NA + 1, vector<size_t>(NB + 1));
for (size_t a = 0; a <= NA; ++a)
M[a][0] = a;
for (size_t b = 0; b <= NB; ++b)
M[0][b] = b;
for (size_t a = 1; a <= NA; ++a)
for (size_t b = 1; b <= NB; ++b)
{
size_t x = M[a-1][b] + 1;
size_t y = M[a][b-1] + 1;
size_t z = M[a-1][b-1] + (A[a-1] == B[b-1] ? 0 : 1);
M[a][b] = min(x,y,z);
}
return M[A.size()][B.size()];
}
bool sort_by_length(const string &a, const string &b){return (a.size()>b.size());}
bool isRepetitive(const string& s)
{
int count = 0;
for (int i=0; i<(int)s.size(); i++)
{
if ((s[i] == 'i') ||
(s[i] == 'l') ||
(s[i] == 'I'))
count++;
}
if (count > ((int)s.size()+1)/2)
{
return true;
}
return false;
}
void er_draw(vector<Mat> &channels, vector<vector<ERStat> > &regions, vector<Vec2i> group, Mat& segmentation)
{
for (int r=0; r<(int)group.size(); r++)
{
ERStat er = regions[group[r][0]][group[r][1]];
if (er.parent != NULL) // deprecate the root region
{
int newMaskVal = 255;
int flags = 4 + (newMaskVal << 8) + FLOODFILL_FIXED_RANGE + FLOODFILL_MASK_ONLY;
floodFill(channels[group[r][0]],segmentation,Point(er.pixel%channels[group[r][0]].cols,er.pixel/channels[group[r][0]].cols),
Scalar(255),0,Scalar(er.level),Scalar(0),flags);
}
}
}
// std::toupper is int->int
static char char_toupper(char ch)
{
return (char)std::toupper((int)ch);
}
int main(int argc, char *argv[])
{
const char *keys =
"{ help h usage ? | | show this message }"
"{ path p |true| path to dataset xml files }";
CommandLineParser parser(argc, argv, keys);
string path(parser.get<string>("path"));
if (parser.has("help") || path=="true")
{
parser.printMessage();
return -1;
}
// loading train & test images description
Ptr<TR_svt> dataset = TR_svt::create();
dataset->load(path);
vector<double> f1Each;
unsigned int correctNum = 0;
unsigned int returnedNum = 0;
unsigned int returnedCorrectNum = 0;
vector< Ptr<Object> >& test = dataset->getTest();
unsigned int num = 0;
for (vector< Ptr<Object> >::iterator itT=test.begin(); itT!=test.end(); ++itT)
{
TR_svtObj *example = static_cast<TR_svtObj *>((*itT).get());
num++;
printf("processed image: %u, name: %s\n", num, example->fileName.c_str());
correctNum += example->tags.size();
/* printf("\ntags:\n");
for (vector<tag>::iterator it=example->tags.begin(); it!=example->tags.end(); ++it)
{
tag &t = (*it);
printf("%s\nx: %u, y: %u, width: %u, height: %u\n",
t.value.c_str(), t.x, t.y, t.x+t.width, t.y+t.height);
}*/
unsigned int correctNumEach = example->tags.size();
unsigned int returnedNumEach = 0;
unsigned int returnedCorrectNumEach = 0;
Mat image = imread((path+example->fileName).c_str());
/*Text Detection*/
// Extract channels to be processed individually
vector<Mat> channels;
Mat grey;
cvtColor(image,grey,COLOR_RGB2GRAY);
// Notice here we are only using grey channel, see textdetection.cpp for example with more channels
channels.push_back(grey);
channels.push_back(255-grey);
// Create ERFilter objects with the 1st and 2nd stage default classifiers
Ptr<ERFilter> er_filter1 = createERFilterNM1(loadClassifierNM1("trained_classifierNM1.xml"),8,0.00015f,0.13f,0.2f,true,0.1f);
Ptr<ERFilter> er_filter2 = createERFilterNM2(loadClassifierNM2("trained_classifierNM2.xml"),0.5);
vector<vector<ERStat> > regions(channels.size());
// Apply the default cascade classifier to each independent channel (could be done in parallel)
for (int c=0; c<(int)channels.size(); c++)
{
er_filter1->run(channels[c], regions[c]);
er_filter2->run(channels[c], regions[c]);
}
// Detect character groups
vector< vector<Vec2i> > nm_region_groups;
vector<Rect> nm_boxes;
erGrouping(image, channels, regions, nm_region_groups, nm_boxes, ERGROUPING_ORIENTATION_HORIZ);
/*Text Recognition (OCR)*/
Ptr<OCRTesseract> ocr = OCRTesseract::create();
for (int i=0; i<(int)nm_boxes.size(); i++)
{
Mat group_img = Mat::zeros(image.rows+2, image.cols+2, CV_8UC1);
er_draw(channels, regions, nm_region_groups[i], group_img);
group_img(nm_boxes[i]).copyTo(group_img);
copyMakeBorder(group_img,group_img,15,15,15,15,BORDER_CONSTANT,Scalar(0));
string output;
vector<Rect> boxes;
vector<string> words;
vector<float> confidences;
ocr->run(group_img, output, &boxes, &words, &confidences, OCR_LEVEL_WORD);
output.erase(remove(output.begin(), output.end(), '\n'), output.end());
//cout << "OCR output = \"" << output << "\" length = " << output.size() << endl;
if (output.size() < 3)
continue;
for (int j=0; j<(int)boxes.size(); j++)
{
boxes[j].x += nm_boxes[i].x-15;
boxes[j].y += nm_boxes[i].y-15;
//cout << " word = " << words[j] << "\t confidence = " << confidences[j] << endl;
if ((words[j].size() < 2) || (confidences[j] < 51) ||
((words[j].size()==2) && (words[j][0] == words[j][1])) ||
((words[j].size()< 4) && (confidences[j] < 60)) ||
isRepetitive(words[j]))
{
continue;
}
std::transform(words[j].begin(), words[j].end(), words[j].begin(), char_toupper);
if (find(example->lex.begin(), example->lex.end(), words[j]) == example->lex.end())
{
continue;
}
returnedNum++;
returnedNumEach++;
/*printf("%s\nx: %u, y: %u, width: %u, height: %u\n",
words[j].c_str(), boxes[j].tl().x, boxes[j].tl().y, boxes[j].br().x, boxes[j].br().y);*/
for (vector<tag>::iterator it=example->tags.begin(); it!=example->tags.end(); ++it)
{
tag &t = (*it);
if (t.value==words[j] &&
!(boxes[j].tl().x > t.x+t.width || boxes[j].br().x < t.x ||
boxes[j].tl().y > t.y+t.height || boxes[j].br().y < t.y))
{
returnedCorrectNum++;
returnedCorrectNumEach++;
break;
}
}
}
}
double p = 0.0;
if (0 != returnedNumEach)
{
p = 1.0*returnedCorrectNumEach/returnedNumEach;
}
double r = 0.0;
if (0 != correctNumEach)
{
r = 1.0*returnedCorrectNumEach/correctNumEach;
}
double f1 = 0.0;
if (0 != p+r)
{
f1 = 2*(p*r)/(p+r);
}
//printf("|%f|\n", f1);
f1Each.push_back(f1);
}
double p = 1.0*returnedCorrectNum/returnedNum;
double r = 1.0*returnedCorrectNum/correctNum;
double f1 = 2*(p*r)/(p+r);
printf("f1: %f\n", f1);
/*double f1 = 0.0;
for (vector<double>::iterator it=f1Each.begin(); it!=f1Each.end(); ++it)
{
f1 += *it;
}
f1 /= f1Each.size();
printf("mean f1: %f\n", f1);*/
return 0;
}
#else
int main()
{
std::cerr << "OpenCV was built without text module" << std::endl;
return 0;
}
#endif // HAVE_OPENCV_TEXT
+99
View File
@@ -0,0 +1,99 @@
/*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/track_vot.hpp"
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <set>
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 folder with dataset }"
"{ datasetID id |1| Dataset ID}";
CommandLineParser parser(argc, argv, keys);
string path(parser.get<string>("path"));
int datasetID(parser.get<int>("datasetID"));
if (parser.has("help") || path == "true")
{
parser.printMessage();
getchar();
return -1;
}
Ptr<TRACK_vot> dataset = TRACK_vot::create();
dataset->load(path);
printf("Datasets number: %d\n", dataset->getDatasetsNum());
for (int i = 1; i <= dataset->getDatasetsNum(); i++)
printf("\tDataset #%d size: %d\n", i, dataset->getDatasetLength(i));
dataset->initDataset(datasetID);
for (int i = 0; i < dataset->getDatasetLength(datasetID); i++)
{
Mat frame;
if (!dataset->getNextFrame(frame))
break;
//Draw Ground Truth BB
vector <Point2d> gtPoints = dataset->getGT();
for (int j = 0; j < (int)(gtPoints.size()-1); j++)
line(frame, gtPoints[j], gtPoints[j + 1], Scalar(0, 255, 0), 2);
line(frame, gtPoints[0], gtPoints[(int)(gtPoints.size()-1)], Scalar(0, 255, 0), 2);
imshow("VOT 2015 DATASET TEST...", frame);
waitKey(100);
}
getchar();
return 0;
}
+151
View File
@@ -0,0 +1,151 @@
/*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/ar_hmdb.hpp"
#include "opencv2/datasets/util.hpp"
#include <map>
namespace cv
{
namespace datasets
{
using namespace std;
class AR_hmdbImp : public AR_hmdb
{
public:
AR_hmdbImp() {}
//AR_hmdbImp(const string &path, int number = 0);
virtual ~AR_hmdbImp() {}
virtual void load(const string &path) CV_OVERRIDE;
private:
void loadDatasetSplit(const string &path, int number = 0);
void loadDataset(const string &path);
map<string, int> actionsId;
};
/*AR_hmdbImp::AR_hmdbImp(const string &path, int number)
{
loadDataset(path, number);
}*/
void AR_hmdbImp::load(const string &path)
{
loadDataset(path);
}
void AR_hmdbImp::loadDataset(const string &path)
{
for (int i=0; i<3; ++i)
{
loadDatasetSplit(path, i);
}
}
void AR_hmdbImp::loadDatasetSplit(const string &path, int number)
{
// valid number [0,1,2]
if (number<0 || number>2)
{
return;
}
train.push_back(vector< Ptr<Object> >());
test.push_back(vector< Ptr<Object> >());
validation.push_back(vector< Ptr<Object> >());
string pathDataset(path + "hmdb51_org/");
string pathSplit(path + "testTrainMulti_7030_splits/");
vector<string> fileNames;
getDirList(pathDataset, fileNames);
for (vector<string>::iterator it=fileNames.begin(); it!=fileNames.end(); ++it)
{
string &action = *it;
map<string, int>::iterator itId = actionsId.find(action);
int id;
if (itId == actionsId.end())
{
actionsId.insert(make_pair(action, actionsId.size()));
id = (int)actionsId.size();
} else
{
id = (*itId).second;
}
char tmp[2];
sprintf(tmp, "%u", number+1);
string fileName(pathSplit + action + "_test_split" + tmp + ".txt");
ifstream infile(fileName.c_str());
string video, label;
while (infile >> video >> label)
{
Ptr<AR_hmdbObj> curr(new AR_hmdbObj);
curr->id = id;
curr->name = action;
curr->videoName = video;
if ("1"==label)
{
train.back().push_back(curr);
} else
if ("2"==label)
{
test.back().push_back(curr);
}
}
}
}
Ptr<AR_hmdb> AR_hmdb::create()
{
return Ptr<AR_hmdbImp>(new AR_hmdbImp);
}
}
}
+119
View File
@@ -0,0 +1,119 @@
/*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/ar_sports.hpp"
#include "opencv2/datasets/util.hpp"
namespace cv
{
namespace datasets
{
using namespace std;
class AR_sportsImp : public AR_sports
{
public:
AR_sportsImp() {}
//AR_sportsImp(const string &path);
virtual ~AR_sportsImp() {}
virtual void load(const string &path) CV_OVERRIDE;
private:
void loadDataset(const string &path);
void loadDatasetPart(const string &fileName, vector< Ptr<Object> > &dataset_);
};
void AR_sportsImp::loadDatasetPart(const string &fileName, vector< Ptr<Object> > &dataset_)
{
ifstream infile(fileName.c_str());
string videoUrl, labels;
while (infile >> videoUrl >> labels)
{
Ptr<AR_sportsObj> curr(new AR_sportsObj);
curr->videoUrl = videoUrl;
vector<string> elems;
split(labels, elems, ',');
for (vector<string>::iterator it=elems.begin(); it!=elems.end(); ++it)
{
curr->labels.push_back(atoi((*it).c_str()));
}
dataset_.push_back(curr);
}
}
/*AR_sportsImp::AR_sportsImp(const string &path)
{
loadDataset(path);
}*/
void AR_sportsImp::load(const string &path)
{
loadDataset(path);
}
void AR_sportsImp::loadDataset(const string &path)
{
train.push_back(vector< Ptr<Object> >());
test.push_back(vector< Ptr<Object> >());
validation.push_back(vector< Ptr<Object> >());
string trainPath(path + "original/train_partition.txt");
string testPath(path + "original/test_partition.txt");
// loading train video urls & labels
loadDatasetPart(trainPath, train.back());
// loading test video urls & labels
loadDatasetPart(testPath, test.back());
}
Ptr<AR_sports> AR_sports::create()
{
return Ptr<AR_sportsImp>(new AR_sportsImp);
}
}
}
+89
View File
@@ -0,0 +1,89 @@
/*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/dataset.hpp"
#include "opencv2/datasets/util.hpp"
namespace cv
{
namespace datasets
{
using namespace std;
vector< Ptr<Object> >& Dataset::getTrain(int splitNum)
{
if (splitNum >= (int)train.size())
{
return empty;
}
return train[splitNum];
}
vector< Ptr<Object> >& Dataset::getTest(int splitNum)
{
if (splitNum >= (int)test.size())
{
return empty;
}
return test[splitNum];
}
vector< Ptr<Object> >& Dataset::getValidation(int splitNum)
{
if (splitNum >= (int)validation.size())
{
return empty;
}
return validation[splitNum];
}
int Dataset::getNumSplits() const
{
return (int)train.size();
}
}
}
+227
View File
@@ -0,0 +1,227 @@
/*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"
#include <map>
#include <set>
namespace cv
{
namespace datasets
{
using namespace std;
class FR_adienceImp CV_FINAL : public FR_adience
{
public:
FR_adienceImp() {}
//FR_adienceImp(const string &path);
virtual ~FR_adienceImp() {}
virtual void load(const string &path) CV_OVERRIDE;
private:
void loadDataset(const string &path);
void loadFile(const string &filename, vector< Ptr<FR_adienceObj> > &out);
void cv5ToSplits(vector< Ptr<FR_adienceObj> > fileList[5]);
map< string, vector<string> > realNames;
set<string> missing;
};
/*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());
getline(infile, line); // skip header
while (getline(infile, line))
{
vector<string> elems;
split(line, elems, ',');
string user_id = elems[0];
string original_image = elems[1];
// convert original_image to real image name
bool isChanged = false;
vector<string> &currImgs = realNames[user_id];
for (vector<string>::iterator it=currImgs.begin(); it!=currImgs.end(); ++it)
{
string &name = *it;
size_t origImgLen = original_image.length();
if (name.length()>origImgLen && name.substr(name.length()-origImgLen) == original_image)
{
original_image = name;
isChanged = true;
break;
}
}
if (!isChanged)
{
missing.insert(user_id+"/"+original_image);
continue;
}
Ptr<FR_adienceObj> curr(new FR_adienceObj);
curr->user_id = user_id;
curr->original_image = original_image;
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)
{
// collect real image names
vector<string> userNames;
getDirList(path+"faces/", userNames);
for (vector<string>::iterator itU=userNames.begin(); itU!=userNames.end(); ++itU)
{
vector<string> fileNames;
getDirList(path+"faces/"+*itU+"/", fileNames);
for (vector<string>::iterator it=fileNames.begin(); it!=fileNames.end(); ++it)
{
string &name = *it;
if (name.length()>3 && name.substr(name.length()-4) == ".jpg")
{
realNames[*itU].push_back(name);
}
}
}
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);
/*for (set<string>::iterator it=missing.begin(); it!=missing.end(); ++it)
{
printf("missing image: %s\n", (*it).c_str());
}*/
realNames.clear();
missing.clear();
}
Ptr<FR_adience> FR_adience::create()
{
return Ptr<FR_adienceImp>(new FR_adienceImp);
}
}
}
+222
View File
@@ -0,0 +1,222 @@
/*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_lfw.hpp"
#include "opencv2/datasets/util.hpp"
#include <map>
namespace cv
{
namespace datasets
{
using namespace std;
class FR_lfwImp CV_FINAL : public FR_lfw
{
public:
FR_lfwImp() {}
//FR_lfwImp(const string &path);
virtual ~FR_lfwImp() {}
virtual void load(const string &path) CV_OVERRIDE;
private:
void loadDataset(const string &path);
map< string, vector<string> > faces;
};
/*FR_lfwImp::FR_lfwImp(const string &path)
{
loadDataset(path);
}*/
void FR_lfwImp::load(const string &path)
{
loadDataset(path);
}
void FR_lfwImp::loadDataset(const string &path)
{
vector<string> fileNames;
getDirList(path, fileNames);
for (vector<string>::iterator it=fileNames.begin(); it!=fileNames.end(); ++it)
{
string &name = *it;
if (name.length()>3 && name.substr(name.length()-4) == ".txt")
{
continue;
}
vector<string> images;
string pathFace(path + name + "/");
vector<string> faceNames;
getDirList(pathFace, faceNames);
for (vector<string>::iterator itFace=faceNames.begin(); itFace!=faceNames.end(); ++itFace)
{
images.push_back(*itFace);
}
faces.insert(make_pair(name, images));
}
// test loading
ifstream infile((path + "pairs.txt").c_str());
string line;
getline(infile, line); // should be 10 300
CV_Assert(line=="10\t300");
unsigned int num = 0;
while (getline(infile, line))
{
if (0 == (num % 600))
{
train.push_back(vector< Ptr<Object> >());
test.push_back(vector< Ptr<Object> >());
}
vector<string> elems;
split(line, elems, '\t');
Ptr<FR_lfwObj> curr(new FR_lfwObj);
string &person1 = elems[0];
unsigned int imageNumber1 = atoi(elems[1].c_str())-1;
curr->image1 = person1 + "/" + faces[person1][imageNumber1];
string person2;
unsigned int imageNumber2;
if (3 == elems.size())
{
person2 = elems[0];
imageNumber2 = atoi(elems[2].c_str())-1;
curr->same = true;
} else
{
person2 = elems[2];
imageNumber2 = atoi(elems[3].c_str())-1;
curr->same = false;
}
curr->image2 = person2 + "/" + faces[person2][imageNumber2];
test.back().push_back(curr);
num++;
}
infile.close();
// dev train loading to train[0]
ifstream infile2((path + "pairsDevTrain.txt").c_str());
getline(infile2, line); // should 1100
CV_Assert(line=="1100");
while (getline(infile2, line))
{
vector<string> elems;
split(line, elems, '\t');
Ptr<FR_lfwObj> curr(new FR_lfwObj);
string &person1 = elems[0];
unsigned int imageNumber1 = atoi(elems[1].c_str())-1;
curr->image1 = person1 + "/" + faces[person1][imageNumber1];
string person2;
unsigned int imageNumber2;
if (3 == elems.size())
{
person2 = elems[0];
imageNumber2 = atoi(elems[2].c_str())-1;
curr->same = true;
} else
{
person2 = elems[2];
imageNumber2 = atoi(elems[3].c_str())-1;
curr->same = false;
}
curr->image2 = person2 + "/" + faces[person2][imageNumber2];
train[0].push_back(curr);
}
infile2.close();
// dev train loading to validation[0]
ifstream infile3((path + "pairsDevTest.txt").c_str());
getline(infile3, line); // should 500
CV_Assert(line=="500");
validation.push_back(vector< Ptr<Object> >());
while (getline(infile3, line))
{
vector<string> elems;
split(line, elems, '\t');
Ptr<FR_lfwObj> curr(new FR_lfwObj);
string &person1 = elems[0];
unsigned int imageNumber1 = atoi(elems[1].c_str())-1;
curr->image1 = person1 + "/" + faces[person1][imageNumber1];
string person2;
unsigned int imageNumber2;
if (3 == elems.size())
{
person2 = elems[0];
imageNumber2 = atoi(elems[2].c_str())-1;
curr->same = true;
} else
{
person2 = elems[2];
imageNumber2 = atoi(elems[3].c_str())-1;
curr->same = false;
}
curr->image2 = person2 + "/" + faces[person2][imageNumber2];
validation[0].push_back(curr);
}
infile3.close();
}
Ptr<FR_lfw> FR_lfw::create()
{
return Ptr<FR_lfwImp>(new FR_lfwImp);
}
}
}
+169
View File
@@ -0,0 +1,169 @@
/*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/gr_chalearn.hpp"
#include "opencv2/datasets/util.hpp"
namespace cv
{
namespace datasets
{
using namespace std;
class GR_chalearnImp CV_FINAL : public GR_chalearn
{
public:
GR_chalearnImp() {}
//GR_chalearnImp(const string &path);
virtual ~GR_chalearnImp() {}
virtual void load(const string &path) CV_OVERRIDE;
private:
void loadDataset(const string &path);
void loadDatasetPart(const string &path, vector< Ptr<Object> > &dataset_, bool loadLabels);
};
/*GR_chalearnImp::GR_chalearnImp(const string &path)
{
loadDataset(path);
}*/
void GR_chalearnImp::load(const string &path)
{
loadDataset(path);
}
void GR_chalearnImp::loadDatasetPart(const string &path, vector< Ptr<Object> > &dataset_, bool loadLabels)
{
vector<string> fileNames;
getDirList(path, fileNames);
for (vector<string>::iterator it=fileNames.begin(); it!=fileNames.end(); ++it)
{
Ptr<GR_chalearnObj> curr(new GR_chalearnObj);
curr->name = *it;
curr->nameColor = curr->name + "/" + curr->name + "_color.mp4";
curr->nameDepth = curr->name + "/" + curr->name + "_depth.mp4";
curr->nameUser = curr->name + "/" + curr->name + "_user.mp4";
// loading video info
string fileVideoInfo(path + curr->name + "/" + curr->name + "_data.csv");
ifstream infile(fileVideoInfo.c_str());
string line;
getline(infile, line);
vector<string> elems;
split(line, elems, ',');
curr->numFrames = atoi(elems[0].c_str());
curr->fps = atoi(elems[1].c_str());
curr->depth = atoi(elems[2].c_str());
// loading ground truth
if (loadLabels)
{
string fileGroundTruth(path + curr->name + "/" + curr->name + "_labels.csv");
ifstream infileGroundTruth(fileGroundTruth.c_str());
while (getline(infileGroundTruth, line))
{
vector<string> elems2;
split(line, elems2, ',');
groundTruth currGroundTruth;
currGroundTruth.gestureID = atoi(elems2[0].c_str());
currGroundTruth.initialFrame = atoi(elems2[1].c_str());
currGroundTruth.lastFrame = atoi(elems2[2].c_str());
curr->groundTruths.push_back(currGroundTruth);
}
}
// loading skeleton
string fileSkeleton(path + curr->name + "/" + curr->name + "_skeleton.csv");
ifstream infileSkeleton(fileSkeleton.c_str());
while (getline(infileSkeleton, line))
{
skeleton currSkeleton;
vector<string> elems2;
split(line, elems2, ',');
for (unsigned int i=0, numJoin=0; i<elems2.size(); i+=9, ++numJoin)
{
currSkeleton.s[numJoin].Wx = atof(elems2[i+0].c_str());
currSkeleton.s[numJoin].Wy = atof(elems2[i+1].c_str());
currSkeleton.s[numJoin].Wz = atof(elems2[i+2].c_str());
currSkeleton.s[numJoin].Rx = atof(elems2[i+3].c_str());
currSkeleton.s[numJoin].Ry = atof(elems2[i+4].c_str());
currSkeleton.s[numJoin].Rz = atof(elems2[i+5].c_str());
currSkeleton.s[numJoin].Rw = atof(elems2[i+6].c_str());
currSkeleton.s[numJoin].Px = atof(elems2[i+7].c_str());
currSkeleton.s[numJoin].Py = atof(elems2[i+8].c_str());
}
curr->skeletons.push_back(currSkeleton);
}
dataset_.push_back(curr);
}
}
void GR_chalearnImp::loadDataset(const string &path)
{
train.push_back(vector< Ptr<Object> >());
test.push_back(vector< Ptr<Object> >());
validation.push_back(vector< Ptr<Object> >());
string pathTrain(path + "Train/");
loadDatasetPart(pathTrain, train.back(), true);
// freely available validation set doesn't have labels
string pathValidation(path + "Validation/");
loadDatasetPart(pathValidation, validation.back(), false);
}
Ptr<GR_chalearn> GR_chalearn::create()
{
return Ptr<GR_chalearnImp>(new GR_chalearnImp);
}
}
}
+134
View File
@@ -0,0 +1,134 @@
/*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/gr_skig.hpp"
#include "opencv2/datasets/util.hpp"
#include <cstring>
namespace cv
{
namespace datasets
{
using namespace std;
class GR_skigImp CV_FINAL : public GR_skig
{
public:
GR_skigImp() {}
//GR_skigImp(const string &path);
virtual ~GR_skigImp() {}
virtual void load(const string &path) CV_OVERRIDE;
private:
void loadDataset(const string &path);
};
/*GR_skigImp::GR_skigImp(const string &path)
{
loadDataset(path);
}*/
void GR_skigImp::load(const string &path)
{
loadDataset(path);
}
void GR_skigImp::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<=6; ++i)
{
char number[2];
sprintf(number, "%u", i);
string pathDatasetRgb(path + "subject" + number + "_rgb/");
string pathDatasetDep(path + "subject" + number + "_dep/");
vector<string> fileNames;
getDirList(pathDatasetRgb, fileNames);
for (vector<string>::iterator it=fileNames.begin(); it!=fileNames.end(); ++it)
{
string &file = *it;
Ptr<GR_skigObj> curr(new GR_skigObj);
curr->rgb = pathDatasetRgb + file;
curr->dep = file;
curr->dep[0] = 'K';
curr->dep = pathDatasetDep + curr->dep;
size_t posPerson = file.find("person_");
size_t posBackground = file.find("backgroud_");
size_t posIllumination = file.find("illumination_");
size_t posPose = file.find("pose_");
size_t posType = file.find("actionType_");
if (string::npos != posPerson &&
string::npos != posBackground &&
string::npos != posIllumination &&
string::npos != posPose &&
string::npos != posType)
{
curr->person = (unsigned char)atoi( file.substr(posPerson + strlen("person_"), 1).c_str() );
curr->background = (backgroundType)atoi( file.substr(posBackground + strlen("backgroud_"), 1).c_str() );
curr->illumination = (illuminationType)atoi( file.substr(posIllumination + strlen("illumination_"), 1).c_str() );
curr->pose = (poseType)atoi( file.substr(posPose + strlen("pose_"), 1).c_str() );
curr->type = (actionType)atoi( file.substr(posType + strlen("actionType_"), 2).c_str() );
train.back().push_back(curr);
} else
{
printf("incorrect file name: %s", file.c_str());
}
}
}
}
Ptr<GR_skig> GR_skig::create()
{
return Ptr<GR_skigImp>(new GR_skigImp);
}
}
}
+232
View File
@@ -0,0 +1,232 @@
/*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 CV_FINAL : public HPE_humaneva
{
public:
HPE_humanevaImp() {}
//HPE_humanevaImp(const string &path);
virtual ~HPE_humanevaImp() {}
virtual void load(const string &path) CV_OVERRIDE;
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) CV_OVERRIDE;
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);
}
}
}
+115
View File
@@ -0,0 +1,115 @@
/*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_parse.hpp"
#include "opencv2/datasets/util.hpp"
namespace cv
{
namespace datasets
{
using namespace std;
class HPE_parseImp CV_FINAL : public HPE_parse
{
public:
HPE_parseImp() {}
//HPE_parseImp(const string &path);
virtual ~HPE_parseImp() {}
virtual void load(const string &path) CV_OVERRIDE;
private:
void loadDataset(const string &path);
};
/*HPE_parseImp::HPE_parseImp(const string &path)
{
loadDataset(path);
}*/
void HPE_parseImp::load(const string &path)
{
loadDataset(path);
}
void HPE_parseImp::loadDataset(const string &path)
{
train.push_back(vector< Ptr<Object> >());
test.push_back(vector< Ptr<Object> >());
validation.push_back(vector< Ptr<Object> >());
unsigned int i=0;
vector<string> fileNames;
getDirList(path, fileNames);
for (vector<string>::iterator it=fileNames.begin(); it!=fileNames.end(); ++it)
{
string &file = *it, ext;
size_t len = file.length();
if (len>4)
{
ext = file.substr(len-4, 4);
}
if (ext==".jpg")
{
Ptr<HPE_parseObj> curr(new HPE_parseObj);
curr->name = file;
if (i<100)
{
train.back().push_back(curr);
} else
{
test.back().push_back(curr);
}
++i;
}
}
}
Ptr<HPE_parse> HPE_parse::create()
{
return Ptr<HPE_parseImp>(new HPE_parseImp);
}
}
}
+126
View File
@@ -0,0 +1,126 @@
/*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/ir_affine.hpp"
#include "opencv2/datasets/util.hpp"
namespace cv
{
namespace datasets
{
using namespace std;
class IR_affineImp CV_FINAL : public IR_affine
{
public:
IR_affineImp() {}
//IR_affineImp(const string &path);
virtual ~IR_affineImp() CV_OVERRIDE {}
virtual void load(const string &path) CV_OVERRIDE;
private:
void loadDataset(const string &path);
};
/*IR_affineImp::IR_affineImp(const string &path)
{
loadDataset(path);
}*/
void IR_affineImp::load(const string &path)
{
loadDataset(path);
}
void IR_affineImp::loadDataset(const string &path)
{
train.push_back(vector< Ptr<Object> >());
test.push_back(vector< Ptr<Object> >());
validation.push_back(vector< Ptr<Object> >());
// detect image extension
string ext;
vector<string> fileNames;
getDirList(path, fileNames);
for (vector<string>::iterator it=fileNames.begin(); it!=fileNames.end(); ++it)
{
string &name = *it;
if (name.length()>=8 && name.substr(0, 3)=="img")
{
ext = name.substr(name.length()-4, 4);
break;
}
}
for (unsigned int i=1; i<=6; ++i)
{
Ptr<IR_affineObj> curr(new IR_affineObj);
char tmp[2];
sprintf(tmp, "%u", i);
curr->imageName = path + "img" + tmp + ext;
if (i>1)
{
string matName(path + "H1to" + tmp + "p");
ifstream infile(matName.c_str());
for (int k=0; k<3; ++k)
{
for (int j=0; j<3; ++j)
{
infile >> curr->mat(k, j);
}
}
}
train.back().push_back(curr);
}
}
Ptr<IR_affine> IR_affine::create()
{
return Ptr<IR_affineImp>(new IR_affineImp);
}
}
}
+117
View File
@@ -0,0 +1,117 @@
/*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/ir_robot.hpp"
#include "opencv2/datasets/util.hpp"
namespace cv
{
namespace datasets
{
using namespace std;
class IR_robotImp CV_FINAL : public IR_robot
{
public:
IR_robotImp() {}
//IR_robotImp(const string &path);
virtual ~IR_robotImp() {}
virtual void load(const string &path) CV_OVERRIDE;
private:
void loadDataset(const string &path);
};
/*IR_robotImp::IR_robotImp(const string &path)
{
loadDataset(path);
}*/
void IR_robotImp::load(const string &path)
{
loadDataset(path);
}
void IR_robotImp::loadDataset(const string &path)
{
train.push_back(vector< Ptr<Object> >());
test.push_back(vector< Ptr<Object> >());
validation.push_back(vector< Ptr<Object> >());
vector<string> fileNames;
getDirList(path, fileNames);
for (vector<string>::iterator it=fileNames.begin(); it!=fileNames.end(); ++it)
{
Ptr<IR_robotObj> curr(new IR_robotObj);
curr->name = *it;
string pathScene(path + curr->name + "/");
vector<string> sceneNames;
getDirList(pathScene, sceneNames);
int currImageNum = 0;
for (vector<string>::iterator itScene=sceneNames.begin(); itScene!=sceneNames.end(); ++itScene)
{
string &fileName = *itScene;
int imageNum = atoi( fileName.substr(3, 3).c_str() );
//int pos = atoi( fileName.substr(6, 2).c_str() );
if (imageNum != currImageNum)
{
curr->pos.push_back(cameraPos());
currImageNum = imageNum;
}
curr->pos.back().images.push_back(fileName);
}
train.back().push_back(curr);
}
}
Ptr<IR_robot> IR_robot::create()
{
return Ptr<IR_robotImp>(new IR_robotImp);
}
}
}
+111
View File
@@ -0,0 +1,111 @@
/*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/is_bsds.hpp"
#include "opencv2/datasets/util.hpp"
namespace cv
{
namespace datasets
{
using namespace std;
class IS_bsdsImp CV_FINAL : public IS_bsds
{
public:
IS_bsdsImp() {}
//IS_bsdsImp(const string &path);
virtual ~IS_bsdsImp() {}
virtual void load(const string &path) CV_OVERRIDE;
private:
void loadDataset(const string &path);
void loadDatasetPart(const string &fileName, vector< Ptr<Object> > &dataset_);
};
void IS_bsdsImp::loadDatasetPart(const string &fileName, vector< Ptr<Object> > &dataset_)
{
ifstream infile(fileName.c_str());
string imageName;
while (infile >> imageName)
{
Ptr<IS_bsdsObj> curr(new IS_bsdsObj);
curr->name = imageName;
dataset_.push_back(curr);
}
}
/*IS_bsdsImp::IS_bsdsImp(const string &path)
{
loadDataset(path);
}*/
void IS_bsdsImp::load(const string &path)
{
loadDataset(path);
}
void IS_bsdsImp::loadDataset(const string &path)
{
train.push_back(vector< Ptr<Object> >());
test.push_back(vector< Ptr<Object> >());
validation.push_back(vector< Ptr<Object> >());
string trainName(path + "iids_train.txt");
string testName(path + "iids_test.txt");
// loading train
loadDatasetPart(trainName, train.back());
// loading test
loadDatasetPart(testName, test.back());
}
Ptr<IS_bsds> IS_bsds::create()
{
return Ptr<IS_bsdsImp>(new IS_bsdsImp);
}
}
}
+106
View File
@@ -0,0 +1,106 @@
/*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/is_weizmann.hpp"
#include "opencv2/datasets/util.hpp"
namespace cv
{
namespace datasets
{
using namespace std;
class IS_weizmannImp CV_FINAL : public IS_weizmann
{
public:
IS_weizmannImp() {}
//IS_weizmannImp(const string &path);
virtual ~IS_weizmannImp() {}
virtual void load(const string &path) CV_OVERRIDE;
private:
void loadDataset(const string &path);
};
/*IS_weizmannImp::IS_weizmannImp(const string &path)
{
loadDataset(path);
}*/
void IS_weizmannImp::load(const string &path)
{
loadDataset(path);
}
void IS_weizmannImp::loadDataset(const string &path)
{
train.push_back(vector< Ptr<Object> >());
test.push_back(vector< Ptr<Object> >());
validation.push_back(vector< Ptr<Object> >());
vector<string> fileNames;
getDirList(path, fileNames);
for (vector<string>::iterator it=fileNames.begin(); it!=fileNames.end(); ++it)
{
string &imageName = *it;
if (imageName.find('.') == string::npos) // only folders, discard .mat
{
Ptr<IS_weizmannObj> curr(new IS_weizmannObj);
curr->imageName = imageName;
curr->srcBw = imageName + "/src_bw/" + imageName + ".png";
curr->srcColor = imageName + "/src_color/" + imageName + ".png";
curr->humanSeg = imageName + "human_seg/";
train.back().push_back(curr);
}
}
}
Ptr<IS_weizmann> IS_weizmann::create()
{
return Ptr<IS_weizmannImp>(new IS_weizmannImp);
}
}
}
+156
View File
@@ -0,0 +1,156 @@
/*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/msm_epfl.hpp"
#include "opencv2/datasets/util.hpp"
namespace cv
{
namespace datasets
{
using namespace std;
class MSM_epflImp CV_FINAL : public MSM_epfl
{
public:
MSM_epflImp() {}
//MSM_epflImp(const string &path);
virtual ~MSM_epflImp() CV_OVERRIDE {}
virtual void load(const string &path) CV_OVERRIDE;
private:
void loadDataset(const string &path);
};
/*MSM_epflImp::MSM_epflImp(const string &path)
{
loadDataset(path);
}*/
void MSM_epflImp::load(const string &path)
{
loadDataset(path);
}
void MSM_epflImp::loadDataset(const string &path)
{
train.push_back(vector< Ptr<Object> >());
test.push_back(vector< Ptr<Object> >());
validation.push_back(vector< Ptr<Object> >());
string pathBounding(path + "bounding/");
string pathCamera(path + "camera/");
string pathP(path + "P/");
string pathPng(path + "png/");
vector<string> fileNames;
getDirList(pathPng, fileNames);
for (vector<string>::iterator it=fileNames.begin(); it!=fileNames.end(); ++it)
{
Ptr<MSM_epflObj> curr(new MSM_epflObj);
curr->imageName = *it;
// load boundary
string fileBounding(pathBounding + curr->imageName + ".bounding");
ifstream infile(fileBounding.c_str());
for (int k=0; k<2; ++k)
{
for (int j=0; j<3; ++j)
{
infile >> curr->bounding(k, j);
}
}
// load camera parameters
string fileCamera(pathCamera + curr->imageName + ".camera");
ifstream infileCamera(fileCamera.c_str());
for (int i=0; i<3; ++i)
{
for (int j=0; j<3; ++j)
{
infileCamera >> curr->camera.mat1(i, j);
}
}
for (int i=0; i<3; ++i)
{
infileCamera >> curr->camera.mat2[i];
}
for (int i=0; i<3; ++i)
{
for (int j=0; j<3; ++j)
{
infileCamera >> curr->camera.mat3(i, j);
}
}
for (int i=0; i<3; ++i)
{
infileCamera >> curr->camera.mat4[i];
}
infileCamera >> curr->camera.imageWidth >> curr->camera.imageHeight;
// load P
string fileP(pathP + curr->imageName + ".P");
ifstream infileP(fileP.c_str());
for (int k=0; k<3; ++k)
{
for (int j=0; j<4; ++j)
{
infileP >> curr->p(k, j);
}
}
train.back().push_back(curr);
}
}
Ptr<MSM_epfl> MSM_epfl::create()
{
return Ptr<MSM_epflImp>(new MSM_epflImp);
}
}
}
+125
View File
@@ -0,0 +1,125 @@
/*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/msm_middlebury.hpp"
#include "opencv2/datasets/util.hpp"
namespace cv
{
namespace datasets
{
using namespace std;
class MSM_middleburyImp CV_FINAL : public MSM_middlebury
{
public:
MSM_middleburyImp() {}
//MSM_middleburyImp(const string &path);
virtual ~MSM_middleburyImp() {}
virtual void load(const string &path) CV_OVERRIDE;
private:
void loadDataset(const string &path);
};
/*MSM_middleburyImp::MSM_middleburyImp(const string &path)
{
loadDataset(path);
}*/
void MSM_middleburyImp::load(const string &path)
{
loadDataset(path);
}
void MSM_middleburyImp::loadDataset(const string &path)
{
train.push_back(vector< Ptr<Object> >());
test.push_back(vector< Ptr<Object> >());
validation.push_back(vector< Ptr<Object> >());
string name(path.substr(0, path.length()-1));
size_t start = name.rfind('/');
name = name.substr(start+1, name.length()-start);
string angName(path + name + "_ang.txt");
string parName(path + name + "_par.txt");
ifstream infile(parName.c_str());
string imageName;
infile >> imageName; // skip header
while (infile >> imageName)
{
Ptr<MSM_middleburyObj> curr(new MSM_middleburyObj);
curr->imageName = imageName;
for (int i=0; i<3; ++i)
{
for (int j=0; j<3; ++j)
{
infile >> curr->k(i, j);
}
}
for (int i=0; i<3; ++i)
{
for (int j=0; j<3; ++j)
{
infile >> curr->r(i, j);
}
}
for (int i=0; i<3; ++i)
{
infile >> curr->t[i];
}
train.back().push_back(curr);
}
}
Ptr<MSM_middlebury> MSM_middlebury::create()
{
return Ptr<MSM_middleburyImp>(new MSM_middleburyImp);
}
}
}
+169
View File
@@ -0,0 +1,169 @@
/*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/or_imagenet.hpp"
#include "opencv2/datasets/util.hpp"
#include <map>
namespace cv
{
namespace datasets
{
using namespace std;
class OR_imagenetImp CV_FINAL : public OR_imagenet
{
public:
OR_imagenetImp() {}
//OR_imagenetImp(const string &path);
virtual ~OR_imagenetImp() CV_OVERRIDE {}
virtual void load(const string &path) CV_OVERRIDE;
private:
void loadDataset(const string &path);
void numberToString(int number, string &out);
};
/*OR_imagenetImp::OR_imagenetImp(const string &path)
{
loadDataset(path);
}*/
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> >());
map<string, int> labels;
ifstream infile((path + "labels.txt").c_str());
string line;
while (getline(infile, line))
{
vector<string> elems;
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->id = atoi(line.c_str());
numberToString((int)validation.back().size()+1, curr->image);
curr->image = "val/ILSVRC2010_val_" + curr->image + ".JPEG";
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
}
}
for (vector<int>::iterator it=testGT.begin(); it!=testGT.end(); ++it)
{
Ptr<OR_imagenetObj> curr(new OR_imagenetObj);
curr->id = *it;
numberToString((int)test.back().size()+1, curr->image);
curr->image = "test/ILSVRC2010_test_" + curr->image + ".JPEG";
test.back().push_back(curr);
}
}
Ptr<OR_imagenet> OR_imagenet::create()
{
return Ptr<OR_imagenetImp>(new OR_imagenetImp);
}
}
}
+145
View File
@@ -0,0 +1,145 @@
/*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/or_mnist.hpp"
#include "opencv2/datasets/util.hpp"
namespace cv
{
namespace datasets
{
using namespace std;
class OR_mnistImp CV_FINAL : public OR_mnist
{
public:
OR_mnistImp() {}
//OR_mnistImp(const string &path);
virtual ~OR_mnistImp() {}
virtual void load(const string &path) CV_OVERRIDE;
private:
void loadDataset(const string &path);
void loadDatasetPart(const string &imagesFile, const string &labelsFile, unsigned int num, vector< Ptr<Object> > &dataset_);
};
/*OR_mnistImp::OR_mnistImp(const string &path)
{
loadDataset(path);
}*/
void OR_mnistImp::load(const string &path)
{
loadDataset(path);
}
void OR_mnistImp::loadDatasetPart(const string &imagesFile, const string &labelsFile, unsigned int num, vector< Ptr<Object> > &dataset_)
{
FILE *f = fopen(imagesFile.c_str(), "rb");
fseek(f, 16, SEEK_CUR);
unsigned int imageSize = 28*28;
char *images = new char[num*imageSize];
size_t res = fread(images, 1, num*imageSize, f);
fclose(f);
if (num*imageSize != res)
{
delete[] images;
return;
}
f = fopen(labelsFile.c_str(), "rb");
fseek(f, 8, SEEK_CUR);
char *labels = new char[num];
res = fread(labels, 1, num, f);
fclose(f);
if (num != res)
{
delete[] images;
delete[] labels;
return;
}
for (unsigned int i=0; i<num; ++i)
{
Ptr<OR_mnistObj> curr(new OR_mnistObj);
curr->label = labels[i];
curr->image = Mat(28, 28, CV_8U);
unsigned int imageIdx = i*imageSize;
for (int j=0; j<curr->image.rows; ++j)
{
char *im = curr->image.ptr<char>(j);
for (int k=0; k<curr->image.cols; ++k)
{
im[k] = images[imageIdx + j*28 + k];
}
}
dataset_.push_back(curr);
}
delete[] images;
delete[] labels;
}
void OR_mnistImp::loadDataset(const string &path)
{
train.push_back(vector< Ptr<Object> >());
test.push_back(vector< Ptr<Object> >());
validation.push_back(vector< Ptr<Object> >());
string trainImagesFile(path + "train-images-idx3-ubyte");
string trainLabelsFile(path + "train-labels-idx1-ubyte");
loadDatasetPart(trainImagesFile, trainLabelsFile, 60000, train.back());
string testImagesFile(path + "t10k-images-idx3-ubyte");
string testLabelsFile(path + "t10k-labels-idx1-ubyte");
loadDatasetPart(testImagesFile, testLabelsFile, 10000, test.back());
}
Ptr<OR_mnist> OR_mnist::create()
{
return Ptr<OR_mnistImp>(new OR_mnistImp);
}
}
}
+223
View File
@@ -0,0 +1,223 @@
/*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) 2015, 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/or_pascal.hpp"
#include "opencv2/datasets/util.hpp"
#if defined(__GNUC__) && __GNUC__ >= 5
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsuggest-override"
#endif
#include "tinyxml2/tinyxml2.h"
#if defined(__GNUC__) && __GNUC__ >= 5
#pragma GCC diagnostic pop
#endif
#include <fstream>
namespace cv
{
namespace datasets
{
using namespace std;
using namespace cv::tinyxml2;
class OR_pascalImp CV_FINAL : public OR_pascal
{
public:
OR_pascalImp() {}
virtual void load(const string &path) CV_OVERRIDE;
private:
void loadDataset(const string &path, const string &nameImageSet, vector< Ptr<Object> > &imageSet);
Ptr<Object> parseAnnotation(const string &path, const string &id);
const char* parseNodeText(XMLElement* node, const string &nodeName, const string &defaultValue);
};
void OR_pascalImp::load(const string &path)
{
train.push_back(vector< Ptr<Object> >());
test.push_back(vector< Ptr<Object> >());
validation.push_back(vector< Ptr<Object> >());
loadDataset(path, "train", train.back());
loadDataset(path, "test", test.back());
loadDataset(path, "val", validation.back());
}
void OR_pascalImp::loadDataset(const string &path, const string &nameImageSet, vector< Ptr<Object> > &imageSet)
{
string pathImageSets(path + "ImageSets/Main/");
string imageList = pathImageSets + nameImageSet + ".txt";
ifstream in(imageList.c_str());
string error_message = format("Image list not exists!\n%s", imageList.c_str());
if (!in.is_open())
CV_Error(Error::StsBadArg, error_message);
string id = "";
while( getline(in, id) )
{
if( strcmp(nameImageSet.c_str(), "test") == 0 ) // test set ground truth is not available
{
Ptr<OR_pascalObj> annotation(new OR_pascalObj);
annotation->filename = path + "JPEGImages/" + id + ".jpg";
imageSet.push_back(annotation);
}
else
{
imageSet.push_back(parseAnnotation(path, id));
}
}
}
const char* OR_pascalImp::parseNodeText(XMLElement* node, const string &nodeName, const string &defaultValue)
{
XMLElement* child = node->FirstChildElement(nodeName.c_str());
if ( child == 0 )
return defaultValue.c_str();
const char* e = child->GetText();
if( e == 0 )
return defaultValue.c_str();
return e ;
}
Ptr<Object> OR_pascalImp::parseAnnotation(const string &path, const string &id)
{
string pathAnnotations(path + "Annotations/");
string pathImages(path + "JPEGImages/");
Ptr<OR_pascalObj> annotation(new OR_pascalObj);
XMLDocument doc;
string xml_file = pathAnnotations + id + ".xml";
XMLError error_code = doc.LoadFile(xml_file.c_str());
string error_message = format("Parsing XML failed. Error code = %d. \nFile = %s", error_code, xml_file.c_str());
switch (error_code)
{
case XML_SUCCESS:
break;
case XML_ERROR_FILE_NOT_FOUND:
error_message = "XML file not found! " + error_message;
CV_Error(Error::StsParseError, error_message);
default:
CV_Error(Error::StsParseError, error_message);
break;
}
// <annotation/>
XMLElement *xml_ann = doc.RootElement();
// <filename/>
string img_name = xml_ann->FirstChildElement("filename")->GetText();
annotation->filename = pathImages + img_name;
// <size/>
XMLElement *sz = xml_ann->FirstChildElement("size");
int width = atoi(sz->FirstChildElement("width")->GetText());
int height = atoi(sz->FirstChildElement("height")->GetText());
int depth = atoi(sz->FirstChildElement("depth")->GetText());
annotation->width = width;
annotation->height = height;
annotation->depth = depth;
// <object/>
vector<PascalObj> objects;
XMLElement *xml_obj = xml_ann->FirstChildElement("object");
while (xml_obj)
{
PascalObj pascal_obj;
pascal_obj.name = xml_obj->FirstChildElement("name")->GetText();
pascal_obj.pose = parseNodeText(xml_obj, "pose", "Unspecified");
pascal_obj.truncated = atoi(parseNodeText(xml_obj, "truncated", "0")) > 0;
pascal_obj.difficult = atoi(parseNodeText(xml_obj, "difficult", "0")) > 0;
pascal_obj.occluded = atoi(parseNodeText(xml_obj, "occluded", "0")) > 0;
// <bndbox/>
XMLElement *xml_bndbox = xml_obj->FirstChildElement("bndbox");
pascal_obj.xmin = atoi(xml_bndbox->FirstChildElement("xmin")->GetText());
pascal_obj.ymin = atoi(xml_bndbox->FirstChildElement("ymin")->GetText());
pascal_obj.xmax = atoi(xml_bndbox->FirstChildElement("xmax")->GetText());
pascal_obj.ymax = atoi(xml_bndbox->FirstChildElement("ymax")->GetText());
// <part/>
vector<PascalPart> parts;
XMLElement *xml_part = xml_obj->FirstChildElement("part");
while (xml_part)
{
PascalPart pascal_part;
pascal_part.name = xml_part->FirstChildElement("name")->GetText();
xml_bndbox = xml_part->FirstChildElement("bndbox");
pascal_part.xmin = atoi(xml_bndbox->FirstChildElement("xmin")->GetText());
pascal_part.ymin = atoi(xml_bndbox->FirstChildElement("ymin")->GetText());
pascal_part.xmax = atoi(xml_bndbox->FirstChildElement("xmax")->GetText());
pascal_part.ymax = atoi(xml_bndbox->FirstChildElement("ymax")->GetText());
parts.push_back(pascal_part);
xml_part = xml_part->NextSiblingElement("part");
}
pascal_obj.parts = parts;
objects.push_back(pascal_obj);
xml_obj = xml_obj->NextSiblingElement("object");
}
annotation->objects = objects;
return annotation;
}
Ptr<OR_pascal> OR_pascal::create()
{
return Ptr<OR_pascalImp>(new OR_pascalImp);
}
}
}
+163
View File
@@ -0,0 +1,163 @@
/*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/or_sun.hpp"
#include "opencv2/datasets/util.hpp"
#include <map>
namespace cv
{
namespace datasets
{
using namespace std;
class OR_sunImp CV_FINAL : public OR_sun
{
public:
OR_sunImp() {}
//OR_sunImp(const string &path);
virtual ~OR_sunImp() CV_OVERRIDE {}
virtual void load(const string &path) CV_OVERRIDE;
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)
{
loadDataset(path);
}*/
void OR_sunImp::load(const string &path)
{
loadDataset(path);
}
void OR_sunImp::loadDatasetPart(const string &path, vector< Ptr<Object> > &dataset_)
{
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 = (int)pathLabel.size();
pathLabel.insert(make_pair(labelStr, curr->label));
paths.push_back(labelStr);
}
curr->name = curr->name.substr(pos+1);
}
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))
{
Ptr<OR_sunObj> curr(new OR_sunObj);
curr->name = line;
string currPath(path + curr->name);
vector<string> fileNames;
getDirList(currPath, fileNames);
for (vector<string>::iterator it=fileNames.begin(); it!=fileNames.end(); ++it)
{
curr->imageNames.push_back(*it);
}
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());
}
}
Ptr<OR_sun> OR_sun::create()
{
return Ptr<OR_sunImp>(new OR_sunImp);
}
}
}
+187
View File
@@ -0,0 +1,187 @@
/*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/pd_caltech.hpp"
#include "opencv2/datasets/util.hpp"
namespace cv
{
namespace datasets
{
using namespace std;
class PD_caltechImp CV_FINAL : public PD_caltech
{
public:
PD_caltechImp() {}
//PD_caltechImp(const string &path);
virtual ~PD_caltechImp() CV_OVERRIDE {}
virtual void load(const string &path) CV_OVERRIDE;
private:
void loadDataset(const string &path);
};
/*PD_caltechImp::PD_caltechImp(const string &path)
{
loadDataset(path);
}*/
void PD_caltechImp::load(const string &path)
{
loadDataset(path);
}
void PD_caltechImp::loadDataset(const string &path)
{
train.push_back(vector< Ptr<Object> >());
test.push_back(vector< Ptr<Object> >());
validation.push_back(vector< Ptr<Object> >());
createDirectory((path + "../images/"));
vector<string> objectNames;
getDirList(path, objectNames);
for (vector<string>::iterator it=objectNames.begin(); it!=objectNames.end(); ++it)
{
Ptr<PD_caltechObj> curr(new PD_caltechObj);
curr->name = *it;
string objectPath(path + "../images/" + curr->name + "/");
createDirectory(objectPath);
string seqImagesPath(path + curr->name + "/");
vector<string> seqNames;
getDirList(seqImagesPath, seqNames);
for (vector<string>::iterator itSeq=seqNames.begin(); itSeq!=seqNames.end(); ++itSeq)
{
string &seqName = *itSeq;
createDirectory((objectPath + seqName));
FILE *f = fopen((seqImagesPath + seqName).c_str(), "rb");
#define SKIP 28+8+512
fseek(f, SKIP, SEEK_CUR);
unsigned int header[9];
size_t res = fread(header, 9, 4, f);
double fps;
res = fread(&fps, 1, 8, f);
fseek(f, 432, SEEK_CUR);
/*printf("width %u\n", header[0]);
printf("height %u\n", header[1]);
printf("imageBitDepth %u\n", header[2]);
printf("imageBitDepthReal %u\n", header[3]);
printf("imageSizeBytes %u\n", header[4]);
printf("imageFormat %u\n", header[5]);
printf("numFrames %u\n", numFrames);
printf("fps %f\n", fps);
printf("trueImageSize %u\n", header[8]);*/
unsigned int numFrames = header[6];
string ext;
switch (header[5])
{
case 100:
case 200:
ext = "raw";
break;
case 101:
ext = "brgb8";
break;
case 102:
case 201:
ext = "jpg";
break;
case 103:
ext = "jbrgb";
break;
case 001:
case 002:
ext = "png";
break;
}
for (unsigned int i=0; i<numFrames; ++i)
{
unsigned int size;
res = fread(&size, 1, 4, f);
char imgName[20];
sprintf(imgName, "/%u.%s", i, ext.c_str());
curr->imageNames.push_back(imgName);
// comment fseek and uncomment next block to unpack all frames
fseek(f, size, SEEK_CUR);
/*char *img = new char[size];
fread(img, size, 1, f);
string imgPath(objectPath + seqName + imgName);
FILE *fImg = fopen(imgPath.c_str(), "wb");
fwrite(img, size, 1, fImg);
fclose(fImg);
delete[] img;*/
fseek(f, 12, SEEK_CUR);
}
if (0 != res) // should fix unused variable warning
{
res = 0;
}
fclose(f);
}
train.back().push_back(curr);
}
}
Ptr<PD_caltech> PD_caltech::create()
{
return Ptr<PD_caltechImp>(new PD_caltechImp);
}
}
}
+203
View File
@@ -0,0 +1,203 @@
/*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) 2015, 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/pd_inria.hpp"
#include "opencv2/datasets/util.hpp"
namespace cv
{
namespace datasets
{
using namespace std;
class PD_inriaImp CV_FINAL : public PD_inria
{
public:
PD_inriaImp() {}
virtual ~PD_inriaImp() CV_OVERRIDE {}
virtual void load(const string &path) CV_OVERRIDE;
private:
void loadDataset(const string &path, const string nameImageSet, vector< Ptr<Object> > &imageSet);
void readTextLines(const string filename, vector< string > &lines);
void parseAnnotation(const string filename, Ptr< PD_inriaObj > &object);
};
void PD_inriaImp::load(const string &path)
{
// Training set
train.push_back(vector< Ptr<Object> >());
loadDataset(path, "Train", train.back());
// Testing set
test.push_back(vector< Ptr<Object> >());
loadDataset(path, "Test", test.back());
// There is no validation set
validation.push_back(vector< Ptr<Object> >());
}
void PD_inriaImp::readTextLines(const string filename, vector< string > &lines)
{
ifstream in(filename.c_str());
string error_message = "";
if (!in.is_open())
{
error_message = format("Unable to open file: \n%s\n", filename.c_str());
CV_Error(Error::StsBadArg, error_message);
}
string currline = "";
while (getline(in, currline))
lines.push_back(currline);
}
void PD_inriaImp::parseAnnotation(const string filename, Ptr< PD_inriaObj > &object)
{
string error_message = "";
ifstream in(filename.c_str());
if (!in.is_open())
{
error_message = format("Unable to open file: \n%s\n", filename.c_str());
CV_Error(Error::StsBadArg, error_message);
}
string imageSizeHeader = "Image size (X x Y x C) : ";
string imageSizeFmt = imageSizeHeader + "%d x %d x %d";
string objWithGTHeader = "Objects with ground truth : ";
string objWithGTFmt = objWithGTHeader + "%d { \"PASperson\" }";
string boundBoxHeader = "Bounding box for object ";
string boundBoxFmt = boundBoxHeader + "%*d \"PASperson\" (Xmin, Ymin) - (Xmax, Ymax) : (%d, %d) - (%d, %d)";
string line = "";
int width = 0;
int height = 0;
int depth = 0;
int xmin, ymin, xmax, ymax;
int numObjects = 0;
while (getline(in, line))
{
if (line[0] == '#' || !line[0])
continue;
if (strstr(line.c_str(), imageSizeHeader.c_str()))
{
sscanf(line.c_str(), imageSizeFmt.c_str(), &width, &height, &depth);
object->width = width;
object->height = height;
object->depth = depth;
}
else if (strstr(line.c_str(), objWithGTHeader.c_str()))
{
sscanf(line.c_str(), objWithGTFmt.c_str(), &numObjects);
if (numObjects <= 0)
break;
}
else if (strstr(line.c_str(), boundBoxHeader.c_str()))
{
sscanf(line.c_str(), boundBoxFmt.c_str(), &xmin, &ymin, &xmax, &ymax);
Rect bndbox;
bndbox.x = xmin;
bndbox.y = ymin;
bndbox.width = xmax - xmin;
bndbox.height = ymax - ymin;
(object->bndboxes).push_back(bndbox);
}
}
CV_Assert((object->bndboxes).size() == (unsigned int)numObjects);
}
void PD_inriaImp::loadDataset(const string &path, const string nameImageSet, vector< Ptr<Object> > &imageSet)
{
string listAnn = path + nameImageSet + "/annotations.lst";
string listPos = path + nameImageSet + "/pos.lst";
string listNeg = path + nameImageSet + "/neg.lst";
vector< string > fsAnn;
vector< string > fsPos;
vector< string > fsNeg;
// read file names
readTextLines(listAnn, fsAnn);
readTextLines(listPos, fsPos);
readTextLines(listNeg, fsNeg);
CV_Assert(fsAnn.size() == fsPos.size());
for (unsigned int i = 0; i < fsPos.size(); i++)
{
Ptr<PD_inriaObj> curr(new PD_inriaObj);
parseAnnotation(path + fsAnn[i], curr);
curr->filename = path + fsPos[i];
curr->sType = POS;
imageSet.push_back(curr);
}
for (unsigned int i = 0; i < fsNeg.size(); i++)
{
Ptr<PD_inriaObj> curr(new PD_inriaObj);
curr->filename = path + fsNeg[i];
curr->sType = NEG;
imageSet.push_back(curr);
}
}
Ptr<PD_inria> PD_inria::create()
{
return Ptr<PD_inriaImp>(new PD_inriaImp);
}
}
}
+167
View File
@@ -0,0 +1,167 @@
/*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/slam_kitti.hpp"
#include "opencv2/datasets/util.hpp"
namespace cv
{
namespace datasets
{
using namespace std;
class SLAM_kittiImp CV_FINAL : public SLAM_kitti
{
public:
SLAM_kittiImp() {}
//SLAM_kittiImp(const string &path);
virtual ~SLAM_kittiImp() CV_OVERRIDE {}
virtual void load(const string &path) CV_OVERRIDE;
private:
void loadDataset(const string &path);
};
/*SLAM_kittiImp::SLAM_kittiImp(const string &path)
{
loadDataset(path);
}*/
void SLAM_kittiImp::load(const string &path)
{
loadDataset(path);
}
void SLAM_kittiImp::loadDataset(const string &path)
{
train.push_back(vector< Ptr<Object> >());
test.push_back(vector< Ptr<Object> >());
validation.push_back(vector< Ptr<Object> >());
string pathSequence(path + "sequences/");
vector<string> fileNames;
getDirList(pathSequence, fileNames);
for (vector<string>::iterator it=fileNames.begin(); it!=fileNames.end(); ++it)
{
Ptr<SLAM_kittiObj> curr(new SLAM_kittiObj);
curr->name = *it;
string currPath(pathSequence + curr->name);
// loading velodyne
string pathVelodyne(currPath + "/velodyne/");
vector<string> velodyneNames;
getDirList(pathVelodyne, velodyneNames);
for (vector<string>::iterator itV=velodyneNames.begin(); itV!=velodyneNames.end(); ++itV)
{
curr->velodyne.push_back(*itV);
}
// loading gray & color images
for (unsigned int i=0; i<=3; ++i)
{
char tmp[2];
sprintf(tmp, "%u", i);
string pathImage(currPath + "/image_" + tmp + "/");
vector<string> imageNames;
getDirList(pathImage, imageNames);
for (vector<string>::iterator itImage=imageNames.begin(); itImage!=imageNames.end(); ++itImage)
{
curr->images[i].push_back(*itImage);
}
}
// loading times
ifstream infile((currPath + "/times.txt").c_str());
string line;
while (getline(infile, line))
{
curr->times.push_back(atof(line.c_str()));
}
// loading calibration
ifstream infile2((currPath + "/calib.txt").c_str());
for (unsigned int i=0; i<4; ++i)
{
getline(infile2, line);
vector<string> elems;
split(line, elems, ' ');
vector<string>::iterator itE=elems.begin();
for (++itE; itE!=elems.end(); ++itE)
{
curr->p[i].push_back(atof((*itE).c_str()));
}
}
// loading poses
ifstream infile3((path + "poses/" + curr->name + ".txt").c_str());
while (getline(infile3, line))
{
pose p;
unsigned int i=0;
vector<string> elems;
split(line, elems, ' ');
for (vector<string>::iterator itE=elems.begin(); itE!=elems.end(); ++itE, ++i)
{
if (i>11)
{
break;
}
p.elem[i] = atof((*itE).c_str());
}
curr->posesArray.push_back(p);
}
train.back().push_back(curr);
}
}
Ptr<SLAM_kitti> SLAM_kitti::create()
{
return Ptr<SLAM_kittiImp>(new SLAM_kittiImp);
}
}
}
+150
View File
@@ -0,0 +1,150 @@
/*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/slam_tumindoor.hpp"
#include "opencv2/datasets/util.hpp"
#include <cstring>
namespace cv
{
namespace datasets
{
using namespace std;
class SLAM_tumindoorImp CV_FINAL : public SLAM_tumindoor
{
public:
SLAM_tumindoorImp() {}
//SLAM_tumindoorImp(const string &path);
virtual ~SLAM_tumindoorImp() CV_OVERRIDE {}
virtual void load(const string &path) CV_OVERRIDE;
private:
void loadDataset(const string &path);
};
/*SLAM_tumindoorImp::SLAM_tumindoorImp(const string &path)
{
loadDataset(path);
}*/
void SLAM_tumindoorImp::load(const string &path)
{
loadDataset(path);
}
void SLAM_tumindoorImp::loadDataset(const string &path)
{
train.push_back(vector< Ptr<Object> >());
test.push_back(vector< Ptr<Object> >());
validation.push_back(vector< Ptr<Object> >());
string infoPath(path + "info/");
// get info map name, .csv should be only one such file in folder
string csvName;
vector<string> infoNames;
getDirList(infoPath, infoNames);
for (vector<string>::iterator it=infoNames.begin(); it!=infoNames.end(); ++it)
{
string &name = *it;
if (name.length()>3 && name.substr( name.length()-4, 4 )==".csv")
{
if (csvName.length()==0)
{
csvName = name;
} else
{
printf("more than one .csv file in info folder\n");
return;
}
}
}
if (csvName.length()==0)
{
printf("didn't find .csv file in info folder\n");
return;
}
ifstream infile((infoPath + csvName).c_str());
string line;
while (getline(infile, line))
{
vector<string> elems;
split(line, elems, ';');
Ptr<SLAM_tumindoorObj> curr(new SLAM_tumindoorObj);
curr->name = elems[0];
if (curr->name.substr(0, strlen("dslr_left")) == "dslr_left")
{
curr->type = LEFT;
} else
if (curr->name.substr(0, strlen("dslr_right")) == "dslr_right")
{
curr->type = RIGHT;
} else
{
curr->type = LADYBUG;
}
for (unsigned int i=0; i<4; ++i)
{
for (unsigned int j=0; j<4; ++j)
{
curr->transformMat(i, j) = atof(elems[1 + j + i*4].c_str());
}
}
train.back().push_back(curr);
}
}
Ptr<SLAM_tumindoor> SLAM_tumindoor::create()
{
return Ptr<SLAM_tumindoorImp>(new SLAM_tumindoorImp);
}
}
}
+74
View File
@@ -0,0 +1,74 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "opencv2/datasets/sr_bsds.hpp"
#include "opencv2/datasets/util.hpp"
namespace cv
{
namespace datasets
{
using namespace std;
class SR_bsdsImp CV_FINAL : public SR_bsds
{
public:
SR_bsdsImp() {}
//SR_bsdsImp(const string &path);
virtual ~SR_bsdsImp() {}
virtual void load(const string &path) CV_OVERRIDE;
private:
void loadDataset(const string &path);
void loadDatasetPart(const string &fileName, vector< Ptr<Object> > &dataset_);
};
void SR_bsdsImp::loadDatasetPart(const string &fileName, vector< Ptr<Object> > &dataset_)
{
ifstream infile(fileName.c_str());
string imageName;
while (infile >> imageName)
{
Ptr<SR_bsdsObj> curr(new SR_bsdsObj);
curr->imageName = imageName;
dataset_.push_back(curr);
}
}
/*SR_bsdsImp::SR_bsdsImp(const string &path)
{
loadDataset(path);
}*/
void SR_bsdsImp::load(const string &path)
{
loadDataset(path);
}
void SR_bsdsImp::loadDataset(const string &path)
{
train.push_back(vector< Ptr<Object> >());
test.push_back(vector< Ptr<Object> >());
validation.push_back(vector< Ptr<Object> >());
string trainName(path + "iids_train.txt");
string testName(path + "iids_test.txt");
// loading train
loadDatasetPart(trainName, train.back());
// loading test
loadDatasetPart(testName, test.back());
}
Ptr<SR_bsds> SR_bsds::create()
{
return Ptr<SR_bsdsImp>(new SR_bsdsImp);
}
}
}
+62
View File
@@ -0,0 +1,62 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "opencv2/datasets/sr_div2k.hpp"
#include "opencv2/datasets/util.hpp"
namespace cv
{
namespace datasets
{
using namespace std;
class SR_div2kImp CV_FINAL : public SR_div2k
{
public:
SR_div2kImp() {}
//SR_div2kImp(const string &path);
virtual ~SR_div2kImp() {}
virtual void load(const string &path) CV_OVERRIDE;
private:
void loadDataset(const string &path);
};
/*SR_div2kImp::SR_div2kImp(const string &path)
{
loadDataset(path);
}*/
void SR_div2kImp::load(const string &path)
{
loadDataset(path);
}
void SR_div2kImp::loadDataset(const string &path)
{
train.push_back(vector< Ptr<Object> >());
test.push_back(vector< Ptr<Object> >());
validation.push_back(vector< Ptr<Object> >());
vector<string> fileNames;
getDirList(path, fileNames);
for (vector<string>::iterator it=fileNames.begin(); it!=fileNames.end(); ++it)
{
string &imageName = *it;
Ptr<SR_div2kObj> curr(new SR_div2kObj);
curr->imageName = imageName;
train.back().push_back(curr);
}
}
Ptr<SR_div2k> SR_div2k::create()
{
return Ptr<SR_div2kImp>(new SR_div2kImp);
}
}
}
+62
View File
@@ -0,0 +1,62 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "opencv2/datasets/sr_general100.hpp"
#include "opencv2/datasets/util.hpp"
namespace cv
{
namespace datasets
{
using namespace std;
class SR_general100Imp CV_FINAL : public SR_general100
{
public:
SR_general100Imp() {}
//SR_general100Imp(const string &path);
virtual ~SR_general100Imp() {}
virtual void load(const string &path) CV_OVERRIDE;
private:
void loadDataset(const string &path);
};
/*SR_general100Imp::SR_general100Imp(const string &path)
{
loadDataset(path);
}*/
void SR_general100Imp::load(const string &path)
{
loadDataset(path);
}
void SR_general100Imp::loadDataset(const string &path)
{
train.push_back(vector< Ptr<Object> >());
test.push_back(vector< Ptr<Object> >());
validation.push_back(vector< Ptr<Object> >());
vector<string> fileNames;
getDirList(path, fileNames);
for (vector<string>::iterator it=fileNames.begin(); it!=fileNames.end(); ++it)
{
string &imageName = *it;
Ptr<SR_general100Obj> curr(new SR_general100Obj);
curr->imageName = imageName;
train.back().push_back(curr);
}
}
Ptr<SR_general100> SR_general100::create()
{
return Ptr<SR_general100Imp>(new SR_general100Imp);
}
}
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+223
View File
@@ -0,0 +1,223 @@
/*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/tr_chars.hpp"
#include "opencv2/datasets/util.hpp"
namespace cv
{
namespace datasets
{
using namespace std;
class TR_charsImp CV_FINAL : public TR_chars
{
public:
TR_charsImp() {}
//TR_charsImp(const string &path, int number = 0);
virtual ~TR_charsImp() CV_OVERRIDE {}
virtual void load(const string &path) CV_OVERRIDE;
private:
void loadDatasetSplit(const string &path, int number);
void loadDataset(const string &path);
void parseLine(const string &line, vector<int> &currSet, int number);
inline void convert(vector<int> &from, vector< Ptr<Object> > &to, vector<int> &allLabels, vector<string> &allNames);
inline void parseSet(const string &line, const string &pattern, bool &flag, vector<int> &set, int number);
};
void TR_charsImp::parseLine(const string &line, vector<int> &currSet, int number)
{
vector<string> elems;
split(line, elems, ' ');
if (number >= (int)elems.size())
{
return;
}
unsigned int ind = atoi(elems[number].c_str());
if (ind > 0)
{
currSet.push_back(ind-1);
}
}
inline void TR_charsImp::convert(vector<int> &from, vector< Ptr<Object> > &to, vector<int> &allLabels, vector<string> &allNames)
{
for (vector<int>::iterator it=from.begin(); it!=from.end(); ++it)
{
if (*it>=(int)allNames.size() || *it>=(int)allLabels.size())
{
printf("incorrect index: %u\n", *it);
continue;
}
Ptr<TR_charsObj> curr(new TR_charsObj);
curr->imgName = allNames[*it];
curr->label = allLabels[*it];
to.push_back(curr);
}
}
inline void TR_charsImp::parseSet(const string &line, const string &pattern, bool &flag, vector<int> &set, int number)
{
size_t pos = line.find(pattern);
if (string::npos != pos)
{
flag = true;
string s(line.substr(pos + pattern.length()));
parseLine(s, set, number);
} else
if (flag)
{
parseLine(line, set, number);
}
}
/*TR_charsImp::TR_charsImp(const string &path, int number)
{
loadDataset(path, number);
}*/
void TR_charsImp::load(const string &path)
{
loadDataset(path);
}
void TR_charsImp::loadDataset(const string &path)
{
int number = 0;
do
{
loadDatasetSplit(path, number);
number++;
} while (train.back().size()>0);
train.pop_back(); // remove last empty split
test.pop_back(); // remove last empty split
validation.pop_back(); // remove last empty split
}
void TR_charsImp::loadDatasetSplit(const string &path, int number)
{
train.push_back(vector< Ptr<Object> >());
test.push_back(vector< Ptr<Object> >());
validation.push_back(vector< Ptr<Object> >());
vector<int> allLabels, trainSet, testSet, validationSet;
vector<string> allNames;
ifstream infile((path + "list_English_Img.m").c_str());
string line;
bool labels = false, names = false, isTrain = false, isTest = false, isValidation = false;
while (getline(infile, line))
{
size_t pos = line.find("];");
if (string::npos != pos)
{
labels = false;
names = false;
isTrain = false;
isTest = false;
isValidation = false;
}
string slabels("list.ALLlabels = [");
pos = line.find(slabels);
if (string::npos != pos)
{
labels = true;
string s(line.substr(pos+slabels.length()));
allLabels.push_back(atoi(s.c_str()));
} else
if (labels)
{
allLabels.push_back(atoi(line.c_str()));
}
string snames("list.ALLnames = [");
pos = line.find(snames);
if (string::npos != pos)
{
names = true;
size_t start = pos+snames.length();
string s(line.substr(start+1, line.length()-start-2));
allNames.push_back(s);
} else
if (names)
{
string s(line.substr(1, line.length()-2));
allNames.push_back(s);
}
string trainStr("list.TRNind = [");
parseSet(line, trainStr, isTrain, trainSet, number);
string testStr("list.TSTind = [");
parseSet(line, testStr, isTest, testSet, number);
string validationStr("list.VALind = [");
parseSet(line, validationStr, isValidation, validationSet, number);
/*"list.classlabels = ["
"list.classnames = ["
"list.NUMclasses = 62;"
"list.TXNind = ["*/
}
convert(trainSet, train.back(), allLabels, allNames);
convert(testSet, test.back(), allLabels, allNames);
convert(validationSet, validation.back(), allLabels, allNames);
}
Ptr<TR_chars> TR_chars::create()
{
return Ptr<TR_charsImp>(new TR_charsImp);
}
}
}
+176
View File
@@ -0,0 +1,176 @@
/*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/tr_icdar.hpp"
#include "opencv2/datasets/util.hpp"
#include <sstream>
#include <fstream>
namespace cv
{
namespace datasets
{
using namespace std;
class TR_icdarImp CV_FINAL : public TR_icdar
{
public:
TR_icdarImp() {}
//TR_icdarImp(const string &path);
virtual ~TR_icdarImp() CV_OVERRIDE {}
virtual void load(const string &path) CV_OVERRIDE;
private:
void loadDataset(const string &path);
void objParseFiles(const string &path, int img_id, vector<Ptr <Object> > &out);
};
void TR_icdarImp::objParseFiles(const string &path, int img_id, vector<Ptr <Object> > &out)
{
Ptr<TR_icdarObj> curr(new TR_icdarObj);
stringstream fileName;
fileName << "img_" << img_id << ".jpg";
curr->fileName = fileName.str();
stringstream gtFileName;
gtFileName << path << "/gt_img_" << img_id << ".txt";
ifstream infile(gtFileName.str().c_str());
if (!infile.is_open()) CV_Error(Error::StsBadArg, gtFileName.str().c_str());
string line;
while (getline(infile, line))
{
//Ignore EOL characters
line.erase(remove(line.begin(), line.end(), '\n'), line.end());
line.erase(remove(line.begin(), line.end(), '\r'), line.end());
//Ignore byte-order marks (BOM first utf character in W$ files)
if ( (line[0] == (char)0xEFu) && (line[1] == (char)0xBBu) && (line[2] == (char)0xBFu) )
line.erase (line.begin(),line.begin()+3);
vector<string> fields;
split(line, fields, ',');
word w;
w.value = fields[8];
w.x = atoi(fields[0].c_str());
w.y = atoi(fields[1].c_str());
w.width = atoi(fields[2].c_str()) - atoi(fields[0].c_str());
w.height = atoi(fields[7].c_str()) - atoi(fields[1].c_str());
curr->words.push_back(w);
}
infile.close();
stringstream lex100FileName;
lex100FileName << path << "/voc_img_" << img_id << ".txt";
infile.open(lex100FileName.str().c_str());
if (!infile.is_open()) CV_Error(Error::StsBadArg, lex100FileName.str().c_str());
while (getline(infile, line))
{
//Ignore EOL characters
line.erase(remove(line.begin(), line.end(), '\n'), line.end());
line.erase(remove(line.begin(), line.end(), '\r'), line.end());
//Ignore byte-order marks (BOM first utf character in W$ files)
if ( (line[0] == (char)0xEFu) && (line[1] == (char)0xBBu) && (line[2] == (char)0xBFu) )
line.erase (line.begin(),line.begin()+3);
curr->lex100.push_back(line);
}
infile.close();
stringstream lexFullFileName;
if (path.substr(path.size()-5,4) == string("test"))
lexFullFileName << path << "ch2_test_vocabulary.txt";
else
lexFullFileName << path << "ch2_training_vocabulary.txt";
infile.open(lexFullFileName.str().c_str());
if (!infile.is_open()) CV_Error(Error::StsBadArg, lexFullFileName.str().c_str());
while (getline(infile, line))
{
//Ignore EOL characters
line.erase(remove(line.begin(), line.end(), '\n'), line.end());
line.erase(remove(line.begin(), line.end(), '\r'), line.end());
//Ignore byte-order marks (BOM first utf character in W$ files)
if ( (line[0] == (char)0xEFu) && (line[1] == (char)0xBBu) && (line[2] == (char)0xBFu) )
line.erase (line.begin(),line.begin()+3);
curr->lexFull.push_back(line);
}
infile.close();
out.push_back(curr);
}
/*TR_icdarImp::TR_icdarImp(const string &path)
{
loadDataset(path);
}*/
void TR_icdarImp::load(const string &path)
{
loadDataset(path);
}
void TR_icdarImp::loadDataset(const string &path)
{
train.push_back(vector< Ptr<Object> >());
test.push_back(vector< Ptr<Object> >());
validation.push_back(vector< Ptr<Object> >());
string train_path(path + "/train/");
string test_path (path + "/test/");
// loading 229 train images descriptions
for (int i=1; i<230; i++)
objParseFiles(train_path, i, train.back());
// loading 233 test images descriptions
for (int i=1; i<234; i++)
objParseFiles(test_path, i, test.back());
}
Ptr<TR_icdar> TR_icdar::create()
{
return Ptr<TR_icdarImp>(new TR_icdarImp);
}
}
}
+154
View File
@@ -0,0 +1,154 @@
/*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/tr_svt.hpp"
#include "opencv2/datasets/util.hpp"
#if defined(__GNUC__) && __GNUC__ >= 5
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsuggest-override"
#endif
#include "tinyxml2/tinyxml2.h"
#if defined(__GNUC__) && __GNUC__ >= 5
#pragma GCC diagnostic pop
#endif
namespace cv
{
namespace datasets
{
using namespace std;
using namespace cv::tinyxml2;
class TR_svtImp CV_FINAL : public TR_svt
{
public:
TR_svtImp() {}
//TR_svtImp(const string &path);
virtual ~TR_svtImp() CV_OVERRIDE {}
virtual void load(const string &path) CV_OVERRIDE;
private:
void loadDataset(const string &path);
void xmlParse(const string &set, vector< Ptr<Object> > &out);
};
void TR_svtImp::xmlParse(const string &set, vector< Ptr<Object> > &out)
{
XMLDocument doc;
doc.LoadFile(set.c_str());
XMLElement *root_ = doc.RootElement();
string rootElem(root_->Name());
if (rootElem == "tagset")
{
string strImage("image");
XMLElement *child = root_->FirstChildElement(strImage.c_str());
while (child)
{
string imageName = child->FirstChildElement("imageName")->GetText();
string lex = child->FirstChildElement("lex")->GetText();
Ptr<TR_svtObj> curr(new TR_svtObj);
curr->fileName = imageName;
split(lex, curr->lex, ',');
XMLElement *childTaggeds = child->FirstChildElement("taggedRectangles");
if (childTaggeds)
{
string strTagged("taggedRectangle");
XMLElement *childTagged = childTaggeds->FirstChildElement(strTagged.c_str());
while (childTagged)
{
tag t;
t.value = childTagged->FirstChildElement("tag")->GetText();
t.height = atoi(childTagged->Attribute("height"));
t.width = atoi(childTagged->Attribute("width"));
t.x = atoi(childTagged->Attribute("x"));
t.y = atoi(childTagged->Attribute("y"));
curr->tags.push_back(t);
childTagged = childTagged->NextSiblingElement(strTagged.c_str());
}
}
out.push_back(curr);
child = child->NextSiblingElement(strImage.c_str());
}
}
}
/*TR_svtImp::TR_svtImp(const string &path)
{
loadDataset(path);
}*/
void TR_svtImp::load(const string &path)
{
loadDataset(path);
}
void TR_svtImp::loadDataset(const string &path)
{
train.push_back(vector< Ptr<Object> >());
test.push_back(vector< Ptr<Object> >());
validation.push_back(vector< Ptr<Object> >());
string trainXml(path + "train.xml");
string testXml(path + "test.xml");
// loading train images description
xmlParse(trainXml, train.back());
// loading test images description
xmlParse(testXml, test.back());
}
Ptr<TR_svt> TR_svt::create()
{
return Ptr<TR_svtImp>(new TR_svtImp);
}
}
}
+382
View File
@@ -0,0 +1,382 @@
/*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/track_alov.hpp"
#include <sys/stat.h>
#include <opencv2/core.hpp>
#include "opencv2/imgcodecs.hpp"
using namespace std;
namespace cv
{
namespace datasets
{
class TRACK_alovImpl CV_FINAL : public TRACK_alov
{
public:
//Constructor
TRACK_alovImpl()
{
activeDatasetID = 1;
frameCounter = 0;
}
//Destructor
virtual ~TRACK_alovImpl() CV_OVERRIDE {}
//Load Dataset
virtual void load(const string &path) CV_OVERRIDE;
virtual void loadAnnotatedOnly(const std::string &path) CV_OVERRIDE;
protected:
virtual int getDatasetsNum() CV_OVERRIDE;
virtual int getDatasetLength(int id) CV_OVERRIDE;
virtual bool initDataset(int id) CV_OVERRIDE;
virtual bool getNextFrame(Mat &frame) CV_OVERRIDE;
virtual bool getFrame(Mat &frame, int datasetID, int frameID) CV_OVERRIDE;
virtual vector <Point2f> getNextGT() CV_OVERRIDE;
virtual vector <Point2f> getGT(int datasetID, int frameID) CV_OVERRIDE;
void loadDataset(const string &path);
void loadDatasetAnnotatedOnly(const string &path);
string fullFramePath(string rootPath, int sectionID, int videoID, int frameID);
string fullAnnoPath(string rootPath, int sectionID, int videoID);
};
void TRACK_alovImpl::load(const string &path)
{
loadDataset(path);
}
void TRACK_alovImpl::loadAnnotatedOnly(const string &path)
{
loadDatasetAnnotatedOnly(path);
}
string TRACK_alovImpl::fullFramePath(string rootPath, int sectionID, int videoID, int frameID)
{
string out;
char videoNum[9];
sprintf(videoNum, "%u", videoID+1);
char frameNum[9];
sprintf(frameNum, "%u", frameID);
out = rootPath + "/imagedata++/" + sectionNames[sectionID] + "/" + sectionNames[sectionID] + "_video";
for (unsigned int i = 0; i < 5 - strlen(videoNum); ++i)
{
out += "0";
}
out += videoNum;
out += "/";
for (unsigned int i = 0; i < 8 - strlen(frameNum); ++i)
{
out += "0";
}
out += frameNum;
out += ".jpg";
return out;
}
string TRACK_alovImpl::fullAnnoPath(string rootPath, int sectionID, int videoID)
{
string out;
char videoNum[9];
sprintf(videoNum, "%u", videoID+1);
out = rootPath + "/alov300++_rectangleAnnotation_full/" + sectionNames[sectionID] + "/" + sectionNames[sectionID] + "_video";
for (unsigned int i = 0; i < 5 - strlen(videoNum); ++i)
{
out += "0";
}
out += videoNum;
out += ".ann";
return out;
}
inline bool fileExists(const std::string& name)
{
struct stat buffer;
return (stat(name.c_str(), &buffer) == 0);
}
void TRACK_alovImpl::loadDataset(const string &rootPath)
{
vector <int> datasetsLengths;
printf("ALOV300++ Dataset Initialization...\n");
//Load frames
//Loop for all sections of ALOV300++ (14 sections)
for (int i = 0; i < 14; i++)
{
//Loop for all videos in section
for (int k = 0; k < sectionSizes[i]; k++)
{
vector <Ptr<TRACK_alovObj> > objects;
//Make a list of datasets lengths
int currFrameID = 0;
for (;;)
{
currFrameID++;
string fullPath = fullFramePath(rootPath, i, k, currFrameID);
if (!fileExists(fullPath))
break;
//Make ALOV300++ Object
Ptr<TRACK_alovObj> currObj(new TRACK_alovObj);
currObj->imagePath = fullPath;
currObj->id = currFrameID;
currObj->gtbb.push_back(Point2d(0, 0));
currObj->gtbb.push_back(Point2d(0, 0));
currObj->gtbb.push_back(Point2d(0, 0));
currObj->gtbb.push_back(Point2d(0, 0));
//Add object to storage
objects.push_back(currObj);
}
datasetsLengths.push_back(currFrameID - 1);
data.push_back(objects);
}
}
//Load annotations
//Loop for all sections of ALOV300++ (14 sections)
int currDatasetID = 0;
for (int i = 0; i < 14; i++)
{
//Loop for all videos in section
for (int k = 0; k < sectionSizes[i]; k++)
{
currDatasetID++;
//Open dataset's ground truth (annotation) file
string annoPath = fullAnnoPath(rootPath, i, k);
ifstream annoList(annoPath.c_str());
if (!annoList.is_open())
{
printf("Error: Can't open annotation file *.ANN!!!\n");
break;
}
//Ground Truth data
int n = 0;
double x1 = 0, y1 = 0,
x2 = 0, y2 = 0,
x3 = 0, y3 = 0,
x4 = 0, y4 = 0;
do
{
//Make ALOV300++ Object
string tmp;
getline(annoList, tmp);
std::istringstream in(tmp);
in >> n >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
Ptr<TRACK_alovObj> currObj = data[currDatasetID-1][n-1];
currObj->gtbb.clear();
currObj->gtbb.push_back(Point2d(x1, y1));
currObj->gtbb.push_back(Point2d(x2, y2));
currObj->gtbb.push_back(Point2d(x3, y3));
currObj->gtbb.push_back(Point2d(x4, y4));
} while (annoList.good());
}
}
return;
}
void TRACK_alovImpl::loadDatasetAnnotatedOnly(const string &rootPath)
{
vector <int> datasetsLengths;
printf("ALOV300++ Annotated Dataset Initialization...\n");
//Loop for all sections of ALOV300++ (14 sections)
for (int i = 0; i < 14; i++)
{
//Loop for all videos in section
for (int k = 0; k < sectionSizes[i]; k++)
{
vector <Ptr<TRACK_alovObj> > objects;
//Open dataset's ground truth (annotation) file
string annoPath = fullAnnoPath(rootPath, i, k);
ifstream annoList(annoPath.c_str());
if (!annoList.is_open())
{
printf("Error: Can't open annotation file *.ANN!!!\n");
break;
}
int framesNum = 0;
do
{
//Make ALOV300++ Object
Ptr<TRACK_alovObj> currObj(new TRACK_alovObj);
string tmp;
framesNum++;
//Ground Truth data
int n = 0;
double x1 = 0, y1 = 0,
x2 = 0, y2 = 0,
x3 = 0, y3 = 0,
x4 = 0, y4 = 0;
getline(annoList, tmp);
std::istringstream in(tmp);
in >> n >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
currObj->gtbb.push_back(Point2d(x1, y1));
currObj->gtbb.push_back(Point2d(x2, y2));
currObj->gtbb.push_back(Point2d(x3, y3));
currObj->gtbb.push_back(Point2d(x4, y4));
string fullPath = fullFramePath(rootPath, i, k, n);
if (!fileExists(fullPath))
break;
currObj->imagePath = fullPath;
currObj->id = n;
//Add object to storage
objects.push_back(currObj);
} while (annoList.good());
datasetsLengths.push_back(framesNum-1);
data.push_back(objects);
}
}
return;
}
int TRACK_alovImpl::getDatasetsNum()
{
return (int)(data.size());
}
int TRACK_alovImpl::getDatasetLength(int id)
{
if (id > 0 && id <= (int)data.size())
return (int)(data[id - 1].size());
else
{
printf("Dataset ID is out of range...\nAllowed IDs are: 1~%d\n", (int)data.size());
return -1;
}
}
bool TRACK_alovImpl::initDataset(int id)
{
if (id > 0 && id <= (int)data.size())
{
activeDatasetID = id;
return true;
}
else
{
printf("Dataset ID is out of range...\nAllowed IDs are: 1~%d\n", (int)data.size());
return false;
}
}
bool TRACK_alovImpl::getNextFrame(Mat &frame)
{
if (frameCounter >= (int)data[activeDatasetID - 1].size())
return false;
string imgPath = data[activeDatasetID - 1][frameCounter]->imagePath;
frame = imread(imgPath);
frameCounter++;
return !frame.empty();
}
bool TRACK_alovImpl::getFrame(Mat &frame, int datasetID, int frameID)
{
if (frameID > (int)data[datasetID-1].size())
return false;
string imgPath = data[datasetID-1][frameID-1]->imagePath;
frame = imread(imgPath);
return !frame.empty();
}
Ptr<TRACK_alov> TRACK_alov::create()
{
return Ptr<TRACK_alovImpl>(new TRACK_alovImpl);
}
vector <Point2f> TRACK_alovImpl::getNextGT()
{
Ptr <TRACK_alovObj> currObj = data[activeDatasetID - 1][frameCounter - 1];
return currObj->gtbb;
}
vector <Point2f> TRACK_alovImpl::getGT(int datasetID, int frameID)
{
Ptr <TRACK_alovObj> currObj = data[datasetID - 1][frameID - 1];
return currObj->gtbb;
}
}
}

Some files were not shown because too many files have changed in this diff Show More