RealSR-NCNN-Android icon indicating copy to clipboard operation
RealSR-NCNN-Android copied to clipboard

How can I directly use the functions of RealSR without calling through the CLI?

Open laverne01 opened this issue 7 months ago • 7 comments

I tried creating a convert function in JNI (which calls the process function of RealSR) and used it in Kotlin. However, the output image after upscaling is just black. I would appreciate your advice on what might be going wrong.

JNIEXPORT jobject JNICALL Java_com_example_realsrandroid_ImageUpscale_convert( JNIEnv *env, jobject /* this */, jobject bitmapIn, jobject assetManager) { ncnn::Mat in_img = ncnn::Mat::from_android_bitmap(env, bitmapIn,ANDROID_BITMAP_FORMAT_RGBA_8888); ncnn::Mat out_img = ncnn::Mat(in_img.w * scale, in_img.h * scale, in_img.c, (size_t) in_img.elemsize, in_img.elempack); realsr.process(in_img, out_img); out_img.to_android_bitmap(env, bitmapIn, ANDROID_BITMAP_FORMAT_RGBA_8888); return bitmapIn; }

I have initialized RealSR on it.

realsr.scale = 4; realsr.tilesize = 200; realsr.prepadding = 10; AAssetManager *mgr = AAssetManager_fromJava(env, assetManager); realsr.load(mgr);

laverne01 avatar Jul 01 '24 10:07 laverne01