Having issues Executing filters
ludovicb1239 opened this issue · 1 comments
ludovicb1239 commented
Hi,
It's my first time using this library and it fits my application perfectly. My program is in C. I read the documentation and tried to understand most of it. But the error is output image not specified and I don't understand it. Is it possible to have help ? A few code snippets would go a big way !
`
FILE* fp_in = fopen("render.bmp", "rb");
unsigned char* data = (unsigned char*)malloc(width * height * 3 * sizeof(char));
fread(data, sizeof(char), width * height * 3, fp_in);
//Read the BMP header and check for compatibility
char header[54];
fread(header, sizeof(char), 54, fp_in);
// Create an Intel Open Image Denoise device
OIDNDevice device = oidnNewDevice(OIDN_DEVICE_TYPE_DEFAULT);
oidnCommitDevice(device);
unsigned char* outData = (unsigned char*)malloc(width * height * 3 * sizeof(char));
// Create a filter for denoising a beauty (color) image using optional auxiliary images too
OIDNFilter filter = oidnNewFilter(device, "RT"); // generic ray tracing filte
oidnSetSharedFilterImage(filter, "color", data , OIDN_FORMAT_FLOAT3, width, height, 0, 0, 0);
oidnCommitFilter(filter);
// Filter the image
oidnExecuteFilter(filter);
// Check for errors
const char* errorMessage;
if (oidnGetDeviceError(device, &errorMessage) != OIDN_ERROR_NONE)
printf("Error: %s\n", errorMessage);
FILE* fp_out = fopen("denoised.bmp", "wb");
//free(file_name);
//Write the BMP header to the output file
fwrite(header, sizeof(char), 54, fp_out);
//Write the denoised data to the output file
fwrite(outData, sizeof(char), width * height * 3, fp_out);
//Clean up
free(outData);
fclose(fp_out);
// Cleanup
oidnReleaseFilter(filter);
oidnReleaseDevice(device);`
atafra commented
Please read the documentation. You need to specify an output image too, not just the input.