mobile_scanner icon indicating copy to clipboard operation
mobile_scanner copied to clipboard

Feature request: return just the scanned barcode, cropped from the whole frame

Open elliots opened this issue 2 years ago • 1 comments

I looked at this but couldn't find a nice way to do it in dart.

In swift, this looked like it was going in the right direction, but the returned image didn't look right.


   private func cropBarcode(image: CIImage, barcode: Barcode) -> CIImage {
        let corners = barcode.cornerPoints!;

        let filter = CIFilter(name: "CIPerspectiveCorrection")
        filter!.setValue( CIVector(cgPoint: corners[0].cgPointValue), forKey: "inputTopLeft")
        filter!.setValue( CIVector(cgPoint: corners[1].cgPointValue), forKey: "inputTopRight")
        filter!.setValue( CIVector(cgPoint: corners[3].cgPointValue), forKey: "inputBottomRight")
        filter!.setValue( CIVector(cgPoint: corners[2].cgPointValue), forKey: "inputBottomLeft")

        filter!.setValue(image, forKey: "inputImage")

        return filter!.outputImage!;
    }

elliots avatar Aug 17 '22 08:08 elliots

I think if we can get the right corner points from all platforms, we can let Flutter handle the cropping.

juliansteenbakker avatar Aug 24 '22 16:08 juliansteenbakker