2017-03-11 31 views
0

我正在做一个模块,我需要[拍摄图像 - >裁剪 - >将其转换为文本]。我已经完成,直到拍摄照片并裁剪它并在imageView中呈现它。但我无法将imageView中的图像转换为文本。如何将imageView中的图像转换为文本并在android中的textView中显示该文本?

这是代码:

protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
     if (resultCode == RESULT_OK) { 
      //user is returning from capturing an image using the camera 
      if(requestCode == CAMERA_CAPTURE){ 
       //get the Uri for the captured image 
       Uri uri = picUri; 
       //carry out the crop operation 
       performCrop(); 
       Log.d("picUri", uri.toString()); 

      } 

      else if(requestCode == PICK_IMAGE_REQUEST){ 
       picUri = data.getData(); 
       Log.d("uriGallery", picUri.toString()); 
       performCrop(); 
      } 

      //user is returning from cropping the image 
      else if(requestCode == PIC_CROP){ 
       //get the returned data 
       Bundle extras = data.getExtras(); 
       //get the cropped bitmap 
       Bitmap thePic = (Bitmap) extras.get("data"); 
       //display the returned cropped image 
       imageView.setImageBitmap(thePic); 

      } 

     } 
    } 

那么还有什么可以后怎么办[image.setImageBitmap(thePic)将其转换为文本,出现在一个TextView。 我在[image.setImageBitmap(thePic)]后尝试使用Google Vision API代码,但无法将其转换为文本。它显示错误,说 [jni_helper.cc:110位图的格式错误:4]
[致命信号6(SIGABRT),代码-6]

那么,如何解决这个问题。

+0

为了更好地帮助回答您的问题,我们更倾向于您的问题证明您已尝试自己解决您的问题,具体示例(通常是代码片段) ,以及您遇到的问题和错误的详细信息。请考虑编辑您的问题以包含[mcve]。 – KernelPanic

回答

相关问题