0

I am implementing a barcode scanner using MLKIT in my application (Kotlin). I need the barcode to be processed only when it is visible in a transparent rectangle in the center of the screen. as we see in the picture below.

PIC 1

Right now my App detects every barcode visible in the camera view as shown below. Is it possible to limit the detection area so the detection only reads from a rectangle in the middle of the screen?

Besides I would like to create a custom PreviewView for a barcode with cameraX, as shown in PIC 1. Thank you.

PIC 2

  • Try making two preview areas that show the same data but on different size. Then, only accept results from the small one :) – George Mar 21 '22 at 18:30
  • Checkout my article exactly on. For future reference that https://medium.com/@saiful103a/scan-barcode-only-when-they-are-inside-a-specific-area-of-the-preview-android-fcf8e02404d7 – saiful103a Oct 28 '22 at 05:54
  • Could you do this? I should do same thing. – Ahmet Yılmaz Nov 14 '22 at 19:04

1 Answers1

0

ML Kit doesn't support specifying interested area currently, so you have to either crop the preview image or filter out barcode results that not in the specified area. Similar question How do I make the camera focus only inside the rectangle and read the text inside the rectangle only in a flutter?

zhouyi
  • 226
  • 1
  • 4