这个问题已经讨论了好几次,但是我无法让它发挥作用.我尝试了构建工具v23,甚至没有编译,所以我转移到编译脚本代码的21版本.ScriptC_rotator类现在在app\build\generated\source\rs\debug\com\models中生成.但是,现在我得到运行时'加载ScriptC脚本'.不知道如何解决这个问题.
public Bitmap rotate(Bitmap bitmap) {
Bitmap target = null;
try {
RenderScript rs = RenderScript.create(activity);
ScriptC_rotator script = new ScriptC_rotator(rs); // this is where the error occur.
script.set_inWidth(bitmap.getWidth());
script.set_inHeight(bitmap.getHeight());
Allocation sourceAllocation = Allocation.createFromBitmap(rs, bitmap,
Allocation.MipmapControl.MIPMAP_NONE,
Allocation.USAGE_SCRIPT);
bitmap.recycle();
script.set_inImage(sourceAllocation);
int targetHeight = bitmap.getWidth();
int targetWidth = bitmap.getHeight();
Bitmap.Config config = bitmap.getConfig();
target = Bitmap.createBitmap(targetWidth, targetHeight, config);
final Allocation targetAllocation = Allocation.createFromBitmap(rs, target,
Allocation.MipmapControl.MIPMAP_NONE,
Allocation.USAGE_SCRIPT);
script.forEach_rotate_90_clockwise(targetAllocation, targetAllocation);
targetAllocation.copyTo(target);
rs.destroy();
}
catch(Exception e){
}
return target;
}
Run Code Online (Sandbox Code Playgroud)
错误: android.support.v8.renderscript.RSRuntimeException:加载ScriptC脚本失败.
摇篮:
compileSdkVersion 21 …Run Code Online (Sandbox Code Playgroud) 我正在研究Renderscript功能并坚持使用A3D(Android 3d)文件格式.我找不到一种简单的方法将Collada文件转换为A3D格式来存储我的搅拌机模型.
我想知道你们是否有想法我可以尝试一下?
有没有人有一个工作代码示例,这样可以看到我做错了什么?
更多信息:http://developer.android.com/reference/android/renderscript/FileA3D.html
编辑:不要误认为Asci3d文件扩展(也是*.a3d)
在Jelly Bean中,是否可以使用由相机预览填充的SurfaceTexture创建Renderscript分配?我正在Android源代码树中构建我的应用程序,所以我可以使用@hide API,例如Allocation.setSurfaceTexture().但是我想避免使用RS Graphics弃用的API.这里的类似问题没有得到完全回答,也没有特定于JB的问题.
尝试以下代码时出现以下问题:
(我知道我正在使用的设备确实支持所请求的VGA分辨率).
public class SampleRSCPCActivity extends Activity implements SurfaceTexture.OnFrameAvailableListener {
final static int DO_KERNEL = 0;
private static final String TAG="SAMPLERSCP";
private static Camera mCamera;
private Camera.Parameters mParams;
private int mFrameWidth, mFrameHeight;
private static SurfaceTexture mST;
private RenderScript mRS;
private Allocation mInAllocation;
private Allocation mOutAllocation;
private ScriptC_mono mScript;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.i(TAG, "onCreate()");
createGUI();
createCamera();
createRSEnvironment();
}
public void onPause() {
Log.i(TAG, "onPause");
mCamera.stopPreview();
mCamera.release();
mCamera …Run Code Online (Sandbox Code Playgroud) 我尝试在Android 2.3.5上运行Renderscript示例HelloCompute.
(我使用v22.2.1-833290和SDK 22.2.1 我从Logcat收到一条错误消息:
W/dalvikvm( 4928): VFY: unable to resolve static method 412: Landroid/renderscript /RenderScript;.create (Landroid/content/Context;)Landroid/renderscript/RenderScript;
W/dalvikvm( 4928): threadid=1: thread exiting with uncaught exception (group=0x4002d560)
E/AndroidRuntime( 4928): FATAL EXCEPTION: main
E/AndroidRuntime( 4928): java.lang.NoSuchMethodError: android.renderscript.RenderScript.create
Run Code Online (Sandbox Code Playgroud)
为了制作apk包,我在构建步骤中添加了Android支持库v13.
我想renders脚库没有正确添加到构建步骤中.抱歉,我找不到Android支持库v8,如以下帖子 http://android-developers.blogspot.com/2013/09/renderscript-in-android-support-library.html
怎么能克服这个问题?
最新的Android SDK(R22)已删除android.renderscript.RSSurfaceView和android.renderscript.RenderScriptGL类.我们如何在SurfaceView或常规Android View上直接使用RenderScript?
我正在尝试在API 16及更高版本的设备上使用Android Renderscript支持库,遵循此处描述的步骤.到目前为止事情并不顺利.
我的Renderscript代码如下所示.
#pragma version(1)
#pragma rs java_package_name(com.xxx.renderscript.test)
#include "rs_time.rsh"
rs_script flipScript;
rs_allocation gIn;
rs_allocation gOut;
int width;
int height;
int direction = 0;
void root(uchar4 *v_out, const void *usrData, uint32_t x, uint32_t y) {
if(direction == 0) { // flip horizontally
const uchar4 *element = rsGetElementAt(gIn, width - x, y);
float4 color = rsUnpackColor8888(*element);
float4 output = {color.r, color.g, color.b};
*v_out = rsPackColorTo8888(output);
}
else if(direction == 1) { // flip vertically
const uchar4 *element = …Run Code Online (Sandbox Code Playgroud) 背景:
我想根据Android相机应用程序的代码添加实时过滤器.但Android相机应用程序的架构基于OpenGL ES 1.x. 我需要使用着色器来自定义我们的过滤器实现.但是,将相机应用程序更新为OpenGL ES 2.0非常困难.然后我必须找到一些其他方法来实现实时过滤器而不是OpenGL.经过一些研究,我决定使用渲染脚本.
问题:
我已经通过渲染脚本编写了一个简单过滤器的演示.它表明fps远低于OpenGL实现它.大约5 fps vs 15 fps.
问题:
Android官方异地说:RenderScript运行时将并行处理设备上可用的所有处理器(如多核CPU,GPU或DSP)的工作,使您可以专注于表达算法而不是调度工作或负载平衡.那为什么渲染脚本实现较慢?
如果渲染脚本不能满足我的要求,有没有更好的方法?
代码详情:
嗨,我和提问者在同一个团队中.我们想要编写一个基于渲染脚本的实时滤镜相机.在我们的测试演示项目中,我们使用了一个简单的过滤器:添加了覆盖过滤器ScriptC脚本的YuvToRGB IntrinsicScript.在OpenGL版本中,我们将相机数据设置为纹理,并使用着色器执行image-filter-procss.像这样:
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureYHandle);
GLES20.glUniform1i(shader.uniforms.get("uTextureY"), 0);
GLES20.glTexSubImage2D(GLES20.GL_TEXTURE_2D, 0, 0, 0, mTextureWidth,
mTextureHeight, GLES20.GL_LUMINANCE, GLES20.GL_UNSIGNED_BYTE,
mPixelsYBuffer.position(0));
Run Code Online (Sandbox Code Playgroud)
在RenderScript版本中,我们将相机数据设置为Allocation,并使用script-kernals执行image-filter-procss.像这样:
// The belowing code is from onPreviewFrame(byte[] data, Camera camera) which gives the camera frame data
byte[] imageData = datas[0];
long timeBegin = System.currentTimeMillis();
mYUVInAllocation.copyFrom(imageData);
mYuv.setInput(mYUVInAllocation);
mYuv.forEach(mRGBAAllocationA);
// To make sure the process of YUVtoRGBA has finished!
mRGBAAllocationA.copyTo(mOutBitmap);
Log.e(TAG, "RS time: YUV to RGBA : " …Run Code Online (Sandbox Code Playgroud) 我正在使用Android Renderscript本机库,但导出时我的*.so文件没有打包APK.
当我运行它时,该应用程序运行正常,Eclipse但这显然是APK文件的包问题:
Caused by: android.support.v8.renderscript.r: Error loading RS jni library: java.lang.UnsatisfiedLinkError: unknown failure
Run Code Online (Sandbox Code Playgroud)
我该怎么做才能添加*.so文件APK?
我想研究一下在Android和Renderscript上创建Renderscript脚本,在过去的一年里,Android-Studio成为Google支持Android应用开发的唯一IDE.
为此,我找到了多个网站,如下:
事实上,我见过的所有教程和示例都是针对Eclipse的,他们说我需要做的就是在"raw"文件夹中创建一个"rs"文件(也在"src"文件夹中尝试过, "MainActivity.java"文件的相同文件夹,它将为我自动生成所需的Java文件,前缀为"ScriptC_".
但它对我不起作用.
我已经从我发现的一些样本(对于Eclipse)创建了一个名为"julia.rs"的文件.这是代码:
#pragma version(1)
#pragma rs java_package_name(lb.com.myapplication)
float cx;
float cy;
float width;
float height;
float zoom;
int precision;
uchar *color;
void root(const uchar4 *in, uchar4 *out, uint32_t x, uint32_t y) {
float fx = (x + 0.5f) / width * (4.f / zoom) - (2.f / zoom);
float fy = (y + 0.5f) / height * (4.f / zoom) - (2.f / zoom);
float t = 0; …Run Code Online (Sandbox Code Playgroud) 我们使用renderscript进行音频dsp处理.它很简单,并且对我们的用例显着提高了性能.但是USAGE_SHARED,对于具有启用GPU执行的自定义驱动程序的设备,我们遇到了一个恼人的问题.
您可能知道,USAGE_SHAREDflag使renderscript分配重用给定的内存,而不必创建它的副本.因此,它不仅可以节省内存,在我们的情况下,可以将性能提高到所需的水平.
以下代码USAGE_SHARED在默认的renderscript驱动程序(libRSDriver.so)上工作正常.使用自定义驱动程序(libRSDriver_adreno.so)USAGE_SHARED不会重用给定的内存,从而重用数据.
这是使用USAGE_SHARED和调用renderscript内核的代码
void process(float* in1, float* in2, float* out, size_t size) {
sp<RS> rs = new RS();
rs->init(app_cache_dir);
sp<const Element> e = Element::F32(rs);
sp<const Type> t = Type::create(rs, e, size, 0, 0);
sp<Allocation> in1Alloc = Allocation::createTyped(
rs, t,
RS_ALLOCATION_MIPMAP_NONE,
RS_ALLOCATION_USAGE_SCRIPT | RS_ALLOCATION_USAGE_SHARED,
in1);
sp<Allocation> in2Alloc = Allocation::createTyped(
rs, t,
RS_ALLOCATION_MIPMAP_NONE,
RS_ALLOCATION_USAGE_SCRIPT | RS_ALLOCATION_USAGE_SHARED,
in2);
sp<Allocation> outAlloc = Allocation::createTyped(
rs, t,
RS_ALLOCATION_MIPMAP_NONE,
RS_ALLOCATION_USAGE_SCRIPT | RS_ALLOCATION_USAGE_SHARED, …Run Code Online (Sandbox Code Playgroud) performance android signal-processing renderscript android-renderscript
android ×10
renderscript ×10
eclipse ×2
collada ×1
java ×1
opengl-es ×1
performance ×1
surfaceview ×1