data_transformer.hpp
#ifndef CAFFE_DATA_TRANSFORMER_HPP
#define CAFFE_DATA_TRANSFORMER_HPP
#include <vector>
#include "caffe/blob.hpp"
#include "caffe/common.hpp"
#include "caffe/proto/caffe.pb.h"
namespace caffe {
template <typename Dtype>
class DataTransformer {
public:
explicit DataTransformer(const TransformationParameter& param, Phase phase);
virtual ~DataTransformer() {}
void InitRand();
void Transform(const Datum& datum, Blob<Dtype>* transformed_blob);
void Transform(const vector<Datum> & datum_vector,
Blob<Dtype>* transformed_blob);
#ifdef USE_OPENCV
void Transform(const vector<cv::Mat> & mat_vector,
Blob<Dtype>* transformed_blob);
void Transform(const cv::Mat& cv_img, Blob<Dtype>* transformed_blob);
#endif // USE_OPENCV
void Transform(Blob<Dtype>* input_blob, Blob<Dtype>* transformed_blob);
vector<int> InferBlobShape(const Datum& datum);
vector<int> InferBlobShape(const vector<Datum> & datum_vector);
#ifdef USE_OPENCV
vector<int> InferBlobShape(const vector<cv::Mat> & mat_vector);
vector<int> InferBlobShape(const cv::Mat& cv_img);
#endif // USE_OPENCV
protected:
virtual int Rand(int n);
void Transform(const Datum& datum, Dtype* transformed_data);
// Tranformation parameters
TransformationParameter param_;
shared_ptr<Caffe::RNG> rng_;
Phase phase_;
Blob<Dtype> data_mean_;
vector<Dtype> mean_values_;
};
} // namespace caffe
#endif // CAFFE_DATA_TRANSFORMER_HPP_
caffe::DataTransformer::Rand
virtual int Rand(int n)
Infers the shape of transformed_blob will have when the transformation is applied to the data....
Definition: data_transformer.cpp:535
caffe::DataTransformer::InferBlobShape
vector< int > InferBlobShape(const Datum &datum)
Infers the shape of transformed_blob will have when the transformation is applied to the data.
Definition: data_transformer.cpp:442
caffe::Blob
A wrapper around SyncedMemory holders serving as the basic computational unit through which Layers,...
Definition: blob.hpp:24
caffe::DataTransformer::Transform
void Transform(const Datum &datum, Blob< Dtype > *transformed_blob)
Applies the transformation defined in the data layer's transform_param block to the data.
Definition: data_transformer.cpp:131
caffe::DataTransformer::InitRand
void InitRand()
Initialize the Random number generations if needed by the transformation.
Definition: data_transformer.cpp:523
caffe::DataTransformer
Applies common transformations to the input data, such as scaling, mirroring, substracting the image ...
Definition: data_transformer.hpp:17
caffe
A layer factory that allows one to register layers. During runtime, registered layers can be called b...
Definition: blob.hpp:14