| 39 | } |
| 40 | |
| 41 | std::shared_ptr<ImageBatchVarShape> ImageBatchVarShape::Create(int capacity) |
| 42 | { |
| 43 | std::vector<std::shared_ptr<CacheItem>> vcont = Cache::Instance().fetch(Key{capacity}); |
| 44 | |
| 45 | // None found? |
| 46 | if (vcont.empty()) |
| 47 | { |
| 48 | std::shared_ptr<ImageBatchVarShape> batch(new ImageBatchVarShape(capacity)); |
| 49 | Cache::Instance().add(*batch); |
| 50 | return batch; |
| 51 | } |
| 52 | else |
| 53 | { |
| 54 | // Get the first one |
| 55 | auto batch = std::static_pointer_cast<ImageBatchVarShape>(vcont[0]); |
| 56 | Image::Key key; |
| 57 | batch->clear(); // make sure it's in pristine state |
| 58 | return batch; |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | std::shared_ptr<ImageBatchVarShape> ImageBatchVarShape::WrapExternalBufferVector(std::vector<py::object> buffers, |
| 63 | nvcv::ImageFormat fmt) |