dwImageNvMedia dwImageCUDA resize

Hi

I want to use drivenet to run our customized model, but i don’t know how to change image size .

Is there any suggestions ?

And there is another question, when i run ./sample_drivenet, i want to know where is the image size changed, and i found that dwImageCUDA size changed between functions.

void DriveNetApp::getNextFrame(dwImageCUDA** nextFrameCUDA, dwImageGL** nextFrameGL)
{
    std::cout << "======================================================================"<< std::endl;
    *nextFrameCUDA = GenericImage::toDW<dwImageCUDA>(camera->readFrame());
    std::cout << "dwImageCUDA after readFrame height =" << (*nextFrameCUDA)->prop.height << std::endl;
    std::cout << "dwImageCUDA after readFrame  width =" << (*nextFrameCUDA)->prop.width  << std::endl;
    std::cout << "======================================================================"<< std::endl;
    if (*nextFrameCUDA == nullptr) {
        camera->resetCamera();
    } else {
        *nextFrameGL = streamerCUDA2GL->post(GenericImage::toDW<dwImageCUDA>(converterToRGBA->convert(GenericImage::fromDW(*nextFrameCUDA))));
    }
}
dwImageGeneric *SimpleCamera::readFrame()
{
    if(m_pendingFrame)
        releaseFrame();

    dwStatus status = dwSensorCamera_readFrame(&m_pendingFrame, 0, 1000000, m_sensor);

    if (status == DW_END_OF_STREAM) {
        std::cout << "Camera reached end of stream." << std::endl;
        return nullptr;
    } else if (status == DW_NOT_READY){
        while (status == DW_NOT_READY) {
            std::this_thread::sleep_for(std::chrono::milliseconds(5));
            status = dwSensorCamera_readFrame(&m_pendingFrame, 0, 1000000, m_sensor);
        }
    } else if (status != DW_SUCCESS) {
        throw std::runtime_error("Error reading from camera");
    }

    dwImageGeneric *img;
    //std::cout << "======= m_imageProperties height =" << m_imageProperties.height << "=======" << std::endl;
    switch(m_imageProperties.type)
    {
    case DW_IMAGE_CPU: {
        dwImageCPU *img_;
        CHECK_DW_ERROR( dwSensorCamera_getImageCPU(&img_, m_outputType, m_pendingFrame));
        img = GenericImage::fromDW(img_);
        break;
    }
    case DW_IMAGE_CUDA: {
        dwImageCUDA *img_;
        CHECK_DW_ERROR( dwSensorCamera_getImageCUDA(&img_, m_outputType, m_pendingFrame));
        img = GenericImage::fromDW(img_);
        break;
    }
    #ifdef VIBRANTE
    case DW_IMAGE_NVMEDIA: {
        dwImageNvMedia *img_;
        
        CHECK_DW_ERROR( dwSensorCamera_getImageNvMedia(&img_, m_outputType, m_pendingFrame));
        //std::cout << "dwImageNvMedia *img_ height = " << img_->prop.height << std::endl;
        img = GenericImage::fromDW(img_);
        break;
    }
    #endif
    default:
        throw std::runtime_error("Invalid image type");
    }
    
    dwImageGeneric *imgOutput = img;
    
    if(m_streamer)
    {
        imgOutput = m_streamer->post(img);
    }

    if (m_converter)
    {
        imgOutput = m_converter->convert(imgOutput);
    }

    // OpenGL
    if(isGLOutputEnabled())
    {
        m_pendingFrameRgba = m_converterRgba->convert(img);
        m_pendingFrameRgbaGL = GenericImage::toDW<dwImageGL>(m_streamerGL->post(m_pendingFrameRgba));
    }
    dwImageCUDA *testimg = GenericImage::toDW<dwImageCUDA>(imgOutput);
    std::cout << "dwImageCUDA imgOutput height = " << testimg->prop.height << std::endl;
    std::cout << "dwImageCUDA imgOutput width  = " << testimg->prop.width << std::endl;
    return imgOutput;
}

I print size information as below.

***********************
Sensor AR0231 RCCB Rev7 detected!
Camera image: 1920x1208
nvmEglStProducerCreateCommon: Entered
Camera image with 1920x1208 at 30 FPS
======================================================================
dwImageCUDA imgOutput height = 1208
dwImageCUDA imgOutput width  = 1920
dwImageCUDA after readFrame height =604
dwImageCUDA after readFrame  width =960
======================================================================
======================================================================
dwImageCUDA imgOutput height = 1208
dwImageCUDA imgOutput width  = 1920
dwImageCUDA after readFrame height =604
dwImageCUDA after readFrame  width =960
======================================================================
======================================================================
dwImageCUDA imgOutput height = 1208
dwImageCUDA imgOutput width  = 1920
dwImageCUDA after readFrame height =604
dwImageCUDA after readFrame  width =960
======================================================================
======================================================================

My question is that why before imgOutput return the size is 1920x1208, then after nextFrameCUDA receive data from camera->readFrame() the size is changed to 960x604.

Dear allenchen8210,
The DriveNet sample shows a more complete and sophisticated implementation of object detection built around the NVIDIA proprietary network architecture. You may check basic object detector sample to run your custom object detection models.

ok thank u, SivaRamaKrishna.

I want to take dwImageCUDA from dwImageNvMedia, I refer to ./sample_camera_gmsl.

In ./sample_camera_gmsl, i try to receive dwImageCUDA via ImageStreamer, i I have some problems.

Here is my code

...
dwImageProperties cameraImageProperties;
dwSensorCamera_getImageProperties(&cameraImageProperties, DW_CAMERA_PROCESSED_IMAGE, cameraSensor);

dwImageStreamerHandle_t nvm2cuda = DW_NULL_HANDLE;
status = dwImageStreamer_initialize(&nvm2cuda, &cameraImageProperties, DW_IMAGE_CUDA, sdk);
if (status != DW_SUCCESS) {
    std::cerr << "\n ERROR dwImageStreamer_initialize: " <<dwGetStatusName(status)<<std::endl;
    exit(1);
}
...
...
dwImageCUDA *cudaImage = nullptr;
status                 = dwImageStreamer_receiveCUDA( &cudaImage, 600000, nvm2cuda);
if (status == DW_SUCCESS && cudaImage) {
    dwImageStreamer_returnReceivedCUDA(cudaImage, nvm2cuda);
}
else{
    std::cout << "\n ERROR dwImageStreamer_receiveCUDA: " << dwGetStatusName(status) << std::endl;
    if(nvm2cuda == nullptr)
        std::cout << "nvm2cuda == nullptr" << std::endl;
}

terminal window:

ERROR dwImageStreamer_reveiveCUDA: DW_TIME_OUT
ImageStreamer: cannot receive, EGLstream busy

it shows error as above.

I really thank u for your help, i’m so excited to implement our model, i can’t wait to implement it.

Thank u SivaRamaKrishna

Dear

Dear allenchen8210,
Could you please create a separate topic for this query on camera_gsml sample. Also, It is not very clear where you are trying to integrate ImageStreamer code. Could you please share the code if possible in that thread for us to review.

hi, i have already created new topic. Thank u~~~~

https://devtalk.nvidia.com/default/topic/1044946/driveworks/dwimagenvmedia-dwimagestreamer-dwimagecuda/