Apollo  6.0
Open source self driving car software
batch_stream.h
Go to the documentation of this file.
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 
17 #pragma once
18 
19 #include <string>
20 #include <vector>
21 
22 #include "NvInfer.h"
23 
24 namespace apollo {
25 namespace perception {
26 namespace inference {
27 
28 class BatchStream {
29  public:
30  BatchStream(int batchSize, int maxBatches, std::string data_path);
31  BatchStream();
32 
33  // @brief reset current batch id
34  void reset(int firstBatch);
35 
36  // @brief get next batch
37  bool next();
38 
39  // @brief skip `skipCount` batches
40  void skip(int skipCount);
41 
42  float *getBatch() { return &mBatch[0]; }
43  int getBatchesRead() const { return mBatchCount; }
44  int getBatchSize() const { return mBatchSize; }
45  nvinfer1::DimsNCHW getDims() const { return mDims; }
46 
47  private:
48  float *getFileBatch() { return &mFileBatch[0]; }
49 
50  bool update();
51 
52  int mBatchSize{0};
53  int mMaxBatches{0};
54  int mBatchCount{0};
55 
56  int mFileCount{0};
57  int mFileBatchPos{0};
58  int mImageSize{0};
59 
60  nvinfer1::DimsNCHW mDims;
61  std::vector<float> mBatch;
62  std::vector<float> mFileBatch;
63  std::string mPath;
64 };
65 
66 } // namespace inference
67 } // namespace perception
68 } // namespace apollo
int getBatchesRead() const
Definition: batch_stream.h:43
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
Definition: batch_stream.h:28
float * getBatch()
Definition: batch_stream.h:42
int getBatchSize() const
Definition: batch_stream.h:44
nvinfer1::DimsNCHW getDims() const
Definition: batch_stream.h:45