VisionWorks Toolkit Reference

April 8, 2016 | 1.4 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-2016, 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 #include <NVXIO/Export.hpp>
37 
43 namespace nvxio
44 {
115 class NVXIO_EXPORT FrameSource
116 {
117 public:
121  struct Parameters
122  {
129  frameWidth(-1),
130  frameHeight(-1),
131  format(VX_DF_IMAGE_VIRT),
132  fps(-1)
133  {}
134  };
135 
140  {
145  CAMERA_SOURCE
146  };
147 
152  {
153  OK,
155  CLOSED
156  };
157 
161  virtual bool open() = 0;
162 
170  virtual FrameSource::FrameStatus fetch(vx_image image, vx_uint32 timeout = 5 /*milliseconds*/) = 0;
171 
177  virtual FrameSource::Parameters getConfiguration() = 0;
178 
186  virtual bool setConfiguration(const FrameSource::Parameters& params) = 0;
187 
191  virtual void close() = 0;
192 
196  virtual ~FrameSource()
197  {}
198 
205  {
206  return sourceType;
207  }
208 
214  std::string getSourceName() const
215  {
216  return sourceName;
217  }
218 
219 protected:
220  FrameSource(FrameSource::SourceType type = FrameSource::UNKNOWN_SOURCE, const std::string & name = "Undefined"):
221  sourceType(type),
222  sourceName(name)
223  {}
224 
226  const std::string sourceName;
227 };
228 
248 NVXIO_EXPORT std::unique_ptr<FrameSource> createDefaultFrameSource(vx_context context, const std::string& uri);
249 
263 NVXIO_EXPORT vx_image loadImageFromFile(vx_context context, const std::string& fileName, vx_df_image format = VX_DF_IMAGE_RGB);
264 
265 }
266 
267 #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.
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.
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
A virtual image of no defined type.
Definition: vx_types.h:632
NVXIO_EXPORT std::unique_ptr< FrameSource > createDefaultFrameSource(vx_context context, const std::string &uri)
FrameSource interface factory that provides appropriate implementation by source URI.
The top level OpenVX Header.
Indicates the frame has been read successfully.
NVXIO_EXPORT 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.
const std::string sourceName
uint32_t vx_uint32
A 32-bit unsigned value.
Definition: vx_types.h:100
FrameSource interface.
vx_uint32 fps
Holds the FPS (for video only).
virtual ~FrameSource()
Destructor.
SourceType
Defines the type of source.
const FrameSource::SourceType sourceType
vx_df_image format
Holds the format of the frame.
vx_uint32 frameWidth
Holds the width of the frame.
FrameSource::SourceType getSourceType() const
Returns the source type of the FrameSource.