I am developing an Android application and take a picture and recognize it.
I get this error once and sometimes without changing the code,
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 so that the user selects 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 runs 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) {
Firas al mannaa
source share