loading an external image into an optiX buffer


i want to load an external image (.jpg, .ppm) into an optiX buffer to denoise it afterwards. i tried something like this below. I loaded the image with openCV, resized the buffer to the size of the image and tried to map the image to the buffer.

cv::Mat src = cv::imread(file_path);
int width = src.cols;
int height = src.rows;
sutil::resizeBuffer(getBuffer(), width, height);
void *dst = getBuffer()->map(0, RT_BUFFER_MAP_WRITE_DISCARD);
memcpy(dst, &src, sizeof(src));

The program throws an exception like:

“Microsoft C++ exception: prodlib::InvalidValue at memory location 0x000000000013F2E0”.

I would guess that an openCV Mat is not the correct datatyp to assign a image to the buffer. Does anyone could point me to a correct direction, so that i can load an external image to an optiX buffer?

Thank you in advance! Cheers, Jakob

Before you can upload data to an OptiX buffer you need to set its type, format, element size, and dimension. That needs to match whatever you’re trying to upload to an input or input_output buffer in that incomplete code excerpt.
Format and element size is implicit for the predefined types. Everything else is a user format.

If you are a beginning with OptiX, please watch the OptiX Introduction presentation and work through the individual examples.
All links here: https://devtalk.nvidia.com/default/topic/998546/optix/optix-advanced-samples-on-github/

All OptiX examples are creating buffers because that is the only way to return data, so there are plenty of examples how to create and fill input buffers and read from output buffers correctly.
I would not recommend to use the sutil:: functions as beginner. You need to understand the core API first.

(Please be careful when submitting posts. This thread appeared three times and the third was already flagged as SPAM. I deleted the duplicates.)

I didnt understand how can I create a floor from mesh with some image on it.
can you point on specific code that do such a thing?

Please find my answer in the other thread: