android fatal signal 11 sigsegv,Android Bitmap Fatal signal 11 (SIGSEGV)

I'm developing and android app that take a picture and OCRed it.

I'm getting this error sometime and sometime not without changing my code,

THE ERROR : 01-08 20:41:59.940: A/libc(10967): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1)

I have a method that crop the image to let the user highlight the text :

private void performCrop(){

File file = new File(_path);

Uri outputFileUri = Uri.fromFile(file);

try{

//call the standard crop action intent (the user device may not support it)

Intent cropIntent = new Intent("com.android.camera.action.CROP");

cropIntent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);

//indicate image type and Uri

cropIntent.setDataAndType(picUri, "image/*");

//set crop properties

cropIntent.putExtra("crop", "true");

//indicate aspect of desired crop

cropIntent.putExtra("aspectX", 5);

cropIntent.putExtra("aspectY", 1);

//indicate output X and Y

cropIntent.putExtra("outputX", 500);

cropIntent.putExtra("outputY", 100);

//retrieve data on return

cropIntent.putExtra("return-data", true);

//start the activity - we handle returning in onActivityResult

startActivityForResult(cropIntent, 2);

}catch(ActivityNotFoundException anfe){

//display an error message

String errorMessage = "Whoops - your device doesn't support the crop action!";

Toast toast = Toast.makeText(this, errorMessage, Toast.LENGTH_SHORT);

toast.show();

} catch (Exception ex) {

Log.v(TAG, ex.toString());

}

}

and here is the method that do the OCR :

protected void onPhotoTaken() {

_taken = true;

BitmapFactory.Options options = new BitmapFactory.Options();

options.inSampleSize = 2;

Bitmap bitmap = BitmapFactory.decodeFile(_path, options);

try {

ExifInterface exif = new ExifInterface(_path);

int exifOrientation = exif.getAttributeInt(

ExifInterface.TAG_ORIENTATION,

ExifInterface.ORIENTATION_NORMAL);

Log.v(TAG, "Orient: " + exifOrientation);

int rotate = 0;

switch (exifOrientation) {

case ExifInterface.ORIENTATION_ROTATE_90:

rotate = 90;

break;

case ExifInterface.ORIENTATION_ROTATE_180:

rotate = 180;

break;

case ExifInterface.ORIENTATION_ROTATE_270:

rotate = 270;

break;

}

Log.v(TAG, "Rotation: " + rotate);

if (rotate != 0) {

// Getting width & height of the given image.

int w = bitmap.getWidth();

int h = bitmap.getHeight();

// Setting pre rotate

Matrix mtx = new Matrix();

mtx.preRotate(rotate);

// Rotating Bitmap

bitmap = Bitmap.createBitmap(bitmap, 0, 0, w, h, mtx, false);

}

// Convert to ARGB_8888, required by tess

bitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true);

} catch (IOException e) {

Log.e(TAG, "Couldn't correct orientation: " + e.toString());

}

// _image.setImageBitmap( bitmap );

Log.v(TAG, "Before baseApi");

TessBaseAPI baseApi = new TessBaseAPI();

baseApi.setDebug(true);

baseApi.init(DATA_PATH, lang);

baseApi.setImage(bitmap);

String recognizedText = baseApi.getUTF8Text();

baseApi.end();

// You now have the text in recognizedText var, you can do anything with it.

// We will display a stripped out trimmed alpha-numeric version of it (if lang is eng)

// so that garbage doesn't make it to the display.

Log.v(TAG, "OCRED TEXT: " + recognizedText);

if ( lang.equalsIgnoreCase("eng") ) {

recognizedText = recognizedText.replaceAll("[^a-zA-Z0-9]+", " ");

}

recognizedText = recognizedText.trim();

if ( recognizedText.length() != 0 ) {

_field.setText(_field.getText().toString().length() == 0 ? recognizedText : _field.getText() + " " + recognizedText);

_field.setSelection(_field.getText().toString().length());

}

// Cycle done.

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值