2016-12-27 15 views
0

アンドロイドレンダスクリプトを使用してアプリケーションを作成しようとしていますが、機能のエッジ検出部分の書き込みに失敗しました。デバイスアンドロイドのバージョンがLolipop以下であれば完璧に動作することがわかりましたが、他のデバイスでは、ほとんどの場合(見たようにコードの変更に依存しないビルドからビルドまでさまざまです)、SIGSEV 11またはSIGBUS 7エラーアドレス障害。Android Renderscript Address Fault

uchar4 __attribute__((kernel)) Edge2(uchar in,uint32_t x, uint32_t y) { 
//sobel 
uint32_t n = max(y - 1, (uint32_t)0); 
uint32_t s = min(y + 1, (uint32_t)height); 
uint32_t e = min(x + 1, (uint32_t)width); 
uint32_t w = max(x - 1, (uint32_t)0); 
const uchar *e11 = rsGetElementAt(gIn, w, n); 
const uchar *e21 = rsGetElementAt(gIn, x, n); 
const uchar *e31 = rsGetElementAt(gIn, e, n); 

const uchar *e12 = rsGetElementAt(gIn, w, y); 
const uchar *e22 = rsGetElementAt(gIn, x, y); 
const uchar *e32 = rsGetElementAt(gIn, e, y); 

const uchar *e13 = rsGetElementAt(gIn, w, s); 
const uchar *e23 = rsGetElementAt(gIn, x, s); 
const uchar *e33 = rsGetElementAt(gIn, e, s); 

float r1 = ((*e12 - *e32)*3 + *e11 + *e13 - *e31 - *e33); 
float r2 = ((*e21 - *e23)*3 + *e11 - *e13 + *e31 - *e33); 
uchar res=(uchar)clamp(sqrt((r1*r1+r2*r2)), 0.0f, 255.0f); 
return (uchar4){res, res, res,(uchar)255}; 
} 

か、これはあまりにも動作しません:

void Edge(const uchar *v_in, uchar4 *v_out, const void *usrData, uint32_t x, uint32_t y){ 

uint32_t n = max(y - 1, (uint32_t)0); 
uint32_t s = min(y + 1, (uint32_t)height); 
uint32_t e = min(x + 1, (uint32_t)width); 
uint32_t w = max(x - 1, (uint32_t)0); 
const uchar *e11 = rsGetElementAt(gIn, w, n); 
const uchar *e21 = rsGetElementAt(gIn, x, n); 
const uchar *e31 = rsGetElementAt(gIn, e, n); 

const uchar *e12 = rsGetElementAt(gIn, w, y); 
const uchar *e22 = rsGetElementAt(gIn, x, y); 
const uchar *e32 = rsGetElementAt(gIn, e, y); 

const uchar *e13 = rsGetElementAt(gIn, w, s); 
const uchar *e23 = rsGetElementAt(gIn, x, s); 
const uchar *e33 = rsGetElementAt(gIn, e, s); 

// 1 0 -1 
// 2 0 -2 
// 1 0 -1 
float r1 = ((*e12 - *e32)*3 + *e11 + *e13 - *e31 - *e33); 
float r2 = ((*e21 - *e23)*3 + *e11 - *e13 + *e31 - *e33); 
uchar res=(uchar)clamp(sqrt((r1*r1+r2*r2)), 0.0f, 255.0f); 
*v_out = (uchar4){res, res, res,(uchar)255}; 
} 

最後の2行(復帰とUCHAR一部)エラーになります

これは、エッジ検出RS実装です。ところで、もし私が "return 10"なんか、そういうものがあれば、それはうまくいきます。

これはJavaの一部です:

public Bitmap doFilter(byte[] data) { 

    _inData.copy1DRangeFrom(0, _previewSamples, data); 
    _inData_yuv.copyFrom(data); 
    _filtersLib.forEach_Edge2(_inData, _outData); 
    yuvToRgbIntrinsic.forEach(_outData_rgb); 
    _filtersLib.forEach_combine(_outData, _outData); 
    _outData.copyTo(_outBmp); 
    return _outBmp;//Bitmap.createScaledBitmap(_outBmp, x, y, false); 
} 

複数scriptCインスタンスがアプリです。これは問題ですか、それともできますか? (何の問題もなく、他のRSファイルでの作業とまったく同じソーベルエッジ検出コード)

エラー:

Fatal signal 7 (SIGBUS), code 2, fault addr 0x8cf7ffff in tid 22666 (om.sketchcamera) 

                [ 12-27 18:36:37.275 317: 317 W/   ] 
                debuggerd: handling request: pid=22625 uid=10124 gid=10124 tid=22666 

デバイス:任意の助けのための一般的な携帯アンドロイド1(アンドロイドN)

おかげ

+0

レンダスクリプトサポートライブラリを使用しているかどうかを確認するだけです。 –

+0

は両方とも試してみましたが、どちらも同じエラーが発生しています –

答えて

2

符号なしのデータ型を使用してxとyの値を渡してから、max(y - 1, (uint32_t)0);などが正しく動作することを期待していますか?バウンドメモリアクセスを左右に行うため、エラーが発生します。

関連する問題