nvxcuRemap - how do you create tables?

Hi I’m using VisionWorks NVX CUDA Primitives API,
I wanted to use the nvxcuRemap function to remap the input image without distortions, I have the problem of how to create the table input.

nvxcu_error_status_e nvxcuRemap ( const nvxcu_image_t * input ,
const nvxcu_image_t * table ,
nvxcu_interpolation_type_e policy ,
const nvxcu_image_t * output ,
const nvxcu_border_t * border ,
const nvxcu_exec_target_t * exec_target

I have map_x and map_y in cv::Mat but the object nvxcu_pitch_linear_image_t is only one but comparing the pitch size nvxcu with the sum of the two cv::Mat map_x and map_y are equal. What I didn’t understand is how to write in nvxcu_pitch_linear_image_t the two vectors cv::Mat.

when I had to write an single image I did this

nvxcu_pitch_linear_image_t image = { };

image.base.format = NVXCU_DF_IMAGE_RGB;
image.base.image_type = NVXCU_PITCH_LINEAR_IMAGE;
image.base.width = frameWidth;
image.base.height = frameHeight;

size_t pitch = 0ul;
uint32_t cn =  3u;

NVXIO_CUDA_SAFE_CALL( cudaMallocPitch(&image.planes[0].dev_ptr, &pitch,
                      image.base.width * cn, image.base.height) );
image.planes[0].pitch_in_bytes = static_cast<uint32_t>(pitch);

cv::cvtColor(frame_left, frame_left, cv::COLOR_BGR2RGB);

My problem is how to load two vectors cv::Mat in an nvxcu_pitch_linear_image_t ?


The table should be NVXCU_DF_IMAGE_2F32, which indicates a size=2 array of nvxcu_pitch_linear_image_t.
So instead of loading two vectors cv::Mat in an nvxcu_pitch_linear_image_t, you should create a nvxcu_pitch_linear_image_t for each cv::Mat.


did you mean in this way?

    nvxcu_pitch_linear_image_t table_left = { };
    table_left.base.format = NVXCU_DF_IMAGE_2F32;
    table_left.base.image_type = NVXCU_PITCH_LINEAR_IMAGE;
    table_left.base.width = frameWidth;
    table_left.base.height = frameHeight;
    size_t pitch = 0ul;
    NVXIO_CUDA_SAFE_CALL( cudaMallocPitch(&table_left.planes[0].dev_ptr, &pitch, table_left.base.width * sizeof(float), table_left.base.height) );
    table_left.planes[0].pitch_in_bytes = static_cast<uint32_t>(pitch);
    NVXIO_CUDA_SAFE_CALL( cudaMallocPitch(&table_left.planes[1].dev_ptr, &pitch, table_left.base.width * sizeof(float), table_left.base.height) );
    table_left.planes[1].pitch_in_bytes = static_cast<uint32_t>(pitch);

this is the result


my solution is wrong, in the documentation it talks about only one planes.

NVXCU_DF_IMAGE_2F32 | A single plane of float32_t[2] data (for example, motion fields).


Please create a nvxcu_pitch_linear_image_t array with size = 2.

nvxcu_pitch_linear_image_t table[2];
table[0].base.format = NVXCU_DF_IMAGE_2F32;
table[0].base.image_type = NVXCU_PITCH_LINEAR_IMAGE;
table[0].base.width = frameWidth;
table[0].base.height = frameHeight;

size_t pitch = 0ul;
NVXIO_CUDA_SAFE_CALL( cudaMallocPitch(&table[0].planes[0].dev_ptr, &pitch, table[0].base.width * sizeof(float), table[0].base.height) );
table[0].planes[0].pitch_in_bytes = static_cast<uint32_t>(pitch);

table[1].base.format = NVXCU_DF_IMAGE_2F32;
table[1].base.image_type = NVXCU_PITCH_LINEAR_IMAGE;
table[1].base.width = frameWidth;
table[1].base.height = frameHeight;

pitch = 0ul;
NVXIO_CUDA_SAFE_CALL( cudaMallocPitch(&table[1].planes[0].dev_ptr, &pitch, table[1].base.width * sizeof(float), table[1].base.height) );
table[1].planes[0].pitch_in_bytes = static_cast<uint32_t>(pitch);

I’ve done it, now what should I pass to the function expects a “const nvxcu_image_t * table”. I used to get this with “&table.base”. but now I have an nvxcu_pitch_linear_image_t[2] table how do I pass it?

There is no update from you for a period, assuming this is not an issue any more.
Hence we are closing this topic. If need further support, please open a new one.


Could you pass the &table to see if it works first?