VisionWorks Toolkit Reference

December 18, 2015 | 1.2 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, 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 <NVX/nvx.h>
37 
43 namespace nvxio
44 {
61 class Render
62 {
63 public:
64 
69  {
74  };
75 
80  struct TextBoxStyle
81  {
85  };
86 
91  struct FeatureStyle
92  {
94  float radius;
95  };
96 
101  struct LineStyle
102  {
104  int thickness;
105  };
106 
112  {
114  };
115 
116 
122  {
124  std::string label;
131  };
132 
137  struct CircleStyle
138  {
140  int thickness;
141  };
142 
147  {
155  };
156 
164  typedef void (*OnKeyboardEventCallback)(void* context, vx_char key, vx_uint32 x, vx_uint32 y);
165 
173  typedef void (*OnMouseEventCallback)(void* context, MouseButtonEvent event, vx_uint32 x, vx_uint32 y);
174 
180  virtual void setOnKeyboardEventCallback(OnKeyboardEventCallback callback, void* context) = 0;
181 
187  virtual void setOnMouseEventCallback(OnMouseEventCallback callback, void* context) = 0;
188 
193  virtual void putImage(vx_image image) = 0;
194 
200  virtual void putText(const std::string& text, const TextBoxStyle& style) = 0;
201 
207  virtual void putFeatures(vx_array location, const FeatureStyle& style) = 0;
208 
214  virtual void putLines(vx_array lines, const LineStyle& style) = 0;
215 
221  virtual void putConvexPoligon(vx_array vertices, const LineStyle& style) = 0;
222 
228  virtual void putMotionField(vx_image field, const MotionFieldStyle& style) = 0;
229 
235  virtual void putObjectLocation(const vx_rectangle_t& location, const DetectedObjectStyle& style) = 0;
236 
242  virtual void putCircles(vx_array circles, const CircleStyle& style) = 0;
243 
250  virtual void putArrows(vx_array old_points, vx_array new_points,
251  const LineStyle& style) = 0;
252 
258  virtual bool flush() = 0;
259 
263  virtual void close() = 0;
264 
270  {
271  return targetType;
272  }
273 
278  std::string getRenderName() const
279  {
280  return renderName;
281  }
282 
287  virtual vx_uint32 getWidth() const = 0;
288 
293  virtual vx_uint32 getHeight() const = 0;
294 
298  virtual ~Render()
299  {}
300 
301 protected:
302 
303  Render(TargetType type = Render::UNKNOWN_RENDER, std::string name = "Undefined"):
304  targetType(type),
305  renderName(name)
306  {}
307 
309  const std::string renderName;
310 };
311 
312 
325 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);
326 
339 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);
340 
353 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);
354 
367 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);
368 
369 }
370 #endif // NVXIO_RENDER_HPP
struct _vx_image * vx_image
An opaque reference to an image.
Definition: vx_types.h:186
vx_uint8 color[4]
Holds the line color in RGBA format.
Definition: Render.hpp:103
int thickness
Holds the line thickness.
Definition: Render.hpp:140
Indicates the right mouse button has been pressed down.
Definition: Render.hpp:152
virtual vx_uint32 getHeight() const =0
Gets the height.
TargetType
Defines the Render types.
Definition: Render.hpp:68
virtual void putConvexPoligon(vx_array vertices, const LineStyle &style)=0
Puts a convex polygon on the image.
virtual void putFeatures(vx_array location, const FeatureStyle &style)=0
Puts features on the image.
float radius
Holds the radius of the feature.
Definition: Render.hpp:94
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
virtual bool flush()=0
Renders all primitives.
bool isHalfTransparent
Holds a flag indicating whether the detected object should be filled with half-transparent color...
Definition: Render.hpp:130
TargetType getTargetType() const
Gets the target type.
Definition: Render.hpp:269
The 2D Coordinates structure.
Definition: vx_types.h:1447
Indicates the mouse has been moved.
Definition: Render.hpp:154
Defines the features parameters.
Definition: Render.hpp:91
const std::string renderName
Definition: Render.hpp:309
NVIDIA VisionWorks Framework and Primitives API.
char vx_char
An 8 bit ASCII character.
Definition: vx_types.h:85
vx_uint8 bgcolor[4]
Holds the background color of the box.
Definition: Render.hpp:83
struct _vx_context * vx_context
An opaque reference to the implementation context.
Definition: vx_types.h:222
void(* OnMouseEventCallback)(void *context, MouseButtonEvent event, vx_uint32 x, vx_uint32 y)
Callback for mouse events.
Definition: Render.hpp:173
Indicates the middle mouse button has been released.
Definition: Render.hpp:151
virtual vx_uint32 getWidth() const =0
Gets the width.
virtual void setOnMouseEventCallback(OnMouseEventCallback callback, void *context)=0
Sets mouse event callback.
std::string label
Holds the text label.
Definition: Render.hpp:124
void(* OnKeyboardEventCallback)(void *context, vx_char key, vx_uint32 x, vx_uint32 y)
Callback for keyboard events.
Definition: Render.hpp:164
virtual void putMotionField(vx_image field, const MotionFieldStyle &style)=0
Puts motion field on the image.
Indicates a render for image writing.
Definition: Render.hpp:73
int thickness
Holds the thickness of the line.
Definition: Render.hpp:104
vx_uint8 color[4]
Holds the text color in RGBA format.
Definition: Render.hpp:82
vx_uint8 color[4]
Holds the feature color in RGBA format.
Definition: Render.hpp:93
virtual void close()=0
Closes the render.
Defines line style.
Definition: Render.hpp:101
Indicates a window render.
Definition: Render.hpp:71
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
virtual void putImage(vx_image image)=0
Puts the image to the render.
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.
virtual void putText(const std::string &text, const TextBoxStyle &style)=0
Puts a message box on the image.
Defines circle style.
Definition: Render.hpp:137
virtual void putCircles(vx_array circles, const CircleStyle &style)=0
Puts circles on the image.
const TargetType targetType
Definition: Render.hpp:308
Indicates a stub render.
Definition: Render.hpp:70
Indicates a render for video writing.
Definition: Render.hpp:72
std::string getRenderName() const
Gets the render name.
Definition: Render.hpp:278
virtual void putObjectLocation(const vx_rectangle_t &location, const DetectedObjectStyle &style)=0
Puts object location on the image.
vx_uint8 color[4]
Holds the line color in RGBA format.
Definition: Render.hpp:139
vx_coordinates2d_t origin
Holds the coordinates of the top-left corner of the box.
Definition: Render.hpp:84
vx_uint8 color[4]
Holds the color of the motion field in RGBA format.
Definition: Render.hpp:113
The rectangle data structure that is shared with the users.
Definition: vx_types.h:1422
The top level OpenVX Header.
Defines motion field style.
Definition: Render.hpp:111
Defines the text box parameters.
Definition: Render.hpp:80
Indicates the left mouse button has been pressed down.
Definition: Render.hpp:148
virtual void putArrows(vx_array old_points, vx_array new_points, const LineStyle &style)=0
Puts arrows on the image.
Indicates the left mouse button has been released.
Definition: Render.hpp:149
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:303
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)
Creates a Window render.
Indicates the right mouse button has been released.
Definition: Render.hpp:153
virtual ~Render()
Destructor.
Definition: Render.hpp:298
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)
Render factory that creates UI render with a window by default.
Defines the detected object's rectangle style.
Definition: Render.hpp:121
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.
virtual void putLines(vx_array lines, const LineStyle &style)=0
Puts lines on the image.
Indicates a middle mouse button has been pressed down.
Definition: Render.hpp:150
MouseButtonEvent
Defines mouse events.
Definition: Render.hpp:146
Render interface.
Definition: Render.hpp:61
virtual void setOnKeyboardEventCallback(OnKeyboardEventCallback callback, void *context)=0
Sets the keyboard event callback.
vx_uint8 thickness
Holds the line thickness.
Definition: Render.hpp:128
vx_uint8 color[4]
Holds the line color in RGBA format.
Definition: Render.hpp:126