title: How to extract text form a specific block of the image? [ML-Kit]
body: <p>I m desperated. I have 16 TextViews. The goal is to take a picture of a prescription. What I want is to extract the right text for every Textview I have. This is my last problem. </p>
  
  <p>Here is the code of taking a photo, create a file, recognize the text and put it in a TextView.</p>
  
  <pre><code>private fun dispatchTakePictureIntent() {
      Intent(MediaStore.ACTION_IMAGE_CAPTURE).also { takePictureIntent -&gt;
          // Ensure that there's a camera activity to handle the intent
          takePictureIntent.resolveActivity(packageManager)?.also {
              // Create the File where the photo should go
  
              val photoFile: File? = try {
                  createImageFile()
              } catch (ex: IOException) {
                  // Error occurred while creating the File
                  null
              }
              // Continue only if the File was successfully created
              photoFile?.also {
                  photoURI = FileProvider.getUriForFile(
                      this,
                      "com.example.android.fileprovider2",
                      it
                  )
                  takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI)
                  startActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO)
                  /*if (REQUEST_TAKE_PHOTO == 1)
                  {
                      return imageView.setImageURI(photoURI)
                  }*/
  
              }
          }
      }
  }
  
  
  
  @Throws(IOException::class)
  private fun createImageFile(): File {
      // Create an image file name
      val timeStamp: String = SimpleDateFormat("yyyyMMdd_HHmmss").format(Date())
      val storageDir: File? = getExternalFilesDir(Environment.DIRECTORY_PICTURES)
      return File.createTempFile(
          "JPEG_${timeStamp}_", /* prefix */
          ".jpg", /* suffix */
          storageDir /* directory */
      ).apply {
          // Save a file: path for use with ACTION_VIEW intents
          currentPhotoPath = absolutePath
  
      }
  }
  
  
  
  
  
  
  
  
  
  
  
  fun startRecognizing(v: View) {
      if (imageView.drawable != null) {
          editText.setText("")
          v.isEnabled = false
          val bitmap = (imageView.drawable as BitmapDrawable).bitmap
          val image = FirebaseVisionImage.fromBitmap(bitmap)
          val detector = FirebaseVision.getInstance().onDeviceTextRecognizer
  
  
          detector.processImage(image)
              .addOnSuccessListener { firebaseVisionText -&gt;
                  v.isEnabled = true
                  processResultText(firebaseVisionText)
              }
              .addOnFailureListener {
                  v.isEnabled = true
                  editText.setText("Failed")
              }
      } else {
          Toast.makeText(this, "Select an Image First", Toast.LENGTH_LONG).show()
      }
  
  }
  
  private fun String.toEditable(): Editable =  Editable.Factory.getInstance().newEditable(this)
  
  
  private fun processResultText(resultText: FirebaseVisionText) {
      if (resultText.textBlocks.size == 0) {
          editText.setText("No Text Found")
          return
      }
      for (blocks in resultText.textBlocks) {
          val blockText = blocks.text
          val stringText  = resultText.text
          val stringTextSplit = stringText.lines()
          krankenkasse.text = stringTextSplit[1].toEditable()
          et2.text = stringTextSplit[4].toEditable()
          et3.text = stringTextSplit[5].toEditable()
          et4.text = stringTextSplit[6].toEditable()
          et5.text = stringTextSplit[7].toEditable()
          et6.text = stringTextSplit[8].toEditable()
          et7.text = stringTextSplit[9].toEditable()
          et8.text = stringTextSplit[11].toEditable()
          editText.append(blockText + "\n")
      }
  }
  </code></pre>
  
  <p>If you have questions. Please ask.</p>