VisionWorks Toolkit Reference

December 18, 2015 | 1.2 Release

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
FrameSource.hpp
Go to the documentation of this file.
1 /*
2 # Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved.
3 #
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions
6 # are met:
7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above copyright
10 # notice, this list of conditions and the following disclaimer in the
11 # documentation and/or other materials provided with the distribution.
12 # * Neither the name of NVIDIA CORPORATION nor the names of its
13 # contributors may be used to endorse or promote products derived
14 # from this software without specific prior written permission.
15 #
16 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
17 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23 # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
24 # OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28 
29 #ifndef NVXIO_FRAMESOURCE_HPP
30 #define NVXIO_FRAMESOURCE_HPP
31 
32 #include <memory>
33 #include <string>
34 
35 #include <VX/vx.h>
36 
42 namespace nvxio
43 {
81 {
82 public:
86  struct Parameters
87  {
94  frameWidth(-1),
95  frameHeight(-1),
97  fps(-1)
98  {}
99  };
100 
105  {
111  };
112 
117  {
118  OK,
121  };
122 
126  virtual bool open() = 0;
127 
138  virtual FrameSource::FrameStatus fetch(vx_image image, vx_uint32 timeout = 5 /*milliseconds*/) = 0;
139 
146 
154  virtual bool setConfiguration(const FrameSource::Parameters& params) = 0;
155 
159  virtual void close() = 0;
160 
164  virtual ~FrameSource()
165  {}
166 
173  {
174  return sourceType;
175  }
176 
182  std::string getSourceName() const
183  {
184  return sourceName;
185  }
186 
187 protected:
188  FrameSource(FrameSource::SourceType type = FrameSource::UNKNOWN_SOURCE, const std::string & name = "Undefined"):
189  sourceType(type),
190  sourceName(name)
191  {}
192 
194  const std::string sourceName;
195 };
196 
215 std::unique_ptr<FrameSource> createDefaultFrameSource(vx_context context, const std::string& uri);
216 
230 vx_image loadImageFromFile(vx_context context, const std::string& fileName, vx_df_image format = VX_DF_IMAGE_RGB);
231 
232 }
233 
234 #endif // NVXIO_FRAMESOURCE_HPP
struct _vx_image * vx_image
An opaque reference to an image.
Definition: vx_types.h:186
Indicates a timeout has been exceeded.
FrameSource(FrameSource::SourceType type=FrameSource::UNKNOWN_SOURCE, const std::string &name="Undefined")
std::string getSourceName() const
Returns the source name of the FrameSource.
Indicates a video file.
Indicates a sequence of images.
FrameStatus
Defines the status of read operations.
FrameSource parameters.
Definition: FrameSource.hpp:86
struct _vx_context * vx_context
An opaque reference to the implementation context.
Definition: vx_types.h:222
Indicates an unknown source.
vx_uint32 frameHeight
Holds the height of the frame.
Definition: FrameSource.hpp:89
uint32_t vx_df_image
Used to hold a VX_DF_IMAGE code to describe the pixel format and color space.
Definition: vx_types.h:171
A single plane of 24-bit pixel as 3 interleaved 8-bit units of R then G then B data. This uses the BT709 full range by default.
Definition: vx_types.h:636
virtual void close()=0
Closes the FrameSource.
A single plane of 32-bit pixel as 4 interleaved 8-bit units of R then G then B data, then a don't care byte. This uses the BT709 full range by default.
Definition: vx_types.h:641
Indicates the frame source has been closed.
virtual FrameSource::Parameters getConfiguration()=0
Gets the configuration of the FrameSource.
vx_image loadImageFromFile(vx_context context, const std::string &fileName, vx_df_image format=VX_DF_IMAGE_RGB)
Loads image from file into OpenVX Image object.
The top level OpenVX Header.
Indicates the frame has been read successfully.
std::unique_ptr< FrameSource > createDefaultFrameSource(vx_context context, const std::string &uri)
FrameSource interface factory that provides appropriate implementation by source URI.
const std::string sourceName
uint32_t vx_uint32
A 32-bit unsigned value.
Definition: vx_types.h:100
FrameSource interface.
Definition: FrameSource.hpp:80
vx_uint32 fps
Holds the FPS (for video only).
Definition: FrameSource.hpp:91
virtual FrameSource::FrameStatus fetch(vx_image image, vx_uint32 timeout=5)=0
Fetches frames from the source.
virtual ~FrameSource()
Destructor.
virtual bool open()=0
Opens the FrameSource.
SourceType
Defines the type of source.
const FrameSource::SourceType sourceType
vx_df_image format
Holds the format of the frame.
Definition: FrameSource.hpp:90
virtual bool setConfiguration(const FrameSource::Parameters &params)=0
Sets the configuration of the FrameSource.
vx_uint32 frameWidth
Holds the width of the frame.
Definition: FrameSource.hpp:88
FrameSource::SourceType getSourceType() const
Returns the source type of the FrameSource.