* This is destination blob. It can be part of top blob's data if
* set_cpu_data() is used. See memory_layer.cpp for an example.
*/
-#ifndef OSX
void Transform(const vector<cv::Mat> & mat_vector,
Blob<Dtype>* transformed_blob);
-#endif
/**
* @brief Applies the transformation defined in the data layer's
* transform_param block to a cv::Mat
protected:
/**
* @brief Generates a random integer from Uniform({0, 1, ..., n-1}).
- *
+ *
* @param n
* The upperbound (exclusive) value of the random number.
* @return
const int width = transformed_blob->width();
CHECK_GT(datum_num, 0) << "There is no datum to add";
- CHECK_EQ(datum_num, num) <<
- "The size of datum_vector must be equals to transformed_blob->num()";
+ CHECK_LE(datum_num, num) <<
+ "The size of datum_vector must be no greater than transformed_blob->num()";
Blob<Dtype> uni_blob(1, channels, height, width);
for (int item_id = 0; item_id < datum_num; ++item_id) {
int offset = transformed_blob->offset(item_id);
}
}
-#ifndef OSX
template<typename Dtype>
void DataTransformer<Dtype>::Transform(const vector<cv::Mat> & mat_vector,
Blob<Dtype>* transformed_blob) {
Transform(mat_vector[item_id], &uni_blob);
}
}
-#endif
template<typename Dtype>
void DataTransformer<Dtype>::Transform(const cv::Mat& cv_img,
+#include <opencv2/core/core.hpp>
+
#include <vector>
#include "caffe/data_layers.hpp"
template <typename Dtype>
void MemoryDataLayer<Dtype>::AddDatumVector(const vector<Datum>& datum_vector) {
CHECK(!has_new_data_) <<
- "Can't add Datum when earlier ones haven't been consumed"
- << " by the upper layers";
+ "Can't add data until current data has been consumed.";
size_t num = datum_vector.size();
- CHECK_GT(num, 0) << "There is no datum to add";
+ CHECK_GT(num, 0) << "There is no datum to add.";
CHECK_EQ(num % batch_size_, 0) <<
- "The number of added datum must be multiple of the batch size";
+ "The added data must be a multiple of the batch size.";
added_data_.Reshape(num, channels_, height_, width_);
added_label_.Reshape(num, 1, 1, 1);
// Apply data transformations (mirror, scale, crop...)
const vector<int>& labels) {
size_t num = mat_vector.size();
CHECK(!has_new_data_) <<
- "Can't add Mat when earlier ones haven't been consumed"
- << " by the upper layers";
- CHECK_EQ(num % batch_size_, 0) <<
- "The number of added datum must be multiple of the batch size";
+ "Can't add mat until current data has been consumed.";
CHECK_GT(num, 0) << "There is no mat to add";
+ CHECK_EQ(num % batch_size_, 0) <<
+ "The added data must be a multiple of the batch size.";
added_data_.Reshape(num, channels_, height_, width_);
added_label_.Reshape(num, 1, 1, 1);
// Apply data transformations (mirror, scale, crop...)
template <typename Dtype>
void MemoryDataLayer<Dtype>::set_batch_size(int new_size) {
CHECK(!has_new_data_) <<
- "Can't change batch_size before all data haven't been consumed"
- << " by the upper layers";
+ "Can't change batch_size until current data has been consumed.";
batch_size_ = new_size;
added_data_.Reshape(batch_size_, channels_, height_, width_);
added_label_.Reshape(batch_size_, 1, 1, 1);