mobile_scanner
mobile_scanner copied to clipboard
Feature request: return just the scanned barcode, cropped from the whole frame
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!;
}
I think if we can get the right corner points from all platforms, we can let Flutter handle the cropping.