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

Function main

rtpose_wrapper/tools/compute_image_mean.cpp:24–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22 "The backend {leveldb, lmdb} containing the images");
23
24int main(int argc, char** argv) {
25 ::google::InitGoogleLogging(argv[0]);
26
27#ifdef USE_OPENCV
28#ifndef GFLAGS_GFLAGS_H_
29 namespace gflags = google;
30#endif
31
32 gflags::SetUsageMessage("Compute the mean_image of a set of images given by"
33 " a leveldb/lmdb\n"
34 "Usage:\n"
35 " compute_image_mean [FLAGS] INPUT_DB [OUTPUT_FILE]\n");
36
37 gflags::ParseCommandLineFlags(&argc, &argv, true);
38
39 if (argc < 2 || argc > 3) {
40 gflags::ShowUsageWithFlagsRestrict(argv[0], "tools/compute_image_mean");
41 return 1;
42 }
43
44 scoped_ptr<db::DB> db(db::GetDB(FLAGS_backend));
45 db->Open(argv[1], db::READ);
46 scoped_ptr<db::Cursor> cursor(db->NewCursor());
47
48 BlobProto sum_blob;
49 int count = 0;
50 // load first datum
51 Datum datum;
52 datum.ParseFromString(cursor->value());
53
54 if (DecodeDatumNative(&datum)) {
55 LOG(INFO) << "Decoding Datum";
56 }
57
58 sum_blob.set_num(1);
59 sum_blob.set_channels(datum.channels());
60 sum_blob.set_height(datum.height());
61 sum_blob.set_width(datum.width());
62 const int data_size = datum.channels() * datum.height() * datum.width();
63 int size_in_datum = std::max<int>(datum.data().size(),
64 datum.float_data_size());
65 for (int i = 0; i < size_in_datum; ++i) {
66 sum_blob.add_data(0.);
67 }
68 LOG(INFO) << "Starting Iteration";
69 while (cursor->valid()) {
70 Datum datum;
71 datum.ParseFromString(cursor->value());
72 DecodeDatumNative(&datum);
73
74 const std::string& data = datum.data();
75 size_in_datum = std::max<int>(datum.data().size(),
76 datum.float_data_size());
77 CHECK_EQ(size_in_datum, data_size) << "Incorrect data field size " <<
78 size_in_datum;
79 if (data.size() != 0) {
80 CHECK_EQ(data.size(), size_in_datum);
81 for (int i = 0; i < size_in_datum; ++i) {

Callers

nothing calls this directly

Calls 13

GetDBFunction · 0.85
DecodeDatumNativeFunction · 0.85
dataMethod · 0.80
WriteProtoToBinaryFileFunction · 0.50
OpenMethod · 0.45
NewCursorMethod · 0.45
valueMethod · 0.45
channelsMethod · 0.45
heightMethod · 0.45
widthMethod · 0.45
sizeMethod · 0.45
validMethod · 0.45

Tested by

no test coverage detected