Jetson Inference
DNN Vision Library
superResNet.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019, 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 #include "tensorNet.h"
24 
25 
30 #if NV_TENSORRT_MAJOR >= 5
31 #define HAS_SUPERRES_NET
32 #endif
33 
34 
39 class superResNet : public tensorNet
40 {
41 public:
45  static superResNet* Create();
46 
50  ~superResNet();
51 
55  bool UpscaleRGBA( float* input, uint32_t inputWidth, uint32_t inputHeight,
56  float* output, uint32_t outputWidth, uint32_t outputHeight,
57  float maxPixelValue=255.0f );
58 
62  bool UpscaleRGBA( float* input, float* output, float maxPixelValue=255.0f );
63 
67  inline uint32_t GetInputWidth() const { return mWidth; }
68 
72  inline uint32_t GetInputHeight() const { return mHeight; }
73 
77  inline uint32_t GetOutputWidth() const { return DIMS_W(mOutputs[0].dims); }
78 
82  inline uint32_t GetOutputHeight() const { return DIMS_H(mOutputs[0].dims); }
83 
87  inline uint32_t GetScaleFactor() const { return GetOutputWidth() / GetInputWidth(); }
88 
89 protected:
90  superResNet();
91 };
92 
93 
uint32_t GetInputHeight() const
Retrieve the height of the input image, in pixels.
Definition: superResNet.h:72
#define DIMS_W(x)
Definition: tensorNet.h:52
uint32_t GetInputWidth() const
Retrieve the width of the input image, in pixels.
Definition: superResNet.h:67
uint32_t GetOutputHeight() const
Retrieve the height of the output image, in pixels.
Definition: superResNet.h:82
std::vector< outputLayer > mOutputs
Definition: tensorNet.h:551
static superResNet * Create()
Load super resolution network.
uint32_t mHeight
Definition: tensorNet.h:528
bool UpscaleRGBA(float *input, uint32_t inputWidth, uint32_t inputHeight, float *output, uint32_t outputWidth, uint32_t outputHeight, float maxPixelValue=255.0f)
Upscale a 4-channel RGBA image.
uint32_t GetOutputWidth() const
Retrieve the width of the output image, in pixels.
Definition: superResNet.h:77
uint32_t mWidth
Definition: tensorNet.h:527
~superResNet()
Destroy.
Super Resolution Network.
Definition: superResNet.h:39
Abstract class for loading a tensor network with TensorRT.
Definition: tensorNet.h:188
uint32_t GetScaleFactor() const
Retrieve the scale factor between the input and output.
Definition: superResNet.h:87
#define DIMS_H(x)
Definition: tensorNet.h:51