NVIDIA DRIVE OS Linux SDK API Reference

5.1.12.0 Release

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
NvRosImgPipeline.h
Go to the documentation of this file.
1 /*Copyright (c) 2018, 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 = new NvRosEglUtil(IMAGE_PRODUCER, EGLDEVICE, MAILBOX);
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_
#define CAMERA_PORTS
Holds a handle representing image objects.
Definition: nvmedia_image.h:69
#define NvMediaSurfaceType
Defines the set of NvMedia surface types.
void NvMediaIPPManager
A handle representing IPP manager object.
Definition: nvmedia_ipp.h:63
void NvMediaIPPPipeline
A handle representing IPP pipeline object.
Definition: nvmedia_ipp.h:80
Holds image capture settings for the CSI format.
Definition: nvmedia_icp.h:210
char inputFormat[MAX_STRING_SIZE]
Class to initialize the EGLStream for the following roles: EGLOUTPUT_CONSUMER, CUDA_CONSUMER, CUDA_PRODUCER, IMAGE_PRODUCER.
EGLStream in mailbox mode.
NVIDIA Media Interface: Surface Handling
Holds configuration parameters for capturing image frames.
NVIDIA Media Interface: Image Processing
char interface[MAX_STRING_SIZE]
NvRosErr InitPipeline()
Initializes the NvRosImgPipeline which internally initializes the NvMediaIPPPipeline.
char description[MAX_STRING_SIZE]
struct NvMediaDevice NvMediaDevice
An opaque handle representing an NvMediaDevice object.
Definition: nvmedia_core.h:337
unsigned int serAddr[MAX_AGGREGATE_IMAGES]
#define MAX_AGGREGATE_IMAGES
struct nvros::_CaptureConfigParams CaptureConfigParams
Holds configuration parameters for capturing image frames.
void NvMediaIPPComponent
A handle representing an IPP component object.
Definition: nvmedia_ipp.h:85
Image producer.
Holds new buffer pool parameters for initializing an IPP component.
Definition: nvmedia_ipp.h:1047
NVIDIA Media Interface: Core
#define NVMEDIA_MAX_PIPELINES_PER_MANAGER
Maximum number of IPP pipelines in IPP manager.
Definition: nvmedia_ipp.h:75
Creates image capture pipelines for NvROS on the NVIDIA DRIVEā„¢ AGX platform through AR0231 imaging s...
NVIDIA Media Interface: Image Processing Pipeline API
NvRosErr ShutdownPipeline()
Shuts down the NvRosImgPipeline and uninitializes all settings prior to starting the pipeline...
char resolution[MAX_STRING_SIZE]
char board[MAX_STRING_SIZE]
NVIDIA Media Interface: EGL Stream
Holds required window system related parameters when initializing EGLStream.
#define MAX_STRING_SIZE
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...
Egldevice window system.
A handle representing an EGL stream producer object.
#define NVMEDIA_MAX_COMPONENTS_PER_PIPELINE
Maximum number of IPP components in IPP pipeline.
Definition: nvmedia_ipp.h:69
unsigned int e2pAddr[MAX_AGGREGATE_IMAGES]
NvRosErr StartPipeline()
Starts the NvRosImgPipeline and must be called after SetCaptureConfig and InitPipeline.
NvRosErr StopPipeline()
Stops the NvRosImgPipeline put into execution by StartPipeline.
enum nvros::_NvRosErrCode NvRosErr
Declares error codes for all NvROS modules and packages.
char name[MAX_STRING_SIZE]
char surfaceFormat[MAX_STRING_SIZE]
NVIDIA Media Interface: Video Output Processing (VOP)
Holds EGL related parameters.
char inputDevice[MAX_STRING_SIZE]
NVIDIA Robot Operating System : Common Enums, Macros, and Constants
unsigned int sensorAddr[MAX_AGGREGATE_IMAGES]