I'm trying to use open image denoise. Here's the code:
int main() {
int width, height, nrChannels;
unsigned char* image = stbi_load("img_cornell_box.png", &width, &height, &nrChannels, 0);
unsigned char* resultImage = new unsigned char[width*height*nrChannels];
oidn::DeviceRef device = oidn::newDevice();
device.commit();
std::cout << nrChannels << std::endl;
oidn::FilterRef filter = device.newFilter("RT");
filter.setImage("color", image, oidn::Format::Float4, width, height);
filter.setImage("output", resultImage, oidn::Format::Float4, width, height);
filter.set("hdr", false);
filter.set("srgb", true);
filter.commit();
filter.execute();
const char* errorMessage;
if (device.getError(errorMessage) != oidn::Error::None) {
std::cout << "Error: " << errorMessage << std::endl;
}
else {
stbi_write_png("img.png", width, height, nrChannels, resultImage, width * nrChannels);
}
}
I'm getting an error saying that the image format is unsupported.
If I use jpg, and change Format::Float4 to Format::Float3 I get this error:
Exception thrown at 0x00007FFC5588E1F5 (OpenImageDenoise.dll) in oidntest.exe: 0xC0000005: Access violation reading location 0x0000021D9C42FA70.
Am I doing something wrong? This is the image I'm using: https://drive.google.com/open?id=1uSjsyWCRisXNFUJG6R8iL5AdVbM7_18u