Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ $ cmake -D OPENCV_EXTRA_MODULES_PATH=<opencv_contrib>/modules -D BUILD_opencv_<r

- **datasets**: Datasets Reader -- Code for reading existing computer vision databases and samples of using the readers to train, test and run using that dataset's data.

- **dnn_objdetect**: Object Detection using CNNs -- Implements compact CNN Model for object detection. Trained using Caffe but uses opencv_dnn modeule.
- **dnn_objdetect**: Object Detection using CNNs -- Implements compact CNN Model for object detection. Trained using Caffe but uses opencv_dnn module.

- **dnn_superres**: Superresolution using CNNs -- Contains four trained convolutional neural networks to upscale images.

Expand Down
47 changes: 47 additions & 0 deletions modules/datasets/include/opencv2/datasets/dataset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,53 @@ Implements loading dataset:
./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
Expand Down
41 changes: 41 additions & 0 deletions modules/datasets/include/opencv2/datasets/sr_bsds.hpp
Original file line number Diff line number Diff line change
@@ -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
41 changes: 41 additions & 0 deletions modules/datasets/include/opencv2/datasets/sr_div2k.hpp
Original file line number Diff line number Diff line change
@@ -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
41 changes: 41 additions & 0 deletions modules/datasets/include/opencv2/datasets/sr_general100.hpp
Original file line number Diff line number Diff line change
@@ -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
50 changes: 50 additions & 0 deletions modules/datasets/samples/sr_bsds.cpp
Original file line number Diff line number Diff line change
@@ -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 changes: 47 additions & 0 deletions modules/datasets/samples/sr_div2k.cpp
Original file line number Diff line number Diff line change
@@ -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;
}
47 changes: 47 additions & 0 deletions modules/datasets/samples/sr_general100.cpp
Original file line number Diff line number Diff line change
@@ -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;
}
Loading