VisionWorks Toolkit Reference

April 8, 2016 | 1.4 Release

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Render.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_RENDER_HPP
30 #define NVXIO_RENDER_HPP
31 
32 #include <memory>
33 #include <string>
34 
35 #include <VX/vx.h>
36 #include <NVXIO/Export.hpp>
37 
38 #ifndef __ANDROID__
39 #include <NVXIO/Application.hpp>
40 #endif
41 
47 namespace nvxio
48 {
73 class NVXIO_EXPORT Render
74 {
75 public:
76 
81  {
85  IMAGE_RENDER
86  };
87 
92  struct TextBoxStyle
93  {
94  vx_uint8 color[4];
95  vx_uint8 bgcolor[4];
97  };
98 
104  {
105  vx_uint8 color[4];
106  float radius;
107  };
108 
113  struct LineStyle
114  {
115  vx_uint8 color[4];
116  int thickness;
117  };
118 
124  {
125  vx_uint8 color[4];
126  };
127 
128 
134  {
136  std::string label;
138  vx_uint8 color[4];
145  };
146 
151  struct CircleStyle
152  {
153  vx_uint8 color[4];
154  int thickness;
155  };
156 
157 #ifndef __ANDROID__
158 
162  {
169  MouseMove
170  };
171 
179  typedef void (*OnKeyboardEventCallback)(void* context, vx_char key, vx_uint32 x, vx_uint32 y);
180 
188  typedef void (*OnMouseEventCallback)(void* context, MouseButtonEvent event, vx_uint32 x, vx_uint32 y);
189 
195  virtual void setOnKeyboardEventCallback(OnKeyboardEventCallback callback, void* context) = 0;
196 
202  virtual void setOnMouseEventCallback(OnMouseEventCallback callback, void* context) = 0;
203 #endif
204 
209  virtual void putImage(vx_image image) = 0;
210 
216  virtual void putTextViewport(const std::string& text, const TextBoxStyle& style) = 0;
217 
223  virtual void putFeatures(vx_array location, const FeatureStyle& style) = 0;
224 
233  virtual void putFeatures(vx_array location, vx_array styles) = 0;
234 
240  virtual void putLines(vx_array lines, const LineStyle& style) = 0;
241 
247  virtual void putConvexPolygon(vx_array vertices, const LineStyle& style) = 0;
248 
254  virtual void putMotionField(vx_image field, const MotionFieldStyle& style) = 0;
255 
261  virtual void putObjectLocation(const vx_rectangle_t& location, const DetectedObjectStyle& style) = 0;
262 
268  virtual void putCircles(vx_array circles, const CircleStyle& style) = 0;
269 
276  virtual void putArrows(vx_array old_points, vx_array new_points,
277  const LineStyle& style) = 0;
278 
279 #ifndef __ANDROID__
280 
285  virtual bool flush() = 0;
286 
290  virtual void close() = 0;
291 #endif
292 
298  {
299  return targetType;
300  }
301 
306  std::string getRenderName() const
307  {
308  return renderName;
309  }
310 
315  virtual vx_uint32 getViewportWidth() const = 0;
316 
321  virtual vx_uint32 getViewportHeight() const = 0;
322 
326  virtual ~Render()
327  {}
328 
329 protected:
330 
331  Render(TargetType type = Render::UNKNOWN_RENDER, std::string name = "Undefined"):
332  targetType(type),
333  renderName(name)
334  {}
335 
337  const std::string renderName;
338 };
339 
340 #ifdef __ANDROID__
341 
353 NVXIO_EXPORT std::unique_ptr<Render> createRender(vx_context context, vx_uint32 width, vx_uint32 height, bool doScale = true);
354 
355 #else
356 
371 NVXIO_EXPORT std::unique_ptr<Render> createDefaultRender(vx_context context, const std::string& title, vx_uint32 width, vx_uint32 height,
372  vx_uint32 format = VX_DF_IMAGE_RGBX, bool doScale = true,
373  bool fullScreen = nvxio::Application::get().getFullScreenFlag());
374 
389 NVXIO_EXPORT std::unique_ptr<Render> createVideoRender(vx_context context, const std::string& path, vx_uint32 width,
390  vx_uint32 height, vx_uint32 format = VX_DF_IMAGE_RGBX);
391 
408 NVXIO_EXPORT std::unique_ptr<Render> createWindowRender(vx_context context, const std::string& title, vx_uint32 width, vx_uint32 height,
409  vx_uint32 format = VX_DF_IMAGE_RGBX, bool doScale = true,
410  bool fullscreen = nvxio::Application::get().getFullScreenFlag());
411 
424 NVXIO_EXPORT std::unique_ptr<Render> createImageRender(vx_context context, const std::string& path, vx_uint32 width, vx_uint32 height,
425  vx_uint32 format = VX_DF_IMAGE_RGBX);
426 
427 #endif
428 
429 }
430 #endif // NVXIO_RENDER_HPP
struct _vx_image * vx_image
An opaque reference to an image.
Definition: vx_types.h:186
int thickness
Holds the line thickness.
Definition: Render.hpp:154
Indicates the right mouse button has been pressed down.
Definition: Render.hpp:167
TargetType
Defines the Render types.
Definition: Render.hpp:80
float radius
Holds the radius of the feature.
Definition: Render.hpp:106
uint8_t vx_uint8
An 8-bit unsigned value.
Definition: vx_types.h:90
struct _vx_array * vx_array
The Array Object. Array is a strongly-typed container for other data structures.
Definition: vx_types.h:279
NVXIO_EXPORT std::unique_ptr< Render > createDefaultRender(vx_context context, const std::string &title, vx_uint32 width, vx_uint32 height, vx_uint32 format=VX_DF_IMAGE_RGBX, bool doScale=true, bool fullScreen=nvxio::Application::get().getFullScreenFlag())
Render factory that creates UI render with a window by default.
bool isHalfTransparent
Holds a flag indicating whether the detected object should be filled with half-transparent color...
Definition: Render.hpp:144
TargetType getTargetType() const
Gets the target type.
Definition: Render.hpp:297
The Application interface.
The 2D Coordinates structure.
Definition: vx_types.h:1447
Defines the features parameters.
Definition: Render.hpp:103
const std::string renderName
Definition: Render.hpp:337
char vx_char
An 8 bit ASCII character.
Definition: vx_types.h:85
struct _vx_context * vx_context
An opaque reference to the implementation context.
Definition: vx_types.h:222
Indicates the middle mouse button has been released.
Definition: Render.hpp:166
std::string label
Holds the text label.
Definition: Render.hpp:136
int thickness
Holds the thickness of the line.
Definition: Render.hpp:116
Defines line style.
Definition: Render.hpp:113
Indicates a window render.
Definition: Render.hpp:83
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
Defines circle style.
Definition: Render.hpp:151
NVXIO_EXPORT std::unique_ptr< Render > createImageRender(vx_context context, const std::string &path, vx_uint32 width, vx_uint32 height, vx_uint32 format=VX_DF_IMAGE_RGBX)
Creates a render for image sequence.
const TargetType targetType
Definition: Render.hpp:336
Indicates a stub render.
Definition: Render.hpp:82
Indicates a render for video writing.
Definition: Render.hpp:84
std::string getRenderName() const
Gets the render name.
Definition: Render.hpp:306
NVXIO_EXPORT std::unique_ptr< Render > createWindowRender(vx_context context, const std::string &title, vx_uint32 width, vx_uint32 height, vx_uint32 format=VX_DF_IMAGE_RGBX, bool doScale=true, bool fullscreen=nvxio::Application::get().getFullScreenFlag())
Creates a Window render.
vx_coordinates2d_t origin
Holds the coordinates of the top-left corner of the box.
Definition: Render.hpp:96
The rectangle data structure that is shared with the users.
Definition: vx_types.h:1422
The top level OpenVX Header.
NVXIO_EXPORT std::unique_ptr< Render > createVideoRender(vx_context context, const std::string &path, vx_uint32 width, vx_uint32 height, vx_uint32 format=VX_DF_IMAGE_RGBX)
Creates a render for writing video.
Defines motion field style.
Definition: Render.hpp:123
Defines the text box parameters.
Definition: Render.hpp:92
Indicates the left mouse button has been pressed down.
Definition: Render.hpp:163
Indicates the left mouse button has been released.
Definition: Render.hpp:164
uint32_t vx_uint32
A 32-bit unsigned value.
Definition: vx_types.h:100
Render(TargetType type=Render::UNKNOWN_RENDER, std::string name="Undefined")
Definition: Render.hpp:331
Indicates the right mouse button has been released.
Definition: Render.hpp:168
virtual ~Render()
Destructor.
Definition: Render.hpp:326
Defines the detected object's rectangle style.
Definition: Render.hpp:133
static Application & get()
Returns the reference to the object.
Indicates a middle mouse button has been pressed down.
Definition: Render.hpp:165
vx_uint8 radius
Holds the radius of the corners.
Definition: Render.hpp:142
MouseButtonEvent
Defines mouse events.
Definition: Render.hpp:161
Render interface.
Definition: Render.hpp:73
vx_uint8 thickness
Holds the line thickness.
Definition: Render.hpp:140