MCPcopy Create free account
hub / github.com/BVLC/caffe / DecodeDatumToCVMat

Function DecodeDatumToCVMat

src/caffe/util/io.cpp:177–189  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

175 return cv_img;
176}
177cv::Mat DecodeDatumToCVMat(const Datum& datum, bool is_color) {
178 cv::Mat cv_img;
179 CHECK(datum.encoded()) << "Datum not encoded";
180 const string& data = datum.data();
181 std::vector<char> vec_data(data.c_str(), data.c_str() + data.size());
182 int cv_read_flag = (is_color ? CV_LOAD_IMAGE_COLOR :
183 CV_LOAD_IMAGE_GRAYSCALE);
184 cv_img = cv::imdecode(vec_data, cv_read_flag);
185 if (!cv_img.data) {
186 LOG(ERROR) << "Could not decode datum ";
187 }
188 return cv_img;
189}
190
191// If Datum is encoded will decoded using DecodeDatumToCVMat and CVMatToDatum
192// If Datum is not encoded will do nothing

Callers 5

TransformMethod · 0.85
InferBlobShapeMethod · 0.85
TEST_FFunction · 0.85
load_batchMethod · 0.85
DecodeDatumFunction · 0.85

Calls 2

dataMethod · 0.80
sizeMethod · 0.45

Tested by 1

TEST_FFunction · 0.68