Jetson Inference
DNN Vision Library
homographyNet.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018, 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 #ifndef __HOMOGRAPHY_NET_H__
24 #define __HOMOGRAPHY_NET_H__
25 
26 
27 #include "tensorNet.h"
28 
29 
30 #if NV_TENSORRT_MAJOR >= 5
31 
37 #define HAS_HOMOGRAPHY_NET
38 #endif
39 
44 #define HOMOGRAPHY_NET_DEFAULT_INPUT "input_0"
45 
50 #define HOMOGRAPHY_NET_DEFAULT_OUTPUT "output_0"
51 
52 
57 class homographyNet : public tensorNet
58 {
59 public:
64  {
65  CUSTOM = 0,
68  };
69 
75  static NetworkType NetworkTypeFromStr( const char* model_name );
76 
82  static homographyNet* Create( NetworkType networkType=WEBCAM_320, uint32_t maxBatchSize=1,
84  bool allowGPUFallback=true );
85 
93  static homographyNet* Create( const char* model_path,
94  const char* input = HOMOGRAPHY_NET_DEFAULT_INPUT,
95  const char* output = HOMOGRAPHY_NET_DEFAULT_OUTPUT,
96  uint32_t maxBatchSize=1, precisionType precision=TYPE_FASTEST,
97  deviceType device=DEVICE_GPU, bool allowGPUFallback=true );
98 
102  static homographyNet* Create( int argc, char** argv );
103 
107  virtual ~homographyNet();
108 
113  bool FindDisplacement( float* imageA, float* imageB, uint32_t width, uint32_t height, float displacement[8] );
114 
119  bool FindHomography( float* imageA, float* imageB, uint32_t width, uint32_t height, float H[3][3] );
120 
125  bool FindHomography( float* imageA, float* imageB, uint32_t width, uint32_t height, float H[3][3], float H_inv[3][3] );
126 
131  bool ComputeHomography( const float displacement[8], float H[3][3] );
132 
137  bool ComputeHomography( const float displacement[8], float H[3][3], float H_inv[3][3] );
138 
139 
140 protected:
141 
142  // constructor
143  homographyNet();
144 };
145 
146 #endif
147 
Sequences collected from webcam (320x240 input)
Definition: homographyNet.h:67
precisionType
Enumeration for indicating the desired precision that the network should run in, if available in hard...
Definition: tensorNet.h:79
GPU (if multiple GPUs are present, a specific GPU can be selected with cudaSetDevice() ...
Definition: tensorNet.h:108
#define HOMOGRAPHY_NET_DEFAULT_INPUT
Name of default input blob for homographyNet ONNX models.
Definition: homographyNet.h:44
Custom model from user.
Definition: homographyNet.h:65
#define HOMOGRAPHY_NET_DEFAULT_OUTPUT
Name of default output blob for homographyNet ONNX models.
Definition: homographyNet.h:50
deviceType
Enumeration for indicating the desired device that the network should run on, if available in hardwar...
Definition: tensorNet.h:106
Homography estimation networks with TensorRT support.
Definition: homographyNet.h:57
The fastest detected precision should be use (i.e.
Definition: tensorNet.h:82
NetworkType
Network choice enumeration.
Definition: homographyNet.h:63
bool FindDisplacement(float *imageA, float *imageB, uint32_t width, uint32_t height, float displacement[8])
Find the displacement from imageA to imageB.
bool ComputeHomography(const float displacement[8], float H[3][3])
Given the displacement from FindDisplacement(), compute the homography.
static homographyNet * Create(NetworkType networkType=WEBCAM_320, uint32_t maxBatchSize=1, precisionType precision=TYPE_FASTEST, deviceType device=DEVICE_GPU, bool allowGPUFallback=true)
Load a new network instance.
virtual ~homographyNet()
Destroy.
bool FindHomography(float *imageA, float *imageB, uint32_t width, uint32_t height, float H[3][3])
Find the homography that warps imageA to imageB.
Abstract class for loading a tensor network with TensorRT.
Definition: tensorNet.h:188
static NetworkType NetworkTypeFromStr(const char *model_name)
Parse a string to one of the built-in pretrained models.
Synthetically-warped COCO (128x128 input)
Definition: homographyNet.h:66