Commit 37c503d4 authored by Vadim Pisarevsky's avatar Vadim Pisarevsky

Merge pull request #96 from avdmitry/datasets

datasets module: PR for adding benchmarks and renaming module from datasetstools
parents 81623285 2c8c4ddf
set(the_description "datasets framework")
ocv_define_module(datasets opencv_core opencv_face opencv_ml opencv_flann)
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4267) # flann, Win64
*******************************************************
datasets. Framework for working with different datasets
*******************************************************
.. highlight:: cpp
The datasets module includes classes for working with different datasets: load data, evaluate different algorithms on them, etc.
.. toctree::
:hidden:
datasets/ar_hmdb
datasets/ar_sports
datasets/fr_lfw
datasets/gr_chalearn
datasets/gr_skig
datasets/hpe_parse
datasets/ir_affine
datasets/ir_robot
datasets/is_bsds
datasets/is_weizmann
datasets/msm_epfl
datasets/msm_middlebury
datasets/or_imagenet
datasets/or_mnist
datasets/or_sun
datasets/pd_caltech
datasets/slam_kitti
datasets/slam_tumindoor
datasets/tr_chars
datasets/tr_svt
Action Recognition
------------------
:doc:`datasets/ar_hmdb`
:doc:`datasets/ar_sports`
Face Recognition
----------------
:doc:`datasets/fr_lfw`
Gesture Recognition
-------------------
:doc:`datasets/gr_chalearn`
:doc:`datasets/gr_skig`
Human Pose Estimation
---------------------
:doc:`datasets/hpe_parse`
Image Registration
------------------
:doc:`datasets/ir_affine`
:doc:`datasets/ir_robot`
Image Segmentation
------------------
:doc:`datasets/is_bsds`
:doc:`datasets/is_weizmann`
Multiview Stereo Matching
-------------------------
:doc:`datasets/msm_epfl`
:doc:`datasets/msm_middlebury`
Object Recognition
------------------
:doc:`datasets/or_imagenet`
:doc:`datasets/or_mnist`
:doc:`datasets/or_sun`
Pedestrian Detection
--------------------
:doc:`datasets/pd_caltech`
SLAM
----
:doc:`datasets/slam_kitti`
:doc:`datasets/slam_tumindoor`
Text Recognition
----------------
:doc:`datasets/tr_chars`
:doc:`datasets/tr_svt`
HMDB: A Large Human Motion Database
===================================
.. ocv:class:: AR_hmdb
Implements loading dataset:
_`"HMDB: A Large Human Motion Database"`: http://serre-lab.clps.brown.edu/resource/hmdb-a-large-human-motion-database/
.. note:: Usage
1. From link above download dataset files: hmdb51_org.rar & test_train_splits.rar.
2. Unpack them.
3. 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, which gives accuracy: 0.107407 (using precomputed HOG/HOF "STIP" features from site, averaging for 3 splits)
To run this benchmark execute:
.. code-block:: bash
./opencv/build/bin/example_datasets_ar_hmdb_benchmark -p=/home/user/path_to_unpacked_folders/
(precomputed features should be unpacked in the same folder: /home/user/path_to_unpacked_folders/hmdb51_org_stips/)
Sports-1M Dataset
=================
.. ocv:class:: AR_sports
Implements loading dataset:
_`"Sports-1M Dataset"`: http://cs.stanford.edu/people/karpathy/deepvideo/
.. note:: Usage
1. From link above download dataset files (git clone https://code.google.com/p/sports-1m-dataset/).
2. To load data run: ./opencv/build/bin/example_datasets_ar_sports -p=/home/user/path_to_downloaded_folders/
Labeled Faces in the Wild
=========================
.. ocv:class:: FR_lfw
Implements loading dataset:
_`"Labeled Faces in the Wild"`: http://vis-www.cs.umass.edu/lfw/
.. note:: Usage
1. From link above download any dataset file: lfw.tgz\lfwa.tar.gz\lfw-deepfunneled.tgz\lfw-funneled.tgz and files with pairs: 10 test splits: pairs.txt and developer train split: pairsDevTrain.txt.
2. Unpack dataset file and place pairs.txt and pairsDevTrain.txt in created folder.
3. 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, which gives accuracy: 0.623833 +- 0.005223 (train split: pairsDevTrain.txt, dataset: lfwa)
To run this benchmark execute:
.. code-block:: bash
./opencv/build/bin/example_datasets_fr_lfw_benchmark -p=/home/user/path_to_unpacked_folder/lfw2/
ChaLearn Looking at People
==========================
.. ocv:class:: GR_chalearn
Implements loading dataset:
_`"ChaLearn Looking at People"`: http://gesture.chalearn.org/
.. note:: Usage
1. Follow instruction from site above, download files for dataset "Track 3: Gesture Recognition": Train1.zip-Train5.zip, Validation1.zip-Validation3.zip (Register on site: www.codalab.org and accept the terms and conditions of competition: https://www.codalab.org/competitions/991#learn_the_details There are three mirrors for downloading dataset files. When I downloaded data only mirror: "Universitat Oberta de Catalunya" works).
2. Unpack train archives Train1.zip-Train5.zip to folder Train/, validation archives Validation1.zip-Validation3.zip to folder Validation/
3. Unpack all archives in Train/ & Validation/ in the folders with the same names, for example: Sample0001.zip to Sample0001/
4. To load data run: ./opencv/build/bin/example_datasets_gr_chalearn -p=/home/user/path_to_unpacked_folders/
Sheffield Kinect Gesture Dataset
================================
.. ocv:class:: GR_skig
Implements loading dataset:
_`"Sheffield Kinect Gesture Dataset"`: http://lshao.staff.shef.ac.uk/data/SheffieldKinectGesture.htm
.. note:: Usage
1. From link above download dataset files: subject1_dep.7z-subject6_dep.7z, subject1_rgb.7z-subject6_rgb.7z.
2. Unpack them.
3. To load data run: ./opencv/build/bin/example_datasets_gr_skig -p=/home/user/path_to_unpacked_folders/
PARSE Dataset
=============
.. ocv:class:: HPE_parse
Implements loading dataset:
_`"PARSE Dataset"`: http://www.ics.uci.edu/~dramanan/papers/parse/
.. note:: Usage
1. From link above download dataset file: people.zip.
2. Unpack it.
3. To load data run: ./opencv/build/bin/example_datasets_hpe_parse -p=/home/user/path_to_unpacked_folder/people_all/
Affine Covariant Regions Datasets
=================================
.. ocv:class:: IR_affine
Implements loading dataset:
_`"Affine Covariant Regions Datasets"`: http://www.robots.ox.ac.uk/~vgg/data/data-aff.html
.. note:: Usage
1. From link above download dataset files: bark\\bikes\\boat\\graf\\leuven\\trees\\ubc\\wall.tar.gz.
2. Unpack them.
3. 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
==============
.. ocv:class:: IR_robot
Implements loading dataset:
_`"Robot Data Set"`: http://roboimagedata.compute.dtu.dk/?page_id=24
.. note:: Usage
1. From link above download files for dataset "Point Feature Data Set – 2010": SET001_6.tar.gz-SET055_60.tar.gz (there are two data sets: - Full resolution images (1200×1600), ~500 Gb and - Half size image (600×800), ~115 Gb.)
2. Unpack them to one folder.
3. To load data run: ./opencv/build/bin/example_datasets_ir_robot -p=/home/user/path_to_unpacked_folder/
The Berkeley Segmentation Dataset and Benchmark
===============================================
.. ocv:class:: IS_bsds
Implements loading dataset:
_`"The Berkeley Segmentation Dataset and Benchmark"`: https://www.eecs.berkeley.edu/Research/Projects/CS/vision/bsds/
.. note:: Usage
1. From link above download dataset files: BSDS300-human.tgz & BSDS300-images.tgz.
2. Unpack them.
3. To load data run: ./opencv/build/bin/example_datasets_is_bsds -p=/home/user/path_to_unpacked_folder/BSDS300/
Weizmann Segmentation Evaluation Database
=========================================
.. ocv:class:: IS_weizmann
Implements loading dataset:
_`"Weizmann Segmentation Evaluation Database"`: http://www.wisdom.weizmann.ac.il/~vision/Seg_Evaluation_DB/
.. note:: Usage
1. From link above download dataset files: Weizmann_Seg_DB_1obj.ZIP & Weizmann_Seg_DB_2obj.ZIP.
2. Unpack them.
3. To load data, for example, for 1 object dataset, run: ./opencv/build/bin/example_datasets_is_weizmann -p=/home/user/path_to_unpacked_folder/1obj/
EPFL Multi-View Stereo
======================
.. ocv:class:: MSM_epfl
Implements loading dataset:
_`"EPFL Multi-View Stereo"`: http://cvlabwww.epfl.ch/~strecha/multiview/denseMVS.html
.. note:: Usage
1. 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.
2. 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/
3. 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
===================================
.. ocv:class:: MSM_middlebury
Implements loading dataset:
_`"Stereo – Middlebury Computer Vision"`: http://vision.middlebury.edu/mview/
.. note:: Usage
1. From link above download dataset files: dino\\dinoRing\\dinoSparseRing\\temple\\templeRing\\templeSparseRing.zip
2. Unpack them.
3. To load data, for example "temple" dataset, run: ./opencv/build/bin/example_datasets_msm_middlebury -p=/home/user/path_to_unpacked_folder/temple/
ImageNet
========
.. ocv:class:: OR_imagenet
Implements loading dataset:
_`"ImageNet"`: http://www.image-net.org/
Currently implemented loading full list with urls. Planned to implement dataset from ILSVRC challenge.
.. note:: Usage
1. From link above download dataset file: imagenet_fall11_urls.tgz
2. Unpack it.
3. To load data run: ./opencv/build/bin/example_datasets_or_imagenet -p=/home/user/path_to_unpacked_file/
MNIST
=====
.. ocv:class:: OR_mnist
Implements loading dataset:
_`"MNIST"`: http://yann.lecun.com/exdb/mnist/
.. note:: Usage
1. From link above download dataset files: t10k-images-idx3-ubyte.gz, t10k-labels-idx1-ubyte.gz, train-images-idx3-ubyte.gz, train-labels-idx1-ubyte.gz.
2. Unpack them.
3. To load data run: ./opencv/build/bin/example_datasets_or_mnist -p=/home/user/path_to_unpacked_files/
SUN Database
============
.. ocv:class:: OR_sun
Implements loading dataset:
_`"SUN Database"`: http://sundatabase.mit.edu/
Currently implemented loading "Scene Recognition Benchmark. SUN397". Planned to implement also "Object Detection Benchmark. SUN2012".
.. note:: Usage
1. From link above download dataset file: SUN397.tar
2. Unpack it.
3. To load data run: ./opencv/build/bin/example_datasets_or_sun -p=/home/user/path_to_unpacked_folder/SUN397/
Caltech Pedestrian Detection Benchmark
======================================
.. ocv:class:: PD_caltech
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.
.. note:: Usage
1. From link above download dataset files: set00.tar-set10.tar.
2. Unpack them to separate folder.
3. To load data run: ./opencv/build/bin/example_datasets_pd_caltech -p=/home/user/path_to_unpacked_folders/
KITTI Vision Benchmark
======================
.. ocv:class:: SLAM_kitti
Implements loading dataset:
_`"KITTI Vision Benchmark"`: http://www.cvlibs.net/datasets/kitti/eval_odometry.php
.. note:: Usage
1. From link above download "Odometry" dataset files: data_odometry_gray\\data_odometry_color\\data_odometry_velodyne\\data_odometry_poses\\data_odometry_calib.zip.
2. 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.
3. To load data run: ./opencv/build/bin/example_datasets_slam_kitti -p=/home/user/path_to_unpacked_folder/dataset/
TUMindoor Dataset
=================
.. ocv:class:: SLAM_tumindoor
Implements loading dataset:
_`"TUMindoor Dataset"`: http://www.navvis.lmt.ei.tum.de/dataset/
.. note:: Usage
1. 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)
2. Unpack them in separate folder for each dataset. dslr.tar.bz2 -> dslr/, info.tar.bz2 -> info/, ladybug.tar.bz2 -> ladybug/, pointcloud.tar.bz2 -> pointcloud/.
3. To load each dataset run: ./opencv/build/bin/example_datasets_slam_tumindoor -p=/home/user/path_to_unpacked_folders/
The Chars74K Dataset
====================
.. ocv:class:: TR_chars
Implements loading dataset:
_`"The Chars74K Dataset"`: http://www.ee.surrey.ac.uk/CVSSP/demos/chars74k/
.. note:: Usage
1. From link above download dataset files: EnglishFnt\\EnglishHnd\\EnglishImg\\KannadaHnd\\KannadaImg.tgz, ListsTXT.tgz.
2. Unpack them.
3. Move .m files from folder ListsTXT/ to appropriate folder. For example, English/list_English_Img.m for EnglishImg.tgz.
4. 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
============================
.. ocv:class:: TR_svt
Implements loading dataset:
_`"The Street View Text Dataset"`: http://vision.ucsd.edu/~kai/svt/
.. note:: Usage
1. From link above download dataset file: svt.zip.
2. Unpack it.
3. To load data run: ./opencv/build/bin/example_datasets_tr_svt -p=/home/user/path_to_unpacked_folder/svt/svt1/
......@@ -39,19 +39,19 @@
//
//M*/
#ifndef OPENCV_DATASETSTOOLS_AR_HMDB_HPP
#define OPENCV_DATASETSTOOLS_AR_HMDB_HPP
#ifndef OPENCV_DATASETS_AR_HMDB_HPP
#define OPENCV_DATASETS_AR_HMDB_HPP
#include <string>
#include <vector>
#include "opencv2/datasetstools/dataset.hpp"
#include "opencv2/datasets/dataset.hpp"
#include <opencv2/core.hpp>
namespace cv
{
namespace datasetstools
namespace datasets
{
struct AR_hmdbObj : public Object
......
......@@ -39,19 +39,19 @@
//
//M*/
#ifndef OPENCV_DATASETSTOOLS_AR_SPORTS_HPP
#define OPENCV_DATASETSTOOLS_AR_SPORTS_HPP
#ifndef OPENCV_DATASETS_AR_SPORTS_HPP
#define OPENCV_DATASETS_AR_SPORTS_HPP
#include <string>
#include <vector>
#include "opencv2/datasetstools/dataset.hpp"
#include "opencv2/datasets/dataset.hpp"
#include <opencv2/core.hpp>
namespace cv
{
namespace datasetstools
namespace datasets
{
struct AR_sportsObj : public Object
......
......@@ -39,8 +39,8 @@
//
//M*/
#ifndef OPENCV_DATASETSTOOLS_DATASET_HPP
#define OPENCV_DATASETSTOOLS_DATASET_HPP
#ifndef OPENCV_DATASETS_DATASET_HPP
#define OPENCV_DATASETS_DATASET_HPP
#include <string>
#include <vector>
......@@ -49,7 +49,7 @@
namespace cv
{
namespace datasetstools
namespace datasets
{
struct Object
......
......@@ -39,19 +39,19 @@
//
//M*/
#ifndef OPENCV_DATASETSTOOLS_FR_LFW_HPP
#define OPENCV_DATASETSTOOLS_FR_LFW_HPP
#ifndef OPENCV_DATASETS_FR_LFW_HPP
#define OPENCV_DATASETS_FR_LFW_HPP
#include <string>
#include <vector>
#include "opencv2/datasetstools/dataset.hpp"
#include "opencv2/datasets/dataset.hpp"
#include <opencv2/core.hpp>
namespace cv
{
namespace datasetstools
namespace datasets
{
struct FR_lfwObj : public Object
......
......@@ -39,19 +39,19 @@
//
//M*/
#ifndef OPENCV_DATASETSTOOLS_GR_CHALEARN_HPP
#define OPENCV_DATASETSTOOLS_GR_CHALEARN_HPP
#ifndef OPENCV_DATASETS_GR_CHALEARN_HPP
#define OPENCV_DATASETS_GR_CHALEARN_HPP
#include <string>
#include <vector>
#include "opencv2/datasetstools/dataset.hpp"
#include "opencv2/datasets/dataset.hpp"
#include <opencv2/core.hpp>
namespace cv
{
namespace datasetstools
namespace datasets
{
struct groundTruth
......
......@@ -39,19 +39,19 @@
//
//M*/
#ifndef OPENCV_DATASETSTOOLS_GR_SKIG_HPP
#define OPENCV_DATASETSTOOLS_GR_SKIG_HPP
#ifndef OPENCV_DATASETS_GR_SKIG_HPP
#define OPENCV_DATASETS_GR_SKIG_HPP
#include <string>
#include <vector>
#include "opencv2/datasetstools/dataset.hpp"
#include "opencv2/datasets/dataset.hpp"
#include <opencv2/core.hpp>
namespace cv
{
namespace datasetstools
namespace datasets
{
enum actionType
......
......@@ -39,19 +39,19 @@
//
//M*/
#ifndef OPENCV_DATASETSTOOLS_HPE_PARSE_HPP
#define OPENCV_DATASETSTOOLS_HPE_PARSE_HPP
#ifndef OPENCV_DATASETS_HPE_PARSE_HPP
#define OPENCV_DATASETS_HPE_PARSE_HPP
#include <string>
#include <vector>
#include "opencv2/datasetstools/dataset.hpp"
#include "opencv2/datasets/dataset.hpp"
#include <opencv2/core.hpp>
namespace cv
{
namespace datasetstools
namespace datasets
{
struct HPE_parseObj : public Object
......
......@@ -39,20 +39,20 @@
//
//M*/
#ifndef OPENCV_DATASETSTOOLS_IR_AFFINE_HPP
#define OPENCV_DATASETSTOOLS_IR_AFFINE_HPP
#ifndef OPENCV_DATASETS_IR_AFFINE_HPP
#define OPENCV_DATASETS_IR_AFFINE_HPP
#include <string>
#include <vector>
#include "opencv2/datasetstools/dataset.hpp"
#include "opencv2/datasets/dataset.hpp"
#include <opencv2/core.hpp>
#include <opencv2/core/matx.hpp>
namespace cv
{
namespace datasetstools
namespace datasets
{
struct IR_affineObj : public Object
......
......@@ -39,19 +39,19 @@
//
//M*/
#ifndef OPENCV_DATASETSTOOLS_IR_ROBOT_HPP
#define OPENCV_DATASETSTOOLS_IR_ROBOT_HPP
#ifndef OPENCV_DATASETS_IR_ROBOT_HPP
#define OPENCV_DATASETS_IR_ROBOT_HPP
#include <string>
#include <vector>
#include "opencv2/datasetstools/dataset.hpp"
#include "opencv2/datasets/dataset.hpp"
#include <opencv2/core.hpp>
namespace cv
{
namespace datasetstools
namespace datasets
{
// calibration matrix from calibrationFile.mat
......
......@@ -39,19 +39,19 @@
//
//M*/
#ifndef OPENCV_DATASETSTOOLS_IS_BSDS_HPP
#define OPENCV_DATASETSTOOLS_IS_BSDS_HPP
#ifndef OPENCV_DATASETS_IS_BSDS_HPP
#define OPENCV_DATASETS_IS_BSDS_HPP
#include <string>
#include <vector>
#include "opencv2/datasetstools/dataset.hpp"
#include "opencv2/datasets/dataset.hpp"
#include <opencv2/core.hpp>
namespace cv
{
namespace datasetstools
namespace datasets
{
struct IS_bsdsObj : public Object
......
......@@ -39,19 +39,19 @@
//
//M*/
#ifndef OPENCV_DATASETSTOOLS_IS_WEIZMANN_HPP
#define OPENCV_DATASETSTOOLS_IS_WEIZMANN_HPP
#ifndef OPENCV_DATASETS_IS_WEIZMANN_HPP
#define OPENCV_DATASETS_IS_WEIZMANN_HPP
#include <string>
#include <vector>
#include "opencv2/datasetstools/dataset.hpp"
#include "opencv2/datasets/dataset.hpp"
#include <opencv2/core.hpp>
namespace cv
{
namespace datasetstools
namespace datasets
{
struct IS_weizmannObj : public Object
......
......@@ -39,19 +39,19 @@
//
//M*/
#ifndef OPENCV_DATASETSTOOLS_MSM_EPFL_HPP
#define OPENCV_DATASETSTOOLS_MSM_EPFL_HPP
#ifndef OPENCV_DATASETS_MSM_EPFL_HPP
#define OPENCV_DATASETS_MSM_EPFL_HPP
#include <string>
#include <vector>
#include "opencv2/datasetstools/dataset.hpp"
#include "opencv2/datasets/dataset.hpp"
#include <opencv2/core.hpp>
namespace cv
{
namespace datasetstools
namespace datasets
{
struct cameraParam
......
......@@ -39,19 +39,19 @@
//
//M*/
#ifndef OPENCV_DATASETSTOOLS_MSM_MIDDLEBURY_HPP
#define OPENCV_DATASETSTOOLS_MSM_MIDDLEBURY_HPP
#ifndef OPENCV_DATASETS_MSM_MIDDLEBURY_HPP
#define OPENCV_DATASETS_MSM_MIDDLEBURY_HPP
#include <string>
#include <vector>
#include "opencv2/datasetstools/dataset.hpp"
#include "opencv2/datasets/dataset.hpp"
#include <opencv2/core.hpp>
namespace cv
{
namespace datasetstools
namespace datasets
{
struct MSM_middleburyObj : public Object
......
......@@ -39,19 +39,19 @@
//
//M*/
#ifndef OPENCV_DATASETSTOOLS_OR_IMAGENET_HPP
#define OPENCV_DATASETSTOOLS_OR_IMAGENET_HPP
#ifndef OPENCV_DATASETS_OR_IMAGENET_HPP
#define OPENCV_DATASETS_OR_IMAGENET_HPP
#include <string>
#include <vector>
#include "opencv2/datasetstools/dataset.hpp"
#include "opencv2/datasets/dataset.hpp"
#include <opencv2/core.hpp>
namespace cv
{
namespace datasetstools
namespace datasets
{
struct OR_imagenetObj : public Object
......
......@@ -39,19 +39,19 @@
//
//M*/
#ifndef OPENCV_DATASETSTOOLS_OR_MNIST_HPP
#define OPENCV_DATASETSTOOLS_OR_MNIST_HPP
#ifndef OPENCV_DATASETS_OR_MNIST_HPP
#define OPENCV_DATASETS_OR_MNIST_HPP
#include <string>
#include <vector>
#include "opencv2/datasetstools/dataset.hpp"
#include "opencv2/datasets/dataset.hpp"
#include <opencv2/core.hpp>
namespace cv
{
namespace datasetstools
namespace datasets
{
struct OR_mnistObj : public Object
......
......@@ -39,19 +39,19 @@
//
//M*/
#ifndef OPENCV_DATASETSTOOLS_OR_SUN_HPP
#define OPENCV_DATASETSTOOLS_OR_SUN_HPP
#ifndef OPENCV_DATASETS_OR_SUN_HPP
#define OPENCV_DATASETS_OR_SUN_HPP
#include <string>
#include <vector>
#include "opencv2/datasetstools/dataset.hpp"
#include "opencv2/datasets/dataset.hpp"
#include <opencv2/core.hpp>
namespace cv
{
namespace datasetstools
namespace datasets
{
struct OR_sunObj : public Object
......
/*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
{
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) = 0;
static Ptr<PD_caltech> create();
};
}
}
#endif
......@@ -39,19 +39,19 @@
//
//M*/
#ifndef OPENCV_DATASETSTOOLS_SLAM_KITTI_HPP
#define OPENCV_DATASETSTOOLS_SLAM_KITTI_HPP
#ifndef OPENCV_DATASETS_SLAM_KITTI_HPP
#define OPENCV_DATASETS_SLAM_KITTI_HPP
#include <string>
#include <vector>
#include "opencv2/datasetstools/dataset.hpp"
#include "opencv2/datasets/dataset.hpp"
#include <opencv2/core.hpp>
namespace cv
{
namespace datasetstools
namespace datasets
{
struct pose
......
......@@ -39,19 +39,19 @@
//
//M*/
#ifndef OPENCV_DATASETSTOOLS_SLAM_TUMINDOOR_HPP
#define OPENCV_DATASETSTOOLS_SLAM_TUMINDOOR_HPP
#ifndef OPENCV_DATASETS_SLAM_TUMINDOOR_HPP
#define OPENCV_DATASETS_SLAM_TUMINDOOR_HPP
#include <string>
#include <vector>
#include "opencv2/datasetstools/dataset.hpp"
#include "opencv2/datasets/dataset.hpp"
#include <opencv2/core.hpp>
namespace cv
{
namespace datasetstools
namespace datasets
{
enum imageType
......
......@@ -39,19 +39,19 @@
//
//M*/
#ifndef OPENCV_DATASETSTOOLS_TR_CHARS_HPP
#define OPENCV_DATASETSTOOLS_TR_CHARS_HPP
#ifndef OPENCV_DATASETS_TR_CHARS_HPP
#define OPENCV_DATASETS_TR_CHARS_HPP
#include <string>
#include <vector>
#include "opencv2/datasetstools/dataset.hpp"
#include "opencv2/datasets/dataset.hpp"
#include <opencv2/core.hpp>
namespace cv
{
namespace datasetstools
namespace datasets
{
struct TR_charsObj : public Object
......
......@@ -39,19 +39,19 @@
//
//M*/
#ifndef OPENCV_DATASETSTOOLS_TR_SVT_HPP
#define OPENCV_DATASETSTOOLS_TR_SVT_HPP
#ifndef OPENCV_DATASETS_TR_SVT_HPP
#define OPENCV_DATASETS_TR_SVT_HPP
#include <string>
#include <vector>
#include "opencv2/datasetstools/dataset.hpp"
#include "opencv2/datasets/dataset.hpp"
#include <opencv2/core.hpp>
namespace cv
{
namespace datasetstools
namespace datasets
{
struct tag
......
......@@ -39,8 +39,8 @@
//
//M*/
#ifndef OPENCV_DATASETSTOOLS_UTIL_HPP
#define OPENCV_DATASETSTOOLS_UTIL_HPP
#ifndef OPENCV_DATASETS_UTIL_HPP
#define OPENCV_DATASETS_UTIL_HPP
#include <string>
#include <vector>
......@@ -49,12 +49,14 @@
namespace cv
{
namespace datasetstools
namespace datasets
{
void split(const std::string &s, std::vector<std::string> &elems, char delim);
void CV_EXPORTS split(const std::string &s, std::vector<std::string> &elems, char delim);
void getDirList(const std::string &dirName, std::vector<std::string> &fileNames);
void CV_EXPORTS createDirectory(const std::string &path);
void CV_EXPORTS getDirList(const std::string &dirName, std::vector<std::string> &fileNames);
}
}
......
......@@ -39,7 +39,7 @@
//
//M*/
#include "opencv2/datasetstools/ar_hmdb.hpp"
#include "opencv2/datasets/ar_hmdb.hpp"
#include <opencv2/core.hpp>
......@@ -50,7 +50,7 @@
using namespace std;
using namespace cv;
using namespace cv::datasetstools;
using namespace cv::datasets;
int main(int argc, char *argv[])
{
......
/*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;
unsigned int getNumFiles(vector< Ptr<Object> > &curr);
unsigned int getNumFiles(vector< Ptr<Object> > &curr)
{
unsigned int numFiles = 0;
for (unsigned int i=0; i<curr.size(); ++i)
{
AR_hmdbObj *example = static_cast<AR_hmdbObj *>(curr[i].get());
vector<string> &videoNames = example->videoNames;
for (vector<string>::iterator it=videoNames.begin(); it!=videoNames.end(); ++it)
{
numFiles++;
}
}
return numFiles;
}
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());
vector<string> &videoNames = example->videoNames;
for (vector<string>::iterator it=videoNames.begin(); it!=videoNames.end(); ++it)
{
string featuresFile = *it + ".txt";
string featuresFullPath = path + "hmdb51_org_stips/" + example->name + "/" + featuresFile;
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) = i;
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 numTrainFiles = getNumFiles(curr);
unsigned int numFeatures = 0;
for (unsigned int i=0; i<curr.size(); ++i)
{
AR_hmdbObj *example = static_cast<AR_hmdbObj *>(curr[i].get());
vector<string> &videoNames = example->videoNames;
for (vector<string>::iterator it=videoNames.begin(); it!=videoNames.end(); ++it)
{
string featuresFile = *it + ".txt";
string featuresFullPath = path + "hmdb51_org_stips/" + example->name + "/" + featuresFile;
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);
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");
SVM::Params params;
params.svmType = SVM::C_SVC;
params.kernelType = SVM::POLY; //SVM::RBF;
params.degree = 0.5;
params.gamma = 1;
params.coef0 = 1;
params.C = 1;
params.nu = 0.5;
params.p = 0;
params.termCrit = TermCriteria(TermCriteria::MAX_ITER+TermCriteria::EPS, 1000, 0.01);
Ptr<SVM> svm = SVM::create(params);
svm->train(trainData, ROW_SAMPLE, trainLabels);
// prepare to predict
curr = dataset->getTest(currSplit);
unsigned int numTestFiles = getNumFiles(curr);
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;
}
......@@ -39,7 +39,7 @@
//
//M*/
#include "opencv2/datasetstools/ar_sports.hpp"
#include "opencv2/datasets/ar_sports.hpp"
#include <opencv2/core.hpp>
......@@ -51,7 +51,7 @@
using namespace std;
using namespace cv;
using namespace cv::datasetstools;
using namespace cv::datasets;
int main(int argc, char *argv[])
{
......
......@@ -39,7 +39,7 @@
//
//M*/
#include "opencv2/datasetstools/fr_lfw.hpp"
#include "opencv2/datasets/fr_lfw.hpp"
#include <opencv2/core.hpp>
......@@ -50,7 +50,7 @@
using namespace std;
using namespace cv;
using namespace cv::datasetstools;
using namespace cv::datasets;
int main(int argc, char *argv[])
{
......
/*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/face.hpp"
#include "opencv2/datasets/fr_lfw.hpp"
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <map>
using namespace std;
using namespace cv;
using namespace cv::datasets;
using namespace cv::face;
map<string, int> people;
int getLabel(const string &imagePath);
int getLabel(const string &imagePath)
{
size_t pos = imagePath.find('/');
string curr = imagePath.substr(0, pos);
map<string, int>::iterator it = people.find(curr);
if (people.end() == it)
{
people.insert(make_pair(curr, (int)people.size()));
it = people.find(curr);
}
return (*it).second;
}
int main(int argc, const 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;
}
// These vectors hold the images and corresponding labels.
vector<Mat> images;
vector<int> labels;
// load dataset
Ptr<FR_lfw> dataset = FR_lfw::create();
dataset->load(path);
unsigned int numSplits = dataset->getNumSplits();
printf("splits number: %u\n", numSplits);
printf("train size: %u\n", (unsigned int)dataset->getTrain().size());
printf("test size: %u\n", (unsigned int)dataset->getTest().size());
for (unsigned int i=0; i<dataset->getTrain().size(); ++i)
{
FR_lfwObj *example = static_cast<FR_lfwObj *>(dataset->getTrain()[i].get());
int currNum = getLabel(example->image1);
Mat img = imread(path+example->image1, IMREAD_GRAYSCALE);
images.push_back(img);
labels.push_back(currNum);
currNum = getLabel(example->image2);
img = imread(path+example->image2, IMREAD_GRAYSCALE);
images.push_back(img);
labels.push_back(currNum);
}
// 2200 pairsDevTrain, first split: correct: 373, from: 600 -> 62.1667%
Ptr<FaceRecognizer> model = createLBPHFaceRecognizer();
// 2200 pairsDevTrain, first split: correct: correct: 369, from: 600 -> 61.5%
//Ptr<FaceRecognizer> model = createEigenFaceRecognizer();
// 2200 pairsDevTrain, first split: correct: 372, from: 600 -> 62%
//Ptr<FaceRecognizer> model = createFisherFaceRecognizer();
model->train(images, labels);
//string saveModelPath = "face-rec-model.txt";
//cout << "Saving the trained model to " << saveModelPath << endl;
//model->save(saveModelPath);
vector<double> p;
for (unsigned int j=0; j<numSplits; ++j)
{
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());
//int currNum = getLabel(example->image1);
Mat img = imread(path+example->image1, IMREAD_GRAYSCALE);
int predictedLabel1 = model->predict(img);
//currNum = getLabel(example->image2);
img = imread(path+example->image2, IMREAD_GRAYSCALE);
int predictedLabel2 = model->predict(img);
if ((predictedLabel1 == predictedLabel2 && example->same) ||
(predictedLabel1 != predictedLabel2 && !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(p.size());
printf("estimated mean accuracy: %f and the standard error of the mean: %f\n", mu, se);
return 0;
}
......@@ -39,7 +39,7 @@
//
//M*/
#include "opencv2/datasetstools/gr_chalearn.hpp"
#include "opencv2/datasets/gr_chalearn.hpp"
#include <opencv2/core.hpp>
......@@ -50,7 +50,7 @@
using namespace std;
using namespace cv;
using namespace cv::datasetstools;
using namespace cv::datasets;
int main(int argc, char *argv[])
{
......
......@@ -39,7 +39,7 @@
//
//M*/
#include "opencv2/datasetstools/gr_skig.hpp"
#include "opencv2/datasets/gr_skig.hpp"
#include <opencv2/core.hpp>
......@@ -51,7 +51,7 @@
using namespace std;
using namespace cv;
using namespace cv::datasetstools;
using namespace cv::datasets;
int main(int argc, char *argv[])
{
......
......@@ -39,7 +39,7 @@
//
//M*/
#include "opencv2/datasetstools/hpe_parse.hpp"
#include "opencv2/datasets/hpe_parse.hpp"
#include <opencv2/core.hpp>
......@@ -50,7 +50,7 @@
using namespace std;
using namespace cv;
using namespace cv::datasetstools;
using namespace cv::datasets;
int main(int argc, char *argv[])
{
......
......@@ -39,7 +39,7 @@
//
//M*/
#include "opencv2/datasetstools/ir_affine.hpp"
#include "opencv2/datasets/ir_affine.hpp"
#include <opencv2/core.hpp>
......@@ -51,7 +51,7 @@
using namespace std;
using namespace cv;
using namespace cv::datasetstools;
using namespace cv::datasets;
int main(int argc, char *argv[])
{
......
......@@ -39,7 +39,7 @@
//
//M*/
#include "opencv2/datasetstools/ir_robot.hpp"
#include "opencv2/datasets/ir_robot.hpp"
#include <opencv2/core.hpp>
......@@ -50,7 +50,7 @@
using namespace std;
using namespace cv;
using namespace cv::datasetstools;
using namespace cv::datasets;
int main(int argc, char *argv[])
{
......
......@@ -39,7 +39,7 @@
//
//M*/
#include "opencv2/datasetstools/is_bsds.hpp"
#include "opencv2/datasets/is_bsds.hpp"
#include <opencv2/core.hpp>
......@@ -50,7 +50,7 @@
using namespace std;
using namespace cv;
using namespace cv::datasetstools;
using namespace cv::datasets;
int main(int argc, char *argv[])
{
......
......@@ -39,7 +39,7 @@
//
//M*/
#include "opencv2/datasetstools/is_weizmann.hpp"
#include "opencv2/datasets/is_weizmann.hpp"
#include <opencv2/core.hpp>
......@@ -50,7 +50,7 @@
using namespace std;
using namespace cv;
using namespace cv::datasetstools;
using namespace cv::datasets;
int main(int argc, char *argv[])
{
......
......@@ -39,7 +39,7 @@
//
//M*/
#include "opencv2/datasetstools/msm_epfl.hpp"
#include "opencv2/datasets/msm_epfl.hpp"
#include <opencv2/core.hpp>
......@@ -50,7 +50,7 @@
using namespace std;
using namespace cv;
using namespace cv::datasetstools;
using namespace cv::datasets;
int main(int argc, char *argv[])
{
......
......@@ -39,7 +39,7 @@
//
//M*/
#include "opencv2/datasetstools/msm_middlebury.hpp"
#include "opencv2/datasets/msm_middlebury.hpp"
#include <opencv2/core.hpp>
......@@ -50,7 +50,7 @@
using namespace std;
using namespace cv;
using namespace cv::datasetstools;
using namespace cv::datasets;
int main(int argc, char *argv[])
{
......
......@@ -39,7 +39,7 @@
//
//M*/
#include "opencv2/datasetstools/or_imagenet.hpp"
#include "opencv2/datasets/or_imagenet.hpp"
#include <opencv2/core.hpp>
......@@ -52,7 +52,7 @@
using namespace std;
using namespace cv;
using namespace cv::datasetstools;
using namespace cv::datasets;
int main(int argc, char *argv[])
{
......
......@@ -39,7 +39,7 @@
//
//M*/
#include "opencv2/datasetstools/or_mnist.hpp"
#include "opencv2/datasets/or_mnist.hpp"
#include <opencv2/core.hpp>
#include <opencv2/imgcodecs.hpp>
......@@ -51,13 +51,13 @@
using namespace std;
using namespace cv;
using namespace cv::datasetstools;
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) }";
"{ path p |true| path to dataset }";
CommandLineParser parser(argc, argv, keys);
string path(parser.get<string>("path"));
if (parser.has("help") || path=="true")
......
......@@ -39,7 +39,7 @@
//
//M*/
#include "opencv2/datasetstools/or_sun.hpp"
#include "opencv2/datasets/or_sun.hpp"
#include <opencv2/core.hpp>
......@@ -50,7 +50,7 @@
using namespace std;
using namespace cv;
using namespace cv::datasetstools;
using namespace cv::datasets;
int main(int argc, char *argv[])
{
......
/*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;
}
......@@ -39,7 +39,7 @@
//
//M*/
#include "opencv2/datasetstools/slam_kitti.hpp"
#include "opencv2/datasets/slam_kitti.hpp"
#include <opencv2/core.hpp>
......@@ -50,7 +50,7 @@
using namespace std;
using namespace cv;
using namespace cv::datasetstools;
using namespace cv::datasets;
int main(int argc, char *argv[])
{
......
......@@ -39,7 +39,7 @@
//
//M*/
#include "opencv2/datasetstools/slam_tumindoor.hpp"
#include "opencv2/datasets/slam_tumindoor.hpp"
#include <opencv2/core.hpp>
......@@ -50,7 +50,7 @@
using namespace std;
using namespace cv;
using namespace cv::datasetstools;
using namespace cv::datasets;
int main(int argc, char *argv[])
{
......
......@@ -39,7 +39,7 @@
//
//M*/
#include "opencv2/datasetstools/tr_chars.hpp"
#include "opencv2/datasets/tr_chars.hpp"
#include <opencv2/core.hpp>
......@@ -51,7 +51,7 @@
using namespace std;
using namespace cv;
using namespace cv::datasetstools;
using namespace cv::datasets;
int main(int argc, char *argv[])
{
......
......@@ -39,7 +39,7 @@
//
//M*/
#include "opencv2/datasetstools/tr_svt.hpp"
#include "opencv2/datasets/tr_svt.hpp"
#include <opencv2/core.hpp>
......@@ -51,7 +51,7 @@
using namespace std;
using namespace cv;
using namespace cv::datasetstools;
using namespace cv::datasets;
int main(int argc, char *argv[])
{
......
......@@ -39,12 +39,13 @@
//
//M*/
#include "opencv2/datasetstools/ar_hmdb.hpp"
#include "opencv2/datasets/ar_hmdb.hpp"
#include "opencv2/datasets/util.hpp"
#include "precomp.hpp"
namespace cv
{
namespace datasetstools
namespace datasets
{
using namespace std;
......
......@@ -39,12 +39,13 @@
//
//M*/
#include "opencv2/datasetstools/ar_sports.hpp"
#include "opencv2/datasets/ar_sports.hpp"
#include "opencv2/datasets/util.hpp"
#include "precomp.hpp"
namespace cv
{
namespace datasetstools
namespace datasets
{
using namespace std;
......
......@@ -39,12 +39,13 @@
//
//M*/
#include "opencv2/datasetstools/dataset.hpp"
#include "opencv2/datasets/dataset.hpp"
#include "opencv2/datasets/util.hpp"
#include "precomp.hpp"
namespace cv
{
namespace datasetstools
namespace datasets
{
using namespace std;
......
......@@ -39,14 +39,15 @@
//
//M*/
#include "opencv2/datasetstools/fr_lfw.hpp"
#include "opencv2/datasets/fr_lfw.hpp"
#include "opencv2/datasets/util.hpp"
#include "precomp.hpp"
#include <map>
namespace cv
{
namespace datasetstools
namespace datasets
{
using namespace std;
......@@ -82,12 +83,13 @@ void FR_lfwImp::loadDataset(const string &path)
getDirList(path, fileNames);
for (vector<string>::iterator it=fileNames.begin(); it!=fileNames.end(); ++it)
{
if ("pairs.txt" == *it)
string &name = *it;
if (name.length()>3 && name.substr(name.length()-4) == ".txt")
{
continue;
}
string &name = *it;
vector<string> images;
string pathFace(path + name + "/");
......@@ -142,6 +144,37 @@ void FR_lfwImp::loadDataset(const string &path)
num++;
}
// dev train loading to train[0]
ifstream infile2((path + "pairsDevTrain.txt").c_str());
getline(infile2, line); // should 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);
}
}
Ptr<FR_lfw> FR_lfw::create()
......
......@@ -39,12 +39,13 @@
//
//M*/
#include "opencv2/datasetstools/gr_chalearn.hpp"
#include "opencv2/datasets/gr_chalearn.hpp"
#include "opencv2/datasets/util.hpp"
#include "precomp.hpp"
namespace cv
{
namespace datasetstools
namespace datasets
{
using namespace std;
......
......@@ -39,14 +39,15 @@
//
//M*/
#include "opencv2/datasetstools/gr_skig.hpp"
#include "opencv2/datasets/gr_skig.hpp"
#include "opencv2/datasets/util.hpp"
#include "precomp.hpp"
#include <cstring>
namespace cv
{
namespace datasetstools
namespace datasets
{
using namespace std;
......
......@@ -39,12 +39,13 @@
//
//M*/
#include "opencv2/datasetstools/hpe_parse.hpp"
#include "opencv2/datasets/hpe_parse.hpp"
#include "opencv2/datasets/util.hpp"
#include "precomp.hpp"
namespace cv
{
namespace datasetstools
namespace datasets
{
using namespace std;
......
......@@ -39,12 +39,13 @@
//
//M*/
#include "opencv2/datasetstools/ir_affine.hpp"
#include "opencv2/datasets/ir_affine.hpp"
#include "opencv2/datasets/util.hpp"
#include "precomp.hpp"
namespace cv
{
namespace datasetstools
namespace datasets
{
using namespace std;
......
......@@ -39,12 +39,13 @@
//
//M*/
#include "opencv2/datasetstools/ir_robot.hpp"
#include "opencv2/datasets/ir_robot.hpp"
#include "opencv2/datasets/util.hpp"
#include "precomp.hpp"
namespace cv
{
namespace datasetstools
namespace datasets
{
using namespace std;
......
......@@ -39,12 +39,13 @@
//
//M*/
#include "opencv2/datasetstools/is_bsds.hpp"
#include "opencv2/datasets/is_bsds.hpp"
#include "opencv2/datasets/util.hpp"
#include "precomp.hpp"
namespace cv
{
namespace datasetstools
namespace datasets
{
using namespace std;
......
......@@ -39,12 +39,13 @@
//
//M*/
#include "opencv2/datasetstools/is_weizmann.hpp"
#include "opencv2/datasets/is_weizmann.hpp"
#include "opencv2/datasets/util.hpp"
#include "precomp.hpp"
namespace cv
{
namespace datasetstools
namespace datasets
{
using namespace std;
......
......@@ -39,12 +39,13 @@
//
//M*/
#include "opencv2/datasetstools/msm_epfl.hpp"
#include "opencv2/datasets/msm_epfl.hpp"
#include "opencv2/datasets/util.hpp"
#include "precomp.hpp"
namespace cv
{
namespace datasetstools
namespace datasets
{
using namespace std;
......
......@@ -39,12 +39,13 @@
//
//M*/
#include "opencv2/datasetstools/msm_middlebury.hpp"
#include "opencv2/datasets/msm_middlebury.hpp"
#include "opencv2/datasets/util.hpp"
#include "precomp.hpp"
namespace cv
{
namespace datasetstools
namespace datasets
{
using namespace std;
......
......@@ -39,12 +39,13 @@
//
//M*/
#include "opencv2/datasetstools/or_imagenet.hpp"
#include "opencv2/datasets/or_imagenet.hpp"
#include "opencv2/datasets/util.hpp"
#include "precomp.hpp"
namespace cv
{
namespace datasetstools
namespace datasets
{
using namespace std;
......
......@@ -39,12 +39,13 @@
//
//M*/
#include "opencv2/datasetstools/or_mnist.hpp"
#include "opencv2/datasets/or_mnist.hpp"
#include "opencv2/datasets/util.hpp"
#include "precomp.hpp"
namespace cv
{
namespace datasetstools
namespace datasets
{
using namespace std;
......
......@@ -39,12 +39,13 @@
//
//M*/
#include "opencv2/datasetstools/or_sun.hpp"
#include "opencv2/datasets/or_sun.hpp"
#include "opencv2/datasets/util.hpp"
#include "precomp.hpp"
namespace cv
{
namespace datasetstools
namespace datasets
{
using namespace std;
......
/*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"
#include "precomp.hpp"
namespace cv
{
namespace datasets
{
using namespace std;
class CV_EXPORTS PD_caltechImp : public PD_caltech
{
public:
PD_caltechImp() {}
//PD_caltechImp(const string &path);
virtual ~PD_caltechImp() {}
virtual void load(const string &path);
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);
}
}
}
......@@ -47,6 +47,4 @@
#include <fstream>
#include "opencv2/datasetstools/util.hpp"
#endif
......@@ -39,12 +39,13 @@
//
//M*/
#include "opencv2/datasetstools/slam_kitti.hpp"
#include "opencv2/datasets/slam_kitti.hpp"
#include "opencv2/datasets/util.hpp"
#include "precomp.hpp"
namespace cv
{
namespace datasetstools
namespace datasets
{
using namespace std;
......
......@@ -39,14 +39,15 @@
//
//M*/
#include "opencv2/datasetstools/slam_tumindoor.hpp"
#include "opencv2/datasets/slam_tumindoor.hpp"
#include "opencv2/datasets/util.hpp"
#include "precomp.hpp"
#include <cstring>
namespace cv
{
namespace datasetstools
namespace datasets
{
using namespace std;
......
......@@ -21,7 +21,7 @@ must not be misrepresented as being the original software.
distribution.
*/
#include "opencv2/datasetstools/tinyxml2/tinyxml2.h"
#include "opencv2/datasets/tinyxml2/tinyxml2.h"
#include <new> // yes, this one new style header, is in the Android SDK.
# ifdef ANDROID_NDK
......
......@@ -39,12 +39,13 @@
//
//M*/
#include "opencv2/datasetstools/tr_chars.hpp"
#include "opencv2/datasets/tr_chars.hpp"
#include "opencv2/datasets/util.hpp"
#include "precomp.hpp"
namespace cv
{
namespace datasetstools
namespace datasets
{
using namespace std;
......
......@@ -39,14 +39,15 @@
//
//M*/
#include "opencv2/datasetstools/tr_svt.hpp"
#include "opencv2/datasets/tr_svt.hpp"
#include "opencv2/datasets/util.hpp"
#include "precomp.hpp"
#include <opencv2/datasetstools/tinyxml2/tinyxml2.h>
#include <opencv2/datasets/tinyxml2/tinyxml2.h>
namespace cv
{
namespace datasetstools
namespace datasets
{
using namespace std;
......
......@@ -39,7 +39,7 @@
//
//M*/
#include "opencv2/datasetstools/util.hpp"
#include "opencv2/datasets/util.hpp"
#include <cstdlib>
......@@ -48,6 +48,7 @@
#ifdef __GNUC__
#include <unistd.h>
#include <dirent.h>
#include <sys/stat.h>
#else
#include <io.h>
#include <direct.h>
......@@ -55,7 +56,7 @@
namespace cv
{
namespace datasetstools
namespace datasets
{
using namespace std;
......@@ -70,6 +71,15 @@ void split(const string &s, vector<string> &elems, char delim)
}
}
void createDirectory(const string &path)
{
#ifdef __GNUC__
mkdir(path.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
#else
mkdir(path.c_str());
#endif
}
void getDirList(const string &dirName, vector<string> &fileNames)
{
#ifdef __GNUC__
......
set(the_description "datasets tools")
ocv_define_module(datasetstools opencv_core)
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment