Apollo 11.0
自动驾驶开放平台
util.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16#pragma once
17
18#include <fstream>
19#include <map>
20#include <memory>
21#include <string>
22#include <vector>
23
26
27namespace apollo {
28namespace perception {
29namespace inference {
30
31template <typename T>
32void load_data(const std::string &filename, std::vector<T> *outputs) {
33 std::ifstream ifs(filename, std::ifstream::in);
34
35 if (ifs.good()) {
36 outputs->clear();
37 T output;
38 while (ifs >> output) {
39 outputs->push_back(output);
40 }
41 ifs.close();
42 }
43}
44
45std::shared_ptr<float> load_binary_data(const std::string &filename);
46
47bool write_result(const std::string &out_path,
48 const std::vector<float> &results);
49bool write_result(const std::string &out_path,
50 const std::map<std::string, std::vector<float>> &results);
51} // namespace inference
52} // namespace perception
53} // namespace apollo
std::shared_ptr< float > load_binary_data(const std::string &filename)
Definition util.cc:24
bool write_result(const std::string &out_path, const std::vector< float > &results)
Definition util.cc:40
void load_data(const std::string &filename, std::vector< T > *outputs)
Definition util.h:32
class register implement
Definition arena_queue.h:37