1
我使用Google的vision API來檢測圖像中的文本。我把它設置在一個圖像視圖中,並放置一個按鈕,並點擊它處理它並顯示文本的按鈕。如果我點擊一張圖片或從圖片上傳一張圖片,這可以正常工作。我也提供了一個裁剪選項,當我點擊該按鈕並設置圖像時,點擊該按鈕,應用程序崩潰。這是我的日誌:OCR應用程序崩潰給出錯誤:jni_helper.cc:110位圖格式錯誤:4
A/native: jni_helper.cc:110 Bitmap is of the wrong format: 4
07-15 15:14:35.511 6965-6965/com.cameradetect A/native: terminating.
07-15 15:14:35.512 6965-6965/com.cameradetect A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 6965 (om.cameradetect)
07-15 15:14:35.614 1368-1368/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
07-15 15:14:35.614 1368-1368/? A/DEBUG: Build fingerprint: 'Android/sdk_google_phone_x86_64/generic_x86_64:6.0/MASTER/3738108:userdebug/test-keys'
07-15 15:14:35.614 1368-1368/? A/DEBUG: Revision: '0'
07-15 15:14:35.614 1368-1368/? A/DEBUG: ABI: 'x86_64'
07-15 15:14:35.614 1368-1368/? A/DEBUG: pid: 6965, tid: 6965, name: om.cameradetect >>> com.cameradetect <<<
07-15 15:14:35.615 1368-1368/? A/DEBUG: signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
07-15 15:14:35.623 1368-1368/? A/DEBUG: Abort message: 'jni_helper.cc:110 Bitmap is of the wrong format: 4
'
07-15 15:14:35.624 1368-1368/? A/DEBUG: rax 0000000000000000 rbx 00007fce9d1a52c0 rcx ffffffffffffffff rdx 0000000000000006
07-15 15:14:35.624 1368-1368/? A/DEBUG: rsi 0000000000001b35 rdi 0000000000001b35
07-15 15:14:35.624 1368-1368/? A/DEBUG: r8 0000000000000003 r9 0000000000000003 r10 0000000000000008 r11 0000000000000206
07-15 15:14:35.624 1368-1368/? A/DEBUG: r12 0000000000001b35 r13 0000000000000006 r14 00007fff88f913c8 r15 0000000012ff9970
07-15 15:14:35.624 1368-1368/? A/DEBUG: cs 0000000000000033 ss 000000000000002b
07-15 15:14:35.624 1368-1368/? A/DEBUG: rip 00007fce9ccfb447 rbp 0000000000000009 rsp 00007fff88f90c88 eflags 0000000000000206
07-15 15:14:35.626 1368-1368/? A/DEBUG: backtrace:
07-15 15:14:35.626 1368-1368/? A/DEBUG: #00 pc 0000000000088447 /system/lib64/libc.so (tgkill+7)
07-15 15:14:35.626 1368-1368/? A/DEBUG: #01 pc 0000000000085b11 /system/lib64/libc.so (pthread_kill+65)
07-15 15:14:35.626 1368-1368/? A/DEBUG: #02 pc 000000000002e841 /system/lib64/libc.so (raise+17)
07-15 15:14:35.626 1368-1368/? A/DEBUG: #03 pc 00000000000288fd /system/lib64/libc.so (abort+61)
07-15 15:14:35.626 1368-1368/? A/DEBUG: #04 pc 00000000001bd2d1 /data/data/com.google.android.gms/files/com.google.android.gms.vision/ocr/libs/x86_64/libocr.so
07-15 15:14:35.626 1368-1368/? A/DEBUG: #05 pc 00000000001bd84d /data/data/com.google.android.gms/files/com.google.android.gms.vision/ocr/libs/x86_64/libocr.so
07-15 15:14:35.607 1368-1368/? W/debuggerd64: type=1400 audit(0.0:58): avc: denied { search } for name="com.google.android.gms" dev="dm-0" ino=114710 scontext=u:r:debuggerd:s0 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=dir permissive=0
07-15 15:14:35.627 1368-1368/? A/DEBUG: #06 pc 000000000004c7ec /data/data/com.google.android.gms/files/com.google.android.gms.vision/ocr/libs/x86_64/libocr.so
07-15 15:14:35.627 1368-1368/? A/DEBUG: #07 pc 0000000000118bf0 /data/data/com.google.android.gms/app_chimera/m/00000002/oat/x86_64/DynamiteModulesB_GmsCore_prodmnc_alldpi_release.odex (offset 0x332000)
這裏是我的裁剪功能:
private void cropImage() {
try{
Intent crop = new Intent("com.android.camera.action.CROP");
crop.setDataAndType(selectImage, "image/*");
crop.putExtra("crop", true);
crop.putExtra("outputX", 180);
crop.putExtra("outputY", 180);
crop.putExtra("aspectX", 3);
crop.putExtra("aspectY", 4);
crop.putExtra("scaleUpIfNeeded", true);
crop.putExtra("return-data", true);
startActivityForResult(crop, CROP_PIC);
}
catch(ActivityNotFoundException e){
e.printStackTrace();
Toast.makeText(MainActivity.this, "Error your phone does not support cropping!", Toast.LENGTH_LONG).show();
}
}
這裏是我的代碼將圖像設置到的ImageView在onActivityResult
方法
if(requestCode == CROP_PIC && data != null){
bitmap = (Bitmap) data.getExtras().get("data");
imageView.setImageBitmap(bitmap);
}
圖像獲取設置,我可以看到它,但按過程給我的錯誤