1

I want to scan driving license of a person like the gif below from my flutter app: The gif can be found here: Image Url

I looked for packages similar to the above image but did not find anything that might suit my needs. I also tried implementing object detection to detect the card object. It could detect the object but I could not implement the edge detection which will detect edges like the image and then take the picture. I would appreciate any sort of guidelines or direction on how I can achieve something like the image. Thanks in advance.

Update:

I am using object detection to get the boundingBox of the detected object.

final objects = await _objectDetector!.processImage(inputImage);

for (DetectedObject detectedObject in objects) {
  final rect = detectedObject.boundingBox;
}

I have a square container inside a Stack widget, from which I get the boundingRegion of the square container.

The problem I am facing, as the CameraController has a resolution of (720*1280), The right offset and bottom offset of the object captured inside the square portion of the screen is always greater than my widgets offset position. The left and top offsets seems to be fine but because of the camera resolution to be greater than screen the bottom and right offsets never matches.

Md. Kamrul Amin
  • 1,870
  • 1
  • 11
  • 33

1 Answers1

0

I just built a document scanner app: https://github.com/yushulx/flutter-document-scanner.

My way is to put the camera preview into a SizedBox in Stack. Then add a CustomPaint to completely cover the SizedBox. Now, you can draw anything you want over the camera preview without extra coordinate calculation. To fit the screen, move the Stack into a FittedBox:

FittedBox(
   fit: BoxFit.cover,
      child: Stack(
        ...
   ),
),

You can check out https://github.com/yushulx/flutter-document-scanner/blob/main/lib/camera_page.dart.

Try my demo: https://yushulx.me/flutter-document-scanner/.

yushulx
  • 11,695
  • 8
  • 37
  • 64