| 56 | #ifdef USE_OPENCV |
| 57 | template <typename Dtype> |
| 58 | void MemoryDataLayer<Dtype>::AddMatVector(const vector<cv::Mat>& mat_vector, |
| 59 | const vector<int>& labels) { |
| 60 | size_t num = mat_vector.size(); |
| 61 | CHECK(!has_new_data_) << |
| 62 | "Can't add mat until current data has been consumed."; |
| 63 | CHECK_GT(num, 0) << "There is no mat to add"; |
| 64 | CHECK_EQ(num % batch_size_, 0) << |
| 65 | "The added data must be a multiple of the batch size."; |
| 66 | added_data_.Reshape(num, channels_, height_, width_); |
| 67 | added_label_.Reshape(num, 1, 1, 1); |
| 68 | // Apply data transformations (mirror, scale, crop...) |
| 69 | this->data_transformer_->Transform(mat_vector, &added_data_); |
| 70 | // Copy Labels |
| 71 | Dtype* top_label = added_label_.mutable_cpu_data(); |
| 72 | for (int item_id = 0; item_id < num; ++item_id) { |
| 73 | top_label[item_id] = labels[item_id]; |
| 74 | } |
| 75 | // num_images == batch_size_ |
| 76 | Dtype* top_data = added_data_.mutable_cpu_data(); |
| 77 | Reset(top_data, top_label, num); |
| 78 | has_new_data_ = true; |
| 79 | } |
| 80 | #endif // USE_OPENCV |
| 81 | |
| 82 | template <typename Dtype> |