Alex2452
Alex2452

Reputation: 334

Renderscript Intrinscics methods within a custom .rs file on Android

is it possible to call ScriptIntrinsics methods within a custom .rs file on Android? What I'd like to achieve is to convert a video frame from YUV to RGBA ,then apply gaussian blur.

Cheers!

Upvotes: 1

Views: 191

Answers (2)

Alex2452
Alex2452

Reputation: 334

Thank you for feedback but I already found a solution with using the ScriptGroup.Builder to instantiate multiple scripts in one chain.

        // Create a group YUV->RGB + Blur chain
        ScriptGroup.Builder b = new ScriptGroup.Builder(rs);
        b.addKernel(scriptIntrinsicYuvToRGB.getKernelID());
        b.addKernel(scriptIntrinsicBlur.getKernelID());

        // Connection is on RGBA8888 side
        b.addConnection(rgbTypeBuilder.create(), scriptIntrinsicYuvToRGB.getKernelID(), scriptIntrinsicBlur.getFieldID_Input());
        mScriptGroup = b.create();

        // Set output
        mScriptGroup.setOutput(scriptIntrinsicBlur.getKernelID(), mOutputAllocation);
        scriptIntrinsicYuvToRGB.setInput(mInputAllocation);

Then just call the mScriptGroup.execute() to make it run as needed.

Upvotes: 2

Quentin Menini
Quentin Menini

Reputation: 160

You cannot use a script inside a rs file to my knowledge, but what you can do is call the scripts one after another using the output allocation for the first script as the input allocation for the second, this should give you the expected results

Upvotes: 0

Related Questions