From dd13fa07ca41809d886486a1bdb65ce3e82e105d Mon Sep 17 00:00:00 2001 From: Kai Li Date: Wed, 26 Feb 2014 05:55:58 +0800 Subject: [PATCH] Fix saving real valued feature bug in the feature extraction example --- examples/demo_extract_features.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/examples/demo_extract_features.cpp b/examples/demo_extract_features.cpp index d16ee70..088cc28 100644 --- a/examples/demo_extract_features.cpp +++ b/examples/demo_extract_features.cpp @@ -137,20 +137,16 @@ int feature_extraction_pipeline(int argc, char** argv) { datum.set_channels(1); datum.clear_data(); datum.clear_float_data(); - string* datum_string = datum.mutable_data(); const Dtype* feature_blob_data = feature_blob->cpu_data(); for (int d = 0; d < dim_features; ++d) { - const char* data_byte = reinterpret_cast(feature_blob_data - + d); - for (int i = 0; i < num_bytes_of_binary_code; ++i) { - datum_string->push_back(data_byte[i]); - } + datum.add_float_data(feature_blob_data[d]); } string value; datum.SerializeToString(&value); snprintf(key_str, max_key_str_length, "%d", image_index); batch->Put(string(key_str), value); - if (++image_index % 1000 == 0) { + ++image_index; + if (image_index % 1000 == 0) { db->Write(leveldb::WriteOptions(), batch); LOG(ERROR)<< "Extracted features of " << image_index << " query images."; delete batch; -- 2.7.4