In my app i'm having an activity which is having an imageview there i'm basically setting a bitmap into it now here i'm using google vision library to fetch text from images in I've succeeded in that however tricky part is that when imageview is clicked at particular position if it contains any text I want it to get highlighted and again if same is clicked I want to be unhighlighted it's kind of select and unselect effect i tried referring many answers but all of them seem to highlight all texts at runtime but I want only a particular to be highlighted when clicked at that position I guess for that I will need to get text position from images and compare it with touch event but I can't seem to find a way to do it here's my code which i'm using to get text from image:
copyimg.setImageBitmap(ImageCaptureActivity.mbitmap)
val textRecognizer = TextRecognizer.Builder(applicationContext).build()
val imageFrame = Frame.Builder()
.setBitmap(ImageCaptureActivity.mbitmap) // your image bitmap
.build()
var imageText = ""
val textBlocks = textRecognizer.detect(imageFrame)
for (i in 0 until textBlocks.size()) {
val textBlock = textBlocks.get(textBlocks.keyAt(i))
imageText = textBlock.value // return string
Log.i("Okaycheckthis:", imageText)
}