标签: renderscript

如何在Android Renderscript中编写卷积乘法?

我是Android Renderscript的新手.我需要在RenderScript中编写卷积乘法,因为最终的应用程序将在Android上运行.数据流将成为一个图像.更具体地说,我无法使用forEach功能编写核心逻辑,尽管我可以用Java编写,但速度太慢!请帮忙!史蒂夫

android convolution renderscript

5
推荐指数
1
解决办法
5612
查看次数

如何在renderscript和android框架之间交换数据?

我是renderscript的新手.我试图使用renderscript添加两个数组元素.

我可以通过方法将值传递给Android的renderscript,invoke_add以便从我建议使用的renderscript返回到Android框架 rsSendToclient().

我如何使用rsSendToClient或任何其他方式回到Android框架.

android renderscript

5
推荐指数
1
解决办法
786
查看次数

Renderscript和GPU

知道那的renderScript的设计是为了掩盖什么处理器我运行的事实,但有什么办法编写代码,使得在GPU专用计算功能的设备(目前,Nexus 10的),它运行GPU?有没有办法告诉脚本的功能是否在GPU上运行?

www.leapconf.com/downloads/LihuaZhang-MulticoreWare.pdf建议如果我不使用全局变量,我不使用递归,并且不在内核中的任何地方调用rsDebug,它将在GPU上运行; 那是对的吗?

我希望看到人们以某种​​方式验证过的短脚本将作为纯粹基于计算的任务运行在gpu上(例如,没有图形工作).

gpu renderscript

5
推荐指数
1
解决办法
1108
查看次数

Allocation.copyTo(Bitmap)破坏像素值

我是Renderscript的新手,我的第一个剧本引人注目.据我所知(从我插入的调试语句)我的代码工作正常,但是当它们被Allocation.copyTo(Bitmap)方法复制回Bitmap时,计算值会变得严重.

我得到了奇怪的颜色,所以最终剥离了我的脚本到这个样本,显示了问题:

void root(const uchar4 *v_in, uchar4 *v_out, const void *usrData, uint32_t x, uint32_t y)
{
   *v_out = rsPackColorTo8888(1.f, 0.f, 0.f, 1.f);

   if (x==0 && y==0) {
      rsDebug("v_out ", v_out->x, v_out->y, v_out->z, v_out->w);
   }
}
Run Code Online (Sandbox Code Playgroud)

这里我们只写出一个不透明的红色像素.调试行似乎打印正确的值(255 0 0 255),实际上我在位图中得到一个红色像素.

但是,如果我稍微更改红色像素上的alpha:

*v_out = rsPackColorTo8888(1.f, 0.f, 0.f, 0.998f);
Run Code Online (Sandbox Code Playgroud)

调试打印(255 0 0 254)仍然看似正确,但最终像素值最终为(0 0 0 254)即.黑色.

显然我怀疑这是一个预先提示的alpha问题,但我的理解是,从Bitmaps复制到Bitmaps的Allocation例程应该为你处理.至少这是Chet Haase在这篇博客文章中建议的:https://plus.google.com/u/0/+ChetHaase/posts/ef6Deey6xKA.

此外,没有任何示例计算脚本似乎提及预乘alpha的任何问题.我的脚本基于SDK中的HelloComputer示例.

如果我犯了一个错误,我会喜欢RS大师为我指出它.

令人遗憾的是,经过2年多的努力,Renderscript的文档仍然很糟糕.

PS.我正在使用的位图是ARGB_888,我正在构建和定位SDK18(Android 4.3)

android renderscript

5
推荐指数
1
解决办法
555
查看次数

RenderScript的Allocation.getSurface()函数总是抱怨"在没有当前上下文的情况下调用OpenGL ES API"

我在Android 4.2版上使用RenderScript.我试图使用"Allocation.USAGE_IO_INPUT"标志创建RenderScript分配.根据该文档,如果设置了"Allocation.USAGE_IO_INPUT",则Allocation将用作SurfaceTexture使用者,并且成员函数"getSurface()"也将变为有效.但是,当我调用getSurface()函数时,我总是收到以下错误消息.

E/libEGL(31656): call to OpenGL ES API with no current context (logged once per thread)
Run Code Online (Sandbox Code Playgroud)

我google了一下,发现大多数人都说这样的错误信息是由GL线程外部调用OpenGL ES API引起的.所以我尝试使用我发现的以下两种方式.

  1. 从GLSurfaceView的onSurfaceCreated()调用getSurface()函数,因为它在GL线程中调用
  2. 使用GLSurfaceView的queueEvent让代码在GL线程中调用(此处描述:OpenGL ES API错误(无上下文))

然而,两次尝试都失败了.

虽然该程序没有崩溃与此错误提示,并确实返回一些表面.我遇到了与调用Allocation.ioReceive()函数时使用由Camera预览填充的SurfaceTexture作为Jelly Bean中的Renderscript输入分配相同的问题.我在调用ioReceive()时得到的错误信息是

E/SurfaceTexture(32208): [unnamed-32208-2] updateTexImage: invalid current EGLDisplay
Run Code Online (Sandbox Code Playgroud)

那么,我想知道在RenderScript中使用USAGE_IO_INPUT Allocation的正确方法是什么?非常感谢你提前.

android allocation opengl-es renderscript

5
推荐指数
0
解决办法
766
查看次数

没有rsDebug,RenderScript代码无法正常工作

我是RenderScript的新手.我试图在http://www.youtube.com/watch?v=5jz0kSuR2j4找到 Romain Guy展示的一个简单示例.

首先,这是代码.

