Image type from ar0231-rccb camera on px2


I’m confused with the image data type from px2 cameras. According to the Driveworks API and samples’ code, each frame read from camera has 3 choices(dwImageNvMedia, dwImageCUDA and dwImageCPU).

I currently want to integrate a redlight detection project(live camera) into px2. But I can’t find the definition of “cudaArray_t” under dwImageCUDA struct. Can someone tell me is that a struct or something else? In addition, how to convert the image data into char type?

Dear hui_luan,
cudaArray_t holds a pointer to CUDA array. Please check

The image data array can be typecasted to char* array and can be read.

Thank you very much for your reply!

I have another question. Can you tell me how the image data passed as dwImageNvMedia? When I looked at drivework API, the struct NvMediaImage is a struct like this:

typedef struct {
NvMediaSurfaceType type;
uint32_t width;
uint32_t height;
uint32_t imageCount;
uint32_t embeddedDataTopSize;
uint32_t embeddedDataBottomSize;
uint32_t attributes;
void *tag;
NvMediaTime captureTimeStamp;
NvMediaGlobalTime captureGlobalTimeStamp;
uint32_t colorStd;

I’m confused about how the data type of frames from live camera looks like when I use dwImageNvmedia. It seems like there is only properties of ‘img’ no member like “cudArray_t data” as dwImageCUDA.

Dear hui_luan,
All the data structures in Nvmedia are of abstract type. NvMediaImage does not directly expose the pointer to the image data. You can use NvMediaImageGetBits function to to copy the image content to a buffer. Please refer to Please check the usage of NvMediaImageGetBits in nvmedia samples

Hi Siva,

Okay…does that mean it is not possible to use NvmediaImage as data interface? I actually want to integrate a redlight detection project into px2. That I need to pass frames from live camera into the project. So how to define the data interface? Or do you have any suggestions? I’ve only read sample source code and not too familiar with all APIs.

Dear hui_luan,
The captured image from camera is stored as NvmediaImage. By using Image streamer NvmediaImage is sent to CUDA consumer. For more details please check image streamer and camera gsml, object detector samples.

Thanks for your advice Siva!

We tried some ways to get cudaImage data, and still have troubles. The code below shows that how I tried to get image data. The basic idea is copy the image from GPU to CPU, and then print the cudArray_t data. However,

cudaMalloc((void **)&aa,sizeof(float32_t) * INFERENCE_N_SIMFRAMES * m_networkOutputSize[0]);
std::cout << "outConf-----size" <<sizeof(float32_t) * m_networkOutputSize[0]<< std::endl;
cudaMemcpy(aa, frame->array[0],sizeof(float32_t) * m_networkOutputSize[0],cudaMemcpyDeviceToHost);
for (int i = 0; i < size; i++){    
         std::cout << "  outConf-----int" << std::endl;
         std::cout << "  a ==" << (*aa++) << std::endl;

where aa is a float type array, and the size is widthheight3. This code give us an error which shows "cannot copy back coverage memory: cudaErrorInvalidValue
". Can you teach me what’s the right procedure to get a frame’s data from live camera? We’ve read a lot sample’s code and we still can’t print any single frame’s data from live camera.

In details, We actually want to know how the data looks like(such as array, matrix, or list) and we need to pass that value to our project. We’ve finished a redlight detection project and still have troubles to integrate that on px2 because of the data interface. That will be great if you can guide us with a right procedure to pass the data to our project.

Dear hui_luan,
If you just want to print the data from camera, please follow

I have provided code changes in camera_gmsl sample to print RGBA image data to a file.

Just for your information, Driveworks provides a wrapper over NVMedia calls when dealing with camera. So, you capture image as NvMediaImage and pass it to GPU using dwImageStreamer(wrapper over EGLStreams). on GPU, the same Image is read as CUDA array buffer. You pass CUDA buffer as input to your DNN. So here dwImageStreamer facilitates in moving Image frames from camera to GPU with out any additional data transfers.

Please check with to copy data from CUDA array.