The Offline Super-Resolution plug-in enables high-quality game-scene screenshots with improved image resolution and detail performance.
To use the Occlusion Culling plug-in, you need to:
In this codelab, you will use the demo project to call Offline Super-Resolution plug-in SDK APIs. Through this demo project, you will:
Configure build options.
CSetAssetsDir("/sdcard/osr");
const char *assetsDir = CGetAssetsDir();
printf("Set directory to %s", assetsDir);
CInitialize();
BufferDescriptor inBuffer;
int w, h;
unsigned char *pixels = ReadPPM(path, w, h);
inBuffer.addr = static_cast<void *>(pixels);
inBuffer.width = w;
inBuffer.height = h;
inBuffer.len = w * h * CHANNELS_RGB;
inBuffer.format = PIXEL_FORMAT_R8G8B8_UNORM;
PluginConfig pluginConfig;
CQuerySuperSamplingPluginConfig(inBuffer.width, inBuffer.height, inBuffer.format, pluginConfig);
int outW = pluginConfig.output.width;
int outH = pluginConfig.output.height;
PixelFormat outFormat = pluginConfig.output.format;
int estimatedTime = pluginConfig.estimatedCostTime;
b) Query the support for the image processing super-resolution capability.
PluginConfig pluginConfig;
CQuerySuperSamplingPluginConfig(inBuffer.width, inBuffer.height, inBuffer.format, pluginConfig);
int outW = pluginConfig.output.width;
int outH = pluginConfig.output.height;
PixelFormat outFormat = pluginConfig.output.format;
int estimatedTime = pluginConfig.estimatedCostTime;
BufferDescriptor outBuffer;
unsigned char *pixels = new(std::nothrow)
unsigned char[outW * outH * Format2Channel(outFormat)];
outBuffer.addr = static_cast<void *>(pixels);
outBuffer.width = outW;
outBuffer.height = outH;
outBuffer.len = outW * outH * Format2Channel(outFormat);
outBuffer.format = outFormat;
int timeout = 10000;
bool success = CSuperSamplingSyncExecute(&inBuffer, &outBuffer, timeout);
a) Synchronously execute the image processing super-resolution capability.
int timeout = 10000;
float sharpness = 0.6;
bool tonemapping = true;
bool success = CImageEnhancingSyncExecute(&inBuffer, &outBuffer, sharpness, tonemapping, timeout);
void CallBack(bool success)
{
// Perform operations based on the execution result.
return;
}
a) Asynchronously execute the AI super-resolution API.
bool success = CSuperSamplingAsyncExecute(&inBuffer, &outBuffer, CallBack);
std::this_thread::sleep_for(std::chrono::seconds(5));
b) Asynchronously execute the image processing super-resolution capability.
int timeout = 10000;
float sharpness = 0.6;
bool tonemapping = true;
bool success = CImageEnhancingAsyncExecute(&inBuffer, &outBuffer, sharpness, tonemapping, CallBack);
std::this_thread::sleep_for(std::chrono::seconds(2));
delete[](static_cast<unsigned char *>(inBuffer.addr));
delete[](static_cast<unsigned char *>(outBuffer.addr));
CUninitialize();
Well done. You have successfully completed this codelab and learned how to:
For more information, click the following links:
Related documents
Download the demo source code used in this codelab from the following address: