Jetson Inference
DNN Vision Library
imageLoader.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20  * DEALINGS IN THE SOFTWARE.
21  */
22 
23 #ifndef __IMAGE_LOADER_H_
24 #define __IMAGE_LOADER_H_
25 
26 
27 #include "videoSource.h"
28 
29 #include <string>
30 #include <vector>
31 
32 
52 class imageLoader : public videoSource
53 {
54 public:
58  static imageLoader* Create( const char* path, const videoOptions& options=videoOptions() );
59 
63  static imageLoader* Create( const videoOptions& options );
64 
68  virtual ~imageLoader();
69 
74  virtual bool Capture( void** image, imageFormat format, uint64_t timeout=DEFAULT_TIMEOUT, int* status=NULL );
75 
80  virtual bool Open();
81 
86  virtual void Close();
87 
94  inline bool IsEOS() const { return mEOS; }
95 
99  virtual inline uint32_t GetType() const { return Type; }
100 
104  static const uint32_t Type = (1 << 4);
105 
122  static const char* SupportedExtensions[];
123 
129  static bool IsSupportedExtension( const char* ext );
130 
131 protected:
132  imageLoader( const videoOptions& options );
133 
134  inline bool isLooping() const { return (mOptions.loop < 0) || ((mOptions.loop > 0) && (mLoopCount < mOptions.loop)); }
135 
136  bool mEOS;
137  size_t mLoopCount;
138  size_t mNextFile;
139 
140  std::vector<std::string> mFiles;
141  std::vector<void*> mBuffers;
142 };
143 
144 #endif
videoSource.h
imageLoader
Load an image or set of images from disk into GPU memory.
Definition: imageLoader.h:52
imageLoader::mLoopCount
size_t mLoopCount
Definition: imageLoader.h:137
imageLoader::IsEOS
bool IsEOS() const
Return true if End Of Stream (EOS) has been reached.
Definition: imageLoader.h:94
imageLoader::isLooping
bool isLooping() const
Definition: imageLoader.h:134
imageLoader::Close
virtual void Close()
Close the stream.
imageLoader::Type
static const uint32_t Type
Unique type identifier of imageLoader class.
Definition: imageLoader.h:104
imageLoader::GetType
virtual uint32_t GetType() const
Return the interface type (imageLoader::Type)
Definition: imageLoader.h:99
imageLoader::SupportedExtensions
static const char * SupportedExtensions[]
String array of supported image file extensions, terminated with a NULL sentinel value.
Definition: imageLoader.h:122
imageLoader::Create
static imageLoader * Create(const char *path, const videoOptions &options=videoOptions())
Create an imageLoader instance from a path and optional videoOptions.
imageLoader::mFiles
std::vector< std::string > mFiles
Definition: imageLoader.h:140
imageLoader::mEOS
bool mEOS
Definition: imageLoader.h:136
imageLoader::mNextFile
size_t mNextFile
Definition: imageLoader.h:138
imageLoader::~imageLoader
virtual ~imageLoader()
Destructor.
imageLoader::Capture
virtual bool Capture(void **image, imageFormat format, uint64_t timeout=DEFAULT_TIMEOUT, int *status=NULL)
Load the next frame.
videoOptions::loop
int loop
Control the number of loops for videoSource disk-based inputs (for example, the number of times that ...
Definition: videoOptions.h:119
videoSource::mOptions
videoOptions mOptions
Definition: videoSource.h:378
imageLoader::IsSupportedExtension
static bool IsSupportedExtension(const char *ext)
Return true if the extension is in the list of SupportedExtensions.
videoSource::DEFAULT_TIMEOUT
static const uint64_t DEFAULT_TIMEOUT
The default Capture timeout (1000ms)
Definition: videoSource.h:371
videoOptions
The videoOptions struct contains common settings that are used to configure and query videoSource and...
Definition: videoOptions.h:37
imageLoader::imageLoader
imageLoader(const videoOptions &options)
imageFormat
imageFormat
The imageFormat enum is used to identify the pixel format and colorspace of an image.
Definition: imageFormat.h:49
imageLoader::Open
virtual bool Open()
Open the stream.
imageLoader::mBuffers
std::vector< void * > mBuffers
Definition: imageLoader.h:141
videoSource
The videoSource API is for capturing frames from video input devices such as MIPI CSI cameras,...
Definition: videoSource.h:118