Conversion opencv image or ros image to dwImageCUDA for lane detection with driveworks

Please provide the following info (check/uncheck the boxes after creating this topic):
Software Version
DRIVE OS Linux 5.2.6
DRIVE OS Linux 5.2.6 and DriveWorks 4.0
DRIVE OS Linux 5.2.0
DRIVE OS Linux 5.2.0 and DriveWorks 3.5
NVIDIA DRIVE™ Software 10.0 (Linux)
NVIDIA DRIVE™ Software 9.0 (Linux)
other DRIVE OS version

Target Operating System

Hardware Platform
NVIDIA DRIVE™ AGX Xavier DevKit (E3550)
NVIDIA DRIVE™ AGX Pegasus DevKit (E3550)

SDK Manager Version

Host Machine Version
native Ubuntu 18.04

I want convert image from opencv or ros image and use it to LaneNet which is in driveworks-2.2. At this moment I convert a image file “.png” to dwImageCuda and I have a good lane markings, but it is only with one image. Is any solution for this problem?
Looking forward to your reply.

Dear @Matthew_Pimot,
Could you check What is the good way to subscribe a ROS image and convert to Nvidia image types
You can generate dwImageCPU from opencv buffer and then you can use ImageStreamer to get dwImageCUDA for processing.

Hi @SivaRamaKrishnaNV ,
Thanks for help,
it was helpful, here is example to convert ros image to dwImageCUDA:

// Copy from ROS sensor_msgs.Image to cv::mat
        cv_bridge::CvImagePtr cvImgPtr = cv_bridge::toCvCopy(msgs, "rgba8");
        cv::Mat rgbaFrame(cvImgPtr->image);

        // std::cout << msgs->height << " " << msgs->width << " " << << " " << rgbaFrame.elemSize() << "\n";

        // Prepare to copy memory from imageCPU to imageCUDA
        size_t elemSize = 0;
        size_t planeCount = 0;
        uint32_t planeChannels[DW_MAX_IMAGE_PLANES];
        dwVector2ui planeSize[DW_MAX_IMAGE_PLANES];
        size_t srcPitch = planeChannels[0] * elemSize * rcbImage->prop.width;
        // Copy imageCPU to image CUDA
        cudaMemcpy2D(rcbImage->dptr[0], rcbImage->pitch[0],, srcPitch, srcPitch, rcbImage->prop.height, cudaMemcpyHostToDevice);
1 Like