MainActivity.java

    package com.example.rsgray;

    import android.app.Activity;
    import android.graphics.Bitmap;
    import android.graphics.BitmapFactory;
    import android.os.Bundle;
    import android.renderscript.Allocation;
    import android.renderscript.RenderScript;
    import android.view.Window;
    import android.view.WindowManager;
    import android.widget.ImageView;
    import android.widget.ImageView.ScaleType;

    public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    ImageView iv = new ImageView(this);
    iv.setScaleType(ScaleType.CENTER_CROP);
    setContentView(iv);

    drawGrayScale(iv, R.drawable.tulips);
}

private void drawGrayScale(ImageView iv, int image) {
    Bitmap in = BitmapFactory.decodeResource(getResources(), image);
    Bitmap out = Bitmap.createBitmap(in.getWidth(), in.getHeight(), in.getConfig());

    RenderScript rs = RenderScript.create(MainActivity.this);
    Allocation inAlloc = …
Run Code Online (Sandbox Code Playgroud)

android renderscript

5
推荐指数
1
解决办法
1865
查看次数

RenderScript绑定指针与分配

RenderScript是否保证内存布局或跨越从Java层绑定的全局指针?

我在某处读到最好使用rsGetElementAt/rsSetElementAt函数,因为不保证布局.

其他地方据说在针对GPU优化时避免使用这些优化,而绑定指针则可以.


在我的特定情况下,我需要内核来访问许多周围像素的值.到目前为止,我已经完成了从Java层绑定的浮点指针.

Java的:

script.set_width(inputWidth);
script.bind_input(inputAllocation);
Run Code Online (Sandbox Code Playgroud)

RS:

int width;
float *input;

void root(const float *v_in, float *v_out, uint32_t x, uint32_t y) {
    int current = x + width * y;
    int above   = current - width;
    int below   = current + width;

    *v_out = input[above   - 1] + input[above  ] + input[above   + 1] +
             input[current - 1] + input[current] + input[current + 1] +
             input[below   - 1] + input[below  ] + input[below   + 1] …
Run Code Online (Sandbox Code Playgroud)

android renderscript

5
推荐指数
1
解决办法
1070
查看次数

加载RS jni库时出错:UnsatisfiedLinkError:无法加载RSSupport:findLibrary返回null

将RenderScript与支持库一起使用时,我在Motorola iRazr(Android 4.1.2)上出现此错误

Error loading RS jni library: java.lang.UnsatisfiedLinkError: Couldn't load RSSupport: findLibrary returned null
Run Code Online (Sandbox Code Playgroud)

三星Galaxy S3上的一切正常.

        Bitmap outputBitmap = Bitmap.createBitmap(inputBitmap);

        RenderScript rs = RenderScript.create(ctx);

        ScriptIntrinsicBlur theIntrinsic = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));

        Allocation tmpIn = Allocation.createFromBitmap(rs, inputBitmap);
        Allocation tmpOut = Allocation.createFromBitmap(rs, outputBitmap);

        theIntrinsic.setRadius(BLUR_RADIUS);
        theIntrinsic.setInput(tmpIn);
        theIntrinsic.forEach(tmpOut);

        tmpOut.copyTo(outputBitmap);
Run Code Online (Sandbox Code Playgroud)

我使用的支持库jar是

build-tools/19.0.1/renderscript/lib/renderscript-v8.jar
Run Code Online (Sandbox Code Playgroud)

任何帮助深表感谢.

编辑:

我将这些文件复制到libs文件夹中,并验证了so文件是否在设备上的data/data/lib文件夹中.

librsjni.solibRSSupport.so存在于设备上...

编辑:

更详细的错误:

  02-26 16:17:42.311: D/dalvikvm(16985): Trying to load lib /data/data/de.proximity.hero/lib/libRSSupport.so    0x42616b70
  02-26 16:17:42.321: D/dalvikvm(16985): Added shared lib /data/data/de.proximity.hero/lib/libRSSupport.so 0x42616b70
  02-26 16:17:42.321: D/dalvikvm(16985): No JNI_OnLoad found in /data/data/de.proximity.hero/lib/libRSSupport.so …
Run Code Online (Sandbox Code Playgroud)

android renderscript android-support-library

5
推荐指数
2
解决办法
6242
查看次数

RenderScript支持库在x86设备上崩溃

我正在android.support.v8.renderscript.*使用x86设备Razor i 运行FATAL EXCEPTION .如果我使用问题就消失了.android.renderscript.*此外,ARM设备没有问题.这是一个例外:

03-03 18:35:26.009  25011-25011/com.example.app E/AndroidRuntime? FATAL EXCEPTION: main
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.app/com.example.app.MainActivity}: android.support.v8.renderscript.RSRuntimeException: Error loading RS jni library: java.lang.UnsatisfiedLinkError: Cannot load library: reloc_library[1306]:   143 cannot locate '__strlen_chk'...
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2115)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2153)
            at android.app.ActivityThread.access$700(ActivityThread.java:137)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1246)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:5031)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:511)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: android.support.v8.renderscript.RSRuntimeException: Error loading RS jni library: java.lang.UnsatisfiedLinkError: Cannot load library: reloc_library[1306]:   143 cannot locate '__strlen_chk'... …
Run Code Online (Sandbox Code Playgroud)

android renderscript

5
推荐指数
3
解决办法
2807
查看次数

RenderScript: Using ScriptGroup for image process causes horizontal stripes

Problem Description:

I write a simple demo using RenderScrip for image process. In my demo, when I use a one-kernal renderscript, it works fine. Yet when I use a script group to connect two rs-kernals for execution, I found the output bitmap with horizontal stripes. Especially when you chose a bitmap with small size.

The output bitmap when I use a one-kernal renderscript: The output bitmap when I use a one-kernal renderscript

The output bitmap when I use a script group to connect two rs-kernals. Note these two rs-kernals …

android bitmap renderscript

5
推荐指数
1
解决办法
384
查看次数