MCPcopy Create free account
hub / github.com/OpenPTrack/open_ptrack_v2 / ReadImageToDatum

Function ReadImageToDatum

rtpose_wrapper/src/caffe/util/io.cpp:119–142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

117}
118
119bool ReadImageToDatum(const string& filename, const int label,
120 const int height, const int width, const bool is_color,
121 const std::string & encoding, Datum* datum) {
122 cv::Mat cv_img = ReadImageToCVMat(filename, height, width, is_color);
123 if (cv_img.data) {
124 if (encoding.size()) {
125 if ( (cv_img.channels() == 3) == is_color && !height && !width &&
126 matchExt(filename, encoding) )
127 return ReadFileToDatum(filename, label, datum);
128 std::vector<uchar> buf;
129 cv::imencode("."+encoding, cv_img, buf);
130 datum->set_data(std::string(reinterpret_cast<char*>(&buf[0]),
131 buf.size()));
132 datum->set_label(label);
133 datum->set_encoded(true);
134 return true;
135 }
136 CVMatToDatum(cv_img, datum);
137 datum->set_label(label);
138 return true;
139 } else {
140 return false;
141 }
142}
143#endif // USE_OPENCV
144
145bool ReadFileToDatum(const string& filename, const int label,

Callers 3

mainFunction · 0.50
TEST_FFunction · 0.50
SetUpMethod · 0.50

Calls 6

ReadImageToCVMatFunction · 0.85
matchExtFunction · 0.85
CVMatToDatumFunction · 0.85
ReadFileToDatumFunction · 0.70
sizeMethod · 0.45
channelsMethod · 0.45

Tested by 2

TEST_FFunction · 0.40
SetUpMethod · 0.40