NVIDIA DRIVE OS Linux SDK API Reference

5.1.15.0 Release
For Test and Development only
NvRosImgPipeline.h
Go to the documentation of this file.
1 /*Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
2 
3 NVIDIA CORPORATION and its licensors retain all intellectual property
4 and proprietary rights in and to this software, related documentation
5 and any modifications thereto. Any use, reproduction, disclosure or
6 distribution of this software and related documentation without an express
7 license agreement from NVIDIA CORPORATION is strictly prohibited.*/
8 
9 #ifndef __NVROSIMGPIPELINE_H_
10 #define __NVROSIMGPIPELINE_H_
11 
12 #include "nvmedia_core.h"
13 #include "nvmedia_surface.h"
14 #include "nvmedia_image.h"
15 #include "nvmedia_ipp.h"
16 #include "nvmedia_isp.h"
17 #include "nvmedia_vop.h"
18 #include "img_dev.h"
19 #include "nvmedia_eglstream.h"
20 
21 #include "nvroscommon.h"
22 #include "nvros_egl_utils/nvros_egl_utils.h"
23 
24 #include <thread>
25 #include <deque>
26 
27 #define MAX_AGGREGATE_IMAGES 4
28 #define MAX_STRING_SIZE 256
29 #define IMAGE_BUFFERS_POOL_SIZE 3
30 #define CAMERA_PORTS 4
31 #define FRAME_RATE 30
32 
46 namespace nvros
47 {
62  typedef struct _CaptureConfigParams
63  {
72  unsigned int i2cDevice;
73  unsigned int csiLanes;
74  unsigned int embeddedDataLinesTop;
76  unsigned int desAddr;
77  unsigned int brdcstSerAddr;
79  unsigned int brdcstSensorAddr;
81  unsigned int e2pPhysicalAddr;
83  unsigned int inputOrder;
84 
94 {
95  private:
96 
97  // Surface parameters
98  NvMediaSurfaceType outSurfaceType;
99  NvMediaSurfaceType inSurfaceType;
100  NvMediaSurfaceType ispOutSurfaceType;
101  NvMediaISPSelect ispSelect;
102  unsigned int surfaceAttr;
103  unsigned int outputWidth;
104  unsigned int outputHeight;
105  unsigned int inputWidth;
106  unsigned int inputHeight;
107  unsigned int ispOutWidth;
108  unsigned int ispOutHeight;
109  unsigned int ispOutColorStd;
110 
111  // Capture configuration
112  bool isYUV;
113  const char* configFile;
114  CaptureConfigParams* mCaptureConfigParams;
115  unsigned int mCaptureConfigSetsNum;
116  unsigned int cameraGrp;
117  unsigned int numOfCameras;
118  ExtImgDevMapInfo cameraMap;
119  ExtImgDevice* mExtImgDevice;
120 
121  // NvMedia IPP specific private variables
122  bool isIspEnabled[MAX_AGGREGATE_IMAGES];
123  bool isOutputEnabled[MAX_AGGREGATE_IMAGES];
124  bool isControlAlgoEnabled[MAX_AGGREGATE_IMAGES];
125  unsigned int rawBytesPerPixel;
126 
127  // NvMediaDevice handle for IPP
128  NvMediaDevice* mNvmediaDevice;
129 
130  //IPP manager
131  NvMediaIPPManager* mIppManager;
132 
133  // IPP pipeline
135 
136  //IPP components
138 
139  //ISP components
141 
142  //ICP components
144 
145  //Control algo. components
147 
148  //output component
150 
151  //ICP settings
152  NvMediaICPSettings mIcpSettings;
153 
154  //component number
155  unsigned int componentNumber[NVMEDIA_MAX_PIPELINES_PER_MANAGER];
156 
157  //Pixel order
158  unsigned int pixelOrder;
159  char* inPixelOrder;
160  unsigned int bitsPerPixel;
161 
162  // NvRosEglUtil instance
163  NvRosEglUtil* mNvRosEglUtil;
164  EglUtilState* mEglUtilState;
165  EglUtilOptions* mEglUtilOptions;
166  EGLStreamKHR mEglStreams[MAX_AGGREGATE_IMAGES];
167 
168  // EGL Producer related private variables
169  NvMediaEGLStreamProducer* cameraStreamEglProducer[MAX_AGGREGATE_IMAGES];
170  std::thread imgProducerThread;
171  NvMediaImage* eglStreamImages[MAX_AGGREGATE_IMAGES];
172 
173  //socket paths
174  const char* eglStreamSocketPath[CAMERA_PORTS][MAX_AGGREGATE_IMAGES] =
175  {
176  {
177  "/tmp/nvros_cam_0_0",
178  "/tmp/nvros_cam_0_1",
179  "/tmp/nvros_cam_0_2",
180  "/tmp/nvros_cam_0_3"
181  },
182 
183  {
184  "/tmp/nvros_cam_1_0",
185  "/tmp/nvros_cam_1_1",
186  "/tmp/nvros_cam_1_2",
187  "/tmp/nvros_cam_1_3"
188  },
189 
190  {
191  "/tmp/nvros_cam_2_0",
192  "/tmp/nvros_cam_2_1",
193  "/tmp/nvros_cam_2_2",
194  "/tmp/nvros_cam_2_3"
195 
196  },
197 
198  {
199  "/tmp/nvros_cam_3_0",
200  "/tmp/nvros_cam_3_1",
201  "/tmp/nvros_cam_3_2",
202  "/tmp/nvros_cam_3_3"
203  }
204  };
205 
206  // Pipeline control variables
207  bool runPipeline;
208  bool shutdownPipeline;
209 
210  //Private methods
211  const char* GetCaptureConfigFile();
212  const char* GetEglStreamSocketPath();
213  NvRosErr ConfigParserInterface();
214  NvRosErr InitNvMediaIPP();
215  NvRosErr IPPSetCaptureSettings();
216  NvRosErr CreateIPPPipeline();
217  NvRosErr CreateSensorControlComponent();
218  NvRosErr CreateCaptureComponent();
219  NvRosErr CreateISPComponent();
220  NvRosErr CreateControlAlgoComponent();
221  NvRosErr CreateOutputComponent();
222  NvRosErr AddComponentsIntoPipeline();
223  NvRosErr SetICPBufferPoolConfig(NvMediaIPPBufferPoolParamsNew* poolConfig);
224  NvRosErr SetISPBufferPoolConfig(NvMediaIPPBufferPoolParamsNew* poolConfig,
225  NvMediaIPPBufferPoolParamsNew *poolStatsConfig);
226  NvRosErr SetControlAlgorithmBufferPoolConfig(NvMediaIPPBufferPoolParamsNew *poolConfig);
227  NvRosErr ImgProducerLoop();
228 
229  public:
230 
253  NvRosErr SetCaptureConfig(const char* cfgFilePath, const unsigned int camGrp,
254  const unsigned int cameras, const bool yuv);
255 
265 
274 
298 
307 
308 }; // NvRosImgPipeline
309 
311 }
312 #endif // __NVROSIMGPIPELINE_H_
CAMERA_PORTS
#define CAMERA_PORTS
Definition: NvRosImgPipeline.h:30
nvros::_CaptureConfigParams::interface
char interface[MAX_STRING_SIZE]
Definition: NvRosImgPipeline.h:71
nvros::_CaptureConfigParams::description
char description[MAX_STRING_SIZE]
Definition: NvRosImgPipeline.h:65
nvmedia_surface.h
NVIDIA Media Interface: Surface Handling
nvros::_CaptureConfigParams::brdcstSerAddr
unsigned int brdcstSerAddr
Definition: NvRosImgPipeline.h:77
nvmedia_eglstream.h
NVIDIA Media Interface: EGL Stream
nvros::NvRosImgPipeline::StartPipeline
NvRosErr StartPipeline()
Starts the NvRosImgPipeline and must be called after SetCaptureConfig and InitPipeline.
NVMEDIA_MAX_COMPONENTS_PER_PIPELINE
#define NVMEDIA_MAX_COMPONENTS_PER_PIPELINE
Maximum number of IPP components in IPP pipeline.
Definition: nvmedia_ipp.h:79
nvros::_CaptureConfigParams::csiLanes
unsigned int csiLanes
Definition: NvRosImgPipeline.h:73
nvros::NvRosImgPipeline::ShutdownPipeline
NvRosErr ShutdownPipeline()
Shuts down the NvRosImgPipeline and uninitializes all settings prior to starting the pipeline.
NvMediaIPPBufferPoolParamsNew
Holds new buffer pool parameters for initializing an IPP component.
Definition: nvmedia_ipp.h:1057
NvMediaIPPComponent
void NvMediaIPPComponent
A handle representing an IPP component object.
Definition: nvmedia_ipp.h:95
nvros::NvRosEglUtil
Class to initialize the EGLStream for the following roles: EGLOUTPUT_CONSUMER, CUDA_CONSUMER,...
Definition: nvros_egl_utils.h:285
MAX_STRING_SIZE
#define MAX_STRING_SIZE
Definition: NvRosImgPipeline.h:28
nvros::_CaptureConfigParams::embeddedDataLinesTop
unsigned int embeddedDataLinesTop
Definition: NvRosImgPipeline.h:74
nvros::_CaptureConfigParams::embeddedDataLinesBottom
unsigned int embeddedDataLinesBottom
Definition: NvRosImgPipeline.h:75
NvMediaDevice
struct NvMediaDevice NvMediaDevice
An opaque handle representing an NvMediaDevice object.
Definition: nvmedia_core.h:348
nvros::NvRosImgPipeline::StopPipeline
NvRosErr StopPipeline()
Stops the NvRosImgPipeline put into execution by StartPipeline.
NvMediaIPPPipeline
void NvMediaIPPPipeline
A handle representing IPP pipeline object.
Definition: nvmedia_ipp.h:90
MAX_AGGREGATE_IMAGES
#define MAX_AGGREGATE_IMAGES
Definition: NvRosImgPipeline.h:27
nvros::_CaptureConfigParams::e2pAddr
unsigned int e2pAddr[MAX_AGGREGATE_IMAGES]
Definition: NvRosImgPipeline.h:82
nvmedia_ipp.h
NVIDIA Media Interface: Image Processing Pipeline API
nvros::_EglUtilState
Holds EGL related parameters.
Definition: nvros_egl_utils.h:198
NvMediaImageRec
Holds a handle representing image objects.
Definition: nvmedia_image.h:71
nvros::_CaptureConfigParams::desAddr
unsigned int desAddr
Definition: NvRosImgPipeline.h:76
nvros::_CaptureConfigParams::board
char board[MAX_STRING_SIZE]
Definition: NvRosImgPipeline.h:66
nvros::_CaptureConfigParams::serAddr
unsigned int serAddr[MAX_AGGREGATE_IMAGES]
Definition: NvRosImgPipeline.h:78
nvros::_CaptureConfigParams::brdcstSensorAddr
unsigned int brdcstSensorAddr
Definition: NvRosImgPipeline.h:79
nvros::_CaptureConfigParams::name
char name[MAX_STRING_SIZE]
Definition: NvRosImgPipeline.h:64
nvmedia_core.h
NVIDIA Media Interface: Core
nvros::NvRosImgPipeline
Creates image capture pipelines for NvROS on the NVIDIA DRIVEā„¢ AGX platform through AR0231 imaging se...
Definition: NvRosImgPipeline.h:93
NvMediaSurfaceType
#define NvMediaSurfaceType
Defines the set of NvMedia surface types.
Definition: nvmedia_surface.h:550
nvros::NvRosErr
enum nvros::_NvRosErrCode NvRosErr
Declares error codes for all NvROS modules and packages.
nvros::CaptureConfigParams
struct nvros::_CaptureConfigParams CaptureConfigParams
Holds configuration parameters for capturing image frames.
NvMediaICPSettings
Holds image capture settings for the CSI format.
Definition: nvmedia_icp.h:255
nvros::NvRosImgPipeline::SetCaptureConfig
NvRosErr SetCaptureConfig(const char *cfgFilePath, const unsigned int camGrp, const unsigned int cameras, const bool yuv)
Sets the configuration parameters for an image capture pipeline and must be called first after the Nv...
nvros::_CaptureConfigParams::surfaceFormat
char surfaceFormat[MAX_STRING_SIZE]
Definition: NvRosImgPipeline.h:69
nvros::_CaptureConfigParams::i2cDevice
unsigned int i2cDevice
Definition: NvRosImgPipeline.h:72
NvMediaEGLStreamProducer
A handle representing an EGL stream producer object.
Definition: nvmedia_eglstream.h:53
NVMEDIA_MAX_PIPELINES_PER_MANAGER
#define NVMEDIA_MAX_PIPELINES_PER_MANAGER
Maximum number of IPP pipelines in IPP manager.
Definition: nvmedia_ipp.h:85
nvmedia_vop.h
NVIDIA Media Interface: Video Output Processing (VOP)
nvros::_CaptureConfigParams::inputFormat
char inputFormat[MAX_STRING_SIZE]
Definition: NvRosImgPipeline.h:68
nvros::_CaptureConfigParams::resolution
char resolution[MAX_STRING_SIZE]
Definition: NvRosImgPipeline.h:70
nvros::_CaptureConfigParams::inputOrder
unsigned int inputOrder
Definition: NvRosImgPipeline.h:83
nvros::_CaptureConfigParams::inputDevice
char inputDevice[MAX_STRING_SIZE]
Definition: NvRosImgPipeline.h:67
nvros::_CaptureConfigParams::sensorAddr
unsigned int sensorAddr[MAX_AGGREGATE_IMAGES]
Definition: NvRosImgPipeline.h:80
nvros::_EglUtilOptions
Holds required window system related parameters when initializing EGLStream.
Definition: nvros_egl_utils.h:169
nvros::_CaptureConfigParams::e2pPhysicalAddr
unsigned int e2pPhysicalAddr
Definition: NvRosImgPipeline.h:81
NvMediaIPPManager
void NvMediaIPPManager
A handle representing IPP manager object.
Definition: nvmedia_ipp.h:73
nvmedia_image.h
NVIDIA Media Interface: Image Processing
nvros::NvRosImgPipeline::InitPipeline
NvRosErr InitPipeline()
Initializes the NvRosImgPipeline which internally initializes the NvMediaIPPPipeline.
nvros::_CaptureConfigParams
Holds configuration parameters for capturing image frames.
Definition: NvRosImgPipeline.h:62
nvros
A global namespace for NvRos packages.
nvroscommon.h
NVIDIA Robot Operating System : Common Enums, Macros, and Constants