简体   繁体   中英

crop area of detected barcode from returned List<Barcode>

i have image(ImageInput) for scan barcode area using google_mlkit_barcode_scannin function, then it returned List that have cornerPoints and boundingBox

how to crop it as new image by cornerPoints or boundingBox..thanks

you can try use the Bitmap and Canvas

for eg

Bitmap original = BitmapFactory.decodeFile(input);
Bitmap bitmap = original.copy(Bitmap.Config.ARGB_8888, true);

//box that you have
int left = box[0];
int top = box[1];
int right = box[2];
int bottom = box[3];
Bitmap cropped = Bitmap.createBitmap(bitmap, left, top, right - left, bottom - top);

FileOutputStream out = new FileOutputStream("result.jpg")
cropped.compress(Bitmap.CompressFormat.JPEG, 100, out);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM